@fatstack/x402 0.0.1 → 0.1.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.
- package/README.md +114 -6
- package/dist/chunk-6LSPHKJ7.js +88 -0
- package/dist/chunk-6LSPHKJ7.js.map +1 -0
- package/dist/chunk-7DVR574O.js +213 -0
- package/dist/chunk-7DVR574O.js.map +1 -0
- package/dist/chunk-HCN75CTX.js +144 -0
- package/dist/chunk-HCN75CTX.js.map +1 -0
- package/dist/client-C8_arVa4.d.cts +86 -0
- package/dist/client-C8_arVa4.d.ts +86 -0
- package/dist/client.cjs +207 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +3 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.js +15 -0
- package/dist/client.js.map +1 -0
- package/dist/index.cjs +464 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +107 -0
- package/dist/index.d.ts +107 -0
- package/dist/index.js +49 -0
- package/dist/index.js.map +1 -0
- package/dist/provider.cjs +273 -0
- package/dist/provider.cjs.map +1 -0
- package/dist/provider.d.cts +99 -0
- package/dist/provider.d.ts +99 -0
- package/dist/provider.js +8 -0
- package/dist/provider.js.map +1 -0
- package/dist/testing.cjs +73 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +22 -0
- package/dist/testing.d.ts +22 -0
- package/dist/testing.js +48 -0
- package/dist/testing.js.map +1 -0
- package/package.json +84 -4
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { PaymentRequirements } from '@x402/core/types';
|
|
2
|
+
import { ExactEvmScheme } from '@x402/evm/exact/client';
|
|
3
|
+
|
|
4
|
+
/** Base networks in CAIP-2 form, which is what x402 v2 speaks. */
|
|
5
|
+
declare const NETWORKS: {
|
|
6
|
+
readonly base: {
|
|
7
|
+
readonly caip2: "eip155:8453";
|
|
8
|
+
readonly chainId: 8453;
|
|
9
|
+
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
10
|
+
};
|
|
11
|
+
readonly 'base-sepolia': {
|
|
12
|
+
readonly caip2: "eip155:84532";
|
|
13
|
+
readonly chainId: 84532;
|
|
14
|
+
readonly usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
type NetworkName = keyof typeof NETWORKS;
|
|
18
|
+
/** USDC is 6 decimals on Base. */
|
|
19
|
+
declare const USDC_DECIMALS = 6;
|
|
20
|
+
/**
|
|
21
|
+
* Required on every 402 body and every payment-facing doc page. A payment is a direct
|
|
22
|
+
* on-chain transfer between two wallets: once settled nobody, Fatstack included, can
|
|
23
|
+
* reverse it.
|
|
24
|
+
*/
|
|
25
|
+
declare const NO_REFUNDS_NOTICE = "Payments are final. Once settled on-chain the transfer cannot be reversed, and there are no refunds.";
|
|
26
|
+
declare const DOCS_URL = "https://fatstack.net/docs/payments";
|
|
27
|
+
/** Correlates a settled payment with the indexer's view of the on-chain transfer. */
|
|
28
|
+
declare const PAYMENT_REF_HEADER = "X-Fatstack-Payment-Ref";
|
|
29
|
+
declare const DEFAULT_FACILITATOR_URL = "https://x402.org/facilitator";
|
|
30
|
+
|
|
31
|
+
/** One recorded spend, in USD, at a wall-clock millisecond. */
|
|
32
|
+
interface SpendRecord {
|
|
33
|
+
at: number;
|
|
34
|
+
usd: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Where rolling spend totals live. The default is in-memory and per-process; swap in a
|
|
38
|
+
* shared implementation (Redis, Durable Object, Postgres) when an agent runs as more
|
|
39
|
+
* than one process, otherwise each process enforces its own separate budget.
|
|
40
|
+
*/
|
|
41
|
+
interface SpendStore {
|
|
42
|
+
record(entry: SpendRecord): Promise<void> | void;
|
|
43
|
+
/** Total USD recorded at or after `sinceMs`. */
|
|
44
|
+
totalSince(sinceMs: number): Promise<number> | number;
|
|
45
|
+
}
|
|
46
|
+
/** Process-local store. Entries older than the longest window are dropped on write. */
|
|
47
|
+
declare function createMemorySpendStore(retentionMs?: number): SpendStore;
|
|
48
|
+
|
|
49
|
+
/** The signer the official EVM scheme expects: address + signTypedData, no key handling. */
|
|
50
|
+
type EvmWallet = ConstructorParameters<typeof ExactEvmScheme>[0];
|
|
51
|
+
interface SpendGuards {
|
|
52
|
+
/** Hard USD ceiling for a single call. */
|
|
53
|
+
maxPerCall?: number;
|
|
54
|
+
/** Rolling 60-minute USD ceiling. */
|
|
55
|
+
maxPerHour?: number;
|
|
56
|
+
/** Rolling 24-hour USD ceiling. */
|
|
57
|
+
maxPerDay?: number;
|
|
58
|
+
/** Hostnames this agent may pay. Checked before any network call. */
|
|
59
|
+
allowedHosts?: string[];
|
|
60
|
+
}
|
|
61
|
+
interface PayFetchOptions {
|
|
62
|
+
wallet: EvmWallet;
|
|
63
|
+
guards?: SpendGuards;
|
|
64
|
+
/** Defaults to a process-local in-memory store. */
|
|
65
|
+
store?: SpendStore;
|
|
66
|
+
networks?: NetworkName[];
|
|
67
|
+
fetch?: typeof globalThis.fetch;
|
|
68
|
+
now?: () => number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks every guard against a quote. Returns the USD value if the call may proceed,
|
|
72
|
+
* throws SpendGuardError otherwise. Called before a payment payload exists.
|
|
73
|
+
*/
|
|
74
|
+
declare function evaluateGuards(quoteUsd: number, guards: SpendGuards, store: SpendStore, now: number): Promise<void>;
|
|
75
|
+
declare function quoteUsdOf(requirements: PaymentRequirements): number;
|
|
76
|
+
/**
|
|
77
|
+
* A `fetch` that pays for 402 responses, under spend guards.
|
|
78
|
+
*
|
|
79
|
+
* The 402 handling, signing and retry are the official x402 packages' work. What this adds
|
|
80
|
+
* is refusal: guards are evaluated inside the payment-policy hook, which runs after the
|
|
81
|
+
* quote is known and before any payload is signed, so exceeding a guard throws
|
|
82
|
+
* SpendGuardError with nothing signed and nothing spent.
|
|
83
|
+
*/
|
|
84
|
+
declare function payFetch(url: RequestInfo | URL, init: RequestInit | undefined, options: PayFetchOptions): Promise<Response>;
|
|
85
|
+
|
|
86
|
+
export { DEFAULT_FACILITATOR_URL as D, type EvmWallet as E, NETWORKS as N, PAYMENT_REF_HEADER as P, type SpendGuards as S, USDC_DECIMALS as U, DOCS_URL as a, NO_REFUNDS_NOTICE as b, type NetworkName as c, type PayFetchOptions as d, type SpendRecord as e, type SpendStore as f, createMemorySpendStore as g, evaluateGuards as h, payFetch as p, quoteUsdOf as q };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { PaymentRequirements } from '@x402/core/types';
|
|
2
|
+
import { ExactEvmScheme } from '@x402/evm/exact/client';
|
|
3
|
+
|
|
4
|
+
/** Base networks in CAIP-2 form, which is what x402 v2 speaks. */
|
|
5
|
+
declare const NETWORKS: {
|
|
6
|
+
readonly base: {
|
|
7
|
+
readonly caip2: "eip155:8453";
|
|
8
|
+
readonly chainId: 8453;
|
|
9
|
+
readonly usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913";
|
|
10
|
+
};
|
|
11
|
+
readonly 'base-sepolia': {
|
|
12
|
+
readonly caip2: "eip155:84532";
|
|
13
|
+
readonly chainId: 84532;
|
|
14
|
+
readonly usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
type NetworkName = keyof typeof NETWORKS;
|
|
18
|
+
/** USDC is 6 decimals on Base. */
|
|
19
|
+
declare const USDC_DECIMALS = 6;
|
|
20
|
+
/**
|
|
21
|
+
* Required on every 402 body and every payment-facing doc page. A payment is a direct
|
|
22
|
+
* on-chain transfer between two wallets: once settled nobody, Fatstack included, can
|
|
23
|
+
* reverse it.
|
|
24
|
+
*/
|
|
25
|
+
declare const NO_REFUNDS_NOTICE = "Payments are final. Once settled on-chain the transfer cannot be reversed, and there are no refunds.";
|
|
26
|
+
declare const DOCS_URL = "https://fatstack.net/docs/payments";
|
|
27
|
+
/** Correlates a settled payment with the indexer's view of the on-chain transfer. */
|
|
28
|
+
declare const PAYMENT_REF_HEADER = "X-Fatstack-Payment-Ref";
|
|
29
|
+
declare const DEFAULT_FACILITATOR_URL = "https://x402.org/facilitator";
|
|
30
|
+
|
|
31
|
+
/** One recorded spend, in USD, at a wall-clock millisecond. */
|
|
32
|
+
interface SpendRecord {
|
|
33
|
+
at: number;
|
|
34
|
+
usd: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Where rolling spend totals live. The default is in-memory and per-process; swap in a
|
|
38
|
+
* shared implementation (Redis, Durable Object, Postgres) when an agent runs as more
|
|
39
|
+
* than one process, otherwise each process enforces its own separate budget.
|
|
40
|
+
*/
|
|
41
|
+
interface SpendStore {
|
|
42
|
+
record(entry: SpendRecord): Promise<void> | void;
|
|
43
|
+
/** Total USD recorded at or after `sinceMs`. */
|
|
44
|
+
totalSince(sinceMs: number): Promise<number> | number;
|
|
45
|
+
}
|
|
46
|
+
/** Process-local store. Entries older than the longest window are dropped on write. */
|
|
47
|
+
declare function createMemorySpendStore(retentionMs?: number): SpendStore;
|
|
48
|
+
|
|
49
|
+
/** The signer the official EVM scheme expects: address + signTypedData, no key handling. */
|
|
50
|
+
type EvmWallet = ConstructorParameters<typeof ExactEvmScheme>[0];
|
|
51
|
+
interface SpendGuards {
|
|
52
|
+
/** Hard USD ceiling for a single call. */
|
|
53
|
+
maxPerCall?: number;
|
|
54
|
+
/** Rolling 60-minute USD ceiling. */
|
|
55
|
+
maxPerHour?: number;
|
|
56
|
+
/** Rolling 24-hour USD ceiling. */
|
|
57
|
+
maxPerDay?: number;
|
|
58
|
+
/** Hostnames this agent may pay. Checked before any network call. */
|
|
59
|
+
allowedHosts?: string[];
|
|
60
|
+
}
|
|
61
|
+
interface PayFetchOptions {
|
|
62
|
+
wallet: EvmWallet;
|
|
63
|
+
guards?: SpendGuards;
|
|
64
|
+
/** Defaults to a process-local in-memory store. */
|
|
65
|
+
store?: SpendStore;
|
|
66
|
+
networks?: NetworkName[];
|
|
67
|
+
fetch?: typeof globalThis.fetch;
|
|
68
|
+
now?: () => number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Checks every guard against a quote. Returns the USD value if the call may proceed,
|
|
72
|
+
* throws SpendGuardError otherwise. Called before a payment payload exists.
|
|
73
|
+
*/
|
|
74
|
+
declare function evaluateGuards(quoteUsd: number, guards: SpendGuards, store: SpendStore, now: number): Promise<void>;
|
|
75
|
+
declare function quoteUsdOf(requirements: PaymentRequirements): number;
|
|
76
|
+
/**
|
|
77
|
+
* A `fetch` that pays for 402 responses, under spend guards.
|
|
78
|
+
*
|
|
79
|
+
* The 402 handling, signing and retry are the official x402 packages' work. What this adds
|
|
80
|
+
* is refusal: guards are evaluated inside the payment-policy hook, which runs after the
|
|
81
|
+
* quote is known and before any payload is signed, so exceeding a guard throws
|
|
82
|
+
* SpendGuardError with nothing signed and nothing spent.
|
|
83
|
+
*/
|
|
84
|
+
declare function payFetch(url: RequestInfo | URL, init: RequestInit | undefined, options: PayFetchOptions): Promise<Response>;
|
|
85
|
+
|
|
86
|
+
export { DEFAULT_FACILITATOR_URL as D, type EvmWallet as E, NETWORKS as N, PAYMENT_REF_HEADER as P, type SpendGuards as S, USDC_DECIMALS as U, DOCS_URL as a, NO_REFUNDS_NOTICE as b, type NetworkName as c, type PayFetchOptions as d, type SpendRecord as e, type SpendStore as f, createMemorySpendStore as g, evaluateGuards as h, payFetch as p, quoteUsdOf as q };
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/client.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
PAYMENT_REF_HEADER: () => PAYMENT_REF_HEADER,
|
|
24
|
+
evaluateGuards: () => evaluateGuards,
|
|
25
|
+
payFetch: () => payFetch,
|
|
26
|
+
quoteUsdOf: () => quoteUsdOf
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(client_exports);
|
|
29
|
+
var import_client = require("@x402/core/client");
|
|
30
|
+
var import_client2 = require("@x402/evm/exact/client");
|
|
31
|
+
var import_fetch = require("@x402/fetch");
|
|
32
|
+
|
|
33
|
+
// src/constants.ts
|
|
34
|
+
var NETWORKS = {
|
|
35
|
+
base: { caip2: "eip155:8453", chainId: 8453, usdc: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913" },
|
|
36
|
+
"base-sepolia": {
|
|
37
|
+
caip2: "eip155:84532",
|
|
38
|
+
chainId: 84532,
|
|
39
|
+
usdc: "0x036CbD53842c5426634e7929541eC2318f3dCF7e"
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var USDC_DECIMALS = 6;
|
|
43
|
+
var PAYMENT_REF_HEADER = "X-Fatstack-Payment-Ref";
|
|
44
|
+
|
|
45
|
+
// src/errors.ts
|
|
46
|
+
var SpendGuardError = class extends Error {
|
|
47
|
+
constructor(guard, message, detail = {}) {
|
|
48
|
+
super(message);
|
|
49
|
+
this.guard = guard;
|
|
50
|
+
this.detail = detail;
|
|
51
|
+
}
|
|
52
|
+
guard;
|
|
53
|
+
detail;
|
|
54
|
+
name = "SpendGuardError";
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/money.ts
|
|
58
|
+
var UNITS_PER_USDC = 10n ** BigInt(USDC_DECIMALS);
|
|
59
|
+
var USDC_ADDRESSES = new Set(
|
|
60
|
+
Object.values(NETWORKS).map((network) => network.usdc.toLowerCase())
|
|
61
|
+
);
|
|
62
|
+
function quoteToUsd(quote) {
|
|
63
|
+
const decimals = USDC_ADDRESSES.has(quote.asset.toLowerCase()) ? USDC_DECIMALS : quote.decimals;
|
|
64
|
+
if (decimals === void 0 || !Number.isInteger(decimals) || decimals < 0 || decimals > 36) {
|
|
65
|
+
throw new RangeError(
|
|
66
|
+
`Cannot price asset ${quote.asset}: unknown decimals. Refusing to evaluate spend guards against an unpriceable quote.`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
if (!/^\d+$/.test(quote.amountAtomic)) {
|
|
70
|
+
throw new RangeError(`Quoted amount is not an integer atomic value: ${quote.amountAtomic}`);
|
|
71
|
+
}
|
|
72
|
+
return Number(quote.amountAtomic) / 10 ** decimals;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// src/store.ts
|
|
76
|
+
function createMemorySpendStore(retentionMs = 24 * 60 * 60 * 1e3) {
|
|
77
|
+
let entries = [];
|
|
78
|
+
return {
|
|
79
|
+
record(entry) {
|
|
80
|
+
entries.push(entry);
|
|
81
|
+
const cutoff = entry.at - retentionMs;
|
|
82
|
+
if (entries.length > 64) entries = entries.filter((e) => e.at >= cutoff);
|
|
83
|
+
},
|
|
84
|
+
totalSince(sinceMs) {
|
|
85
|
+
let total = 0;
|
|
86
|
+
for (const entry of entries) if (entry.at >= sinceMs) total += entry.usd;
|
|
87
|
+
return total;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// src/client.ts
|
|
93
|
+
var HOUR_MS = 60 * 60 * 1e3;
|
|
94
|
+
var DAY_MS = 24 * HOUR_MS;
|
|
95
|
+
function hostOf(input) {
|
|
96
|
+
try {
|
|
97
|
+
const raw = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
|
98
|
+
return new URL(raw).hostname.toLowerCase();
|
|
99
|
+
} catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function hostAllowed(host, allowed) {
|
|
104
|
+
return allowed.some((entry) => {
|
|
105
|
+
const candidate = entry.trim().toLowerCase().replace(/^\*\./, "");
|
|
106
|
+
return host === candidate || host.endsWith(`.${candidate}`);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
async function evaluateGuards(quoteUsd, guards, store, now) {
|
|
110
|
+
if (guards.maxPerCall !== void 0 && quoteUsd > guards.maxPerCall) {
|
|
111
|
+
throw new SpendGuardError(
|
|
112
|
+
"maxPerCall",
|
|
113
|
+
`Call costs $${quoteUsd} which exceeds the maxPerCall limit of $${guards.maxPerCall}`,
|
|
114
|
+
{ limitUsd: guards.maxPerCall, attemptedUsd: quoteUsd }
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
if (guards.maxPerHour !== void 0) {
|
|
118
|
+
const spent = await store.totalSince(now - HOUR_MS);
|
|
119
|
+
if (spent + quoteUsd > guards.maxPerHour) {
|
|
120
|
+
throw new SpendGuardError(
|
|
121
|
+
"maxPerHour",
|
|
122
|
+
`Call costs $${quoteUsd} and $${spent} was already spent this hour, exceeding the maxPerHour limit of $${guards.maxPerHour}`,
|
|
123
|
+
{ limitUsd: guards.maxPerHour, attemptedUsd: spent + quoteUsd }
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
if (guards.maxPerDay !== void 0) {
|
|
128
|
+
const spent = await store.totalSince(now - DAY_MS);
|
|
129
|
+
if (spent + quoteUsd > guards.maxPerDay) {
|
|
130
|
+
throw new SpendGuardError(
|
|
131
|
+
"maxPerDay",
|
|
132
|
+
`Call costs $${quoteUsd} and $${spent} was already spent today, exceeding the maxPerDay limit of $${guards.maxPerDay}`,
|
|
133
|
+
{ limitUsd: guards.maxPerDay, attemptedUsd: spent + quoteUsd }
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function quoteUsdOf(requirements) {
|
|
139
|
+
const asRecord = requirements;
|
|
140
|
+
const amountAtomic = asRecord.maxAmountRequired ?? asRecord.amount;
|
|
141
|
+
if (!amountAtomic || !asRecord.asset) {
|
|
142
|
+
throw new RangeError("Payment requirements carry no priceable amount; refusing to pay.");
|
|
143
|
+
}
|
|
144
|
+
return quoteToUsd({
|
|
145
|
+
amountAtomic,
|
|
146
|
+
asset: asRecord.asset,
|
|
147
|
+
decimals: asRecord.extra?.decimals
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
async function payFetch(url, init, options) {
|
|
151
|
+
const guards = options.guards ?? {};
|
|
152
|
+
const store = options.store ?? createMemorySpendStore();
|
|
153
|
+
const now = options.now ?? Date.now;
|
|
154
|
+
const baseFetch = options.fetch ?? globalThis.fetch;
|
|
155
|
+
const networks = options.networks ?? ["base"];
|
|
156
|
+
if (guards.allowedHosts) {
|
|
157
|
+
const host = hostOf(url);
|
|
158
|
+
if (!host || !hostAllowed(host, guards.allowedHosts)) {
|
|
159
|
+
throw new SpendGuardError(
|
|
160
|
+
"allowedHosts",
|
|
161
|
+
`Host ${host ?? "<unparseable>"} is not in allowedHosts`,
|
|
162
|
+
{ host: host ?? void 0 }
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
let quotedUsd = null;
|
|
167
|
+
const client = new import_client.x402Client((_version, requirements) => {
|
|
168
|
+
const affordable = requirements.filter((requirement) => {
|
|
169
|
+
const usd = quoteUsdOf(requirement);
|
|
170
|
+
return guards.maxPerCall === void 0 || usd <= guards.maxPerCall;
|
|
171
|
+
});
|
|
172
|
+
const chosen = (affordable.length > 0 ? affordable : requirements)[0];
|
|
173
|
+
if (!chosen) throw new RangeError("Resource offered no payment requirements");
|
|
174
|
+
quotedUsd = quoteUsdOf(chosen);
|
|
175
|
+
return chosen;
|
|
176
|
+
});
|
|
177
|
+
for (const name of networks) {
|
|
178
|
+
client.register(NETWORKS[name].caip2, new import_client2.ExactEvmScheme(options.wallet));
|
|
179
|
+
}
|
|
180
|
+
const guarded = async (input, requestInit) => {
|
|
181
|
+
const response2 = await baseFetch(input, requestInit);
|
|
182
|
+
if (response2.status !== 402) return response2;
|
|
183
|
+
const body = await response2.clone().json().catch(() => null);
|
|
184
|
+
const accepts = body?.accepts;
|
|
185
|
+
if (Array.isArray(accepts) && accepts.length > 0) {
|
|
186
|
+
const cheapest = accepts.map((requirement) => quoteUsdOf(requirement)).sort((a, b) => a - b)[0];
|
|
187
|
+
if (cheapest !== void 0) {
|
|
188
|
+
await evaluateGuards(cheapest, guards, store, now());
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return response2;
|
|
192
|
+
};
|
|
193
|
+
const paying = (0, import_fetch.wrapFetchWithPayment)(guarded, client);
|
|
194
|
+
const response = await paying(url, init);
|
|
195
|
+
if (response.headers.get("x-payment-response") && quotedUsd !== null) {
|
|
196
|
+
await store.record({ at: now(), usd: quotedUsd });
|
|
197
|
+
}
|
|
198
|
+
return response;
|
|
199
|
+
}
|
|
200
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
201
|
+
0 && (module.exports = {
|
|
202
|
+
PAYMENT_REF_HEADER,
|
|
203
|
+
evaluateGuards,
|
|
204
|
+
payFetch,
|
|
205
|
+
quoteUsdOf
|
|
206
|
+
});
|
|
207
|
+
//# sourceMappingURL=client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/constants.ts","../src/errors.ts","../src/money.ts","../src/store.ts"],"sourcesContent":["import { x402Client } from '@x402/core/client';\nimport type { PaymentRequirements } from '@x402/core/types';\nimport { ExactEvmScheme } from '@x402/evm/exact/client';\nimport { wrapFetchWithPayment } from '@x402/fetch';\n\nimport { NETWORKS, PAYMENT_REF_HEADER } from './constants.js';\nimport type { NetworkName } from './constants.js';\nimport { SpendGuardError } from './errors.js';\nimport { quoteToUsd } from './money.js';\nimport { createMemorySpendStore } from './store.js';\nimport type { SpendStore } from './store.js';\n\n/** The signer the official EVM scheme expects: address + signTypedData, no key handling. */\nexport type EvmWallet = ConstructorParameters<typeof ExactEvmScheme>[0];\n\nexport interface SpendGuards {\n /** Hard USD ceiling for a single call. */\n maxPerCall?: number;\n /** Rolling 60-minute USD ceiling. */\n maxPerHour?: number;\n /** Rolling 24-hour USD ceiling. */\n maxPerDay?: number;\n /** Hostnames this agent may pay. Checked before any network call. */\n allowedHosts?: string[];\n}\n\nexport interface PayFetchOptions {\n wallet: EvmWallet;\n guards?: SpendGuards;\n /** Defaults to a process-local in-memory store. */\n store?: SpendStore;\n networks?: NetworkName[];\n fetch?: typeof globalThis.fetch;\n now?: () => number;\n}\n\nconst HOUR_MS = 60 * 60 * 1000;\nconst DAY_MS = 24 * HOUR_MS;\n\nfunction hostOf(input: RequestInfo | URL): string | null {\n try {\n const raw =\n typeof input === 'string'\n ? input\n : input instanceof URL\n ? input.toString()\n : (input as Request).url;\n return new URL(raw).hostname.toLowerCase();\n } catch {\n return null;\n }\n}\n\n/** `example.com` in allowedHosts also authorises `tool.example.com`. */\nfunction hostAllowed(host: string, allowed: readonly string[]): boolean {\n return allowed.some((entry) => {\n const candidate = entry.trim().toLowerCase().replace(/^\\*\\./, '');\n return host === candidate || host.endsWith(`.${candidate}`);\n });\n}\n\n/**\n * Checks every guard against a quote. Returns the USD value if the call may proceed,\n * throws SpendGuardError otherwise. Called before a payment payload exists.\n */\nexport async function evaluateGuards(\n quoteUsd: number,\n guards: SpendGuards,\n store: SpendStore,\n now: number,\n): Promise<void> {\n if (guards.maxPerCall !== undefined && quoteUsd > guards.maxPerCall) {\n throw new SpendGuardError(\n 'maxPerCall',\n `Call costs $${quoteUsd} which exceeds the maxPerCall limit of $${guards.maxPerCall}`,\n { limitUsd: guards.maxPerCall, attemptedUsd: quoteUsd },\n );\n }\n\n if (guards.maxPerHour !== undefined) {\n const spent = await store.totalSince(now - HOUR_MS);\n if (spent + quoteUsd > guards.maxPerHour) {\n throw new SpendGuardError(\n 'maxPerHour',\n `Call costs $${quoteUsd} and $${spent} was already spent this hour, exceeding the maxPerHour limit of $${guards.maxPerHour}`,\n { limitUsd: guards.maxPerHour, attemptedUsd: spent + quoteUsd },\n );\n }\n }\n\n if (guards.maxPerDay !== undefined) {\n const spent = await store.totalSince(now - DAY_MS);\n if (spent + quoteUsd > guards.maxPerDay) {\n throw new SpendGuardError(\n 'maxPerDay',\n `Call costs $${quoteUsd} and $${spent} was already spent today, exceeding the maxPerDay limit of $${guards.maxPerDay}`,\n { limitUsd: guards.maxPerDay, attemptedUsd: spent + quoteUsd },\n );\n }\n }\n}\n\n/** Reads the quoted amount out of x402 payment requirements. */\ninterface PriceableRequirement {\n maxAmountRequired?: string;\n amount?: string;\n asset?: string;\n extra?: { decimals?: number };\n}\n\nexport function quoteUsdOf(requirements: PaymentRequirements): number {\n const asRecord: PriceableRequirement = requirements;\n const amountAtomic = asRecord.maxAmountRequired ?? asRecord.amount;\n if (!amountAtomic || !asRecord.asset) {\n throw new RangeError('Payment requirements carry no priceable amount; refusing to pay.');\n }\n return quoteToUsd({\n amountAtomic,\n asset: asRecord.asset,\n decimals: asRecord.extra?.decimals,\n });\n}\n\n/**\n * A `fetch` that pays for 402 responses, under spend guards.\n *\n * The 402 handling, signing and retry are the official x402 packages' work. What this adds\n * is refusal: guards are evaluated inside the payment-policy hook, which runs after the\n * quote is known and before any payload is signed, so exceeding a guard throws\n * SpendGuardError with nothing signed and nothing spent.\n */\nexport async function payFetch(\n url: RequestInfo | URL,\n init: RequestInit | undefined,\n options: PayFetchOptions,\n): Promise<Response> {\n const guards = options.guards ?? {};\n const store = options.store ?? createMemorySpendStore();\n const now = options.now ?? Date.now;\n const baseFetch = options.fetch ?? globalThis.fetch;\n const networks = options.networks ?? (['base'] as NetworkName[]);\n\n // Host allowlist is checked first: an unauthorised host should cost no request at all.\n if (guards.allowedHosts) {\n const host = hostOf(url);\n if (!host || !hostAllowed(host, guards.allowedHosts)) {\n throw new SpendGuardError(\n 'allowedHosts',\n `Host ${host ?? '<unparseable>'} is not in allowedHosts`,\n { host: host ?? undefined },\n );\n }\n }\n\n let quotedUsd: number | null = null;\n\n const client = new x402Client((_version, requirements) => {\n // Runs before the payment payload is created. Throwing here means no signature.\n const affordable = requirements.filter((requirement) => {\n const usd = quoteUsdOf(requirement);\n return guards.maxPerCall === undefined || usd <= guards.maxPerCall;\n });\n\n const chosen = (affordable.length > 0 ? affordable : requirements)[0];\n if (!chosen) throw new RangeError('Resource offered no payment requirements');\n\n quotedUsd = quoteUsdOf(chosen);\n return chosen;\n });\n\n for (const name of networks) {\n client.register(NETWORKS[name].caip2, new ExactEvmScheme(options.wallet));\n }\n\n const guarded: typeof globalThis.fetch = async (input, requestInit) => {\n const response = await baseFetch(input, requestInit);\n if (response.status !== 402) return response;\n\n // Peek at the quote and apply guards before the wrapper signs anything.\n const body = await response\n .clone()\n .json()\n .catch(() => null);\n const accepts = (body as { accepts?: PaymentRequirements[] } | null)?.accepts;\n if (Array.isArray(accepts) && accepts.length > 0) {\n const cheapest = accepts\n .map((requirement) => quoteUsdOf(requirement))\n .sort((a, b) => a - b)[0];\n if (cheapest !== undefined) {\n await evaluateGuards(cheapest, guards, store, now());\n }\n }\n return response;\n };\n\n const paying = wrapFetchWithPayment(guarded, client);\n const response = await paying(url as RequestInfo, init);\n\n // Record the spend only once a payment actually settled.\n if (response.headers.get('x-payment-response') && quotedUsd !== null) {\n await store.record({ at: now(), usd: quotedUsd });\n }\n\n return response;\n}\n\nexport { PAYMENT_REF_HEADER };\n","/** Base networks in CAIP-2 form, which is what x402 v2 speaks. */\nexport const NETWORKS = {\n base: { caip2: 'eip155:8453', chainId: 8453, usdc: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' },\n 'base-sepolia': {\n caip2: 'eip155:84532',\n chainId: 84532,\n usdc: '0x036CbD53842c5426634e7929541eC2318f3dCF7e',\n },\n} as const;\n\nexport type NetworkName = keyof typeof NETWORKS;\n\n/** USDC is 6 decimals on Base. */\nexport const USDC_DECIMALS = 6;\n\n/**\n * Required on every 402 body and every payment-facing doc page. A payment is a direct\n * on-chain transfer between two wallets: once settled nobody, Fatstack included, can\n * reverse it.\n */\nexport const NO_REFUNDS_NOTICE =\n 'Payments are final. Once settled on-chain the transfer cannot be reversed, and there are no refunds.';\n\nexport const DOCS_URL = 'https://fatstack.net/docs/payments';\n\n/** Correlates a settled payment with the indexer's view of the on-chain transfer. */\nexport const PAYMENT_REF_HEADER = 'X-Fatstack-Payment-Ref';\n\nexport const DEFAULT_FACILITATOR_URL = 'https://x402.org/facilitator';\n","/** Names of the spend guards an agent can set. */\nexport type GuardName = 'maxPerCall' | 'maxPerHour' | 'maxPerDay' | 'allowedHosts';\n\n/**\n * Thrown before anything is signed when a call would breach a spend guard.\n *\n * Payments are final, so the only place to stop an unwanted spend is before the\n * signature exists. Every guard raises this, and it is never thrown after a payment\n * payload has been created.\n */\nexport class SpendGuardError extends Error {\n override readonly name = 'SpendGuardError';\n\n constructor(\n readonly guard: GuardName,\n message: string,\n readonly detail: { limitUsd?: number; attemptedUsd?: number; host?: string } = {},\n ) {\n super(message);\n }\n}\n\n/** Thrown by seams that are typed and reachable but deliberately not built yet. */\nexport class NotImplementedError extends Error {\n override readonly name = 'NotImplementedError';\n\n constructor(feature: string) {\n super(`${feature} is not implemented in this build.`);\n }\n}\n\n/** Thrown when an optional framework adapter is used without its package installed. */\nexport class MissingAdapterError extends Error {\n override readonly name = 'MissingAdapterError';\n\n constructor(pkg: string) {\n super(`${pkg} is not installed. Add it to use this adapter: pnpm add ${pkg}`);\n }\n}\n","import { NETWORKS, USDC_DECIMALS } from './constants.js';\n\nconst UNITS_PER_USDC = 10n ** BigInt(USDC_DECIMALS);\n\n/** \"1.25\" -> 1250000n. Rejects anything that is not a plain non-negative decimal. */\nexport function parseUsdc(input: string): bigint {\n const match = /^(\\d+)(?:\\.(\\d{1,6}))?$/.exec(input.trim());\n if (!match) {\n throw new RangeError(`Not a USDC amount with at most ${USDC_DECIMALS} decimals: ${input}`);\n }\n const whole = BigInt(match[1] ?? '0');\n const fraction = BigInt((match[2] ?? '').padEnd(USDC_DECIMALS, '0') || '0');\n return whole * UNITS_PER_USDC + fraction;\n}\n\n/** 1250000n -> \"1.25\". Trailing zeros trimmed. */\nexport function formatUsdc(atomic: bigint): string {\n if (atomic < 0n) throw new RangeError('USDC amounts are never negative');\n const whole = atomic / UNITS_PER_USDC;\n const fraction = (atomic % UNITS_PER_USDC).toString().padStart(USDC_DECIMALS, '0');\n const trimmed = fraction.replace(/0+$/, '');\n return trimmed ? `${whole}.${trimmed}` : whole.toString();\n}\n\nconst USDC_ADDRESSES = new Set(\n Object.values(NETWORKS).map((network) => network.usdc.toLowerCase()),\n);\n\n/**\n * Converts a quoted amount to USD for guard evaluation.\n *\n * Fails closed: if the asset is not a USDC contract we recognise and the quote carries no\n * usable `decimals`, this throws rather than guessing. Guessing here would let an\n * unrecognised token slip past a spend cap, and the payment is irreversible.\n */\nexport function quoteToUsd(quote: {\n amountAtomic: string;\n asset: string;\n decimals?: number | undefined;\n}): number {\n const decimals = USDC_ADDRESSES.has(quote.asset.toLowerCase()) ? USDC_DECIMALS : quote.decimals;\n\n if (decimals === undefined || !Number.isInteger(decimals) || decimals < 0 || decimals > 36) {\n throw new RangeError(\n `Cannot price asset ${quote.asset}: unknown decimals. Refusing to evaluate spend guards against an unpriceable quote.`,\n );\n }\n\n if (!/^\\d+$/.test(quote.amountAtomic)) {\n throw new RangeError(`Quoted amount is not an integer atomic value: ${quote.amountAtomic}`);\n }\n\n return Number(quote.amountAtomic) / 10 ** decimals;\n}\n","/** One recorded spend, in USD, at a wall-clock millisecond. */\nexport interface SpendRecord {\n at: number;\n usd: number;\n}\n\n/**\n * Where rolling spend totals live. The default is in-memory and per-process; swap in a\n * shared implementation (Redis, Durable Object, Postgres) when an agent runs as more\n * than one process, otherwise each process enforces its own separate budget.\n */\nexport interface SpendStore {\n record(entry: SpendRecord): Promise<void> | void;\n /** Total USD recorded at or after `sinceMs`. */\n totalSince(sinceMs: number): Promise<number> | number;\n}\n\n/** Process-local store. Entries older than the longest window are dropped on write. */\nexport function createMemorySpendStore(retentionMs = 24 * 60 * 60 * 1000): SpendStore {\n let entries: SpendRecord[] = [];\n\n return {\n record(entry) {\n entries.push(entry);\n const cutoff = entry.at - retentionMs;\n if (entries.length > 64) entries = entries.filter((e) => e.at >= cutoff);\n },\n totalSince(sinceMs) {\n let total = 0;\n for (const entry of entries) if (entry.at >= sinceMs) total += entry.usd;\n return total;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAE3B,IAAAA,iBAA+B;AAC/B,mBAAqC;;;ACF9B,IAAM,WAAW;AAAA,EACtB,MAAM,EAAE,OAAO,eAAe,SAAS,MAAM,MAAM,6CAA6C;AAAA,EAChG,gBAAgB;AAAA,IACd,OAAO;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AACF;AAKO,IAAM,gBAAgB;AAatB,IAAM,qBAAqB;;;AChB3B,IAAM,kBAAN,cAA8B,MAAM;AAAA,EAGzC,YACW,OACT,SACS,SAAsE,CAAC,GAChF;AACA,UAAM,OAAO;AAJJ;AAEA;AAAA,EAGX;AAAA,EALW;AAAA,EAEA;AAAA,EALO,OAAO;AAS3B;;;AClBA,IAAM,iBAAiB,OAAO,OAAO,aAAa;AAsBlD,IAAM,iBAAiB,IAAI;AAAA,EACzB,OAAO,OAAO,QAAQ,EAAE,IAAI,CAAC,YAAY,QAAQ,KAAK,YAAY,CAAC;AACrE;AASO,SAAS,WAAW,OA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AK,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC;AAC1B,UAAI,aAAa,QAAW;AAC1B,cAAM,eAAe,UAAU,QAAQ,OAAO,IAAI,CAAC;AAAA,MACrD;AAAA,IACF;AACA,WAAOA;AAAA,EACT;AAEA,QAAM,aAAS,mCAAqB,SAAS,MAAM;AACnD,QAAM,WAAW,MAAM,OAAO,KAAoB,IAAI;AAGtD,MAAI,SAAS,QAAQ,IAAI,oBAAoB,KAAK,cAAc,MAAM;AACpE,UAAM,MAAM,OAAO,EAAE,IAAI,IAAI,GAAG,KAAK,UAAU,CAAC;AAAA,EAClD;AAEA,SAAO;AACT;","names":["import_client","response"]}
|
package/dist/client.d.ts
ADDED
package/dist/client.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
evaluateGuards,
|
|
3
|
+
payFetch,
|
|
4
|
+
quoteUsdOf
|
|
5
|
+
} from "./chunk-HCN75CTX.js";
|
|
6
|
+
import {
|
|
7
|
+
PAYMENT_REF_HEADER
|
|
8
|
+
} from "./chunk-6LSPHKJ7.js";
|
|
9
|
+
export {
|
|
10
|
+
PAYMENT_REF_HEADER,
|
|
11
|
+
evaluateGuards,
|
|
12
|
+
payFetch,
|
|
13
|
+
quoteUsdOf
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|