Replace z.any() with z.custom<T>() for WebAuthn types

Use proper TypeScript types from @simplewebauthn/types instead of
z.any() for WebAuthn-related schemas:
- PublicKeyCredentialCreationOptionsJSON
- PublicKeyCredentialRequestOptionsJSON
- RegistrationResponseJSON
- AuthenticationResponseJSON

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
RevIQ
2026-01-09 12:17:29 +08:00
parent b6bce41092
commit a4dff188eb
4 changed files with 17 additions and 6 deletions

View File

@@ -1,3 +1,9 @@
import type {
AuthenticationResponseJSON,
PublicKeyCredentialCreationOptionsJSON,
PublicKeyCredentialRequestOptionsJSON,
RegistrationResponseJSON,
} from "@simplewebauthn/types";
import { oc } from "@orpc/contract";
import * as z from "zod";
import {
@@ -72,28 +78,28 @@ export const contract = oc.router({
.output(
z.object({
challengeId: z.number(),
options: z.any(), // PublicKeyCredentialCreationOptionsJSON
options: z.custom<PublicKeyCredentialCreationOptionsJSON>(),
}),
),
verifyRegistration: oc
.input(
z.object({
challengeId: z.number(),
response: z.any(), // RegistrationResponseJSON
response: z.custom<RegistrationResponseJSON>(),
}),
)
.output(z.void()),
createAuthenticationOptions: oc.output(
z.object({
challengeId: z.number(),
options: z.any(), // PublicKeyCredentialRequestOptionsJSON
options: z.custom<PublicKeyCredentialRequestOptionsJSON>(),
}),
),
verifyAuthentication: oc
.input(
z.object({
challengeId: z.number(),
response: z.any(), // AuthenticationResponseJSON
response: z.custom<AuthenticationResponseJSON>(),
}),
)
.output(z.void()),
@@ -113,7 +119,7 @@ export const contract = oc.router({
createPasskey: oc.input(z.object({ name: z.string() })).output(
z.object({
challengeId: z.number(),
options: z.any(), // PublicKeyCredentialCreationOptionsJSON
options: z.custom<PublicKeyCredentialCreationOptionsJSON>(),
}),
),
renamePasskey: oc