Enhance passkey registration handling with error checks and CORS support
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 49s

Add validation for server response in the registration process, ensuring the presence of necessary options. Implement CORS headers for cross-device authentication and increase the timeout for registration to 5 minutes. Include debug logging for options structure to aid in troubleshooting.
This commit is contained in:
Torsten Schulz (local)
2026-01-07 21:24:11 +01:00
parent e7e9d7815c
commit b34a6fc155
2 changed files with 36 additions and 1 deletions

View File

@@ -334,7 +334,19 @@ const handleRegisterWithPasskey = async () => {
}
})
if (!pre.success || !pre.options) {
throw new Error('Ungültige Antwort vom Server')
}
// Debug: Prüfe Options-Struktur
if (!pre.options.challenge) {
console.error('Options fehlen challenge:', pre.options)
throw new Error('Ungültige WebAuthn-Options vom Server')
}
const mod = await import('@simplewebauthn/browser')
// startRegistration erwartet die Options direkt, nicht verschachtelt
// @simplewebauthn/browser v13+ erwartet die Options direkt
const credential = await mod.startRegistration(pre.options)
const response = await $fetch('/api/auth/register-passkey', {