From 6535abf074d2c4d0e895ba4d01c100d261a510b5 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Thu, 8 Jan 2026 14:17:18 +0100 Subject: [PATCH] Enhance debug logging for Passkey Registration options Add detailed debug statements in the registrieren.vue component to validate the complete options structure during Passkey registration. Update the register-passkey API to simplify the options return process, eliminating unnecessary serialization while maintaining comprehensive logging of the options details for improved troubleshooting. --- pages/registrieren.vue | 22 ++++++++++++++++ .../api/auth/register-passkey-options.post.js | 25 ++++++++----------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/pages/registrieren.vue b/pages/registrieren.vue index ed8a7b9..67b3785 100644 --- a/pages/registrieren.vue +++ b/pages/registrieren.vue @@ -443,6 +443,28 @@ const handleRegisterWithPasskey = async () => { console.error('[DEBUG] Options missing challenge:', JSON.stringify(pre.options, null, 2)) throw new Error('Ungültige WebAuthn-Options vom Server') } + + // Debug: Prüfe die vollständige Options-Struktur + console.log('[DEBUG] Full options structure check:', { + hasChallenge: !!pre.options.challenge, + challengeValue: pre.options.challenge?.substring(0, 20) + '...', + challengeType: typeof pre.options.challenge, + hasRp: !!pre.options.rp, + rpId: pre.options.rp?.id, + rpName: pre.options.rp?.name, + hasUser: !!pre.options.user, + userId: pre.options.user?.id ? 'present' : 'missing', + userIdType: typeof pre.options.user?.id, + userName: pre.options.user?.name, + userDisplayName: pre.options.user?.displayName, + hasPubKeyCredParams: !!pre.options.pubKeyCredParams, + pubKeyCredParamsCount: pre.options.pubKeyCredParams?.length, + hasAuthenticatorSelection: !!pre.options.authenticatorSelection, + timeout: pre.options.timeout, + timeoutType: typeof pre.options.timeout, + allKeys: Object.keys(pre.options), + optionsStringified: JSON.stringify(pre.options).substring(0, 200) + '...' + }) console.log('[DEBUG] Calling startRegistration...') console.log('[DEBUG] Full options object (will be encoded in QR code for Cross-Device):', JSON.stringify(pre.options, null, 2)) diff --git a/server/api/auth/register-passkey-options.post.js b/server/api/auth/register-passkey-options.post.js index 92a8ed6..7381ca6 100644 --- a/server/api/auth/register-passkey-options.post.js +++ b/server/api/auth/register-passkey-options.post.js @@ -142,24 +142,21 @@ export default defineEventHandler(async (event) => { }) } - // Stelle sicher, dass die Options korrekt serialisiert werden - const serializedOptions = { - ...options, - challenge: options.challenge, - rp: options.rp, - user: options.user, - pubKeyCredParams: options.pubKeyCredParams, - authenticatorSelection: options.authenticatorSelection, - timeout: options.timeout || 300000 - } - + // Options direkt zurückgeben (wie in passkeys/registration-options.post.js) + // @simplewebauthn/server gibt bereits korrekt formatierte Options zurück const totalDuration = Date.now() - requestStart console.log(`[DEBUG] Returning options (total: ${totalDuration}ms)`, { registrationId, - optionsKeys: Object.keys(serializedOptions), - serializedChallengeLength: serializedOptions.challenge?.length + optionsKeys: Object.keys(options), + challengeLength: options.challenge?.length, + challengeType: typeof options.challenge, + rpId: options.rp?.id, + userIdType: typeof options.user?.id, + timeout: options.timeout }) - return { success: true, registrationId, options: serializedOptions } + // WICHTIG: Options direkt zurückgeben, keine manuelle Serialisierung + // Die Options von @simplewebauthn/server sind bereits korrekt formatiert + return { success: true, registrationId, options } })