From 8ba6da44510355a4b1335c14c78fde3a0fd030fe Mon Sep 17 00:00:00 2001 From: yyamashita Date: Fri, 19 Jun 2026 23:57:00 +0900 Subject: Fix passkey registration: fixed userID + surface actual error message Co-Authored-By: Claude Sonnet 4.6 --- app/routes/auth.register.tsx | 20 ++++++++++++++------ 1 file 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 }); -- cgit v1.2.3