@alore/auth-react-sdk 1.0.1-alpha → 1.0.2-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 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;
@@ -48,13 +48,11 @@ export class AloreAuth {
48
48
  sessionId: context.sessionId,
49
49
  }),
50
50
  });
51
- if (!response.ok) {
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 = event.type === 'START_PASSKEY_LOGIN' ? (_c = event.payload) === null || _c === void 0 ? void 0 : _c.email : undefined;
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 || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alore/auth-react-sdk",
3
- "version": "1.0.1-alpha",
3
+ "version": "1.0.2-alpha",
4
4
  "repository": "https://github.com/0xCarbon/alore-js",
5
5
  "description": "SDK for Alore Auth",
6
6
  "main": "dist/index.js",