From 9da6a06bea17c26315225f394d997ff5379c8ad2 Mon Sep 17 00:00:00 2001
From: yyamashita <yyamashita@hetzner.yyamashita.com>
Date: Sat, 20 Jun 2026 00:22:20 +0900
Subject: Debug passkey: send minimal options to isolate iOS SyntaxError

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---
 app/routes/auth.register.tsx | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

(limited to 'app/routes/auth.register.tsx')

diff --git a/app/routes/auth.register.tsx b/app/routes/auth.register.tsx
index 64f4c78..06f42f5 100644
--- a/app/routes/auth.register.tsx
+++ b/app/routes/auth.register.tsx
@@ -41,14 +41,19 @@ export async function action({ request }: Route.ActionArgs) {
         userVerification: "required",
       },
     });
-    // hints (L3) と extensions (L2) は古い iOS Safari が処理できないため除外
-    // また alg: -8 (Ed25519) も互換性のため除外
-    const { hints: _h, extensions: _e, ...safeOptions } = options as typeof options & { hints?: unknown; extensions?: unknown };
-    safeOptions.pubKeyCredParams = safeOptions.pubKeyCredParams.filter(
-      (p) => p.alg === -7 || p.alg === -257
-    );
+    // iOS Safari の parseCreationOptionsFromJSON は unknown フィールドで SyntaxError を投げるため
+    // 必須フィールドのみ送信して原因を絞り込む
+    const minimalOptions = {
+      rp: options.rp,
+      user: options.user,
+      challenge: options.challenge,
+      pubKeyCredParams: options.pubKeyCredParams.filter(
+        (p) => p.alg === -7 || p.alg === -257
+      ),
+    };
+    console.log("[passkey] options sent to browser:", JSON.stringify(minimalOptions));
     session.set("challenge", options.challenge);
-    return Response.json(safeOptions, {
+    return Response.json(minimalOptions, {
       headers: { "Set-Cookie": await commitSession(session) },
     });
   }
-- 
cgit v1.2.3

