z-zero-mcp-server 1.10.4 β 1.11.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 +9 -9
- package/dist/base_backend.js +19 -2
- package/dist/failure_taxonomy.d.ts +13 -6
- package/dist/failure_taxonomy.js +74 -6
- package/dist/index.js +316 -234
- package/dist/lib/api-base.d.ts +4 -1
- package/dist/lib/api-base.js +48 -26
- package/dist/lib/domain-lock.js +59 -16
- package/dist/lib/extract-total-price.d.ts +23 -17
- package/dist/lib/extract-total-price.js +146 -139
- package/dist/lib/key-store.d.ts +25 -2
- package/dist/lib/key-store.js +175 -25
- package/dist/lib/url-guard.js +12 -1
- package/dist/playwright_bridge.d.ts +9 -1
- package/dist/playwright_bridge.js +355 -139
- package/dist/types.d.ts +1 -0
- package/dist/ucp_bridge.js +12 -0
- package/package.json +3 -2
- package/dist/lib/web3-detector.d.ts +0 -19
- package/dist/lib/web3-detector.js +0 -157
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ npx z-zero-mcp-server
|
|
|
14
14
|
|
|
15
15
|
**What makes it different:**
|
|
16
16
|
- π **Zero-trust by design** β the AI never sees PAN, CVV, or expiry. Card data exists only in RAM, injected via Playwright at the last step, then wiped.
|
|
17
|
-
- β½ **
|
|
17
|
+
- β½ **Funded in USDC on Base** β the agent's wallet holds USDC (gasless, sponsored by Coinbase Paymaster); every purchase is paid with a single-use card funded from it. Z-Zero never sends crypto to an address it reads off a web page.
|
|
18
18
|
- π³ **JIT single-use virtual cards** β amount-locked, 1-hour TTL, burned after a single use. Fiat fallback for the rest of the web.
|
|
19
19
|
- π§ **Smart Routing + checkout intelligence** β `get_merchant_hints` serves platform-specific checkout playbooks (Shopify, Etsy, WooCommerceβ¦).
|
|
20
20
|
- βοΈ **Linked purpose + outcome** β the server signs the criteria the agent records at issuance. Before checkout, `execute_payment` hands those criteria back and requires a second call with `go` or `pause`; a confirmed purchase seals the answer into the signed receipt. The record is inspectable without pretending the platform judged whether the agent told the truth.
|
|
@@ -71,8 +71,6 @@ npx z-zero-mcp-server
|
|
|
71
71
|
|
|
72
72
|
*The AI agent never touches card data β it only handles single-use tokens. Real card details are injected by Playwright at the last step and wiped from RAM.*
|
|
73
73
|
|
|
74
|
-
> **Crypto checkout branch:** when `auto_pay_checkout` detects a crypto-native checkout (EIP-681), it skips the card flow entirely and settles as a **gasless USDC transfer on Base** β see above. Off by default; enable with `Z_ZERO_ENABLE_WEB3_PAY=1`.
|
|
75
|
-
|
|
76
74
|
---
|
|
77
75
|
|
|
78
76
|
## Why Z-ZERO
|
|
@@ -115,14 +113,16 @@ Get your Passport Key at: **[z-zero.xyz/dashboard/agents](https://z-zero.xyz/das
|
|
|
115
113
|
|
|
116
114
|
---
|
|
117
115
|
|
|
118
|
-
## Security: rotate-on-connect (v1.5.0
|
|
116
|
+
## Security: rotate-on-connect (v1.5.0+; config keys too since v1.11.0)
|
|
119
117
|
|
|
120
|
-
The key you copy from the dashboard
|
|
121
|
-
The moment
|
|
118
|
+
The key you copy from the dashboard is only a **one-time bootstrap ticket** β whether you paste it into a chat (`set_api_key`) or your agent writes it into the MCP config as `Z_ZERO_API_KEY`.
|
|
119
|
+
The moment the MCP server first uses it, it silently swaps it for a fresh key:
|
|
122
120
|
|
|
123
121
|
- The fresh key travels **server β MCP process β disk** and is stored in `~/.z-zero/credentials` (mode `0600`). It never appears in any LLM conversation, tool result, or config file.
|
|
124
122
|
- The pasted key is **dead within seconds** β a copy living in a chat transcript, clipboard, or screenshot can no longer be used by anyone.
|
|
125
|
-
- On startup the MCP loads the key from `~/.z-zero/credentials
|
|
123
|
+
- On startup the MCP loads the key from `~/.z-zero/credentials`. If you later put a **different** key in `Z_ZERO_API_KEY`, that new key wins and is rotated in turn.
|
|
124
|
+
- `set_api_key` will not replace a working key with one from a **different account** (a page could tell an agent to "connect" a stranger's key, whose deposit address would then be shown to you). To switch accounts on purpose, revoke the current key on the dashboard first.
|
|
125
|
+
- `Z_ZERO_API_BASE_URL` (your own Z-Zero server) is ignored unless you also set `Z_ZERO_ALLOW_CUSTOM_API=1`; a custom server gets its own key file and never receives your z-zero.xyz key.
|
|
126
126
|
|
|
127
127
|
**One key = one machine.** All agents on the same machine (Claude Desktop, Claude Code, Cursor, β¦) share the same MCP install and the same credentials file β install once, every agent can pay. Connecting a *different* machine with a copied key rotates it, which instantly disconnects the original machine. That is deliberate: it blocks key sharing **and** doubles as an intrusion alarm β if your agent suddenly fails auth, someone else used your key; go to the dashboard and revoke.
|
|
128
128
|
|
|
@@ -162,7 +162,7 @@ Older self-hosted backends without the rotate endpoint keep working β the past
|
|
|
162
162
|
|
|
163
163
|
| Tool | Description |
|
|
164
164
|
|------|-------------|
|
|
165
|
-
| `auto_pay_checkout` |
|
|
165
|
+
| `auto_pay_checkout` | One-call checkout for a page whose total is already visible. **Requires `max_amount`** (USD, the most the owner agreed to; the agent converts other currencies). The card is never larger; on a USD page a visible total above it, or no readable total, stops before any card is issued. Card only |
|
|
166
166
|
| `get_merchant_hints` | Fetch platform-specific checkout playbook (pre-steps + selectors) from Knowledge Base |
|
|
167
167
|
| `report_checkout_fail` | Report a failed checkout with a **structured `failure_class`** (14-class enum) β feeds the self-healing loop |
|
|
168
168
|
| `verify_receipt` | Verify a signed receipt by id β prove a purchase happened instead of claiming it |
|
|
@@ -322,4 +322,4 @@ Cancel an unused token (refunds balance).
|
|
|
322
322
|
|
|
323
323
|
---
|
|
324
324
|
|
|
325
|
-
*Security: the key you paste is never kept β it rotates the moment your agent first connects, and the fresh key lives only in a local owner-only file (`~/.z-zero/credentials`, mode 0600), never in any LLM conversation. Card data exists only in volatile RAM during execution.*
|
|
325
|
+
*Security: the key you paste or put in the MCP config is never kept β it rotates the moment your agent first connects, and the fresh key lives only in a local owner-only file (`~/.z-zero/credentials`, mode 0600), never in any LLM conversation. Card data exists only in volatile RAM during execution.*
|
package/dist/base_backend.js
CHANGED
|
@@ -31,7 +31,24 @@ if (!(0, key_store_js_1.hasPassportKey)()) {
|
|
|
31
31
|
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
32
32
|
// HTTP helpers (same as api_backend.ts to call Dashboard API)
|
|
33
33
|
// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
34
|
-
|
|
34
|
+
// Every authenticated call: first make sure a config key has been rotated
|
|
35
|
+
// (lib/key-store.ts); on a 401 from a stored key, fall back once to a newer key
|
|
36
|
+
// in the MCP config.
|
|
37
|
+
async function withKey(call) {
|
|
38
|
+
await (0, key_store_js_1.ensureKeyReady)();
|
|
39
|
+
const first = await call();
|
|
40
|
+
if (first?.error === "AUTH_REQUIRED" && first?.status === 401 && await (0, key_store_js_1.recoverFromRejectedKey)()) {
|
|
41
|
+
return call();
|
|
42
|
+
}
|
|
43
|
+
return first;
|
|
44
|
+
}
|
|
45
|
+
function apiRequest(endpoint, method = "GET", body = null) {
|
|
46
|
+
return withKey(() => apiRequestOnce(endpoint, method, body));
|
|
47
|
+
}
|
|
48
|
+
function internalApiRequest(endpoint, method, body) {
|
|
49
|
+
return withKey(() => internalApiRequestOnce(endpoint, method, body));
|
|
50
|
+
}
|
|
51
|
+
async function apiRequestOnce(endpoint, method = "GET", body = null) {
|
|
35
52
|
const PASSPORT_KEY = (0, key_store_js_1.getPassportKey)(); // β
Hot-swap: read key dynamically each request
|
|
36
53
|
if (!PASSPORT_KEY) {
|
|
37
54
|
return { error: "AUTH_REQUIRED", message: "Z_ZERO_API_KEY is missing." };
|
|
@@ -94,7 +111,7 @@ function httpError(res, err) {
|
|
|
94
111
|
message: err?.message || err?.error || res.statusText,
|
|
95
112
|
};
|
|
96
113
|
}
|
|
97
|
-
async function
|
|
114
|
+
async function internalApiRequestOnce(endpoint, method, body) {
|
|
98
115
|
// Auth is the Bearer Passport Key β the server dropped the x-internal-secret
|
|
99
116
|
// gate on /resolve and /burn (redundant to per-user token ownership, Jul 2026).
|
|
100
117
|
// The old client-side CONFIG_ERROR check here broke execute_payment for every
|
|
@@ -23,14 +23,21 @@ export interface CheckoutEvent {
|
|
|
23
23
|
intent_id?: string;
|
|
24
24
|
evidence_ref?: string;
|
|
25
25
|
}
|
|
26
|
+
export declare function redactCardData(text: string, opts?: {
|
|
27
|
+
cards?: "any" | "valid";
|
|
28
|
+
}): string;
|
|
26
29
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* them to ASCII so one pattern catches both forms.
|
|
30
|
+
* Remove THIS card's own values from a text β whatever is glued between the
|
|
31
|
+
* digits β then run the general redaction. Used on every string the checkout
|
|
32
|
+
* bridge hands back: the pattern above cannot know that a lone 3-digit number
|
|
33
|
+
* is the CVV, but the bridge does.
|
|
32
34
|
*/
|
|
33
|
-
export declare function
|
|
35
|
+
export declare function scrubCardValues(text: string, secrets: {
|
|
36
|
+
number?: string;
|
|
37
|
+
cvv?: string;
|
|
38
|
+
}, opts?: {
|
|
39
|
+
cards?: "any" | "valid";
|
|
40
|
+
}): string;
|
|
34
41
|
/** First 6 digits of a PAN β safe to log (BIN is not cardholder data). */
|
|
35
42
|
export declare function extractBin(cardNumber: string | undefined): string | undefined;
|
|
36
43
|
/**
|
package/dist/failure_taxonomy.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.LEGACY_ERROR_TYPE_MAP = exports.CHECKOUT_STEPS = exports.FAILURE_CLASSES = exports.TAXONOMY_VERSION = void 0;
|
|
15
15
|
exports.redactCardData = redactCardData;
|
|
16
|
+
exports.scrubCardValues = scrubCardValues;
|
|
16
17
|
exports.extractBin = extractBin;
|
|
17
18
|
exports.classifyBridgeResult = classifyBridgeResult;
|
|
18
19
|
exports.TAXONOMY_VERSION = 1;
|
|
@@ -51,21 +52,88 @@ exports.CHECKOUT_STEPS = [
|
|
|
51
52
|
// Screenshots/DOM/HAR/messages must never contain PAN or CVV.
|
|
52
53
|
// ------------------------------------------------------------
|
|
53
54
|
/**
|
|
54
|
-
* Mask
|
|
55
|
+
* Mask card numbers and CVVs in any text. Same function as
|
|
56
|
+
* z-zero-dashboard/src/lib/failure-taxonomy.ts (keep the two in step).
|
|
55
57
|
*
|
|
56
58
|
* NFKC first: full-width digits (οΌοΌοΌοΌβ¦) read as a card number to a human and
|
|
57
59
|
* to anything downstream, but slip past an ASCII \d regex. Normalising folds
|
|
58
60
|
* them to ASCII so one pattern catches both forms.
|
|
61
|
+
*
|
|
62
|
+
* A card number is 12β19 digits, however they are glued together: plain,
|
|
63
|
+
* spaced, hyphenated, `id_4242β¦`, `4242.4242β¦`, double spaces, `%20`,
|
|
64
|
+
* en-dashes (audit T07 F4, T19 T12-F9). Any digit run of that length with up
|
|
65
|
+
* to three separator characters between digits, not touching another digit.
|
|
66
|
+
*
|
|
67
|
+
* What survives untouched: transaction hashes, UUIDs and other long hex
|
|
68
|
+
* strings (they contain digit runs by chance), and any number under 12 digits.
|
|
69
|
+
*
|
|
70
|
+
* `cards: "any"` (default) masks every 12β19 digit run β right for error text
|
|
71
|
+
* and anything handed to the model, where a stray number is worth nothing and
|
|
72
|
+
* a leaked card is. `cards: "valid"` masks only runs that can BE a card number
|
|
73
|
+
* (13β19 digits, first digit 2β6, Luhn passes) β for an order number whose
|
|
74
|
+
* digits are the point.
|
|
59
75
|
*/
|
|
60
|
-
|
|
76
|
+
const PAN_SEPARATOR = String.raw `(?:%20|[\s._\-β-ββ]){0,3}`;
|
|
77
|
+
const PAN_OR_HEX = new RegExp(
|
|
78
|
+
// group 1 = keep: a UUID, or 32+ hex characters with at least one letter
|
|
79
|
+
String.raw `([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|(?<![0-9a-f])(?=[0-9]*[a-f])[0-9a-f]{32,}(?![0-9a-f]))` +
|
|
80
|
+
String.raw `|(?<!\d)\d(?:${PAN_SEPARATOR}\d){11,18}(?!\d)`, "gi");
|
|
81
|
+
// cvv=123 Β· "cvv":"123" Β· 'cvc': '123' Β· security_code: 123 Β· _cvv_123
|
|
82
|
+
const CVV_PAIR = new RegExp(String.raw `(?<![a-z0-9])(cvv2?|cvc2?|security[\s_-]?code)(?![a-z])(?:%20|%22|%3a|%3d|[\s"'=:_>-]){0,6}\d{3,4}(?!\d)`, "gi");
|
|
83
|
+
/** Luhn checksum β every real card number passes it; 9 in 10 random digit runs do not. */
|
|
84
|
+
function passesLuhn(digits) {
|
|
85
|
+
let sum = 0;
|
|
86
|
+
let double = false;
|
|
87
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
88
|
+
let d = digits.charCodeAt(i) - 48;
|
|
89
|
+
if (double) {
|
|
90
|
+
d *= 2;
|
|
91
|
+
if (d > 9)
|
|
92
|
+
d -= 9;
|
|
93
|
+
}
|
|
94
|
+
sum += d;
|
|
95
|
+
double = !double;
|
|
96
|
+
}
|
|
97
|
+
return sum % 10 === 0;
|
|
98
|
+
}
|
|
99
|
+
function redactCardData(text, opts = {}) {
|
|
61
100
|
if (!text)
|
|
62
101
|
return text;
|
|
102
|
+
const validOnly = opts.cards === "valid";
|
|
63
103
|
return text
|
|
64
104
|
.normalize("NFKC")
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
105
|
+
.replace(PAN_OR_HEX, (match, hex) => {
|
|
106
|
+
if (hex)
|
|
107
|
+
return match;
|
|
108
|
+
if (validOnly) {
|
|
109
|
+
// "%20" is a separator here, not two digits of the number.
|
|
110
|
+
const digits = match.replace(/%20/gi, "").replace(/\D/g, "");
|
|
111
|
+
if (digits.length < 13 || !/^[2-6]/.test(digits) || !passesLuhn(digits))
|
|
112
|
+
return match;
|
|
113
|
+
}
|
|
114
|
+
return "[PAN_REDACTED]";
|
|
115
|
+
})
|
|
116
|
+
.replace(CVV_PAIR, "$1 [REDACTED]");
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Remove THIS card's own values from a text β whatever is glued between the
|
|
120
|
+
* digits β then run the general redaction. Used on every string the checkout
|
|
121
|
+
* bridge hands back: the pattern above cannot know that a lone 3-digit number
|
|
122
|
+
* is the CVV, but the bridge does.
|
|
123
|
+
*/
|
|
124
|
+
function scrubCardValues(text, secrets, opts = {}) {
|
|
125
|
+
if (!text)
|
|
126
|
+
return text;
|
|
127
|
+
let out = text.normalize("NFKC");
|
|
128
|
+
const pan = (secrets.number || "").replace(/\D/g, "");
|
|
129
|
+
if (pan.length >= 12) {
|
|
130
|
+
out = out.replace(new RegExp(pan.split("").join("(?:%20|[^0-9]){0,3}"), "g"), "[PAN_REDACTED]");
|
|
131
|
+
}
|
|
132
|
+
const cvv = (secrets.cvv || "").replace(/\D/g, "");
|
|
133
|
+
if (cvv.length >= 3) {
|
|
134
|
+
out = out.replace(new RegExp(`(?<!\\d)${cvv}(?!\\d)`, "g"), "[REDACTED]");
|
|
135
|
+
}
|
|
136
|
+
return redactCardData(out, opts);
|
|
69
137
|
}
|
|
70
138
|
/** First 6 digits of a PAN β safe to log (BIN is not cardholder data). */
|
|
71
139
|
function extractBin(cardNumber) {
|