@alore/auth-react-sdk 1.0.1-alpha → 1.0.3-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 +2 -2
- package/dist/utils/AloreAuth.d.ts +7 -4
- package/dist/utils/AloreAuth.js +15 -15
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export interface AuthProviderConfig {
|
|
|
27
27
|
requireUsername?: boolean;
|
|
28
28
|
passwordMinLength?: number;
|
|
29
29
|
enablePasskeys?: boolean;
|
|
30
|
+
enablePasswords?: boolean;
|
|
30
31
|
socialLoginEnabled?: boolean;
|
|
31
32
|
privacyPolicyUrl?: string;
|
|
32
33
|
termsOfServiceUrl?: string;
|
|
@@ -91,11 +92,10 @@ export interface ForgeData {
|
|
|
91
92
|
}
|
|
92
93
|
export interface SocialProvider {
|
|
93
94
|
id: string;
|
|
94
|
-
authProviderConfigId: string;
|
|
95
95
|
providerName: string;
|
|
96
96
|
clientId: string;
|
|
97
97
|
enabled?: boolean;
|
|
98
|
-
createdAt
|
|
98
|
+
createdAt?: string;
|
|
99
99
|
updatedAt?: string;
|
|
100
100
|
}
|
|
101
101
|
export {};
|
|
@@ -219,7 +219,10 @@ export declare class AloreAuth {
|
|
|
219
219
|
}) => Promise<ForgeData>;
|
|
220
220
|
googleLogin: (_: AuthMachineContext, event: {
|
|
221
221
|
type: 'GOOGLE_LOGIN';
|
|
222
|
-
|
|
222
|
+
payload: {
|
|
223
|
+
accessToken: string;
|
|
224
|
+
providerName: string;
|
|
225
|
+
};
|
|
223
226
|
}) => Promise<{
|
|
224
227
|
googleOtpCode: any;
|
|
225
228
|
salt: any;
|
|
@@ -230,10 +233,10 @@ export declare class AloreAuth {
|
|
|
230
233
|
};
|
|
231
234
|
sessionId: any;
|
|
232
235
|
isNewUser?: undefined;
|
|
233
|
-
|
|
236
|
+
socialProviderRegisterUser?: undefined;
|
|
234
237
|
} | {
|
|
235
238
|
isNewUser: boolean;
|
|
236
|
-
|
|
239
|
+
socialProviderRegisterUser: {
|
|
237
240
|
email: any;
|
|
238
241
|
nickname: any;
|
|
239
242
|
salt: any;
|
|
@@ -248,7 +251,7 @@ export declare class AloreAuth {
|
|
|
248
251
|
googleUser?: undefined;
|
|
249
252
|
sessionId?: undefined;
|
|
250
253
|
isNewUser?: undefined;
|
|
251
|
-
|
|
254
|
+
socialProviderRegisterUser?: undefined;
|
|
252
255
|
}>;
|
|
253
256
|
verifyGoogleLogin: (context: AuthMachineContext, event: {
|
|
254
257
|
type: 'COMPLETE_GOOGLE_SIGN_IN';
|
package/dist/utils/AloreAuth.js
CHANGED
|
@@ -48,13 +48,11 @@ export class AloreAuth {
|
|
|
48
48
|
sessionId: context.sessionId,
|
|
49
49
|
}),
|
|
50
50
|
});
|
|
51
|
-
if (
|
|
52
|
-
const data = yield response.json();
|
|
53
|
-
throw new Error((data === null || data === void 0 ? void 0 : data.message) || (data === null || data === void 0 ? void 0 : data.error) || data);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
51
|
+
if (response.ok) {
|
|
56
52
|
return {};
|
|
57
53
|
}
|
|
54
|
+
const data = yield response.json();
|
|
55
|
+
throw new Error((data === null || data === void 0 ? void 0 : data.message) || (data === null || data === void 0 ? void 0 : data.error) || data);
|
|
58
56
|
}),
|
|
59
57
|
completeRegistration: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
60
58
|
const { email, nickname, passwordHash, device } = event.payload;
|
|
@@ -176,15 +174,15 @@ export class AloreAuth {
|
|
|
176
174
|
// Passkey registration flow
|
|
177
175
|
startRegisterPasskey: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
178
176
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
179
|
-
const { email, nickname, device } = event.payload;
|
|
177
|
+
const { email, nickname, device } = event.payload || context.registerUser;
|
|
180
178
|
const startPasskeyRegistrationResponse = yield this.fetchWithProgressiveBackoff('/auth/v1/account-registration-passkey', {
|
|
181
179
|
method: 'POST',
|
|
182
180
|
headers: {
|
|
183
181
|
'Content-Type': 'application/json',
|
|
184
182
|
},
|
|
185
183
|
body: JSON.stringify({
|
|
186
|
-
userEmail: email,
|
|
187
|
-
userNickname: nickname,
|
|
184
|
+
userEmail: email || null,
|
|
185
|
+
userNickname: nickname || null,
|
|
188
186
|
userDevice: device,
|
|
189
187
|
rpOrigin: rpDomain,
|
|
190
188
|
}),
|
|
@@ -194,15 +192,15 @@ export class AloreAuth {
|
|
|
194
192
|
}),
|
|
195
193
|
finishRegisterPasskey: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
196
194
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
197
|
-
const { email, nickname, device, passkeyRegistration } = event.payload;
|
|
195
|
+
const { email, nickname, device, passkeyRegistration } = event.payload || {};
|
|
198
196
|
const response = yield this.fetchWithProgressiveBackoff('/auth/v1/account-registration-passkey-finish', {
|
|
199
197
|
method: 'POST',
|
|
200
198
|
headers: {
|
|
201
199
|
'Content-Type': 'application/json',
|
|
202
200
|
},
|
|
203
201
|
body: JSON.stringify({
|
|
204
|
-
userEmail: email,
|
|
205
|
-
userNickname: nickname,
|
|
202
|
+
userEmail: email || null,
|
|
203
|
+
userNickname: nickname || null,
|
|
206
204
|
userDevice: device,
|
|
207
205
|
passkeyRegistration,
|
|
208
206
|
sessionId: context.sessionId,
|
|
@@ -217,7 +215,7 @@ export class AloreAuth {
|
|
|
217
215
|
startPasskeyAuth: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
218
216
|
var _c;
|
|
219
217
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
220
|
-
const email =
|
|
218
|
+
const email = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.email;
|
|
221
219
|
const searchParams = new URLSearchParams();
|
|
222
220
|
const url = '/auth/v1/login-passkey';
|
|
223
221
|
if (rpDomain) {
|
|
@@ -231,6 +229,7 @@ export class AloreAuth {
|
|
|
231
229
|
const data = yield startAuthResponse.json();
|
|
232
230
|
if (startAuthResponse.ok)
|
|
233
231
|
return data;
|
|
232
|
+
throw new Error(data.message || data.error || data);
|
|
234
233
|
}),
|
|
235
234
|
finishPasskeyAuth: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
236
235
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
@@ -392,14 +391,15 @@ export class AloreAuth {
|
|
|
392
391
|
}),
|
|
393
392
|
// Google login flow
|
|
394
393
|
googleLogin: (_, event) => __awaiter(this, void 0, void 0, function* () {
|
|
395
|
-
const {
|
|
394
|
+
const { accessToken, providerName } = event.payload;
|
|
396
395
|
const response = yield this.fetchWithProgressiveBackoff('/auth/v1/google-login', {
|
|
397
396
|
method: 'POST',
|
|
398
397
|
headers: {
|
|
399
398
|
'Content-Type': 'application/json',
|
|
400
399
|
},
|
|
401
400
|
body: JSON.stringify({
|
|
402
|
-
accessToken
|
|
401
|
+
accessToken,
|
|
402
|
+
provider: providerName,
|
|
403
403
|
}),
|
|
404
404
|
});
|
|
405
405
|
const data = yield response.json();
|
|
@@ -418,7 +418,7 @@ export class AloreAuth {
|
|
|
418
418
|
if (response.status === 404) {
|
|
419
419
|
return {
|
|
420
420
|
isNewUser: true,
|
|
421
|
-
|
|
421
|
+
socialProviderRegisterUser: {
|
|
422
422
|
email: data.email,
|
|
423
423
|
nickname: data.nickname,
|
|
424
424
|
salt: data.salt,
|