import { z } from 'zod/v4'; import { UnsignedVCValidator, UnsignedVPValidator, VCValidator, VPValidator, } from '@learncard/types'; const ProofOptionsValidator = z .object({ type: z.string().optional(), verificationMethod: z.string().optional(), proofPurpose: z.string().optional(), proofFormat: z.string().optional(), created: z.string().optional(), challenge: z.string().optional(), domain: z.string().optional(), cryptosuite: z .enum([ 'eddsa-rdfc-2022', 'eddsa-2022', 'json-eddsa-2022', 'ecdsa-2019', 'jcs-ecdsa-2019', ]) .optional(), }) .strict(); const VerificationProofOptionsValidator = ProofOptionsValidator.extend({ checks: z.enum(['proof', 'JWS', 'credentialStatus', 'credentialSchema']).array().optional(), }); export const IssueEndpointValidator = z.object({ credential: UnsignedVCValidator, options: ProofOptionsValidator.extend({ credentialStatus: z.object({ type: z.string() }).optional(), }).optional(), }); export type IssueEndpoint = z.infer; export const IssuePresentationEndpointValidator = z.object({ presentation: UnsignedVPValidator, options: ProofOptionsValidator.optional(), }); export type IssuePresentationEndpoint = z.infer; export const UpdateStatusEndpointValidator = z.object({ credentialId: z.string(), credentialStatus: z .object({ type: z.string().optional(), status: z.string().optional() }) .array() .optional(), }); export type UpdateStatusEndpoint = z.infer; export const VerifyCredentialEndpointValidator = z.object({ verifiableCredential: VCValidator, options: VerificationProofOptionsValidator.optional(), }); export type VerifyCredentialEndpoint = z.infer; export const VerifyPresentationEndpointValidator = z .object({ verifiablePresentation: VPValidator, options: VerificationProofOptionsValidator.optional(), }) .or(z.object({ presentation: UnsignedVPValidator })); export type VerifyPresentationEndpoint = z.infer;