@micha.bigler/ui-core-micha 1.2.4 → 1.2.5

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.
@@ -178,12 +178,13 @@ async function registerPasskeyStart({ passwordless = true } = {}) {
178
178
  params: passwordless ? { passwordless: true } : {},
179
179
  withCredentials: true,
180
180
  });
181
- const data = res.data || {};
182
- // allauth.headless: { creation_options: { publicKey: { ... } } }
183
- // Wir wollen am Ende den INNEREN publicKey-Block haben:
184
- const publicKeyJson = (data.creation_options && data.creation_options.publicKey) ||
185
- data.publicKey ||
186
- data;
181
+ const responseBody = res.data || {};
182
+ // Handle nested 'data' wrapper if present, otherwise use body directly
183
+ const payload = responseBody.data || responseBody;
184
+ // Extract the inner publicKey structure required by the browser API
185
+ const publicKeyJson = (payload.creation_options && payload.creation_options.publicKey) ||
186
+ payload.publicKey ||
187
+ payload;
187
188
  return publicKeyJson;
188
189
  }
189
190
  async function registerPasskeyComplete(credentialJson, name = 'Passkey') {
@@ -226,11 +227,13 @@ export async function registerPasskey(name = 'Passkey') {
226
227
  async function loginWithPasskeyStart() {
227
228
  ensureWebAuthnSupport();
228
229
  const res = await axios.get(`${HEADLESS_BASE}/auth/webauthn/login`, { withCredentials: true });
229
- const data = res.data || {};
230
- // allauth.headless: { request_options: { publicKey: { ... } } }
231
- const requestOptionsJson = (data.request_options && data.request_options.publicKey) ||
232
- data.request_options ||
233
- data;
230
+ const responseBody = res.data || {};
231
+ // Handle nested 'data' wrapper if present
232
+ const payload = responseBody.data || responseBody;
233
+ // Extract request options for authentication
234
+ const requestOptionsJson = (payload.request_options && payload.request_options.publicKey) ||
235
+ payload.request_options ||
236
+ payload;
234
237
  return requestOptionsJson;
235
238
  }
236
239
  async function loginWithPasskeyComplete(credentialJson) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "private": false,
@@ -235,18 +235,21 @@ async function registerPasskeyStart({ passwordless = true } = {}) {
235
235
  },
236
236
  );
237
237
 
238
- const data = res.data || {};
238
+ const responseBody = res.data || {};
239
239
 
240
- // allauth.headless: { creation_options: { publicKey: { ... } } }
241
- // Wir wollen am Ende den INNEREN publicKey-Block haben:
240
+ // Handle nested 'data' wrapper if present, otherwise use body directly
241
+ const payload = responseBody.data || responseBody;
242
+
243
+ // Extract the inner publicKey structure required by the browser API
242
244
  const publicKeyJson =
243
- (data.creation_options && data.creation_options.publicKey) ||
244
- data.publicKey ||
245
- data;
245
+ (payload.creation_options && payload.creation_options.publicKey) ||
246
+ payload.publicKey ||
247
+ payload;
246
248
 
247
249
  return publicKeyJson;
248
250
  }
249
251
 
252
+
250
253
  async function registerPasskeyComplete(credentialJson, name = 'Passkey') {
251
254
  const res = await axios.post(
252
255
  `${HEADLESS_BASE}/account/authenticators/webauthn`,
@@ -304,13 +307,16 @@ async function loginWithPasskeyStart() {
304
307
  { withCredentials: true },
305
308
  );
306
309
 
307
- const data = res.data || {};
310
+ const responseBody = res.data || {};
311
+
312
+ // Handle nested 'data' wrapper if present
313
+ const payload = responseBody.data || responseBody;
308
314
 
309
- // allauth.headless: { request_options: { publicKey: { ... } } }
315
+ // Extract request options for authentication
310
316
  const requestOptionsJson =
311
- (data.request_options && data.request_options.publicKey) ||
312
- data.request_options ||
313
- data;
317
+ (payload.request_options && payload.request_options.publicKey) ||
318
+ payload.request_options ||
319
+ payload;
314
320
 
315
321
  return requestOptionsJson;
316
322
  }