import type { JWTHeader, JWTPayload } from "@europeum-ebsi/did-jwt"; import type { EBSIVerifiablePresentation } from "@europeum-ebsi/vcdm1.1-presentation-schema"; import type { Schemas as VcSchemas, TypeExtensions as VcTypeExtensions, VerifyCredentialOptions, } from "@europeum-ebsi/verifiable-credential/vcdm11.js"; import type { RawAxiosRequestHeaders } from "axios"; import type { JsonWebKey } from "did-resolver"; import type { ProofPurposeTypes } from "../shared/types.ts"; export interface CreateVerifiablePresentationJwtOptions extends CommonOptions { /** * User-defined VP JWT `exp` * If none is provided, fallback to `payload.verifiableCredential` JWTs lowest `exp`. */ exp?: number | undefined; /** * Additional header parameters to add to the JWT header */ header?: Partial; /** * User-defined VP JWT `nbf` * If none is provided, fallback to `payload.verifiableCredential` JWTs highest `nbf`. */ nbf?: number | undefined; /** * The nonce is used to stop a replay attack */ nonce?: string | undefined; /** * Determines whether to validate the Verifiable Presentation payload or not. * Validation is active by default. * * Note: even when skipValidation is set to true, the payload must be a valid * EBSI Verifiable Presentation. * @defaultValue false */ skipValidation?: boolean; } // Aliases for the automatically generated types export interface Schemas extends VcSchemas { Presentation: EBSIVerifiablePresentation; } export type TypeExtensions = VcTypeExtensions; export interface VerifyPresentationJwtOptions extends CommonOptions { /** * Time in seconds expanding the validity period of the JWT, both before "nbf" and after "exp". Default : 0 second. * Note: the did-jwt library uses a similar `skewTime` parameter with a default value of 5 minutes (300 seconds). */ clockSkew?: number; /** * Determines whether to validate the signature of the VP JWT or not. * Validation is active by default. * @defaultValue false */ skipSignatureValidation?: boolean; /** * Unix timestamp. Optional comparison date. Default: current date and time. * For the JWT to be valid, `nbf` ≤ `validAt` ≤ `exp`. */ validAt?: number; } export type VpJwtHeader = JWTHeader & { alg: "EdDSA" | "ES256" | "ES256K"; jwk?: JsonWebKey; kid: string; typ: "JWT"; }; export interface VpJwtPayload extends JWTPayload { iat: number; iss: string; jti: string; sub: string; vp: Schemas["Presentation"]; } /** * Options that are common to both `verifyPresentationJwt` and `createVerifiablePresentationJwt` */ interface CommonOptions { /** * Custom Axios request headers */ axiosHeaders?: RawAxiosRequestHeaders; /** * Verification relationship * @defaultValue "authentication" */ proofPurpose?: ProofPurposeTypes; /** * Determines whether to validate the resolution of the VP holder DID or not. * Validation is active by default. * @defaultValue false */ skipHolderDidResolutionValidation?: boolean; /** * Axios requests timeout (in milliseconds). Default: 15 seconds */ timeout?: number; /** * Credential verification options */ verifyCredentialOptions?: VerifyCredentialOptions; }