feat: align with upstream 1.5.9.9

This commit is contained in:
2026-09-12 18:21:11 +08:00
commit 34f0679117
805 changed files with 376275 additions and 0 deletions
@@ -0,0 +1,21 @@
import { generateAuthenticationOptions } from '@simplewebauthn/server'
import { setWebAuthnChallenge } from '~~/server/utils/webauthn-token'
import { getWebAuthnConfig } from '~~/server/utils/webauthn-config'
import { createApiError } from '~~/server/utils/apiError'
export default defineEventHandler(async (event) => {
const { rpID } = getWebAuthnConfig(event)
if (!rpID) {
throw createApiError(500, 'AUTH_WEBAUTHN_RP_ID_INVALID', 'WebAuthn RP ID 配置无效')
}
const options = await generateAuthenticationOptions({
rpID,
userVerification: 'preferred',
allowCredentials: []
})
setWebAuthnChallenge(event, options.challenge, 'authentication')
return options
})