@alore/auth-react-sdk 1.1.0-alpha.14 → 1.1.0-alpha.15
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 +6 -0
- package/dist/utils/AloreAuth.d.ts +12 -0
- package/dist/utils/AloreAuth.js +32 -4
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -44,6 +44,12 @@ export interface AuthMachineContext {
|
|
|
44
44
|
error?: string;
|
|
45
45
|
active2fa?: TwoFactorAuth[];
|
|
46
46
|
sessionId?: string;
|
|
47
|
+
socialChallenge?: {
|
|
48
|
+
sessionId: string;
|
|
49
|
+
idToken: string;
|
|
50
|
+
providerName: string;
|
|
51
|
+
device?: string;
|
|
52
|
+
};
|
|
47
53
|
registerUser?: {
|
|
48
54
|
email: string;
|
|
49
55
|
nickname: string;
|
|
@@ -220,10 +220,22 @@ export declare class AloreAuth {
|
|
|
220
220
|
providerName: string;
|
|
221
221
|
device?: string;
|
|
222
222
|
nonce?: string;
|
|
223
|
+
sessionId?: string;
|
|
224
|
+
emailCode?: string;
|
|
223
225
|
};
|
|
224
226
|
}) => Promise<{
|
|
227
|
+
emailChallenge: {
|
|
228
|
+
sessionId: any;
|
|
229
|
+
idToken: string;
|
|
230
|
+
providerName: string;
|
|
231
|
+
device: string | undefined;
|
|
232
|
+
};
|
|
233
|
+
sessionUser?: undefined;
|
|
234
|
+
isNewUser?: undefined;
|
|
235
|
+
} | {
|
|
225
236
|
sessionUser: any;
|
|
226
237
|
isNewUser: boolean;
|
|
238
|
+
emailChallenge?: undefined;
|
|
227
239
|
}>;
|
|
228
240
|
googleLogin: (context: AuthMachineContext, event: {
|
|
229
241
|
type: 'GOOGLE_LOGIN';
|
package/dist/utils/AloreAuth.js
CHANGED
|
@@ -415,16 +415,44 @@ export class AloreAuth {
|
|
|
415
415
|
* password step.
|
|
416
416
|
*/
|
|
417
417
|
socialLogin: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
418
|
-
const { idToken, providerName, device, nonce } = event.payload;
|
|
418
|
+
const { idToken, providerName, device, nonce, sessionId, emailCode } = event.payload;
|
|
419
419
|
const { authProviderConfigs } = context;
|
|
420
|
-
const { firebaseCompatible } = authProviderConfigs || {};
|
|
421
|
-
const
|
|
420
|
+
const { firebaseCompatible, locale } = authProviderConfigs || {};
|
|
421
|
+
const query = new URLSearchParams();
|
|
422
|
+
if (firebaseCompatible)
|
|
423
|
+
query.set('firebaseCompatibleToken', String(firebaseCompatible));
|
|
424
|
+
if (locale)
|
|
425
|
+
query.set('locale', locale);
|
|
426
|
+
const queryString = query.toString();
|
|
427
|
+
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/social-login${queryString ? `?${queryString}` : ''}`, {
|
|
422
428
|
method: 'POST',
|
|
423
429
|
headers: {
|
|
424
430
|
'Content-Type': 'application/json',
|
|
425
431
|
},
|
|
426
|
-
body: JSON.stringify(Object.assign(Object.assign({ idToken, provider: providerName }, (device ? { device } : {})), (nonce ? { nonce } : {}))),
|
|
432
|
+
body: JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({ idToken, provider: providerName }, (device ? { device } : {})), (nonce ? { nonce } : {})), (sessionId ? { sessionId } : {})), (emailCode ? { emailCode } : {}))),
|
|
427
433
|
});
|
|
434
|
+
// Not every 403 here is a refusal. Where the provider does not vouch for
|
|
435
|
+
// the address — Microsoft never does, since Entra carries no
|
|
436
|
+
// email_verified claim — the backend emails a code to the address the
|
|
437
|
+
// token claimed and hands back the session carrying it. The flow
|
|
438
|
+
// continues by calling this same endpoint again with that session and
|
|
439
|
+
// the code.
|
|
440
|
+
if (response.status === 403) {
|
|
441
|
+
const challenge = yield response
|
|
442
|
+
.clone()
|
|
443
|
+
.json()
|
|
444
|
+
.catch(() => null);
|
|
445
|
+
if ((challenge === null || challenge === void 0 ? void 0 : challenge.error) === 'SOCIAL_EMAIL_VERIFICATION_REQUIRED' && (challenge === null || challenge === void 0 ? void 0 : challenge.sessionId)) {
|
|
446
|
+
return {
|
|
447
|
+
emailChallenge: {
|
|
448
|
+
sessionId: challenge.sessionId,
|
|
449
|
+
idToken,
|
|
450
|
+
providerName,
|
|
451
|
+
device,
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
}
|
|
428
456
|
if (!response.ok)
|
|
429
457
|
yield this.throwParsedResponseError(response);
|
|
430
458
|
const sessionUser = yield response.json();
|