twzrd-x402-gate 0.9.0 → 0.9.2
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/QUICKSTART.md +11 -20
- package/README.md +54 -242
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/mpp-hook.d.ts +12 -39
- package/dist/mpp-hook.d.ts.map +1 -1
- package/dist/mpp-hook.js +13 -76
- package/dist/mpp-hook.js.map +1 -1
- package/dist/resource-bind-tx.d.ts +27 -0
- package/dist/resource-bind-tx.d.ts.map +1 -0
- package/dist/resource-bind-tx.js +118 -0
- package/dist/resource-bind-tx.js.map +1 -0
- package/dist/resource-bind.d.ts +48 -0
- package/dist/resource-bind.d.ts.map +1 -0
- package/dist/resource-bind.js +184 -0
- package/dist/resource-bind.js.map +1 -0
- package/dist/spend-control.d.ts +39 -0
- package/dist/spend-control.d.ts.map +1 -0
- package/dist/spend-control.js +137 -0
- package/dist/spend-control.js.map +1 -0
- package/dist/spend-ledger-file.d.ts +3 -0
- package/dist/spend-ledger-file.d.ts.map +1 -0
- package/dist/spend-ledger-file.js +66 -0
- package/dist/spend-ledger-file.js.map +1 -0
- package/dist/x402-client-hook.d.ts +18 -24
- package/dist/x402-client-hook.d.ts.map +1 -1
- package/dist/x402-client-hook.js +36 -41
- package/dist/x402-client-hook.js.map +1 -1
- package/package.json +8 -7
- package/dist/cloudflare-base.d.ts +0 -49
- package/dist/cloudflare-base.d.ts.map +0 -1
- package/dist/cloudflare-base.js +0 -113
- package/dist/cloudflare-base.js.map +0 -1
- package/dist/cloudflare-x402.d.ts +0 -29
- package/dist/cloudflare-x402.d.ts.map +0 -1
- package/dist/cloudflare-x402.js +0 -31
- package/dist/cloudflare-x402.js.map +0 -1
- package/dist/wash-default.d.ts +0 -106
- package/dist/wash-default.d.ts.map +0 -1
- package/dist/wash-default.js +0 -223
- package/dist/wash-default.js.map +0 -1
package/QUICKSTART.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
# twzrd-x402-gate — Quickstart (15 minutes, 0 USDC)
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Refuses payment to a wash-flagged merchant **before your wallet signs**. Free intel, no
|
|
4
|
+
API key, no signup, no config — every `TWZRD_*` env var is an optional override. If intel
|
|
5
|
+
is unreachable the gate never *invents* a wash flag (the wash check fails open); a failed
|
|
6
|
+
preflight blocks the payment by default (`TWZRD_FAIL_OPEN=true` to allow).
|
|
6
7
|
|
|
7
|
-
**Pin:** `twzrd-x402-gate@0.
|
|
8
|
+
**Pin:** `twzrd-x402-gate@0.8.18` + stock PayAI client `x402-solana@2.1.0` (official
|
|
9
|
+
`beforePayment` seat). `@x402/core` Path E remains supported; refuse script is fallback.
|
|
8
10
|
|
|
9
11
|
## 1. Stock PayAI client (default seat — copy-paste)
|
|
10
12
|
|
|
11
13
|
```bash
|
|
12
|
-
npm install twzrd-x402-gate@0.
|
|
14
|
+
npm install twzrd-x402-gate@0.8.18 x402-solana@2.1.0
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
> **ESM-only.** The package ships `import` conditions only — a CommonJS
|
|
@@ -17,16 +19,6 @@ npm install twzrd-x402-gate@0.9.0 x402-solana@3.0.0
|
|
|
17
19
|
> fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`. Set `"type": "module"` in your
|
|
18
20
|
> package.json, use `.mjs`, or bundle ESM.
|
|
19
21
|
|
|
20
|
-
```typescript
|
|
21
|
-
import { createX402Client } from "x402-solana";
|
|
22
|
-
import { createTwzrdPayingClient } from "twzrd-x402-gate";
|
|
23
|
-
|
|
24
|
-
// was: createX402Client({ wallet })
|
|
25
|
-
const client = createX402Client(createTwzrdPayingClient({ wallet }));
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Or hook-only:
|
|
29
|
-
|
|
30
22
|
```typescript
|
|
31
23
|
import { createX402Client } from "x402-solana";
|
|
32
24
|
import { createTwzrdBeforePaymentHook } from "twzrd-x402-gate";
|
|
@@ -34,18 +26,17 @@ import { createTwzrdBeforePaymentHook } from "twzrd-x402-gate";
|
|
|
34
26
|
const client = createX402Client({
|
|
35
27
|
wallet,
|
|
36
28
|
network: "solana",
|
|
37
|
-
beforePayment: createTwzrdBeforePaymentHook(),
|
|
29
|
+
beforePayment: createTwzrdBeforePaymentHook({ refuseWashFlagged: true }),
|
|
38
30
|
});
|
|
39
31
|
```
|
|
40
32
|
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
Equivalent: `beforePayment: installTwzrdAutoGate("x402-solana", { refuseWashFlagged: true })`.
|
|
43
34
|
Then: `await client.fetch("https://merchant.example/paid");`
|
|
44
35
|
|
|
45
36
|
## 1b. Official `@x402/core` client (Path E)
|
|
46
37
|
|
|
47
38
|
```bash
|
|
48
|
-
npm install twzrd-x402-gate@0.
|
|
39
|
+
npm install twzrd-x402-gate@0.8.18 @x402/core @x402/fetch @x402/svm
|
|
49
40
|
```
|
|
50
41
|
|
|
51
42
|
```typescript
|
|
@@ -62,7 +53,7 @@ installTwzrdAutoGate(client, { refuseWashFlagged: true });
|
|
|
62
53
|
|
|
63
54
|
```bash
|
|
64
55
|
# Stock-client seat proof (beforePayment, signer_invocation_count=0)
|
|
65
|
-
# needs x402-solana@
|
|
56
|
+
# needs x402-solana@2.1.0 installed - the harness fallback runs but does not
|
|
66
57
|
# clear closure (its negative arm counts a would-be sign)
|
|
67
58
|
npm run x402-solana-before-payment-proof
|
|
68
59
|
# writes block-proof-<run_id>.json — hook: beforePayment
|
package/README.md
CHANGED
|
@@ -1,63 +1,35 @@
|
|
|
1
1
|
# twzrd-x402-gate
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**TWZRD is the spend-control SDK for agents paying over x402** — and the default
|
|
4
|
+
`onBeforePaymentCreation` policy engine for official x402 clients.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
to say **no** before the signature. TWZRD is that no — inside `beforePayment` /
|
|
7
|
-
fetch+sign, not inside PayAI’s SDK defaults, not as a shop at intel.twzrd.xyz.
|
|
6
|
+
### One call (named export `twzrd`)
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
```js
|
|
9
|
+
import { twzrd } from "twzrd-x402-gate";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import { createX402Client } from "x402-solana";
|
|
17
|
-
import { createTwzrdPayingClient } from "twzrd-x402-gate";
|
|
18
|
-
|
|
19
|
-
// was: createX402Client({ wallet })
|
|
20
|
-
const client = createX402Client(createTwzrdPayingClient({ wallet }));
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Equivalent one-hook form:
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { createX402Client } from "x402-solana";
|
|
27
|
-
import { createTwzrdBeforePaymentHook } from "twzrd-x402-gate";
|
|
28
|
-
|
|
29
|
-
const client = createX402Client({
|
|
30
|
-
wallet,
|
|
31
|
-
network: "solana",
|
|
32
|
-
beforePayment: createTwzrdBeforePaymentHook(), // wash default
|
|
11
|
+
const result = await twzrd.safeFetch(url, {
|
|
12
|
+
maxSpend: "0.10", // per-call cap AND cumulative budget
|
|
13
|
+
allowNetworks: ["solana", "base"],
|
|
14
|
+
requireOfferBinding: true, // demand a chain-verifiable bind-v1 receipt
|
|
15
|
+
pay, // your wallet signs — this SDK never holds keys
|
|
33
16
|
});
|
|
17
|
+
// result.verdict: "allow" | "warn" | "block" — blocks have signerInvocations === 0
|
|
18
|
+
// result.receipt: { strength: "hard"|"soft"|"refuse", leaf_hash, fact_type: "resource_bound" }
|
|
34
19
|
```
|
|
35
20
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
**fail-open** on timeout / non-2xx / throw (never invent wash).
|
|
39
|
-
No Path A, no requireReceipt, no second 402, no payment-control tokens.
|
|
21
|
+
Full walkthrough: [QUICKSTART.md](https://github.com/twzrd-sol/twzrd-trust/blob/main/QUICKSTART.md) ·
|
|
22
|
+
verify receipts yourself: [REVIEW.md](https://github.com/twzrd-sol/twzrd-trust/blob/main/REVIEW.md)
|
|
40
23
|
|
|
41
|
-
**
|
|
42
|
-
|
|
24
|
+
**Core product (buyer gate):** after the client selects the exact payment requirement and
|
|
25
|
+
**before** payment payload creation / wallet signing — free preflight + merchant_card wash
|
|
26
|
+
refuse. Protects the **payer** from a risky **merchant** (`payTo`). Chain-neutral envelope;
|
|
27
|
+
**Solana-deep** reputation only (Base/EVM = explicit `unknown`).
|
|
43
28
|
|
|
44
|
-
|
|
45
|
-
createTwzrdBeforePaymentHook({ engine: "full", /* … */ })
|
|
46
|
-
// or createTwzrdFullBeforePaymentHook({ … })
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
Customer = whoever ships `createX402Client({ wallet })` with no hook (Eliza, MCP
|
|
50
|
-
hosts, agent wallets). Crawlers will never `npm install`.
|
|
51
|
-
|
|
52
|
-
> **ESM-only:** CommonJS `require()` fails with `ERR_PACKAGE_PATH_NOT_EXPORTED`
|
|
53
|
-
> — set `"type": "module"` (or use `.mjs` / an ESM bundler).
|
|
54
|
-
|
|
55
|
-
### Default-on AutoGate (alternate seats)
|
|
29
|
+
### Default-on AutoGate (5 lines)
|
|
56
30
|
|
|
57
31
|
```bash
|
|
58
|
-
npm install twzrd-x402-gate@
|
|
59
|
-
# official @x402/* path (alternate seat):
|
|
60
|
-
# npm install twzrd-x402-gate@0.9.0 @x402/core @x402/fetch @x402/svm
|
|
32
|
+
npm install twzrd-x402-gate @x402/core @x402/fetch @x402/svm
|
|
61
33
|
```
|
|
62
34
|
|
|
63
35
|
```typescript
|
|
@@ -65,28 +37,26 @@ import { x402Client } from "@x402/core/client";
|
|
|
65
37
|
import { installTwzrdAutoGate } from "twzrd-x402-gate";
|
|
66
38
|
|
|
67
39
|
const client = new x402Client();
|
|
68
|
-
//
|
|
40
|
+
// refuseWashFlagged defaults true; gateOnCanSpend stays false unless you opt in
|
|
69
41
|
installTwzrdAutoGate(client, { refuseWashFlagged: true });
|
|
70
42
|
// then register schemes + wrapFetchWithPayment as usual
|
|
71
43
|
```
|
|
72
44
|
|
|
73
|
-
**Intercept proof (0 USDC,
|
|
45
|
+
**Intercept proof (0 USDC, wash seller never reaches signer):**
|
|
74
46
|
|
|
75
47
|
```bash
|
|
76
48
|
cd packages/twzrd-x402-gate && npm run autogate-block-proof
|
|
77
49
|
# writes block-proof-<run_id>.json (schema twzrd.autogate_block_proof.v1)
|
|
78
|
-
# public reason:
|
|
79
|
-
# or "TWZRD_TRUST_GATE_BLOCK: decision_block" (readiness block basis)
|
|
80
|
-
# fixture resolves live: wash_flagged seller if available, else decision=block
|
|
50
|
+
# public reason: TWZRD_TRUST_GATE_BLOCK: wash_flagged
|
|
81
51
|
```
|
|
82
52
|
|
|
83
|
-
`gateOnCanSpend` remains **opt-in** (`false` by default; set `true` or `TWZRD_GATE_ON_CAN_SPEND=1` only when you want hard cap enforcement).
|
|
53
|
+
`gateOnCanSpend` remains **opt-in** (`false` by default; set `true` or `TWZRD_GATE_ON_CAN_SPEND=1` only when you want hard cap enforcement).
|
|
84
54
|
|
|
85
|
-
**Optional:** a resource-server settle hook so merchants can apply **customer policy**
|
|
55
|
+
**Optional (0.8.1):** a resource-server settle hook so merchants can apply **customer policy**
|
|
86
56
|
before they settle and serve (abuse, sanctions, bots, “don’t serve this payer”). Not an equal
|
|
87
57
|
mirror of the buyer problem — settled USDC is final; wash resistance is mainly TWZRD scoring.
|
|
88
58
|
|
|
89
|
-
## Seller settle guard (`onBeforeSettle`) — optional
|
|
59
|
+
## Seller settle guard (`onBeforeSettle`) — optional 0.8.1
|
|
90
60
|
|
|
91
61
|
Resource servers can screen the **payer** before *they* settle an inbound payment and serve
|
|
92
62
|
the resource. Use for merchant policy (abuse / sanctions / bots / customer selection). TWZRD is
|
|
@@ -98,7 +68,7 @@ transfer on-chain. Wash/sybil edges are primarily discounted in TWZRD scoring, n
|
|
|
98
68
|
revenue refusal.
|
|
99
69
|
|
|
100
70
|
```bash
|
|
101
|
-
npm install twzrd-x402-gate@0.
|
|
71
|
+
npm install twzrd-x402-gate@0.8.18
|
|
102
72
|
```
|
|
103
73
|
|
|
104
74
|
```typescript
|
|
@@ -130,23 +100,7 @@ Offline demo: `npx tsx examples/seller-settle-guard.ts`
|
|
|
130
100
|
Fixture-backed SVM extract tests live in `test/seller-hook.test.ts` +
|
|
131
101
|
`test/fixtures/exact-svm-transfer-checked.ts`.
|
|
132
102
|
|
|
133
|
-
**PayAI
|
|
134
|
-
Both 2.1.0 and 3.0.0 are supported and produce an identical refuse transcript; 3.0.0
|
|
135
|
-
is the current release and what the install lines pin. The hook absorbs the one
|
|
136
|
-
breaking change between them (`declaredResource` is a string on 2.1.0, `{ url }` on
|
|
137
|
-
3.0.0) - see `src/x402-client-hook.ts` and `test/x402-solana-before-payment.test.ts`.
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
import { createX402Client } from "x402-solana";
|
|
141
|
-
import { createTwzrdPayingClient } from "twzrd-x402-gate";
|
|
142
|
-
|
|
143
|
-
const client = createX402Client(createTwzrdPayingClient({ wallet }));
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Also: `installTwzrdAutoGate("x402-solana", opts)` returns the same wash-default hook.
|
|
147
|
-
Prove refuse-before-sign: `npm run x402-solana-before-payment-proof`.
|
|
148
|
-
|
|
149
|
-
**PayAI agentic-payments** (alternate PayAI surface; prefer x402-solana@3.0.0 when available):
|
|
103
|
+
**PayAI agentic-payments** (the active PayAI SDK, not the dormant x402-solana):
|
|
150
104
|
`npx tsx examples/payai-agentic-onPaymentVerified.ts` — wire `onPaymentVerified`
|
|
151
105
|
→ `toPayaiVerifyResult` to screen payers before serving. Fail-open by default.
|
|
152
106
|
|
|
@@ -158,7 +112,7 @@ Prove refuse-before-sign: `npm run x402-solana-before-payment-proof`.
|
|
|
158
112
|
Install the published gate and run against wash fixtures:
|
|
159
113
|
|
|
160
114
|
```bash
|
|
161
|
-
npm install twzrd-x402-gate@0.
|
|
115
|
+
npm install twzrd-x402-gate@0.8.18
|
|
162
116
|
# from package root after install, or from a checkout:
|
|
163
117
|
npm run wash-dogfood
|
|
164
118
|
```
|
|
@@ -178,7 +132,7 @@ Gate dogfood: `approved=false` `reason=twzrd_decision_block`, **USDC spent = 0**
|
|
|
178
132
|
|
|
179
133
|
**Accurate paste line:**
|
|
180
134
|
|
|
181
|
-
> Preflight returned decision=block on wash seller 7G73PL… / HuSiSpc… (preflight_id 378468 / 378469, wash_flagged=true). Gate approved=false reason=twzrd_decision_block. No USDC spent. No tx broadcast. Repro: `npm i twzrd-x402-gate@0.
|
|
135
|
+
> Preflight returned decision=block on wash seller 7G73PL… / HuSiSpc… (preflight_id 378468 / 378469, wash_flagged=true). Gate approved=false reason=twzrd_decision_block. No USDC spent. No tx broadcast. Repro: `npm i twzrd-x402-gate@0.8.5 && npm run wash-dogfood` or gist above.
|
|
182
136
|
|
|
183
137
|
This is a **reproducible demonstration** that the free gate blocks known wash sellers with stamped `preflight_id`s and zero spend. It is **not** proof that external agents already default to this path at scale.
|
|
184
138
|
|
|
@@ -256,61 +210,11 @@ No AgentCash. No marketplace. No second probe. No TWZRD custody.
|
|
|
256
210
|
Wire `twzrdOnPaymentRequested` / prefer `onPaymentRequired` + `onBeforePayment` per
|
|
257
211
|
[lifecycle hooks](https://docs.x402.org/advanced-concepts/lifecycle-hooks). Same policy core.
|
|
258
212
|
|
|
259
|
-
### Cloudflare Agents x402 (Base)
|
|
260
|
-
|
|
261
|
-
Cloudflare's `withX402Client` takes an `onPaymentRequired` callback before its
|
|
262
|
-
automatic payment retry. Use the adapter below at that boundary:
|
|
263
|
-
|
|
264
|
-
```ts
|
|
265
|
-
import { createTwzrdCloudflareX402Approval } from "twzrd-x402-gate";
|
|
266
|
-
|
|
267
|
-
const approvePayment = createTwzrdCloudflareX402Approval({
|
|
268
|
-
// Base/EVM has no TWZRD behavioral reputation yet. Refuse it rather than
|
|
269
|
-
// presenting a policy allow as a trust verdict.
|
|
270
|
-
unsupportedNetworkMode: "strict",
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
await this.x402Client.callTool(approvePayment, {
|
|
274
|
-
name: "paid_tool",
|
|
275
|
-
arguments: {},
|
|
276
|
-
});
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
`observe` is available for an agent that intentionally permits unscored Base
|
|
280
|
-
payments, but it returns policy allow with `decision=unknown`; it is never a
|
|
281
|
-
TWZRD reputation approval. This adapter protects the Cloudflare x402 path only.
|
|
282
|
-
MPP is a separate protocol and belongs on its own `onChallenge` /
|
|
283
|
-
`onPaymentRequired` control path.
|
|
284
|
-
|
|
285
|
-
### Cloudflare Worker / Base x402 (edge-safe preflight)
|
|
286
|
-
|
|
287
|
-
For a Worker, import the dedicated subpath rather than the package root. It has
|
|
288
|
-
no Node-native imports and sends the exact Base `payTo` plus `chain_id: 8453` to
|
|
289
|
-
`/v1/intel/preflight` before a Viem account signs:
|
|
290
|
-
|
|
291
|
-
```ts
|
|
292
|
-
import { withTwzrdBasePreflight } from "twzrd-x402-gate/cloudflare-base";
|
|
293
|
-
|
|
294
|
-
const signature = await withTwzrdBasePreflight(
|
|
295
|
-
paymentRequirements, // accepts: [{ network: "eip155:8453", payTo: "0x..." }]
|
|
296
|
-
{ intelBase: "https://intel.twzrd.xyz" },
|
|
297
|
-
() => account.signTypedData(eip3009Authorization),
|
|
298
|
-
);
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
`block` throws `TwzrdBasePaymentBlockedError` and never invokes the signing
|
|
302
|
-
callback. `allow` and `warn` both proceed; enforce any additional amount or
|
|
303
|
-
mandate policy in the caller. Base is not presented as reputation-scored.
|
|
304
|
-
Checksummed and lowercase EVM addresses are accepted unchanged. The fixture in
|
|
305
|
-
[`test/cloudflare-base-edge.test.ts`](./test/cloudflare-base-edge.test.ts) proves
|
|
306
|
-
`block → zero signTypedData calls` and the compiled subpath is checked for Node
|
|
307
|
-
runtime leaks.
|
|
308
|
-
|
|
309
213
|
### Raw-fetch composition (injectible pay client only)
|
|
310
214
|
|
|
311
215
|
```typescript
|
|
312
216
|
import { installTwzrdAutoGate } from "twzrd-x402-gate";
|
|
313
|
-
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
217
|
+
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
314
218
|
|
|
315
219
|
// Guard RAW fetch, then hand to a client that still surfaces 402 to the guard layer
|
|
316
220
|
// — OR installTwzrdAutoGate(x402Client) (canonical) / installTwzrdX402ClientHook alias.
|
|
@@ -353,13 +257,11 @@ Dogfood (one public live proof path):
|
|
|
353
257
|
## Install
|
|
354
258
|
|
|
355
259
|
```bash
|
|
356
|
-
npm install twzrd-x402-gate@0.
|
|
260
|
+
npm install twzrd-x402-gate@0.8.18
|
|
357
261
|
```
|
|
358
262
|
|
|
359
|
-
|
|
360
|
-
`
|
|
361
|
-
may be one patch ahead until that release is on npm. Confirm with
|
|
362
|
-
`npm view twzrd-x402-gate version`.
|
|
263
|
+
Do not hardcode a version in this doc — every past pin here (**0.5.4**, **0.7.1**, **0.8.5**,
|
|
264
|
+
**0.8.6**) has gone stale. Check `npm view twzrd-x402-gate version` if in doubt.
|
|
363
265
|
|
|
364
266
|
Optional settle guard (resource-server **payer** policy): see **Seller settle guard
|
|
365
267
|
(`onBeforeSettle`) — optional 0.8.1** above. Do not confuse with facilitator
|
|
@@ -453,16 +355,15 @@ installTwzrdX402ClientHook(client, {
|
|
|
453
355
|
- Hook binding test:
|
|
454
356
|
[`test/intent-binding.test.ts`](./test/intent-binding.test.ts).
|
|
455
357
|
|
|
456
|
-
### On MPP (Machine Payments Protocol) — Solana
|
|
358
|
+
### On MPP (Machine Payments Protocol) — Solana charge only
|
|
457
359
|
|
|
458
|
-
`createTwzrdMppOnChallenge` guards `Mppx.create({ onChallenge })`.
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
(`allowUnevaluated: true` is an explicit ungated opt-out).
|
|
360
|
+
`createTwzrdMppOnChallenge` guards `Mppx.create({ onChallenge })`. The mppx
|
|
361
|
+
Solana method signs AND broadcasts the transaction inside `createCredential()`,
|
|
362
|
+
so `onChallenge` is the last deterministic checkpoint before money moves - and
|
|
363
|
+
mppx re-throws `onChallenge` errors, so a TWZRD block is an exception that means
|
|
364
|
+
**`createCredential()` never runs and nothing signs**. On allow, the guard
|
|
365
|
+
creates the credential for the exact challenge it evaluated; non-`solana/charge`
|
|
366
|
+
challenges fail closed (`allowUnevaluated: true` to opt out).
|
|
466
367
|
|
|
467
368
|
```typescript
|
|
468
369
|
import { Mppx } from "mppx/client";
|
|
@@ -478,30 +379,6 @@ const mppx = Mppx.create({
|
|
|
478
379
|
});
|
|
479
380
|
```
|
|
480
381
|
|
|
481
|
-
For Base, use mppx's EVM client with explicit local spend policy:
|
|
482
|
-
|
|
483
|
-
```typescript
|
|
484
|
-
import { Mppx } from "mppx/client";
|
|
485
|
-
import { evm } from "mppx/evm/client";
|
|
486
|
-
import { createTwzrdMppOnChallenge, createLocalDecisionSigner } from "twzrd-x402-gate";
|
|
487
|
-
|
|
488
|
-
const mppx = Mppx.create({
|
|
489
|
-
methods: [evm({ account: wallet })],
|
|
490
|
-
onChallenge: createTwzrdMppOnChallenge({
|
|
491
|
-
signer: createLocalDecisionSigner(),
|
|
492
|
-
policy: {
|
|
493
|
-
allowedNetworks: ["eip155:8453"],
|
|
494
|
-
allowedAssets: ["0x833589fCD6EDb6E08f4c7C32D4f71b54bdA02913"],
|
|
495
|
-
maxAmountUsd: "1.00",
|
|
496
|
-
},
|
|
497
|
-
}),
|
|
498
|
-
});
|
|
499
|
-
```
|
|
500
|
-
|
|
501
|
-
Base is **not reputation-scored**. The EVM path provides an actual pre-credential
|
|
502
|
-
local control point for Base USDC; it does not call a Solana-derived score or
|
|
503
|
-
present a local policy allow as a TWZRD trust verdict.
|
|
504
|
-
|
|
505
382
|
**Scope limit (honest):** the guard is authoritative only when no
|
|
506
383
|
`onChallengeReceived` event handler supplies a credential. mppx resolves
|
|
507
384
|
`eventCredential ?? onChallenge(...)`, so an event handler returning a credential
|
|
@@ -517,8 +394,6 @@ fails closed rather than approve a payment it cannot bind:
|
|
|
517
394
|
| Non-USD-pegged asset | `UNPRICED_ASSET` | Policy ceilings are USD; the wire amount is base-unit tokens. Pricing SOL would store `asset: solana:native` beside a **dollar** `amount` and lose the token quantity actually transferred. (A 1.5 SOL charge of `1500000000` at 9 decimals would otherwise evaluate as "$1.50" and sail under a $5 ceiling while moving ~$270.) USDC/USDT only until an intent version carries token amount + quote. |
|
|
518
395
|
| Unknown cluster | `UNKNOWN_CLUSTER` | mppx-solana's `resolveEndpoint` returns an unrecognized `cluster` **verbatim as the RPC endpoint URL**, and a network string containing "solana" is otherwise scored as mainnet - so `solana:https://seller-rpc.example` would inherit mainnet reputation for a chain never observed. Known cluster names only. |
|
|
519
396
|
| Misdeclared decimals | `MALFORMED_CHALLENGE` | A known stablecoin declaring the wrong decimals is a discount attempt, not a rounding error. |
|
|
520
|
-
| Non-Base EVM chain | `UNSUPPORTED_EVM_NETWORK` | EVM MPP is narrow: Base mainnet only. A testnet or another EVM network cannot inherit a Base USDC valuation. |
|
|
521
|
-
| EVM split recipients | `MULTI_LEG_CHARGE` | mppx EVM permits `splits`; each is an additional recipient. PaymentIntent v1 binds one amount to one payTo, so the guard refuses rather than approve transfers it cannot represent. |
|
|
522
397
|
|
|
523
398
|
The intent binds a **digest of the entire normalized challenge**, not just
|
|
524
399
|
`realm:id` - swapping `recipient` or `amount` under the same challenge id changes
|
|
@@ -571,10 +446,8 @@ Canonical entry point (design: `docs/strategy/install-autogate-design.md`). One
|
|
|
571
446
|
| Call | Adapter |
|
|
572
447
|
|------|---------|
|
|
573
448
|
| `installTwzrdAutoGate(payWrap, opts?)` | Fetch: guard raw fetch → pay client |
|
|
574
|
-
| `installTwzrdAutoGate(x402Client, opts?)` | Official
|
|
575
|
-
| `installTwzrdAutoGate("x402-solana", opts?)` | PayAI stock client `beforePayment` (2.1.0+) |
|
|
449
|
+
| `installTwzrdAutoGate(x402Client, opts?)` | Official x402 `onBeforePaymentCreation` |
|
|
576
450
|
| `installTwzrdAutoGate("mpp", opts)` | MPP `onChallenge` (returns handler) |
|
|
577
|
-
| `createTwzrdBeforePaymentHook(opts?)` | Same as `"x402-solana"` — pass to `createX402Client` |
|
|
578
451
|
|
|
579
452
|
Aliases: `installTwzrdX402ClientHook`, `createTwzrdMppOnChallenge` remain; docs prefer AutoGate.
|
|
580
453
|
Kill switch: `TWZRD_GATE_ENABLED=false` or `TWZRD_AUTO_GATE=0`. Uninstall x402 installs with `uninstallTwzrdAutoGate(client)`.
|
|
@@ -587,7 +460,7 @@ ever gets a chance to sign.
|
|
|
587
460
|
|
|
588
461
|
```typescript
|
|
589
462
|
import { installTwzrdAutoGate } from "twzrd-x402-gate";
|
|
590
|
-
import { wrapFetchWithPayment } from "@x402/
|
|
463
|
+
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
591
464
|
|
|
592
465
|
const payingFetch = installTwzrdAutoGate((guarded) => wrapFetchWithPayment(guarded, buyerWallet));
|
|
593
466
|
|
|
@@ -638,7 +511,7 @@ manage the raw/paying composition yourself:
|
|
|
638
511
|
|
|
639
512
|
```typescript
|
|
640
513
|
import { withTwzrdGuard } from "twzrd-x402-gate";
|
|
641
|
-
import { wrapFetchWithPayment } from "@x402/
|
|
514
|
+
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
642
515
|
|
|
643
516
|
const raw = globalThis.fetch; // MUST still surface HTTP 402
|
|
644
517
|
const guarded = withTwzrdGuard(raw); // guard sits upstream
|
|
@@ -673,49 +546,15 @@ const safeFetch = withTwzrdGuard(x402Fetch, {
|
|
|
673
546
|
});
|
|
674
547
|
```
|
|
675
548
|
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
stays free** (abort on `block` only — we do not tax their rail).
|
|
680
|
-
|
|
681
|
-
On the **buyer** install, if you pass `x402Fetch` (or use
|
|
682
|
-
`installTwzrdAutoGate(payWrap)`, which auto-wires `payWrap(raw)`), Path A
|
|
683
|
-
defaults on:
|
|
684
|
-
|
|
685
|
-
| Free decision | Resource price | What fires |
|
|
686
|
-
|---------------|----------------|------------|
|
|
687
|
-
| `block` | any | free refuse |
|
|
688
|
-
| `warn` | ≥ $2.50 | $0.05 V6 (`requireReceipt`) |
|
|
689
|
-
| `warn` | < $2.50 | $0.001 quick re-decide (`escalateOnWarn`) |
|
|
690
|
-
| `allow` | > $2.50 | $0.05 V6 |
|
|
691
|
-
| `allow` | ≤ $2.50 | free proceed |
|
|
692
|
-
|
|
693
|
-
```typescript
|
|
694
|
-
import { wrapFetchWithPayment } from "@x402/svm";
|
|
695
|
-
import { createTwzrdBeforePaymentHook } from "twzrd-x402-gate";
|
|
696
|
-
|
|
697
|
-
const x402Fetch = wrapFetchWithPayment(fetch, buyerWallet);
|
|
698
|
-
const client = createX402Client({
|
|
699
|
-
wallet: buyerWallet,
|
|
700
|
-
network: "solana",
|
|
701
|
-
beforePayment: createTwzrdBeforePaymentHook({
|
|
702
|
-
refuseWashFlagged: true,
|
|
703
|
-
x402Fetch, // turns Path A defaults on
|
|
704
|
-
}),
|
|
705
|
-
});
|
|
706
|
-
```
|
|
707
|
-
|
|
708
|
-
Opt out: `requireReceipt: false` and/or `escalateOnWarn: false`.
|
|
709
|
-
Refuse-only seats (no `x402Fetch`) stay free.
|
|
710
|
-
|
|
711
|
-
`evaluate_x402_resource` itself stays opt-in. `autoReceipt: true` still buys
|
|
712
|
-
$0.05 on every non-block (broader than the default ladder).
|
|
549
|
+
`autoReceipt` is **off by default** — it spends the **buyer's** USDC, so you opt in. When on,
|
|
550
|
+
every warn/allow verdict settles $0.05 USDC to TWZRD and returns a signed V6 trust credential
|
|
551
|
+
for the counterparty before you pay the resource.
|
|
713
552
|
|
|
714
553
|
**`x402Fetch` is yours to supply** (this package is dependency-free). Wire the proven
|
|
715
554
|
`@x402/svm` sponsored-feePayer client — the same one `twzrd-mcp-server` uses:
|
|
716
555
|
|
|
717
556
|
```typescript
|
|
718
|
-
import { wrapFetchWithPayment } from "@x402/
|
|
557
|
+
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
719
558
|
const x402Fetch = wrapFetchWithPayment(fetch, buyerWallet); // settles 402 challenges
|
|
720
559
|
```
|
|
721
560
|
|
|
@@ -907,31 +746,17 @@ const gatedFetch = wrapFetchWithTwzrdGate(fetch, resolveConfig());
|
|
|
907
746
|
|
|
908
747
|
A payment is **blocked** when:
|
|
909
748
|
1. `decision ∈ blockDecisions` (default: `["block"]`)
|
|
910
|
-
2. `trust_score < preflightMinScore` (default: `40`)
|
|
911
|
-
`trust_score` is scored `0` (`policy.ts`: `card.trust_score ?? 0`), so a
|
|
912
|
-
missing score blocks under the default floor
|
|
749
|
+
2. `trust_score < preflightMinScore` (default: `40`)
|
|
913
750
|
3. `can_spend === false` — **only** when `gateOnCanSpend: true` (default `false`, opt-in)
|
|
914
|
-
4. `merchant_card.wash_flagged === true` — **on by default**
|
|
915
|
-
(`refuseWashFlagged`, `TWZRD_REFUSE_WASH_FLAGGED`); forces `verdict: "block"`
|
|
916
|
-
with `reason: twzrd_wash_flagged`. Only tightens, and fails **open** when the
|
|
917
|
-
card is unreachable or `wash_flagged` is `null` (never evaluated ≠ clean).
|
|
918
|
-
Soft-cap instead of hard refuse with `washMaxUsdc` / `TWZRD_WASH_MAX_USDC`.
|
|
919
751
|
|
|
920
752
|
`warn` is allowed unless overridden. Preflight network failure **fails closed** by default (a preflight outage blocks the payment, so an intel hiccup never silently approves a spend); set `failOpen: true` / `TWZRD_FAIL_OPEN=true` to opt into legacy allow-on-outage.
|
|
921
753
|
|
|
922
754
|
A 402 whose payment requirements yield **no identifiable seller wallet** (missing/empty `payTo`, or an unparseable `accepts[]`) is a different case from "unknown seller" — it always **blocks** with `reason: twzrd_unidentifiable_payment_recipient`, without ever calling the preflight network. This is unconditional (not affected by `failOpen`): `failOpen` governs what happens when the TWZRD *service* is unreachable, not what happens when the caller can't say who they're paying.
|
|
923
755
|
|
|
924
756
|
> **`can_spend` note:** the free preflight returns `can_spend=false` for most sellers
|
|
925
|
-
> not yet in the TWZRD corpus, including legitimate ones.
|
|
926
|
-
>
|
|
927
|
-
>
|
|
928
|
-
>
|
|
929
|
-
> This is **not** a blanket "unknown sellers are allowed by default". Conditions 1,
|
|
930
|
-
> 2 and 4 above are all active by default, and condition 2 is the one that catches
|
|
931
|
-
> unknown sellers: a card carrying no `trust_score` evaluates as `0` and blocks
|
|
932
|
-
> under the default `preflightMinScore: 40` with `twzrd_score_0_below_40`. To
|
|
933
|
-
> actually let unscored sellers through, lower or disable `preflightMinScore` —
|
|
934
|
-
> setting `gateOnCanSpend` does not govern it.
|
|
757
|
+
> not yet in the TWZRD corpus, including legitimate ones. The default is decision-only
|
|
758
|
+
> gating so unknown sellers on platforms like Agentic.Market are not blocked by default.
|
|
759
|
+
> Set `gateOnCanSpend: true` for strict mode.
|
|
935
760
|
|
|
936
761
|
## Config
|
|
937
762
|
|
|
@@ -942,24 +767,11 @@ A 402 whose payment requirements yield **no identifiable seller wallet** (missin
|
|
|
942
767
|
| `blockDecisions` | `TWZRD_BLOCK_DECISIONS` | `block` | Decisions that throw |
|
|
943
768
|
| `failOpen` | `TWZRD_FAIL_OPEN` | `false` | `true` opts into legacy allow-on-outage; default blocks (fail-closed) |
|
|
944
769
|
| `gateOnCanSpend` | `TWZRD_GATE_ON_CAN_SPEND` | `false` | Also block when `can_spend=false` |
|
|
945
|
-
| `refuseWashFlagged` | `TWZRD_REFUSE_WASH_FLAGGED` | **`true`** | Refuse when `merchant_card.wash_flagged === true` (Policy 4). Set `false` / `0` to opt out |
|
|
946
|
-
| `washMaxUsdc` | `TWZRD_WASH_MAX_USDC` | — | Soft cap instead of hard refuse on wash: allow up to this USDC amount |
|
|
947
|
-
| `unsupportedNetworkMode` | `TWZRD_UNSUPPORTED_NETWORK_MODE` | `observe` | Behavior on a non-Solana / unrecognized network |
|
|
948
|
-
| `fetch` | — | global `fetch` | Injected fetch used for preflight + merchant card (testing / custom agents) |
|
|
949
|
-
| `onWarnUpsell` | — | — | Callback fired on a `warn` verdict (Path A upsell hook) |
|
|
950
|
-
| `attribution` | `TWZRD_ATTRIBUTION_INTEGRATION` + `TWZRD_ATTRIBUTION_RUN_ID` | — | Opt-in run attribution (see below) |
|
|
951
|
-
|
|
952
|
-
The four options below are **not** `TwzrdGateConfig` fields — they belong to
|
|
953
|
-
`TwzrdGuardOptions` / `InstallAutoGateOptions` (`withTwzrdGuard` /
|
|
954
|
-
`installTwzrdAutoGate`). Passing them to `createTwzrdGate({...})` is a type error
|
|
955
|
-
and is silently dropped at runtime:
|
|
956
|
-
|
|
957
|
-
| Option | Env | Default | Description |
|
|
958
|
-
|---|---|---|---|
|
|
959
770
|
| `autoReceipt` | — | `false` | Auto-buy $0.05 TWZRD receipt on warn/allow |
|
|
960
771
|
| `x402Fetch` | — | — | x402-capable fetch for `autoReceipt` |
|
|
961
772
|
| `onReceipt` | — | — | Callback after receipt is captured |
|
|
962
773
|
| `disabled` (`installTwzrdAutoGate` only) | `TWZRD_AUTO_GATE=0`/`false` | `false` | Bypass the guard entirely — `payWrap` gets the raw, unguarded fetch |
|
|
774
|
+
| `attribution` | `TWZRD_ATTRIBUTION_INTEGRATION` + `TWZRD_ATTRIBUTION_RUN_ID` | — | Opt-in run attribution (see below) |
|
|
963
775
|
|
|
964
776
|
## Gate adoption proof (no-spend harness)
|
|
965
777
|
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export { classifyNetwork, decideUnsupportedNetwork, amountBucket, type NetworkCl
|
|
|
7
7
|
export type { TwzrdGateDecision } from "./types.js";
|
|
8
8
|
export { fetchMerchantCard, applyWashFlaggedPolicy, type TwzrdMerchantCard, type WashPolicyInput, type WashPolicyResult, } from "./merchant-card.js";
|
|
9
9
|
export { twzrdOnPaymentRequested } from "./mcp-hook.js";
|
|
10
|
-
export { createTwzrdCloudflareX402Approval, type CloudflareX402PaymentRequirements, } from "./cloudflare-x402.js";
|
|
11
10
|
export { wrapFetchWithTwzrdGate } from "./wrap-fetch.js";
|
|
12
11
|
export { evaluate_x402_resource, type EvaluateX402Options, type EvaluateX402Result, } from "./evaluate.js";
|
|
13
12
|
export { DEFAULT_REQUIRE_RECEIPT_MIN_SPEND_USDC, resolveRequireReceiptPolicy, shouldAttemptPathAReceipt, shouldRequirePathAReceipt, type RequireReceiptPolicy, type ResolvedRequireReceiptPolicy, } from "./receipt-policy.js";
|
|
@@ -17,8 +16,11 @@ export { installTwzrdAutoGate, uninstallTwzrdAutoGate, isTwzrdAutoGateDisabled,
|
|
|
17
16
|
export { TWZRD_TRUST_GATE_BLOCK_WASH, TWZRD_TRUST_GATE_BLOCK_CAN_SPEND, TWZRD_TRUST_GATE_BLOCK_DECISION, TWZRD_TRUST_GATE_BLOCK_BUDGET, toTrustGateBlockReason, } from "./trust-gate-reason.js";
|
|
18
17
|
export { attachBlockOutcomeAttestation, AUTOGATE_BLOCK_PROOF_SCHEMA, AUTOGATE_BLOCK_PROOF_SCHEMA_V1_1, AUTOGATE_BLOCK_PROOF_SCHEMA_V1_2, buildAutogateBlockProof, resolveInstalledPackageVersion, type AutogateBlockProof, type BuildAutogateBlockProofInput, type ExecutionMode, } from "./block-proof.js";
|
|
19
18
|
export { safeFetch, runAgentcashFetch, main as safeFetchMain, type SafeFetchOptions, type SafeFetchResult, } from "./safe-fetch.js";
|
|
20
|
-
export { installTwzrdX402ClientHook, twzrdBeforePaymentCreation, evaluateBeforePaymentCreation, createTwzrdBeforePaymentHook,
|
|
21
|
-
export {
|
|
19
|
+
export { installTwzrdX402ClientHook, twzrdBeforePaymentCreation, evaluateBeforePaymentCreation, createTwzrdBeforePaymentHook, mapX402SolanaRequirements, flattenDeclaredResource, resourceUrlFromPaymentRequired, type X402ClientLike, type X402SelectedRequirements, type X402DeclaredResource, type BeforePaymentCreationContext, type BeforePaymentCreationResult, type InstallX402ClientHookOptions, type X402PaymentControlOptions, type X402SolanaBeforePaymentContext, } from "./x402-client-hook.js";
|
|
20
|
+
export { RESOURCE_BIND_DOMAIN, RESOURCE_BIND_EXTRA_KEY, RESOURCE_BIND_MEMO_PREFIX, RESOURCE_BIND_MEMO_MAX, ZERO_BODY_HASH, canonicalResourceUrl, resourceBindLeafHash, networksEquivalent, rawReqFromPaymentRequired, rememberRawInvoice, wrapFetchRememberInvoice, resourceBindMemo, memoContainsResourceBind, stampResourceBind, evaluateResourceBind, type BindStrength, type ResourceBindReq, type ResourceBindDecision, } from "./resource-bind.js";
|
|
21
|
+
export { extractSvmMemoFromTransaction, extractSvmTransferLegs, evaluateResourceBindFromSvmTx, evaluateResourceBindLegsFromSvmTx, MEMO_PROGRAM_ADDRESS as RESOURCE_BIND_MEMO_PROGRAM, type ResourceBindLeafFields, type SvmTransferLegs, } from "./resource-bind-tx.js";
|
|
22
|
+
export { twzrd, spendControlSafeFetch, type SpendControlOptions, type SpendControlResult, } from "./spend-control.js";
|
|
23
|
+
export { createFileSpendLedger } from "./spend-ledger-file.js";
|
|
22
24
|
export { runGateAdoptionProof, main as adoptionProofMain, ADOPTION_TRANSCRIPT_SCHEMA, ADOPTION_PROOF_SELLER, ADOPTION_PROOF_NETWORK, ADOPTION_PROOF_RESOURCE, type GateAdoptionTranscript, type GateAdoptionStep, type GateAdoptionAssertions, type GateAdoptionLineage, type RunGateAdoptionProofOptions, } from "./adoption-proof.js";
|
|
23
25
|
export { quickCheck, QUICK_PRICE_USDC, type QuickCheckResult, type QuickCheckOptions, type TwzrdTier, } from "./quick.js";
|
|
24
26
|
export { createSponsoredX402Fetch, type SponsorSettle, type SponsoredX402Options, } from "./sponsored.js";
|
|
@@ -28,7 +30,7 @@ export { assertIntentApproved, createDecisionRegistry, createLocalDecisionSigner
|
|
|
28
30
|
export { buildBlockedNeverSignedAttestation, buildOutcomeAttestation, computeDecisionOutcomeLeafV1, DECISION_OUTCOME_V1_DOMAIN, verifyOutcomeAttestationSignature, type DecisionOutcomeAttestation, type DecisionOutcomeFields, type OutcomeKind, type OutcomeVerdict, } from "./outcome-attestation.js";
|
|
29
31
|
export { createMemorySpendLedger, evaluateIntent, POLICY_VERSION, TWZRD_BUDGET_EXCEEDED, type CounterpartyIntelligence, type EvaluateIntentOptions, type IntelligenceProvider, type Mandate, type SpendLedger, type SpendPolicy, } from "./policy-runtime.js";
|
|
30
32
|
export { ap2CheckoutToIntent, x402RequirementsToIntent, type Ap2Cart, type Ap2UserMandate, type X402IntentContext, } from "./intent-adapters.js";
|
|
31
|
-
export { createTwzrdMppOnChallenge, mppChallengeToIntent, mppChallengeDigest,
|
|
33
|
+
export { createTwzrdMppOnChallenge, mppChallengeToIntent, mppChallengeDigest, NATIVE_SOL_CURRENCY, TwzrdMppBlockError, type MppChallenge, type MppIntentContext, type MppOnChallengeHelpers, type MppOnChallengeOptions, type MppSolanaChargeRequest, } from "./mpp-hook.js";
|
|
32
34
|
export { approvalToIntelligence, counterpartyKnownFromApproval, createTwzrdIntelligenceProvider, intentAmountToPriceUsd, type TwzrdIntelligenceOptions, } from "./intelligence.js";
|
|
33
35
|
export { createTwzrdSettleGuard, defaultExtractPayer, extractSvmPayerFromTransaction, twzrdPayerScreen, toPayaiVerifyResult, type SettleGuardContext, type SettleGuardAbort, type SettleGuardResult, type PayerScreen, type ScreenFn, type GetPayerFn, type SettleGuardOptions, } from "./seller-hook.js";
|
|
34
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,KAAK,uBAAuB,EAAE,MAAM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AK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,6BAA6B,EAC7B,+BAA+B,EAC/B,sBAAsB,EACtB,KAAK,wBAAwB,GAC9B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,8BAA8B,EAC9B,gBAAgB,EAChB,mBAAmB,EACnB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,kBAAkB,GACxB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export { payToFromRequirements, priceUsdcFromAmountMicro, pickRequirements, TWZR
|
|
|
10
10
|
export { classifyNetwork, decideUnsupportedNetwork, amountBucket, } from "./network.js";
|
|
11
11
|
export { fetchMerchantCard, applyWashFlaggedPolicy, } from "./merchant-card.js";
|
|
12
12
|
export { twzrdOnPaymentRequested } from "./mcp-hook.js";
|
|
13
|
-
export { createTwzrdCloudflareX402Approval, } from "./cloudflare-x402.js";
|
|
14
13
|
export { wrapFetchWithTwzrdGate } from "./wrap-fetch.js";
|
|
15
14
|
export { evaluate_x402_resource, } from "./evaluate.js";
|
|
16
15
|
export { DEFAULT_REQUIRE_RECEIPT_MIN_SPEND_USDC, resolveRequireReceiptPolicy, shouldAttemptPathAReceipt, shouldRequirePathAReceipt, } from "./receipt-policy.js";
|
|
@@ -20,8 +19,11 @@ export { installTwzrdAutoGate, uninstallTwzrdAutoGate, isTwzrdAutoGateDisabled,
|
|
|
20
19
|
export { TWZRD_TRUST_GATE_BLOCK_WASH, TWZRD_TRUST_GATE_BLOCK_CAN_SPEND, TWZRD_TRUST_GATE_BLOCK_DECISION, TWZRD_TRUST_GATE_BLOCK_BUDGET, toTrustGateBlockReason, } from "./trust-gate-reason.js";
|
|
21
20
|
export { attachBlockOutcomeAttestation, AUTOGATE_BLOCK_PROOF_SCHEMA, AUTOGATE_BLOCK_PROOF_SCHEMA_V1_1, AUTOGATE_BLOCK_PROOF_SCHEMA_V1_2, buildAutogateBlockProof, resolveInstalledPackageVersion, } from "./block-proof.js";
|
|
22
21
|
export { safeFetch, runAgentcashFetch, main as safeFetchMain, } from "./safe-fetch.js";
|
|
23
|
-
export { installTwzrdX402ClientHook, twzrdBeforePaymentCreation, evaluateBeforePaymentCreation, createTwzrdBeforePaymentHook,
|
|
24
|
-
export {
|
|
22
|
+
export { installTwzrdX402ClientHook, twzrdBeforePaymentCreation, evaluateBeforePaymentCreation, createTwzrdBeforePaymentHook, mapX402SolanaRequirements, flattenDeclaredResource, resourceUrlFromPaymentRequired, } from "./x402-client-hook.js";
|
|
23
|
+
export { RESOURCE_BIND_DOMAIN, RESOURCE_BIND_EXTRA_KEY, RESOURCE_BIND_MEMO_PREFIX, RESOURCE_BIND_MEMO_MAX, ZERO_BODY_HASH, canonicalResourceUrl, resourceBindLeafHash, networksEquivalent, rawReqFromPaymentRequired, rememberRawInvoice, wrapFetchRememberInvoice, resourceBindMemo, memoContainsResourceBind, stampResourceBind, evaluateResourceBind, } from "./resource-bind.js";
|
|
24
|
+
export { extractSvmMemoFromTransaction, extractSvmTransferLegs, evaluateResourceBindFromSvmTx, evaluateResourceBindLegsFromSvmTx, MEMO_PROGRAM_ADDRESS as RESOURCE_BIND_MEMO_PROGRAM, } from "./resource-bind-tx.js";
|
|
25
|
+
export { twzrd, spendControlSafeFetch, } from "./spend-control.js";
|
|
26
|
+
export { createFileSpendLedger } from "./spend-ledger-file.js";
|
|
25
27
|
export { runGateAdoptionProof, main as adoptionProofMain, ADOPTION_TRANSCRIPT_SCHEMA, ADOPTION_PROOF_SELLER, ADOPTION_PROOF_NETWORK, ADOPTION_PROOF_RESOURCE, } from "./adoption-proof.js";
|
|
26
28
|
export { quickCheck, QUICK_PRICE_USDC, } from "./quick.js";
|
|
27
29
|
export { createSponsoredX402Fetch, } from "./sponsored.js";
|
|
@@ -31,7 +33,7 @@ export { assertIntentApproved, createDecisionRegistry, createLocalDecisionSigner
|
|
|
31
33
|
export { buildBlockedNeverSignedAttestation, buildOutcomeAttestation, computeDecisionOutcomeLeafV1, DECISION_OUTCOME_V1_DOMAIN, verifyOutcomeAttestationSignature, } from "./outcome-attestation.js";
|
|
32
34
|
export { createMemorySpendLedger, evaluateIntent, POLICY_VERSION, TWZRD_BUDGET_EXCEEDED, } from "./policy-runtime.js";
|
|
33
35
|
export { ap2CheckoutToIntent, x402RequirementsToIntent, } from "./intent-adapters.js";
|
|
34
|
-
export { createTwzrdMppOnChallenge, mppChallengeToIntent, mppChallengeDigest,
|
|
36
|
+
export { createTwzrdMppOnChallenge, mppChallengeToIntent, mppChallengeDigest, NATIVE_SOL_CURRENCY, TwzrdMppBlockError, } from "./mpp-hook.js";
|
|
35
37
|
export { approvalToIntelligence, counterpartyKnownFromApproval, createTwzrdIntelligenceProvider, intentAmountToPriceUsd, } from "./intelligence.js";
|
|
36
38
|
// Optional resource-server settle guard (merchant policy on the payer).
|
|
37
39
|
// Core product remains the buyer gate. Attaches to onBeforeSettle; advisory + fail-open.
|