twzrd-x402-gate 0.3.0 → 0.5.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/README.md +203 -23
- package/bin/twzrd-safe-fetch.js +30 -0
- package/dist/auto-gate.d.ts +48 -0
- package/dist/auto-gate.d.ts.map +1 -0
- package/dist/auto-gate.js +34 -0
- package/dist/auto-gate.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -0
- package/dist/config.js.map +1 -1
- package/dist/evaluate.d.ts +4 -0
- package/dist/evaluate.d.ts.map +1 -1
- package/dist/evaluate.js +19 -3
- package/dist/evaluate.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp-hook.d.ts +22 -3
- package/dist/mcp-hook.d.ts.map +1 -1
- package/dist/mcp-hook.js +29 -6
- package/dist/mcp-hook.js.map +1 -1
- package/dist/merchant-card.d.ts +52 -0
- package/dist/merchant-card.d.ts.map +1 -0
- package/dist/merchant-card.js +69 -0
- package/dist/merchant-card.js.map +1 -0
- package/dist/network.d.ts +57 -0
- package/dist/network.d.ts.map +1 -0
- package/dist/network.js +137 -0
- package/dist/network.js.map +1 -0
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +99 -1
- package/dist/policy.js.map +1 -1
- package/dist/safe-fetch.d.ts +129 -0
- package/dist/safe-fetch.d.ts.map +1 -0
- package/dist/safe-fetch.js +471 -0
- package/dist/safe-fetch.js.map +1 -0
- package/dist/types.d.ts +64 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/with-guard.d.ts.map +1 -1
- package/dist/with-guard.js +6 -0
- package/dist/with-guard.js.map +1 -1
- package/dist/wrap-fetch.d.ts.map +1 -1
- package/dist/wrap-fetch.js +5 -2
- package/dist/wrap-fetch.js.map +1 -1
- package/dist/x402-client-hook.d.ts +87 -0
- package/dist/x402-client-hook.d.ts.map +1 -0
- package/dist/x402-client-hook.js +101 -0
- package/dist/x402-client-hook.js.map +1 -0
- package/package.json +34 -4
package/README.md
CHANGED
|
@@ -1,44 +1,204 @@
|
|
|
1
1
|
# twzrd-x402-gate
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
**TWZRD is the default `onBeforePaymentCreation` policy engine for official x402 clients.**
|
|
4
|
+
|
|
5
|
+
Agent-side firewall: after the client selects the exact payment requirement and **before**
|
|
6
|
+
payment payload creation / wallet signing — free preflight + merchant_card wash refuse.
|
|
7
|
+
Chain-neutral envelope; **Solana-deep** reputation only (Base/EVM = explicit `unknown`).
|
|
8
|
+
|
|
9
|
+
## Canonical integration (official x402 client)
|
|
5
10
|
|
|
6
11
|
```typescript
|
|
7
|
-
import {
|
|
12
|
+
import { x402Client } from "@x402/core/client";
|
|
13
|
+
import { wrapFetchWithPayment } from "@x402/fetch";
|
|
14
|
+
import { ExactSvmScheme } from "@x402/svm/exact/client";
|
|
15
|
+
import { installTwzrdX402ClientHook } from "twzrd-x402-gate";
|
|
16
|
+
|
|
17
|
+
const client = new x402Client();
|
|
18
|
+
client.register("solana:*", new ExactSvmScheme(svmSigner));
|
|
19
|
+
// Optional: client.register("eip155:*", new ExactEvmScheme(evmSigner));
|
|
8
20
|
|
|
9
|
-
|
|
10
|
-
//
|
|
21
|
+
installTwzrdX402ClientHook(client, { gateOnCanSpend: true });
|
|
22
|
+
// → onBeforePaymentCreation: scores selectedRequirements, abort if policy denies
|
|
23
|
+
|
|
24
|
+
const fetchWithPayment = wrapFetchWithPayment(fetch, client);
|
|
25
|
+
await fetchWithPayment("https://merchant.example/paid");
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```text
|
|
29
|
+
official x402 client receives 402
|
|
30
|
+
→ selects exact requirement
|
|
31
|
+
→ onBeforePaymentCreation
|
|
32
|
+
→ TWZRD (network + payTo + amount + resource)
|
|
33
|
+
→ local policy allow | warn | block
|
|
34
|
+
→ agent-owned wallet signs same requirement
|
|
11
35
|
```
|
|
12
36
|
|
|
37
|
+
No AgentCash. No marketplace. No second probe. No TWZRD custody.
|
|
38
|
+
|
|
39
|
+
### MCP (`@x402/mcp`)
|
|
40
|
+
|
|
41
|
+
Wire `twzrdOnPaymentRequested` / prefer `onPaymentRequired` + `onBeforePayment` per
|
|
42
|
+
[lifecycle hooks](https://docs.x402.org/advanced-concepts/lifecycle-hooks). Same policy core.
|
|
43
|
+
|
|
44
|
+
### Raw-fetch composition (injectible pay client only)
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { installTwzrdAutoGate } from "twzrd-x402-gate";
|
|
48
|
+
import { wrapFetchWithPayment } from "@x402/fetch"; // or @x402/svm helper
|
|
49
|
+
|
|
50
|
+
// Guard RAW fetch, then hand to a client that still surfaces 402 to the guard layer
|
|
51
|
+
// — OR prefer installTwzrdX402ClientHook on x402Client (above).
|
|
52
|
+
const payingFetch = installTwzrdAutoGate((guarded) =>
|
|
53
|
+
wrapFetchWithPayment(guarded, client),
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Buyer flow (trustless, fail-open) — locked sequence
|
|
58
|
+
|
|
59
|
+
Canonical path for every agent that spends USDC on Solana x402:
|
|
60
|
+
|
|
61
|
+
| Step | Call | Cost | What gates pay |
|
|
62
|
+
|------|------|------|----------------|
|
|
63
|
+
| 1 | `POST /v1/intel/preflight` | free | `decision=block` → refuse (`twzrd_decision_block`). Score floor / optional `can_spend` also deny. |
|
|
64
|
+
| 2 | `GET /v1/intel/merchant_card/{payTo}` | free | `wash_flagged: true` → refuse by default (`twzrd_wash_flagged`). **Only tightens** step 1. |
|
|
65
|
+
| 3 | Optional paid trust | $0.05 / $0.001 | On `warn` or high-value: `GET /v1/intel/trust/{payTo}` or `quickCheck`. Never required for the free refuse path. |
|
|
66
|
+
| 4 | Pay (or refuse) | resource price | Only if steps 1–2 approved (and any opt-in paid escalate did not block). |
|
|
67
|
+
|
|
68
|
+
**Fail-open (no invent):**
|
|
69
|
+
- Preflight HTTP/network error → default fail-closed in gate 0.2+ (`TWZRD_FAIL_OPEN=true` restores legacy allow-on-outage).
|
|
70
|
+
- Merchant card unreachable / non-2xx / missing `wash_flagged` → `washFlagged=null` → **do not refuse on wash** (preflight decision stands).
|
|
71
|
+
- Only a successful card with `wash_flagged: true` triggers wash refuse or soft cap.
|
|
72
|
+
|
|
73
|
+
**Wash policy (exact):**
|
|
74
|
+
- Prior preflight deny → unchanged (wash never loosens a block).
|
|
75
|
+
- `refuseWashFlagged=false` or wash not true → keep preflight approval.
|
|
76
|
+
- `wash_flagged=true` + no cap → `approved=false`, `reason=twzrd_wash_flagged`, `verdict=block`.
|
|
77
|
+
- `wash_flagged=true` + `washMaxUsdc` set + `priceUsdc <= cap` → allow, `washCapped=true`, reason `twzrd_wash_capped_{price}_le_{cap}`.
|
|
78
|
+
- `wash_flagged=true` + price above cap (or price unknown) → refuse with `twzrd_wash_flagged_above_cap_*`.
|
|
79
|
+
|
|
80
|
+
**Order note:** `onWarnUpsell` (points at paid `/trust`) fires on preflight `warn` **before** the merchant_card wash check. A wash-flagged seller that preflighted as `warn` may still get the upsell hook, then be refused on step 2.
|
|
81
|
+
|
|
82
|
+
Dogfood:
|
|
83
|
+
- Free only (wash refuse): `npm run wash-dogfood` → [`examples/wash-refuse-dogfood.ts`](./examples/wash-refuse-dogfood.ts)
|
|
84
|
+
- Official client + Path E hook (live Solana ≤$0.001): `npm run official-dogfood` → [`examples/official-x402-dogfood.ts`](./examples/official-x402-dogfood.ts). Needs `@x402/fetch` `@x402/svm` `@x402/core` `@solana/kit` `@scure/base` and a funded Solana key (`SVM_KEYPAIR_PATH` or `~/.agentcash/solana-wallet.json`). `--block` exercises hard `gateOnCanSpend` abort with $0 spend.
|
|
85
|
+
|
|
13
86
|
## Install
|
|
14
87
|
|
|
15
88
|
```bash
|
|
16
89
|
npm install twzrd-x402-gate
|
|
17
90
|
```
|
|
18
91
|
|
|
19
|
-
|
|
92
|
+
### Experimental CLI: `twzrd-safe-fetch` (AgentCash advisory pre-check)
|
|
93
|
+
|
|
94
|
+
> **Not a challenge-bound firewall.** Classification: `advisory_precheck`.
|
|
95
|
+
>
|
|
96
|
+
> AgentCash CLI internalizes 402 handling. This tool can only decide whether to
|
|
97
|
+
> **invoke** AgentCash after scoring a **probe** challenge. AgentCash then makes a
|
|
98
|
+
> **second** request and may sign a different recipient/network/amount (TOCTOU).
|
|
99
|
+
> JSON output always sets `requirementScoredMatchesRequirementSigned: false`.
|
|
100
|
+
>
|
|
101
|
+
> Secure integrations: `installTwzrdAutoGate` over **raw** fetch + injectible pay
|
|
102
|
+
> client, or `twzrdOnPaymentRequested` (MCP). Do **not** wrap AgentCash's paying
|
|
103
|
+
> fetch with `withTwzrdGuard`.
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Advisory: block AgentCash invocation when can_spend=false
|
|
107
|
+
npx twzrd-safe-fetch https://example/paid --gate-on-can-spend --payment-network solana --json
|
|
108
|
+
|
|
109
|
+
# Dry-run: preflight only, zero USDC
|
|
110
|
+
npx twzrd-safe-fetch 'https://intel.twzrd.xyz/v1/intel/quick/<pubkey>' --dry-run --json
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
probe request → TWZRD scores challenge A → (if allowed) AgentCash request → may sign challenge B
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- Exit `2` = policy blocked (AgentCash never started).
|
|
118
|
+
- Exit `0` = passthrough / dry-run allowed / AgentCash returned success (binding unproven).
|
|
119
|
+
- Base/EVM: explicit `decision=unknown` (see Networks).
|
|
120
|
+
|
|
121
|
+
Library: `import { safeFetch } from "twzrd-x402-gate/safe-fetch"`.
|
|
122
|
+
|
|
123
|
+
## Quickstart: `installTwzrdAutoGate` (default-on)
|
|
20
124
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
125
|
+
`installTwzrdAutoGate` is the one-liner form of "guard the raw fetch, then hand it to your
|
|
126
|
+
x402 client." It takes a `payWrap` function — whatever composes your paying client on top of
|
|
127
|
+
a fetch — and returns a fetch that's already gated: a blocked seller throws before your client
|
|
128
|
+
ever gets a chance to sign.
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { installTwzrdAutoGate } from "twzrd-x402-gate";
|
|
132
|
+
import { wrapFetchWithPayment } from "@x402/svm";
|
|
133
|
+
|
|
134
|
+
const payingFetch = installTwzrdAutoGate((guarded) => wrapFetchWithPayment(guarded, buyerWallet));
|
|
135
|
+
|
|
136
|
+
// Use payingFetch everywhere you'd call a paid resource:
|
|
137
|
+
const response = await payingFetch("https://api.exa.ai/search");
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`payWrap` receives the **guarded** fetch (the guard has already run by the time your client
|
|
141
|
+
sees a 402) — this is the only correct composition order. Building it the other way round
|
|
142
|
+
(guarding an already-paying fetch) is a no-op; see [Compatibility note](#compatibility-note).
|
|
143
|
+
Any x402 client that composes over an underlying `fetch` works the same way — swap in
|
|
144
|
+
whatever `payWrap` your client's API expects (agentcash, ClawRouter, PayAI, a custom
|
|
145
|
+
`@x402/svm` scheme, etc.).
|
|
146
|
+
|
|
147
|
+
Default **ON**. Disable with `TWZRD_AUTO_GATE=0` (env, deploy-time kill switch) or
|
|
148
|
+
`{ disabled: true }` (per-call, e.g. in tests) — the raw fetch is handed straight to
|
|
149
|
+
`payWrap`, unguarded.
|
|
150
|
+
|
|
151
|
+
What happens on every HTTP 402 the raw fetch returns:
|
|
152
|
+
1. Reads the Solana-network entry from `accepts[]` (falls back to first entry) to get the seller wallet.
|
|
153
|
+
2. Calls `POST /v1/intel/preflight` — free, no auth. `decision=block` (or score floor) throws — `payWrap`'s client never signs.
|
|
154
|
+
3. Calls `GET /v1/intel/merchant_card/{payTo}` — free, no auth. `wash_flagged: true` refuses by default (only tightens step 2; fail-open if the card is unreachable — no invent).
|
|
155
|
+
4. Otherwise returns the 402 to `payWrap`'s client, which pays normally.
|
|
156
|
+
|
|
157
|
+
Non-402 responses pass through unchanged.
|
|
158
|
+
|
|
159
|
+
### Networks (Solana-deep, chain-neutral envelope)
|
|
160
|
+
|
|
161
|
+
The gate **recognizes** multi-chain 402s but only **reputation-scores Solana mainnet**.
|
|
162
|
+
|
|
163
|
+
| Network | Reputation scored? | Default policy (`unsupportedNetworkMode`) |
|
|
164
|
+
|---------|-------------------|-------------------------------------------|
|
|
165
|
+
| Solana mainnet | Yes — free preflight + merchant_card | allow/block from intel |
|
|
166
|
+
| Base / other EVM (`eip155:*`) | **No** | `observe` (default): `decision=unknown`, `policyAction=allow`, telemetry `unsupported_network_seen` |
|
|
167
|
+
| Base / EVM in `strict` mode | No | `policyAction=block` before sign |
|
|
168
|
+
|
|
169
|
+
This is intentional: Base listing abundance ≠ Solana behavioral history. Unsupported is never
|
|
170
|
+
represented as a TWZRD trust `allow`. Set `TWZRD_UNSUPPORTED_NETWORK_MODE=strict` (or
|
|
171
|
+
`{ unsupportedNetworkMode: "strict" }`) to hard-block unscored networks.
|
|
172
|
+
|
|
173
|
+
Dual-chain accepts still prefer the Solana entry for scoring (same as payment clients that
|
|
174
|
+
prefer Solana when available).
|
|
175
|
+
|
|
176
|
+
### Lower-level: `withTwzrdGuard`
|
|
177
|
+
|
|
178
|
+
`installTwzrdAutoGate` is built on `withTwzrdGuard` — the fetch wrapper itself, if you want to
|
|
179
|
+
manage the raw/paying composition yourself:
|
|
24
180
|
|
|
25
181
|
```typescript
|
|
26
182
|
import { withTwzrdGuard } from "twzrd-x402-gate";
|
|
27
|
-
import {
|
|
183
|
+
import { wrapFetchWithPayment } from "@x402/svm";
|
|
28
184
|
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const safeFetch =
|
|
185
|
+
const raw = globalThis.fetch; // MUST still surface HTTP 402
|
|
186
|
+
const guarded = withTwzrdGuard(raw); // guard sits upstream
|
|
187
|
+
const safeFetch = wrapFetchWithPayment(guarded, buyerWallet);
|
|
32
188
|
|
|
33
|
-
// Use safeFetch everywhere you'd call a paid resource:
|
|
34
189
|
const response = await safeFetch("https://api.exa.ai/search");
|
|
35
190
|
```
|
|
36
191
|
|
|
37
192
|
What the guard does on HTTP 402:
|
|
38
193
|
1. Reads the Solana-network entry from `accepts[]` (falls back to first entry) to get the seller wallet.
|
|
39
|
-
2.
|
|
40
|
-
3. `
|
|
41
|
-
|
|
194
|
+
2. Free `POST /v1/intel/preflight` — `decision=block` / score floor deny.
|
|
195
|
+
3. Free `GET /v1/intel/merchant_card/{payTo}` — `wash_flagged:true` **refuses by default**
|
|
196
|
+
(`reason: twzrd_wash_flagged`). Fail-open if the card is unreachable (no invent).
|
|
197
|
+
4. If approved: returns the original 402 for the x402 client to pay.
|
|
198
|
+
|
|
199
|
+
Opt out of wash refuse: `withTwzrdGuard(fetch, { refuseWashFlagged: false })` or
|
|
200
|
+
`TWZRD_REFUSE_WASH_FLAGGED=0`. Soft cap instead of hard refuse: `washMaxUsdc` /
|
|
201
|
+
`TWZRD_WASH_MAX_USDC`.
|
|
42
202
|
|
|
43
203
|
Non-402 responses pass through unchanged.
|
|
44
204
|
|
|
@@ -190,14 +350,28 @@ if (!approved) abort(reason);
|
|
|
190
350
|
|
|
191
351
|
### `@x402/mcp` payment hook
|
|
192
352
|
|
|
193
|
-
|
|
194
|
-
|
|
353
|
+
The hook accepts the real `@x402/mcp` v2 `PaymentRequestedContext`
|
|
354
|
+
(`{ toolName, arguments, paymentRequired }`) — wire it directly:
|
|
195
355
|
|
|
196
|
-
|
|
197
|
-
|
|
356
|
+
```typescript
|
|
357
|
+
import { createx402MCPClient } from "@x402/mcp";
|
|
358
|
+
import { registerExactSvmScheme } from "@x402/svm/exact/client";
|
|
359
|
+
import { twzrdOnPaymentRequested } from "twzrd-x402-gate";
|
|
360
|
+
|
|
361
|
+
const client = createx402MCPClient({
|
|
362
|
+
name: "my-agent",
|
|
363
|
+
version: "1.0.0",
|
|
364
|
+
schemes: [/* e.g. registered SVM scheme */],
|
|
365
|
+
autoPayment: true,
|
|
366
|
+
onPaymentRequested: (ctx) => twzrdOnPaymentRequested(ctx), // false = deny before signing
|
|
198
367
|
});
|
|
199
368
|
```
|
|
200
369
|
|
|
370
|
+
The legacy flat shape (`{ accepts, context }`) is still accepted. Prior to
|
|
371
|
+
0.6.1, only the flat shape was read — wired into the real `@x402/mcp` runtime
|
|
372
|
+
the hook saw `accepts: undefined` and fail-closed-blocked every payment (safe,
|
|
373
|
+
but a 100% false-block).
|
|
374
|
+
|
|
201
375
|
### `wrapFetchWithTwzrdGate`
|
|
202
376
|
|
|
203
377
|
```typescript
|
|
@@ -219,6 +393,8 @@ A payment is **blocked** when:
|
|
|
219
393
|
|
|
220
394
|
`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.
|
|
221
395
|
|
|
396
|
+
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.
|
|
397
|
+
|
|
222
398
|
> **`can_spend` note:** the free preflight returns `can_spend=false` for most sellers
|
|
223
399
|
> not yet in the TWZRD corpus, including legitimate ones. The default is decision-only
|
|
224
400
|
> gating so unknown sellers on platforms like Agentic.Market are not blocked by default.
|
|
@@ -236,12 +412,16 @@ A payment is **blocked** when:
|
|
|
236
412
|
| `autoReceipt` | — | `false` | Auto-buy $0.05 TWZRD receipt on warn/allow |
|
|
237
413
|
| `x402Fetch` | — | — | x402-capable fetch for `autoReceipt` |
|
|
238
414
|
| `onReceipt` | — | — | Callback after receipt is captured |
|
|
415
|
+
| `disabled` (`installTwzrdAutoGate` only) | `TWZRD_AUTO_GATE=0`/`false` | `false` | Bypass the guard entirely — `payWrap` gets the raw, unguarded fetch |
|
|
239
416
|
|
|
240
417
|
## Compatibility note
|
|
241
418
|
|
|
242
419
|
**Proxied x402 clients** (AgentCash's `.fetch`, ClawRouter `:8402`): these clients handle
|
|
243
|
-
402 internally and return 200. The guard never sees a 402
|
|
244
|
-
|
|
420
|
+
402 internally and return 200. The guard never sees a 402 if it wraps the client's *output* —
|
|
421
|
+
it must wrap the client's *input*. `installTwzrdAutoGate` enforces this composition order by
|
|
422
|
+
construction: it guards the raw fetch first, then hands the guarded fetch to your `payWrap`.
|
|
423
|
+
If you're composing `withTwzrdGuard` manually instead, pass the raw (non-paying) fetch to
|
|
424
|
+
`withTwzrdGuard`, then wrap its output in your x402 client — never the reverse. Or call
|
|
245
425
|
`evaluate_x402_resource` explicitly before routing through the proxy.
|
|
246
426
|
|
|
247
427
|
## Why pre-spend, not post-pay
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Publishable bin for twzrd-safe-fetch.
|
|
4
|
+
* Prefers compiled dist; falls back to tsx source in dev checkouts.
|
|
5
|
+
*/
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { existsSync } from "node:fs";
|
|
8
|
+
import { dirname, join } from "node:path";
|
|
9
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
10
|
+
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
const root = join(__dirname, "..");
|
|
13
|
+
const dist = join(root, "dist", "safe-fetch.js");
|
|
14
|
+
const src = join(root, "src", "safe-fetch.ts");
|
|
15
|
+
|
|
16
|
+
if (existsSync(dist)) {
|
|
17
|
+
await import(pathToFileURL(dist).href);
|
|
18
|
+
} else if (existsSync(src)) {
|
|
19
|
+
const r = spawnSync(
|
|
20
|
+
"npx",
|
|
21
|
+
["--yes", "tsx", src, ...process.argv.slice(2)],
|
|
22
|
+
{ stdio: "inherit", cwd: root },
|
|
23
|
+
);
|
|
24
|
+
process.exit(r.status ?? 1);
|
|
25
|
+
} else {
|
|
26
|
+
console.error(
|
|
27
|
+
"twzrd-safe-fetch: missing dist/safe-fetch.js — run npm run build in twzrd-x402-gate",
|
|
28
|
+
);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type TwzrdGuardOptions } from "./with-guard.js";
|
|
2
|
+
/**
|
|
3
|
+
* Takes a guarded (pre-pay-checked) fetch and returns the fetch your agent actually
|
|
4
|
+
* calls — i.e. your x402 client composed on top of the guard (agentcash, ClawRouter,
|
|
5
|
+
* @x402/svm, PayAI, etc.).
|
|
6
|
+
*/
|
|
7
|
+
export type PayWrap = (guardedFetch: typeof fetch) => typeof fetch;
|
|
8
|
+
export type InstallAutoGateOptions = TwzrdGuardOptions & {
|
|
9
|
+
/**
|
|
10
|
+
* The RAW (non-paying) fetch to guard. This MUST be a fetch that still surfaces
|
|
11
|
+
* HTTP 402 — do not pass an already-paying client here (see compatibility note
|
|
12
|
+
* in README: proxied clients like AgentCash/.fetch resolve 402 internally and
|
|
13
|
+
* return 200, so the guard would never see the block condition).
|
|
14
|
+
* Default: globalThis.fetch.
|
|
15
|
+
*/
|
|
16
|
+
rawFetch?: typeof fetch;
|
|
17
|
+
/**
|
|
18
|
+
* Force-disable the gate (payWrap gets the raw fetch, unguarded). Mirrors
|
|
19
|
+
* TWZRD_AUTO_GATE=0 / "false". Prefer the env var for a deploy-time kill switch;
|
|
20
|
+
* use this for tests.
|
|
21
|
+
*/
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Default-on composition helper: guards the RAW fetch with the free TWZRD preflight,
|
|
26
|
+
* THEN hands the guarded fetch to your payment wrapper. This is the one-liner form of
|
|
27
|
+
* the two-step pattern documented in the README:
|
|
28
|
+
*
|
|
29
|
+
* const raw = globalThis.fetch;
|
|
30
|
+
* const gated = withTwzrdGuard(raw);
|
|
31
|
+
* const paying = payWrap(gated);
|
|
32
|
+
*
|
|
33
|
+
* Composing it this way by construction rules out the common mis-wiring of guarding
|
|
34
|
+
* an already-paying fetch (which returns 200 and never gives the guard a 402 to act on).
|
|
35
|
+
*
|
|
36
|
+
* Default ON — a blocked seller throws before payWrap's client ever signs. Opt out with
|
|
37
|
+
* TWZRD_AUTO_GATE=0 (env) or { disabled: true } (per-call), e.g. for a local dev harness
|
|
38
|
+
* that intentionally wants the unguarded fetch.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* import { installTwzrdAutoGate } from "twzrd-x402-gate";
|
|
42
|
+
* import { wrapFetchWithPayment } from "@x402/svm";
|
|
43
|
+
*
|
|
44
|
+
* const payingFetch = installTwzrdAutoGate((guarded) => wrapFetchWithPayment(guarded, buyerWallet));
|
|
45
|
+
* await payingFetch("https://api.exa.ai/search"); // blocked sellers throw before signing
|
|
46
|
+
*/
|
|
47
|
+
export declare function installTwzrdAutoGate(payWrap: PayWrap, options?: InstallAutoGateOptions): typeof fetch;
|
|
48
|
+
//# sourceMappingURL=auto-gate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-gate.d.ts","sourceRoot":"","sources":["../src/auto-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzE;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,YAAY,EAAE,OAAO,KAAK,KAAK,OAAO,KAAK,CAAC;AAEnE,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,GAAG;IACvD;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,KAAK,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,KAAK,CAQd"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { withTwzrdGuard } from "./with-guard.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default-on composition helper: guards the RAW fetch with the free TWZRD preflight,
|
|
4
|
+
* THEN hands the guarded fetch to your payment wrapper. This is the one-liner form of
|
|
5
|
+
* the two-step pattern documented in the README:
|
|
6
|
+
*
|
|
7
|
+
* const raw = globalThis.fetch;
|
|
8
|
+
* const gated = withTwzrdGuard(raw);
|
|
9
|
+
* const paying = payWrap(gated);
|
|
10
|
+
*
|
|
11
|
+
* Composing it this way by construction rules out the common mis-wiring of guarding
|
|
12
|
+
* an already-paying fetch (which returns 200 and never gives the guard a 402 to act on).
|
|
13
|
+
*
|
|
14
|
+
* Default ON — a blocked seller throws before payWrap's client ever signs. Opt out with
|
|
15
|
+
* TWZRD_AUTO_GATE=0 (env) or { disabled: true } (per-call), e.g. for a local dev harness
|
|
16
|
+
* that intentionally wants the unguarded fetch.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* import { installTwzrdAutoGate } from "twzrd-x402-gate";
|
|
20
|
+
* import { wrapFetchWithPayment } from "@x402/svm";
|
|
21
|
+
*
|
|
22
|
+
* const payingFetch = installTwzrdAutoGate((guarded) => wrapFetchWithPayment(guarded, buyerWallet));
|
|
23
|
+
* await payingFetch("https://api.exa.ai/search"); // blocked sellers throw before signing
|
|
24
|
+
*/
|
|
25
|
+
export function installTwzrdAutoGate(payWrap, options) {
|
|
26
|
+
const raw = options?.rawFetch ?? globalThis.fetch;
|
|
27
|
+
const envDisabled = process.env.TWZRD_AUTO_GATE === "0" || process.env.TWZRD_AUTO_GATE === "false";
|
|
28
|
+
const disabled = options?.disabled ?? envDisabled;
|
|
29
|
+
if (disabled)
|
|
30
|
+
return payWrap(raw);
|
|
31
|
+
const guarded = withTwzrdGuard(raw, options);
|
|
32
|
+
return payWrap(guarded);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=auto-gate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-gate.js","sourceRoot":"","sources":["../src/auto-gate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA0B,MAAM,iBAAiB,CAAC;AA0BzE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAgB,EAChB,OAAgC;IAEhC,MAAM,GAAG,GAAG,OAAO,EAAE,QAAQ,IAAI,UAAU,CAAC,KAAK,CAAC;IAClD,MAAM,WAAW,GACf,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,KAAK,OAAO,CAAC;IACjF,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,WAAW,CAAC;IAClD,IAAI,QAAQ;QAAE,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7C,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAC1B,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -5,6 +5,15 @@ export type ResolvedTwzrdGateConfig = {
|
|
|
5
5
|
blockDecisions: Set<string>;
|
|
6
6
|
failOpen: boolean;
|
|
7
7
|
gateOnCanSpend: boolean;
|
|
8
|
+
/** Default true: refuse when free merchant_card.wash_flagged */
|
|
9
|
+
refuseWashFlagged: boolean;
|
|
10
|
+
/** Soft cap USDC when wash_flagged; null = hard refuse */
|
|
11
|
+
washMaxUsdc: number | null;
|
|
12
|
+
/**
|
|
13
|
+
* Unscored-network policy (Base/EVM/…). Default observe.
|
|
14
|
+
* @see UnsupportedNetworkMode in network.ts
|
|
15
|
+
*/
|
|
16
|
+
unsupportedNetworkMode: "observe" | "strict";
|
|
8
17
|
fetch: typeof fetch;
|
|
9
18
|
onWarnUpsell?: (ctx: TwzrdUpsellContext) => void | Promise<void>;
|
|
10
19
|
};
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE,CAAC;AAYF,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,eAAe,GAAG,uBAAuB,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEtE,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,gEAAgE;IAChE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,0DAA0D;IAC1D,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B;;;OAGG;IACH,sBAAsB,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC7C,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,kBAAkB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE,CAAC;AAYF,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,eAAe,GAAG,uBAAuB,CA0ElF"}
|
package/dist/config.js
CHANGED
|
@@ -29,6 +29,25 @@ export function resolveConfig(overrides) {
|
|
|
29
29
|
const gateOnCanSpend = overrides?.gateOnCanSpend ??
|
|
30
30
|
(process.env.TWZRD_GATE_ON_CAN_SPEND === "true" ||
|
|
31
31
|
process.env.TWZRD_GATE_ON_CAN_SPEND === "1");
|
|
32
|
+
// Default true: free merchant_card.wash_flagged → refuse pay (trustless step 3).
|
|
33
|
+
// Opt out: refuseWashFlagged:false or TWZRD_REFUSE_WASH_FLAGGED=0|false.
|
|
34
|
+
const refuseWashEnv = process.env.TWZRD_REFUSE_WASH_FLAGGED;
|
|
35
|
+
const refuseWashFlagged = overrides?.refuseWashFlagged ??
|
|
36
|
+
!(refuseWashEnv === "0" || refuseWashEnv === "false");
|
|
37
|
+
let washMaxUsdc = null;
|
|
38
|
+
if (overrides?.washMaxUsdc != null && Number.isFinite(overrides.washMaxUsdc)) {
|
|
39
|
+
washMaxUsdc = overrides.washMaxUsdc;
|
|
40
|
+
}
|
|
41
|
+
else if (process.env.TWZRD_WASH_MAX_USDC != null && process.env.TWZRD_WASH_MAX_USDC !== "") {
|
|
42
|
+
const n = Number(process.env.TWZRD_WASH_MAX_USDC);
|
|
43
|
+
if (Number.isFinite(n) && n >= 0)
|
|
44
|
+
washMaxUsdc = n;
|
|
45
|
+
}
|
|
46
|
+
// Default observe: Base/EVM payments are allowed but marked decision=unknown
|
|
47
|
+
// (policy allow ≠ reputation allow). Strict blocks unscored networks before sign.
|
|
48
|
+
const envMode = (process.env.TWZRD_UNSUPPORTED_NETWORK_MODE ?? "").trim().toLowerCase();
|
|
49
|
+
const unsupportedNetworkMode = overrides?.unsupportedNetworkMode ??
|
|
50
|
+
(envMode === "strict" ? "strict" : "observe");
|
|
32
51
|
const fetchFn = overrides?.fetch ?? globalThis.fetch;
|
|
33
52
|
if (typeof fetchFn !== "function") {
|
|
34
53
|
throw new Error("[twzrd-x402-gate] fetch is not available; pass config.fetch");
|
|
@@ -39,6 +58,9 @@ export function resolveConfig(overrides) {
|
|
|
39
58
|
blockDecisions,
|
|
40
59
|
failOpen,
|
|
41
60
|
gateOnCanSpend,
|
|
61
|
+
refuseWashFlagged,
|
|
62
|
+
washMaxUsdc,
|
|
63
|
+
unsupportedNetworkMode,
|
|
42
64
|
fetch: fetchFn,
|
|
43
65
|
onWarnUpsell: overrides?.onWarnUpsell,
|
|
44
66
|
};
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAqBA,SAAS,mBAAmB,CAAC,GAAuB;IAClD,MAAM,MAAM,GAAG,GAAG,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC;IACtC,OAAO,IAAI,GAAG,CACZ,MAAM;SACH,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;SACpB,MAAM,CAAC,OAAO,CAAC,CACnB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,SAA2B;IACvD,MAAM,SAAS,GAAG,CAChB,SAAS,EAAE,SAAS;QACpB,OAAO,CAAC,GAAG,CAAC,gBAAgB;QAC5B,yBAAyB,CAC1B,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEtB,MAAM,MAAM,GACV,SAAS,EAAE,iBAAiB;QAC5B,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,IAAI,IAAI,CAAC,CAAC;IACxD,MAAM,iBAAiB,GAAG,CAAC,MAAM,CA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CAAC;QAC7E,WAAW,GAAG,SAAS,CAAC,WAAW,CAAC;IACtC,CAAC;SAAM,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,KAAK,EAAE,EAAE,CAAC;QAC7F,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;QAClD,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAAE,WAAW,GAAG,CAAC,CAAC;IACpD,CAAC;IAED,6EAA6E;IAC7E,kFAAkF;IAClF,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACxF,MAAM,sBAAsB,GAC1B,SAAS,EAAE,sBAAsB;QACjC,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEhD,MAAM,OAAO,GAAG,SAAS,EAAE,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC;IACrD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IAED,OAAO;QACL,SAAS;QACT,iBAAiB;QACjB,cAAc;QACd,QAAQ;QACR,cAAc;QACd,iBAAiB;QACjB,WAAW;QACX,sBAAsB;QACtB,KAAK,EAAE,OAAO;QACd,YAAY,EAAE,SAAS,EAAE,YAAY;KACtC,CAAC;AACJ,CAAC"}
|
package/dist/evaluate.d.ts
CHANGED
|
@@ -59,6 +59,10 @@ export type EvaluateX402Result = {
|
|
|
59
59
|
escalatedScore?: number | null;
|
|
60
60
|
/** the paid quick-tier label (Bronze/Silver/Gold/Platinum) from the escalation */
|
|
61
61
|
escalatedTier?: TwzrdTier | null;
|
|
62
|
+
network?: string;
|
|
63
|
+
networkSupported?: boolean;
|
|
64
|
+
reputationScored?: boolean;
|
|
65
|
+
policyAction?: "allow" | "block";
|
|
62
66
|
};
|
|
63
67
|
/**
|
|
64
68
|
* Evaluate an x402 resource before the buyer pays:
|
package/dist/evaluate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG;IAClD;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;IACzB;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/D;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE;QACf,iHAAiH;QACjH,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,qFAAqF;QACrF,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,EAAE,aAAa,GAAG,SAAS,CAAC;IACpC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,kBAAkB,CAAC;IACzB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,OAAO,C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UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,kBAAkB,CAAC;IACzB,iFAAiF;IACjF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,8FAA8F;IAC9F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6GAA6G;IAC7G,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kFAAkF;IAClF,aAAa,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,uBAAuB,EAC5C,IAAI,GAAE,mBAAwB,GAC7B,OAAO,CAAC,kBAAkB,CAAC,CAqI7B"}
|
package/dist/evaluate.js
CHANGED
|
@@ -24,6 +24,9 @@ export async function evaluate_x402_resource(resourceUrl, paymentRequirements, o
|
|
|
24
24
|
// Decision-only gate: unknown sellers score warn (~45), not block.
|
|
25
25
|
// Gating on can_spend would block every Agentic.Market seller not in corpus.
|
|
26
26
|
gateOnCanSpend: opts.gateOnCanSpend,
|
|
27
|
+
refuseWashFlagged: opts.refuseWashFlagged,
|
|
28
|
+
washMaxUsdc: opts.washMaxUsdc,
|
|
29
|
+
unsupportedNetworkMode: opts.unsupportedNetworkMode,
|
|
27
30
|
fetch: opts.fetch,
|
|
28
31
|
});
|
|
29
32
|
const { payTo, amountMicro, resource } = payToFromRequirements(paymentRequirements);
|
|
@@ -33,9 +36,18 @@ export async function evaluate_x402_resource(resourceUrl, paymentRequirements, o
|
|
|
33
36
|
payTo,
|
|
34
37
|
priceUsdc,
|
|
35
38
|
agentIntent: "evaluate_x402_resource",
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
// Evaluate the exact network on the requirement the pay client will use
|
|
40
|
+
// (pickRequirements prefers Solana when dual-listed).
|
|
41
|
+
chain: paymentRequirements.network,
|
|
42
|
+
},
|
|
43
|
+
// resolveConfig already embeds refuseWashFlagged / washMaxUsdc
|
|
44
|
+
config);
|
|
45
|
+
// Unscored networks: decision stays "unknown" — never map to reputation allow/warn/block.
|
|
46
|
+
const decision = (approval.verdict === "unknown"
|
|
47
|
+
? "unknown"
|
|
48
|
+
: (approval.card.decision ?? approval.verdict ?? "unknown"));
|
|
49
|
+
// Paid trust receipt is Solana-only product surface — omit for unscored nets.
|
|
50
|
+
const receiptUrl = payTo && approval.reputationScored === true
|
|
39
51
|
? `${config.intelBase}/v1/intel/trust/${encodeURIComponent(payTo)}`
|
|
40
52
|
: undefined;
|
|
41
53
|
const base = {
|
|
@@ -46,6 +58,10 @@ export async function evaluate_x402_resource(resourceUrl, paymentRequirements, o
|
|
|
46
58
|
card: approval.card,
|
|
47
59
|
failOpen: approval.failOpen,
|
|
48
60
|
receiptUrl,
|
|
61
|
+
network: approval.network,
|
|
62
|
+
networkSupported: approval.networkSupported,
|
|
63
|
+
reputationScored: approval.reputationScored,
|
|
64
|
+
policyAction: approval.policyAction,
|
|
49
65
|
};
|
|
50
66
|
// Autonomous risk-escalation: a *proceeding* `warn` (uncertain / unknown seller)
|
|
51
67
|
// is vetted by settling the cheap $0.001 quick tier and re-deciding on the paid
|
package/dist/evaluate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../src/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,UAAU,EAAkB,MAAM,YAAY,CAAC;AA0ExD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,WAAmB,EACnB,mBAA4C,EAC5C,OAA4B,EAAE;IAE9B,MAAM,MAAM,GAAG,aAAa,CAAC;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;QACzC,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,mEAAmE;QACnE,6EAA6E;QAC7E,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;QACzC,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;QACnD,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CAAC;IAEH,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,qBAAqB,CAAC,mBAAmB,CAAC,CAAC;IACpF,MAAM,S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CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,11 +2,17 @@ export { createTwzrdGate, defaultGate, type TwzrdGate } from "./gate.js";
|
|
|
2
2
|
export { resolveConfig, type ResolvedTwzrdGateConfig } from "./config.js";
|
|
3
3
|
export { evaluateReadinessCard, buildPreflightInput, twzrdPreflight, twzrdApprovePayment, type PolicyEvaluateInput, } from "./policy.js";
|
|
4
4
|
export { payToFromRequirements, priceUsdcFromAmountMicro, pickRequirements } from "./payto.js";
|
|
5
|
+
export { classifyNetwork, decideUnsupportedNetwork, amountBucket, type NetworkClass, type NetworkKind, type UnsupportedNetworkMode, type UnsupportedNetworkDecision, } from "./network.js";
|
|
6
|
+
export type { TwzrdGateDecision } from "./types.js";
|
|
7
|
+
export { fetchMerchantCard, applyWashFlaggedPolicy, type TwzrdMerchantCard, type WashPolicyInput, type WashPolicyResult, } from "./merchant-card.js";
|
|
5
8
|
export { twzrdOnPaymentRequested } from "./mcp-hook.js";
|
|
6
9
|
export { wrapFetchWithTwzrdGate } from "./wrap-fetch.js";
|
|
7
10
|
export { evaluate_x402_resource, type EvaluateX402Options, type EvaluateX402Result, } from "./evaluate.js";
|
|
8
11
|
export { withTwzrdGuard, type TwzrdGuardOptions } from "./with-guard.js";
|
|
12
|
+
export { installTwzrdAutoGate, type PayWrap, type InstallAutoGateOptions, } from "./auto-gate.js";
|
|
13
|
+
export { safeFetch, runAgentcashFetch, main as safeFetchMain, type SafeFetchOptions, type SafeFetchResult, } from "./safe-fetch.js";
|
|
14
|
+
export { installTwzrdX402ClientHook, twzrdBeforePaymentCreation, type X402ClientLike, type X402SelectedRequirements, type BeforePaymentCreationContext, type BeforePaymentCreationResult, type InstallX402ClientHookOptions, } from "./x402-client-hook.js";
|
|
9
15
|
export { quickCheck, QUICK_PRICE_USDC, type QuickCheckResult, type QuickCheckOptions, type TwzrdTier, } from "./quick.js";
|
|
10
16
|
export { createSponsoredX402Fetch, type SponsorSettle, type SponsoredX402Options, } from "./sponsored.js";
|
|
11
|
-
export type { TwzrdDecision, TwzrdReadinessCard, TwzrdPreflightInput, TwzrdGateConfig, TwzrdApproveContext, TwzrdApprovalResult, TwzrdUpsellContext, X402PaymentRequirements, X402PaymentRequiredBody, X402McpPaymentRequest, } from "./types.js";
|
|
17
|
+
export type { TwzrdDecision, TwzrdReadinessCard, TwzrdPreflightInput, TwzrdGateConfig, TwzrdApproveContext, TwzrdApprovalResult, TwzrdUpsellContext, X402PaymentRequirements, X402PaymentRequiredBody, X402McpPaymentRequest, X402McpPaymentRequestedContext, } from "./types.js";
|
|
12
18
|
//# 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,eAAe,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,sBAAsB,EACtB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,SAAS,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BAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,oBAAoB,EACpB,KAAK,OAAO,EACZ,KAAK,sBAAsB,GAC5B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,IAAI,IAAI,aAAa,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,KAAK,cAAc,EACnB,KAAK,wBAAwB,EAC7B,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,4BAA4B,GAClC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,SAAS,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,KAAK,aAAa,EAClB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,qBAAqB,EACrB,8BAA8B,GAC/B,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -6,10 +6,15 @@ export { createTwzrdGate, defaultGate } from "./gate.js";
|
|
|
6
6
|
export { resolveConfig } from "./config.js";
|
|
7
7
|
export { evaluateReadinessCard, buildPreflightInput, twzrdPreflight, twzrdApprovePayment, } from "./policy.js";
|
|
8
8
|
export { payToFromRequirements, priceUsdcFromAmountMicro, pickRequirements } from "./payto.js";
|
|
9
|
+
export { classifyNetwork, decideUnsupportedNetwork, amountBucket, } from "./network.js";
|
|
10
|
+
export { fetchMerchantCard, applyWashFlaggedPolicy, } from "./merchant-card.js";
|
|
9
11
|
export { twzrdOnPaymentRequested } from "./mcp-hook.js";
|
|
10
12
|
export { wrapFetchWithTwzrdGate } from "./wrap-fetch.js";
|
|
11
13
|
export { evaluate_x402_resource, } from "./evaluate.js";
|
|
12
14
|
export { withTwzrdGuard } from "./with-guard.js";
|
|
15
|
+
export { installTwzrdAutoGate, } from "./auto-gate.js";
|
|
16
|
+
export { safeFetch, runAgentcashFetch, main as safeFetchMain, } from "./safe-fetch.js";
|
|
17
|
+
export { installTwzrdX402ClientHook, twzrdBeforePaymentCreation, } from "./x402-client-hook.js";
|
|
13
18
|
export { quickCheck, QUICK_PRICE_USDC, } from "./quick.js";
|
|
14
19
|
export { createSponsoredX402Fetch, } from "./sponsored.js";
|
|
15
20
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,qFAAqF;AACrF,uFAAuF;AACvF,qFAAqF;AACrF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAkB,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,aAAa,EAAgC,MAAM,aAAa,CAAC;AAC1E,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,GAEpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,sBAAsB,GAGvB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAA0B,MAAM,iBAAiB,CAAC;AACzE,OAAO,EACL,UAAU,EACV,gBAAgB,GAIjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,GAGzB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.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