/** A priced cart line the mandate seals (the fields the gates re-derive from). */ export interface CartMandateLine { id: string; quantity: number; unitPrice: number; lineTotal: number; minimumAge?: number; } export interface CartMandate { type: "ap2.CartMandate"; /** Stable id (defaults to `cart_`); a PaymentMandate can reference it. */ id: string; /** The order this cart is bound to — a mandate replayed against another order is refused. */ orderId: string; lines: CartMandateLine[]; currency: string; /** Cart total in major units — re-derived server-side, sealed here for integrity. */ total: number; /** Epoch ms. */ issuedAt: number; expiresAt: number; /** Signature suite. v0.1 = server HMAC-SHA256; reserved for a future key-bound variant. */ alg: "HS256"; trust_level: "presence-only-demo"; /** base64url HMAC over the canonical payload. */ signature: string; } /** Default validity window — mirrors the challenge-token TTL policy. */ export declare const DEFAULT_CART_MANDATE_TTL_MS: number; export interface IssueCartMandateArgs { orderId: string; lines: CartMandateLine[]; currency: string; total: number; /** Defaults to `cart_`. */ id?: string; /** Injectable clock (tests); defaults to `Date.now()`. */ now?: number; ttlMs?: number; } /** Issue (sign) a Cart Mandate for a server-priced cart. */ export declare function issueCartMandate(args: IssueCartMandateArgs, secret: string): CartMandate; /** * Decode a Cart Mandate carried on a GET request's `cart` query param as base64url * JSON — the `statelessOrders` transport (FR-007). Returns `undefined` for a * missing/garbage value; `verifyCartMandate` is the real gate, so decoding is * trust-free (a bad value just falls through to the store path / fails closed). */ export declare function decodeCartMandateParam(v: unknown): unknown; export type CartMandateRefusal = "malformed" | "signature" | "order-id" | "expired"; export type CartMandateVerdict = { ok: true; mandate: CartMandate; } | { ok: false; reason: CartMandateRefusal; }; /** * Verify a Cart Mandate against the order it should be bound to. Checks, in order: * 1. shape (a malformed/non-mandate object is refused); * 2. SIGNATURE — recompute the HMAC over the canonical payload + constant-time compare, * so a forged or edited cart fails here first (`signature`); * 3. order-id binding — a valid mandate replayed against a different order (`order-id`); * 4. expiry — a stale mandate, with a DISTINCT reason so a slow buyer sees "expired", * not "tampered" (`expired`). * Returns the typed verdict; it never throws. */ export declare function verifyCartMandate(mandate: unknown, expectedOrderId: string, secret: string, now?: number): CartMandateVerdict;