Improve passkey registration error handling and options serialization
Some checks failed
Code Analysis (JS/Vue) / analyze (push) Failing after 44s
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:
@@ -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 }
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user