Improve passkey registration error handling and options serialization
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 44s

Enhance the registration process by adding error handling for the WebAuthn startRegistration method and ensuring the presence of required options. Include debug logging for received options and serialize the options correctly before returning them in the API response, improving robustness and clarity in the registration flow.
This commit is contained in:
Torsten Schulz (local)
2026-01-07 21:30:13 +01:00
parent b34a6fc155
commit bb985ddc8f
2 changed files with 32 additions and 5 deletions

View File

@@ -75,9 +75,23 @@ export default defineEventHandler(async (event) => {
hasChallenge: !!options.challenge,
rpId: options.rp?.id,
userId: options.user?.id ? 'present' : 'missing',
timeout: options.timeout
timeout: options.timeout,
challengeType: typeof options.challenge
})
return { success: true, registrationId, options }
// Stelle sicher, dass die Options korrekt serialisiert werden
// @simplewebauthn/server gibt ein Objekt zurück, das direkt JSON-serialisierbar ist
// Aber wir müssen sicherstellen, dass alle Properties vorhanden sind
const serializedOptions = {
...options,
challenge: options.challenge,
rp: options.rp,
user: options.user,
pubKeyCredParams: options.pubKeyCredParams,
authenticatorSelection: options.authenticatorSelection,
timeout: options.timeout || 300000
}
return { success: true, registrationId, options: serializedOptions }
})