@visa/cli 4.1.0-rc.25 → 4.1.0-rc.3

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 (63) hide show
  1. package/dist/cli.js +295 -364
  2. package/dist/mcp-server/index.js +148 -148
  3. package/native/bin/win32-x64/visa-keychain-win.exe +0 -0
  4. package/package.json +3 -5
  5. package/server.json +2 -2
  6. package/dist/checkout-engine/adapters/generic.d.ts +0 -19
  7. package/dist/checkout-engine/adapters/generic.js +0 -201
  8. package/dist/checkout-engine/adapters/index.d.ts +0 -7
  9. package/dist/checkout-engine/adapters/index.js +0 -17
  10. package/dist/checkout-engine/adapters/stripe-like.d.ts +0 -10
  11. package/dist/checkout-engine/adapters/stripe-like.js +0 -21
  12. package/dist/checkout-engine/browser-launch.d.ts +0 -46
  13. package/dist/checkout-engine/browser-launch.js +0 -81
  14. package/dist/checkout-engine/ceremony.d.ts +0 -64
  15. package/dist/checkout-engine/ceremony.js +0 -261
  16. package/dist/checkout-engine/cli-engine.d.ts +0 -60
  17. package/dist/checkout-engine/cli-engine.js +0 -242
  18. package/dist/checkout-engine/detect.d.ts +0 -61
  19. package/dist/checkout-engine/detect.js +0 -372
  20. package/dist/checkout-engine/evidence.d.ts +0 -22
  21. package/dist/checkout-engine/evidence.js +0 -59
  22. package/dist/checkout-engine/executor.d.ts +0 -172
  23. package/dist/checkout-engine/executor.js +0 -1233
  24. package/dist/checkout-engine/hosted-approval.d.ts +0 -78
  25. package/dist/checkout-engine/hosted-approval.js +0 -171
  26. package/dist/checkout-engine/index.d.ts +0 -3
  27. package/dist/checkout-engine/index.js +0 -5
  28. package/dist/checkout-engine/inline-target.d.ts +0 -13
  29. package/dist/checkout-engine/inline-target.js +0 -37
  30. package/dist/checkout-engine/instrument.d.ts +0 -54
  31. package/dist/checkout-engine/instrument.js +0 -83
  32. package/dist/checkout-engine/live-fill-approval.d.ts +0 -52
  33. package/dist/checkout-engine/live-fill-approval.js +0 -107
  34. package/dist/checkout-engine/mandate.d.ts +0 -25
  35. package/dist/checkout-engine/mandate.js +0 -100
  36. package/dist/checkout-engine/outcome.d.ts +0 -30
  37. package/dist/checkout-engine/outcome.js +0 -190
  38. package/dist/checkout-engine/owner-only-file.d.ts +0 -10
  39. package/dist/checkout-engine/owner-only-file.js +0 -22
  40. package/dist/checkout-engine/package.json +0 -3
  41. package/dist/checkout-engine/pay-args.d.ts +0 -14
  42. package/dist/checkout-engine/pay-args.js +0 -44
  43. package/dist/checkout-engine/pay.d.ts +0 -1
  44. package/dist/checkout-engine/pay.js +0 -13
  45. package/dist/checkout-engine/receipt.d.ts +0 -81
  46. package/dist/checkout-engine/receipt.js +0 -109
  47. package/dist/checkout-engine/repo-env.d.ts +0 -11
  48. package/dist/checkout-engine/repo-env.js +0 -23
  49. package/dist/checkout-engine/run-live-fill.d.ts +0 -1
  50. package/dist/checkout-engine/run-live-fill.js +0 -443
  51. package/dist/checkout-engine/types.d.ts +0 -26
  52. package/dist/checkout-engine/types.js +0 -2
  53. package/dist/checkout-engine/vgs-gateway/fetch-credential.d.mts +0 -74
  54. package/dist/checkout-engine/vgs-gateway/fetch-credential.mjs +0 -248
  55. package/dist/checkout-engine/vgs-gateway/server-mint-client.d.ts +0 -49
  56. package/dist/checkout-engine/vgs-gateway/server-mint-client.js +0 -150
  57. package/dist/checkout-engine/vgs-live-instrument.d.ts +0 -141
  58. package/dist/checkout-engine/vgs-live-instrument.js +0 -252
  59. package/dist/checkout-engine/vic-confirmation.d.ts +0 -34
  60. package/dist/checkout-engine/vic-confirmation.js +0 -39
  61. package/dist/skills/pair-visa-agent/RUNTIMES.md +0 -79
  62. package/dist/skills/pair-visa-agent/SKILL.md +0 -360
  63. package/dist/skills/pair-visa-agent/scripts/setup.mjs +0 -48
@@ -1,252 +0,0 @@
1
- /**
2
- * Our fail-closed freshness bound, matching the runner's 15-minute checkout
3
- * review window — NOT a claim about VGS's actual assurance TTL (unpublished).
4
- * The only proven-working configuration mints the intent right after the
5
- * ceremony; anything older is refused before an intent is created.
6
- */
7
- export const PURCHASE_ASSURANCE_MAX_AGE_MS = 15 * 60 * 1000;
8
- /** Tolerated forward clock skew on `mintedAt` before it is treated as invalid. */
9
- const PURCHASE_ASSURANCE_MAX_SKEW_MS = 2 * 60 * 1000;
10
- export function decimalToMinor(value) {
11
- // JSON files routinely carry a number where the contract says decimal string
12
- // ("transactionAmount": 5): refuse non-strings HERE so every caller surfaces
13
- // its scoped invalid/mismatch remedy instead of a raw TypeError crash.
14
- if (typeof value !== 'string')
15
- return null;
16
- if (!/^\d+(\.\d{1,2})?$/.test(value))
17
- return null;
18
- const [whole, fraction = ''] = value.split('.');
19
- const minor = Number(whole) * 100 + Number(fraction.padEnd(2, '0'));
20
- return Number.isSafeInteger(minor) ? minor : null;
21
- }
22
- function validateTarget(reference, ctx) {
23
- if (typeof reference.merchantName !== 'string' ||
24
- typeof reference.merchantCountryCode !== 'string' ||
25
- !reference.merchantName.trim() ||
26
- !/^[A-Z]{2}$/.test(reference.merchantCountryCode)) {
27
- throw new Error('VGS checkout reference merchant name/country is invalid');
28
- }
29
- let referenceHost;
30
- try {
31
- referenceHost = new URL(reference.merchantUrl).hostname;
32
- }
33
- catch {
34
- throw new Error('VGS checkout reference merchant URL is invalid');
35
- }
36
- if (referenceHost !== ctx.merchantHost) {
37
- throw new Error(`VGS credential merchant mismatch: ${referenceHost} vs ${ctx.merchantHost}`);
38
- }
39
- const amountMinor = decimalToMinor(reference.transactionAmount);
40
- if (amountMinor === null)
41
- throw new Error('VGS checkout reference amount is invalid');
42
- if (amountMinor !== ctx.amountMinor) {
43
- throw new Error(`VGS credential amount mismatch: ${amountMinor} vs ${ctx.amountMinor} minor units`);
44
- }
45
- // String() so a JSON-number currency (840) mismatches with a readable
46
- // message instead of crashing on .toUpperCase().
47
- const currency = String(reference.transactionCurrencyCode).toUpperCase();
48
- if (currency !== ctx.currency) {
49
- throw new Error(`VGS credential currency mismatch: ${currency} vs ${ctx.currency}`);
50
- }
51
- }
52
- function validateCliCredential(value) {
53
- if (typeof value.tokenId !== 'string' || !value.tokenId.trim()) {
54
- throw new Error('CLI agent credential requires tokenId');
55
- }
56
- // Deliberately no assuranceData requirement: the artifact's enrollment-time
57
- // assurance is identity/enrollment material and is never read here (#5709).
58
- }
59
- /**
60
- * Refuse to mint an intent unless the assurance is fresh and its declared
61
- * scope matches the checkout target exactly. `now` is injectable so the
62
- * freshness rules are testable with a pinned clock (same pattern as
63
- * validateCredential).
64
- */
65
- export function validatePurchaseAssurance(value, target, now = new Date()) {
66
- const remedy = 'run a fresh device-binding ceremony scoped to this exact merchant, amount, and ' +
67
- 'currency, and pass its output via --purchase-assurance-file (#5709)';
68
- if (value == null || typeof value !== 'object') {
69
- throw new Error(`purchase assurance is missing — ${remedy}`);
70
- }
71
- if (value.assuranceData == null) {
72
- throw new Error(`purchase assurance requires assuranceData — ${remedy}`);
73
- }
74
- const mintedAtMs = typeof value.mintedAt === 'string' ? Date.parse(value.mintedAt) : NaN;
75
- if (!Number.isFinite(mintedAtMs)) {
76
- throw new Error(`purchase assurance requires an ISO 8601 mintedAt — ${remedy}`);
77
- }
78
- const age = now.getTime() - mintedAtMs;
79
- if (age < -PURCHASE_ASSURANCE_MAX_SKEW_MS) {
80
- throw new Error(`purchase assurance mintedAt is in the future — ${remedy}`);
81
- }
82
- if (age > PURCHASE_ASSURANCE_MAX_AGE_MS) {
83
- throw new Error(`purchase assurance is stale (minted ${value.mintedAt}, limit ` +
84
- `${PURCHASE_ASSURANCE_MAX_AGE_MS / 60000} minutes) — ${remedy}`);
85
- }
86
- let targetHost;
87
- try {
88
- targetHost = new URL(target.merchantUrl).hostname;
89
- }
90
- catch {
91
- throw new Error('VGS checkout reference merchant URL is invalid');
92
- }
93
- if (value.merchantHost !== targetHost) {
94
- throw new Error(`purchase assurance merchant mismatch: ${value.merchantHost} vs ${targetHost} — ${remedy}`);
95
- }
96
- const assuranceMinor = decimalToMinor(value.transactionAmount);
97
- const targetMinor = decimalToMinor(target.transactionAmount);
98
- if (assuranceMinor === null || assuranceMinor !== targetMinor) {
99
- throw new Error(`purchase assurance amount mismatch: ${value.transactionAmount} vs ` +
100
- `${target.transactionAmount} — ${remedy}`);
101
- }
102
- if (typeof value.transactionCurrencyCode !== 'string' ||
103
- value.transactionCurrencyCode.toUpperCase() !==
104
- String(target.transactionCurrencyCode).toUpperCase()) {
105
- throw new Error(`purchase assurance currency mismatch: ${value.transactionCurrencyCode} vs ` +
106
- `${target.transactionCurrencyCode} — ${remedy}`);
107
- }
108
- }
109
- // `now` is injectable so expiry rules are testable with a pinned clock.
110
- export function validateCredential(value, now = new Date()) {
111
- if (!/^\d{12,19}$/.test(value.networkToken)) {
112
- throw new Error('VGS credential network token must contain 12-19 digits');
113
- }
114
- if (!/^\d{3,4}$/.test(value.cryptogramValue)) {
115
- throw new Error('VGS credential short DAVV must contain 3-4 digits');
116
- }
117
- if (typeof value.cryptogramType !== 'string' || value.cryptogramType.toUpperCase() !== 'DAVV') {
118
- throw new Error(`VGS credential type ${value.cryptogramType || '<missing>'} is not DAVV`);
119
- }
120
- if (!Number.isInteger(value.expMonth) || value.expMonth < 1 || value.expMonth > 12) {
121
- throw new Error('VGS credential expiration month is invalid');
122
- }
123
- if (!Number.isInteger(value.expYear) ||
124
- value.expYear < now.getFullYear() ||
125
- (value.expYear === now.getFullYear() && value.expMonth < now.getMonth() + 1)) {
126
- throw new Error('VGS credential is expired');
127
- }
128
- if (value.cryptogramExpiresAt !== undefined) {
129
- const expiresAtMs = Date.parse(value.cryptogramExpiresAt);
130
- if (!Number.isFinite(expiresAtMs))
131
- throw new Error('VGS credential expiry is invalid');
132
- if (expiresAtMs - now.getTime() < 60_000) {
133
- throw new Error('VGS credential has less than 60 seconds of validity remaining');
134
- }
135
- }
136
- }
137
- /**
138
- * Mints the full DPAN + short DAVV only after the executor revalidates the
139
- * reviewed merchant, amount, and currency. The payment credential remains in
140
- * memory, is never returned to the caller, and can be requested only once.
141
- */
142
- export class VgsLiveInstrument {
143
- reference;
144
- cardholderName;
145
- fetchCredential;
146
- kind = 'agentic-token';
147
- used = false;
148
- minted = null;
149
- constructor(reference, cardholderName, fetchCredential) {
150
- this.reference = reference;
151
- this.cardholderName = cardholderName;
152
- this.fetchCredential = fetchCredential;
153
- }
154
- /**
155
- * Non-null once VGS has actually issued a credential (the intent is consumed
156
- * from that moment, even if local validation later rejects the credential) —
157
- * exactly the population a VIC confirmation can be owed for.
158
- */
159
- confirmationTarget() {
160
- return this.minted;
161
- }
162
- async getCredential(ctx) {
163
- if (this.used)
164
- throw new Error('VGS live credential instrument is single-use');
165
- this.used = true;
166
- validateTarget(this.reference, ctx);
167
- if (!this.reference.tokenId || !this.reference.intentId) {
168
- throw new Error('VGS checkout reference requires tokenId and intentId');
169
- }
170
- if (!this.cardholderName.trim())
171
- throw new Error('cardholder name is required');
172
- const { tokenId, intentId, ...transaction } = this.reference;
173
- const value = await this.fetchCredential({ tokenId, intentId, transaction });
174
- this.minted = { tokenId, intentId };
175
- try {
176
- validateCredential(value);
177
- }
178
- catch (err) {
179
- // VGS already issued a cryptogram for this intent even though we refuse
180
- // to fill it; "correct inputs and retry" would silently reuse a consumed
181
- // intent, so steer the operator to a fresh one.
182
- throw new Error(`${err.message} — a credential was issued by VGS but rejected locally; obtain a fresh intent before retrying`);
183
- }
184
- return {
185
- pan: value.networkToken,
186
- expMonth: value.expMonth,
187
- expYear: value.expYear,
188
- cvc: value.cryptogramValue,
189
- cardholderName: this.cardholderName.trim(),
190
- ...(value.cryptogramExpiresAt ? { credentialExpiresAt: value.cryptogramExpiresAt } : {}),
191
- };
192
- }
193
- }
194
- /**
195
- * Consumes #5614's claimed CLI enrollment artifact (for the tokenId) plus a
196
- * FRESH purchase-scoped assurance, and creates a fresh, transaction-scoped VIC
197
- * intent + credential after checkout approval. This is the production-shaped
198
- * bridge; unlike VgsLiveInstrument it never needs a pre-created intent ID.
199
- *
200
- * The enrollment artifact's stored assuranceData is deliberately never sent:
201
- * replaying it makes intent creation succeed (HTTP 201) while the cryptogram
202
- * deterministically never completes — the #5709 dead end. Purchase
203
- * authorization is the fresh, merchant+amount+currency-scoped assurance,
204
- * validated against the checkout target BEFORE any intent is minted so a
205
- * doomed intent is never created.
206
- */
207
- export class VgsAssuranceInstrument {
208
- enrollment;
209
- purchase;
210
- target;
211
- cardholderName;
212
- mintCredential;
213
- kind = 'agentic-token';
214
- used = false;
215
- minted = null;
216
- constructor(enrollment, purchase, target, cardholderName, mintCredential) {
217
- this.enrollment = enrollment;
218
- this.purchase = purchase;
219
- this.target = target;
220
- this.cardholderName = cardholderName;
221
- this.mintCredential = mintCredential;
222
- }
223
- /** See VgsLiveInstrument.confirmationTarget — same contract. */
224
- confirmationTarget() {
225
- return this.minted;
226
- }
227
- async getCredential(ctx) {
228
- if (this.used)
229
- throw new Error('VGS assurance instrument is single-use');
230
- this.used = true;
231
- validateCliCredential(this.enrollment);
232
- validateTarget(this.target, ctx);
233
- validatePurchaseAssurance(this.purchase, this.target);
234
- if (!this.cardholderName.trim())
235
- throw new Error('cardholder name is required');
236
- const { payment: value, intentId } = await this.mintCredential({
237
- tokenId: this.enrollment.tokenId,
238
- assuranceData: this.purchase.assuranceData,
239
- transaction: this.target,
240
- });
241
- this.minted = { tokenId: this.enrollment.tokenId, intentId };
242
- validateCredential(value);
243
- return {
244
- pan: value.networkToken,
245
- expMonth: value.expMonth,
246
- expYear: value.expYear,
247
- cvc: value.cryptogramValue,
248
- cardholderName: this.cardholderName.trim(),
249
- ...(value.cryptogramExpiresAt ? { credentialExpiresAt: value.cryptogramExpiresAt } : {}),
250
- };
251
- }
252
- }
@@ -1,34 +0,0 @@
1
- import type { CheckoutOutcome } from './executor.js';
2
- import type { VicConfirmationTarget } from './vgs-live-instrument.js';
3
- export type VicTransactionStatus = 'APPROVED' | 'DECLINED';
4
- export type PostVicConfirmation = (input: {
5
- tokenId: string;
6
- intentId: string;
7
- transactionStatus: VicTransactionStatus;
8
- transactionType: 'PURCHASE';
9
- transactionTimestamp: string;
10
- transaction: {
11
- transactionAmount: string;
12
- transactionCurrencyCode: string;
13
- };
14
- }) => Promise<unknown>;
15
- export type VicConfirmationReport = {
16
- posted: true;
17
- transactionStatus: VicTransactionStatus;
18
- } | {
19
- posted: false;
20
- reason: string;
21
- };
22
- /** Definitive merchant answers map to a status; everything else maps to none. */
23
- export declare function outcomeToTransactionStatus(outcome: CheckoutOutcome): VicTransactionStatus | null;
24
- export declare function reportVicOutcome(input: {
25
- target: VicConfirmationTarget | null;
26
- outcome: CheckoutOutcome;
27
- transaction: {
28
- transactionAmount: string;
29
- transactionCurrencyCode: string;
30
- };
31
- post: PostVicConfirmation;
32
- /** Injectable for tests; defaults to now. */
33
- timestamp?: Date;
34
- }): Promise<VicConfirmationReport>;
@@ -1,39 +0,0 @@
1
- /** Definitive merchant answers map to a status; everything else maps to none. */
2
- export function outcomeToTransactionStatus(outcome) {
3
- if (outcome === 'confirmed')
4
- return 'APPROVED';
5
- if (outcome === 'declined')
6
- return 'DECLINED';
7
- return null;
8
- }
9
- export async function reportVicOutcome(input) {
10
- const transactionStatus = outcomeToTransactionStatus(input.outcome);
11
- if (!transactionStatus) {
12
- return {
13
- posted: false,
14
- reason: `outcome '${input.outcome}' is not a definitive merchant answer — ` +
15
- 'resolve it with the merchant, then post the confirmation manually',
16
- };
17
- }
18
- if (!input.target) {
19
- return { posted: false, reason: 'no VIC credential was minted in this run' };
20
- }
21
- try {
22
- await input.post({
23
- tokenId: input.target.tokenId,
24
- intentId: input.target.intentId,
25
- transactionStatus,
26
- transactionType: 'PURCHASE',
27
- transactionTimestamp: (input.timestamp ?? new Date()).toISOString(),
28
- transaction: input.transaction,
29
- });
30
- return { posted: true, transactionStatus };
31
- }
32
- catch (err) {
33
- return {
34
- posted: false,
35
- reason: `confirmation POST failed: ${err.message} — the merchant outcome stands; ` +
36
- 'retry the confirmation for this intent out-of-band',
37
- };
38
- }
39
- }
@@ -1,79 +0,0 @@
1
- # Running the Visa pairing skill in OpenClaw **and** Hermes
2
-
3
- `@visa/visa-cli-openclaw` is packaged for OpenClaw, but the v4 **pairing** capability
4
- (`skills/pair-visa-agent/`) is deliberately runtime-agnostic: one skill works in OpenClaw,
5
- [Hermes](https://github.com/NousResearch/hermes-agent), or any runtime that can run the
6
- `visa` CLI or mount its MCP server. This doc is the map of how the two runtimes differ and
7
- why a single skill suffices.
8
-
9
- ## The blunt fact: plugins are NOT portable
10
-
11
- | Axis | OpenClaw | Hermes (NousResearch) |
12
- | --------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
13
- | Language | **JavaScript/TypeScript** | **Python** |
14
- | Plugin manifest | `openclaw.plugin.json` + `definePluginEntry` (`index.ts`) | `~/.hermes/plugins/<name>/plugin.yaml` + `__init__.py`, `ctx.register_tool(...)` |
15
- | Config file | `~/.openclaw/openclaw.json` | `~/.hermes/config.yaml` |
16
- | Skills | markdown `SKILL.md` (+ optional UV scripts) | markdown `~/.hermes/skills/<name>/` (agent-authored + curated Skills Hub) |
17
- | MCP | `openclaw.json` → `mcp.servers.*` | `config.yaml` → `mcp_servers.*` |
18
- | Persona | `SOUL.md` | `SOUL.md` |
19
- | Migration | — | `hermes claw migrate` (v0.3.0+): imports SOUL, memory, **skills → `~/.hermes/skills/openclaw-imports/`**, allowlists, and **MCP servers** |
20
-
21
- You cannot ship one plugin binary for both — the OpenClaw JS `pair_agent_*` tools in this
22
- package do not load in Hermes. **Do not try.**
23
-
24
- ## What IS portable: markdown skills + MCP
25
-
26
- Both runtimes (a) read markdown skills natively and (b) mount MCP servers via an
27
- equivalent config block (`mcp.servers.*` ↔ `mcp_servers.*`, same `command`/`args`/`env`,
28
- same tool include/exclude). So the cross-runtime bridge is:
29
-
30
- 1. **The `visa` CLI** — `visa agent enroll|enroll-claim --format json` (piped, load-bearing
31
- exit codes). Any runtime that can execute a command can pair.
32
- 2. **The `visa` MCP server** — the bundled `dist/mcp-server/index.js` entrypoint (there is
33
- **no `visa mcp` subcommand**; `visa-cli install <client>` registers it, or configure it
34
- by hand). Mount it identically in either runtime:
35
-
36
- **OpenClaw** (`~/.openclaw/openclaw.json`):
37
-
38
- ```json
39
- {
40
- "mcp": {
41
- "servers": {
42
- "visa-cli": {
43
- "command": "node",
44
- "args": ["<npm root -g>/@visa/cli/dist/mcp-server/index.js"]
45
- }
46
- }
47
- }
48
- }
49
- ```
50
-
51
- **Hermes** (`~/.hermes/config.yaml`):
52
-
53
- ```yaml
54
- mcp_servers:
55
- visa-cli:
56
- command: node
57
- args: ['<npm root -g>/@visa/cli/dist/mcp-server/index.js']
58
- ```
59
-
60
- 3. **One `pair-visa-agent/SKILL.md`** — runtime-agnostic. It tells the agent to use
61
- whichever pairing surface is present (`pair_agent_*` OpenClaw tools → `enroll_agent`
62
- MCP tool → raw `visa agent …` CLI), all wrapping the same on-device hand-off.
63
-
64
- ## So: how each runtime gets the capability
65
-
66
- | Runtime | How it pairs |
67
- | ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
68
- | **OpenClaw** | Install this package → the JS `pair_agent_start`/`pair_agent_poll` tools + the skill. (Or just the `visa` MCP server + the skill, no plugin.) |
69
- | **Hermes** | Mount the `visa` MCP server in `config.yaml` (→ `enroll_agent`) and drop `pair-visa-agent/SKILL.md` into `~/.hermes/skills/`. `hermes claw migrate` will also import the skill from an existing OpenClaw install. No Python plugin required. |
70
- | **Anything else** | `visa` on PATH + the skill. The skill's raw-CLI path is the universal fallback. |
71
-
72
- ## Optional: a symmetric Hermes plugin
73
-
74
- Not required — Hermes users get the full capability via the MCP server + skill above. If
75
- you want the _same named tools_ (`pair_agent_start`/`pair_agent_poll`) in Hermes, a thin
76
- `~/.hermes/plugins/visa-cli/` Python plugin (`plugin.yaml` + `__init__.py`) that shells out
77
- to `visa agent enroll|enroll-claim --format json` and registers the tools via
78
- `ctx.register_tool(...)` would mirror the OpenClaw plugin. Tracked as a fast-follow; the
79
- CLI + MCP + skill already make pairing "just work" in Hermes.