@vonpay/checkout-cli 0.8.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.
Files changed (59) hide show
  1. package/README.md +9 -3
  2. package/dist/app-info.d.ts +5 -0
  3. package/dist/app-info.d.ts.map +1 -0
  4. package/dist/app-info.js +11 -0
  5. package/dist/app-info.js.map +1 -0
  6. package/dist/client-factory.d.ts.map +1 -1
  7. package/dist/client-factory.js +9 -4
  8. package/dist/client-factory.js.map +1 -1
  9. package/dist/commands/capabilities.js +2 -2
  10. package/dist/commands/capabilities.js.map +1 -1
  11. package/dist/commands/checkout.d.ts.map +1 -1
  12. package/dist/commands/checkout.js +9 -0
  13. package/dist/commands/checkout.js.map +1 -1
  14. package/dist/commands/doctor.d.ts.map +1 -1
  15. package/dist/commands/doctor.js +2 -0
  16. package/dist/commands/doctor.js.map +1 -1
  17. package/dist/commands/health.d.ts.map +1 -1
  18. package/dist/commands/health.js +11 -4
  19. package/dist/commands/health.js.map +1 -1
  20. package/dist/commands/listen.d.ts.map +1 -1
  21. package/dist/commands/listen.js +22 -9
  22. package/dist/commands/listen.js.map +1 -1
  23. package/dist/commands/payment-intents.d.ts +17 -0
  24. package/dist/commands/payment-intents.d.ts.map +1 -1
  25. package/dist/commands/payment-intents.js +39 -11
  26. package/dist/commands/payment-intents.js.map +1 -1
  27. package/dist/commands/refunds.d.ts.map +1 -1
  28. package/dist/commands/refunds.js +12 -9
  29. package/dist/commands/refunds.js.map +1 -1
  30. package/dist/commands/sessions.js +3 -3
  31. package/dist/commands/sessions.js.map +1 -1
  32. package/dist/commands/tokens.js +2 -2
  33. package/dist/commands/tokens.js.map +1 -1
  34. package/dist/commands/trigger.d.ts.map +1 -1
  35. package/dist/commands/trigger.js +17 -0
  36. package/dist/commands/trigger.js.map +1 -1
  37. package/dist/config.d.ts.map +1 -1
  38. package/dist/config.js +4 -2
  39. package/dist/config.js.map +1 -1
  40. package/dist/utils/errors.d.ts +74 -1
  41. package/dist/utils/errors.d.ts.map +1 -1
  42. package/dist/utils/errors.js +127 -13
  43. package/dist/utils/errors.js.map +1 -1
  44. package/dist/utils/forward-to.d.ts +5 -1
  45. package/dist/utils/forward-to.d.ts.map +1 -1
  46. package/dist/utils/forward-to.js +10 -6
  47. package/dist/utils/forward-to.js.map +1 -1
  48. package/dist/utils/json-errors.d.ts +16 -0
  49. package/dist/utils/json-errors.d.ts.map +1 -0
  50. package/dist/utils/json-errors.js +41 -0
  51. package/dist/utils/json-errors.js.map +1 -0
  52. package/dist/utils/live-key.d.ts.map +1 -1
  53. package/dist/utils/live-key.js +3 -2
  54. package/dist/utils/live-key.js.map +1 -1
  55. package/dist/utils/spinner.d.ts +15 -0
  56. package/dist/utils/spinner.d.ts.map +1 -0
  57. package/dist/utils/spinner.js +18 -0
  58. package/dist/utils/spinner.js.map +1 -0
  59. package/package.json +2 -2
@@ -1,5 +1,7 @@
1
1
  /**
2
- * URL validation for `vonpay checkout listen --forward-to`.
2
+ * URL validation for `vonpay checkout listen --forward-to` and
3
+ * `vonpay checkout trigger --url` (same policy since 0.8.1; the flag names in
4
+ * messages are passed in).
3
5
  *
4
6
  * Default posture: loopback-only. Refuses any URL whose hostname is not
5
7
  * one of the IPv4/IPv6 loopback aliases. This protects against the
@@ -30,5 +32,7 @@ export type ForwardToVerdict = {
30
32
  */
31
33
  export declare function validateForwardTo(raw: string, opts: {
32
34
  allowTunnel: boolean;
35
+ flag?: string;
36
+ tunnelFlag?: string;
33
37
  }): ForwardToVerdict;
34
38
  //# sourceMappingURL=forward-to.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"forward-to.d.ts","sourceRoot":"","sources":["../../src/utils/forward-to.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAmBH,MAAM,MAAM,gBAAgB,GACxB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,WAAW,EAAE,OAAO,CAAA;CAAE,GAC7B,gBAAgB,CA6ClB"}
1
+ {"version":3,"file":"forward-to.d.ts","sourceRoot":"","sources":["../../src/utils/forward-to.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAmBH,MAAM,MAAM,gBAAgB,GACxB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,UAAU,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAElC;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACjE,gBAAgB,CA+ClB"}
@@ -1,5 +1,7 @@
1
1
  /**
2
- * URL validation for `vonpay checkout listen --forward-to`.
2
+ * URL validation for `vonpay checkout listen --forward-to` and
3
+ * `vonpay checkout trigger --url` (same policy since 0.8.1; the flag names in
4
+ * messages are passed in).
3
5
  *
4
6
  * Default posture: loopback-only. Refuses any URL whose hostname is not
5
7
  * one of the IPv4/IPv6 loopback aliases. This protects against the
@@ -36,8 +38,10 @@ const LOOPBACK_HOSTS = new Set([
36
38
  * (the CLI surfaces `reason` to stderr and exits non-zero).
37
39
  */
38
40
  export function validateForwardTo(raw, opts) {
41
+ const flag = opts.flag ?? "--forward-to";
42
+ const tunnelFlag = opts.tunnelFlag ?? "--forward-to-tunnel";
39
43
  if (typeof raw !== "string" || raw.length === 0) {
40
- return { ok: false, reason: "--forward-to URL is required" };
44
+ return { ok: false, reason: `${flag} URL is required` };
41
45
  }
42
46
  let url;
43
47
  try {
@@ -46,13 +50,13 @@ export function validateForwardTo(raw, opts) {
46
50
  catch {
47
51
  return {
48
52
  ok: false,
49
- reason: `--forward-to is not a parseable URL: ${truncate(raw)}`,
53
+ reason: `${flag} is not a parseable URL: ${truncate(raw)}`,
50
54
  };
51
55
  }
52
56
  if (url.protocol !== "http:" && url.protocol !== "https:") {
53
57
  return {
54
58
  ok: false,
55
- reason: `--forward-to scheme must be http or https; got ${url.protocol}`,
59
+ reason: `${flag} scheme must be http or https; got ${url.protocol}`,
56
60
  };
57
61
  }
58
62
  const host = normalizeHost(url.hostname);
@@ -60,8 +64,8 @@ export function validateForwardTo(raw, opts) {
60
64
  if (!isLoopback && !opts.allowTunnel) {
61
65
  return {
62
66
  ok: false,
63
- reason: `--forward-to refuses non-loopback hosts by default (got ${url.hostname}). ` +
64
- `Re-run with --forward-to-tunnel if forwarding through ngrok / Cloudflare Tunnel / etc.`,
67
+ reason: `${flag} refuses non-loopback hosts by default (got ${url.hostname}). ` +
68
+ `Re-run with ${tunnelFlag} if forwarding through ngrok / Cloudflare Tunnel / etc.`,
65
69
  };
66
70
  }
67
71
  // `0.0.0.0` is treated as loopback for dev convenience, but it's a
@@ -1 +1 @@
1
- {"version":3,"file":"forward-to.js","sourceRoot":"","sources":["../../src/utils/forward-to.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,WAAW;IACX,WAAW;IACX,SAAS,EAAE,sEAAsE;IACjF,KAAK;IACL,uEAAuE;IACvE,uEAAuE;IACvE,4BAA4B;IAC5B,OAAO;IACP,0DAA0D;IAC1D,kEAAkE;IAClE,6DAA6D;IAC7D,wBAAwB;IACxB,kBAAkB;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9B,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACvD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,QAAQ,CAAC,WAAW,EAAE,CAAC;AAChC,CAAC;AAED,SAAS,QAAQ,CAAC,CAAS;IACzB,OAAO,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC;AACvD,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;AAKlD,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,CAgBN;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAOlE"}
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"}
@@ -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
- console.error(chalk.red(`Refusing to ${operation} with a live key. Pass --confirm-live to acknowledge this is intentional.`));
29
- process.exit(1);
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;AAElD,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,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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.8.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.0.0",
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"