vibecash 0.2.5 → 0.2.7

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 (2) hide show
  1. package/dist/index.js +87 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -265,12 +265,15 @@ function registerPriceCommands(program2) {
265
265
  if (opts.interval) body.interval = opts.interval;
266
266
  const data = await apiRequest("POST", "/prices", body);
267
267
  success("Price created");
268
- output(data, (d) => [
269
- `Price ID: ${d.id}`,
270
- `Amount: ${fmtAmount(d.unitAmount ?? d.amount, d.currency)}`,
271
- `Type: ${d.type}`,
272
- d.interval ? `Interval: ${d.interval}` : null
273
- ].filter(Boolean).join("\n"));
268
+ output(data, (d) => {
269
+ const payUrl = process.env.VIBECASH_PAY_URL || "https://vibecash.dev";
270
+ return [
271
+ `Price ID: ${d.id}`,
272
+ `Amount: ${fmtAmount(d.unitAmount ?? d.amount, d.currency)}${d.interval ? "/" + d.interval : ""}`,
273
+ `Type: ${d.type}`,
274
+ `Payment URL: ${payUrl}/buy/${d.id}`
275
+ ].join("\n");
276
+ });
274
277
  } catch (err) {
275
278
  console.error(`Error: ${err.message}`);
276
279
  process.exit(1);
@@ -1008,6 +1011,83 @@ function registerWebhookCommands(program2) {
1008
1011
  });
1009
1012
  }
1010
1013
 
1014
+ // src/commands/key.ts
1015
+ function registerKeyCommands(program2) {
1016
+ const key = program2.command("key").description("Manage API keys");
1017
+ key.command("create").description("Create a new API key").requiredOption("-t, --type <type>", "Key type: full or server").option("-n, --name <name>", 'Key name (e.g. "Production Backend")').action(async (opts) => {
1018
+ try {
1019
+ if (opts.type !== "full" && opts.type !== "server") {
1020
+ console.error('Error: type must be "full" or "server"');
1021
+ process.exit(1);
1022
+ }
1023
+ const body = { type: opts.type };
1024
+ if (opts.name) body.name = opts.name;
1025
+ const data = await apiRequest("POST", "/keys", body);
1026
+ success(`${opts.type === "server" ? "Server" : "Full"} key created`);
1027
+ output(data, (d) => [
1028
+ `Key ID: ${d.id}`,
1029
+ `Secret: ${d.secret}`,
1030
+ `Type: ${d.type}`,
1031
+ d.name ? `Name: ${d.name}` : null,
1032
+ "",
1033
+ "Save this secret \u2014 it will not be shown again.",
1034
+ opts.type === "server" ? "This key can create products, prices, and checkouts but cannot issue refunds or payouts." : null
1035
+ ].filter(Boolean).join("\n"));
1036
+ } catch (err) {
1037
+ console.error(`Error: ${err.message}`);
1038
+ process.exit(1);
1039
+ }
1040
+ });
1041
+ key.command("list").description("List all API keys").action(async () => {
1042
+ try {
1043
+ const data = await apiRequest("GET", "/keys");
1044
+ output(data, (d) => {
1045
+ const items = d.data || [];
1046
+ if (!Array.isArray(items) || items.length === 0) return "No API keys found.";
1047
+ table(
1048
+ ["ID", "Type", "Name", "Last Used", "Active"],
1049
+ items.map((k) => [
1050
+ k.id,
1051
+ k.type,
1052
+ k.name || "-",
1053
+ k.lastUsedAt ? fmtDate(k.lastUsedAt) : "Never",
1054
+ k.active ? "yes" : "no"
1055
+ ])
1056
+ );
1057
+ return "";
1058
+ });
1059
+ } catch (err) {
1060
+ console.error(`Error: ${err.message}`);
1061
+ process.exit(1);
1062
+ }
1063
+ });
1064
+ key.command("revoke <id>").description("Revoke an API key").action(async (id) => {
1065
+ try {
1066
+ await apiRequest("DELETE", `/keys/${id}`);
1067
+ success(`Key ${id} revoked`);
1068
+ } catch (err) {
1069
+ console.error(`Error: ${err.message}`);
1070
+ process.exit(1);
1071
+ }
1072
+ });
1073
+ key.command("roll <id>").description("Rotate an API key (new secret, old one stops working)").action(async (id) => {
1074
+ try {
1075
+ const data = await apiRequest("POST", `/keys/${id}/roll`);
1076
+ success("Key rotated");
1077
+ output(data, (d) => [
1078
+ `Key ID: ${d.id}`,
1079
+ `New Secret: ${d.secret}`,
1080
+ "",
1081
+ "Save this secret \u2014 it will not be shown again.",
1082
+ "The old secret has been invalidated."
1083
+ ].join("\n"));
1084
+ } catch (err) {
1085
+ console.error(`Error: ${err.message}`);
1086
+ process.exit(1);
1087
+ }
1088
+ });
1089
+ }
1090
+
1011
1091
  // src/index.ts
1012
1092
  var program = new Command();
1013
1093
  program.name("vibecash").description("VibeCash CLI - manage payments from the command line").version("0.2.2").option("--json", "Output in JSON format").hook("preAction", (thisCommand) => {
@@ -1026,4 +1106,5 @@ registerPayoutCommands(program);
1026
1106
  registerBankCommands(program);
1027
1107
  registerKycCommands(program);
1028
1108
  registerWebhookCommands(program);
1109
+ registerKeyCommands(program);
1029
1110
  program.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibecash",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "VibeCash CLI - Payment infrastructure for the AI era. Accept cards, e-wallets, and QR payments in Southeast Asia.",
5
5
  "type": "module",
6
6
  "bin": {