@vonpay/checkout-cli 0.5.0 → 0.5.1
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 +9 -0
- package/dist/commands/checkout.d.ts.map +1 -1
- package/dist/commands/checkout.js +2 -0
- package/dist/commands/checkout.js.map +1 -1
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +23 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/config.d.ts +11 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +29 -1
- package/dist/config.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,6 +20,14 @@ vonpay checkout login
|
|
|
20
20
|
|
|
21
21
|
Stores credentials at `~/.vonpay/config.json` (mode `0600`). Use a test-mode key (`vp_sk_test_...`) for local development. The CLI also reads `VON_PAY_SECRET_KEY` from the environment if set, which takes precedence over the saved config.
|
|
22
22
|
|
|
23
|
+
The key is stored in plaintext (owner-only `0600`), so remove it before sharing or decommissioning a machine:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
vonpay checkout logout
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`logout` deletes the stored key (and the config file if nothing else remains). It does not unset `VON_PAY_SECRET_KEY` — if that environment variable is set it still takes precedence, so `unset` it to fully log out of the shell.
|
|
30
|
+
|
|
23
31
|
## Commands
|
|
24
32
|
|
|
25
33
|
All commands are namespaced under `vonpay checkout`:
|
|
@@ -27,6 +35,7 @@ All commands are namespaced under `vonpay checkout`:
|
|
|
27
35
|
| Command | Purpose |
|
|
28
36
|
|---|---|
|
|
29
37
|
| `vonpay checkout login` | Save API key to `~/.vonpay/config.json` |
|
|
38
|
+
| `vonpay checkout logout` | Remove the stored API key from `~/.vonpay/config.json` |
|
|
30
39
|
| `vonpay checkout init` | Scaffold a minimal checkout integration starter |
|
|
31
40
|
| `vonpay checkout sessions create` | Create a hosted-checkout session and print the URL |
|
|
32
41
|
| `vonpay checkout sessions get <id>` | Fetch session details |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/commands/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/commands/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAcpC,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiBvD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { loginCommand } from "./login.js";
|
|
2
|
+
import { logoutCommand } from "./logout.js";
|
|
2
3
|
import { initCommand } from "./init.js";
|
|
3
4
|
import { sessionsCommand } from "./sessions.js";
|
|
4
5
|
import { paymentIntentsCommand } from "./payment-intents.js";
|
|
@@ -14,6 +15,7 @@ export function registerCheckout(program) {
|
|
|
14
15
|
.command("checkout")
|
|
15
16
|
.description("Checkout integration tools");
|
|
16
17
|
checkout.addCommand(loginCommand());
|
|
18
|
+
checkout.addCommand(logoutCommand());
|
|
17
19
|
checkout.addCommand(initCommand());
|
|
18
20
|
checkout.addCommand(sessionsCommand());
|
|
19
21
|
checkout.addCommand(paymentIntentsCommand());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/commands/checkout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,aAAa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EAAE,CAAC,CAAC;IACrC,QAAQ,CAAC,UAAU,CAAC,aAAa,EAAE,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/dist/config.d.ts
CHANGED
|
@@ -6,6 +6,17 @@ export interface CliConfig {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function loadConfig(): CliConfig;
|
|
8
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
|
+
};
|
|
9
20
|
export declare function getApiKey(): string | undefined;
|
|
10
21
|
export declare function requireApiKey(): string;
|
|
11
22
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,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,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAO9C;AAED,wBAAgB,aAAa,IAAI,MAAM,CAStC"}
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,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,4 +1,4 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
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
4
|
const CONFIG_DIR = join(homedir(), ".vonpay");
|
|
@@ -23,6 +23,34 @@ export function saveConfig(config) {
|
|
|
23
23
|
mode: 0o600,
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Remove the stored API key from `~/.vonpay/config.json` (the `logout` flow).
|
|
28
|
+
* Drops only the secret — any non-secret config (e.g. `baseUrl`) is preserved —
|
|
29
|
+
* and deletes the file entirely if nothing else remains, so a clean logout
|
|
30
|
+
* leaves no plaintext-key husk on disk. Does NOT touch `VON_PAY_SECRET_KEY` in
|
|
31
|
+
* the environment (the caller surfaces that, since it still takes precedence).
|
|
32
|
+
* Returns whether a stored key was actually present.
|
|
33
|
+
*/
|
|
34
|
+
export function clearStoredApiKey() {
|
|
35
|
+
const config = loadConfig();
|
|
36
|
+
// Nothing to remove → touch nothing on disk (no redundant rewrite, and a
|
|
37
|
+
// malformed/parse-failed config is left alone rather than silently deleted).
|
|
38
|
+
if (!config.checkout?.apiKey)
|
|
39
|
+
return { removed: false };
|
|
40
|
+
delete config.checkout.apiKey;
|
|
41
|
+
// Drop an emptied `checkout` block so we don't persist a bare `{}` husk.
|
|
42
|
+
if (Object.keys(config.checkout).length === 0)
|
|
43
|
+
delete config.checkout;
|
|
44
|
+
if (Object.keys(config).length === 0) {
|
|
45
|
+
// Nothing left to persist — remove the file so logout leaves no trace.
|
|
46
|
+
// `force` tolerates a concurrent delete (no uncaught ENOENT on a TOCTOU race).
|
|
47
|
+
rmSync(CONFIG_FILE, { force: true });
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
saveConfig(config);
|
|
51
|
+
}
|
|
52
|
+
return { removed: true };
|
|
53
|
+
}
|
|
26
54
|
export function getApiKey() {
|
|
27
55
|
// Env var takes precedence
|
|
28
56
|
const envKey = process.env.VON_PAY_SECRET_KEY;
|
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,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;
|
|
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;AAEjC,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,OAAO,CAAC,KAAK,CACX,uFAAuF,CACxF,CAAC;QACF,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAiB;IAC1C,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,aAAa,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE;QACjE,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;AACL,CAAC;AAED;;;;;;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