diff --git a/bun.lock b/bun.lock index 08b80f8..8bb0b1d 100644 --- a/bun.lock +++ b/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=="], diff --git a/packages/api-contract/package.json b/packages/api-contract/package.json index 2f21ce3..427b28d 100644 --- a/packages/api-contract/package.json +++ b/packages/api-contract/package.json @@ -17,6 +17,7 @@ }, "dependencies": { "@orpc/contract": "^1.13.2", + "@simplewebauthn/types": "^12.0.0", "libphonenumber-js": "^1.12.33", "zod": "^4.3.5" }, diff --git a/packages/api-contract/src/contract.ts b/packages/api-contract/src/contract.ts index 28e32ea..11362fc 100644 --- a/packages/api-contract/src/contract.ts +++ b/packages/api-contract/src/contract.ts @@ -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(), }), ), verifyRegistration: oc .input( z.object({ challengeId: z.number(), - response: z.any(), // RegistrationResponseJSON + response: z.custom(), }), ) .output(z.void()), createAuthenticationOptions: oc.output( z.object({ challengeId: z.number(), - options: z.any(), // PublicKeyCredentialRequestOptionsJSON + options: z.custom(), }), ), verifyAuthentication: oc .input( z.object({ challengeId: z.number(), - response: z.any(), // AuthenticationResponseJSON + response: z.custom(), }), ) .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(), }), ), renamePasskey: oc diff --git a/packages/api-contract/src/schemas/auth.ts b/packages/api-contract/src/schemas/auth.ts index ba45015..c7139ca 100644 --- a/packages/api-contract/src/schemas/auth.ts +++ b/packages/api-contract/src/schemas/auth.ts @@ -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(), }); /**