diff options
Diffstat (limited to 'app/routes')
| -rw-r--r-- | app/routes/auth.register.tsx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/routes/auth.register.tsx b/app/routes/auth.register.tsx index c064eff..01b0699 100644 --- a/app/routes/auth.register.tsx +++ b/app/routes/auth.register.tsx @@ -32,6 +32,7 @@ export async function action({ request }: Route.ActionArgs) { const options = await generateRegistrationOptions({ rpName, rpID, + userID: new Uint8Array([109, 105, 99, 114, 111, 98, 108, 111, 103]), // "microblog" userName: "admin", attestationType: "none", authenticatorSelection: { @@ -50,12 +51,19 @@ export async function action({ request }: Route.ActionArgs) { if (!challenge) return Response.json({ error: "セッション切れです" }, { status: 400 }); const body = (await request.json()) as RegistrationResponseJSON; - const verification = await verifyRegistrationResponse({ - response: body, - expectedChallenge: challenge, - expectedOrigin: origin, - expectedRPID: rpID, - }); + let verification; + try { + verification = await verifyRegistrationResponse({ + response: body, + expectedChallenge: challenge, + expectedOrigin: origin, + expectedRPID: rpID, + }); + } catch (err) { + const msg = err instanceof Error ? err.message : String(err); + console.error("[passkey] verifyRegistrationResponse failed:", msg); + return Response.json({ error: msg }, { status: 400 }); + } if (!verification.verified || !verification.registrationInfo) { return Response.json({ error: "登録に失敗しました" }, { status: 400 }); |
