@alore/auth-react-sdk 1.0.3-alpha → 1.0.5-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 +8 -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
|
@@ -13,11 +13,13 @@ export type KeyDerivationFunction = 'argon2d' | 'pbkdf2';
|
|
|
13
13
|
* @property requireUsername - Optional boolean to require username.
|
|
14
14
|
* @property passwordMinLength - Optional number for password minimum length.
|
|
15
15
|
* @property enablePasskeys - Optional boolean to enable passkeys.
|
|
16
|
+
* @property enablePasswords - Optional boolean to enable passwords.
|
|
16
17
|
* @property socialLoginEnabled - Optional boolean to enable social login.
|
|
17
18
|
* @property privacyPolicyUrl - Optional string for privacy policy URL.
|
|
18
19
|
* @property termsOfServiceUrl - Optional string for terms of service URL.
|
|
19
20
|
* @property logoUrl - Optional string for logo URL.
|
|
20
21
|
* @property socialProviders - Optional social login providers.
|
|
22
|
+
* @property enableWalletCreation - Optional boolean to enable wallet creation.
|
|
21
23
|
*/
|
|
22
24
|
export interface AuthProviderConfig {
|
|
23
25
|
rpDomain?: string;
|
|
@@ -33,7 +35,13 @@ export interface AuthProviderConfig {
|
|
|
33
35
|
termsOfServiceUrl?: string;
|
|
34
36
|
logoUrl?: string;
|
|
35
37
|
socialProviders?: SocialProvider[];
|
|
38
|
+
enableWalletCreation?: boolean;
|
|
39
|
+
firebaseOptions?: FirebaseOptions;
|
|
36
40
|
}
|
|
41
|
+
type FirebaseOptions = {
|
|
42
|
+
firebaseCompatible?: boolean;
|
|
43
|
+
firebaseServiceAccountEmail?: string;
|
|
44
|
+
};
|
|
37
45
|
export interface AuthMachineContext {
|
|
38
46
|
authProviderConfigs?: AuthProviderConfig;
|
|
39
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);
|
|
@@ -191,7 +199,7 @@ export class AloreAuth {
|
|
|
191
199
|
return data;
|
|
192
200
|
}),
|
|
193
201
|
finishRegisterPasskey: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
194
|
-
const { rpDomain } = context.authProviderConfigs || {};
|
|
202
|
+
const { rpDomain, firebaseOptions } = context.authProviderConfigs || {};
|
|
195
203
|
const { email, nickname, device, passkeyRegistration } = event.payload || {};
|
|
196
204
|
const response = yield this.fetchWithProgressiveBackoff('/auth/v1/account-registration-passkey-finish', {
|
|
197
205
|
method: 'POST',
|
|
@@ -205,6 +213,7 @@ export class AloreAuth {
|
|
|
205
213
|
passkeyRegistration,
|
|
206
214
|
sessionId: context.sessionId,
|
|
207
215
|
rpOrigin: rpDomain,
|
|
216
|
+
firebaseOptions,
|
|
208
217
|
}),
|
|
209
218
|
});
|
|
210
219
|
const data = yield response.json();
|
|
@@ -213,9 +222,9 @@ export class AloreAuth {
|
|
|
213
222
|
}),
|
|
214
223
|
// Passkey login flow
|
|
215
224
|
startPasskeyAuth: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
216
|
-
var
|
|
225
|
+
var _d;
|
|
217
226
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
218
|
-
const email = (
|
|
227
|
+
const email = (_d = event.payload) === null || _d === void 0 ? void 0 : _d.email;
|
|
219
228
|
const searchParams = new URLSearchParams();
|
|
220
229
|
const url = '/auth/v1/login-passkey';
|
|
221
230
|
if (rpDomain) {
|
|
@@ -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();
|