From 9232c6c29514df0cb20f27fb7157baf5ed1a255b Mon Sep 17 00:00:00 2001
From: yyamashita <yyamashita@hetzner.yyamashita.com>
Date: Sat, 20 Jun 2026 00:35:47 +0900
Subject: Debug: force render between steps, remove rp.id from native options

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

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

diff --git a/app/routes/auth.register.tsx b/app/routes/auth.register.tsx
index 28d5b03..7d8fb5d 100644
--- a/app/routes/auth.register.tsx
+++ b/app/routes/auth.register.tsx
@@ -120,29 +120,33 @@ export default function Register() {
   const [step, setStep] = useState("");
 
   async function handleRegister() {
+    const tick = () => new Promise<void>((r) => setTimeout(r, 50));
     setStatus("loading");
     setErrorMsg("");
     setStep("");
     try {
-      setStep("1. options 取得中…");
+      setStep("1a. fetch 中…"); await tick();
       const optRes = await fetch("/auth/register?intent=options", {
         method: "POST",
         headers: { "Content-Type": "application/json" },
         body: JSON.stringify({ token }),
       });
+      setStep("1b. fetch 完了 status=" + optRes.status); await tick();
       if (!optRes.ok) {
         const err = await optRes.json();
         throw new Error(err.error ?? "オプション取得に失敗しました");
       }
       const optJSON = await optRes.json();
-      setStep("2. options 受信 OK → credentials.create() 呼び出し中…");
+      setStep("1c. JSON パース OK"); await tick();
 
       const userId = b64urlToBuffer(optJSON.user.id);
       const challenge = b64urlToBuffer(optJSON.challenge);
+      setStep("2. credentials.create() 呼び出し中…"); await tick();
 
+      // rp.id / authenticatorSelection / attestation を省略して最小構成で試す
       const credential = await navigator.credentials.create({
         publicKey: {
-          rp: optJSON.rp,
+          rp: { name: optJSON.rp.name },
           user: {
             id: userId,
             name: optJSON.user.name,
@@ -150,17 +154,11 @@ export default function Register() {
           },
           challenge,
           pubKeyCredParams: optJSON.pubKeyCredParams,
-          timeout: 60000,
-          attestation: "none",
-          authenticatorSelection: {
-            residentKey: "required" as ResidentKeyRequirement,
-            userVerification: "required" as UserVerificationRequirement,
-          },
         },
       }) as PublicKeyCredential | null;
 
       if (!credential) throw new Error("クレデンシャルの作成に失敗しました");
-      setStep("3. credential 取得 OK → サーバー送信中…");
+      setStep("3. credential 取得 OK → サーバー送信中…"); await tick();
 
       const attestation = credential.response as AuthenticatorAttestationResponse;
       const regResponse: RegistrationResponseJSON = {
-- 
cgit v1.2.3

