Füge Unterstützung für Firefox-Browser hinzu, indem die Registrierung von Passkeys ohne bevorzugten Authentifikator-Typ ermöglicht wird.
All checks were successful
Code Analysis and Production Deploy / analyze (push) Has been skipped
Code Analysis and Production Deploy / deploy-production (push) Has been skipped
Code Analysis and Production Deploy / deploy-test (push) Successful in 1m52s

This commit is contained in:
Torsten Schulz (local)
2026-05-15 13:56:12 +02:00
parent 842a516ce6
commit 4521ce002e

View File

@@ -393,6 +393,12 @@ const loadPasskeys = async () => {
}
}
const isFirefoxBrowser = () => {
if (!process.client) return false
const ua = navigator.userAgent || ''
return /firefox/i.test(ua)
}
const addPasskey = async () => {
passkeyError.value = ''
passkeyLoading.value = true
@@ -400,10 +406,12 @@ const addPasskey = async () => {
const name = window.prompt('Name für den Passkey (z.B. "iPhone", "Laptop"):', 'Passkey') || 'Passkey'
const mod = await import('@simplewebauthn/browser')
// Kein preferredAuthenticatorType setzen → kein authenticatorAttachment gesetzt
// → Browser (inkl. Firefox) wählt selbst: interner Passkey-Store, Smartphone oder Security Key
// Firefox speichert den Passkey dann intern wie ein Passwort (kein Hardware-Key nötig)
const res = await $fetch('/api/auth/passkeys/registration-options', { method: 'POST' })
// Firefox/Linux kommt mit localDevice teils nicht klar. Für Chromium bevorzugen wir lokal.
const registrationOptionsRequest = isFirefoxBrowser()
? { method: 'POST' }
: { method: 'POST', body: { preferredAuthenticatorType: 'localDevice' } }
const res = await $fetch('/api/auth/passkeys/registration-options', registrationOptionsRequest)
// @simplewebauthn/browser v13+ erwartet { optionsJSON: options }
const credential = await mod.startRegistration({ optionsJSON: res.options })