@bosonprotocol/x402-client 0.1.0-alpha-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/action.ts","../../src/fulfillment.ts","../../src/response.ts","../../src/payload.ts","../../src/pre-commit.ts","../../src/post-commit.ts","../../src/withdraw.ts","../../src/client.ts","../../src/signer-from-adapter.ts"],"names":["encodeSignedPayload"],"mappings":";;;;;;;;AAyBA,IAAM,MAAA,GAA8B,4BAAA;AACpC,IAAM,MAAA,GAA8B,kCAAA;AAO7B,SAAS,UAAA,CACd,cACA,MAAA,EACqB;AACrB,EAAA,MAAM,UAAA,GAAa,QAAQ,UAAA,IAAc,MAAA;AAEzC,EAAA,MAAM,YAAA,GAAe,YAAA,CAAa,OAAA,CAAQ,IAAA,CAAK,IAAA;AAAA,IAC7C,CAAC,MAAM,CAAA,CAAE,EAAA,KAAO,UAAU,CAAA,CAAE,QAAA,CAAS,SAAS,QAAQ;AAAA,GACxD;AACA,EAAA,MAAM,YAAA,GAAe,YAAA,CAAa,OAAA,CAAQ,IAAA,CAAK,IAAA;AAAA,IAC7C,CAAC,MAAM,CAAA,CAAE,EAAA,KAAO,UAAU,CAAA,CAAE,QAAA,CAAS,SAAS,QAAQ;AAAA,GACxD;AAEA,EAAA,IAAI,eAAe,mBAAA,EAAqB;AACtC,IAAA,IAAI,cAAc,OAAO,MAAA;AACzB,IAAA,MAAM,IAAI,uBAAA;AAAA,MACR,CAAA,gDAAA,EAAmD,MAAM,CAAA,sDAAA,EAAyD,YAAA,CAAa,QAAQ,IAAA,CAAK,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,CAAE,EAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAAA,KACzK;AAAA,EACF;AAEA,EAAA,IAAI,eAAe,aAAA,EAAe;AAChC,IAAA,IAAI,cAAc,OAAO,MAAA;AACzB,IAAA,MAAM,I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AqB,IAAA,EAAM,WAAW,CAAA;AAC5D,EAAA,IAAI,MAAA,CAAO,IAAA,KAAS,MAAA,EAAW,MAAA,CAAO,IAAA,CAAK,EAAE,IAAA,EAAM,MAAA,EAAQ,IAAA,EAAM,SAAA,EAAW,CAAA;AAC5E,EAAA,OAAO,MAAA;AACT","file":"index.js","sourcesContent":["// Pick the on-chain Boson action to invoke from a parsed PaymentRequirements.\n//\n// Two commit-time actions are supported:\n// - `boson-createOfferAndCommit` (Flow A, deferred redeem)\n// - `boson-createOfferCommitAndRedeem` (Flow B, atomic commit+redeem)\n//\n// Selection rules:\n// - `policy.redeemMode = \"commit-only\"`: require Flow A.\n// - `policy.redeemMode = \"auto\"` (or unset): prefer Flow A, fall back to Flow B.\n// - `policy.redeemMode = \"commit-and-redeem\"`: require Flow B; throw\n// `NoCompatibleActionError` if the server hasn't advertised it.\n//\n// In \"auto\" mode we keep MVP behaviour (prefer Flow A whenever advertised)\n// so existing callers don't silently switch flows on the SDK upgrade. A\n// future policy could promote Flow B when both are offered, but that's a\n// separate change.\n\nimport type {\n BosonCommitActionId,\n EscrowPaymentRequirements,\n} from \"@bosonprotocol/x402-core/schemes/escrow\";\n\nimport { NoCompatibleActionError } from \"./errors.js\";\nimport type { Policy } from \"./types.js\";\n\nconst FLOW_A: BosonCommitActionId = \"boson-createOfferAndCommit\";\nconst FLOW_B: BosonCommitActionId = \"boson-createOfferCommitAndRedeem\";\n\n/**\n * Resolve the Boson commit-time action the client will sign. Throws\n * `NoCompatibleActionError` when the server hasn't advertised any action\n * compatible with the requested policy.\n */\nexport function pickAction(\n requirements: EscrowPaymentRequirements,\n policy?: Policy,\n): BosonCommitActionId {\n const redeemMode = policy?.redeemMode ?? \"auto\";\n\n const flowAOffered = requirements.actions.next.some(\n (a) => a.id === FLOW_A && a.channels.includes(\"server\"),\n );\n const flowBOffered = requirements.actions.next.some(\n (a) => a.id === FLOW_B && a.channels.includes(\"server\"),\n );\n\n if (redeemMode === \"commit-and-redeem\") {\n if (flowBOffered) return FLOW_B;\n throw new NoCompatibleActionError(\n `policy.redeemMode='commit-and-redeem' requires '${FLOW_B}' on the server channel; requirements only advertise [${requirements.actions.next.map((a) => a.id).join(\", \")}]`,\n );\n }\n\n if (redeemMode === \"commit-only\") {\n if (flowAOffered) return FLOW_A;\n throw new NoCompatibleActionError(\n `policy.redeemMode='commit-only' requires '${FLOW_A}' on the server channel; requirements only advertise [${requirements.actions.next.map((a) => a.id).join(\", \")}]`,\n );\n }\n\n // \"auto\": prefer Flow A when present, but fall back to Flow B.\n if (flowAOffered) return FLOW_A;\n if (flowBOffered) return FLOW_B;\n\n throw new NoCompatibleActionError(\n `no commit-time action ('${FLOW_A}' or '${FLOW_B}') with 'server' channel found in requirements.actions.next`,\n );\n}\n","// Resolve the `fulfillment` slot the client will attach to the commit-time\n// payment payload. The buyer's chosen `option` always flows (capability\n// negotiation against the server's advertised set); the `data` field is\n// validated locally against the option's JSON Schema either way so the\n// client fails fast before signing — but whether it travels with the\n// commit-time payload depends on the action the client is signing:\n//\n// - Atomic Flow B (`boson-createOfferCommitAndRedeem`): the commit and\n// on-chain redeem happen in one transaction, so the X-PAYMENT header\n// is the only round trip the buyer makes. `data` MUST be present.\n// - Two-step Flow A (`boson-createOfferAndCommit`): the buyer redeems\n// later via `boson-redeem`'s POST body — `data` is omitted at commit\n// and attached at redeem.\n//\n// The conditional emission lives in the payload assembler (`payload.ts`);\n// this module returns both `option` and `data` and lets the caller decide.\n\nimport Ajv from \"ajv\";\nimport type { EscrowPaymentRequirements } from \"@bosonprotocol/x402-core/schemes/escrow\";\n\nimport { FulfillmentValidationError } from \"./errors.js\";\nimport type { FulfillmentConfig, X402bClientConfig } from \"./types.js\";\n\nexport interface ResolvedFulfillment {\n option: string;\n /**\n * Buyer-supplied delivery data, validated locally against the option's\n * JSON Schema. The payload assembler decides whether to include this\n * field in the commit-time payload (Flow B yes, Flow A no).\n */\n data: Record<string, unknown> | null;\n}\n\n/**\n * Returns the resolved `{ option, data }` pair the assembler will attach\n * to the commit-time fulfillment slot (Flow B) or carry forward for the\n * redeem-time POST body (Flow A). Throws when the requirements demand a\n * fulfillment but the client config doesn't supply one, when the option\n * id isn't advertised by the server, or when the buyer data doesn't\n * validate against the option's schema.\n */\nexport function resolveFulfillment(\n requirements: EscrowPaymentRequirements,\n config: Pick<X402bClientConfig, \"fulfillment\">,\n): ResolvedFulfillment | undefined {\n const required = requirements.fulfillment?.required ?? false;\n if (!required) {\n return undefined;\n }\n\n const fulfillmentConfig: FulfillmentConfig | undefined = config.fulfillment;\n if (!fulfillmentConfig) {\n throw new FulfillmentValidationError(\n \"requirements.fulfillment.required is true but client config did not supply a fulfillment selection\",\n );\n }\n\n const option = requirements.fulfillment?.options.find((o) => o.id === fulfillmentConfig.option);\n if (!option) {\n const advertised = requirements.fulfillment?.options.map((o) => o.id).join(\", \") ?? \"<none>\";\n throw new FulfillmentValidationError(\n `fulfillment option '${fulfillmentConfig.option}' not advertised by requirements (advertised: ${advertised})`,\n );\n }\n\n if (option.schema === null) {\n if (fulfillmentConfig.data !== null) {\n throw new FulfillmentValidationError(\n `fulfillment option '${option.id}' accepts no buyer data; use null`,\n );\n }\n } else {\n const ajv = new Ajv({ allErrors: true, strict: false });\n const validate = ajv.compile(option.schema);\n const ok = validate(fulfillmentConfig.data);\n if (!ok) {\n throw new FulfillmentValidationError(\n `fulfillment data does not match option '${option.id}' schema: ${ajv.errorsText(validate.errors)}`,\n );\n }\n }\n\n return { option: fulfillmentConfig.option, data: fulfillmentConfig.data };\n}\n","// Parse the optional `X-PAYMENT-RESPONSE` header the server may emit after\n// settling.\n//\n// The escrow-scheme spec doesn't pin a strict contract for this header yet,\n// so the parser is permissive: base64-decode the value, JSON-parse it, and\n// return `{ raw }`. Best-effort lifting picks `exchangeId` / `state` from\n// the common property paths an x402B server might use. Callers who need\n// stronger guarantees can read `raw` directly.\n\nimport type { ExchangeSummary } from \"./types.js\";\n\nconst HEADER_NAME = \"X-PAYMENT-RESPONSE\";\n\n/** Read a header value from anything that exposes `.get(name)`. */\ninterface HeaderLike {\n get(name: string): string | null;\n}\n\ninterface ResponseLike {\n headers: HeaderLike;\n}\n\n/**\n * Decode the `X-PAYMENT-RESPONSE` header on a Response-like object. Returns\n * `undefined` when the header isn't set; throws on a malformed payload.\n */\nexport function parsePaymentResponse(response: ResponseLike): ExchangeSummary | undefined {\n const raw = response.headers.get(HEADER_NAME);\n if (!raw) {\n return undefined;\n }\n\n const json = decodeBase64(raw);\n const parsed: unknown = JSON.parse(json);\n const summary: ExchangeSummary = { raw: parsed };\n\n // Only walk into the payload when it's actually a plain record. A valid\n // JSON value can be `null`, an array, or a primitive — touching keys on\n // those would crash, defeating the file-header permissive promise.\n if (typeof parsed === \"object\" && parsed !== null && !Array.isArray(parsed)) {\n const obj = parsed as Record<string, unknown>;\n\n const exchangeId = pickString(obj, [\"exchangeId\", \"exchange_id\"]);\n if (exchangeId !== undefined) {\n summary.exchangeId = exchangeId;\n }\n\n if (isClientStateShape(obj.state)) {\n summary.state = obj.state;\n }\n\n // Fallback for the server-emitted shape, which carries exchange state\n // under `nextActions.exchangeState` (and optionally `disputeState`)\n // rather than a top-level `state` field. The top-level lookup above\n // still wins when present, preserving forward-compat with external\n // servers that publish the flatter shape.\n if (\n summary.state === undefined &&\n typeof obj.nextActions === \"object\" &&\n obj.nextActions !== null &&\n !Array.isArray(obj.nextActions)\n ) {\n const na = obj.nextActions as Record<string, unknown>;\n const exchange = pickString(na, [\"exchangeState\"]);\n const dispute = pickString(na, [\"disputeState\"]);\n if (exchange !== undefined) {\n let candidate: unknown;\n if (exchange === \"DISPUTED\") {\n candidate = dispute !== undefined ? { exchange, dispute } : undefined;\n } else {\n candidate = { exchange };\n }\n if (isClientStateShape(candidate)) {\n summary.state = candidate;\n }\n }\n }\n }\n\n return summary;\n}\n\n/**\n * Shape gate for `state` arriving from the permissive server header. We\n * keep the file-header promise of permissiveness — `ClientState` is\n * `\"PRE_COMMIT\"` or an `{ exchange, dispute? }` record today, but the\n * wire contract isn't pinned, so any non-empty string (e.g. raw\n * `ExchangeState` value) or non-array `{ exchange }`-shaped record is\n * surfaced verbatim. Numbers, booleans, `null`, empty strings, arrays,\n * and records missing a string `exchange` field are rejected so garbage\n * payloads can't masquerade as a typed `ClientState`.\n */\nfunction isClientStateShape(v: unknown): v is NonNullable<ExchangeSummary[\"state\"]> {\n if (typeof v === \"string\") return v.length > 0;\n if (typeof v !== \"object\" || v === null || Array.isArray(v)) return false;\n const rec = v as Record<string, unknown>;\n if (typeof rec.exchange !== \"string\" || rec.exchange.length === 0) return false;\n if (\"dispute\" in rec && rec.dispute !== undefined && typeof rec.dispute !== \"string\") {\n return false;\n }\n return true;\n}\n\nfunction decodeBase64(value: string): string {\n if (typeof Buffer !== \"undefined\") {\n return Buffer.from(value, \"base64\").toString(\"utf8\");\n }\n const binary = atob(value);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return new TextDecoder().decode(bytes);\n}\n\nfunction pickString(obj: Record<string, unknown>, keys: string[]): string | undefined {\n for (const key of keys) {\n const v = obj[key];\n if (typeof v === \"string\" && v.length > 0) {\n return v;\n }\n }\n return undefined;\n}\n","// Assemble the X-PAYMENT body and base64-encode it.\n//\n// Defense-in-depth: the assembled `EscrowPaymentPayload` is re-validated\n// through `parseEscrowPaymentPayload` from `@bosonprotocol/x402-core`\n// before serialization, so shape bugs surface here instead of at the\n// server. Base64 encoding picks `Buffer` on Node and `btoa` on browser\n// targets — tsup builds both, so the runtime branch matters.\n\nimport {\n parseEscrowPaymentPayload,\n type BosonMetaTx,\n type BosonTokenAuth,\n type EscrowPaymentPayload,\n type EscrowPaymentRequirements,\n type TokenAuthStrategy,\n} from \"@bosonprotocol/x402-core/schemes/escrow\";\nimport type { Address } from \"viem\";\n\nimport type { ResolvedFulfillment } from \"./fulfillment.js\";\n\n/** Current x402 protocol version embedded in the payload envelope. */\nexport const X402_VERSION = 2;\n\nexport interface AssembleArgs {\n requirements: EscrowPaymentRequirements;\n action: string;\n tokenAuthStrategy: TokenAuthStrategy;\n metaTx: BosonMetaTx;\n tokenAuth?: BosonTokenAuth;\n fulfillment?: ResolvedFulfillment;\n buyer: Address;\n}\n\n/** Construct and re-validate the payload, returning the structured object. */\nexport function assemblePayload({\n requirements,\n action,\n tokenAuthStrategy,\n metaTx,\n tokenAuth,\n fulfillment,\n buyer,\n}: AssembleArgs): EscrowPaymentPayload {\n // Fulfillment `data` rides along only for atomic Flow B — Flow A\n // defers it to the redeem POST body. The conditional emission keeps\n // the assembler aligned with the server-side rule-13 validator that\n // rejects `data` on Flow A and requires it on Flow B.\n const fulfillmentSlot =\n fulfillment === undefined\n ? undefined\n : action === \"boson-createOfferCommitAndRedeem\"\n ? { option: fulfillment.option, data: fulfillment.data }\n : { option: fulfillment.option };\n\n const payload: EscrowPaymentPayload = {\n x402Version: X402_VERSION,\n scheme: \"escrow\",\n network: requirements.network,\n payload: {\n action,\n tokenAuthStrategy,\n offerRef: {\n fullOffer: requirements.offer.fullOffer,\n sellerSig: requirements.offer.sellerSig,\n },\n buyer,\n metaTx,\n ...(tokenAuth ? { tokenAuth } : {}),\n },\n ...(fulfillmentSlot ? { fulfillment: fulfillmentSlot } : {}),\n };\n\n // Defensive re-parse — surfaces shape bugs (e.g. malformed hex) before\n // the payload escapes the client.\n parseEscrowPaymentPayload(payload);\n return payload;\n}\n\n/** Build, validate, and base64-encode the payload for the `X-PAYMENT` header. */\nexport function assembleAndEncodePayload(args: AssembleArgs): string {\n const payload = assemblePayload(args);\n const json = JSON.stringify(payload);\n if (typeof Buffer !== \"undefined\") {\n return Buffer.from(json, \"utf8\").toString(\"base64\");\n }\n // Browser fallback. Wire payloads mostly carry hex/numeric strings,\n // but atomic Flow B's `fulfillment.data` is a `Record<string, unknown>`\n // the buyer populates — emails, addresses, free-form notes. `btoa`\n // accepts only a binary string (code units 0–255) and throws\n // `InvalidCharacterError` on any character above U+00FF. UTF-8 encode\n // the JSON first, then map the bytes into the binary-string form\n // `btoa` expects.\n const bytes = new TextEncoder().encode(json);\n let binary = \"\";\n for (const b of bytes) {\n binary += String.fromCharCode(b);\n }\n return btoa(binary);\n}\n","// Sign the buyer's Boson protocol meta-transaction for one of the two\n// commit-time actions:\n//\n// - Flow A — `boson-createOfferAndCommit` (deferred redeem). Signed via\n// `coreSdk.signMetaTxCreateOfferAndCommit`.\n// - Flow B — `boson-createOfferCommitAndRedeem` (atomic commit+redeem\n// via `OrchestrationHandlerFacet2.createOfferCommitAndRedeem`). Signed\n// via `coreSdk.signMetaTxCreateOfferCommitAndRedeem`.\n//\n// Both route through `CoreSDK` directly so the EIP-712 domain, function\n// signature, and calldata encoding stay in lock-step with the deployed\n// protocol. The returned `SignedMetaTx` is shaped exactly as the on-chain\n// `MetaTransactionsHandlerFacet` recovers against; we re-shape it into\n// the escrow scheme's wire-format `BosonMetaTx` for the X-PAYMENT payload.\n\nimport type { CoreSDK } from \"@bosonprotocol/core-sdk\";\nimport type { FullOfferArgs } from \"@bosonprotocol/common\";\nimport type {\n BosonMetaTx,\n EscrowPaymentRequirements,\n} from \"@bosonprotocol/x402-core/schemes/escrow\";\nimport type { Address, Hex } from \"viem\";\n\nimport { randomUint256 } from \"./utils/crypto.js\";\n\nexport interface SignCreateOfferAndCommitArgs {\n requirements: EscrowPaymentRequirements;\n coreSdk: CoreSDK;\n buyer: Address;\n}\n\n/**\n * Builds the buyer-side meta-tx for `createOfferAndCommit`, signs it via\n * `CoreSDK`, and returns the wire-format envelope ready to be embedded in\n * an `EscrowPaymentPayload`.\n *\n * The `createOfferAndCommitArgs` are reconstructed from the\n * `requirements.offer` triple — the opaque `fullOffer` carries the\n * `Omit<FullOfferArgs, \"signature\">` shape, `sellerSig` becomes the\n * `signature`, and the buyer's address is spliced in as `committer`. Any\n * shape drift between the wire format and `FullOfferArgs` surfaces as a\n * yup validation error from core-sdk's\n * `createOfferAndCommitArgsSchema.validateSync` — propagate it rather than\n * patch silently (CLAUDE.md \"Production over spec when they diverge\").\n */\nexport async function signCreateOfferAndCommit({\n requirements,\n coreSdk,\n buyer,\n}: SignCreateOfferAndCommitArgs): Promise<BosonMetaTx> {\n const nonce = randomUint256();\n\n const createOfferAndCommitArgs = buildCreateOfferAndCommitArgs(requirements, buyer);\n\n const signed = await coreSdk.signMetaTxCreateOfferAndCommit({\n nonce: nonce.toString(),\n createOfferAndCommitArgs,\n });\n\n return reshape(signed, buyer, nonce);\n}\n\n/**\n * Flow B counterpart to {@link signCreateOfferAndCommit} — signs\n * the meta-tx that drives `OrchestrationHandlerFacet2.createOfferCommitAndRedeem`.\n * The argument shape is identical (the protocol uses the same\n * `FullOfferArgs` struct); only the resulting function selector and\n * post-state differ.\n */\nexport async function signCreateOfferCommitAndRedeem({\n requirements,\n coreSdk,\n buyer,\n}: SignCreateOfferAndCommitArgs): Promise<BosonMetaTx> {\n const nonce = randomUint256();\n\n const createOfferAndCommitArgs = buildCreateOfferAndCommitArgs(requirements, buyer);\n\n const signed = await coreSdk.signMetaTxCreateOfferCommitAndRedeem({\n nonce: nonce.toString(),\n createOfferAndCommitArgs,\n });\n\n return reshape(signed, buyer, nonce);\n}\n\nfunction buildCreateOfferAndCommitArgs(\n requirements: EscrowPaymentRequirements,\n buyer: Address,\n): FullOfferArgs {\n return {\n ...(requirements.offer.fullOffer as object),\n signature: requirements.offer.sellerSig,\n committer: buyer,\n } as unknown as FullOfferArgs;\n}\n\nfunction reshape(\n signed: {\n functionName: string;\n functionSignature: string;\n r: string;\n s: string;\n v: number;\n },\n buyer: Address,\n nonce: bigint,\n): BosonMetaTx {\n return {\n from: buyer,\n nonce: nonce.toString(),\n functionName: signed.functionName,\n functionSignature: signed.functionSignature as Hex,\n sig: {\n v: Number(signed.v),\n r: signed.r as Hex,\n s: signed.s as Hex,\n },\n };\n}\n","// Sign Boson protocol meta-transactions for post-commit buyer actions.\n//\n// These are the transitions the buyer can drive once an exchange exists on\n// chain: redeem the voucher, cancel/complete the exchange, or move through\n// the dispute family. Each is a single-call meta-tx that the\n// server/facilitator submits via\n// `MetaTransactionsHandlerFacet.executeMetaTransaction`. None of them\n// carry a token-auth payload (the funds are already escrowed) so the\n// returned `BosonMetaTx` is the full wire-format the server consumes —\n// usually as a JSON POST body, not an `X-PAYMENT` header.\n//\n// We return both the `BosonMetaTx` envelope (useful for on-chain or MCP\n// channels) and the ABI-encoded `signedPayload` Hex consumed by the\n// server/facilitator HTTP convenience routes. The encoder lives in\n// `@bosonprotocol/x402-evm/codec` so client and facilitator share one\n// implementation.\n//\n// `boson-escalateDispute` is the one exception. If the dispute resolver\n// requires an escalation deposit, the resolver/server can return its own\n// 402 carrying an `escrow` `PaymentRequirements` and the buyer pairs this\n// meta-tx with a token-auth payload — that wrapper lives outside MVP. Here\n// we only sign the meta-tx itself; the deposit flow is a later PR.\n\nimport type { CoreSDK } from \"@bosonprotocol/core-sdk\";\nimport type { BosonMetaTx, Hex as WireHex } from \"@bosonprotocol/x402-core/schemes/escrow\";\nimport type { ActionId } from \"@bosonprotocol/x402-core/state-machine\";\nimport { encodeSignedPayload } from \"@bosonprotocol/x402-evm/codec\";\nimport type { Address, Hex } from \"viem\";\n\nimport { randomUint256 } from \"./utils/crypto.js\";\n\n// Matches the subset of ethers' `BigNumberish` core-sdk actually accepts at\n// runtime, without pulling `@ethersproject/bignumber` into this package's\n// declared deps. Callers usually pass decimal strings (the wire format).\ntype BigNumberish = string | number | bigint;\n\n/**\n * Buyer-invokable post-commit action ids — derived from `ActionId` in\n * `@bosonprotocol/x402-core/state-machine` (the single source of truth)\n * by excluding:\n *\n * - the commit-time ids, which the buyer signs via `handle402`;\n * - `boson-revokeVoucher`, which is seller-only;\n * - entity-keyed actions (`boson-withdrawFunds`), which are signed via\n * `client.signWithdrawFunds` / `client.signWithdrawAllAvailableFunds`\n * because they take an `entityId` + token list rather than an\n * `exchangeId`.\n */\ntype BuyerPostCommitActionId = Exclude<\n ActionId,\n | \"boson-createOfferAndCommit\"\n | \"boson-createOfferCommitAndRedeem\"\n | \"boson-revokeVoucher\"\n | \"boson-withdrawFunds\"\n>;\n\n/** Caller-supplied arguments for `client.signAction`. */\nexport type SignActionArgs = SimplePostCommitArgs | ResolveDisputeArgs;\n\ninterface BaseArgs {\n exchangeId: BigNumberish;\n /** CAIP-2 network identifier (e.g. `\"eip155:8453\"`). */\n network: string;\n /** Boson Diamond address (the `escrowAddress` from the prior 402). */\n escrowAddress: Address;\n}\n\nexport interface SimplePostCommitArgs extends BaseArgs {\n actionId: Exclude<BuyerPostCommitActionId, \"boson-resolveDispute\">;\n}\n\nexport interface ResolveDisputeArgs extends BaseArgs {\n actionId: \"boson-resolveDispute\";\n /** Buyer share of the disputed amount, in the units the protocol expects (basis points). */\n buyerPercent: BigNumberish;\n /** Counterparty (seller) signature over the proposal. Hex string or `{r, s, v}`. */\n counterpartySig: Hex | { r: Hex; s: Hex; v: number };\n}\n\nexport interface SignPostCommitActionDeps {\n buildCoreSdk: (network: string, escrowAddress: Address) => { coreSdk: CoreSDK; chainId: number };\n getBuyerAddress: () => Promise<Address>;\n}\n\n/**\n * Wire-format result of `signPostCommitAction`: the signed `BosonMetaTx`\n * envelope plus its ABI-encoded `signedPayload` Hex. Pick the one that\n * matches the channel — the server/facilitator HTTP routes consume\n * `signedPayload`; direct on-chain or MCP submissions use `metaTx`.\n */\nexport interface SignedPostCommitAction {\n metaTx: BosonMetaTx;\n /**\n * ABI-encoded `BosonMetaTx` ready to drop into a server / facilitator\n * route's `signedPayload` field. The hex is JSON-serialisable; we type\n * it as the loose wire `Hex` (string) rather than viem's strict\n * `\\`0x\\${string}\\`` so the codec's output matches the schemes module's\n * own `Hex` alias.\n */\n signedPayload: WireHex;\n}\n\n/**\n * Sign a post-commit action through the appropriate `CoreSDK.signMetaTx*`\n * mixin method. Returns both the wire-format `BosonMetaTx` envelope and\n * the ABI-encoded `signedPayload` Hex ready to POST to a server /\n * facilitator route.\n */\nexport async function signPostCommitAction(\n args: SignActionArgs,\n deps: SignPostCommitActionDeps,\n): Promise<SignedPostCommitAction> {\n const nonce = randomUint256();\n const buyer = await deps.getBuyerAddress();\n const { coreSdk } = deps.buildCoreSdk(args.network, args.escrowAddress);\n\n const signed = await callSignMetaTx(coreSdk, args, nonce);\n\n const metaTx: BosonMetaTx = {\n from: buyer,\n nonce: nonce.toString(),\n functionName: signed.functionName,\n functionSignature: signed.functionSignature as Hex,\n sig: {\n v: Number(signed.v),\n r: signed.r as Hex,\n s: signed.s as Hex,\n },\n };\n\n return { metaTx, signedPayload: encodeSignedPayload(metaTx) };\n}\n\ninterface SignedMetaTxShape {\n functionName: string;\n functionSignature: string;\n r: string;\n s: string;\n v: number;\n}\n\nasync function callSignMetaTx(\n coreSdk: CoreSDK,\n args: SignActionArgs,\n nonce: bigint,\n): Promise<SignedMetaTxShape> {\n const nonceStr = nonce.toString();\n const exchangeId = args.exchangeId;\n\n switch (args.actionId) {\n case \"boson-redeem\":\n return coreSdk.signMetaTxRedeemVoucher({ nonce: nonceStr, exchangeId });\n case \"boson-cancelVoucher\":\n return coreSdk.signMetaTxCancelVoucher({ nonce: nonceStr, exchangeId });\n case \"boson-completeExchange\":\n return coreSdk.signMetaTxCompleteExchange({ nonce: nonceStr, exchangeId });\n case \"boson-raiseDispute\":\n return coreSdk.signMetaTxRaiseDispute({ nonce: nonceStr, exchangeId });\n case \"boson-retractDispute\":\n return coreSdk.signMetaTxRetractDispute({ nonce: nonceStr, exchangeId });\n case \"boson-escalateDispute\":\n return coreSdk.signMetaTxEscalateDispute({ nonce: nonceStr, exchangeId });\n case \"boson-resolveDispute\":\n return coreSdk.signMetaTxResolveDispute({\n nonce: nonceStr,\n exchangeId,\n buyerPercent: args.buyerPercent,\n counterpartySig: args.counterpartySig,\n });\n default: {\n // The discriminated union makes this unreachable at the type level;\n // the `never` annotation enforces exhaustiveness at compile time, and\n // the throw guarantees a clear error if a runtime value ever slips\n // past the type checker.\n const _exhaustive: never = args;\n throw new Error(\n `x402-client: unsupported post-commit action '${(_exhaustive as { actionId: string }).actionId}'`,\n );\n }\n }\n}\n","// Sign Boson protocol meta-transactions for the entity-keyed\n// `boson-withdrawFunds` action.\n//\n// Unlike the buyer-side post-commit signers, withdraw is keyed by the\n// Boson account `entityId` (buyer or seller) rather than an exchange\n// id. The on-chain primitive is\n// `FundsHandlerFacet.withdrawFunds(uint256 entityId, address[] tokenList,\n// uint256[] tokenAmounts)`. The meta-tx variant\n// (`coreSdk.signMetaTxWithdrawFunds`) wraps that calldata in an EIP-712\n// envelope ready for `MetaTransactionsHandlerFacet.executeMetaTransaction`.\n//\n// Scope cap for v1: callers withdraw the *whole* current balance set.\n// `signWithdrawAllAvailableFunds` reads the funds entity from the\n// subgraph, drops zero balances, then delegates to `signWithdrawFunds`\n// for the actual EIP-712 sign. Partial / user-chosen amounts can be\n// added later without a wire-format change.\n\nimport type { CoreSDK } from \"@bosonprotocol/core-sdk\";\nimport {\n DECIMAL_UINT,\n type BosonMetaTx,\n type Hex as WireHex,\n} from \"@bosonprotocol/x402-core/schemes/escrow\";\nimport { encodeSignedPayload } from \"@bosonprotocol/x402-evm/codec\";\nimport type { Address, Hex } from \"viem\";\n\nimport { randomUint256 } from \"./utils/crypto.js\";\n\n// Matches the subset of ethers' `BigNumberish` core-sdk actually accepts at\n// runtime, without pulling `@ethersproject/bignumber` into this package's\n// declared deps. Callers usually pass decimal strings (the wire format).\ntype BigNumberish = string | number | bigint;\n\n/**\n * Coerce a caller-supplied `entityId` to its canonical wire form (a\n * non-negative integer decimal string). Rejects NaN, fractional, and\n * negative values up-front — passing them on to core-sdk would either\n * trip a downstream BigInt conversion or, worse, produce a signed\n * payload that always reverts on-chain.\n */\nfunction normalizeEntityId(value: BigNumberish): string {\n if (typeof value === \"bigint\") {\n if (value < 0n) throw new Error(`entityId must be non-negative, got ${value.toString()}`);\n return value.toString();\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0) {\n throw new Error(`entityId must be a non-negative integer, got ${String(value)}`);\n }\n return value.toString();\n }\n // typeof value === \"string\"\n const trimmed = value.trim();\n if (trimmed.length === 0 || !DECIMAL_UINT.test(trimmed)) {\n throw new Error(`entityId must be a decimal non-negative integer string, got \"${value}\"`);\n }\n return trimmed;\n}\n\n/**\n * Resolution targets accepted by the \"withdraw all\" helper. Either\n * pass the raw `entityId` (numeric Boson account id) or an EVM\n * `address` with an optional `role` discriminator for the case where\n * the address maps to both a seller and a buyer entity.\n */\nexport type WithdrawEntitySelector =\n | { entityId: BigNumberish }\n | { address: Address; role?: \"buyer\" | \"seller\" };\n\n/** Arguments accepted by `signWithdrawFunds` (caller-resolved entity + token list). */\nexport interface SignWithdrawFundsArgs {\n entityId: BigNumberish;\n /** CAIP-2 network identifier (e.g. `\"eip155:8453\"`). */\n network: string;\n /** Boson Diamond address (the `escrowAddress` from the prior 402). */\n escrowAddress: Address;\n /** Token addresses to withdraw — must align by index with `tokenAmounts`. */\n tokenList: readonly Address[];\n /** Amounts to withdraw — must align by index with `tokenList`. */\n tokenAmounts: readonly BigNumberish[];\n}\n\n/** Arguments accepted by `signWithdrawAllAvailableFunds` — entity + network only. */\nexport type SignWithdrawAllAvailableFundsArgs = WithdrawEntitySelector & {\n /** CAIP-2 network identifier (e.g. `\"eip155:8453\"`). */\n network: string;\n /** Boson Diamond address. */\n escrowAddress: Address;\n};\n\n/** Wire-format result identical in shape to `SignedPostCommitAction`. */\nexport interface SignedWithdrawFunds {\n metaTx: BosonMetaTx;\n signedPayload: WireHex;\n /** Resolved `entityId` (echoed back for caller convenience when looked up by address). */\n entityId: string;\n /** Tokens included in the signature, in calldata order. */\n tokenList: readonly Address[];\n /** Amounts included in the signature, in calldata order. */\n tokenAmounts: readonly string[];\n}\n\nexport interface SignWithdrawDeps {\n buildCoreSdk: (network: string, escrowAddress: Address) => { coreSdk: CoreSDK; chainId: number };\n /** Returns the address that will sign the meta-tx — must match the configured signer. */\n getSignerAddress: () => Promise<Address>;\n}\n\ninterface SignedMetaTxShape {\n functionName: string;\n functionSignature: string;\n r: string;\n s: string;\n v: number;\n}\n\n/** Subset of `CoreSDK` used here — kept narrow so tests can stub easily. */\ninterface WithdrawCoreSdkLike {\n signMetaTxWithdrawFunds(args: {\n nonce: string;\n entityId: BigNumberish;\n tokenList: string[];\n tokenAmounts: BigNumberish[];\n }): Promise<SignedMetaTxShape>;\n getFunds(queryVars: { fundsFilter: { accountId: string } }): Promise<\n Array<{\n accountId: string;\n availableAmount: string;\n token: { address: string };\n }>\n >;\n getSellersByAddress(address: string): Promise<Array<{ id: string }>>;\n getBuyers(queryVars: { buyersFilter: { wallet: string } }): Promise<Array<{ id: string }>>;\n}\n\n/**\n * Sign a `withdrawFunds(entityId, tokenList, tokenAmounts)` meta-tx\n * against the configured Diamond domain. The caller supplies the\n * exact token + amount snapshot to commit to.\n */\nexport async function signWithdrawFunds(\n args: SignWithdrawFundsArgs,\n deps: SignWithdrawDeps,\n): Promise<SignedWithdrawFunds> {\n const normalised: SignWithdrawFundsArgs = {\n ...args,\n entityId: normalizeEntityId(args.entityId),\n };\n const { coreSdk } = deps.buildCoreSdk(normalised.network, normalised.escrowAddress);\n const from = await deps.getSignerAddress();\n return signWithdrawFundsInternal(normalised, coreSdk as unknown as WithdrawCoreSdkLike, from);\n}\n\n/**\n * \"Withdraw all\" sugar. Resolves the entity (by id or by address),\n * reads the funds entity from the subgraph, drops zero balances, and\n * signs `withdrawFunds(entityId, allTokens, allAmounts)`. Throws when\n * the entity has no available funds.\n */\nexport async function signWithdrawAllAvailableFunds(\n args: SignWithdrawAllAvailableFundsArgs,\n deps: SignWithdrawDeps,\n): Promise<SignedWithdrawFunds> {\n const { coreSdk } = deps.buildCoreSdk(args.network, args.escrowAddress);\n const sdk = coreSdk as unknown as WithdrawCoreSdkLike;\n const from = await deps.getSignerAddress();\n const entityId = await resolveEntityIdClientSide(sdk, args);\n const funds = await sdk.getFunds({ fundsFilter: { accountId: entityId } });\n const nonZero = funds.filter((f) => f.availableAmount !== \"0\" && BigInt(f.availableAmount) > 0n);\n if (nonZero.length === 0) {\n throw new Error(\n `signWithdrawAllAvailableFunds: entity ${entityId} has no available funds to withdraw`,\n );\n }\n return signWithdrawFundsInternal(\n {\n entityId,\n network: args.network,\n escrowAddress: args.escrowAddress,\n tokenList: nonZero.map((f) => f.token.address as Address),\n tokenAmounts: nonZero.map((f) => f.availableAmount),\n },\n sdk,\n from,\n );\n}\n\nasync function signWithdrawFundsInternal(\n args: SignWithdrawFundsArgs,\n coreSdk: WithdrawCoreSdkLike,\n from: Address,\n): Promise<SignedWithdrawFunds> {\n if (args.tokenList.length !== args.tokenAmounts.length) {\n throw new Error(\n `signWithdrawFunds: tokenList (${args.tokenList.length}) and tokenAmounts (${args.tokenAmounts.length}) must be the same length`,\n );\n }\n const nonce = randomUint256();\n const nonceStr = nonce.toString();\n const signed = await coreSdk.signMetaTxWithdrawFunds({\n nonce: nonceStr,\n entityId: args.entityId,\n tokenList: args.tokenList.map((t) => t),\n tokenAmounts: args.tokenAmounts.map((a) => a),\n });\n\n const metaTx: BosonMetaTx = {\n from,\n nonce: nonceStr,\n functionName: signed.functionName,\n functionSignature: signed.functionSignature as Hex,\n sig: {\n v: Number(signed.v),\n r: signed.r as Hex,\n s: signed.s as Hex,\n },\n };\n\n return {\n metaTx,\n signedPayload: encodeSignedPayload(metaTx),\n entityId: normalizeEntityId(args.entityId),\n tokenList: args.tokenList,\n tokenAmounts: args.tokenAmounts.map((a) => String(a)),\n };\n}\n\nasync function resolveEntityIdClientSide(\n coreSdk: WithdrawCoreSdkLike,\n selector: WithdrawEntitySelector,\n): Promise<string> {\n if (\"entityId\" in selector) return normalizeEntityId(selector.entityId);\n const address = selector.address.toLowerCase();\n const role = selector.role;\n const [sellers, buyers] = await Promise.all([\n role === \"buyer\"\n ? Promise.resolve<Array<{ id: string }>>([])\n : coreSdk.getSellersByAddress(address),\n role === \"seller\"\n ? Promise.resolve<Array<{ id: string }>>([])\n : coreSdk.getBuyers({ buyersFilter: { wallet: address } }),\n ]);\n const sellerIds = sellers.map((s) => s.id);\n const buyerIds = buyers.map((b) => b.id);\n\n if (role === \"seller\") {\n if (sellerIds.length === 0) {\n throw new Error(\n `signWithdrawAllAvailableFunds: no seller entity found for address ${address}`,\n );\n }\n if (sellerIds.length > 1) {\n throw new Error(\n `signWithdrawAllAvailableFunds: address ${address} resolves to multiple seller entities (ids ${sellerIds.join(\", \")}); pass entityId to disambiguate`,\n );\n }\n return sellerIds[0]!;\n }\n if (role === \"buyer\") {\n if (buyerIds.length === 0) {\n throw new Error(\n `signWithdrawAllAvailableFunds: no buyer entity found for address ${address}`,\n );\n }\n if (buyerIds.length > 1) {\n throw new Error(\n `signWithdrawAllAvailableFunds: address ${address} resolves to multiple buyer entities (ids ${buyerIds.join(\", \")}); pass entityId to disambiguate`,\n );\n }\n return buyerIds[0]!;\n }\n\n // role unspecified — exactly-one rule across both sides. Refuse to\n // guess when the address resolves to multiple sellers, multiple\n // buyers, or any combination of the two: the signed payload commits\n // to a single entityId, so silently picking `[0]` would be a bug\n // farm waiting to bite.\n const totalMatches = sellerIds.length + buyerIds.length;\n if (totalMatches === 0) {\n throw new Error(\n `signWithdrawAllAvailableFunds: no seller or buyer entity found for address ${address}`,\n );\n }\n if (totalMatches > 1) {\n throw new Error(\n `signWithdrawAllAvailableFunds: address ${address} resolves to ${describeClientMatches(sellerIds, buyerIds)}; pass role and/or entityId to disambiguate`,\n );\n }\n if (sellerIds.length === 1) return sellerIds[0]!;\n return buyerIds[0]!;\n}\n\nfunction describeClientMatches(sellerIds: string[], buyerIds: string[]): string {\n const parts: string[] = [];\n if (sellerIds.length > 0) {\n parts.push(\n sellerIds.length === 1\n ? `seller (id ${sellerIds[0]})`\n : `${sellerIds.length} sellers (ids ${sellerIds.join(\", \")})`,\n );\n }\n if (buyerIds.length > 0) {\n parts.push(\n buyerIds.length === 1\n ? `buyer (id ${buyerIds[0]})`\n : `${buyerIds.length} buyers (ids ${buyerIds.join(\", \")})`,\n );\n }\n return parts.join(\" and \");\n}\n","// Top-level `createX402bClient` factory.\n//\n// Wires the action picker, token-auth strategy dispatcher, meta-tx signer\n// (via `CoreSDK`), fulfillment resolver, and payload assembler into:\n//\n// - `handle402(requirements)` — commit-time flow that emits the base64\n// `X-PAYMENT` value for the 402 retry.\n// - `signAction(args)` — post-commit flow that signs one of the buyer's\n// follow-up meta-transactions (redeem / cancel / complete / dispute\n// family). No token-auth or X-PAYMENT wrapping; the caller picks a\n// channel and POSTs the wire envelope.\n\nimport {\n parseEscrowPaymentRequirements,\n type EscrowPaymentRequirements,\n} from \"@bosonprotocol/x402-core/schemes/escrow\";\nimport type { Address } from \"viem\";\n\nimport { pickAction } from \"./action.js\";\nimport { createCoreSdkFactory } from \"./core-sdk-factory.js\";\nimport { resolveFulfillment } from \"./fulfillment.js\";\nimport { assembleAndEncodePayload } from \"./payload.js\";\nimport { signCreateOfferAndCommit, signCreateOfferCommitAndRedeem } from \"./pre-commit.js\";\nimport {\n signPostCommitAction,\n type SignActionArgs,\n type SignedPostCommitAction,\n} from \"./post-commit.js\";\nimport { parsePaymentResponse } from \"./response.js\";\nimport {\n signWithdrawAllAvailableFunds,\n signWithdrawFunds,\n type SignWithdrawAllAvailableFundsArgs,\n type SignWithdrawFundsArgs,\n type SignedWithdrawFunds,\n} from \"./withdraw.js\";\nimport { buildAndSignTokenAuth } from \"./token-auth/index.js\";\nimport { MaxAmountExceededError, UnsupportedTokenAuthError } from \"./errors.js\";\nimport type { ExchangeSummary, X402bClientConfig } from \"./types.js\";\n\nexport interface X402bClient {\n /**\n * Consume a parsed escrow PaymentRequirements and return the base64\n * value to set as the `X-PAYMENT` header on the retry.\n */\n handle402(requirements: unknown): Promise<string>;\n\n /**\n * Sign a Boson protocol meta-transaction for a buyer-driven post-commit\n * action (redeem, cancel, complete, dispute family). Returns both the\n * wire-format `BosonMetaTx` envelope and the ABI-encoded `signedPayload`\n * Hex — pick the shape that matches the chosen channel. Server /\n * facilitator HTTP routes consume `signedPayload` directly (e.g. as\n * the `signedPayload` field on the JSON POST body to the endpoint the\n * prior response advertised under `actions.next[].endpoints.server`);\n * on-chain and MCP channels use the `metaTx` object.\n *\n * Note: `boson-escalateDispute` signs only the meta-tx. If the dispute\n * resolver requires an escalation deposit, the resolver/server returns\n * its own 402 with an `escrow` `PaymentRequirements` and the buyer pairs\n * this meta-tx with a token-auth payload — the deposit wrapper is out\n * of MVP.\n */\n signAction(args: SignActionArgs): Promise<SignedPostCommitAction>;\n\n /**\n * Sign a `withdrawFunds(entityId, tokenList, tokenAmounts)` meta-tx.\n * Caller-resolved entity + tokens snapshot — see\n * `signWithdrawAllAvailableFunds` for the read-from-subgraph \"withdraw\n * everything\" sugar.\n */\n signWithdrawFunds(args: SignWithdrawFundsArgs): Promise<SignedWithdrawFunds>;\n\n /**\n * Read available funds for the given entity from the subgraph and\n * sign a meta-tx withdrawing the entire current balance set. Accepts\n * either an `entityId` directly or an `address` (with optional\n * `role` for ambiguous wallets).\n */\n signWithdrawAllAvailableFunds(\n args: SignWithdrawAllAvailableFundsArgs,\n ): Promise<SignedWithdrawFunds>;\n\n /**\n * Best-effort decode of `X-PAYMENT-RESPONSE` after a successful retry.\n * Returns `undefined` when the header isn't present.\n */\n parsePaymentResponse(response: {\n headers: { get(name: string): string | null };\n }): ExchangeSummary | undefined;\n}\n\n/**\n * Build a stateless client bound to a buyer signer + policy. The\n * underlying `CoreSDK` is built lazily per `(chainId, escrowAddress)` and\n * cached across calls — both `handle402` and `signAction` reuse it.\n */\nexport function createX402bClient(config: X402bClientConfig): X402bClient {\n const buildCoreSdk = createCoreSdkFactory(config.signer, config);\n\n const getBuyerAddress = async () => (await config.signer.getAddress()) as Address;\n\n return {\n async handle402(rawRequirements) {\n const requirements: EscrowPaymentRequirements =\n parseEscrowPaymentRequirements(rawRequirements);\n\n const action = pickAction(requirements, config.policy);\n const fulfillment = resolveFulfillment(requirements, config);\n enforceMaxAmount(requirements.amount, config.policy?.maxAmount);\n const buyer = await getBuyerAddress();\n\n const { coreSdk, chainId } = buildCoreSdk(\n requirements.network,\n requirements.escrowAddress as Address,\n );\n\n // `policy.tokenAuthStrategy` forces a specific strategy from the\n // server's advertised set instead of letting the dispatcher pick\n // by preference. The forced value must be in\n // `requirements.tokenAuthStrategies`; otherwise the override is\n // rejected. `\"none\"` short-circuits the dispatcher entirely (the\n // buyer has approved the escrow off-band and the payment rides\n // the protocol's `safeTransferFrom` fallback); for the other\n // strategies the dispatcher is invoked with the advertised set\n // narrowed to a single element so it must pick the requested one.\n let tokenAuth: Awaited<ReturnType<typeof buildAndSignTokenAuth>>[\"tokenAuth\"] | undefined;\n let strategy: Awaited<ReturnType<typeof buildAndSignTokenAuth>>[\"strategy\"];\n const forcedStrategy = config.policy?.tokenAuthStrategy;\n if (forcedStrategy !== undefined) {\n if (!requirements.tokenAuthStrategies.includes(forcedStrategy)) {\n throw new UnsupportedTokenAuthError(\n `policy.tokenAuthStrategy \"${forcedStrategy}\" is not in requirements.tokenAuthStrategies (${requirements.tokenAuthStrategies.join(\", \")})`,\n );\n }\n if (forcedStrategy === \"none\") {\n strategy = \"none\";\n tokenAuth = undefined;\n } else {\n const built = await buildAndSignTokenAuth({\n requirements: { ...requirements, tokenAuthStrategies: [forcedStrategy] },\n buyer,\n coreSdk,\n tokenDomainResolver: config.tokenDomainResolver,\n publicClient: config.publicClients?.[chainId],\n });\n strategy = built.strategy;\n tokenAuth = built.tokenAuth;\n }\n } else {\n const built = await buildAndSignTokenAuth({\n requirements,\n buyer,\n coreSdk,\n tokenDomainResolver: config.tokenDomainResolver,\n publicClient: config.publicClients?.[chainId],\n });\n strategy = built.strategy;\n tokenAuth = built.tokenAuth;\n }\n\n // Flow B (boson-createOfferCommitAndRedeem) carries the buyer's\n // delivery data along with the commit-time payload — there's no\n // later round trip in which to attach it. Flow A defers `data` to\n // the redeem-time POST body; `assemblePayload` handles the\n // conditional emission based on `action`.\n const signMetaTx =\n action === \"boson-createOfferCommitAndRedeem\"\n ? signCreateOfferCommitAndRedeem\n : signCreateOfferAndCommit;\n const metaTx = await signMetaTx({ requirements, coreSdk, buyer });\n\n return assembleAndEncodePayload({\n requirements,\n action,\n tokenAuthStrategy: strategy,\n metaTx,\n tokenAuth,\n fulfillment,\n buyer,\n });\n },\n\n signAction(args) {\n return signPostCommitAction(args, { buildCoreSdk, getBuyerAddress });\n },\n\n signWithdrawFunds(args) {\n return signWithdrawFunds(args, { buildCoreSdk, getSignerAddress: getBuyerAddress });\n },\n\n signWithdrawAllAvailableFunds(args) {\n return signWithdrawAllAvailableFunds(args, {\n buildCoreSdk,\n getSignerAddress: getBuyerAddress,\n });\n },\n\n parsePaymentResponse(response) {\n return parsePaymentResponse(response);\n },\n };\n}\n\nfunction enforceMaxAmount(amount: string, maxAmount?: string): void {\n if (maxAmount === undefined) {\n return;\n }\n\n const amountBigInt = BigInt(amount);\n const maxAmountBigInt = BigInt(maxAmount);\n if (amountBigInt > maxAmountBigInt) {\n throw new MaxAmountExceededError(\n `x402-client: requirements.amount ${amount} exceeds policy.maxAmount ${maxAmount}`,\n );\n }\n}\n","// Translator that wraps a Boson `Web3LibAdapter` (e.g. an `EthersAdapter`\n// from `@bosonprotocol/ethers-sdk`) as an x402-client `Signer`. The point\n// is to let consumers who already hold an adapter for the deployed Boson\n// protocol reuse it with `createX402bClient` without writing the shim\n// themselves — and without forcing this package to take `ethers` (or\n// `@bosonprotocol/common`) as a peer dep.\n//\n// Structural typing keeps the coupling minimal: `Web3LibAdapterLike` picks\n// only the two methods we actually invoke. The consumer's own `ethers` /\n// `@bosonprotocol/ethers-sdk` install carries the full types — an\n// `EthersAdapter` instance satisfies `Web3LibAdapterLike` by shape.\n//\n// Note on `EIP712Domain` injection: `eth_signTypedData_v4` (and the\n// `EthersAdapter` JSON path) expects `types.EIP712Domain` to be present\n// and to match exactly the fields populated on `domain`. We derive it\n// from `domain`'s field presence — the same rule viem applies internally\n// in `getTypesForEIP712Domain`.\n\nimport {\n getAddress,\n serializeTypedData,\n type Address,\n type Hex,\n type TypedDataDomain,\n type TypedDataDefinition,\n type TypedDataParameter,\n} from \"viem\";\n\nimport type { Signer } from \"./types.js\";\n\n/**\n * Structural subset of `@bosonprotocol/common`'s `Web3LibAdapter` that\n * {@link signerFromEthersAdapter} actually exercises. An `EthersAdapter`\n * from `@bosonprotocol/ethers-sdk` (or any future concrete adapter)\n * satisfies this shape without an explicit cast.\n */\nexport interface Web3LibAdapterLike {\n getSignerAddress(): Promise<string>;\n send(method: string, params: readonly unknown[]): Promise<unknown>;\n}\n\n/**\n * Wrap a Boson `Web3LibAdapter`-shaped object as an x402-client\n * {@link Signer}. `signTypedData` builds the standard\n * `eth_signTypedData_v4` JSON payload (including a derived\n * `EIP712Domain` type list) and routes it through `adapter.send`.\n */\nexport function signerFromEthersAdapter(adapter: Web3LibAdapterLike): Signer {\n const resolveAddress = async (): Promise<Address> => getAddress(await adapter.getSignerAddress());\n return {\n getAddress: resolveAddress,\n signTypedData: async ({ domain, types, primaryType, message }) => {\n const from = await resolveAddress();\n const typedData = {\n domain,\n types: { ...types, EIP712Domain: deriveEip712DomainType(domain) },\n primaryType,\n message,\n };\n const json = serializeTypedData(typedData as unknown as TypedDataDefinition);\n const sig = await adapter.send(\"eth_signTypedData_v4\", [from, json]);\n if (typeof sig !== \"string\" || !/^0x[0-9a-fA-F]+$/.test(sig)) {\n throw new Error(\n \"signerFromEthersAdapter: adapter.send did not return a hex signature string\",\n );\n }\n return sig as Hex;\n },\n };\n}\n\n/**\n * Build the `EIP712Domain` type-list from the fields actually present on\n * `domain`, in the canonical EIP-712 order (`name`, `version`, `chainId`,\n * `verifyingContract`, `salt`). Matches viem's internal derivation so the\n * resulting digest agrees with what a viem signer would produce.\n */\nfunction deriveEip712DomainType(domain: TypedDataDomain): readonly TypedDataParameter[] {\n const fields: TypedDataParameter[] = [];\n if (domain.name !== undefined) fields.push({ name: \"name\", type: \"string\" });\n if (domain.version !== undefined) fields.push({ name: \"version\", type: \"string\" });\n if (domain.chainId !== undefined) fields.push({ name: \"chainId\", type: \"uint256\" });\n if (domain.verifyingContract !== undefined)\n fields.push({ name: \"verifyingContract\", type: \"address\" });\n if (domain.salt !== undefined) fields.push({ name: \"salt\", type: \"bytes32\" });\n return fields;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,3 @@
1
+ export { buildAndSignTokenAuth } from '../chunk-JTTWAQGC.js';
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@bosonprotocol/x402-client",
3
+ "version": "0.1.0-alpha-0",
4
+ "license": "Apache-2.0",
5
+ "description": "Boson Protocol x402 buyer-side SDK — framework-agnostic client that intercepts 402 escrow-scheme responses and produces the X-PAYMENT header.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/bosonprotocol/x402B.git",
9
+ "directory": "typescript/packages/client"
10
+ },
11
+ "homepage": "https://github.com/bosonprotocol/x402B/tree/main/typescript/packages/client",
12
+ "bugs": {
13
+ "url": "https://github.com/bosonprotocol/x402B/issues"
14
+ },
15
+ "keywords": [
16
+ "x402",
17
+ "boson-protocol",
18
+ "escrow",
19
+ "client",
20
+ "buyer",
21
+ "web3",
22
+ "payments"
23
+ ],
24
+ "main": "./dist/cjs/index.js",
25
+ "module": "./dist/esm/index.js",
26
+ "types": "./dist/cjs/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/cjs/index.d.ts",
30
+ "import": "./dist/esm/index.js",
31
+ "require": "./dist/cjs/index.js"
32
+ },
33
+ "./schemas/*": "./dist/schemas/*"
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "dependencies": {
44
+ "@bosonprotocol/common": "1.33.0-alpha.7",
45
+ "@bosonprotocol/core-sdk": "1.48.0-alpha.6",
46
+ "ajv": "^8.17.1",
47
+ "viem": "^2.39.3",
48
+ "@bosonprotocol/x402-core": "^0.1.0-alpha-0",
49
+ "@bosonprotocol/x402-evm": "^0.1.0-alpha-0"
50
+ },
51
+ "devDependencies": {
52
+ "@types/node": "^20.17.10",
53
+ "tsup": "^8.3.5",
54
+ "typescript": "^5.7.2",
55
+ "vitest": "^2.1.8"
56
+ },
57
+ "scripts": {
58
+ "prebuild": "pnpm --filter @bosonprotocol/x402-core build",
59
+ "build": "tsup && node scripts/postbuild.mjs",
60
+ "test": "vitest run",
61
+ "lint": "eslint src test --max-warnings 0",
62
+ "clean": "rm -rf dist .turbo"
63
+ }
64
+ }