@alore/auth-react-sdk 1.0.5-alpha → 1.0.7-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 +1 -5
- package/dist/utils/AloreAuth.js +13 -21
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -36,12 +36,8 @@ export interface AuthProviderConfig {
|
|
|
36
36
|
logoUrl?: string;
|
|
37
37
|
socialProviders?: SocialProvider[];
|
|
38
38
|
enableWalletCreation?: boolean;
|
|
39
|
-
firebaseOptions?: FirebaseOptions;
|
|
40
|
-
}
|
|
41
|
-
type FirebaseOptions = {
|
|
42
39
|
firebaseCompatible?: boolean;
|
|
43
|
-
|
|
44
|
-
};
|
|
40
|
+
}
|
|
45
41
|
export interface AuthMachineContext {
|
|
46
42
|
authProviderConfigs?: AuthProviderConfig;
|
|
47
43
|
salt?: string;
|
package/dist/utils/AloreAuth.js
CHANGED
|
@@ -56,10 +56,9 @@ export class AloreAuth {
|
|
|
56
56
|
throw new Error((data === null || data === void 0 ? void 0 : data.message) || (data === null || data === void 0 ? void 0 : data.error) || data);
|
|
57
57
|
}),
|
|
58
58
|
completeRegistration: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
var _a;
|
|
60
59
|
const { email, nickname, passwordHash, device } = event.payload;
|
|
61
|
-
const { firebaseCompatible
|
|
62
|
-
const response = yield this.fetchWithProgressiveBackoff(
|
|
60
|
+
const { firebaseCompatible } = context.authProviderConfigs || {};
|
|
61
|
+
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/account-registration${firebaseCompatible ? `?firebaseCompatibleToken=${firebaseCompatible}` : ''}`, {
|
|
63
62
|
method: 'POST',
|
|
64
63
|
headers: {
|
|
65
64
|
'Content-Type': 'application/json',
|
|
@@ -69,10 +68,6 @@ export class AloreAuth {
|
|
|
69
68
|
nickname,
|
|
70
69
|
passwordHash,
|
|
71
70
|
device,
|
|
72
|
-
firebaseOptions: {
|
|
73
|
-
firebaseCompatible,
|
|
74
|
-
firebaseServiceAccountEmail,
|
|
75
|
-
},
|
|
76
71
|
}),
|
|
77
72
|
});
|
|
78
73
|
const data = yield response.json();
|
|
@@ -143,7 +138,7 @@ export class AloreAuth {
|
|
|
143
138
|
return {};
|
|
144
139
|
}),
|
|
145
140
|
verifyLogin: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
var
|
|
141
|
+
var _a, _b;
|
|
147
142
|
const { email, passwordHash, device, locale } = event.payload;
|
|
148
143
|
const { credentialEmail } = context;
|
|
149
144
|
const searchParams = new URLSearchParams();
|
|
@@ -170,7 +165,7 @@ export class AloreAuth {
|
|
|
170
165
|
if (response.status === 403) {
|
|
171
166
|
return { active2fa: data };
|
|
172
167
|
}
|
|
173
|
-
if (((
|
|
168
|
+
if (((_a = data === null || data === void 0 ? void 0 : data.error) === null || _a === void 0 ? void 0 : _a.includes('2FA')) || ((_b = data === null || data === void 0 ? void 0 : data.error) === null || _b === void 0 ? void 0 : _b.includes('device'))) {
|
|
174
169
|
return { error: data === null || data === void 0 ? void 0 : data.error };
|
|
175
170
|
}
|
|
176
171
|
throw new Error((data === null || data === void 0 ? void 0 : data.message) || (data === null || data === void 0 ? void 0 : data.error) || data);
|
|
@@ -199,7 +194,7 @@ export class AloreAuth {
|
|
|
199
194
|
return data;
|
|
200
195
|
}),
|
|
201
196
|
finishRegisterPasskey: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
202
|
-
const { rpDomain
|
|
197
|
+
const { rpDomain } = context.authProviderConfigs || {};
|
|
203
198
|
const { email, nickname, device, passkeyRegistration } = event.payload || {};
|
|
204
199
|
const response = yield this.fetchWithProgressiveBackoff('/auth/v1/account-registration-passkey-finish', {
|
|
205
200
|
method: 'POST',
|
|
@@ -213,7 +208,6 @@ export class AloreAuth {
|
|
|
213
208
|
passkeyRegistration,
|
|
214
209
|
sessionId: context.sessionId,
|
|
215
210
|
rpOrigin: rpDomain,
|
|
216
|
-
firebaseOptions,
|
|
217
211
|
}),
|
|
218
212
|
});
|
|
219
213
|
const data = yield response.json();
|
|
@@ -222,9 +216,9 @@ export class AloreAuth {
|
|
|
222
216
|
}),
|
|
223
217
|
// Passkey login flow
|
|
224
218
|
startPasskeyAuth: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
225
|
-
var
|
|
219
|
+
var _c;
|
|
226
220
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
227
|
-
const email = (
|
|
221
|
+
const email = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.email;
|
|
228
222
|
const searchParams = new URLSearchParams();
|
|
229
223
|
const url = '/auth/v1/login-passkey';
|
|
230
224
|
if (rpDomain) {
|
|
@@ -241,9 +235,9 @@ export class AloreAuth {
|
|
|
241
235
|
throw new Error(data.message || data.error || data);
|
|
242
236
|
}),
|
|
243
237
|
finishPasskeyAuth: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
const { rpDomain } = context.authProviderConfigs || {};
|
|
238
|
+
const { rpDomain, firebaseCompatible } = context.authProviderConfigs || {};
|
|
245
239
|
const { passkeyAuth } = event.payload;
|
|
246
|
-
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/login-passkey-finish`, {
|
|
240
|
+
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/login-passkey-finish${firebaseCompatible ? `?firebaseCompatibleToken=${firebaseCompatible}` : ''}`, {
|
|
247
241
|
method: 'POST',
|
|
248
242
|
headers: {
|
|
249
243
|
'Content-Type': 'application/json',
|
|
@@ -340,15 +334,14 @@ export class AloreAuth {
|
|
|
340
334
|
verifyEmail2fa: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
341
335
|
const { email, passwordHash, secureCode } = event.payload;
|
|
342
336
|
const { credentialEmail, authProviderConfigs } = context;
|
|
343
|
-
const {
|
|
344
|
-
const response = yield this.fetchWithProgressiveBackoff(
|
|
337
|
+
const { firebaseCompatible } = authProviderConfigs || {};
|
|
338
|
+
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/email-2fa-verification${firebaseCompatible ? `?firebaseCompatibleToken=${firebaseCompatible}` : ''}`, {
|
|
345
339
|
method: 'POST',
|
|
346
340
|
body: JSON.stringify({
|
|
347
341
|
email: email || credentialEmail,
|
|
348
342
|
passwordHash,
|
|
349
343
|
emailCode: secureCode,
|
|
350
344
|
sessionId: context.sessionId,
|
|
351
|
-
firebaseOptions,
|
|
352
345
|
}),
|
|
353
346
|
headers: {
|
|
354
347
|
'Content-Type': 'application/json',
|
|
@@ -405,8 +398,8 @@ export class AloreAuth {
|
|
|
405
398
|
googleLogin: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
406
399
|
const { accessToken, providerName } = event.payload;
|
|
407
400
|
const { authProviderConfigs } = context;
|
|
408
|
-
const {
|
|
409
|
-
const response = yield this.fetchWithProgressiveBackoff(
|
|
401
|
+
const { firebaseCompatible } = authProviderConfigs || {};
|
|
402
|
+
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/google-login${firebaseCompatible ? `?firebaseCompatibleToken=${firebaseCompatible}` : ''}`, {
|
|
410
403
|
method: 'POST',
|
|
411
404
|
headers: {
|
|
412
405
|
'Content-Type': 'application/json',
|
|
@@ -414,7 +407,6 @@ export class AloreAuth {
|
|
|
414
407
|
body: JSON.stringify({
|
|
415
408
|
accessToken,
|
|
416
409
|
provider: providerName,
|
|
417
|
-
firebaseOptions,
|
|
418
410
|
}),
|
|
419
411
|
});
|
|
420
412
|
const data = yield response.json();
|