@alore/auth-react-sdk 1.1.0-alpha.13 → 1.1.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types.d.ts +4 -1
- package/dist/utils/AloreAuth.d.ts +21 -0
- package/dist/utils/AloreAuth.js +28 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -72,7 +72,10 @@ type SessionUser = {
|
|
|
72
72
|
id: string;
|
|
73
73
|
lastLogin: string | null;
|
|
74
74
|
lastTransaction: string | null;
|
|
75
|
-
nickname: string;
|
|
75
|
+
nickname: string | null;
|
|
76
|
+
/** Provider-hosted profile photo URL, when the account was created or
|
|
77
|
+
* linked through social login. Always https; null otherwise. */
|
|
78
|
+
picture: string | null;
|
|
76
79
|
status: string;
|
|
77
80
|
accessToken: string;
|
|
78
81
|
refreshToken: string;
|
|
@@ -204,6 +204,27 @@ export declare class AloreAuth {
|
|
|
204
204
|
type: 'INITIALIZE';
|
|
205
205
|
forgeId?: string | null | undefined;
|
|
206
206
|
}) => Promise<ForgeData>;
|
|
207
|
+
/**
|
|
208
|
+
* Passwordless social sign-in.
|
|
209
|
+
*
|
|
210
|
+
* Sends an OIDC id_token, not an access token: an access token carries no
|
|
211
|
+
* audience the backend can verify, so the older googleLogin flow below
|
|
212
|
+
* cannot tell a token minted for this app from one minted for any other.
|
|
213
|
+
* On success the backend returns a full session — there is no OTP and no
|
|
214
|
+
* password step.
|
|
215
|
+
*/
|
|
216
|
+
socialLogin: (context: AuthMachineContext, event: {
|
|
217
|
+
type: 'SOCIAL_LOGIN';
|
|
218
|
+
payload: {
|
|
219
|
+
idToken: string;
|
|
220
|
+
providerName: string;
|
|
221
|
+
device?: string;
|
|
222
|
+
nonce?: string;
|
|
223
|
+
};
|
|
224
|
+
}) => Promise<{
|
|
225
|
+
sessionUser: any;
|
|
226
|
+
isNewUser: boolean;
|
|
227
|
+
}>;
|
|
207
228
|
googleLogin: (context: AuthMachineContext, event: {
|
|
208
229
|
type: 'GOOGLE_LOGIN';
|
|
209
230
|
payload: {
|
package/dist/utils/AloreAuth.js
CHANGED
|
@@ -405,6 +405,34 @@ export class AloreAuth {
|
|
|
405
405
|
yield this.throwParsedResponseError(response);
|
|
406
406
|
return data;
|
|
407
407
|
}),
|
|
408
|
+
/**
|
|
409
|
+
* Passwordless social sign-in.
|
|
410
|
+
*
|
|
411
|
+
* Sends an OIDC id_token, not an access token: an access token carries no
|
|
412
|
+
* audience the backend can verify, so the older googleLogin flow below
|
|
413
|
+
* cannot tell a token minted for this app from one minted for any other.
|
|
414
|
+
* On success the backend returns a full session — there is no OTP and no
|
|
415
|
+
* password step.
|
|
416
|
+
*/
|
|
417
|
+
socialLogin: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
418
|
+
const { idToken, providerName, device, nonce } = event.payload;
|
|
419
|
+
const { authProviderConfigs } = context;
|
|
420
|
+
const { firebaseCompatible } = authProviderConfigs || {};
|
|
421
|
+
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/social-login${firebaseCompatible ? `?firebaseCompatibleToken=${firebaseCompatible}` : ''}`, {
|
|
422
|
+
method: 'POST',
|
|
423
|
+
headers: {
|
|
424
|
+
'Content-Type': 'application/json',
|
|
425
|
+
},
|
|
426
|
+
body: JSON.stringify(Object.assign(Object.assign({ idToken, provider: providerName }, (device ? { device } : {})), (nonce ? { nonce } : {}))),
|
|
427
|
+
});
|
|
428
|
+
if (!response.ok)
|
|
429
|
+
yield this.throwParsedResponseError(response);
|
|
430
|
+
const sessionUser = yield response.json();
|
|
431
|
+
// 201 means the backend provisioned the account on this call. The
|
|
432
|
+
// consuming app keys its own user creation off that, so it has to survive
|
|
433
|
+
// as far as the onRegister/onLogin split in Auth.tsx.
|
|
434
|
+
return { sessionUser, isNewUser: response.status === 201 };
|
|
435
|
+
}),
|
|
408
436
|
// Google login flow
|
|
409
437
|
googleLogin: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
410
438
|
const { accessToken, providerName } = event.payload;
|