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:
@@ -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
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { RegistrationResponseJSON } from "@simplewebauthn/types";
|
||||
import * as z from "zod";
|
||||
import { emailSchema } from "./common.js";
|
||||
|
||||
@@ -8,7 +9,7 @@ import { emailSchema } from "./common.js";
|
||||
*/
|
||||
export const passkeyInfoSchema = z.object({
|
||||
challengeId: z.number(),
|
||||
response: z.any(), // RegistrationResponseJSON from @simplewebauthn/browser
|
||||
response: z.custom<RegistrationResponseJSON>(),
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user