import type { CeremonyOrder } from "../types.js"; import type { Origin } from "../origin.js"; export interface DcInstrument { issuer: string | null; instrumentId: string | null; maskedAccount: string | null; holder: string | null; expiry: string | null; } export interface DcMandate { type: "ap2.PaymentMandate"; version: "0.1-dc-demo"; id: string; issuedAt: string; expiresAt: string; issuer: string; subject: { credentialId: string | null; }; cart: CeremonyOrder; payment: { instrument: DcInstrument; amount: number; currency: string; }; userAuthorization: { type: "openid4vp-dc-api"; /** The amount-bound transaction_data the wallet would sign over (base64url). */ transactionData: string; /** * The transaction_data_hash Gate 1 re-checks against SHA-256(transactionData). * Instant-demo: the server's own hash (always matches). REAL path: the value * EXTRACTED from the wallet's device-signed DeviceResponse — so Gate 1 verifies * the wallet actually authorized THIS amount/payee. */ transactionDataHash: string | null; /** * The COSE hash-algorithm id the wallet reported in `transaction_data_hash_alg` * (e.g. -16 SHA-256, -43 SHA-384). Null ⇒ the wallet used Multipaz's SHA-256 * default and omitted the element. Gate 1 recomputes the hash with this algorithm. */ transactionDataHashAlg?: number | null; /** Presence-only: the instrument was disclosed but not cryptographically verified. */ presented: boolean; /** * REAL path only — the wallet's raw mdoc vp_token (base64url DeviceResponse) and * the structural issuerAuth/deviceAuth presence Gate 2 reads. Absent on the * instant-demo path (Gate 2 falls back to instrument presence there). */ vpToken?: string; authBlocks?: { hasIssuerAuth: boolean; hasDeviceAuth: boolean; }; }; trust_level: "presence-only-demo"; } /** * Build the presence-only DC payment mandate. The transaction_data is derived from * the (catalog-re-priced) order + this RP's origin, so its amount/payee are the * server's truth; `presentedAmount` is what the caller asserts authorizing (Gate 1 * re-checks it equals the re-derived payable — a tampered value is refused). */ export declare function buildDcMandate(args: { order: CeremonyOrder; origin: Origin; claims: Record; presentedAmount?: number; issuer?: string; }): DcMandate; export interface GateResult { gate: string; pass: boolean; detail: string; } export declare function runDcGates(mandate: DcMandate, origin: Origin, opts?: { loyaltyDiscountPct?: number; }): GateResult[]; /** * Build the DC mandate from a REAL wallet DeviceResponse. Unlike the instant-demo * builder, `transactionDataHash` is the value EXTRACTED from the wallet's * device-signed mdoc (deviceSigned/transaction_data_hash) — Gate 1 then re-checks it * equals SHA-256 of the transaction_data WE sealed (transactionDataB64). The vpToken * + parsed issuerAuth/deviceAuth presence drive Gate 2. The instrument fields come * from the issuer-signed namespaces of the SAME DeviceResponse. */ export declare function buildDcMandateFromPresentation(args: { order: CeremonyOrder; vpStr: string; transactionDataB64: string; issuer?: string; }): DcMandate; export interface DcVerification { mandate: DcMandate; gates: GateResult[]; } /** * Verify the wallet's REAL OpenID4VP presentation: open the sealed reader context, * JWE-decrypt the response (jose ECDH-ES compactDecrypt), pull the mdoc vp_token, * build the amount-bound mandate from the device-signed DeviceResponse, and run the * four gates. Faithfully ported from the demo's payment-gate/dc-payment/verify.ts. * The crypto (decryption + the transaction_data hash binding) is REAL; the issuer * trust anchor is not (trust_level presence-only-demo). */ export declare function verifyDcPresentation(args: { order: CeremonyOrder; origin: Origin; result: { protocol?: string; data?: unknown; }; readerContextToken: string; secret: string; }): Promise;