@mysten-incubation/suipay-buyer 0.4.0-dev.0 → 0.4.0-dev.10

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.
@@ -869,7 +869,7 @@ var DELIVERY_CODES = {
869
869
  user: { title: "Something went wrong", message: "No result came back from the service." }
870
870
  },
871
871
  "delivery.seller_timeout": {
872
- surfaces: ["gateway"],
872
+ surfaces: ["gateway", "sdk", "mcp_local", "mcp_hosted"],
873
873
  status: 504,
874
874
  title: "Seller timed out after payment",
875
875
  paymentState: "charged",
@@ -1110,6 +1110,16 @@ var INDEXER_CODES = {
1110
1110
  nextAction: "contact_support",
1111
1111
  user: null,
1112
1112
  logOnly: true
1113
+ },
1114
+ "indexer.unsettled_delivery": {
1115
+ surfaces: ["indexer"],
1116
+ status: null,
1117
+ title: "Delivered call has no matching on-chain settlement",
1118
+ paymentState: "not_charged",
1119
+ retry: "never",
1120
+ nextAction: "contact_support",
1121
+ user: null,
1122
+ logOnly: true
1113
1123
  }
1114
1124
  };
1115
1125
 
@@ -2395,8 +2405,7 @@ var VALUE_PATTERNS = [
2395
2405
  /-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,
2396
2406
  // Sui bech32 private keys.
2397
2407
  /suiprivkey1[0-9a-z]{20,}/gi,
2398
- // JSON Web Tokens (delivery proofs, OAuth tokens).
2399
- /\beyJ[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}\.[A-Za-z0-9_-]{5,}/g,
2408
+ // JSON Web Tokens are matched by `redactJwts`, not a regex here.
2400
2409
  // Bearer and Payment authorization values.
2401
2410
  /\b(Bearer|Payment|Basic)\s+[A-Za-z0-9\-._~+/=,:]{8,}(?:\s*,\s*[a-z]+="[^"]*")*/g,
2402
2411
  // `sk-…`-style vendor keys.
@@ -2406,6 +2415,44 @@ var VALUE_PATTERNS = [
2406
2415
  // Google API keys.
2407
2416
  /\bAIza[0-9A-Za-z_-]{30,}/g
2408
2417
  ];
2418
+ var JWT_POSITION = 2;
2419
+ var WORD_CHAR = /[A-Za-z0-9_]/;
2420
+ var JWT_CHAR = /[A-Za-z0-9_-]/;
2421
+ function redactJwts(text) {
2422
+ if (!text.includes("eyJ"))
2423
+ return text;
2424
+ const stop = new Int32Array(text.length + 1);
2425
+ stop[text.length] = text.length;
2426
+ for (let p = text.length - 1; p >= 0; p -= 1) {
2427
+ stop[p] = JWT_CHAR.test(text[p]) ? stop[p + 1] : p;
2428
+ }
2429
+ const segment = (from) => from <= text.length ? stop[from] : -1;
2430
+ let out = "";
2431
+ let last = 0;
2432
+ let i = text.indexOf("eyJ");
2433
+ while (i !== -1) {
2434
+ let end = -1;
2435
+ if (i === 0 || !WORD_CHAR.test(text[i - 1])) {
2436
+ const first = segment(i + 3);
2437
+ if (first - (i + 3) >= 5 && text[first] === ".") {
2438
+ const second = segment(first + 1);
2439
+ if (second - (first + 1) >= 5 && text[second] === ".") {
2440
+ const third = segment(second + 1);
2441
+ if (third - (second + 1) >= 5)
2442
+ end = third;
2443
+ }
2444
+ }
2445
+ }
2446
+ if (end === -1) {
2447
+ i = text.indexOf("eyJ", i + 1);
2448
+ continue;
2449
+ }
2450
+ out += text.slice(last, i) + REDACTED;
2451
+ last = end;
2452
+ i = text.indexOf("eyJ", end);
2453
+ }
2454
+ return out + text.slice(last);
2455
+ }
2409
2456
  var JSON_SECRET_KEY_COLON = new RegExp(String.raw`(\\?)(["'])([\w.-]{0,64}${SECRET_KEY_SOURCE}[\w.-]{0,64}|key)(\\\2|\2)(\s*:\s*)`, "gi");
2410
2457
  var KEY_VALUE_PATTERN = new RegExp(String.raw`((?:(?<![\w.-])[\w.-]{0,64}${SECRET_KEY_SOURCE}[\w.-]{0,64}|(?<![\w.-])key)\s*[:=]\s*)("(?:\\.|[^"\\])*"?|'(?:\\.|[^'\\])*'?|(?![[{])[^\s"',;&}]+)`, "gi");
2411
2458
  var INSPECT_SECRET_KEY = new RegExp(String.raw`(?:(?<![\w.-])[\w.-]{0,64}${SECRET_KEY_SOURCE}[\w.-]{0,64}|(?<![\w.-])key)\s*[:=]\s*`, "gi");
@@ -2443,8 +2490,11 @@ function redactSecrets(text) {
2443
2490
  const head = dropSplitToken(text.slice(0, REDACT_MAX_LENGTH));
2444
2491
  out = `${head} \u2026[truncated ${text.length - head.length} chars]`;
2445
2492
  }
2446
- for (const pattern of VALUE_PATTERNS)
2493
+ for (const [index, pattern] of VALUE_PATTERNS.entries()) {
2494
+ if (index === JWT_POSITION)
2495
+ out = redactJwts(out);
2447
2496
  out = out.replace(pattern, REDACTED);
2497
+ }
2448
2498
  out = out.replace(URL_PATTERN, (_match, scheme, userinfo, host, path, query) => `${scheme}://${userinfo ? `${REDACTED}@` : ""}${host}${path}${query ? `?${REDACTED}` : ""}`);
2449
2499
  out = out.replace(RELATIVE_URL_QUERY, (_m, prefix, path) => `${prefix}${path}?${REDACTED}`);
2450
2500
  out = redactJsonSecretValues(out);
@@ -3059,9 +3109,11 @@ var CONTEXT_ALLOWLIST = /* @__PURE__ */ new Set([
3059
3109
  "ownerDailyMist",
3060
3110
  "ownerHourlyMist",
3061
3111
  "ownerIdentityDailyMist",
3112
+ "ownerIdentityHourlyMist",
3062
3113
  "delegateDailyMist",
3063
3114
  "delegateHourlyMist",
3064
3115
  "delegateIdentityDailyMist",
3116
+ "delegateIdentityHourlyMist",
3065
3117
  "consecutiveFailures",
3066
3118
  "failuresInARow",
3067
3119
  "epochReadFailures",
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as ErrorCode, P as PaymentState, N as NextAction, R as Receipt, C as CodeFor, D as DelegationScope, O as Offer } from './native-transfer-DspFvMQc.js';
2
- export { B as BuildNativeTransferInput, M as McpPaymentSigner, a as NativeTransferAccept, b as NativeTransferBuild, c as NativeTransferError, d as NativeTransferGas, e as NativeTransferSignerInput, S as SuiPayError, f as SuiPayErrorFields, g as buildMcpPaymentPayload, h as buildNativeTransferBytes, i as createNativeTransferSigner, j as inspectNativeTransfer, t as toErrorFields } from './native-transfer-DspFvMQc.js';
1
+ import { E as ErrorCode, P as PaymentState, N as NextAction, R as Receipt, C as CodeFor, D as DelegationScope, O as Offer } from './native-transfer-DWs55Mse.js';
2
+ export { B as BuildNativeTransferInput, M as McpPaymentSigner, a as NativeTransferAccept, b as NativeTransferBuild, c as NativeTransferError, d as NativeTransferGas, e as NativeTransferSignerInput, S as SuiPayError, f as SuiPayErrorFields, g as buildMcpPaymentPayload, h as buildNativeTransferBytes, i as createNativeTransferSigner, j as inspectNativeTransfer, t as toErrorFields } from './native-transfer-DWs55Mse.js';
3
3
  import { SuiGrpcClient } from '@mysten/sui/grpc';
4
4
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
5
5
  import { KeyObject } from 'node:crypto';
@@ -990,7 +990,7 @@ declare function createReader(options: PayerReadClientOptions): PayerReadClient;
990
990
  * prior done result is never lost when capability is unavailable.
991
991
  * 5. Derive payment_id_hash / terms_hash.
992
992
  * 6. Build the full executable pay transaction (real shared-object versions).
993
- * 7. Validate-before-sign (built tx encodes exactly the intended pay; gas may differ).
993
+ * 7. Validate-before-sign (intended pay plus the caller's gas authority).
994
994
  * 8. Sign, 9. execute, 10. complete(ledger) with terminal ok/ambiguous, settle.
995
995
  * x402 refuses before 3 when its offer, gas pins or epoch are missing, skips
996
996
  * 4, builds 6 with the offer-pinned sponsor gas, and in place of 9-10
@@ -1825,6 +1825,9 @@ interface VerifyPreparedSettlementInput {
1825
1825
  */
1826
1826
  expectedGrantObjectId?: string;
1827
1827
  expectedPoolObjectId?: string;
1828
+ /** Independently read network bounds for Epoch / ValidDuring envelopes. */
1829
+ getCurrentEpoch?: () => Promise<bigint | number>;
1830
+ getChainIdentifier?: () => Promise<string>;
1828
1831
  }
1829
1832
  /**
1830
1833
  * Verify a prepared settlement and return it, or throw