import type { RotatableDIDDocument } from '../../../types/passport.js'; export type Ap2ResolveDidDocument = (agentId: string) => Promise; import type { OwnerConfirmation, V2Delegation } from '../../types.js'; import type { AP2Amount, AP2CheckoutMandate, AP2LineItemRequirement, AP2Mandate, AP2Merchant, AP2OpenCheckoutMandate, AP2OpenPaymentMandate, AP2PaymentInstrument, AP2PaymentMandate, AP2Pisp, Ap2VerifyResult, CartDetails, SignedAP2Mandate } from './types.js'; export type { AP2AllowedMerchantsConstraint, AP2AllowedPayeesConstraint, AP2AllowedPaymentInstrumentsConstraint, AP2Amount, AP2AmountRangeConstraint, AP2BudgetConstraint, AP2CheckoutConstraint, AP2CheckoutMandate, AP2Cnf, AP2Item, AP2LineItemRequirement, AP2LineItemsConstraint, AP2Mandate, AP2Merchant, AP2OpenCheckoutMandate, AP2OpenPaymentMandate, AP2PaymentConstraint, AP2PaymentInstrument, AP2PaymentMandate, AP2PaymentReferenceConstraint, AP2Pisp, AP2VctCheckout, AP2VctOpenCheckout, AP2VctOpenPayment, AP2VctPayment, Ap2VerifyReason, Ap2VerifyResult, CartDetails, CartMandate, IntentMandate, SignedAP2Mandate, } from './types.js'; export { AP2_VERSION } from './types.js'; export interface ApsToAp2IntentOptions { /** Currency the budget is denominated in. ISO 4217. */ currency: string; /** Optional list of merchants the intent may settle with. When * omitted, the mandate carries no `allowed_merchants` constraint * (the future cart can settle with any merchant). */ allowed_merchants?: AP2Merchant[]; /** Optional line-item requirement spec. When omitted, no `line_items` * constraint is included. */ line_items?: AP2LineItemRequirement[]; /** Override resource_limits key. Defaults to 'commerce.spend_limit'. */ spend_limit_key?: string; /** Audit B P9 — owner confirmation when the delegation declares an * escalation_requirement on action_class 'commerce'. Required when * the requirement is set; otherwise unused. */ owner_confirmation?: OwnerConfirmation; /** session_id for 'per_session' confirmation scope. */ session_id?: string | null; /** Override clock for tests. */ now?: Date; } /** * Build an AP2 OpenCheckoutMandate from an APS V2Delegation. * * APS delegation → AP2 mapping: * delegation.scope.action_categories → encoded as constraints * via opts.allowed_merchants * and opts.line_items * delegation.delegatee (Ed25519 hex pubkey)→ cnf.jwk (OKP/Ed25519/x) * delegation.policy_context.valid_from → iat (Unix epoch seconds) * delegation.policy_context.valid_until → exp (Unix epoch seconds) */ export declare function apsToAp2IntentMandate(delegation: V2Delegation, opts: ApsToAp2IntentOptions): AP2OpenCheckoutMandate; export interface ApsToAp2CartOptions { /** sha256 hash of the merchant-signed JWT, base64url. When the * caller hasn't computed it (no JWT yet), pass an empty string; * the gateway integration layer fills it before wire emit. */ checkout_hash?: string; /** base64url-encoded merchant-signed JWT of the checkout payload. * Defaults to '' for SDK-only audit; the gateway populates this * for wire-compatible mandates. */ checkout_jwt?: string; /** Audit B P9 — owner confirmation when the delegation declares an * escalation_requirement on action_class 'commerce'. */ owner_confirmation?: OwnerConfirmation; session_id?: string | null; now?: Date; } /** * Build an AP2 CheckoutMandate from an APS V2Delegation + concrete * cart details. AP2 CheckoutMandate is one-way: AP2 has additional * cart fields (specific items + total) that APS delegations don't * encode, so the caller must supply them. * * The reverse direction (CheckoutMandate → V2Delegation) loses the * cart contents — see ap2MandateToApsDelegation. */ export declare function apsToAp2CartMandate(delegation: V2Delegation, cart: CartDetails, opts?: ApsToAp2CartOptions): AP2CheckoutMandate; export interface ApsToAp2PaymentOptions { /** Required: payee merchant. */ payee: AP2Merchant; /** Required: instrument used. */ payment_instrument: AP2PaymentInstrument; /** Required: settlement amount. AP2 PaymentMandate locks a specific * amount; APS delegation carries a spend_limit (cap), so caller * supplies the exact transaction amount here. */ payment_amount: AP2Amount; /** Required: base64url-encoded sha256 of the originating checkout_jwt * (or of any unique identifier for the txn when no JWT exists). */ transaction_id: string; pisp?: AP2Pisp; execution_date?: string; risk_data?: Record; /** Audit B P9 — owner confirmation when the delegation declares an * escalation_requirement on action_class 'commerce'. */ owner_confirmation?: OwnerConfirmation; session_id?: string | null; now?: Date; } export declare function apsToAp2PaymentMandate(delegation: V2Delegation, opts: ApsToAp2PaymentOptions): AP2PaymentMandate; export interface ApsToAp2OpenPaymentOptions { currency: string; /** Override resource_limits key. Defaults to 'commerce.spend_limit'. */ spend_limit_key?: string; allowed_payees?: AP2Merchant[]; allowed_payment_instruments?: AP2PaymentInstrument[]; payment_reference?: string; /** Audit B P9 — owner confirmation when the delegation declares an * escalation_requirement on action_class 'commerce'. */ owner_confirmation?: OwnerConfirmation; session_id?: string | null; now?: Date; } export declare function apsToAp2OpenPaymentMandate(delegation: V2Delegation, opts: ApsToAp2OpenPaymentOptions): AP2OpenPaymentMandate; export interface Ap2ToApsOptions { /** Caller supplies the delegator DID (the user / principal who * authorized the mandate). AP2 encodes the holder via cnf, but * the upstream principal isn't standardized in v0.2. */ delegator_did: string; /** Caller supplies the delegation id (UUID or content hash). AP2 * uses transaction_id / checkout_hash; APS delegations have * their own id space. */ delegation_id: string; /** Default policy_context fields for the resulting V2Delegation. */ policy_version?: string; values_floor_version?: string; trust_epoch?: number; issuer_id?: string; /** ISO 8601 timestamp; defaults to new Date().toISOString(). */ created_at?: string; /** Optional override resource_limits key. */ spend_limit_key?: string; } /** * Reverse crosswalk: AP2 mandate → partial V2Delegation. The result * is a "shape" — issuer/policy fields are filled from opts because * AP2 mandates don't carry APS policy provenance. Callers typically * pass the result through the SDK's V2Delegation construction * pipeline to produce a fully-signed delegation. * * Rules for which mandate types map back: * OpenCheckoutMandate → scope.action_categories=['commerce.checkout'] * constraints surface via scope.constraints * OpenPaymentMandate → scope.action_categories=['commerce.payment'], * budget constraint → resource_limits[spend_limit_key] * CheckoutMandate → scope.action_categories=['commerce.checkout'], * specific cart not preserved (one-way mapping * on the forward direction) * PaymentMandate → scope.action_categories=['commerce.payment'], * specific amount carried as resource_limits */ export declare function ap2MandateToApsDelegation(mandate: AP2Mandate, opts: Ap2ToApsOptions): V2Delegation; export interface SignAp2MandateOptions { /** Phase 4.1 / Q1: opt into the AccountabilityReceiptBase shape on the * outer envelope. The mandate dict itself is unchanged so the signature * remains byte-identical for legacy callers. New envelopes carry * claim_type='rail.ap2.mandate.v1', timestamp, and scope_of_claim. */ accountability_shape?: boolean; /** Override the default scope_of_claim (implies accountability_shape). */ scope_of_claim?: import('../../accountability/types/base.js').ScopeOfClaim; /** Phase 4.1 / P12: when both supplied, signer_did becomes a DID URI * of the form `${issuer_agent_id}#${issuer_key_ref}`. Otherwise the * legacy raw-hex pubkey form is used. Compatible-superset. */ issuer_agent_id?: string; issuer_key_ref?: string; /** Phase 4.1 / Q2: link to the AttributionReceipt this mandate is * paying against. Sits on the envelope, not the mandate dict, so * the AP2 wire-level signature stays byte-identical to legacy. */ attribution_receipt_id?: string; /** Phase 4.1 / Q2: link to the SettlementRecord whose payment_obligations * declared the payment this mandate authorizes. Envelope-side. */ settlement_record_id?: string; } export declare function signAp2Mandate(mandate: T, signerPrivateKeyHex: string, options?: SignAp2MandateOptions): SignedAP2Mandate; export interface VerifyAp2MandateOptions { /** Optional clock for ttl checks; defaults to Date.now(). */ now?: Date; /** Skew tolerance in seconds (default 60). */ clock_skew_seconds?: number; /** When provided, the verifier asserts signed.signer_did === expected_signer_did. */ expected_signer_did?: string; /** Phase 4.1 / P12: required when signer_did is a DID URI. The async * `verifyAp2MandateWithDID` path invokes this resolver. */ resolveDidDocument?: Ap2ResolveDidDocument; } export declare function verifyAp2Mandate(signed: SignedAP2Mandate, options?: VerifyAp2MandateOptions): Ap2VerifyResult; /** Phase 4.1 / P12: async mandate verifier with DID URI support. */ export declare function verifyAp2MandateWithDID(signed: SignedAP2Mandate, options?: VerifyAp2MandateOptions): Promise; //# sourceMappingURL=index.d.ts.map