import type { GateResponse, PaymentResult, XenarchConfig } from "./types.js"; export declare class NoFacilitatorSettledError extends Error { readonly tried: string[]; constructor(tried: string[]); } /** * Make a paid HTTP request to a 402-gated URL. * * XEN-385: dropped `x402-fetch` because its replay sends the raw x402 * `X-PAYMENT` header, which the Xenarch WP plugin's middleware doesn't * recognize — the plugin verifies payments via the canonical Xenarch * `X-Xenarch-Gate-Id` + `X-Xenarch-Tx-Hash` headers. Mirrors the * CLI's pattern (xenarch-sdks/cli/src/lib/payment.ts). * * Steps: * 1. Pick the x402 `accepts` entry to settle against (prefer exact * scheme on the gate's network + USDC). * 2. Sign EIP-3009 `transferWithAuthorization` for USDC on Base via * viem (`account.signTypedData`). * 3. Iterate through `gate.facilitators` in order, POSTing the signed * payload to each `/settle` endpoint until one returns * `success: true` with a tx hash. * 4. Re-fetch the gated URL with the canonical Xenarch headers; the * publisher's middleware stateless-verifies the tx on-chain and * serves the content. * * Throws `NoFacilitatorSettledError` if no facilitator settles. Throws * `Error("Paid fetch failed: ...")` if every facilitator settled but * the publisher's replay returns non-200. */ /** * Settle an x402 envelope and return the on-chain tx — WITHOUT the gate URL * re-fetch. This is the wrapped-pay-link counterpart to payAndFetch: a pay-link * finalizes via POST /v1/links/{id}/claim, not a publisher replay. Kept here so * it reuses the module-private EIP-3009 signing constants; the signing body * mirrors payAndFetch (XEN-414). */ export declare function settleX402(config: XenarchConfig, gate: GateResponse): Promise<{ txHash: string; facilitator: string; }>; export declare function payAndFetch(url: string, config: XenarchConfig, gate: GateResponse): Promise<{ response: Response; result: PaymentResult; }>; //# sourceMappingURL=payment.d.ts.map