@spendctl/adapter-x402 0.0.0-stage → 0.2.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,48 @@
1
+ import { type AssetConfig, type PaymentOption } from "@spendctl/core";
2
+ import type { PaymentPayload, PaymentRequired, SettleResponse } from "@x402/core/types";
3
+ import { type ClientEvmSigner } from "@x402/evm";
4
+ export type { ClientEvmSigner };
5
+ /** Request headers through which a client attaches an x402 payment. */
6
+ export declare const X402_PAYMENT_HEADERS: readonly ["payment-signature", "x-payment"];
7
+ export interface X402Challenge {
8
+ protocol: "x402";
9
+ version: number;
10
+ paymentRequired: PaymentRequired;
11
+ options: PaymentOption[];
12
+ }
13
+ /** Maps a v1 network name (`base-sepolia`) to CAIP-2 (`eip155:84532`). v2 ids pass through. */
14
+ export declare function toCaip2(network: string): string;
15
+ export declare function toOptions(paymentRequired: PaymentRequired, extraAssets?: AssetConfig[]): PaymentOption[];
16
+ /**
17
+ * Detects an x402 challenge in a 402 response: v2 `PAYMENT-REQUIRED` header first,
18
+ * then a v1 JSON body. Returns undefined when the 402 is not x402.
19
+ */
20
+ export declare function parseX402(headers: Headers, bodyText: string, extraAssets?: AssetConfig[]): X402Challenge | undefined;
21
+ export interface SignedX402 {
22
+ headers: Record<string, string>;
23
+ payload: PaymentPayload;
24
+ nonce?: string;
25
+ payer?: string;
26
+ validBefore?: number;
27
+ }
28
+ /**
29
+ * Signs the chosen option with the given EVM signer using the official x402 SDK
30
+ * and returns the request headers to retry with. The SDK's own spend controls are
31
+ * disabled because spendctl's policy engine already decided.
32
+ */
33
+ export declare function signX402(challenge: X402Challenge, option: PaymentOption, signer: ClientEvmSigner, opts?: {
34
+ paymentId?: string;
35
+ }): Promise<SignedX402>;
36
+ export interface X402Settlement {
37
+ success: boolean;
38
+ transaction?: string;
39
+ network?: string;
40
+ payer?: string;
41
+ amount?: string;
42
+ errorReason?: string;
43
+ pending: boolean;
44
+ raw: SettleResponse;
45
+ }
46
+ /** Reads `PAYMENT-RESPONSE` (v2) or `X-PAYMENT-RESPONSE` (v1). */
47
+ export declare function parseX402Settlement(headers: Headers): X402Settlement | undefined;
48
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAqB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGzF,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAuB,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7G,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,WAAW,CAAC;AAIjE,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,uEAAuE;AACvE,eAAO,MAAM,oBAAoB,YAAI,mBAAmB,EAAE,WAAW,CAAU,CAAC;AAEhF,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,eAAe,CAAC;IACjC,OAAO,EAAE,aAAa,EAAE,CAAC;CAC1B;AAmBD,+FAA+F;AAC/F,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK/C;AA2BD,wBAAgB,SAAS,CAAC,eAAe,EAAE,eAAe,EAAE,WAAW,GAAE,WAAW,EAAO,GAAG,aAAa,EAAE,CA4B5G;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,WAAW,GAAE,WAAW,EAAO,GAC9B,aAAa,GAAG,SAAS,CAuB3B;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAYD;;;;GAIG;AACH,wBAAsB,QAAQ,CAC5B,SAAS,EAAE,aAAa,EACxB,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAChC,OAAO,CAAC,UAAU,CAAC,CA+BrB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,cAAc,CAAC;CACrB;AAED,kEAAkE;AAClE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAkBhF"}
package/dist/index.js ADDED
@@ -0,0 +1,165 @@
1
+ import { atomicToUsdMicros } from "@spendctl/core";
2
+ import { x402Client } from "@x402/core/client";
3
+ import { decodePaymentResponseHeader, x402HTTPClient } from "@x402/core/http";
4
+ import { DEFAULT_ASSETS } from "@x402/evm";
5
+ import { registerExactEvmScheme } from "@x402/evm/exact/client";
6
+ import { EVM_NETWORK_CHAIN_ID_MAP } from "@x402/evm/v1";
7
+ /** Request headers through which a client attaches an x402 payment. */
8
+ export const X402_PAYMENT_HEADERS = ["payment-signature", "x-payment"];
9
+ const SOLANA_V1 = {
10
+ solana: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
11
+ "solana-devnet": "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
12
+ };
13
+ /** Maps a v1 network name (`base-sepolia`) to CAIP-2 (`eip155:84532`). v2 ids pass through. */
14
+ export function toCaip2(network) {
15
+ if (network.includes(":"))
16
+ return network;
17
+ const chainId = EVM_NETWORK_CHAIN_ID_MAP[network];
18
+ if (chainId !== undefined)
19
+ return `eip155:${chainId}`;
20
+ return SOLANA_V1[network] ?? network;
21
+ }
22
+ function lookupAsset(network, asset, extra) {
23
+ const custom = extra.find((entry) => entry.network === network && entry.asset.toLowerCase() === asset.toLowerCase());
24
+ if (custom)
25
+ return { symbol: custom.symbol, decimals: custom.decimals, usdPegged: custom.usdPegged };
26
+ // DEFAULT_ASSETS lists the USD-pegged assets the x402 SDK knows per network.
27
+ const table = DEFAULT_ASSETS;
28
+ const known = table[network]?.find((entry) => entry.asset.toLowerCase() === asset.toLowerCase());
29
+ return known ? { symbol: known.symbol, decimals: known.decimals, usdPegged: true } : undefined;
30
+ }
31
+ function unsignable(requirement, network) {
32
+ if (requirement.scheme !== "exact")
33
+ return `scheme "${requirement.scheme}" is not supported yet (only "exact")`;
34
+ if (!network.startsWith("eip155:"))
35
+ return `network ${network} is not supported yet (only EVM)`;
36
+ const flow = requirement.extra?.paymentFlow;
37
+ if (flow !== undefined && flow !== "authorization")
38
+ return `payment flow "${String(flow)}" is not supported`;
39
+ const method = requirement.extra?.assetTransferMethod;
40
+ if (method !== undefined && method !== "eip3009")
41
+ return `asset transfer method "${String(method)}" is not supported`;
42
+ return undefined;
43
+ }
44
+ export function toOptions(paymentRequired, extraAssets = []) {
45
+ const accepts = (paymentRequired.accepts ?? []);
46
+ return accepts.map((requirement, index) => {
47
+ const network = toCaip2(requirement.network);
48
+ const amountAtomic = String(requirement.amount ?? requirement.maxAmountRequired ?? "");
49
+ const known = lookupAsset(network, requirement.asset, extraAssets);
50
+ const validAmount = /^\d+$/.test(amountAtomic);
51
+ const reason = validAmount
52
+ ? unsignable(requirement, network)
53
+ : `amount ${JSON.stringify(amountAtomic)} is not an integer`;
54
+ return {
55
+ protocol: "x402",
56
+ protocolVersion: paymentRequired.x402Version,
57
+ scheme: requirement.scheme,
58
+ flow: typeof requirement.extra?.paymentFlow === "string" ? requirement.extra.paymentFlow : undefined,
59
+ network,
60
+ asset: requirement.asset,
61
+ assetSymbol: known?.symbol,
62
+ decimals: known?.decimals,
63
+ amountAtomic: validAmount ? amountAtomic : "0",
64
+ usdMicros: known?.usdPegged && validAmount ? atomicToUsdMicros(amountAtomic, known.decimals) : undefined,
65
+ payTo: requirement.payTo,
66
+ maxTimeoutSeconds: requirement.maxTimeoutSeconds,
67
+ index,
68
+ signable: reason === undefined,
69
+ unsignableReason: reason,
70
+ };
71
+ });
72
+ }
73
+ /**
74
+ * Detects an x402 challenge in a 402 response: v2 `PAYMENT-REQUIRED` header first,
75
+ * then a v1 JSON body. Returns undefined when the 402 is not x402.
76
+ */
77
+ export function parseX402(headers, bodyText, extraAssets = []) {
78
+ let body;
79
+ try {
80
+ body = bodyText ? JSON.parse(bodyText) : undefined;
81
+ }
82
+ catch {
83
+ body = undefined;
84
+ }
85
+ let paymentRequired;
86
+ try {
87
+ paymentRequired = new x402HTTPClient(new x402Client()).getPaymentRequiredResponse((name) => headers.get(name), body);
88
+ }
89
+ catch {
90
+ return undefined;
91
+ }
92
+ if (!Array.isArray(paymentRequired.accepts))
93
+ return undefined;
94
+ return {
95
+ protocol: "x402",
96
+ version: paymentRequired.x402Version,
97
+ paymentRequired,
98
+ options: toOptions(paymentRequired, extraAssets),
99
+ };
100
+ }
101
+ function sameRequirement(a, b) {
102
+ return (a.scheme === b.scheme &&
103
+ a.network === b.network &&
104
+ a.payTo.toLowerCase() === b.payTo.toLowerCase() &&
105
+ a.asset.toLowerCase() === b.asset.toLowerCase() &&
106
+ String(a.amount ?? a.maxAmountRequired) === String(b.amount ?? b.maxAmountRequired));
107
+ }
108
+ /**
109
+ * Signs the chosen option with the given EVM signer using the official x402 SDK
110
+ * and returns the request headers to retry with. The SDK's own spend controls are
111
+ * disabled because spendctl's policy engine already decided.
112
+ */
113
+ export async function signX402(challenge, option, signer, opts = {}) {
114
+ const target = challenge.paymentRequired.accepts[option.index];
115
+ if (!target)
116
+ throw new Error(`x402 option ${option.index} does not exist`);
117
+ const client = new x402Client((_version, requirements) => {
118
+ const match = requirements.find((r) => sameRequirement(r, target));
119
+ if (!match)
120
+ throw new Error("Selected x402 option is not signable by the registered schemes");
121
+ return match;
122
+ });
123
+ registerExactEvmScheme(client, { signer });
124
+ client.setSpendControls(false);
125
+ const payload = await client.createPaymentPayload(challenge.paymentRequired);
126
+ const declared = challenge.paymentRequired.extensions?.["payment-identifier"];
127
+ if (declared && opts.paymentId) {
128
+ payload.extensions = {
129
+ ...(payload.extensions ?? {}),
130
+ "payment-identifier": { ...declared, info: { ...(declared.info ?? {}), id: opts.paymentId } },
131
+ };
132
+ }
133
+ const headers = new x402HTTPClient(client).encodePaymentSignatureHeader(payload);
134
+ const authorization = payload.payload?.authorization;
135
+ return {
136
+ headers,
137
+ payload,
138
+ nonce: authorization?.nonce,
139
+ payer: authorization?.from,
140
+ validBefore: authorization?.validBefore ? Number(authorization.validBefore) : undefined,
141
+ };
142
+ }
143
+ /** Reads `PAYMENT-RESPONSE` (v2) or `X-PAYMENT-RESPONSE` (v1). */
144
+ export function parseX402Settlement(headers) {
145
+ const value = headers.get("PAYMENT-RESPONSE") ?? headers.get("X-PAYMENT-RESPONSE");
146
+ if (!value)
147
+ return undefined;
148
+ try {
149
+ const raw = decodePaymentResponseHeader(value);
150
+ return {
151
+ success: raw.success,
152
+ transaction: raw.transaction || undefined,
153
+ network: raw.network,
154
+ payer: raw.payer,
155
+ amount: raw.amount,
156
+ errorReason: raw.errorReason,
157
+ pending: raw.errorReason === "settlement_pending",
158
+ raw,
159
+ };
160
+ }
161
+ catch {
162
+ return undefined;
163
+ }
164
+ }
165
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,iBAAiB,EAAsB,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OA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stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "x402 (v1 and v2) adapter for spendctl: parses 402 challenges and signs exact EVM payments.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "THIRD_PARTY_NOTICES"
19
+ ],
20
+ "engines": {
21
+ "node": ">=22.13"
22
+ },
23
+ "dependencies": {
24
+ "@x402/core": "2.28.0",
25
+ "@x402/evm": "2.28.0",
26
+ "viem": "^2.57.11",
27
+ "@spendctl/core": "0.2.0"
28
+ },
29
+ "homepage": "https://spendctl.dev",
30
+ "scripts": {}
6
31
  }