@visa/cli 4.1.0-rc.298 → 4.1.0-rc.299

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.
Files changed (77) hide show
  1. package/README.md +29 -45
  2. package/dist/cli.js +556 -786
  3. package/dist/mcp-server/index.js +408 -622
  4. package/dist/merchant-ucp-mcp/index.js +6 -6
  5. package/dist/skills/pair-visa-agent/SKILL.md +175 -240
  6. package/native/bin/win32-arm64/visa-runtime-signer.exe +0 -0
  7. package/native/bin/win32-x64/visa-keychain-win.exe +0 -0
  8. package/native/bin/win32-x64/visa-runtime-signer.exe +0 -0
  9. package/package.json +2 -4
  10. package/server.json +2 -2
  11. package/dist/checkout-engine/adapters/generic.d.ts +0 -88
  12. package/dist/checkout-engine/adapters/generic.js +0 -526
  13. package/dist/checkout-engine/adapters/index.d.ts +0 -10
  14. package/dist/checkout-engine/adapters/index.js +0 -24
  15. package/dist/checkout-engine/adapters/shopify.d.ts +0 -98
  16. package/dist/checkout-engine/adapters/shopify.js +0 -744
  17. package/dist/checkout-engine/adapters/stripe-like.d.ts +0 -10
  18. package/dist/checkout-engine/adapters/stripe-like.js +0 -21
  19. package/dist/checkout-engine/amount.d.ts +0 -17
  20. package/dist/checkout-engine/amount.js +0 -72
  21. package/dist/checkout-engine/browser-launch.d.ts +0 -51
  22. package/dist/checkout-engine/browser-launch.js +0 -96
  23. package/dist/checkout-engine/browserbase-browser.d.ts +0 -24
  24. package/dist/checkout-engine/browserbase-browser.js +0 -186
  25. package/dist/checkout-engine/ceremony.d.ts +0 -64
  26. package/dist/checkout-engine/ceremony.js +0 -261
  27. package/dist/checkout-engine/cli-engine.d.ts +0 -417
  28. package/dist/checkout-engine/cli-engine.js +0 -1331
  29. package/dist/checkout-engine/confirmed-merchants.d.ts +0 -31
  30. package/dist/checkout-engine/confirmed-merchants.js +0 -165
  31. package/dist/checkout-engine/detect.d.ts +0 -61
  32. package/dist/checkout-engine/detect.js +0 -398
  33. package/dist/checkout-engine/evidence.d.ts +0 -25
  34. package/dist/checkout-engine/evidence.js +0 -104
  35. package/dist/checkout-engine/executor.d.ts +0 -262
  36. package/dist/checkout-engine/executor.js +0 -1837
  37. package/dist/checkout-engine/hosted-approval.d.ts +0 -195
  38. package/dist/checkout-engine/hosted-approval.js +0 -501
  39. package/dist/checkout-engine/index.d.ts +0 -12
  40. package/dist/checkout-engine/index.js +0 -13
  41. package/dist/checkout-engine/instrument.d.ts +0 -61
  42. package/dist/checkout-engine/instrument.js +0 -87
  43. package/dist/checkout-engine/known-merchants.d.ts +0 -10
  44. package/dist/checkout-engine/known-merchants.js +0 -38
  45. package/dist/checkout-engine/live-fill-approval.d.ts +0 -37
  46. package/dist/checkout-engine/live-fill-approval.js +0 -76
  47. package/dist/checkout-engine/mandate/card-mandate.d.ts +0 -121
  48. package/dist/checkout-engine/mandate/card-mandate.js +0 -226
  49. package/dist/checkout-engine/mandate/mandate-ledger.d.ts +0 -175
  50. package/dist/checkout-engine/mandate/mandate-ledger.js +0 -425
  51. package/dist/checkout-engine/mandate.d.ts +0 -33
  52. package/dist/checkout-engine/mandate.js +0 -135
  53. package/dist/checkout-engine/outcome.d.ts +0 -30
  54. package/dist/checkout-engine/outcome.js +0 -225
  55. package/dist/checkout-engine/owner-only-file.d.ts +0 -19
  56. package/dist/checkout-engine/owner-only-file.js +0 -41
  57. package/dist/checkout-engine/package.json +0 -3
  58. package/dist/checkout-engine/receipt-dir.d.ts +0 -6
  59. package/dist/checkout-engine/receipt-dir.js +0 -8
  60. package/dist/checkout-engine/receipt.d.ts +0 -135
  61. package/dist/checkout-engine/receipt.js +0 -148
  62. package/dist/checkout-engine/shopify-primary-domain.d.ts +0 -25
  63. package/dist/checkout-engine/shopify-primary-domain.js +0 -96
  64. package/dist/checkout-engine/trace-handles.d.ts +0 -8
  65. package/dist/checkout-engine/trace-handles.js +0 -12
  66. package/dist/checkout-engine/types.d.ts +0 -52
  67. package/dist/checkout-engine/types.js +0 -2
  68. package/dist/checkout-engine/unresolved-charges.d.ts +0 -34
  69. package/dist/checkout-engine/unresolved-charges.js +0 -134
  70. package/dist/checkout-engine/vgs-gateway/server-mint-client.d.ts +0 -155
  71. package/dist/checkout-engine/vgs-gateway/server-mint-client.js +0 -493
  72. package/dist/checkout-engine/vgs-live-instrument.d.ts +0 -144
  73. package/dist/checkout-engine/vgs-live-instrument.js +0 -229
  74. package/dist/checkout-engine/vic-confirmation.d.ts +0 -52
  75. package/dist/checkout-engine/vic-confirmation.js +0 -45
  76. package/dist/checkout-engine/web-bot-auth.d.ts +0 -98
  77. package/dist/checkout-engine/web-bot-auth.js +0 -218
@@ -1,104 +0,0 @@
1
- // Evidence log. A timestamped JSONL trail of everything the executor did:
2
- // navigation, adapter choice, each field fill (with confidence + source),
3
- // the mandate verdict, the submit, and the final outcome, plus a compact
4
- // accessibility snapshot of the end state.
5
- //
6
- // Money-adjacent hygiene rule: the full PAN, the cvc, the card expiry, and any
7
- // one-time verification code NEVER enter the log. PANs are masked to last-4;
8
- // cvc, expiry, and OTP codes are redacted entirely. maskPan/maskCvc/maskExpiry/
9
- // maskOtp are the only sanctioned way to put such a value anywhere near a log
10
- // line. (receipt.ts redactPanLikeDigits only catches 12-19-digit PANs, so a
11
- // 4-8-digit OTP would slip straight through — maskOtp at the fill site is the
12
- // load-bearing guarantee it never reaches the evidence log.) Contact PII
13
- // (cardholder name, email, address, ...) is redacted via redactContact: the
14
- // log records THAT a field was filled, never the personal value.
15
- // Mask a PAN to its last four digits. Non-digits are stripped for the count.
16
- export function maskPan(pan) {
17
- const digits = (pan || '').replace(/\D/g, '');
18
- if (digits.length <= 4)
19
- return '****';
20
- return `**** **** **** ${digits.slice(-4)}`;
21
- }
22
- // The cvc is never displayed, even masked by length.
23
- export function maskCvc(_cvc) {
24
- return 'redacted';
25
- }
26
- // The expiry is credential material too (one of the three keyable components
27
- // alongside the DPAN and the DAVV) — it never enters the log, in any format.
28
- export function maskExpiry() {
29
- return 'redacted';
30
- }
31
- // A merchant one-time verification code is single-use secret material — it
32
- // never enters the log, in any format. Used at the oneTimeCode fill site so
33
- // the code is masked exactly as cvc/PAN are (see the header note above).
34
- export function maskOtp() {
35
- return 'redacted';
36
- }
37
- // The registrable domain (approx eTLD+1) of an email address or hostname, for
38
- // the caller-side from-domain guard on verification links: before navigating a
39
- // link parsed from an untrusted OTP email, require the link host to match the
40
- // message sender's domain. extract.ts guarantees mechanical extraction, NOT
41
- // navigation safety — this guard is the anti-injection backstop.
42
- export function hostOf(hostOrEmail) {
43
- return (hostOrEmail.split('@').pop() ?? '').trim().toLowerCase().replace(/\.$/, '');
44
- }
45
- // Strict bidirectional host-suffix match (exact / child / parent). Deliberately
46
- // NOT approximate eTLD+1 — that collapses shared-tenant hosts (`x.myshopify.com`,
47
- // `x.co.uk`) to a common suffix and lets a sibling tenant match; siblings never
48
- // match here. Fails SAFE: an unrelated-but-legitimate sender is skipped, not
49
- // trusted.
50
- function hostsRelated(a, b) {
51
- const x = hostOf(a);
52
- const y = hostOf(b);
53
- if (!x || !y)
54
- return false;
55
- return x === y || x.endsWith('.' + y) || y.endsWith('.' + x);
56
- }
57
- // Whether a verification LINK is safe to navigate: the sender must NOT be the
58
- // unauthenticated inbound variant (AgentMail marks spoofable inbound with an
59
- // `.unauthenticated` sub-label), and the link host must belong to the sender's
60
- // domain. Returns false to SKIP a link that fails either check.
61
- export function verificationLinkAllowed(link, messageFrom) {
62
- if (/\.unauthenticated\b/i.test(messageFrom))
63
- return false;
64
- let linkHost;
65
- try {
66
- linkHost = new URL(link).hostname;
67
- }
68
- catch {
69
- return false;
70
- }
71
- return hostsRelated(linkHost, messageFrom);
72
- }
73
- // Contact values (cardholder name, email, address, ...) are PII and never
74
- // enter the log raw either. Email keeps its domain for debuggability;
75
- // everything else becomes a bare presence marker.
76
- export function redactContact(role, value) {
77
- if (!value)
78
- return '';
79
- if (role === 'email') {
80
- const at = value.lastIndexOf('@');
81
- return at > 0 ? `<redacted>@${value.slice(at + 1)}` : '<redacted>';
82
- }
83
- return '<redacted>';
84
- }
85
- export class EvidenceLog {
86
- steps = [];
87
- snapshotSummary = null;
88
- step(type, data = {}) {
89
- this.steps.push({ ts: new Date().toISOString(), type, data });
90
- }
91
- setSnapshotSummary(summary) {
92
- this.snapshotSummary = summary;
93
- }
94
- getSteps() {
95
- return this.steps;
96
- }
97
- // Newline-delimited JSON. One object per line.
98
- toJSONL() {
99
- return this.steps.map((s) => JSON.stringify(s)).join('\n');
100
- }
101
- toObject() {
102
- return { steps: this.steps, snapshotSummary: this.snapshotSummary };
103
- }
104
- }
@@ -1,262 +0,0 @@
1
- import type { Browser, BrowserContext, Page } from 'playwright-core';
2
- import { type FieldMap } from './detect.js';
3
- import { type Mandate, type MandateRefusalCode } from './mandate.js';
4
- import type { Instrument } from './instrument.js';
5
- import type { Contact, OtpResolver } from './types.js';
6
- import { EvidenceLog } from './evidence.js';
7
- import { type ObservedOutcome } from './outcome.js';
8
- import { type WebBotAuthConfig } from './web-bot-auth.js';
9
- import { type NavigationRedirectEvidence } from './shopify-primary-domain.js';
10
- export { minorFromDecimal, pageCurrency } from './amount.js';
11
- export type CheckoutMode = 'dry-run' | 'submit';
12
- export type CheckoutRoute = 'guest-card';
13
- export type CheckoutOutcome = 'reviewed-dry-run'
14
- /** Historical receipt value from the credential-disclosing dry-run. */
15
- | 'filled-dry-run' | 'partial-fill' | 'adapter-required' | 'confirmed' | 'declined' | 'action-required' | 'cancelled' | 'blocked-by-mandate'
16
- /**
17
- * KNOWN-NOT-CHARGED. Every `failed` path ends before the pay control was
18
- * clicked (or before a credential existed at all), so a caller may retry it
19
- * without risking a second charge.
20
- */
21
- | 'failed'
22
- /**
23
- * SUBMITTED, OUTCOME UNKNOWN — the pay control WAS clicked and neither a
24
- * confirmation nor a decline was observed before the deadline. The charge may
25
- * have captured. NEVER retry this automatically.
26
- *
27
- * This case used to be reported as `failed`, and the difference is not
28
- * academic: on 2026-08-17 a whop.com checkout returned `failed` here, the
29
- * caller read that as "nothing happened" and re-ran the purchase, and the
30
- * second run drew a second $5 against the owner's mandate. `outcome.ts`
31
- * already treats an unrecognized post-submit page as the SAFE direction
32
- * ('unknown' → operator verification); collapsing it into `failed` at the
33
- * boundary is what threw that safety away. The distinction has to survive all
34
- * the way to the value consumers branch on.
35
- */
36
- | 'unverified';
37
- /** Stable machine-readable cause for an expected terminal checkout result. */
38
- export type CheckoutFailureCode = 'card-number-field-unavailable' | 'human-action-required' | 'mandate-blocked'
39
- /** A detected, visible field we held a value for refused every fill attempt. */
40
- | 'required-field-unfillable';
41
- export type CredentialLifecycle = 'not-requested' | 'minted-not-exposed' | 'partially-exposed' | 'fully-filled';
42
- export type CredentialTiming = {
43
- approvedAt?: string;
44
- credentialMintedAt?: string;
45
- credentialExpiresAt?: string;
46
- fillCompletedAt?: string;
47
- };
48
- export type CheckoutResult = {
49
- outcome: CheckoutOutcome;
50
- fields: FieldMap;
51
- evidence: EvidenceLog;
52
- confirmationRef?: string;
53
- requiresAdapter: string[];
54
- credentialLifecycle: CredentialLifecycle;
55
- credentialTiming: CredentialTiming;
56
- failureCode?: CheckoutFailureCode;
57
- /** Bounded reason behind a `blocked-by-mandate` outcome; absent otherwise. */
58
- refusalCode?: MandateRefusalCode;
59
- detail?: string;
60
- };
61
- export type PrepareCheckoutOptions = {
62
- url: string;
63
- checkoutRoute: CheckoutRoute;
64
- mandate: Mandate;
65
- browser: Browser;
66
- contact?: Contact;
67
- amountMinor?: number;
68
- currency?: string;
69
- debugShotsDir?: string;
70
- webBotAuth?: WebBotAuthConfig | null;
71
- /**
72
- * Process-internal UCP provenance. Public callers may relay only handoffId;
73
- * this origin set is recovered by the CLI from its single-use registry.
74
- */
75
- trustedMerchantIdentity?: Readonly<{
76
- handoffId: string;
77
- checkoutId: string;
78
- allowedOrigins: readonly string[];
79
- expiresAt: string;
80
- }>;
81
- };
82
- export type RunCheckoutOptions = PrepareCheckoutOptions & {
83
- instrument: Instrument;
84
- contact: Contact;
85
- mode: CheckoutMode;
86
- outcomeDeadlineMs?: number;
87
- resolveEmailOtp?: OtpResolver;
88
- };
89
- export type CheckoutReview = {
90
- id: string;
91
- url: string;
92
- merchantHost: string;
93
- /** Exact origin frozen for a trusted UCP checkout; omitted for generic flows. */
94
- merchantOrigin?: string;
95
- amountMinor: number;
96
- currency: string;
97
- mandateMaxAmountMinor: number;
98
- mandateExpiresAt: string;
99
- submitTarget: string | null;
100
- submitTargetFingerprint: Readonly<CheckoutSubmitTargetFingerprint> | null;
101
- detectedRoles: readonly string[];
102
- checkoutRoute: CheckoutRoute;
103
- };
104
- export type CheckoutSubmitTargetFingerprint = {
105
- kind: 'submit-control' | 'text-button';
106
- label: string;
107
- elementTag: string;
108
- elementId: string | null;
109
- elementName: string | null;
110
- elementType: string | null;
111
- formAction: string | null;
112
- formMethod: string | null;
113
- formTarget: string | null;
114
- };
115
- export type PreparedCheckout = {
116
- readonly review: Readonly<CheckoutReview>;
117
- readonly fields: Readonly<FieldMap>;
118
- readonly evidence: EvidenceLog;
119
- readonly requiresAdapter: readonly string[];
120
- readonly checkoutRoute: CheckoutRoute;
121
- };
122
- export type PrepareCheckoutResult = {
123
- status: 'ready';
124
- checkout: PreparedCheckout;
125
- } | {
126
- status: 'finished';
127
- result: CheckoutResult;
128
- };
129
- export type CheckoutApproval = {
130
- approved: true;
131
- reviewId: string;
132
- };
133
- export type SubmitApprovedCheckoutOptions = {
134
- approval: CheckoutApproval;
135
- instrument: Instrument;
136
- contact: Contact;
137
- mode: CheckoutMode;
138
- outcomeDeadlineMs?: number;
139
- challengeHoldMs?: number;
140
- onChallengeHold?: (signal: string | null) => void;
141
- resolveEmailOtp?: OtpResolver;
142
- };
143
- export type SubmitCandidateMeta = {
144
- label: string;
145
- ariaHidden: boolean;
146
- tabIndex: number | null;
147
- visible: boolean;
148
- area: number;
149
- };
150
- export declare function preferredSubmitIndex(cands: readonly SubmitCandidateMeta[], opts?: {
151
- allowDeferred?: boolean;
152
- }): number;
153
- export declare function snapshotOrigin(rawUrl: string): string;
154
- export type PreparedCheckoutSession = {
155
- checkout: PreparedCheckout;
156
- context: BrowserContext;
157
- page: Page;
158
- options: PrepareCheckoutOptions;
159
- evidence: EvidenceLog;
160
- fields: FieldMap;
161
- requiresAdapter: Set<string>;
162
- };
163
- export type PreparedCheckoutSessionStore = {
164
- put: (reviewId: string, state: PreparedCheckoutSession) => void;
165
- take: (reviewId: string) => PreparedCheckoutSession | undefined;
166
- peek: (reviewId: string) => PreparedCheckoutSession | undefined;
167
- pendingCleanupReviewIds: () => readonly string[];
168
- reapExpired: (nowMs?: number) => Promise<number>;
169
- dispose: () => Promise<void>;
170
- };
171
- export type InMemoryPreparedCheckoutStoreOptions = {
172
- ttlMs?: number;
173
- cleanupRetryMs?: number;
174
- now?: () => number;
175
- };
176
- export declare const DEFAULT_PREPARED_CHECKOUT_TTL_MS: number;
177
- export declare const DEFAULT_PREPARED_CHECKOUT_CLEANUP_RETRY_MS = 5000;
178
- export declare class InMemoryPreparedCheckoutStore implements PreparedCheckoutSessionStore {
179
- private readonly entries;
180
- private readonly cleanupPending;
181
- private readonly ttlMs;
182
- private readonly cleanupRetryMs;
183
- private readonly now;
184
- private reaper;
185
- constructor(options?: InMemoryPreparedCheckoutStoreOptions);
186
- put(reviewId: string, state: PreparedCheckoutSession): void;
187
- take(reviewId: string): PreparedCheckoutSession | undefined;
188
- peek(reviewId: string): PreparedCheckoutSession | undefined;
189
- pendingCleanupReviewIds(): readonly string[];
190
- reapExpired(nowMs?: number): Promise<number>;
191
- dispose(): Promise<void>;
192
- private queueCleanup;
193
- private scheduleReaper;
194
- private closeState;
195
- }
196
- export type TrustedOriginVerdict = Readonly<{
197
- code: MandateRefusalCode;
198
- reason: string;
199
- }>;
200
- export declare function trustedMerchantOriginVerdict(options: PrepareCheckoutOptions, pageUrl: string, expectedOrigin?: string): TrustedOriginVerdict | null;
201
- export declare function trustedMerchantOriginRefusal(options: PrepareCheckoutOptions, pageUrl: string, expectedOrigin?: string): string | null;
202
- /**
203
- * Bind the storefront a trusted UCP continuation actually lands on (#8669).
204
- *
205
- * The merchant published its UCP business profile at its own business origin
206
- * and declared the permanent `*.myshopify.com` service that issued the
207
- * continuation; the CLI verified both before minting the handoff. That is
208
- * independently verified merchant provenance, so the review may bind the final
209
- * page origin when, and only when: the navigation started on that declared
210
- * myshopify origin, the final origin is plain HTTPS, and its host is the
211
- * declared business host modulo a leading `www.` label. The redirect chain in
212
- * between (Shopify's primary-domain hop, its shop.app bounce, #8496) carries no
213
- * authority either way: a redirect cannot land on the merchant's own business
214
- * domain unless the merchant controls it, and any other final host stays an
215
- * undeclared origin. Shopify's `primary_domain_redirection` proof is recorded
216
- * as evidence when present but is not required.
217
- */
218
- export declare function trustedShopifyAliasOrigin(args: {
219
- allowedOrigins: readonly string[];
220
- initialUrl: string;
221
- finalUrl: string;
222
- redirects: readonly NavigationRedirectEvidence[];
223
- }): string | null;
224
- export declare function reconcileHeldOutcome(original: ObservedOutcome, held: ObservedOutcome): ObservedOutcome;
225
- export declare function debugShotMaskPlan(fields: FieldMap): {
226
- skipReason: string | null;
227
- maskLocators: string[];
228
- maskFrames: {
229
- frame: string;
230
- locator: string;
231
- }[];
232
- };
233
- export declare function isStripeLinkConsumerRequest(url: string): boolean;
234
- export declare function suppressStripeLink(page: Page, evidence: EvidenceLog): Promise<void>;
235
- export type LinkQuietResult = {
236
- fired: boolean;
237
- waitedMs: number;
238
- };
239
- /**
240
- * Wait for the suppressed Stripe Link lookup to fire and settle BEFORE the
241
- * submit click. Stripe debounces its consumer-session lookup ~300ms after the
242
- * email input changes; our fill→click gap is single-digit ms, so the (aborted)
243
- * lookup used to land INSIDE Stripe's in-flight submit chain and kill it
244
- * silently — the click looked accepted but tokenization never ran and the page
245
- * sat on the form until the outcome deadline (#5879: three identical live
246
- * stalls at donate.stripe.com). Verified live A/B on that page: instant click →
247
- * dead submit, no /v1/payment_methods; lookup settled first → tokenization and
248
- * the confirm step both reached.
249
- *
250
- * If the lookup already fired, only the short settle applies (lets Stripe's
251
- * abort handling unwind). If it never fires — non-Link page variants, no email
252
- * field — the bound expires and the click proceeds as before.
253
- */
254
- export declare function waitForLinkLookupQuiet(page: Page, opts?: {
255
- boundMs?: number;
256
- settleMs?: number;
257
- delay?: (ms: number) => Promise<void>;
258
- }): Promise<LinkQuietResult>;
259
- export declare function prepareCheckout(opts: PrepareCheckoutOptions, store?: PreparedCheckoutSessionStore): Promise<PrepareCheckoutResult>;
260
- export declare function submitApprovedCheckout(reviewId: string, opts: SubmitApprovedCheckoutOptions, store?: PreparedCheckoutSessionStore): Promise<CheckoutResult>;
261
- export declare function cancelPreparedCheckout(reviewId: string, detail?: string, store?: PreparedCheckoutSessionStore): Promise<CheckoutResult>;
262
- export declare function runCheckout(opts: RunCheckoutOptions, store?: PreparedCheckoutSessionStore): Promise<CheckoutResult>;