@micha.bigler/ui-core-micha 1.2.3 → 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.
- package/dist/auth/authApi.js +19 -13
- package/package.json +1 -1
- package/src/auth/authApi.jsx +23 -14
package/dist/auth/authApi.js
CHANGED
|
@@ -178,12 +178,14 @@ async function registerPasskeyStart({ passwordless = true } = {}) {
|
|
|
178
178
|
params: passwordless ? { passwordless: true } : {},
|
|
179
179
|
withCredentials: true,
|
|
180
180
|
});
|
|
181
|
-
const
|
|
182
|
-
//
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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;
|
|
188
|
+
return publicKeyJson;
|
|
187
189
|
}
|
|
188
190
|
async function registerPasskeyComplete(credentialJson, name = 'Passkey') {
|
|
189
191
|
const res = await axios.post(`${HEADLESS_BASE}/account/authenticators/webauthn`, {
|
|
@@ -197,10 +199,12 @@ export async function registerPasskey(name = 'Passkey') {
|
|
|
197
199
|
if (!hasJsonWebAuthn) {
|
|
198
200
|
throw new Error('Passkey JSON helpers are not available in this browser.');
|
|
199
201
|
}
|
|
200
|
-
|
|
202
|
+
// Hier bekommst du bereits den inneren publicKey-Block mit challenge etc.
|
|
203
|
+
const publicKeyJson = await registerPasskeyStart({ passwordless: true });
|
|
201
204
|
let credential;
|
|
202
205
|
try {
|
|
203
|
-
|
|
206
|
+
// publicKeyJson hat challenge auf Top-Level
|
|
207
|
+
const publicKeyOptions = window.PublicKeyCredential.parseCreationOptionsFromJSON(publicKeyJson);
|
|
204
208
|
credential = await navigator.credentials.create({
|
|
205
209
|
publicKey: publicKeyOptions,
|
|
206
210
|
});
|
|
@@ -223,11 +227,13 @@ export async function registerPasskey(name = 'Passkey') {
|
|
|
223
227
|
async function loginWithPasskeyStart() {
|
|
224
228
|
ensureWebAuthnSupport();
|
|
225
229
|
const res = await axios.get(`${HEADLESS_BASE}/auth/webauthn/login`, { withCredentials: true });
|
|
226
|
-
const
|
|
227
|
-
//
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
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;
|
|
231
237
|
return requestOptionsJson;
|
|
232
238
|
}
|
|
233
239
|
async function loginWithPasskeyComplete(credentialJson) {
|
package/package.json
CHANGED
package/src/auth/authApi.jsx
CHANGED
|
@@ -235,17 +235,21 @@ async function registerPasskeyStart({ passwordless = true } = {}) {
|
|
|
235
235
|
},
|
|
236
236
|
);
|
|
237
237
|
|
|
238
|
-
const
|
|
238
|
+
const responseBody = res.data || {};
|
|
239
239
|
|
|
240
|
-
//
|
|
241
|
-
const
|
|
242
|
-
(data.creation_options && data.creation_options.publicKey) ||
|
|
243
|
-
data.creation_options ||
|
|
244
|
-
data;
|
|
240
|
+
// Handle nested 'data' wrapper if present, otherwise use body directly
|
|
241
|
+
const payload = responseBody.data || responseBody;
|
|
245
242
|
|
|
246
|
-
|
|
243
|
+
// Extract the inner publicKey structure required by the browser API
|
|
244
|
+
const publicKeyJson =
|
|
245
|
+
(payload.creation_options && payload.creation_options.publicKey) ||
|
|
246
|
+
payload.publicKey ||
|
|
247
|
+
payload;
|
|
248
|
+
|
|
249
|
+
return publicKeyJson;
|
|
247
250
|
}
|
|
248
251
|
|
|
252
|
+
|
|
249
253
|
async function registerPasskeyComplete(credentialJson, name = 'Passkey') {
|
|
250
254
|
const res = await axios.post(
|
|
251
255
|
`${HEADLESS_BASE}/account/authenticators/webauthn`,
|
|
@@ -265,12 +269,14 @@ export async function registerPasskey(name = 'Passkey') {
|
|
|
265
269
|
throw new Error('Passkey JSON helpers are not available in this browser.');
|
|
266
270
|
}
|
|
267
271
|
|
|
268
|
-
|
|
272
|
+
// Hier bekommst du bereits den inneren publicKey-Block mit challenge etc.
|
|
273
|
+
const publicKeyJson = await registerPasskeyStart({ passwordless: true });
|
|
269
274
|
|
|
270
275
|
let credential;
|
|
271
276
|
try {
|
|
277
|
+
// publicKeyJson hat challenge auf Top-Level
|
|
272
278
|
const publicKeyOptions =
|
|
273
|
-
window.PublicKeyCredential.parseCreationOptionsFromJSON(
|
|
279
|
+
window.PublicKeyCredential.parseCreationOptionsFromJSON(publicKeyJson);
|
|
274
280
|
|
|
275
281
|
credential = await navigator.credentials.create({
|
|
276
282
|
publicKey: publicKeyOptions,
|
|
@@ -301,13 +307,16 @@ async function loginWithPasskeyStart() {
|
|
|
301
307
|
{ withCredentials: true },
|
|
302
308
|
);
|
|
303
309
|
|
|
304
|
-
const
|
|
310
|
+
const responseBody = res.data || {};
|
|
311
|
+
|
|
312
|
+
// Handle nested 'data' wrapper if present
|
|
313
|
+
const payload = responseBody.data || responseBody;
|
|
305
314
|
|
|
306
|
-
//
|
|
315
|
+
// Extract request options for authentication
|
|
307
316
|
const requestOptionsJson =
|
|
308
|
-
(
|
|
309
|
-
|
|
310
|
-
|
|
317
|
+
(payload.request_options && payload.request_options.publicKey) ||
|
|
318
|
+
payload.request_options ||
|
|
319
|
+
payload;
|
|
311
320
|
|
|
312
321
|
return requestOptionsJson;
|
|
313
322
|
}
|