@vonpay/checkout-cli 0.12.0 → 0.14.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/dist/index.js +2397 -12
- package/package.json +6 -4
- package/dist/app-info.d.ts +0 -5
- package/dist/app-info.d.ts.map +0 -1
- package/dist/app-info.js +0 -11
- package/dist/app-info.js.map +0 -1
- package/dist/client-factory.d.ts +0 -10
- package/dist/client-factory.d.ts.map +0 -1
- package/dist/client-factory.js +0 -31
- package/dist/client-factory.js.map +0 -1
- package/dist/commands/capabilities.d.ts +0 -15
- package/dist/commands/capabilities.d.ts.map +0 -1
- package/dist/commands/capabilities.js +0 -99
- package/dist/commands/capabilities.js.map +0 -1
- package/dist/commands/checkout.d.ts +0 -3
- package/dist/commands/checkout.d.ts.map +0 -1
- package/dist/commands/checkout.js +0 -39
- package/dist/commands/checkout.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -59
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -366
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/health.d.ts +0 -3
- package/dist/commands/health.d.ts.map +0 -1
- package/dist/commands/health.js +0 -52
- package/dist/commands/health.js.map +0 -1
- package/dist/commands/init.d.ts +0 -10
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -112
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/listen.d.ts +0 -19
- package/dist/commands/listen.d.ts.map +0 -1
- package/dist/commands/listen.js +0 -249
- package/dist/commands/listen.js.map +0 -1
- package/dist/commands/login.d.ts +0 -27
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -75
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -3
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js +0 -23
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/payment-intents.d.ts +0 -62
- package/dist/commands/payment-intents.d.ts.map +0 -1
- package/dist/commands/payment-intents.js +0 -271
- package/dist/commands/payment-intents.js.map +0 -1
- package/dist/commands/refunds.d.ts +0 -40
- package/dist/commands/refunds.d.ts.map +0 -1
- package/dist/commands/refunds.js +0 -142
- package/dist/commands/refunds.js.map +0 -1
- package/dist/commands/sessions.d.ts +0 -16
- package/dist/commands/sessions.d.ts.map +0 -1
- package/dist/commands/sessions.js +0 -152
- package/dist/commands/sessions.js.map +0 -1
- package/dist/commands/tokens.d.ts +0 -3
- package/dist/commands/tokens.d.ts.map +0 -1
- package/dist/commands/tokens.js +0 -73
- package/dist/commands/tokens.js.map +0 -1
- package/dist/commands/trigger.d.ts +0 -38
- package/dist/commands/trigger.d.ts.map +0 -1
- package/dist/commands/trigger.js +0 -246
- package/dist/commands/trigger.js.map +0 -1
- package/dist/config.d.ts +0 -22
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -72
- package/dist/config.js.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/utils/errors.d.ts +0 -80
- package/dist/utils/errors.d.ts.map +0 -1
- package/dist/utils/errors.js +0 -179
- package/dist/utils/errors.js.map +0 -1
- package/dist/utils/forward-to.d.ts +0 -38
- package/dist/utils/forward-to.d.ts.map +0 -1
- package/dist/utils/forward-to.js +0 -92
- package/dist/utils/forward-to.js.map +0 -1
- package/dist/utils/json-errors.d.ts +0 -16
- package/dist/utils/json-errors.d.ts.map +0 -1
- package/dist/utils/json-errors.js +0 -41
- package/dist/utils/json-errors.js.map +0 -1
- package/dist/utils/listen-forward.d.ts +0 -49
- package/dist/utils/listen-forward.d.ts.map +0 -1
- package/dist/utils/listen-forward.js +0 -113
- package/dist/utils/listen-forward.js.map +0 -1
- package/dist/utils/listen-output.d.ts +0 -52
- package/dist/utils/listen-output.d.ts.map +0 -1
- package/dist/utils/listen-output.js +0 -85
- package/dist/utils/listen-output.js.map +0 -1
- package/dist/utils/live-key.d.ts +0 -22
- package/dist/utils/live-key.d.ts.map +0 -1
- package/dist/utils/live-key.js +0 -37
- package/dist/utils/live-key.js.map +0 -1
- package/dist/utils/metadata.d.ts +0 -2
- package/dist/utils/metadata.d.ts.map +0 -1
- package/dist/utils/metadata.js +0 -31
- package/dist/utils/metadata.js.map +0 -1
- package/dist/utils/sanitize.d.ts +0 -4
- package/dist/utils/sanitize.d.ts.map +0 -1
- package/dist/utils/sanitize.js +0 -18
- package/dist/utils/sanitize.js.map +0 -1
- package/dist/utils/spinner.d.ts +0 -15
- package/dist/utils/spinner.d.ts.map +0 -1
- package/dist/utils/spinner.js +0 -18
- package/dist/utils/spinner.js.map +0 -1
- package/dist/utils/sse-consumer.d.ts +0 -81
- package/dist/utils/sse-consumer.d.ts.map +0 -1
- package/dist/utils/sse-consumer.js +0 -172
- package/dist/utils/sse-consumer.js.map +0 -1
- package/dist/utils/sse-parser.d.ts +0 -63
- package/dist/utils/sse-parser.d.ts.map +0 -1
- package/dist/utils/sse-parser.js +0 -149
- package/dist/utils/sse-parser.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
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;AAItC;;;;;GAKG;AACH,SAAS,YAAY,CAAC,OAAoB;IACxC,MAAM,WAAW,GACf,OAAO,CAAC,MAAM,KAAK,WAAW;QAC5B,CAAC,CAAC,KAAK,CAAC,KAAK;QACb,CAAC,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W,CAAC,oBAAoB,CAAC;SACjC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;SAC9B,MAAM,CAAC,QAAQ,EAAE,iBAAiB,CAAC;SACnC,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,IAAwB,EAAE,EAAE;QACrD,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAC;QAEpD,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9C,OAAO,CAAC,IAAI,EAAE,CAAC;YAEf,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAChD,CAAC;iBAAM,CAAC;gBACN,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,OAAO,CAAC;oBAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC9D,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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/commands/tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0BpC,wBAAgB,aAAa,IAAI,OAAO,CA+EvC"}
|
package/dist/commands/tokens.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import chalk from "chalk";
|
|
3
|
-
import { startSpinner } from "../utils/spinner.js";
|
|
4
|
-
import { requireApiKey } from "../config.js";
|
|
5
|
-
import { makeCheckoutClient } from "../client-factory.js";
|
|
6
|
-
import { parseMetadata } from "../utils/metadata.js";
|
|
7
|
-
import { handleError } from "../utils/errors.js";
|
|
8
|
-
import { warnLiveSecretFlag } from "../utils/live-key.js";
|
|
9
|
-
function printToken(token) {
|
|
10
|
-
const statusColor = token.status === "active"
|
|
11
|
-
? chalk.green
|
|
12
|
-
: token.status === "expired"
|
|
13
|
-
? chalk.yellow
|
|
14
|
-
: chalk.red;
|
|
15
|
-
console.log(` ID: ${token.id}`);
|
|
16
|
-
console.log(` Status: ${statusColor(token.status)}`);
|
|
17
|
-
console.log(` Card: ${token.card.brand} •••• ${token.card.last4}`);
|
|
18
|
-
console.log(` Expires: ${String(token.card.expMonth).padStart(2, "0")}/${token.card.expYear}`);
|
|
19
|
-
}
|
|
20
|
-
export function tokensCommand() {
|
|
21
|
-
const tokens = new Command("tokens").description("Create payment-method tokens for saved-card / MIT flows");
|
|
22
|
-
tokens
|
|
23
|
-
.command("create")
|
|
24
|
-
.description("Create a payment-method token")
|
|
25
|
-
.option("--buyer-id <id>", "Buyer ID to attach the token to")
|
|
26
|
-
.option("--provider-reference <ref>", "Provider tokenization handle (required for live keys with iframe-vault providers)")
|
|
27
|
-
.option("--metadata <pair...>", "Metadata key=value (repeat flag for multiple pairs)")
|
|
28
|
-
.option("--idempotency-key <key>", "Idempotency key for safe retries")
|
|
29
|
-
.option("--json", "Output raw JSON")
|
|
30
|
-
.action(async (opts) => {
|
|
31
|
-
const apiKey = requireApiKey();
|
|
32
|
-
// Nothing is auto-minted any more: a sandbox account tokenizes on its
|
|
33
|
-
// payment provider's test environment and needs what that provider
|
|
34
|
-
// needs, just like live. A test key on a live account, or on a sandbox
|
|
35
|
-
// with no provider, gets 422 sandbox_account_required.
|
|
36
|
-
if (!opts.buyerId && !opts.providerReference) {
|
|
37
|
-
console.warn(chalk.yellow("Warning: no --buyer-id or --provider-reference supplied. Providers with an iframe vault (sandbox and live alike) will fail with a 422 validation_error."));
|
|
38
|
-
}
|
|
39
|
-
if (opts.providerReference !== undefined) {
|
|
40
|
-
warnLiveSecretFlag(apiKey, "--provider-reference");
|
|
41
|
-
}
|
|
42
|
-
const client = makeCheckoutClient();
|
|
43
|
-
const spinner = startSpinner("Creating token...");
|
|
44
|
-
try {
|
|
45
|
-
const metadata = parseMetadata(opts.metadata);
|
|
46
|
-
const params = {};
|
|
47
|
-
if (opts.buyerId !== undefined)
|
|
48
|
-
params.buyerId = opts.buyerId;
|
|
49
|
-
if (opts.providerReference !== undefined) {
|
|
50
|
-
params.providerReference = opts.providerReference;
|
|
51
|
-
}
|
|
52
|
-
if (metadata !== undefined)
|
|
53
|
-
params.metadata = metadata;
|
|
54
|
-
const token = await client.tokens.create(params, opts.idempotencyKey
|
|
55
|
-
? { idempotencyKey: opts.idempotencyKey }
|
|
56
|
-
: undefined);
|
|
57
|
-
spinner.stop();
|
|
58
|
-
if (opts.json) {
|
|
59
|
-
console.log(JSON.stringify(token, null, 2));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
console.log(chalk.green("✓ Token created"));
|
|
63
|
-
printToken(token);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
spinner.stop();
|
|
68
|
-
handleError(err);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
return tokens;
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=tokens.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,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ACzC,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"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
export declare const SUPPORTED_EVENTS: readonly ["charge.succeeded", "charge.failed", "charge.refunded", "refund.failed", "payment_intent.succeeded", "payment_intent.failed", "payment_intent.cancelled", "mirror.order.created", "session.succeeded", "session.failed"];
|
|
3
|
-
/**
|
|
4
|
-
* Event keys the server emits but no merchant can subscribe to. Triggering one
|
|
5
|
-
* locally works, but an endpoint will never receive it in staging or
|
|
6
|
-
* production, so a handler tested only against these is untested.
|
|
7
|
-
*/
|
|
8
|
-
export declare const UNSUBSCRIBABLE_EVENTS: readonly SupportedEvent[];
|
|
9
|
-
/**
|
|
10
|
-
* Print a warning when the developer triggers an event they will never receive
|
|
11
|
-
* in a real environment. Returns whether a warning was emitted so this stays
|
|
12
|
-
* testable without capturing stdout.
|
|
13
|
-
*/
|
|
14
|
-
export declare function warnIfUnsubscribable(event: SupportedEvent, write?: (msg: string) => void): boolean;
|
|
15
|
-
type SupportedEvent = (typeof SUPPORTED_EVENTS)[number];
|
|
16
|
-
interface WebhookEnvelope {
|
|
17
|
-
id: string;
|
|
18
|
-
type: SupportedEvent;
|
|
19
|
-
created: number;
|
|
20
|
-
livemode: boolean;
|
|
21
|
-
merchant_id: string;
|
|
22
|
-
/**
|
|
23
|
-
* Always `true` here: this is a synthesized event, exactly like the server's
|
|
24
|
-
* "Send test event", which sets the same marker. A receiver that skips on it
|
|
25
|
-
* must skip these too — otherwise `trigger` would exercise a code path the
|
|
26
|
-
* real test button never reaches.
|
|
27
|
-
*/
|
|
28
|
-
test_event: true;
|
|
29
|
-
data: Record<string, unknown>;
|
|
30
|
-
}
|
|
31
|
-
export declare function buildPayload(event: SupportedEvent, opts: {
|
|
32
|
-
sessionId?: string;
|
|
33
|
-
amount?: number;
|
|
34
|
-
currency?: string;
|
|
35
|
-
}): WebhookEnvelope;
|
|
36
|
-
export declare function triggerCommand(): Command;
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=trigger.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trigger.d.ts","sourceRoot":"","sources":["../../src/commands/trigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsBpC,eAAO,MAAM,gBAAgB,oOAWnB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,cAAc,EAG1D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,cAAc,EACrB,KAAK,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAA6B,GACpD,OAAO,CAYT;AACD,KAAK,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAMxD,UAAU,eAAe;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,UAAU,EAAE,IAAI,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AA2FD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/D,eAAe,CAiBjB;AAED,wBAAgB,cAAc,IAAI,OAAO,CA6HxC"}
|
package/dist/commands/trigger.js
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { createHmac, randomUUID } from "node:crypto";
|
|
3
|
-
import chalk from "chalk";
|
|
4
|
-
import ora from "ora";
|
|
5
|
-
import { requireApiKey } from "../config.js";
|
|
6
|
-
import { requireLiveConfirmation } from "../utils/live-key.js";
|
|
7
|
-
import { validateForwardTo } from "../utils/forward-to.js";
|
|
8
|
-
import { safeDisplay } from "../utils/sanitize.js";
|
|
9
|
-
// Real server-emitted event keys this local trigger can synthesize. The
|
|
10
|
-
// fictional `refund.created` was removed — the server emits `charge.refunded`.
|
|
11
|
-
//
|
|
12
|
-
// ⚠️ ORDER MATTERS: `charge.*` first, because those are the keys a merchant can
|
|
13
|
-
// actually SUBSCRIBE to, and this list is what `--help` prints. `session.*` are
|
|
14
|
-
// emitted internally but are absent from the merchant subscription catalog,
|
|
15
|
-
// which accepts an unknown key, stores nothing and returns success — so an
|
|
16
|
-
// endpoint subscribed to one receives nothing, forever. They stay triggerable
|
|
17
|
-
// (removing them would break anyone scripting against this command) but
|
|
18
|
-
// `warnIfUnsubscribable` below says so at the point of use. Until 0.5.2 this
|
|
19
|
-
// list offered `session.succeeded` and NOT `charge.succeeded`, so the only
|
|
20
|
-
// fulfilment event a merchant can receive was the one event this tool could not
|
|
21
|
-
// synthesize.
|
|
22
|
-
export const SUPPORTED_EVENTS = [
|
|
23
|
-
"charge.succeeded",
|
|
24
|
-
"charge.failed",
|
|
25
|
-
"charge.refunded",
|
|
26
|
-
"refund.failed",
|
|
27
|
-
"payment_intent.succeeded",
|
|
28
|
-
"payment_intent.failed",
|
|
29
|
-
"payment_intent.cancelled",
|
|
30
|
-
"mirror.order.created",
|
|
31
|
-
"session.succeeded",
|
|
32
|
-
"session.failed",
|
|
33
|
-
];
|
|
34
|
-
/**
|
|
35
|
-
* Event keys the server emits but no merchant can subscribe to. Triggering one
|
|
36
|
-
* locally works, but an endpoint will never receive it in staging or
|
|
37
|
-
* production, so a handler tested only against these is untested.
|
|
38
|
-
*/
|
|
39
|
-
export const UNSUBSCRIBABLE_EVENTS = [
|
|
40
|
-
"session.succeeded",
|
|
41
|
-
"session.failed",
|
|
42
|
-
];
|
|
43
|
-
/**
|
|
44
|
-
* Print a warning when the developer triggers an event they will never receive
|
|
45
|
-
* in a real environment. Returns whether a warning was emitted so this stays
|
|
46
|
-
* testable without capturing stdout.
|
|
47
|
-
*/
|
|
48
|
-
export function warnIfUnsubscribable(event, write = (m) => console.warn(m)) {
|
|
49
|
-
if (!UNSUBSCRIBABLE_EVENTS.includes(event))
|
|
50
|
-
return false;
|
|
51
|
-
const suggestion = event === "session.succeeded" ? "charge.succeeded" : "charge.failed";
|
|
52
|
-
write(chalk.yellow(`⚠ ${event} is emitted internally but is NOT subscribable.\n` +
|
|
53
|
-
` The subscription API accepts the key, stores nothing and returns success, so a\n` +
|
|
54
|
-
` real endpoint receives this event NEVER — a handler tested only against it is\n` +
|
|
55
|
-
` untested. Use ${suggestion} instead.`));
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
// Per-event `data` shapes matching the server's buildEventData() for the
|
|
59
|
-
// events this trigger supports. Synthetic-but-realistic values; the failure
|
|
60
|
-
// fixtures use codes already on the normalized allowlist.
|
|
61
|
-
function buildEventData(event, ids, amount, currency) {
|
|
62
|
-
const base = {
|
|
63
|
-
session_id: ids.sessionId,
|
|
64
|
-
payment_intent_id: ids.paymentIntentId,
|
|
65
|
-
transaction_id: ids.transactionId,
|
|
66
|
-
amount,
|
|
67
|
-
currency,
|
|
68
|
-
};
|
|
69
|
-
switch (event) {
|
|
70
|
-
case "session.succeeded":
|
|
71
|
-
case "payment_intent.succeeded":
|
|
72
|
-
return base;
|
|
73
|
-
case "charge.succeeded":
|
|
74
|
-
// Von transaction id — the one to reconcile on (server sends it).
|
|
75
|
-
return { ...base, vp_tx_id: ids.transactionId, card: null };
|
|
76
|
-
case "session.failed":
|
|
77
|
-
case "payment_intent.failed":
|
|
78
|
-
return {
|
|
79
|
-
...base,
|
|
80
|
-
failure_reason: "Card declined",
|
|
81
|
-
failure_code: "card_declined",
|
|
82
|
-
network_decline_code: "05",
|
|
83
|
-
};
|
|
84
|
-
case "charge.failed":
|
|
85
|
-
return {
|
|
86
|
-
...base,
|
|
87
|
-
failure_reason: "Card declined",
|
|
88
|
-
failure_code: "card_declined",
|
|
89
|
-
// Non-null ONLY when failure_code is `blocked_by_rule`; this fixture is
|
|
90
|
-
// an ordinary decline, so a consumer must see the null.
|
|
91
|
-
rule_code: null,
|
|
92
|
-
// Always null on a decline: no money moved, no settlement row.
|
|
93
|
-
vp_tx_id: null,
|
|
94
|
-
network_decline_code: "05",
|
|
95
|
-
};
|
|
96
|
-
case "mirror.order.created":
|
|
97
|
-
// Connector-neutral, like the server: the merchant's own order number and
|
|
98
|
-
// the customer's order page. No session/transaction ids on this event.
|
|
99
|
-
return {
|
|
100
|
-
payment_intent_id: ids.paymentIntentId,
|
|
101
|
-
order_number: `TEST-${randomUUID().slice(0, 6).toUpperCase()}`,
|
|
102
|
-
order_status_url: null,
|
|
103
|
-
};
|
|
104
|
-
case "payment_intent.cancelled":
|
|
105
|
-
return { ...base, cancellation_reason: "buyer_abandoned" };
|
|
106
|
-
case "charge.refunded":
|
|
107
|
-
return {
|
|
108
|
-
...base,
|
|
109
|
-
refund_id: `vpr_test_${randomUUID().slice(0, 8)}`,
|
|
110
|
-
vp_tx_id: ids.transactionId,
|
|
111
|
-
// The two unambiguous companions to `amount`. The server has emitted
|
|
112
|
-
// both for some time; omitting them here made a handler that reads them
|
|
113
|
-
// look broken against a synthetic event.
|
|
114
|
-
refund_amount: amount,
|
|
115
|
-
amount_refunded_total: amount,
|
|
116
|
-
reason: "customer_request",
|
|
117
|
-
is_partial: false,
|
|
118
|
-
original_charge_amount: amount,
|
|
119
|
-
card: null,
|
|
120
|
-
};
|
|
121
|
-
case "refund.failed":
|
|
122
|
-
return {
|
|
123
|
-
...base,
|
|
124
|
-
refund_id: `vpr_test_${randomUUID().slice(0, 8)}`,
|
|
125
|
-
// Mirrors charge.refunded: the Von transaction id of the refunded charge.
|
|
126
|
-
vp_tx_id: ids.transactionId,
|
|
127
|
-
// No money moved: this is the reversal amount that FAILED to move.
|
|
128
|
-
refund_amount: amount,
|
|
129
|
-
amount_refunded_total: 0,
|
|
130
|
-
reason: "customer_request",
|
|
131
|
-
// LOCKED two-value refund vocabulary — `refund_declined` (terminal) or
|
|
132
|
-
// `refund_unresolved` (no provider response, true state unknown).
|
|
133
|
-
reason_code: "refund_declined",
|
|
134
|
-
is_partial: false,
|
|
135
|
-
original_charge_amount: amount,
|
|
136
|
-
retry_available: true,
|
|
137
|
-
card: null,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
export function buildPayload(event, opts) {
|
|
142
|
-
const amount = opts.amount ?? 1499;
|
|
143
|
-
const currency = opts.currency ?? "USD";
|
|
144
|
-
const ids = {
|
|
145
|
-
sessionId: opts.sessionId ?? `vp_cs_test_${randomUUID().slice(0, 8)}`,
|
|
146
|
-
transactionId: `vp_tx_test_${randomUUID().slice(0, 8)}`,
|
|
147
|
-
paymentIntentId: `vpi_test_${randomUUID().slice(0, 8)}`,
|
|
148
|
-
};
|
|
149
|
-
return {
|
|
150
|
-
id: `vp_evt_test_${randomUUID().slice(0, 8)}`,
|
|
151
|
-
type: event,
|
|
152
|
-
created: Math.floor(Date.now() / 1000),
|
|
153
|
-
livemode: false,
|
|
154
|
-
merchant_id: `vp_mer_test_${randomUUID().slice(0, 8)}`,
|
|
155
|
-
test_event: true,
|
|
156
|
-
data: buildEventData(event, ids, amount, currency),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
export function triggerCommand() {
|
|
160
|
-
return new Command("trigger")
|
|
161
|
-
.description("Send a test webhook event to a local URL")
|
|
162
|
-
.argument("<event>", `Event type (${SUPPORTED_EVENTS.join(", ")})`)
|
|
163
|
-
.requiredOption("--url <url>", "Local webhook URL (e.g. http://localhost:3000/webhooks)")
|
|
164
|
-
.option("--session-id <id>", "Custom session ID")
|
|
165
|
-
.option("--amount <cents>", "Amount in minor units", (v) => parseInt(v, 10))
|
|
166
|
-
.option("--currency <code>", "Currency code")
|
|
167
|
-
.option("--url-tunnel", "Allow a non-loopback --url (ngrok / Cloudflare Tunnel). Without it, --url must be this machine")
|
|
168
|
-
.option("--confirm-live", "Required when the loaded key is vp_sk_live_*: the event is signed with that LIVE key and sent to --url")
|
|
169
|
-
.action(async (event, opts) => {
|
|
170
|
-
if (!SUPPORTED_EVENTS.includes(event)) {
|
|
171
|
-
console.error(chalk.red(`Unknown event: ${event}\nSupported: ${SUPPORTED_EVENTS.join(", ")}`));
|
|
172
|
-
process.exit(1);
|
|
173
|
-
}
|
|
174
|
-
warnIfUnsubscribable(event);
|
|
175
|
-
// Same destination policy as `listen --forward-to`: this machine only,
|
|
176
|
-
// unless --url-tunnel. A signed synthetic event is a local-dev tool; a
|
|
177
|
-
// production endpoint that verifies with the API key would accept it as
|
|
178
|
-
// a genuine paid-order event.
|
|
179
|
-
const destination = validateForwardTo(String(opts.url ?? ""), {
|
|
180
|
-
allowTunnel: opts.urlTunnel === true,
|
|
181
|
-
flag: "--url",
|
|
182
|
-
tunnelFlag: "--url-tunnel",
|
|
183
|
-
});
|
|
184
|
-
if (!destination.ok) {
|
|
185
|
-
console.error(chalk.red(destination.reason));
|
|
186
|
-
process.exit(1);
|
|
187
|
-
}
|
|
188
|
-
if (destination.warning)
|
|
189
|
-
console.warn(chalk.yellow(destination.warning));
|
|
190
|
-
const apiKey = requireApiKey();
|
|
191
|
-
// A synthetic event signed with a LIVE key is a real signature from a
|
|
192
|
-
// real secret, sent to whatever --url says (any host, not only
|
|
193
|
-
// localhost). A receiver that verifies with that key — the documented
|
|
194
|
-
// local-dev stand-in — accepts it as genuine, so a live-key trigger
|
|
195
|
-
// aimed at a production endpoint forges a paid-order event. Same gate as
|
|
196
|
-
// the money commands, before anything is signed or sent.
|
|
197
|
-
requireLiveConfirmation(apiKey, opts, "trigger a test webhook event", `signs a synthetic event with your LIVE key and sends it to ${safeDisplay(String(opts.url))}`);
|
|
198
|
-
const payload = buildPayload(event, opts);
|
|
199
|
-
const body = JSON.stringify(payload);
|
|
200
|
-
// v1 webhook signature contract: ONE `x-vonpay-signature` header of
|
|
201
|
-
// shape `t=<unix-seconds>,v1=<hex>`, HMAC-SHA256 over `${t}.${body}`.
|
|
202
|
-
// There is no separate timestamp header. For this local trigger the
|
|
203
|
-
// signing secret is your API key (verify with
|
|
204
|
-
// `constructEvent(rawBody, signatureHeader, apiKey)`).
|
|
205
|
-
const t = Math.floor(Date.now() / 1000);
|
|
206
|
-
const v1 = createHmac("sha256", apiKey)
|
|
207
|
-
.update(`${t}.${body}`)
|
|
208
|
-
.digest("hex");
|
|
209
|
-
const signatureHeader = `t=${t},v1=${v1}`;
|
|
210
|
-
const spinner = ora(`Sending ${event} to ${opts.url}...`).start();
|
|
211
|
-
try {
|
|
212
|
-
const response = await fetch(opts.url, {
|
|
213
|
-
method: "POST",
|
|
214
|
-
headers: {
|
|
215
|
-
"Content-Type": "application/json",
|
|
216
|
-
"x-vonpay-signature": signatureHeader,
|
|
217
|
-
"User-Agent": "VonPay-Webhook/1.0 (CLI trigger)",
|
|
218
|
-
},
|
|
219
|
-
body,
|
|
220
|
-
signal: AbortSignal.timeout(10_000),
|
|
221
|
-
});
|
|
222
|
-
spinner.stop();
|
|
223
|
-
if (response.ok) {
|
|
224
|
-
console.log(chalk.green(`✓ ${event} delivered → ${response.status}`));
|
|
225
|
-
}
|
|
226
|
-
else {
|
|
227
|
-
console.log(chalk.yellow(`⚠ ${event} delivered but got ${response.status} response`));
|
|
228
|
-
}
|
|
229
|
-
console.log(chalk.dim(` Event: ${payload.id} (${payload.type})`));
|
|
230
|
-
console.log(chalk.dim(` Amount: ${payload.data.amount} ${payload.data.currency}`));
|
|
231
|
-
console.log(chalk.dim(`\n Verify with: vonpay.webhooks.constructEvent(rawBody, signatureHeader, secret)`));
|
|
232
|
-
console.log(chalk.dim(` (local dev: 'secret' is your API key here — production webhooks are signed with your endpoint's whsec_… secret, NOT your API key)`));
|
|
233
|
-
}
|
|
234
|
-
catch (err) {
|
|
235
|
-
spinner.stop();
|
|
236
|
-
if (err instanceof Error && err.name === "TimeoutError") {
|
|
237
|
-
console.error(chalk.red(`Timeout: ${opts.url} did not respond within 10s`));
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
console.error(chalk.red(`Failed to deliver: ${err instanceof Error ? err.message : err}`));
|
|
241
|
-
}
|
|
242
|
-
process.exit(1);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
//# sourceMappingURL=trigger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trigger.js","sourceRoot":"","sources":["../../src/commands/trigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAA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7D,CACF,CAAC;YACF,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CACP,mFAAmF,CACpF,CACF,CAAC;YACF,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,GAAG,CACP,qIAAqI,CACtI,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,EAAE,CAAC;YACf,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;gBACxD,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,GAAG,6BAA6B,CAAC,CAAC,CAAC;YAC9E,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CACX,KAAK,CAAC,GAAG,CACP,sBAAsB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CACjE,CACF,CAAC;YACJ,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/config.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface CliConfig {
|
|
2
|
-
checkout?: {
|
|
3
|
-
apiKey?: string;
|
|
4
|
-
baseUrl?: string;
|
|
5
|
-
};
|
|
6
|
-
}
|
|
7
|
-
export declare function loadConfig(): CliConfig;
|
|
8
|
-
export declare function saveConfig(config: CliConfig): void;
|
|
9
|
-
/**
|
|
10
|
-
* Remove the stored API key from `~/.vonpay/config.json` (the `logout` flow).
|
|
11
|
-
* Drops only the secret — any non-secret config (e.g. `baseUrl`) is preserved —
|
|
12
|
-
* and deletes the file entirely if nothing else remains, so a clean logout
|
|
13
|
-
* leaves no plaintext-key husk on disk. Does NOT touch `VON_PAY_SECRET_KEY` in
|
|
14
|
-
* the environment (the caller surfaces that, since it still takes precedence).
|
|
15
|
-
* Returns whether a stored key was actually present.
|
|
16
|
-
*/
|
|
17
|
-
export declare function clearStoredApiKey(): {
|
|
18
|
-
removed: boolean;
|
|
19
|
-
};
|
|
20
|
-
export declare function getApiKey(): string | undefined;
|
|
21
|
-
export declare function requireApiKey(): string;
|
|
22
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { emitCliError } from "./utils/json-errors.js";
|
|
5
|
-
const CONFIG_DIR = join(homedir(), ".vonpay");
|
|
6
|
-
const CONFIG_FILE = join(CONFIG_DIR, "config.json");
|
|
7
|
-
export function loadConfig() {
|
|
8
|
-
if (!existsSync(CONFIG_FILE))
|
|
9
|
-
return {};
|
|
10
|
-
try {
|
|
11
|
-
return JSON.parse(readFileSync(CONFIG_FILE, "utf-8"));
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
console.error("Warning: ~/.vonpay/config.json is malformed. Run `vonpay checkout login` to reset it.");
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export function saveConfig(config) {
|
|
19
|
-
if (!existsSync(CONFIG_DIR)) {
|
|
20
|
-
mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
21
|
-
}
|
|
22
|
-
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n", {
|
|
23
|
-
encoding: "utf-8",
|
|
24
|
-
mode: 0o600,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Remove the stored API key from `~/.vonpay/config.json` (the `logout` flow).
|
|
29
|
-
* Drops only the secret — any non-secret config (e.g. `baseUrl`) is preserved —
|
|
30
|
-
* and deletes the file entirely if nothing else remains, so a clean logout
|
|
31
|
-
* leaves no plaintext-key husk on disk. Does NOT touch `VON_PAY_SECRET_KEY` in
|
|
32
|
-
* the environment (the caller surfaces that, since it still takes precedence).
|
|
33
|
-
* Returns whether a stored key was actually present.
|
|
34
|
-
*/
|
|
35
|
-
export function clearStoredApiKey() {
|
|
36
|
-
const config = loadConfig();
|
|
37
|
-
// Nothing to remove → touch nothing on disk (no redundant rewrite, and a
|
|
38
|
-
// malformed/parse-failed config is left alone rather than silently deleted).
|
|
39
|
-
if (!config.checkout?.apiKey)
|
|
40
|
-
return { removed: false };
|
|
41
|
-
delete config.checkout.apiKey;
|
|
42
|
-
// Drop an emptied `checkout` block so we don't persist a bare `{}` husk.
|
|
43
|
-
if (Object.keys(config.checkout).length === 0)
|
|
44
|
-
delete config.checkout;
|
|
45
|
-
if (Object.keys(config).length === 0) {
|
|
46
|
-
// Nothing left to persist — remove the file so logout leaves no trace.
|
|
47
|
-
// `force` tolerates a concurrent delete (no uncaught ENOENT on a TOCTOU race).
|
|
48
|
-
rmSync(CONFIG_FILE, { force: true });
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
saveConfig(config);
|
|
52
|
-
}
|
|
53
|
-
return { removed: true };
|
|
54
|
-
}
|
|
55
|
-
export function getApiKey() {
|
|
56
|
-
// Env var takes precedence
|
|
57
|
-
const envKey = process.env.VON_PAY_SECRET_KEY;
|
|
58
|
-
if (envKey)
|
|
59
|
-
return envKey;
|
|
60
|
-
const config = loadConfig();
|
|
61
|
-
return config.checkout?.apiKey;
|
|
62
|
-
}
|
|
63
|
-
export function requireApiKey() {
|
|
64
|
-
const key = getApiKey();
|
|
65
|
-
if (!key) {
|
|
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);
|
|
69
|
-
}
|
|
70
|
-
return key;
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AAC9C,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AASpD,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QAAE,OAAO,EAAE,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAc,CAAC;IACrE,CAAC;IAAC,MAAM,CAAC;QACP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A2B;IAC3B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAC9C,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAE1B,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC;IAC5B,OAAO,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC;AACjC,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,MAAM,GAAG,GAAG,SAAS,EAAE,CAAC;IACxB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,iCAAiC;QACjC,MAAM,OAAO,GACX,0EAA0E,CAAC;QAC7E,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CACpB,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAC7D,CAAC;AAEF,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,8BAA8B,CAAC;KAC3C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAExB,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAE1B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/utils/errors.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
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;
|
|
75
|
-
export declare function handleError(err: unknown): never;
|
|
76
|
-
export declare const __testing__: {
|
|
77
|
-
scrubSecrets: typeof scrubSecrets;
|
|
78
|
-
};
|
|
79
|
-
export {};
|
|
80
|
-
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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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