import type { IntentBoundsInput } from "./bounds.js"; /** The delegate public key (`K_s`) an open mandate names in `cnf` — the agent's key. */ export interface DelegateJwk { kty: "EC"; crv: "P-256"; x: string; y: string; } /** One AP2 Mandate Content object, as it travels in `delegate_payload`. */ export type MandateContent = Record; /** * The delegation format a `delegate` entry names — Delegate SD-JWT §7.1: "REQUIRED string * containing either dSD-JWT or dSD-JWT+KB". NOT the credential's VDC format (`dc+sd-jwt`), which * is what AP2's example carries here; the draft's member names the delegation, not the credential. * `dSD-JWT` is the plain form: the holder delegates, and the agent adds its own key binding later. */ export declare const DELEGATE_FORMAT = "dSD-JWT"; /** The hash algorithms this rail can produce, by their IANA `transaction_data_hashes_alg` name. */ declare const HASH_ALGS: { readonly "sha-256": "sha256"; readonly "sha-384": "sha384"; readonly "sha-512": "sha512"; }; /** One of the algorithms a `delegate` entry may request. */ export type DelegateHashAlg = keyof typeof HASH_ALGS; /** What this rail asks for when a caller names nothing — the SD-JWT default (RFC 9901 §4.1.1). */ export declare const DEFAULT_HASH_ALG: DelegateHashAlg; /** * Why `merchantUrl` can't name a merchant, or null when it can. It must be an absolute * http(s) URL: the store's `walletOrigin`. Checked at runtime because the intent-sign * functions are exported: a JavaScript caller that leaves it out gets a message saying what to * pass (and verify refuses instead of throwing `Invalid URL`), and a value like * `"foo:shop.example/wine"` — which parses, with an empty host — cannot name another store. * It is also the tripwire if a default derived from the request origin ever comes back (#331). */ export declare function merchantUrlProblem(v: unknown): string | null; /** Is `alg` one this rail can actually compute? A wallet asked for anything else cannot answer. */ export declare function isDelegateHashAlg(alg: string): alg is DelegateHashAlg; /** * The two "open" mandates for a grant: what the agent may buy, and how much it may spend. * * CONTENT ONLY, for the WALLET to sign — this is the path where the person grants the authority. * `Ap2Issuer.openCheckout` / `openPayment` are the other path: open mandates the GATE signs with * its own key. Same wire format, different signer, and a verifier must not confuse the two. * * Deterministic in its inputs — the same grant record and delegate key always produce the same * bytes. That is what lets `/verify` rebuild them and compare. * * `exp` is an absolute epoch-seconds expiry. It comes from the grant's own validity window * when it has one; a caller must pass it rather than have this file invent a lifetime, because * an expiry the human never saw is a term they never agreed to. */ export declare function openMandatesForGrant(args: { bounds: IntentBoundsInput; /** The gate's origin — the merchant identity the constraints name. */ origin: string; /** The agent's public key. AP2 binds an open mandate to the agent allowed to use it. */ delegate: DelegateJwk; /** Absolute expiry, epoch seconds. */ exp: number; /** * The concrete product ids the grant may buy, resolved from the SERVER's record and catalog * (`grants._allowedSkusFor`). NOT `bounds.allow.skus`: a category-bounded grant names no * products, and putting its empty list into `checkout.line_items` would say "nothing may be * bought" — the constraint's own meaning — for a grant the human approved for a category. */ allowedSkus: string[]; }): MandateContent[]; /** * Does what the wallet signed match what the server asked it to sign? * * The KB-JWT's `delegate_payload` is an array whose elements have been "replaced with * disclosures" (§5.1.4) — RFC 9901 §4.2.4.2 array-element digests, each `{"...": ""}`. * So the check is: every digest this server computed from its OWN grant record is present. * * WHY CONTAINMENT AND NOT EQUALITY. §7.1 permits the wallet to add decoy digests, and a KB-JWT * with several delegations in it is the draft's normal case. An extra digest authorizes nothing * here — it stands for content this server never produced and will never accept — while * demanding an exact set would refuse a conformant wallet. What is NOT optional is that EVERY * expected digest is there: a wallet that signed only the last entry it was given (#192) fails * this, where a length check alone would have let it through. * * The digest is over the disclosure's exact bytes, which encode the mandate's exact bytes, so a * wallet or a man in the middle that added a constraint, dropped one, or swapped the `cnf` key * for its own produces a different digest and does not match. */ export declare function delegatePayloadMatches(signed: unknown, expectedDigests: string[]): boolean; /** * An RFC 9901 §4.2.4.2 array-element disclosure: `base64url(JSON([salt, value]))`. * * This is what Delegate SD-JWT §7.1 calls "the Array Disclosure of the delegate payload" and * sends in `delegate_payload_disclosure`. The element it discloses is ONE Mandate Content object. */ export declare function arrayDisclosure(salt: string, value: MandateContent): string; /** * The digest of a disclosure, per RFC 9901 §4.2.4.2 — hashed over the ASCII of the disclosure * string itself, not over the value it encodes. Re-encoding the JSON differently therefore * produces a different digest, which is exactly the tamper-evidence we want. */ export declare function disclosureDigest(disclosure: string, alg: DelegateHashAlg): string; /** The `delegate` request entries for a set of mandates, and the digests they must come back as. */ export interface DelegateEntries { /** One `transaction_data` object per mandate, ready to base64url-encode. */ entries: Record[]; /** The array-element digests the KB-JWT's `delegate_payload` must carry, in the same order. */ digests: string[]; /** The disclosures themselves — echoed so a caller can show or log what it asked for. */ disclosures: string[]; } /** * The `transaction_data` entries Delegate SD-JWT §7.1 defines, ready to base64url-encode. * * ONE ENTRY PER MANDATE. §5.1.4's `delegate_payload` array holds one Delegate Payload per * element, and §7.1 says "Multiple delegate transaction_data MAY be included in the same request. * In that case, each MUST have their digest included in the delegate_payload." A grant's checkout * authority and payment authority are two payloads, so they are two entries — which is also the * shape that catches a wallet signing only the last entry it was given (#192). * * `credential_ids` MUST reference the DCQL credential allowed to authorize it; a mismatch * there is one of the ways the whole presentation fails with an error that points nowhere * near the cause. */ export declare function delegateEntries(args: { mandates: MandateContent[]; credentialId: string; /** The gate secret — salts the disclosures so `/verify` can rebuild them (see `delegateSalt`). */ secret: string; /** Scopes the salts to this grant, so two grants never share a disclosure. */ grantId: string; hashAlg?: DelegateHashAlg; }): DelegateEntries; export {};