feat(auth): Google/Apple login, named custom providers, identity link/unlink
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
name: rudder-web-sdk
|
||||
description: Use when working with the Rudder TypeScript/JavaScript SDK (@rudder/js-sdk) — the browser/player-facing SDK for the Rudder LiveOps platform. Covers client setup, device/custom auth, observable domains (player, inventory, catalog, stores, remote config, storage), leaderboards, quests, battle pass, scenario effects, and error handling. Load this whenever code imports from @rudder/js-sdk or RudderClient appears.
|
||||
description: Use when working with the Rudder TypeScript/JavaScript SDK (@rudder/js-sdk) — the browser/player-facing SDK for the Rudder LiveOps platform. Covers client setup, device/google/apple/custom auth, identity linking, observable domains (player, inventory, catalog, stores, remote config, storage), leaderboards, quests, battle pass, scenario effects, and error handling. Load this whenever code imports from @rudder/js-sdk or RudderClient appears.
|
||||
---
|
||||
|
||||
# Rudder Web SDK (@rudder/js-sdk)
|
||||
@@ -51,12 +51,22 @@ drop cached state.
|
||||
|
||||
```ts
|
||||
await client.auth.loginWithDevice({ region, language, nickname }); // device id auto-generated/persisted
|
||||
await client.auth.loginWithCustom({ customData, region, language, nickname });
|
||||
await client.auth.loginWithGoogle({ idToken, region, language, nickname });
|
||||
await client.auth.loginWithApple({ idToken, region, language, nickname });
|
||||
await client.auth.loginWithCustom({ customData, provider?, region, language, nickname });
|
||||
// identity linking (requires an active session):
|
||||
await client.auth.linkWithGoogle(idToken);
|
||||
await client.auth.linkWithApple(idToken);
|
||||
await client.auth.linkWithCustom({ customData, provider? });
|
||||
await client.auth.unlinkIdentity(provider); // 'device' | 'google' | 'apple' | 'custom' | 'custom:<name>'
|
||||
client.auth.logout();
|
||||
client.auth.isAuthenticated; // boolean
|
||||
client.auth.onAuthStateChange(cb); // fires immediately, returns unsubscribe
|
||||
```
|
||||
|
||||
Linked identities are listed on the profile: `client.player.data.identities`
|
||||
(`PlayerProfileIdentity { provider, subject, createdAt }`).
|
||||
|
||||
Tokens are saved to the `TokenStore` automatically. The transport injects
|
||||
`Authorization: Bearer <token>`, retries GETs, and single-flight refreshes on
|
||||
401; a failed refresh clears tokens and emits `signed-out`. Details:
|
||||
|
||||
Reference in New Issue
Block a user