Skip to content

Commit 6fc9c03

Browse files
committed
Simplify the transports cast in /passkeys/registration/begin
The cast on `p.transports` was a multi-line conditional-types expression that fished the element type out of buildRegistrationOptions' parameter shape via `Parameters<...>` and `infer T`. The element type is just AuthenticatorTransportFuture from @simplewebauthn/server, which the same file already imports transitively, so import it directly and cast to AuthenticatorTransportFuture[]. Runtime is identical; the call site fits on one line again. #487 (comment) Assisted-by: Claude Code:claude-opus-4-7
1 parent c41a7a8 commit 6fc9c03

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

src/pages/auth.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { zValidator } from "@hono/zod-validator";
22
import { getLogger } from "@logtape/logtape";
3+
import type { AuthenticatorTransportFuture } from "@simplewebauthn/server";
34
import { eq } from "drizzle-orm";
45
import { Hono } from "hono";
56
import { deleteCookie, getSignedCookie, setSignedCookie } from "hono/cookie";
@@ -116,13 +117,7 @@ auth.post("/passkeys/registration/begin", async (c) => {
116117
email: credential.email,
117118
existingCredentials: enrolled.map((p) => ({
118119
id: p.id,
119-
transports: p.transports as ReadonlyArray<
120-
Parameters<
121-
typeof buildRegistrationOptions
122-
>[0]["existingCredentials"][number]["transports"]
123-
> extends ReadonlyArray<infer T>
124-
? T
125-
: never,
120+
transports: p.transports as AuthenticatorTransportFuture[],
126121
})),
127122
});
128123
const expiresAt = Date.now() + PASSKEY_REG_MAX_AGE_SECONDS * 1000;

0 commit comments

Comments
 (0)