@vonpay/checkout-cli 0.13.0 → 0.15.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 (114) hide show
  1. package/README.md +30 -5
  2. package/dist/index.js +2795 -13
  3. package/package.json +6 -4
  4. package/dist/app-info.d.ts +0 -5
  5. package/dist/app-info.d.ts.map +0 -1
  6. package/dist/app-info.js +0 -11
  7. package/dist/app-info.js.map +0 -1
  8. package/dist/client-factory.d.ts +0 -10
  9. package/dist/client-factory.d.ts.map +0 -1
  10. package/dist/client-factory.js +0 -31
  11. package/dist/client-factory.js.map +0 -1
  12. package/dist/commands/capabilities.d.ts +0 -22
  13. package/dist/commands/capabilities.d.ts.map +0 -1
  14. package/dist/commands/capabilities.js +0 -123
  15. package/dist/commands/capabilities.js.map +0 -1
  16. package/dist/commands/checkout.d.ts +0 -3
  17. package/dist/commands/checkout.d.ts.map +0 -1
  18. package/dist/commands/checkout.js +0 -39
  19. package/dist/commands/checkout.js.map +0 -1
  20. package/dist/commands/doctor.d.ts +0 -59
  21. package/dist/commands/doctor.d.ts.map +0 -1
  22. package/dist/commands/doctor.js +0 -366
  23. package/dist/commands/doctor.js.map +0 -1
  24. package/dist/commands/health.d.ts +0 -3
  25. package/dist/commands/health.d.ts.map +0 -1
  26. package/dist/commands/health.js +0 -52
  27. package/dist/commands/health.js.map +0 -1
  28. package/dist/commands/init.d.ts +0 -10
  29. package/dist/commands/init.d.ts.map +0 -1
  30. package/dist/commands/init.js +0 -112
  31. package/dist/commands/init.js.map +0 -1
  32. package/dist/commands/listen.d.ts +0 -19
  33. package/dist/commands/listen.d.ts.map +0 -1
  34. package/dist/commands/listen.js +0 -249
  35. package/dist/commands/listen.js.map +0 -1
  36. package/dist/commands/login.d.ts +0 -27
  37. package/dist/commands/login.d.ts.map +0 -1
  38. package/dist/commands/login.js +0 -75
  39. package/dist/commands/login.js.map +0 -1
  40. package/dist/commands/logout.d.ts +0 -3
  41. package/dist/commands/logout.d.ts.map +0 -1
  42. package/dist/commands/logout.js +0 -23
  43. package/dist/commands/logout.js.map +0 -1
  44. package/dist/commands/payment-intents.d.ts +0 -62
  45. package/dist/commands/payment-intents.d.ts.map +0 -1
  46. package/dist/commands/payment-intents.js +0 -271
  47. package/dist/commands/payment-intents.js.map +0 -1
  48. package/dist/commands/refunds.d.ts +0 -40
  49. package/dist/commands/refunds.d.ts.map +0 -1
  50. package/dist/commands/refunds.js +0 -142
  51. package/dist/commands/refunds.js.map +0 -1
  52. package/dist/commands/sessions.d.ts +0 -16
  53. package/dist/commands/sessions.d.ts.map +0 -1
  54. package/dist/commands/sessions.js +0 -152
  55. package/dist/commands/sessions.js.map +0 -1
  56. package/dist/commands/tokens.d.ts +0 -3
  57. package/dist/commands/tokens.d.ts.map +0 -1
  58. package/dist/commands/tokens.js +0 -89
  59. package/dist/commands/tokens.js.map +0 -1
  60. package/dist/commands/trigger.d.ts +0 -38
  61. package/dist/commands/trigger.d.ts.map +0 -1
  62. package/dist/commands/trigger.js +0 -246
  63. package/dist/commands/trigger.js.map +0 -1
  64. package/dist/config.d.ts +0 -22
  65. package/dist/config.d.ts.map +0 -1
  66. package/dist/config.js +0 -72
  67. package/dist/config.js.map +0 -1
  68. package/dist/index.d.ts +0 -3
  69. package/dist/index.d.ts.map +0 -1
  70. package/dist/index.js.map +0 -1
  71. package/dist/utils/errors.d.ts +0 -80
  72. package/dist/utils/errors.d.ts.map +0 -1
  73. package/dist/utils/errors.js +0 -179
  74. package/dist/utils/errors.js.map +0 -1
  75. package/dist/utils/forward-to.d.ts +0 -38
  76. package/dist/utils/forward-to.d.ts.map +0 -1
  77. package/dist/utils/forward-to.js +0 -92
  78. package/dist/utils/forward-to.js.map +0 -1
  79. package/dist/utils/json-errors.d.ts +0 -16
  80. package/dist/utils/json-errors.d.ts.map +0 -1
  81. package/dist/utils/json-errors.js +0 -41
  82. package/dist/utils/json-errors.js.map +0 -1
  83. package/dist/utils/listen-forward.d.ts +0 -49
  84. package/dist/utils/listen-forward.d.ts.map +0 -1
  85. package/dist/utils/listen-forward.js +0 -113
  86. package/dist/utils/listen-forward.js.map +0 -1
  87. package/dist/utils/listen-output.d.ts +0 -52
  88. package/dist/utils/listen-output.d.ts.map +0 -1
  89. package/dist/utils/listen-output.js +0 -85
  90. package/dist/utils/listen-output.js.map +0 -1
  91. package/dist/utils/live-key.d.ts +0 -22
  92. package/dist/utils/live-key.d.ts.map +0 -1
  93. package/dist/utils/live-key.js +0 -37
  94. package/dist/utils/live-key.js.map +0 -1
  95. package/dist/utils/metadata.d.ts +0 -2
  96. package/dist/utils/metadata.d.ts.map +0 -1
  97. package/dist/utils/metadata.js +0 -31
  98. package/dist/utils/metadata.js.map +0 -1
  99. package/dist/utils/sanitize.d.ts +0 -4
  100. package/dist/utils/sanitize.d.ts.map +0 -1
  101. package/dist/utils/sanitize.js +0 -18
  102. package/dist/utils/sanitize.js.map +0 -1
  103. package/dist/utils/spinner.d.ts +0 -15
  104. package/dist/utils/spinner.d.ts.map +0 -1
  105. package/dist/utils/spinner.js +0 -18
  106. package/dist/utils/spinner.js.map +0 -1
  107. package/dist/utils/sse-consumer.d.ts +0 -81
  108. package/dist/utils/sse-consumer.d.ts.map +0 -1
  109. package/dist/utils/sse-consumer.js +0 -172
  110. package/dist/utils/sse-consumer.js.map +0 -1
  111. package/dist/utils/sse-parser.d.ts +0 -63
  112. package/dist/utils/sse-parser.d.ts.map +0 -1
  113. package/dist/utils/sse-parser.js +0 -149
  114. package/dist/utils/sse-parser.js.map +0 -1
@@ -1,249 +0,0 @@
1
- import { Command } from "commander";
2
- import { VonPayCheckout, isLiveKey } from "@vonpay/checkout-node";
3
- import { requireApiKey } from "../config.js";
4
- import { getBaseUrl } from "../client-factory.js";
5
- import { validateForwardTo } from "../utils/forward-to.js";
6
- import { consumeSse, SseAuthError, } from "../utils/sse-consumer.js";
7
- import { formatAttemptHuman, formatAttemptJson, formatLifecycleHuman, formatLifecycleJson, } from "../utils/listen-output.js";
8
- import { forwardPayload } from "../utils/listen-forward.js";
9
- import { CLI_APP_INFO, SILENT_ERROR_REPORTER } from "../app-info.js";
10
- import { exitWithCliError, handleError } from "../utils/errors.js";
11
- import { jsonErrorsEnabled } from "../utils/json-errors.js";
12
- /**
13
- * `vonpay checkout listen` — long-lived SSE consumer for the merchant's
14
- * webhook delivery attempts.
15
- *
16
- * Industry conventions followed: WHATWG SSE spec for parsing,
17
- * Last-Event-ID for reconnect dedupe, exponential backoff, loopback-only
18
- * forward-to (Stripe CLI posture), refuse-live gate (mirrors
19
- * `vonpay checkout login --confirm-cli-exposure`), kubectl/gh-style
20
- * default human output with `--json` opt-in for machine consumption.
21
- *
22
- * Output channels:
23
- * stdout — attempt events (one per delivery), formatted per --json
24
- * stderr — lifecycle (connecting, reconnecting, shutdown summary)
25
- *
26
- * Stdout stays parseable in JSON mode regardless of reconnects.
27
- */
28
- export function listenCommand() {
29
- return new Command("listen")
30
- .description("Watch webhook delivery attempts in real time. Optionally re-forward each event to a local URL for development.")
31
- .option("--forward-to <url>", "Local URL to receive a shadow copy of each delivered event (loopback only by default)")
32
- .option("--forward-to-tunnel", "Allow non-loopback --forward-to URLs (for ngrok / Cloudflare Tunnel workflows)")
33
- .option("--events <type>", "Only stream attempts for the given event type. Repeat the flag for multiple types.", (value, prev) => (prev ? [...prev, value] : [value]))
34
- .option("--json", "Emit one JSON object per line on stdout instead of the colored transcript")
35
- .option("--api-key <key>", "Override the API key from env / config")
36
- .option("--confirm-live", "Acknowledge that the listen stream may surface production webhook attempts (required for vp_sk_live_* keys)")
37
- .action(async (opts) => {
38
- const apiKey = opts.apiKey ?? requireApiKey();
39
- // A refusal before the stream opens. Under --json it is the same
40
- // one-line `{"error", "code": null}` every other command prints; the
41
- // text stays this command's `[vonpay]` line.
42
- const refuse = (message) => {
43
- if (jsonErrorsEnabled())
44
- exitWithCliError(message, message);
45
- process.stderr.write(formatLifecycleHuman(message, "error") + "\n");
46
- return process.exit(1);
47
- };
48
- if (isLiveKey(apiKey) && !opts.confirmLive) {
49
- refuse("Refusing to start listen with a live key (vp_sk_live_*). Re-run with --confirm-live to acknowledge that production webhook attempts will stream to this terminal.");
50
- }
51
- if (!apiKey.startsWith("vp_sk_test_") &&
52
- !isLiveKey(apiKey)) {
53
- refuse("Listen requires a secret key (vp_sk_*). Publishable keys are rejected by the server.");
54
- }
55
- let forwardUrl;
56
- let forwardWarning;
57
- if (opts.forwardTo) {
58
- const verdict = validateForwardTo(opts.forwardTo, {
59
- allowTunnel: opts.forwardToTunnel === true,
60
- });
61
- if (!verdict.ok)
62
- refuse(verdict.reason);
63
- forwardUrl = verdict.url;
64
- forwardWarning = verdict.warning;
65
- }
66
- // Build the SSE URL from the SDK's resolved base URL — honors
67
- // VONPAY_BASE_URL / config.json baseUrl overrides used by the rest
68
- // of the CLI commands.
69
- const baseUrl = (getBaseUrl() ?? "https://checkout.vonpay.com").replace(/\/+$/, "");
70
- const sseUrl = new URL(`${baseUrl}/v1/webhook_listen`);
71
- if (opts.events && opts.events.length > 0) {
72
- sseUrl.searchParams.set("event_types", opts.events.join(","));
73
- }
74
- // SDK client for the per-attempt fetchEvent calls (only used when --forward-to is set)
75
- const sdk = forwardUrl
76
- ? new VonPayCheckout({ apiKey, baseUrl, appInfo: CLI_APP_INFO, errorReporter: SILENT_ERROR_REPORTER })
77
- : null;
78
- const controller = new AbortController();
79
- let eventCount = 0;
80
- const startedAt = Date.now();
81
- const mode = opts.json === true ? "json" : "human";
82
- const onSignal = (sig) => {
83
- const elapsedSec = Math.round((Date.now() - startedAt) / 1000);
84
- if (mode === "human") {
85
- process.stderr.write("\n" +
86
- formatLifecycleHuman(`Shutting down (${sig}). Received ${eventCount} event${eventCount === 1 ? "" : "s"} in ${elapsedSec}s.`, "info") +
87
- "\n");
88
- }
89
- else {
90
- process.stderr.write(formatLifecycleJson("shutdown", {
91
- signal: sig,
92
- event_count: eventCount,
93
- elapsed_seconds: elapsedSec,
94
- }) + "\n");
95
- }
96
- controller.abort();
97
- };
98
- process.once("SIGINT", () => onSignal("SIGINT"));
99
- process.once("SIGTERM", () => onSignal("SIGTERM"));
100
- const onLifecycle = (event) => {
101
- if (mode === "json") {
102
- process.stderr.write(formatLifecycleJson(event.kind, lifecyclePayload(event)) + "\n");
103
- return;
104
- }
105
- process.stderr.write(formatLifecycleHuman(lifecycleHumanMessage(event), lifecycleSeverity(event.kind)) + "\n");
106
- };
107
- // Pre-stream, emitted directly rather than through onLifecycle —
108
- // "warning" is not a LifecycleEvent kind (it's a one-shot forward-target
109
- // caveat, not a connection-lifecycle transition), so it intentionally
110
- // bypasses the onLifecycle/lifecyclePayload path.
111
- if (forwardWarning) {
112
- process.stderr.write(mode === "human"
113
- ? formatLifecycleHuman(forwardWarning, "warn") + "\n"
114
- : formatLifecycleJson("warning", { message: forwardWarning }) + "\n");
115
- }
116
- if (mode === "human") {
117
- const filterNote = opts.events?.length
118
- ? ` (filtered to ${opts.events.join(", ")})`
119
- : "";
120
- const fwdNote = forwardUrl ? ` → forwarding to ${forwardUrl.toString()}` : "";
121
- process.stderr.write(formatLifecycleHuman(`Ready! Listening for webhook delivery attempts${filterNote}${fwdNote}.`, "info") + "\n");
122
- }
123
- else {
124
- process.stderr.write(formatLifecycleJson("ready", {
125
- base_url: baseUrl,
126
- filter: opts.events ?? null,
127
- forward_to: forwardUrl?.toString() ?? null,
128
- }) + "\n");
129
- }
130
- try {
131
- for await (const sseEvent of consumeSse({
132
- url: sseUrl.toString(),
133
- headers: { Authorization: `Bearer ${apiKey}` },
134
- signal: controller.signal,
135
- onLifecycle,
136
- })) {
137
- if (sseEvent.type === "timeout") {
138
- // Server-ceiling. The consumer reconnects transparently —
139
- // surface as a lifecycle note, not a stream event.
140
- onLifecycle({
141
- kind: "disconnected",
142
- reason: "server-ceiling (1h cap; auto-reconnecting)",
143
- willRetryInMs: 0,
144
- });
145
- continue;
146
- }
147
- if (sseEvent.type !== "webhook.attempt") {
148
- // Future-compatible: skip unknown event types so an additive
149
- // server-side surface doesn't break older CLI versions.
150
- continue;
151
- }
152
- let payload;
153
- try {
154
- payload = JSON.parse(sseEvent.data);
155
- }
156
- catch {
157
- continue; // malformed frame; skip
158
- }
159
- eventCount += 1;
160
- let forwardOutcome = null;
161
- if (forwardUrl && sdk) {
162
- try {
163
- const eventRecord = await sdk.webhookEvents.retrieve(payload.event_id);
164
- forwardOutcome = await forwardPayload(eventRecord.payload, {
165
- url: forwardUrl,
166
- signingSecret: apiKey,
167
- signal: controller.signal,
168
- });
169
- }
170
- catch (err) {
171
- const message = err instanceof Error ? err.message : String(err);
172
- forwardOutcome = {
173
- attempted: true,
174
- status: null,
175
- latencyMs: null,
176
- error: `fetch-event failed: ${message.slice(0, 200)}`,
177
- };
178
- }
179
- }
180
- if (mode === "human") {
181
- process.stdout.write(formatAttemptHuman(payload, forwardOutcome) + "\n");
182
- }
183
- else {
184
- process.stdout.write(formatAttemptJson(payload, forwardOutcome) + "\n");
185
- }
186
- }
187
- }
188
- catch (err) {
189
- if (err instanceof SseAuthError) {
190
- if (mode === "human") {
191
- process.stderr.write(formatLifecycleHuman(`Authentication failed (HTTP ${err.status}). Run \`vonpay checkout login\` with a valid secret key.`, "error") + "\n");
192
- }
193
- else {
194
- process.stderr.write(formatLifecycleJson("auth_failed", { status: err.status }) + "\n");
195
- }
196
- process.exit(1);
197
- }
198
- // Anything else is unexpected. Under --json it still ends the stream
199
- // with one JSON error line rather than a stack trace; the text mode
200
- // behaves as before.
201
- if (jsonErrorsEnabled())
202
- handleError(err);
203
- throw err;
204
- }
205
- });
206
- }
207
- function lifecyclePayload(event) {
208
- switch (event.kind) {
209
- case "connecting":
210
- return { last_event_id: event.lastEventId ?? null };
211
- case "connected":
212
- return {};
213
- case "disconnected":
214
- return { reason: event.reason, will_retry_in_ms: event.willRetryInMs };
215
- case "auth_failed":
216
- return { status: event.status };
217
- case "fatal":
218
- return { error: event.error.message };
219
- }
220
- }
221
- function lifecycleHumanMessage(event) {
222
- switch (event.kind) {
223
- case "connecting":
224
- return event.lastEventId
225
- ? `Reconnecting (resume from ${event.lastEventId})`
226
- : "Connecting...";
227
- case "connected":
228
- return "Connected.";
229
- case "disconnected":
230
- return `Disconnected: ${event.reason}. Retrying in ${event.willRetryInMs}ms.`;
231
- case "auth_failed":
232
- return `Authentication failed (HTTP ${event.status}).`;
233
- case "fatal":
234
- return `Fatal: ${event.error.message}`;
235
- }
236
- }
237
- function lifecycleSeverity(kind) {
238
- switch (kind) {
239
- case "connecting":
240
- case "connected":
241
- return "info";
242
- case "disconnected":
243
- return "warn";
244
- case "auth_failed":
245
- case "fatal":
246
- return "error";
247
- }
248
- }
249
- //# sourceMappingURL=listen.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"listen.js","sourceRoot":"","sources":["../../src/commands/listen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EACL,UAAU,EACV,YAAY,GAEb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,GAEpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAW5D;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,OAAO,CAA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B,KAAK,cAAc;YACjB,OAAO,MAAM,CAAC;QAChB,KAAK,aAAa,CAAC;QACnB,KAAK,OAAO;YACV,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -1,27 +0,0 @@
1
- import { Command } from "commander";
2
- export type CliKeyGateVerdict = {
3
- action: "prompt";
4
- } | {
5
- action: "refuse";
6
- reason: string;
7
- } | {
8
- action: "save";
9
- warning?: string;
10
- };
11
- /**
12
- * Pure decision for `vonpay checkout login [key] [--confirm-cli-exposure]`.
13
- *
14
- * - No key on CLI → prompt interactively.
15
- * - Test key on CLI → warn, save.
16
- * - Live key on CLI without --confirm-cli-exposure → refuse (exit 1).
17
- * - Live key on CLI with --confirm-cli-exposure → warn, save.
18
- *
19
- * TTY detection is intentionally NOT part of this gate — pseudo-TTYs in CI
20
- * runners (CircleCI, GitHub Actions, docker --tty) make stdin/stderr.isTTY
21
- * unreliable. Requiring the explicit flag is the reliable signal.
22
- */
23
- export declare function evaluateCliKeyGate(key: string | undefined, opts: {
24
- confirmCliExposure?: boolean;
25
- }): CliKeyGateVerdict;
26
- export declare function loginCommand(): Command;
27
- //# sourceMappingURL=login.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACpB;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,IAAI,EAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GACrC,iBAAiB,CAYnB;AAYD,wBAAgB,YAAY,IAAI,OAAO,CA0DtC"}
@@ -1,75 +0,0 @@
1
- import { Command } from "commander";
2
- import { createInterface } from "node:readline";
3
- import chalk from "chalk";
4
- import { isLiveKey } from "@vonpay/checkout-node";
5
- import { loadConfig, saveConfig } from "../config.js";
6
- const VALID_PREFIXES = ["vp_sk_test_", "vp_sk_live_"];
7
- /**
8
- * Pure decision for `vonpay checkout login [key] [--confirm-cli-exposure]`.
9
- *
10
- * - No key on CLI → prompt interactively.
11
- * - Test key on CLI → warn, save.
12
- * - Live key on CLI without --confirm-cli-exposure → refuse (exit 1).
13
- * - Live key on CLI with --confirm-cli-exposure → warn, save.
14
- *
15
- * TTY detection is intentionally NOT part of this gate — pseudo-TTYs in CI
16
- * runners (CircleCI, GitHub Actions, docker --tty) make stdin/stderr.isTTY
17
- * unreliable. Requiring the explicit flag is the reliable signal.
18
- */
19
- export function evaluateCliKeyGate(key, opts) {
20
- if (!key)
21
- return { action: "prompt" };
22
- const warning = "Warning: passing keys as a command argument exposes them in shell history and process-list (`ps`). Use interactive mode (`vonpay checkout login`) instead.";
23
- if (isLiveKey(key) && !opts.confirmCliExposure) {
24
- return {
25
- action: "refuse",
26
- reason: "Refusing to save a live key supplied on the CLI. Re-run with --confirm-cli-exposure if this is intentional, or omit the key argument to be prompted interactively.",
27
- };
28
- }
29
- return { action: "save", warning };
30
- }
31
- function readLine(prompt) {
32
- const rl = createInterface({ input: process.stdin, output: process.stderr });
33
- return new Promise((resolve) => {
34
- rl.question(prompt, (answer) => {
35
- rl.close();
36
- resolve(answer.trim());
37
- });
38
- });
39
- }
40
- export function loginCommand() {
41
- return new Command("login")
42
- .description("Store your API key for CLI access")
43
- .argument("[key]", "API secret key (vp_sk_*)")
44
- .option("--confirm-cli-exposure", "Acknowledge that passing a live key as a command argument exposes it to shell history and ps(1).")
45
- .action(async (key, opts) => {
46
- let apiKey = key;
47
- const verdict = evaluateCliKeyGate(key, opts);
48
- if (verdict.action === "refuse") {
49
- console.warn(chalk.yellow("Warning: passing keys as a command argument exposes them in shell history and process-list (`ps`). Use interactive mode (`vonpay checkout login`) instead."));
50
- console.error(chalk.red(verdict.reason));
51
- process.exit(1);
52
- }
53
- if (verdict.action === "save" && verdict.warning) {
54
- console.warn(chalk.yellow(verdict.warning));
55
- }
56
- if (!apiKey) {
57
- console.log(chalk.dim("Get your API key from the Von Payments dashboard → Developers"));
58
- apiKey = await readLine("API key (vp_sk_*): ");
59
- }
60
- if (!apiKey) {
61
- console.error(chalk.red("No key provided."));
62
- process.exit(1);
63
- }
64
- if (!VALID_PREFIXES.some((p) => apiKey.startsWith(p))) {
65
- console.error(chalk.red(`Invalid key format. Must start with ${VALID_PREFIXES.join(" or ")}`));
66
- process.exit(1);
67
- }
68
- const config = loadConfig();
69
- config.checkout = { ...config.checkout, apiKey };
70
- saveConfig(config);
71
- const mode = apiKey.includes("_test_") ? "test" : "live";
72
- console.log(chalk.green(`✓ API key saved (${mode} mode) → ~/.vonpay/config.json`));
73
- });
74
- }
75
- //# sourceMappingURL=login.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,cAAc,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;AAOtD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAChC,GAAuB,EACvB,IAAsC;IAEtC,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACtC,MAAM,OAAO,G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AO,CAAC,GAAG,CACT,KAAK,CAAC,KAAK,CAAC,oBAAoB,IAAI,gCAAgC,CAAC,CACtE,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function logoutCommand(): Command;
3
- //# sourceMappingURL=logout.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,aAAa,IAAI,OAAO,CA2BvC"}
@@ -1,23 +0,0 @@
1
- import { Command } from "commander";
2
- import chalk from "chalk";
3
- import { clearStoredApiKey } from "../config.js";
4
- export function logoutCommand() {
5
- return new Command("logout")
6
- .description("Remove the stored API key from ~/.vonpay/config.json")
7
- .action(() => {
8
- const { removed } = clearStoredApiKey();
9
- if (removed) {
10
- console.log(chalk.green("✓ Stored API key removed from ~/.vonpay/config.json"));
11
- }
12
- else {
13
- console.log(chalk.dim("No stored API key found in ~/.vonpay/config.json"));
14
- }
15
- // The stored key is gone, but an env var still takes precedence in
16
- // `getApiKey()` — surface that so the user isn't surprised the CLI is
17
- // still authenticated after a logout.
18
- if (process.env.VON_PAY_SECRET_KEY) {
19
- console.warn(chalk.yellow("Note: VON_PAY_SECRET_KEY is still set in your environment and takes precedence over the stored config. Run `unset VON_PAY_SECRET_KEY` to fully log out of this shell."));
20
- }
21
- });
22
- }
23
- //# sourceMappingURL=logout.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,MAAM,UAAU,aAAa;IAC3B,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;SACzB,WAAW,CAAC,sDAAsD,CAAC;SACnE,MAAM,CAAC,GAAG,EAAE;QACX,MAAM,EAAE,OAAO,EAAE,GAAG,iBAAiB,EAAE,CAAC;QAExC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,KAAK,CAAC,qDAAqD,CAAC,CACnE,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAC9D,CAAC;QACJ,CAAC;QAED,mEAAmE;QACnE,sEAAsE;QACtE,sCAAsC;QACtC,IAAI,OAAO,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CACV,KAAK,CAAC,MAAM,CACV,uKAAuK,CACxK,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,62 +0,0 @@
1
- import { Command } from "commander";
2
- import type { CreatePaymentIntentParams, MITBlock } from "@vonpay/checkout-node";
3
- interface CreateOpts {
4
- amount: number;
5
- currency: string;
6
- captureMethod?: string;
7
- metadata?: string[];
8
- mitInitiator?: string;
9
- mitReason?: string;
10
- mitOriginalTransactionId?: string;
11
- paymentMethod?: string;
12
- sessionId?: string;
13
- buyerId?: string;
14
- buyerEmail?: string;
15
- idempotencyKey?: string;
16
- confirmLive?: boolean;
17
- json?: boolean;
18
- }
19
- /**
20
- * Assemble the create-intent body from parsed flags.
21
- *
22
- * Extracted from the action handler so the wiring is TESTABLE. A flag can be
23
- * declared on the command and never reach the SDK call — and for
24
- * `--payment-method`, `--session-id` and `--buyer-id` that failure is silent
25
- * and expensive: the first names the saved card to bill, the other two are
26
- * money-safety controls that only apply when actually sent.
27
- *
28
- * Every optional field is set only when supplied. An omitted flag must stay
29
- * ABSENT rather than become an explicit `undefined` — asserting a null buyer
30
- * is a different request from never asserting one. Empty strings count as
31
- * not-provided, matching `buildMITBlock`.
32
- */
33
- declare function buildCreateParams(opts: CreateOpts, resolved: {
34
- captureMethod?: "automatic" | "manual";
35
- metadata?: Record<string, string>;
36
- mit?: MITBlock;
37
- }): CreatePaymentIntentParams;
38
- /**
39
- * The idempotency key this charge is sent with: the caller's
40
- * `--idempotency-key` when given (trimmed), otherwise a freshly generated one.
41
- *
42
- * Every charge carries a key. The API refuses a keyless charge from
43
- * 28 October 2026 (`400 idempotency_key_required`), and a key is also what
44
- * lets the SDK retry an ambiguous failure (timeout, 5xx) inside this one
45
- * command without risking a second charge. A generated key protects only that
46
- * single invocation — re-running the command makes a new key and therefore a
47
- * new charge — so it is printed (to stderr, keeping `--json` stdout clean)
48
- * for the caller to pass back on a deliberate retry of the SAME charge.
49
- */
50
- declare function resolveIdempotencyKey(flag: string | undefined): {
51
- key: string;
52
- generated: boolean;
53
- };
54
- declare function buildMITBlock(opts: CreateOpts): MITBlock | undefined;
55
- export declare function paymentIntentsCommand(): Command;
56
- export declare const __testing__: {
57
- buildMITBlock: typeof buildMITBlock;
58
- buildCreateParams: typeof buildCreateParams;
59
- resolveIdempotencyKey: typeof resolveIdempotencyKey;
60
- };
61
- export {};
62
- //# sourceMappingURL=payment-intents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"payment-intents.d.ts","sourceRoot":"","sources":["../../src/commands/payment-intents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,OAAO,KAAK,EACV,yBAAyB,EAEzB,QAAQ,EAGT,MAAM,uBAAuB,CAAC;AAe/B,UAAU,UAAU;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB,CAAC,EAAE,MA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