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:
3
bun.lock
3
bun.lock
@@ -84,6 +84,7 @@
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@orpc/contract": "^1.13.2",
|
||||
"@simplewebauthn/types": "^12.0.0",
|
||||
"libphonenumber-js": "^1.12.33",
|
||||
"zod": "^4.3.5",
|
||||
},
|
||||
@@ -351,6 +352,8 @@
|
||||
|
||||
"@rollup/rollup-win32-x64-msvc": ["@rollup/rollup-win32-x64-msvc@4.55.1", "", { "os": "win32", "cpu": "x64" }, "sha512-SPEpaL6DX4rmcXtnhdrQYgzQ5W2uW3SCJch88lB2zImhJRhIIK44fkUrgIV/Q8yUNfw5oyZ5vkeQsZLhCb06lw=="],
|
||||
|
||||
"@simplewebauthn/types": ["@simplewebauthn/types@12.0.0", "", {}, "sha512-q6y8MkoV8V8jB4zzp18Uyj2I7oFp2/ONL8c3j8uT06AOWu3cIChc1au71QYHrP2b+xDapkGTiv+9lX7xkTlAsA=="],
|
||||
|
||||
"@standard-schema/spec": ["@standard-schema/spec@1.1.0", "", {}, "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w=="],
|
||||
|
||||
"@stricli/core": ["@stricli/core@1.2.5", "", {}, "sha512-+afyztQW7fwWkqmU2WQZbdc3LjnZThWYdtE0l+hykZ1Rvy7YGxZSvsVCS/wZ/2BNv117pQ9TU1GZZRIcPnB4tw=="],
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@orpc/contract": "^1.13.2",
|
||||
"@simplewebauthn/types": "^12.0.0",
|
||||
"libphonenumber-js": "^1.12.33",
|
||||
"zod": "^4.3.5"
|
||||
},
|
||||
|
||||
@@ -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