z-zero-mcp-server 1.12.4 → 1.12.5

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.
@@ -156,7 +156,10 @@ function finish(r, secrets) {
156
156
  const clean = (t) => hideExpiry((0, failure_taxonomy_js_1.scrubCardValues)(hideDealCode(t, secrets.code), secrets), secrets);
157
157
  const out = { ...r, message: clean(r.message) };
158
158
  if (r.page_detail) {
159
- out.page_detail = clean(r.page_detail).slice(0, PAGE_DETAIL_MAX);
159
+ // Cut AFTER cleaning, at a space where there is one (a long address has none: plain cut).
160
+ const cleaned = clean(r.page_detail);
161
+ const at = cleaned.length > PAGE_DETAIL_MAX ? cleaned.slice(0, PAGE_DETAIL_MAX + 1).lastIndexOf(" ") : -1;
162
+ out.page_detail = cleaned.length <= PAGE_DETAIL_MAX ? cleaned : cleaned.slice(0, at > PAGE_DETAIL_MAX / 2 ? at : PAGE_DETAIL_MAX);
160
163
  }
161
164
  if (r.receipt_id !== undefined) {
162
165
  // An "order number" that holds the code is dropped outright, like one that holds the card.
@@ -449,11 +452,15 @@ async function readPageAlerts(page) {
449
452
  continue;
450
453
  const t = (el.innerText || "").replace(/\s+/g, " ").trim();
451
454
  if (t.length >= 8)
452
- seen.add(cutAtSpace(t, 200));
455
+ seen.add(cutAtSpace(t, 600));
453
456
  if (seen.size >= 3)
454
457
  break;
455
458
  }
456
- return cutAtSpace(Array.from(seen).join(" | "), 300);
459
+ // Far longer than what is handed back (PAGE_DETAIL_MAX): the short cut is made in
460
+ // finish(), AFTER card values and deal codes are scrubbed from the whole text. A value
461
+ // written with spaces ("4242 4242 4242 4242") that sat across an early cut left its
462
+ // first groups behind, where the scrubbing no longer saw a card number (review, round 4).
463
+ return cutAtSpace(Array.from(seen).join(" | "), 1500);
457
464
  }).catch(() => "");
458
465
  }
459
466
  /** The whole line a decline phrase sits on (readableText puts one text node per line). */
@@ -473,8 +480,11 @@ function cutWords(t, max) {
473
480
  function textNewSince(before, now) {
474
481
  if (before === undefined)
475
482
  return now;
476
- const old = new Set(before.split("\n").map((l) => l.trim()).filter(Boolean));
477
- return now.split("\n").map((l) => l.trim()).filter((l) => l && !old.has(l)).join("\n");
483
+ // Lines are compared with their inner whitespace collapsed: a page that redraws itself may
484
+ // space the same sentence differently, and that must not make old help text "new".
485
+ const norm = (l) => l.replace(/\s+/g, " ").trim();
486
+ const old = new Set(before.split("\n").map(norm).filter(Boolean));
487
+ return now.split("\n").map(norm).filter((l) => l && !old.has(l)).join("\n");
478
488
  }
479
489
  /**
480
490
  * The text a person looking at the page can actually read (audit T12 F6, M.7).
@@ -574,19 +584,29 @@ async function detectPaymentOutcome(page, checkoutUrl) {
574
584
  return false;
575
585
  }
576
586
  })();
577
- const urlSignal = movedOff && SUCCESS_URL_RE.test(currentUrl);
587
+ // The address is judged by its PATH only. A query string names where the shop would go
588
+ // next ("?return_url=/thank-you", "?next=confirmation"), not where the buyer is.
589
+ const urlSignal = movedOff && SUCCESS_URL_RE.test((() => { try {
590
+ return new URL(currentUrl).pathname;
591
+ }
592
+ catch {
593
+ return '';
594
+ } })());
578
595
  const textSignal = SUCCESS_TEXT_RE.test(bodyText);
579
- // Order of judgement (changed in 1.12.4, independent review 27/11/2026). Until then the
580
- // page-wide decline words were tested FIRST and on ALL the text: a thank-you page or a
581
- // checkout whose help text says "What if my card was declined?" was reported 'declined'
582
- // for an order that had gone through — an invitation to pay twice.
583
- // 1. The page has MOVED to a confirmation address → confirmed.
584
- // 2. The page's own ERROR BANNER says the card did not go through → declined.
585
- // 3. Confirmation words on the page → confirmed.
586
- // 4. Decline words in text that was NOT on the page before Pay was pressed → declined.
596
+ // Order of judgement. Until 1.12.4 the page-wide decline words were tested FIRST and on
597
+ // ALL the text: a thank-you page or a checkout whose help text says "What if my card was
598
+ // declined?" was reported 'declined' for an order that had gone through — an invitation
599
+ // to pay twice. 1.12.4 fixed that but let a confirmation ADDRESS win over the page's
600
+ // error banner: a shop that answers a refusal at /orders/123/payment?error=declined, or
601
+ // at any address holding "confirmation", was reported 'confirmed' for a declined card —
602
+ // the token burned, the hold stranded (independent review, round 4; fixed in 1.12.5).
603
+ // 1. The page's own ERROR BANNER says the card did not go through → declined. A real
604
+ // thank-you page does not carry an alert saying the card was refused.
605
+ // 2. The page has moved to a confirmation address, or says so in words → confirmed.
606
+ // 3. Decline words in text that was NOT on the page before Pay was pressed → declined.
587
607
  // Help text, FAQs and product notes were there before; a shop's refusal is new.
588
608
  const alertDeclined = ALERT_DECLINE_RE.test(alerts) || DECLINE_TEXT_RE.test(alerts);
589
- if (!urlSignal && alertDeclined) {
609
+ if (alertDeclined) {
590
610
  return { kind: 'declined', page_said: alerts || undefined };
591
611
  }
592
612
  if (!urlSignal && !textSignal) {
@@ -1113,6 +1133,10 @@ async function _fillCheckoutFormInner(page, checkoutUrl, cardData, hints, deal,
1113
1133
  // no_fields on the first real deal order (26/11/2026). Selectors the agent did pass
1114
1134
  // are kept — the preset only fills what is missing.
1115
1135
  let cardFieldsFrom = 'agent hints';
1136
+ // ONE allowance for card frames to appear and load, shared by the two waits below (the
1137
+ // Shopify look-out, then "every attached frame has its page"). They used to run one
1138
+ // after the other with a fresh 8 seconds each (review, round 4).
1139
+ let cardFramesUntil = 0;
1116
1140
  if (!(hints && (hints.card_selector || hints.exp_selector || hints.cvv_selector))) {
1117
1141
  await page.waitForLoadState("load", { timeout: 10_000 }).catch(() => { });
1118
1142
  const hasShopifyCardFrames = () => page.frames().some((f) => f !== page.mainFrame() && /^card-fields-number/.test(f.name()) &&
@@ -1123,8 +1147,8 @@ async function _fillCheckoutFormInner(page, checkoutUrl, cardData, hints, deal,
1123
1147
  // building them, give them a few seconds.
1124
1148
  let shopifyCardFrames = hasShopifyCardFrames();
1125
1149
  if (!shopifyCardFrames && (/\/checkouts\//.test(page.url()) || await page.$('iframe[name^="card-fields"], [id*="card-fields" i]').catch(() => null))) {
1126
- const until = Date.now() + 8_000;
1127
- while (!shopifyCardFrames && Date.now() < until) {
1150
+ cardFramesUntil = Date.now() + CARD_FRAMES_WAIT_MS;
1151
+ while (!shopifyCardFrames && Date.now() < cardFramesUntil) {
1128
1152
  await page.waitForTimeout(400).catch(() => { });
1129
1153
  shopifyCardFrames = hasShopifyCardFrames();
1130
1154
  }
@@ -1150,7 +1174,7 @@ async function _fillCheckoutFormInner(page, checkoutUrl, cardData, hints, deal,
1150
1174
  // wait at all, so an agent that followed the hints was the one more likely to
1151
1175
  // fail (independent review, 27/11/2026).
1152
1176
  const attachedCardFrames = () => page.$$eval('iframe', (els, n) => els.filter((e) => (e.getAttribute('name') || '').includes(n)).length, frameName).catch(() => 0);
1153
- const framesUntil = Date.now() + CARD_FRAMES_WAIT_MS;
1177
+ const framesUntil = cardFramesUntil || Date.now() + CARD_FRAMES_WAIT_MS;
1154
1178
  for (;;) {
1155
1179
  const attached = await attachedCardFrames();
1156
1180
  if (attached > 0 && loadedCardFrames().length >= attached)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "z-zero-mcp-server",
3
- "version": "1.12.4",
3
+ "version": "1.12.5",
4
4
  "description": "Z-ZERO MCP Server — Secure JIT Virtual Card Payment tools for AI Agents (Claude, Cursor, AutoGPT) — Real Single-Use Virtual Cards, settled in USDC on Base",
5
5
  "main": "dist/index.js",
6
6
  "bin": {