@alore/auth-react-sdk 1.1.0-alpha.2 → 1.1.0-alpha.4
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/utils/AloreAuth.js +11 -11
- package/dist/utils/AuthError.d.ts +1 -0
- package/dist/utils/AuthError.js +1 -0
- package/package.json +1 -1
package/dist/utils/AloreAuth.js
CHANGED
|
@@ -48,7 +48,7 @@ export class AloreAuth {
|
|
|
48
48
|
retrieveSalt: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
const { email } = event.payload;
|
|
50
50
|
if (!this.services.isEmailAllowed(context, email)) {
|
|
51
|
-
throw new
|
|
51
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
52
52
|
}
|
|
53
53
|
const { credentialEmail } = context;
|
|
54
54
|
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/salt/${email || credentialEmail}`, {
|
|
@@ -83,7 +83,7 @@ export class AloreAuth {
|
|
|
83
83
|
completeRegistration: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
84
84
|
const { email, nickname, passwordHash, device } = event.payload;
|
|
85
85
|
if (!this.services.isEmailAllowed(context, email)) {
|
|
86
|
-
throw new
|
|
86
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
87
87
|
}
|
|
88
88
|
const { firebaseCompatible } = context.authProviderConfigs || {};
|
|
89
89
|
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/account-registration${firebaseCompatible ? `?firebaseCompatibleToken=${firebaseCompatible}` : ''}`, {
|
|
@@ -122,7 +122,7 @@ export class AloreAuth {
|
|
|
122
122
|
sendConfirmationEmail: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
123
123
|
const { email, nickname, locale } = event.payload;
|
|
124
124
|
if (!this.services.isEmailAllowed(context, email)) {
|
|
125
|
-
throw new
|
|
125
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
126
126
|
}
|
|
127
127
|
const searchParams = new URLSearchParams();
|
|
128
128
|
const url = '/auth/v1/confirmation-email';
|
|
@@ -156,7 +156,7 @@ export class AloreAuth {
|
|
|
156
156
|
sendCode: (context, event) => __awaiter(this, void 0, void 0, function* () {
|
|
157
157
|
const { email } = event.payload;
|
|
158
158
|
if (!this.services.isEmailAllowed(context, email)) {
|
|
159
|
-
|
|
159
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
160
160
|
}
|
|
161
161
|
const response = yield this.fetchWithProgressiveBackoff(`/reset-password`, {
|
|
162
162
|
method: 'POST',
|
|
@@ -175,7 +175,7 @@ export class AloreAuth {
|
|
|
175
175
|
var _a, _b;
|
|
176
176
|
const { email, passwordHash, device, locale } = event.payload;
|
|
177
177
|
if (!this.services.isEmailAllowed(context, email || context.credentialEmail)) {
|
|
178
|
-
throw new
|
|
178
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
179
179
|
}
|
|
180
180
|
const { credentialEmail } = context;
|
|
181
181
|
const searchParams = new URLSearchParams();
|
|
@@ -216,7 +216,7 @@ export class AloreAuth {
|
|
|
216
216
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
217
217
|
const { email, nickname, device } = event.payload || context.registerUser;
|
|
218
218
|
if (email && !this.services.isEmailAllowed(context, email)) {
|
|
219
|
-
throw new
|
|
219
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
220
220
|
}
|
|
221
221
|
const startPasskeyRegistrationResponse = yield this.fetchWithProgressiveBackoff('/auth/v1/account-registration-passkey', {
|
|
222
222
|
method: 'POST',
|
|
@@ -237,7 +237,7 @@ export class AloreAuth {
|
|
|
237
237
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
238
238
|
const { email, nickname, device, passkeyRegistration } = event.payload || {};
|
|
239
239
|
if (email && !this.services.isEmailAllowed(context, email)) {
|
|
240
|
-
throw new
|
|
240
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
241
241
|
}
|
|
242
242
|
const response = yield this.fetchWithProgressiveBackoff('/auth/v1/account-registration-passkey-finish', {
|
|
243
243
|
method: 'POST',
|
|
@@ -263,7 +263,7 @@ export class AloreAuth {
|
|
|
263
263
|
const { rpDomain } = context.authProviderConfigs || {};
|
|
264
264
|
const email = (_c = event.payload) === null || _c === void 0 ? void 0 : _c.email;
|
|
265
265
|
if (email && !this.services.isEmailAllowed(context, email)) {
|
|
266
|
-
throw new
|
|
266
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
267
267
|
}
|
|
268
268
|
const searchParams = new URLSearchParams();
|
|
269
269
|
const url = '/auth/v1/login-passkey';
|
|
@@ -381,7 +381,7 @@ export class AloreAuth {
|
|
|
381
381
|
const { email, passwordHash, secureCode } = event.payload;
|
|
382
382
|
const { credentialEmail, authProviderConfigs } = context;
|
|
383
383
|
if (!this.services.isEmailAllowed(context, email || credentialEmail)) {
|
|
384
|
-
throw new
|
|
384
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
385
385
|
}
|
|
386
386
|
const { firebaseCompatible } = authProviderConfigs || {};
|
|
387
387
|
const response = yield this.fetchWithProgressiveBackoff(`/auth/v1/email-2fa-verification${firebaseCompatible ? `?firebaseCompatibleToken=${firebaseCompatible}` : ''}`, {
|
|
@@ -461,7 +461,7 @@ export class AloreAuth {
|
|
|
461
461
|
const data = yield response.json();
|
|
462
462
|
if (response.ok) {
|
|
463
463
|
if (!this.services.isEmailAllowed(context, data.email)) {
|
|
464
|
-
throw new
|
|
464
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
465
465
|
}
|
|
466
466
|
return {
|
|
467
467
|
googleOtpCode: data.otpCode,
|
|
@@ -476,7 +476,7 @@ export class AloreAuth {
|
|
|
476
476
|
}
|
|
477
477
|
if (response.status === 404) {
|
|
478
478
|
if (!this.services.isEmailAllowed(context, data.email)) {
|
|
479
|
-
throw new
|
|
479
|
+
throw new AloreAuthError(ErrorTypes.EMAIL_DOMAIN_NOT_ALLOWED, 'Email domain not allowed', 400);
|
|
480
480
|
}
|
|
481
481
|
return {
|
|
482
482
|
isNewUser: true,
|
|
@@ -5,6 +5,7 @@ export declare enum ErrorCodes {
|
|
|
5
5
|
}
|
|
6
6
|
export declare enum ErrorTypes {
|
|
7
7
|
CLIENT_ID_REQUIRED = "CLIENT_ID_REQUIRED",
|
|
8
|
+
EMAIL_DOMAIN_NOT_ALLOWED = "EMAIL_DOMAIN_NOT_ALLOWED",
|
|
8
9
|
PASSKEY_NOT_SUPPORTED = "PASSKEY_NOT_SUPPORTED",
|
|
9
10
|
USER_ALREADY_EXISTS = "USER_ALREADY_EXISTS",
|
|
10
11
|
FAILED_TO_FETCH = "FAILED_TO_FETCH",
|
package/dist/utils/AuthError.js
CHANGED
|
@@ -8,6 +8,7 @@ export var ErrorCodes;
|
|
|
8
8
|
export var ErrorTypes;
|
|
9
9
|
(function (ErrorTypes) {
|
|
10
10
|
ErrorTypes["CLIENT_ID_REQUIRED"] = "CLIENT_ID_REQUIRED";
|
|
11
|
+
ErrorTypes["EMAIL_DOMAIN_NOT_ALLOWED"] = "EMAIL_DOMAIN_NOT_ALLOWED";
|
|
11
12
|
ErrorTypes["PASSKEY_NOT_SUPPORTED"] = "PASSKEY_NOT_SUPPORTED";
|
|
12
13
|
ErrorTypes["USER_ALREADY_EXISTS"] = "USER_ALREADY_EXISTS";
|
|
13
14
|
ErrorTypes["FAILED_TO_FETCH"] = "FAILED_TO_FETCH";
|