@vonpay/checkout-cli 0.9.0 → 0.10.0
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/README.md +6 -2
- package/dist/app-info.d.ts +5 -0
- package/dist/app-info.d.ts.map +1 -0
- package/dist/app-info.js +11 -0
- package/dist/app-info.js.map +1 -0
- package/dist/client-factory.d.ts.map +1 -1
- package/dist/client-factory.js +9 -4
- package/dist/client-factory.js.map +1 -1
- package/dist/commands/capabilities.js +2 -2
- package/dist/commands/capabilities.js.map +1 -1
- package/dist/commands/checkout.d.ts.map +1 -1
- package/dist/commands/checkout.js +9 -0
- package/dist/commands/checkout.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +2 -0
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/health.d.ts.map +1 -1
- package/dist/commands/health.js +11 -4
- package/dist/commands/health.js.map +1 -1
- package/dist/commands/listen.d.ts.map +1 -1
- package/dist/commands/listen.js +22 -9
- package/dist/commands/listen.js.map +1 -1
- package/dist/commands/payment-intents.d.ts.map +1 -1
- package/dist/commands/payment-intents.js +7 -7
- package/dist/commands/payment-intents.js.map +1 -1
- package/dist/commands/refunds.d.ts.map +1 -1
- package/dist/commands/refunds.js +12 -9
- package/dist/commands/refunds.js.map +1 -1
- package/dist/commands/sessions.js +3 -3
- package/dist/commands/sessions.js.map +1 -1
- package/dist/commands/tokens.js +2 -2
- package/dist/commands/tokens.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +4 -2
- package/dist/config.js.map +1 -1
- package/dist/utils/errors.d.ts +74 -1
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +127 -13
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/json-errors.d.ts +16 -0
- package/dist/utils/json-errors.d.ts.map +1 -0
- package/dist/utils/json-errors.js +41 -0
- package/dist/utils/json-errors.js.map +1 -0
- package/dist/utils/live-key.d.ts.map +1 -1
- package/dist/utils/live-key.js +3 -2
- package/dist/utils/live-key.js.map +1 -1
- package/dist/utils/spinner.d.ts +15 -0
- package/dist/utils/spinner.d.ts.map +1 -0
- package/dist/utils/spinner.js +18 -0
- package/dist/utils/spinner.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refunds.js","sourceRoot":"","sources":["../../src/commands/refunds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"refunds.js","sourceRoot":"","sources":["../../src/commands/refunds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAMzD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAcnD,iEAAiE;AACjE,SAAS,OAAO,CAAC,CAAqB;IACpC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC5C,CAAC;AAED;;;GAGG;AACH,kDAAkD;AAClD,SAAS,OAAO,CAAC,IAA0C;IACzD,MAAM,GAAG,GAAG,cAAc,EAAE;SACzB,QAAQ,CAAC,IAAI,CAAC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CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAEjD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CACxC,MAAM,EACN,IAAI,CAAC,cAAc;gBACjB,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE;gBACzC,CAAC,CAAC,SAAS,CACd,CAAC;YACF,OAAO,CAAC,IAAI,EAAE,CAAC;YAEf,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;gBAC7C,WAAW,CAAC,MAAM,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,OAAO;IACP,mBAAmB;IACnB,iBAAiB;IACjB,WAAW;CACZ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import
|
|
3
|
+
import { startSpinner } from "../utils/spinner.js";
|
|
4
4
|
import { formatMinorUnits } from "@vonpay/checkout-node";
|
|
5
5
|
import { makeCheckoutClient } from "../client-factory.js";
|
|
6
6
|
import { handleError } from "../utils/errors.js";
|
|
@@ -21,7 +21,7 @@ export function sessionsCommand() {
|
|
|
21
21
|
.option("--json", "Output raw JSON")
|
|
22
22
|
.action(async (opts) => {
|
|
23
23
|
const client = makeClient();
|
|
24
|
-
const spinner =
|
|
24
|
+
const spinner = startSpinner("Creating session...");
|
|
25
25
|
try {
|
|
26
26
|
const params = {
|
|
27
27
|
amount: opts.amount,
|
|
@@ -77,7 +77,7 @@ export function sessionsCommand() {
|
|
|
77
77
|
.option("--json", "Output raw JSON")
|
|
78
78
|
.action(async (id, opts) => {
|
|
79
79
|
const client = makeClient();
|
|
80
|
-
const spinner =
|
|
80
|
+
const spinner = startSpinner("Fetching session...");
|
|
81
81
|
try {
|
|
82
82
|
const session = await client.sessions.get(id);
|
|
83
83
|
spinner.stop();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/commands/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/commands/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAEtC,MAAM,UAAU,eAAe;IAC7B,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,WAAW,CAClD,qCAAqC,CACtC,CAAC;IAEF,QAAQ;SACL,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,+BAA+B,CAAC;SAC5C,cAAc,CA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,CAAC,kBAAkB,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC5C,OAAO,CAAC,GAAG,CAAC,kBAAkB,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBAC7D,OAAO,CAAC,GAAG,CACT,kBAAkB,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,CACvE,CAAC;gBACF,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;oBAC1B,OAAO,CAAC,GAAG,CAAC,kBAAkB,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;gBACzD,CAAC;gBACD,OAAO,CAAC,GAAG,CAAC,kBAAkB,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;gBACnD,OAAO,CAAC,GAAG,CAAC,kBAAkB,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/dist/commands/tokens.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
-
import
|
|
3
|
+
import { startSpinner } from "../utils/spinner.js";
|
|
4
4
|
import { requireApiKey } from "../config.js";
|
|
5
5
|
import { makeCheckoutClient } from "../client-factory.js";
|
|
6
6
|
import { parseMetadata } from "../utils/metadata.js";
|
|
@@ -40,7 +40,7 @@ export function tokensCommand() {
|
|
|
40
40
|
warnLiveSecretFlag(apiKey, "--provider-reference");
|
|
41
41
|
}
|
|
42
42
|
const client = makeCheckoutClient();
|
|
43
|
-
const spinner =
|
|
43
|
+
const spinner = startSpinner("Creating token...");
|
|
44
44
|
try {
|
|
45
45
|
const metadata = parseMetadata(opts.metadata);
|
|
46
46
|
const params = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/commands/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/commands/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,SAAS,UAAU,CAAC,KAAY;IAC9B,MAAM,WAAW,GACf,KAAK,CAAC,MAAM,KAAK,QAAQ;QACvB,CAAC,CAAC,KAAK,CAAC,KAAK;QACb,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS;YAC1B,CAAC,CAAC,KAAK,CAAC,MAAM;YACd,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;IAElB,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,gBAAgB,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,GAAG,CAAC,gBAAgB,KAAK,CAAC,IAAI,CAAC,KAAK,SAAS,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC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AAC,QAAQ,CAAC,CAAC;YAC9C,MAAM,MAAM,GAAsB,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;gBAAE,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;YAC9D,IAAI,IAAI,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;gBACzC,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;YACpD,CAAC;YACD,IAAI,QAAQ,KAAK,SAAS;gBAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAEvD,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CACtC,MAAM,EACN,IAAI,CAAC,cAAc;gBACjB,CAAC,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE;gBACzC,CAAC,CAAC,SAAS,CACd,CAAC;YACF,OAAO,CAAC,IAAI,EAAE,CAAC;YAEf,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC;gBAC5C,UAAU,CAAC,KAAK,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,WAAW,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC,CACF,CAAC;IAEJ,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE;QACT,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,wBAAgB,UAAU,IAAI,SAAS,CAUtC;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAQlD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,IAAI;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CAkBxD;AAED,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAO9C;AAED,wBAAgB,aAAa,IAAI,MAAM,CAStC"}
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
import { emitCliError } from "./utils/json-errors.js";
|
|
4
5
|
const CONFIG_DIR = join(homedir(), ".vonpay");
|
|
5
6
|
const CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
6
7
|
export function loadConfig() {
|
|
@@ -62,8 +63,9 @@ export function getApiKey() {
|
|
|
62
63
|
export function requireApiKey() {
|
|
63
64
|
const key = getApiKey();
|
|
64
65
|
if (!key) {
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
// Fixed text, nothing to redact.
|
|
67
|
+
const message = "No API key found. Run `vonpay checkout login` or set VON_PAY_SECRET_KEY.";
|
|
68
|
+
emitCliError({ error: message, code: null }, message);
|
|
67
69
|
}
|
|
68
70
|
return key;
|
|
69
71
|
}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,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AAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/utils/errors.d.ts
CHANGED
|
@@ -1,4 +1,77 @@
|
|
|
1
|
-
|
|
1
|
+
import { VonPayError, type SessionNotExpirableError, type SessionNotModifiableError } from "@vonpay/checkout-node";
|
|
2
|
+
/**
|
|
3
|
+
* Secret shapes redacted from anything this CLI prints about an error.
|
|
4
|
+
*
|
|
5
|
+
* ⛔ Until 0.8.0 this matched `vp_sk_*` only, so a webhook signing secret, a
|
|
6
|
+
* session-signing secret or a Stripe key inside an error message (a failed
|
|
7
|
+
* config read, a proxy echoing a header) was printed in the clear — and CLI
|
|
8
|
+
* output lands in CI logs and pasted support threads.
|
|
9
|
+
*
|
|
10
|
+
* One of the lists `tests/scripts/secret-shape-parity.test.mjs` holds to the
|
|
11
|
+
* same definition of "a secret" as the SDK telemetry blocklists, the commit
|
|
12
|
+
* gate and the scrubbers. Add a shape there and here together.
|
|
13
|
+
*
|
|
14
|
+
* Publishable keys (`vp_pk_*`, `pk_*`) are deliberately NOT redacted: they are
|
|
15
|
+
* public by design (the commit gate does not block them either), and an error
|
|
16
|
+
* naming the publishable key that was rejected is useful.
|
|
17
|
+
*
|
|
18
|
+
* `vp_sk_live_…` contains `sk_live_…`. The Vonpay pattern runs first so the
|
|
19
|
+
* key is redacted as a Vonpay key; the output (`vp_sk_***`) is the same either
|
|
20
|
+
* way, and the Stripe pattern does not match it again.
|
|
21
|
+
*/
|
|
22
|
+
export declare const SECRET_PATTERNS: ReadonlyArray<readonly [RegExp, string]>;
|
|
23
|
+
export declare function scrubSecrets(s: string): string;
|
|
24
|
+
/** Own data fields of a class instance (methods excluded). */
|
|
25
|
+
type DataKeys<T> = {
|
|
26
|
+
[K in keyof T]-?: T[K] extends (...args: never[]) => unknown ? never : K;
|
|
27
|
+
}[keyof T];
|
|
28
|
+
/** `Error`'s own fields. `message` is printed as the first line; the rest are not structured data. */
|
|
29
|
+
type ErrorBaseKeys = "name" | "message" | "stack" | "cause";
|
|
30
|
+
type StructuredField = Exclude<DataKeys<VonPayError>, ErrorBaseKeys> | Exclude<DataKeys<SessionNotExpirableError>, ErrorBaseKeys> | Exclude<DataKeys<SessionNotModifiableError>, ErrorBaseKeys>;
|
|
31
|
+
/**
|
|
32
|
+
* The structured fields, in print order. ONE list, read by both output
|
|
33
|
+
* formats: the text lines below and the `--json` object. It is the key list of
|
|
34
|
+
* `FIELD_PRINTERS`, whose mapped type makes `tsc` fail when `VonPayError` gains
|
|
35
|
+
* a field the CLI does not handle — so the JSON cannot silently drop a field
|
|
36
|
+
* the text prints, or the reverse.
|
|
37
|
+
*
|
|
38
|
+
* The MCP server's error envelope (`ERROR_ENVELOPE_FIELDS` in
|
|
39
|
+
* `@vonpay/checkout-mcp`) is held to the same set by
|
|
40
|
+
* `tests/integration/cli-mcp-error-field-parity.test.ts`. The two packages are
|
|
41
|
+
* published separately, so neither imports the other.
|
|
42
|
+
*/
|
|
43
|
+
export declare const ERROR_FIELDS: ReadonlyArray<StructuredField>;
|
|
44
|
+
/**
|
|
45
|
+
* The one JSON object printed for an error under `--json`.
|
|
46
|
+
*
|
|
47
|
+
* Every error has:
|
|
48
|
+
* - `error` — the message (always a string)
|
|
49
|
+
* - `code` — the API error code, or `null` when no API response was
|
|
50
|
+
* involved (a network failure, or a problem the CLI caught
|
|
51
|
+
* before sending anything)
|
|
52
|
+
* and an API error adds every structured field the SDK's error carries that is
|
|
53
|
+
* not `undefined` — the same fields, under the same names, as the MCP server's
|
|
54
|
+
* error envelope: `status`, `nextAction`, `retryable`, `retryWithheld`,
|
|
55
|
+
* `captureOutcome`, `voidOutcome`, … Unlike the text output, `false` values are
|
|
56
|
+
* kept: `"retryWithheld": false` is an answer.
|
|
57
|
+
*
|
|
58
|
+
* ⚠️ `code: null` on `payment-intents capture` / `void` / `create` or
|
|
59
|
+
* `refunds create` does NOT mean nothing happened: a network failure leaves
|
|
60
|
+
* the outcome unknown. Read the resource back before running it again.
|
|
61
|
+
*
|
|
62
|
+
* Nothing here can carry the API key, the idempotency key or the request body:
|
|
63
|
+
* `VonPayError` holds none of them, and any other error contributes only its
|
|
64
|
+
* message. Every string still goes through the same redaction as the text
|
|
65
|
+
* output.
|
|
66
|
+
*/
|
|
67
|
+
export declare function errorJson(err: unknown): Record<string, unknown>;
|
|
68
|
+
/**
|
|
69
|
+
* Exit 1 on a problem the CLI caught itself, before calling the API (a live
|
|
70
|
+
* key without --confirm-live, a bad flag value). In text mode `text` is
|
|
71
|
+
* printed exactly as given; under `--json` the output is
|
|
72
|
+
* `{"error": <message>, "code": null}`, redacted like everything else.
|
|
73
|
+
*/
|
|
74
|
+
export declare function exitWithCliError(message: string, text: string): never;
|
|
2
75
|
export declare function handleError(err: unknown): never;
|
|
3
76
|
export declare const __testing__: {
|
|
4
77
|
scrubSecrets: typeof scrubSecrets;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC/B,MAAM,uBAAuB,CAAC;AAG/B;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAMpE,CAAC;AAEF,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI9C;AAED,8DAA8D;AAC9D,KAAK,QAAQ,CAAC,CAAC,IAAI;KAChB,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,GAAG,KAAK,GAAG,CAAC;CACzE,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX,sGAAsG;AACtG,KAAK,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE5D,KAAK,eAAe,GAChB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,aAAa,CAAC,GAC7C,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,aAAa,CAAC,GAC1D,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAE,aAAa,CAAC,CAAC;AA6DhE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,YAAY,EAAkC,aAAa,CAAC,eAAe,CAAC,CAAC;AAyB1F;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAY/D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAErE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK,CAe/C;AAED,eAAO,MAAM,WAAW;;CAEvB,CAAC"}
|
package/dist/utils/errors.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import { VonPayError } from "@vonpay/checkout-node";
|
|
2
|
+
import { VonPayError, } from "@vonpay/checkout-node";
|
|
3
|
+
import { emitCliError, jsonErrorsEnabled, printJsonError } from "./json-errors.js";
|
|
3
4
|
/**
|
|
4
5
|
* Secret shapes redacted from anything this CLI prints about an error.
|
|
5
6
|
*
|
|
@@ -20,34 +21,147 @@ import { VonPayError } from "@vonpay/checkout-node";
|
|
|
20
21
|
* key is redacted as a Vonpay key; the output (`vp_sk_***`) is the same either
|
|
21
22
|
* way, and the Stripe pattern does not match it again.
|
|
22
23
|
*/
|
|
23
|
-
const SECRET_PATTERNS = [
|
|
24
|
+
export const SECRET_PATTERNS = [
|
|
24
25
|
[/vp_sk_(?:test|live)_[A-Za-z0-9_-]+/g, "vp_sk_***"],
|
|
25
26
|
[/ss_(?:test|live)_[A-Za-z0-9_-]+/g, "ss_***"],
|
|
26
27
|
[/whsec_[A-Za-z0-9_-]+/g, "whsec_***"],
|
|
27
28
|
[/sk_(?:test|live)_[A-Za-z0-9_-]+/g, "sk_***"],
|
|
28
29
|
[/rk_(?:test|live)_[A-Za-z0-9_-]+/g, "rk_***"],
|
|
29
30
|
];
|
|
30
|
-
function scrubSecrets(s) {
|
|
31
|
+
export function scrubSecrets(s) {
|
|
31
32
|
let out = s;
|
|
32
33
|
for (const [re, replacement] of SECRET_PATTERNS)
|
|
33
34
|
out = out.replace(re, replacement);
|
|
34
35
|
return out;
|
|
35
36
|
}
|
|
37
|
+
const str = (v) => (v === undefined || v === null ? null : String(v));
|
|
38
|
+
const FIELD_PRINTERS = {
|
|
39
|
+
code: (e) => `Code: ${str(e.code)}`,
|
|
40
|
+
fix: (e) => `Fix: ${str(e.fix)}`,
|
|
41
|
+
nextAction: (e) => (e.nextAction ? `Next action: ${str(e.nextAction)}` : null),
|
|
42
|
+
retryable: (e) => typeof e.retryable === "boolean"
|
|
43
|
+
? `Retryable: ${e.retryable ? "yes" : "no — do not re-run this command as-is"}`
|
|
44
|
+
: null,
|
|
45
|
+
retryWithheld: (e) => e.retryWithheld === true
|
|
46
|
+
? "Retry withheld: the outcome was unclear and no idempotency key was sent, so the CLI did not retry. Check whether it went through before running it again; with --idempotency-key, re-running the SAME key is safe."
|
|
47
|
+
: null,
|
|
48
|
+
captureOutcome: (e) => e.captureOutcome
|
|
49
|
+
? `Capture outcome: ${str(e.captureOutcome)} — the provider accepted the capture but it could not be recorded, so money may have moved. Do NOT capture again; read the payment intent back first.`
|
|
50
|
+
: null,
|
|
51
|
+
voidOutcome: (e) => e.voidOutcome
|
|
52
|
+
? `Void outcome: ${str(e.voidOutcome)} — the provider accepted the void but it could not be recorded. Do NOT void again or tell the buyer the hold was released until a read-back confirms it.`
|
|
53
|
+
: null,
|
|
54
|
+
currentStatus: (e) => (e.currentStatus ? `Current status: ${str(e.currentStatus)}` : null),
|
|
55
|
+
rejectReason: (e) => (e.rejectReason ? `Reject reason: ${str(e.rejectReason)}` : null),
|
|
56
|
+
paymentIntent: (e) => (e.paymentIntent ? `Payment intent: ${str(e.paymentIntent)}` : null),
|
|
57
|
+
// refund_target_is_duplicate: the SDK has already checked this is a
|
|
58
|
+
// transaction id (vp_tx_*), so it is safe to echo as a command.
|
|
59
|
+
refundInstead: (e) => e.refundInstead
|
|
60
|
+
? `Refund instead: vonpay checkout refunds create --transaction ${str(e.refundInstead)}`
|
|
61
|
+
: null,
|
|
62
|
+
reason: (e) => (e.reason ? `Reason: ${str(e.reason)}` : null),
|
|
63
|
+
session: (e) => (e.session ? `Session: ${JSON.stringify(e.session)}` : null),
|
|
64
|
+
llmHint: (e) => (e.llmHint ? `Hint: ${str(e.llmHint)}` : null),
|
|
65
|
+
docs: (e) => (e.docs ? `Docs: ${str(e.docs)}` : null),
|
|
66
|
+
status: (e) => (typeof e.status === "number" ? `HTTP status: ${e.status}` : null),
|
|
67
|
+
rateLimit: (e) => (e.rateLimit ? `Rate limit: ${JSON.stringify(e.rateLimit)}` : null),
|
|
68
|
+
requestId: (e) => (e.requestId ? `Request ID: ${str(e.requestId)}` : null),
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The structured fields, in print order. ONE list, read by both output
|
|
72
|
+
* formats: the text lines below and the `--json` object. It is the key list of
|
|
73
|
+
* `FIELD_PRINTERS`, whose mapped type makes `tsc` fail when `VonPayError` gains
|
|
74
|
+
* a field the CLI does not handle — so the JSON cannot silently drop a field
|
|
75
|
+
* the text prints, or the reverse.
|
|
76
|
+
*
|
|
77
|
+
* The MCP server's error envelope (`ERROR_ENVELOPE_FIELDS` in
|
|
78
|
+
* `@vonpay/checkout-mcp`) is held to the same set by
|
|
79
|
+
* `tests/integration/cli-mcp-error-field-parity.test.ts`. The two packages are
|
|
80
|
+
* published separately, so neither imports the other.
|
|
81
|
+
*/
|
|
82
|
+
export const ERROR_FIELDS = Object.keys(FIELD_PRINTERS);
|
|
83
|
+
/** The detail lines printed under `Error: <message>`, already scrubbed. */
|
|
84
|
+
function errorDetailLines(err) {
|
|
85
|
+
const source = err;
|
|
86
|
+
const lines = [];
|
|
87
|
+
for (const print of Object.values(FIELD_PRINTERS)) {
|
|
88
|
+
const line = print(source);
|
|
89
|
+
if (line !== null)
|
|
90
|
+
lines.push(` ${scrubSecrets(line)}`);
|
|
91
|
+
}
|
|
92
|
+
return lines;
|
|
93
|
+
}
|
|
94
|
+
/** Scrub every string inside a JSON-able value (the `session` object, for one). */
|
|
95
|
+
function scrubDeep(value) {
|
|
96
|
+
if (typeof value === "string")
|
|
97
|
+
return scrubSecrets(value);
|
|
98
|
+
if (Array.isArray(value))
|
|
99
|
+
return value.map(scrubDeep);
|
|
100
|
+
if (value !== null && typeof value === "object") {
|
|
101
|
+
const out = {};
|
|
102
|
+
for (const [k, v] of Object.entries(value))
|
|
103
|
+
out[k] = scrubDeep(v);
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
return value;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The one JSON object printed for an error under `--json`.
|
|
110
|
+
*
|
|
111
|
+
* Every error has:
|
|
112
|
+
* - `error` — the message (always a string)
|
|
113
|
+
* - `code` — the API error code, or `null` when no API response was
|
|
114
|
+
* involved (a network failure, or a problem the CLI caught
|
|
115
|
+
* before sending anything)
|
|
116
|
+
* and an API error adds every structured field the SDK's error carries that is
|
|
117
|
+
* not `undefined` — the same fields, under the same names, as the MCP server's
|
|
118
|
+
* error envelope: `status`, `nextAction`, `retryable`, `retryWithheld`,
|
|
119
|
+
* `captureOutcome`, `voidOutcome`, … Unlike the text output, `false` values are
|
|
120
|
+
* kept: `"retryWithheld": false` is an answer.
|
|
121
|
+
*
|
|
122
|
+
* ⚠️ `code: null` on `payment-intents capture` / `void` / `create` or
|
|
123
|
+
* `refunds create` does NOT mean nothing happened: a network failure leaves
|
|
124
|
+
* the outcome unknown. Read the resource back before running it again.
|
|
125
|
+
*
|
|
126
|
+
* Nothing here can carry the API key, the idempotency key or the request body:
|
|
127
|
+
* `VonPayError` holds none of them, and any other error contributes only its
|
|
128
|
+
* message. Every string still goes through the same redaction as the text
|
|
129
|
+
* output.
|
|
130
|
+
*/
|
|
131
|
+
export function errorJson(err) {
|
|
132
|
+
if (err instanceof VonPayError) {
|
|
133
|
+
const out = { error: err.message };
|
|
134
|
+
const source = err;
|
|
135
|
+
for (const field of ERROR_FIELDS) {
|
|
136
|
+
const value = source[field];
|
|
137
|
+
if (value !== undefined)
|
|
138
|
+
out[field] = value;
|
|
139
|
+
}
|
|
140
|
+
return scrubDeep(out);
|
|
141
|
+
}
|
|
142
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
143
|
+
return { error: scrubSecrets(message), code: null };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Exit 1 on a problem the CLI caught itself, before calling the API (a live
|
|
147
|
+
* key without --confirm-live, a bad flag value). In text mode `text` is
|
|
148
|
+
* printed exactly as given; under `--json` the output is
|
|
149
|
+
* `{"error": <message>, "code": null}`, redacted like everything else.
|
|
150
|
+
*/
|
|
151
|
+
export function exitWithCliError(message, text) {
|
|
152
|
+
return emitCliError({ error: scrubSecrets(message), code: null }, text);
|
|
153
|
+
}
|
|
36
154
|
export function handleError(err) {
|
|
155
|
+
if (jsonErrorsEnabled()) {
|
|
156
|
+
printJsonError(errorJson(err));
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
37
159
|
if (err instanceof VonPayError) {
|
|
38
160
|
// Server-supplied text is scrubbed too: it is echoed to a terminal and
|
|
39
161
|
// from there into logs, and nothing guarantees it never quotes a secret.
|
|
40
162
|
console.error(chalk.red(`Error: ${scrubSecrets(err.message)}`));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (err.refundInstead) {
|
|
44
|
-
// refund_target_is_duplicate: the SDK has already checked this is a
|
|
45
|
-
// transaction id (vp_tx_*), so it is safe to echo as a command.
|
|
46
|
-
console.error(chalk.dim(` Refund instead: vonpay checkout refunds create --transaction ${err.refundInstead}`));
|
|
47
|
-
}
|
|
48
|
-
if (err.requestId) {
|
|
49
|
-
console.error(chalk.dim(` Request ID: ${err.requestId}`));
|
|
50
|
-
}
|
|
163
|
+
for (const line of errorDetailLines(err))
|
|
164
|
+
console.error(chalk.dim(line));
|
|
51
165
|
process.exit(1);
|
|
52
166
|
}
|
|
53
167
|
const message = err instanceof Error ? err.message : String(err);
|
package/dist/utils/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,WAAW,GAGZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,MAAM,eAAe,GAA6C;IACvE,CAAC,qCAAqC,EAAE,WAAW,CAAC;IACpD,CAAC,kCAAkC,EAAE,QAAQ,CAAC;IAC9C,CAAC,uBAAuB,EAAE,WAAW,CAAC;IACtC,CAAC,kCAAkC,EAAE,QAAQ,CAAC;IAC9C,CAAC,kCAAkC,EAAE,QAAQ,CAAC;CAC/C,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,KAAK,MAAM,CAAC,EAAE,EAA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M,WAAW,GAAG;IACzB,YAAY;CACb,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function setJsonErrors(enabled: boolean): void;
|
|
2
|
+
export declare function jsonErrorsEnabled(): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* One error, as one JSON line, on stderr. stdout is left alone: under
|
|
5
|
+
* `--json` it carries the command's RESULT, and a script reading stdout must
|
|
6
|
+
* never be handed an error it could parse as a result. The exit code (1) is
|
|
7
|
+
* what says the command failed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function printJsonError(obj: Record<string, unknown>): void;
|
|
10
|
+
/**
|
|
11
|
+
* Print an error the CLI caught itself and exit 1: `json` under `--json`,
|
|
12
|
+
* otherwise `text` exactly as given. Callers pass already-redacted values;
|
|
13
|
+
* `exitWithCliError` in `errors.ts` does that for a message.
|
|
14
|
+
*/
|
|
15
|
+
export declare function emitCliError(json: Record<string, unknown>, text: string): never;
|
|
16
|
+
//# sourceMappingURL=json-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-errors.d.ts","sourceRoot":"","sources":["../../src/utils/json-errors.ts"],"names":[],"mappings":"AAcA,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEpD;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAE3C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAI/E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether errors in this run are printed as JSON, and the one place they are
|
|
3
|
+
* written. Deliberately a leaf module (no imports) so the lowest-level code —
|
|
4
|
+
* `config.ts`'s `requireApiKey` — can use it without pulling in the SDK. The
|
|
5
|
+
* error formatting itself lives in `errors.ts`.
|
|
6
|
+
*
|
|
7
|
+
* Set once per run, before the command's action, from that command's own
|
|
8
|
+
* `--json` flag — by the `preAction` hook in `commands/checkout.ts`. A process
|
|
9
|
+
* runs one command, so a process-wide setting is the honest scope, and it
|
|
10
|
+
* reaches the checks that fail before any request is sent (no key, the
|
|
11
|
+
* live-key gate) without threading the flag through each of them.
|
|
12
|
+
*/
|
|
13
|
+
let jsonErrors = false;
|
|
14
|
+
export function setJsonErrors(enabled) {
|
|
15
|
+
jsonErrors = enabled;
|
|
16
|
+
}
|
|
17
|
+
export function jsonErrorsEnabled() {
|
|
18
|
+
return jsonErrors;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* One error, as one JSON line, on stderr. stdout is left alone: under
|
|
22
|
+
* `--json` it carries the command's RESULT, and a script reading stdout must
|
|
23
|
+
* never be handed an error it could parse as a result. The exit code (1) is
|
|
24
|
+
* what says the command failed.
|
|
25
|
+
*/
|
|
26
|
+
export function printJsonError(obj) {
|
|
27
|
+
console.error(JSON.stringify(obj));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Print an error the CLI caught itself and exit 1: `json` under `--json`,
|
|
31
|
+
* otherwise `text` exactly as given. Callers pass already-redacted values;
|
|
32
|
+
* `exitWithCliError` in `errors.ts` does that for a message.
|
|
33
|
+
*/
|
|
34
|
+
export function emitCliError(json, text) {
|
|
35
|
+
if (jsonErrors)
|
|
36
|
+
printJsonError(json);
|
|
37
|
+
else
|
|
38
|
+
console.error(text);
|
|
39
|
+
return process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=json-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-errors.js","sourceRoot":"","sources":["../../src/utils/json-errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,UAAU,GAAG,OAAO,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAA4B;IACzD,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAA6B,EAAE,IAAY;IACtE,IAAI,UAAU;QAAE,cAAc,CAAC,IAAI,CAAC,CAAC;;QAChC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACzB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-key.d.ts","sourceRoot":"","sources":["../../src/utils/live-key.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"live-key.d.ts","sourceRoot":"","sources":["../../src/utils/live-key.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAMlD,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,MAAM,EACjB,WAAW,SAAoB,GAC9B,IAAI,CAYN;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAOlE"}
|
package/dist/utils/live-key.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
2
|
import { isLiveKey } from "@vonpay/checkout-node";
|
|
3
|
+
import { exitWithCliError } from "./errors.js";
|
|
3
4
|
// The ONE definition of "live key", owned by the SDK (3.0.0+). Re-exported so
|
|
4
5
|
// existing imports of `isLiveKey` from this module keep working; do not
|
|
5
6
|
// re-implement the prefix check here.
|
|
@@ -25,8 +26,8 @@ export function requireLiveConfirmation(key, opts, operation, consequence = "is
|
|
|
25
26
|
console.warn(chalk.yellow(`Live key in use — ${operation} ${consequence}. Proceeding because --confirm-live was passed.`));
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
const message = `Refusing to ${operation} with a live key. Pass --confirm-live to acknowledge this is intentional.`;
|
|
30
|
+
exitWithCliError(message, chalk.red(message));
|
|
30
31
|
}
|
|
31
32
|
export function warnLiveSecretFlag(key, flag) {
|
|
32
33
|
if (!isLiveKey(key))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"live-key.js","sourceRoot":"","sources":["../../src/utils/live-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"live-key.js","sourceRoot":"","sources":["../../src/utils/live-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,8EAA8E;AAC9E,wEAAwE;AACxE,sCAAsC;AACtC,OAAO,EAAE,SAAS,EAAE,CAAC;AAMrB;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,uBAAuB,CACrC,GAAW,EACX,IAAkB,EAClB,SAAiB,EACjB,WAAW,GAAG,iBAAiB;IAE/B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QAAE,OAAO;IAC5B,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CACV,KAAK,CAAC,MAAM,CACV,qBAAqB,SAAS,IAAI,WAAW,iDAAiD,CAC/F,CACF,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,eAAe,SAAS,2EAA2E,CAAC;IACpH,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,IAAY;IAC1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;QAAE,OAAO;IAC5B,OAAO,CAAC,IAAI,CACV,KAAK,CAAC,MAAM,CACV,oBAAoB,IAAI,mJAAmJ,CAC5K,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Ora } from "ora";
|
|
2
|
+
/**
|
|
3
|
+
* Start the progress spinner for a command — silent under `--json`.
|
|
4
|
+
*
|
|
5
|
+
* ⛔ When stderr is not a terminal (a script, a CI step) ora does not animate:
|
|
6
|
+
* it prints its text once, as `- Capturing payment intent...`, to stderr. Under
|
|
7
|
+
* `--json` that put a non-JSON line in front of the JSON error, so stderr did
|
|
8
|
+
* not parse. `doctor` already silenced its spinner under `--json` for the same
|
|
9
|
+
* reason; every command now does. Without `--json` nothing changes.
|
|
10
|
+
*
|
|
11
|
+
* Reads the per-run `--json` setting made by the `preAction` hook in
|
|
12
|
+
* `commands/checkout.ts`, which runs before any command's action.
|
|
13
|
+
*/
|
|
14
|
+
export declare function startSpinner(text: string): Ora;
|
|
15
|
+
//# sourceMappingURL=spinner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.d.ts","sourceRoot":"","sources":["../../src/utils/spinner.ts"],"names":[],"mappings":"AAAA,OAAY,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAGpC;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAE9C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ora from "ora";
|
|
2
|
+
import { jsonErrorsEnabled } from "./json-errors.js";
|
|
3
|
+
/**
|
|
4
|
+
* Start the progress spinner for a command — silent under `--json`.
|
|
5
|
+
*
|
|
6
|
+
* ⛔ When stderr is not a terminal (a script, a CI step) ora does not animate:
|
|
7
|
+
* it prints its text once, as `- Capturing payment intent...`, to stderr. Under
|
|
8
|
+
* `--json` that put a non-JSON line in front of the JSON error, so stderr did
|
|
9
|
+
* not parse. `doctor` already silenced its spinner under `--json` for the same
|
|
10
|
+
* reason; every command now does. Without `--json` nothing changes.
|
|
11
|
+
*
|
|
12
|
+
* Reads the per-run `--json` setting made by the `preAction` hook in
|
|
13
|
+
* `commands/checkout.ts`, which runs before any command's action.
|
|
14
|
+
*/
|
|
15
|
+
export function startSpinner(text) {
|
|
16
|
+
return ora({ text, isSilent: jsonErrorsEnabled() }).start();
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=spinner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spinner.js","sourceRoot":"","sources":["../../src/utils/spinner.ts"],"names":[],"mappings":"AAAA,OAAO,GAAiB,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,iBAAiB,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;AAC9D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vonpay/checkout-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Von Payments CLI — developer tools for checkout integration",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"node": ">=20"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@vonpay/checkout-node": "^3.
|
|
18
|
+
"@vonpay/checkout-node": "^3.3.0",
|
|
19
19
|
"commander": "^13.0.0",
|
|
20
20
|
"chalk": "^5.4.0",
|
|
21
21
|
"ora": "^8.2.0"
|