@alore/auth-react-sdk 1.1.0-alpha.12 → 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 +31 -1
- package/package.json +2 -2
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
|
@@ -297,7 +297,9 @@ export class AloreAuth {
|
|
|
297
297
|
throw new Error(optionsResponse.statusText);
|
|
298
298
|
}
|
|
299
299
|
const optionsData = yield optionsResponse.json();
|
|
300
|
-
const credential = yield startAuthentication(
|
|
300
|
+
const credential = yield startAuthentication({
|
|
301
|
+
optionsJSON: optionsData.requestChallengeResponse.publicKey,
|
|
302
|
+
}).catch((err) => {
|
|
301
303
|
throw new Error(err);
|
|
302
304
|
});
|
|
303
305
|
const response = yield this.fetchWithProgressiveBackoff('/auth/v1/hw-2fa-finish-verification', {
|
|
@@ -403,6 +405,34 @@ export class AloreAuth {
|
|
|
403
405
|
yield this.throwParsedResponseError(response);
|
|
404
406
|
return data;
|
|
405
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
|
+
}),
|
|
406
436
|
// Google login flow
|
|
407
437
|
googleLogin: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
408
438
|
const { accessToken, providerName } = event.payload;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alore/auth-react-sdk",
|
|
3
|
-
"version": "1.1.0-alpha.
|
|
3
|
+
"version": "1.1.0-alpha.14",
|
|
4
4
|
"repository": "https://github.com/0xCarbon/alore-js",
|
|
5
5
|
"description": "SDK for Alore Auth",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"node": ">=20.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@simplewebauthn/browser": "
|
|
23
|
+
"@simplewebauthn/browser": "13.3.0",
|
|
24
24
|
"argon2-browser": "1.18.0",
|
|
25
25
|
"ethers": "6.7.1",
|
|
26
26
|
"js-cookie": "3.0.5",
|