@alore/auth-react-sdk 1.0.4-alpha → 1.0.6-alpha
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 +5 -0
- package/dist/utils/AloreAuth.d.ts +3 -3
- package/dist/utils/AloreAuth.js +26 -11
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -36,7 +36,12 @@ export interface AuthProviderConfig {
|
|
|
36
36
|
logoUrl?: string;
|
|
37
37
|
socialProviders?: SocialProvider[];
|
|
38
38
|
enableWalletCreation?: boolean;
|
|
39
|
+
firebaseOptions?: FirebaseOptions;
|
|
39
40
|
}
|
|
41
|
+
type FirebaseOptions = {
|
|
42
|
+
firebaseCompatible?: boolean;
|
|
43
|
+
firebaseServiceAccountEmail?: string;
|
|
44
|
+
};
|
|
40
45
|
export interface AuthMachineContext {
|
|
41
46
|
authProviderConfigs?: AuthProviderConfig;
|
|
42
47
|
salt?: string;
|
|
@@ -60,7 +60,7 @@ export declare class AloreAuth {
|
|
|
60
60
|
type: 'SEND_REGISTRATION_EMAIL';
|
|
61
61
|
payload: {
|
|
62
62
|
email: string;
|
|
63
|
-
nickname
|
|
63
|
+
nickname?: string;
|
|
64
64
|
isForgeClaim?: boolean;
|
|
65
65
|
locale?: string;
|
|
66
66
|
};
|
|
@@ -83,7 +83,7 @@ export declare class AloreAuth {
|
|
|
83
83
|
} | {
|
|
84
84
|
error?: undefined;
|
|
85
85
|
}>;
|
|
86
|
-
verifyLogin: (
|
|
86
|
+
verifyLogin: (context: AuthMachineContext, event: {
|
|
87
87
|
type: 'VERIFY_LOGIN';
|
|
88
88
|
payload: {
|
|
89
89
|
email: string;
|
|
@@ -217,7 +217,7 @@ export declare class AloreAuth {
|
|
|
217
217
|
type: 'INITIALIZE';
|
|
218
218
|
forgeId?: string | null | undefined;
|
|
219
219
|
}) => Promise<ForgeData>;
|
|
220
|
-
googleLogin: (
|
|
220
|
+
googleLogin: (context: AuthMachineContext, event: {
|
|
221
221
|
type: 'GOOGLE_LOGIN';
|
|
222
222
|
payload: {
|
|
223
223
|
accessToken: string;
|
package/dist/utils/AloreAuth.js
CHANGED
|
@@ -25,7 +25,8 @@ export class AloreAuth {
|
|
|
25
25
|
// Email and password flow
|
|
26
26
|
retrieveSalt: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const { email } = event.payload;
|
|
28
|
-
const
|
|
28
|
+
const { credentialEmail } = context;
|
|
29
|
+
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/salt/${email || credentialEmail}`, {
|
|
29
30
|
headers: {
|
|
30
31
|
'Content-Type': 'application/json',
|
|
31
32
|
},
|
|
@@ -55,7 +56,9 @@ export class AloreAuth {
|
|
|
55
56
|
throw new Error((data === null || data === void 0 ? void 0 : data.message) || (data === null || data === void 0 ? void 0 : data.error) || data);
|
|
56
57
|
}),
|
|
57
58
|
completeRegistration: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
var _a;
|
|
58
60
|
const { email, nickname, passwordHash, device } = event.payload;
|
|
61
|
+
const { firebaseCompatible, firebaseServiceAccountEmail } = ((_a = context.authProviderConfigs) === null || _a === void 0 ? void 0 : _a.firebaseOptions) || {};
|
|
59
62
|
const response = yield this.fetchWithProgressiveBackoff('/auth/v1/account-registration', {
|
|
60
63
|
method: 'POST',
|
|
61
64
|
headers: {
|
|
@@ -66,6 +69,10 @@ export class AloreAuth {
|
|
|
66
69
|
nickname,
|
|
67
70
|
passwordHash,
|
|
68
71
|
device,
|
|
72
|
+
firebaseOptions: {
|
|
73
|
+
firebaseCompatible,
|
|
74
|
+
firebaseServiceAccountEmail,
|
|
75
|
+
},
|
|
69
76
|
}),
|
|
70
77
|
});
|
|
71
78
|
const data = yield response.json();
|
|
@@ -106,7 +113,7 @@ export class AloreAuth {
|
|
|
106
113
|
},
|
|
107
114
|
body: JSON.stringify({
|
|
108
115
|
email,
|
|
109
|
-
nickname,
|
|
116
|
+
nickname: nickname || null,
|
|
110
117
|
}),
|
|
111
118
|
});
|
|
112
119
|
if (response.ok) {
|
|
@@ -135,9 +142,10 @@ export class AloreAuth {
|
|
|
135
142
|
return { error: response === null || response === void 0 ? void 0 : response.statusText };
|
|
136
143
|
return {};
|
|
137
144
|
}),
|
|
138
|
-
verifyLogin: (
|
|
139
|
-
var
|
|
145
|
+
verifyLogin: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
var _b, _c;
|
|
140
147
|
const { email, passwordHash, device, locale } = event.payload;
|
|
148
|
+
const { credentialEmail } = context;
|
|
141
149
|
const searchParams = new URLSearchParams();
|
|
142
150
|
const url = '/auth/v1/login-verification';
|
|
143
151
|
if (locale) {
|
|
@@ -152,7 +160,7 @@ export class AloreAuth {
|
|
|
152
160
|
'Content-Type': 'application/json',
|
|
153
161
|
},
|
|
154
162
|
body: JSON.stringify({
|
|
155
|
-
email,
|
|
163
|
+
email: email || credentialEmail,
|
|
156
164
|
passwordHash,
|
|
157
165
|
device,
|
|
158
166
|
}),
|
|
@@ -162,7 +170,7 @@ export class AloreAuth {
|
|
|
162
170
|
if (response.status === 403) {
|
|
163
171
|
return { active2fa: data };
|
|
164
172
|
}
|
|
165
|
-
if (((
|
|
173
|
+
if (((_b = data === null || data === void 0 ? void 0 : data.error) === null || _b === void 0 ? void 0 : _b.includes('2FA')) || ((_c = data === null || data === void 0 ? void 0 : data.error) === null || _c === void 0 ? void 0 : _c.includes('device'))) {
|
|
166
174
|
return { error: data === null || data === void 0 ? void 0 : data.error };
|
|
167
175
|
}
|
|
168
176
|
throw new Error((data === null || data === void 0 ? void 0 : data.message) || (data === null || data === void 0 ? void 0 : data.error) || data);
|
|
@@ -213,9 +221,9 @@ export class AloreAuth {
|
|
|
213
221
|
}),
|
|
214
222
|
// Passkey login flow
|
|
215
223
|
startPasskeyAuth: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
-
var
|
|
224
|
+
var _d;
|
|
217
225
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
218
|
-
const email = (
|
|
226
|
+
const email = (_d = event.payload) === null || _d === void 0 ? void 0 : _d.email;
|
|
219
227
|
const searchParams = new URLSearchParams();
|
|
220
228
|
const url = '/auth/v1/login-passkey';
|
|
221
229
|
if (rpDomain) {
|
|
@@ -232,7 +240,7 @@ export class AloreAuth {
|
|
|
232
240
|
throw new Error(data.message || data.error || data);
|
|
233
241
|
}),
|
|
234
242
|
finishPasskeyAuth: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
235
|
-
const { rpDomain } = context.authProviderConfigs || {};
|
|
243
|
+
const { rpDomain, firebaseOptions } = context.authProviderConfigs || {};
|
|
236
244
|
const { passkeyAuth } = event.payload;
|
|
237
245
|
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/login-passkey-finish`, {
|
|
238
246
|
method: 'POST',
|
|
@@ -243,6 +251,7 @@ export class AloreAuth {
|
|
|
243
251
|
passkeyAuth,
|
|
244
252
|
sessionId: context.sessionId,
|
|
245
253
|
rpOrigin: rpDomain,
|
|
254
|
+
firebaseOptions,
|
|
246
255
|
}),
|
|
247
256
|
});
|
|
248
257
|
const data = yield response.json();
|
|
@@ -330,13 +339,16 @@ export class AloreAuth {
|
|
|
330
339
|
}),
|
|
331
340
|
verifyEmail2fa: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
332
341
|
const { email, passwordHash, secureCode } = event.payload;
|
|
342
|
+
const { credentialEmail, authProviderConfigs } = context;
|
|
343
|
+
const { firebaseOptions } = authProviderConfigs || {};
|
|
333
344
|
const response = yield this.fetchWithProgressiveBackoff('/auth/v1/email-2fa-verification', {
|
|
334
345
|
method: 'POST',
|
|
335
346
|
body: JSON.stringify({
|
|
336
|
-
email,
|
|
347
|
+
email: email || credentialEmail,
|
|
337
348
|
passwordHash,
|
|
338
349
|
emailCode: secureCode,
|
|
339
350
|
sessionId: context.sessionId,
|
|
351
|
+
firebaseOptions,
|
|
340
352
|
}),
|
|
341
353
|
headers: {
|
|
342
354
|
'Content-Type': 'application/json',
|
|
@@ -390,8 +402,10 @@ export class AloreAuth {
|
|
|
390
402
|
return data;
|
|
391
403
|
}),
|
|
392
404
|
// Google login flow
|
|
393
|
-
googleLogin: (
|
|
405
|
+
googleLogin: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
394
406
|
const { accessToken, providerName } = event.payload;
|
|
407
|
+
const { authProviderConfigs } = context;
|
|
408
|
+
const { firebaseOptions } = authProviderConfigs || {};
|
|
395
409
|
const response = yield this.fetchWithProgressiveBackoff('/auth/v1/google-login', {
|
|
396
410
|
method: 'POST',
|
|
397
411
|
headers: {
|
|
@@ -400,6 +414,7 @@ export class AloreAuth {
|
|
|
400
414
|
body: JSON.stringify({
|
|
401
415
|
accessToken,
|
|
402
416
|
provider: providerName,
|
|
417
|
+
firebaseOptions,
|
|
403
418
|
}),
|
|
404
419
|
});
|
|
405
420
|
const data = yield response.json();
|