From 0b44daefb11b5eb764bca32ab2af79c5325a3672 Mon Sep 17 00:00:00 2001
From: yyamashita <yyamashita@hetzner.yyamashita.com>
Date: Sat, 20 Jun 2026 00:13:24 +0900
Subject: Strip extensions + filter algs for iOS Safari compatibility

- Remove extensions.credProps (WebAuthn L2, causes TypeError on older iOS)
- Remove alg:-8 (Ed25519, not universally supported)
- Show error name in UI for easier debugging

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

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

diff --git a/app/routes/auth.register.tsx b/app/routes/auth.register.tsx
index 2b5ad2a..64f4c78 100644
--- a/app/routes/auth.register.tsx
+++ b/app/routes/auth.register.tsx
@@ -41,8 +41,12 @@ export async function action({ request }: Route.ActionArgs) {
         userVerification: "required",
       },
     });
-    // hints は WebAuthn L3 の新フィールドで古い iOS が処理できないため除外
-    const { hints: _hints, ...safeOptions } = options as typeof options & { hints?: unknown };
+    // 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
+    );
     session.set("challenge", options.challenge);
     return Response.json(safeOptions, {
       headers: { "Set-Cookie": await commitSession(session) },
@@ -127,7 +131,7 @@ export default function Register() {
       window.location.href = "/";
     } catch (e) {
       setStatus("error");
-      setErrorMsg(e instanceof Error ? e.message : "エラーが発生しました");
+      setErrorMsg(e instanceof Error ? `${e.name}: ${e.message}` : String(e));
     }
   }
 
-- 
cgit v1.2.3

