@visa/cli 4.1.0-rc.6 → 4.1.0-rc.61

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 (70) hide show
  1. package/README.md +168 -235
  2. package/dist/checkout-engine/adapters/generic.d.ts +23 -0
  3. package/dist/checkout-engine/adapters/generic.js +216 -0
  4. package/dist/checkout-engine/adapters/index.d.ts +8 -0
  5. package/dist/checkout-engine/adapters/index.js +21 -0
  6. package/dist/checkout-engine/adapters/shopify.d.ts +31 -0
  7. package/dist/checkout-engine/adapters/shopify.js +423 -0
  8. package/dist/checkout-engine/adapters/stripe-like.d.ts +10 -0
  9. package/dist/checkout-engine/adapters/stripe-like.js +21 -0
  10. package/dist/checkout-engine/amount.d.ts +15 -0
  11. package/dist/checkout-engine/amount.js +72 -0
  12. package/dist/checkout-engine/browser-launch.d.ts +46 -0
  13. package/dist/checkout-engine/browser-launch.js +81 -0
  14. package/dist/checkout-engine/ceremony.d.ts +64 -0
  15. package/dist/checkout-engine/ceremony.js +261 -0
  16. package/dist/checkout-engine/cli-engine.d.ts +200 -0
  17. package/dist/checkout-engine/cli-engine.js +659 -0
  18. package/dist/checkout-engine/detect.d.ts +61 -0
  19. package/dist/checkout-engine/detect.js +398 -0
  20. package/dist/checkout-engine/evidence.d.ts +25 -0
  21. package/dist/checkout-engine/evidence.js +104 -0
  22. package/dist/checkout-engine/executor.d.ts +176 -0
  23. package/dist/checkout-engine/executor.js +1322 -0
  24. package/dist/checkout-engine/hosted-approval.d.ts +142 -0
  25. package/dist/checkout-engine/hosted-approval.js +339 -0
  26. package/dist/checkout-engine/index.d.ts +6 -0
  27. package/dist/checkout-engine/index.js +8 -0
  28. package/dist/checkout-engine/inline-target.d.ts +13 -0
  29. package/dist/checkout-engine/inline-target.js +37 -0
  30. package/dist/checkout-engine/instrument.d.ts +61 -0
  31. package/dist/checkout-engine/instrument.js +87 -0
  32. package/dist/checkout-engine/live-fill-approval.d.ts +43 -0
  33. package/dist/checkout-engine/live-fill-approval.js +90 -0
  34. package/dist/checkout-engine/mandate/card-mandate.d.ts +121 -0
  35. package/dist/checkout-engine/mandate/card-mandate.js +227 -0
  36. package/dist/checkout-engine/mandate/mandate-ledger.d.ts +142 -0
  37. package/dist/checkout-engine/mandate/mandate-ledger.js +335 -0
  38. package/dist/checkout-engine/mandate.d.ts +25 -0
  39. package/dist/checkout-engine/mandate.js +100 -0
  40. package/dist/checkout-engine/outcome.d.ts +30 -0
  41. package/dist/checkout-engine/outcome.js +225 -0
  42. package/dist/checkout-engine/owner-only-file.d.ts +19 -0
  43. package/dist/checkout-engine/owner-only-file.js +41 -0
  44. package/dist/checkout-engine/package.json +3 -0
  45. package/dist/checkout-engine/receipt.d.ts +81 -0
  46. package/dist/checkout-engine/receipt.js +109 -0
  47. package/dist/checkout-engine/repo-env.d.ts +11 -0
  48. package/dist/checkout-engine/repo-env.js +23 -0
  49. package/dist/checkout-engine/trace-handles.d.ts +8 -0
  50. package/dist/checkout-engine/trace-handles.js +12 -0
  51. package/dist/checkout-engine/types.d.ts +44 -0
  52. package/dist/checkout-engine/types.js +2 -0
  53. package/dist/checkout-engine/vgs-gateway/fetch-credential.d.mts +74 -0
  54. package/dist/checkout-engine/vgs-gateway/fetch-credential.mjs +248 -0
  55. package/dist/checkout-engine/vgs-gateway/server-mint-client.d.ts +82 -0
  56. package/dist/checkout-engine/vgs-gateway/server-mint-client.js +180 -0
  57. package/dist/checkout-engine/vgs-live-instrument.d.ts +170 -0
  58. package/dist/checkout-engine/vgs-live-instrument.js +293 -0
  59. package/dist/checkout-engine/vic-confirmation.d.ts +34 -0
  60. package/dist/checkout-engine/vic-confirmation.js +39 -0
  61. package/dist/cli.js +391 -427
  62. package/dist/mcp-server/index.js +312 -163
  63. package/dist/skills/pair-visa-agent/RUNTIMES.md +92 -0
  64. package/dist/skills/pair-visa-agent/SKILL.md +315 -0
  65. package/dist/skills/pair-visa-agent/scripts/setup.mjs +48 -0
  66. package/install.ps1 +3 -41
  67. package/install.sh +3 -35
  68. package/native/bin/win32-x64/visa-keychain-win.exe +0 -0
  69. package/package.json +11 -7
  70. package/server.json +3 -3
@@ -0,0 +1,176 @@
1
+ import type { Browser, BrowserContext, Page } from 'playwright-core';
2
+ import { type FieldMap } from './detect.js';
3
+ import { type Mandate } 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
+ export { minorFromDecimal, pageCurrency } from './amount.js';
9
+ export type CheckoutMode = 'dry-run' | 'submit';
10
+ export type CheckoutOutcome = 'reviewed-dry-run'
11
+ /** Historical receipt value from the credential-disclosing dry-run. */
12
+ | 'filled-dry-run' | 'partial-fill' | 'adapter-required' | 'confirmed' | 'declined' | 'action-required' | 'cancelled' | 'blocked-by-mandate' | 'failed';
13
+ export type CredentialLifecycle = 'not-requested' | 'minted-not-exposed' | 'partially-exposed' | 'fully-filled';
14
+ export type CredentialTiming = {
15
+ approvedAt?: string;
16
+ credentialMintedAt?: string;
17
+ credentialExpiresAt?: string;
18
+ fillCompletedAt?: string;
19
+ };
20
+ export type CheckoutResult = {
21
+ outcome: CheckoutOutcome;
22
+ fields: FieldMap;
23
+ evidence: EvidenceLog;
24
+ confirmationRef?: string;
25
+ requiresAdapter: string[];
26
+ credentialLifecycle: CredentialLifecycle;
27
+ credentialTiming: CredentialTiming;
28
+ detail?: string;
29
+ };
30
+ export type PrepareCheckoutOptions = {
31
+ url: string;
32
+ mandate: Mandate;
33
+ browser: Browser;
34
+ contact?: Contact;
35
+ amountMinor?: number;
36
+ currency?: string;
37
+ debugShotsDir?: string;
38
+ };
39
+ export type RunCheckoutOptions = PrepareCheckoutOptions & {
40
+ instrument: Instrument;
41
+ contact: Contact;
42
+ mode: CheckoutMode;
43
+ outcomeDeadlineMs?: number;
44
+ resolveEmailOtp?: OtpResolver;
45
+ };
46
+ export type CheckoutReview = {
47
+ id: string;
48
+ url: string;
49
+ merchantHost: string;
50
+ amountMinor: number;
51
+ currency: string;
52
+ mandateMaxAmountMinor: number;
53
+ mandateExpiresAt: string;
54
+ submitTarget: string | null;
55
+ submitTargetFingerprint: Readonly<CheckoutSubmitTargetFingerprint> | null;
56
+ detectedRoles: readonly string[];
57
+ };
58
+ export type CheckoutSubmitTargetFingerprint = {
59
+ kind: 'submit-control' | 'text-button';
60
+ label: string;
61
+ elementTag: string;
62
+ elementId: string | null;
63
+ elementName: string | null;
64
+ elementType: string | null;
65
+ formAction: string | null;
66
+ formMethod: string | null;
67
+ formTarget: string | null;
68
+ };
69
+ export type PreparedCheckout = {
70
+ readonly review: Readonly<CheckoutReview>;
71
+ readonly fields: Readonly<FieldMap>;
72
+ readonly evidence: EvidenceLog;
73
+ readonly requiresAdapter: readonly string[];
74
+ };
75
+ export type PrepareCheckoutResult = {
76
+ status: 'ready';
77
+ checkout: PreparedCheckout;
78
+ } | {
79
+ status: 'finished';
80
+ result: CheckoutResult;
81
+ };
82
+ export type CheckoutApproval = {
83
+ approved: true;
84
+ reviewId: string;
85
+ };
86
+ export type SubmitApprovedCheckoutOptions = {
87
+ approval: CheckoutApproval;
88
+ instrument: Instrument;
89
+ contact: Contact;
90
+ mode: CheckoutMode;
91
+ outcomeDeadlineMs?: number;
92
+ challengeHoldMs?: number;
93
+ onChallengeHold?: (signal: string | null) => void;
94
+ resolveEmailOtp?: OtpResolver;
95
+ };
96
+ export type PreparedCheckoutSession = {
97
+ checkout: PreparedCheckout;
98
+ context: BrowserContext;
99
+ page: Page;
100
+ options: PrepareCheckoutOptions;
101
+ evidence: EvidenceLog;
102
+ fields: FieldMap;
103
+ requiresAdapter: Set<string>;
104
+ };
105
+ export type PreparedCheckoutSessionStore = {
106
+ put: (reviewId: string, state: PreparedCheckoutSession) => void;
107
+ take: (reviewId: string) => PreparedCheckoutSession | undefined;
108
+ peek: (reviewId: string) => PreparedCheckoutSession | undefined;
109
+ pendingCleanupReviewIds: () => readonly string[];
110
+ reapExpired: (nowMs?: number) => Promise<number>;
111
+ dispose: () => Promise<void>;
112
+ };
113
+ export type InMemoryPreparedCheckoutStoreOptions = {
114
+ ttlMs?: number;
115
+ cleanupRetryMs?: number;
116
+ now?: () => number;
117
+ };
118
+ export declare const DEFAULT_PREPARED_CHECKOUT_TTL_MS: number;
119
+ export declare const DEFAULT_PREPARED_CHECKOUT_CLEANUP_RETRY_MS = 5000;
120
+ export declare class InMemoryPreparedCheckoutStore implements PreparedCheckoutSessionStore {
121
+ private readonly entries;
122
+ private readonly cleanupPending;
123
+ private readonly ttlMs;
124
+ private readonly cleanupRetryMs;
125
+ private readonly now;
126
+ private reaper;
127
+ constructor(options?: InMemoryPreparedCheckoutStoreOptions);
128
+ put(reviewId: string, state: PreparedCheckoutSession): void;
129
+ take(reviewId: string): PreparedCheckoutSession | undefined;
130
+ peek(reviewId: string): PreparedCheckoutSession | undefined;
131
+ pendingCleanupReviewIds(): readonly string[];
132
+ reapExpired(nowMs?: number): Promise<number>;
133
+ dispose(): Promise<void>;
134
+ private queueCleanup;
135
+ private scheduleReaper;
136
+ private closeState;
137
+ }
138
+ export declare function reconcileHeldOutcome(original: ObservedOutcome, held: ObservedOutcome): ObservedOutcome;
139
+ export declare function debugShotMaskPlan(fields: FieldMap): {
140
+ skipReason: string | null;
141
+ maskLocators: string[];
142
+ maskFrames: {
143
+ frame: string;
144
+ locator: string;
145
+ }[];
146
+ };
147
+ export declare function isStripeLinkConsumerRequest(url: string): boolean;
148
+ export declare function suppressStripeLink(page: Page, evidence: EvidenceLog): Promise<void>;
149
+ export type LinkQuietResult = {
150
+ fired: boolean;
151
+ waitedMs: number;
152
+ };
153
+ /**
154
+ * Wait for the suppressed Stripe Link lookup to fire and settle BEFORE the
155
+ * submit click. Stripe debounces its consumer-session lookup ~300ms after the
156
+ * email input changes; our fill→click gap is single-digit ms, so the (aborted)
157
+ * lookup used to land INSIDE Stripe's in-flight submit chain and kill it
158
+ * silently — the click looked accepted but tokenization never ran and the page
159
+ * sat on the form until the outcome deadline (#5879: three identical live
160
+ * stalls at donate.stripe.com). Verified live A/B on that page: instant click →
161
+ * dead submit, no /v1/payment_methods; lookup settled first → tokenization and
162
+ * the confirm step both reached.
163
+ *
164
+ * If the lookup already fired, only the short settle applies (lets Stripe's
165
+ * abort handling unwind). If it never fires — non-Link page variants, no email
166
+ * field — the bound expires and the click proceeds as before.
167
+ */
168
+ export declare function waitForLinkLookupQuiet(page: Page, opts?: {
169
+ boundMs?: number;
170
+ settleMs?: number;
171
+ delay?: (ms: number) => Promise<void>;
172
+ }): Promise<LinkQuietResult>;
173
+ export declare function prepareCheckout(opts: PrepareCheckoutOptions, store?: PreparedCheckoutSessionStore): Promise<PrepareCheckoutResult>;
174
+ export declare function submitApprovedCheckout(reviewId: string, opts: SubmitApprovedCheckoutOptions, store?: PreparedCheckoutSessionStore): Promise<CheckoutResult>;
175
+ export declare function cancelPreparedCheckout(reviewId: string, detail?: string, store?: PreparedCheckoutSessionStore): Promise<CheckoutResult>;
176
+ export declare function runCheckout(opts: RunCheckoutOptions, store?: PreparedCheckoutSessionStore): Promise<CheckoutResult>;