@visa/cli 4.1.0-rc.145 → 4.1.0-rc.147
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.
- package/dist/checkout-engine/cli-engine.d.ts +9 -0
- package/dist/checkout-engine/cli-engine.js +21 -1
- package/dist/checkout-engine/vgs-gateway/server-mint-client.d.ts +19 -0
- package/dist/checkout-engine/vgs-gateway/server-mint-client.js +24 -1
- package/dist/cli.js +321 -321
- package/dist/mcp-server/index.js +251 -251
- package/native/bin/win32-x64/visa-keychain-win.exe +0 -0
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -16,6 +16,15 @@ import type { Contact, OtpResolver } from './types.js';
|
|
|
16
16
|
* is classified by its underlying gateway error. Exported for tests.
|
|
17
17
|
*/
|
|
18
18
|
export declare function isTransientDrawFailure(err: unknown): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* A verdict refusal may be wrapped by drawFromMandate after its local
|
|
21
|
+
* reservation is released. Walk the cause chain so the original auth status +
|
|
22
|
+
* reasons still decide whether the mandate is permanently disabled.
|
|
23
|
+
*/
|
|
24
|
+
export declare function classifyCardDrawVerdictFailure(err: unknown): {
|
|
25
|
+
transient: boolean;
|
|
26
|
+
reasons: string[];
|
|
27
|
+
} | null;
|
|
19
28
|
export type CliReviewInput = {
|
|
20
29
|
url: string;
|
|
21
30
|
amount: string;
|
|
@@ -33,6 +33,21 @@ export function isTransientDrawFailure(err) {
|
|
|
33
33
|
const msgs = [];
|
|
34
34
|
let e = err;
|
|
35
35
|
for (let i = 0; i < 5 && e; i++) {
|
|
36
|
+
// A refusal that declared itself TERMINAL wins outright, before any message
|
|
37
|
+
// matching. Message text is not a safe carrier for this decision: the mint
|
|
38
|
+
// client interpolates provider-supplied `upstream_codes` into its message
|
|
39
|
+
// for diagnosability, and an identifier like `request_timeout` would match
|
|
40
|
+
// the unanchored `tim(e|ed)-out` alternative below and silently reclassify
|
|
41
|
+
// a permanent 422 as transient — skipping markUnhonored and stranding the
|
|
42
|
+
// mandate in the retry-forever loop this classifier exists to prevent.
|
|
43
|
+
// Duck-typed rather than instanceof so it survives bundling and any
|
|
44
|
+
// re-wrapping across package boundaries. Optional chaining rather than an
|
|
45
|
+
// explicit null guard: the loop condition already proved `e` truthy, so a
|
|
46
|
+
// `e !== null` test is dead code, and `?.` stays safe on a primitive or a
|
|
47
|
+
// nullish link if that guard ever changes.
|
|
48
|
+
if (e?.terminal === true) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
36
51
|
if (e instanceof Error && typeof e.message === 'string')
|
|
37
52
|
msgs.push(e.message);
|
|
38
53
|
e = e.cause;
|
|
@@ -51,7 +66,12 @@ export function isTransientDrawFailure(err) {
|
|
|
51
66
|
* reservation is released. Walk the cause chain so the original auth status +
|
|
52
67
|
* reasons still decide whether the mandate is permanently disabled.
|
|
53
68
|
*/
|
|
54
|
-
|
|
69
|
+
// Exported for the cross-package pin in test/cli-engine.test.ts: the CLI's
|
|
70
|
+
// card-draw client decides the `status` this reads, so the two move together
|
|
71
|
+
// and a test that spans the boundary is the only one that would catch a drift.
|
|
72
|
+
// Not re-exported from index.ts — the public @visa/checkout-engine surface is
|
|
73
|
+
// the explicit allowlist there, same as isTransientDrawFailure above.
|
|
74
|
+
export function classifyCardDrawVerdictFailure(err) {
|
|
55
75
|
const transientReasons = new Set(['challenge_failed', 'challenge_malformed', 'verdict_refused']);
|
|
56
76
|
let current = err;
|
|
57
77
|
for (let i = 0; i < 5 && current; i++) {
|
|
@@ -17,6 +17,25 @@ export type ServerMintDeps = {
|
|
|
17
17
|
* — the mint must never throw here.
|
|
18
18
|
*/
|
|
19
19
|
export declare function merchantOrigin(url: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* A definitive refusal from the cryptogram mint route — the request will not
|
|
22
|
+
* succeed if retried unchanged.
|
|
23
|
+
*
|
|
24
|
+
* `terminal` is the load-bearing field. Draw terminality used to be decided by
|
|
25
|
+
* regex over the error MESSAGE, which made it hostage to text nobody controls:
|
|
26
|
+
* this client now interpolates the provider's own `upstream_codes` into the
|
|
27
|
+
* message for diagnosability, and a provider identifier such as
|
|
28
|
+
* `request_timeout` would match the transient matcher's unanchored
|
|
29
|
+
* `tim(e|ed)-out` alternative — flipping a permanent 422 back to "transient",
|
|
30
|
+
* skipping markUnhonored, and stranding the mandate in the exact retry-forever
|
|
31
|
+
* loop this whole change exists to kill. Terminality is therefore carried
|
|
32
|
+
* structurally, and consumers must consult it BEFORE any message matching.
|
|
33
|
+
*/
|
|
34
|
+
export declare class ServerCryptogramRefusedError extends Error {
|
|
35
|
+
readonly status: number;
|
|
36
|
+
readonly terminal: true;
|
|
37
|
+
constructor(status: number, detail: string);
|
|
38
|
+
}
|
|
20
39
|
/**
|
|
21
40
|
* Optional mandate override for serverCreateIntent. Absent → the historical
|
|
22
41
|
* 1:1 fresh-tap shape is preserved byte-for-byte (cap = ceil(amount)+10 min 25,
|
|
@@ -40,6 +40,29 @@ export function merchantOrigin(url) {
|
|
|
40
40
|
return url;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* A definitive refusal from the cryptogram mint route — the request will not
|
|
45
|
+
* succeed if retried unchanged.
|
|
46
|
+
*
|
|
47
|
+
* `terminal` is the load-bearing field. Draw terminality used to be decided by
|
|
48
|
+
* regex over the error MESSAGE, which made it hostage to text nobody controls:
|
|
49
|
+
* this client now interpolates the provider's own `upstream_codes` into the
|
|
50
|
+
* message for diagnosability, and a provider identifier such as
|
|
51
|
+
* `request_timeout` would match the transient matcher's unanchored
|
|
52
|
+
* `tim(e|ed)-out` alternative — flipping a permanent 422 back to "transient",
|
|
53
|
+
* skipping markUnhonored, and stranding the mandate in the exact retry-forever
|
|
54
|
+
* loop this whole change exists to kill. Terminality is therefore carried
|
|
55
|
+
* structurally, and consumers must consult it BEFORE any message matching.
|
|
56
|
+
*/
|
|
57
|
+
export class ServerCryptogramRefusedError extends Error {
|
|
58
|
+
status;
|
|
59
|
+
terminal = true;
|
|
60
|
+
constructor(status, detail) {
|
|
61
|
+
super(`server cryptogram refused (${status}): ${detail}`);
|
|
62
|
+
this.name = 'ServerCryptogramRefusedError';
|
|
63
|
+
this.status = status;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
43
66
|
/** Read a stable, non-secret error message from a route's JSON body. */
|
|
44
67
|
async function routeError(res) {
|
|
45
68
|
const doc = (await res.json().catch(() => null));
|
|
@@ -165,7 +188,7 @@ export async function serverFetchCryptogram(base, mintToken, input, deps = {}) {
|
|
|
165
188
|
// healthy mandate. The route maps upstream rate limits to 503 today, so this
|
|
166
189
|
// is a guard against a future emitter, not a live path.
|
|
167
190
|
if (res.status >= 400 && res.status < 500 && res.status !== 429) {
|
|
168
|
-
throw new
|
|
191
|
+
throw new ServerCryptogramRefusedError(res.status, await routeError(res));
|
|
169
192
|
}
|
|
170
193
|
lastError = `${res.status}: ${await routeError(res)}`;
|
|
171
194
|
if (attempt < attempts)
|