@agenzo/token-cli 0.3.0 → 0.3.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/dist/index.js CHANGED
@@ -270,10 +270,6 @@ var ApiClient = class {
270
270
  const headers = {
271
271
  "User-Agent": `agenzo-admin-cli/${getCurrentVersion()}`
272
272
  };
273
- const traceparent = process.env.TRACEPARENT;
274
- if (traceparent) {
275
- headers["traceparent"] = traceparent;
276
- }
277
273
  if (auth.type === "bearer") {
278
274
  headers["Authorization"] = `Bearer ${auth.token}`;
279
275
  } else if (auth.type === "api-key") {
@@ -696,17 +692,11 @@ async function renderWithContext(result, opts, configManager) {
696
692
  render({ ...result, data: payload }, opts);
697
693
  }
698
694
  var PromptEngine = class {
699
- /** Return flagValue if provided, else env fallback, else prompt interactively */
695
+ /** Return flagValue directly if provided, otherwise prompt interactively */
700
696
  static async resolveInput(flagValue, config) {
701
697
  if (flagValue !== void 0) {
702
698
  return flagValue;
703
699
  }
704
- if (config.envVar) {
705
- const envValue = process.env[config.envVar];
706
- if (envValue !== void 0 && envValue !== "") {
707
- return envValue;
708
- }
709
- }
710
700
  if (config.type === "password") {
711
701
  return password({ message: config.message, mask: "*" });
712
702
  }
@@ -753,247 +743,21 @@ async function collectPaymentMethodParams(type, flags) {
753
743
  return params;
754
744
  }
755
745
 
756
- // src/verb-schema.ts
757
- var CLI_NAME = "agenzo-token-cli";
758
- function wantsJsonSchema(argv = process.argv) {
759
- for (let i = 0; i < argv.length; i++) {
760
- const a = argv[i];
761
- if (a === "--format=json") return true;
762
- if (a === "--format" && argv[i + 1] === "json") return true;
763
- }
764
- return false;
765
- }
766
- function emitSchema(schema) {
767
- console.log(JSON.stringify(schema, null, 2));
768
- }
769
- function attachSchemaHelp(cmd, schema) {
770
- const baseHelp = cmd.helpInformation.bind(cmd);
771
- cmd.helpInformation = (context) => {
772
- if (!wantsJsonSchema()) return baseHelp(context);
773
- emitSchema(schema);
774
- return "";
775
- };
776
- return cmd;
777
- }
778
- var pmAddSchema = {
779
- cli: CLI_NAME,
780
- noun: "payment-methods",
781
- verb: "add",
782
- description: "Add a payment method (card binding + 3DS verification)",
783
- flags: {
784
- "card-number": { type: "string", required: true, description: "Card number (PAN)" },
785
- "exp-month": { type: "string", required: true, description: "Expiration month (MM)" },
786
- "exp-year": { type: "string", required: true, description: "Expiration year (YY or YYYY)" },
787
- "cardholder-name": { type: "string", required: true, description: "Name on the card" },
788
- "member-id": { type: "string", required: false, description: "Member ID to associate the card with" },
789
- "api-key": { type: "string", required: true, description: "API Key for authentication", source: "config" }
790
- },
791
- response: {
792
- id: { type: "string", description: "Payment method ID" },
793
- status: { type: "string", description: "PENDING / ACTIVE / FAILED" },
794
- card_brand: { type: "string", description: "visa / mastercard / ..." },
795
- last_four: { type: "string", description: "Last 4 digits of card" },
796
- verification_url: { type: "string|null", description: "3DS verification URL (when PENDING)" }
797
- },
798
- example: {
799
- command: 'agenzo-token-cli payment-methods add --card-number 4111111111111111 --exp-month 12 --exp-year 2027 --cardholder-name "Alice Test"',
800
- output_summary: "Returns payment method ID and 3DS verification URL. Complete 3DS to activate."
801
- },
802
- error_recovery: {
803
- INVALID_CARD: "Card number failed Luhn check or is not supported. Verify and retry.",
804
- EVO_ERROR: "Upstream payment processor error. Retry after a short delay."
805
- }
806
- };
807
- var pmListSchema = {
808
- cli: CLI_NAME,
809
- noun: "payment-methods",
810
- verb: "list",
811
- description: "List payment methods for the authenticated developer",
812
- flags: {
813
- "member": { type: "string", required: false, description: "Filter by member ID" },
814
- "api-key": { type: "string", required: true, description: "API Key for authentication", source: "config" }
815
- },
816
- response: {
817
- payment_methods: {
818
- type: "array",
819
- description: "List of payment methods",
820
- items: {
821
- id: { type: "string", description: "Payment method ID" },
822
- status: { type: "string", description: "PENDING / ACTIVE / DISABLED" },
823
- card_brand: { type: "string", description: "Card brand" },
824
- last_four: { type: "string", description: "Last 4 digits" },
825
- created_at: { type: "string", description: "Creation time (ISO 8601)" }
826
- }
827
- }
828
- },
829
- example: {
830
- command: "agenzo-token-cli payment-methods list",
831
- output_summary: "Returns array of payment methods with status and card info."
832
- }
833
- };
834
- var pmGetSchema = {
835
- cli: CLI_NAME,
836
- noun: "payment-methods",
837
- verb: "get",
838
- description: "Get a payment method by ID",
839
- flags: {
840
- "pm-id": { type: "string", required: true, description: "Payment method ID" },
841
- "api-key": { type: "string", required: true, description: "API Key for authentication", source: "config" }
842
- },
843
- response: {
844
- id: { type: "string", description: "Payment method ID" },
845
- status: { type: "string", description: "PENDING / ACTIVE / DISABLED / FAILED / EXPIRED" },
846
- card_brand: { type: "string", description: "Card brand" },
847
- last_four: { type: "string", description: "Last 4 digits" },
848
- member_id: { type: "string|null", description: "Associated member ID" },
849
- created_at: { type: "string", description: "Creation time" }
850
- },
851
- example: {
852
- command: "agenzo-token-cli payment-methods get pm_01HZXD...",
853
- output_summary: "Returns full payment method details including 3DS verification status."
854
- }
855
- };
856
- var pmDisableSchema = {
857
- cli: CLI_NAME,
858
- noun: "payment-methods",
859
- verb: "disable",
860
- description: "Disable a payment method (cascades revoke on active payment tokens)",
861
- flags: {
862
- "pm-id": { type: "string", required: true, description: "Payment method ID to disable" },
863
- "api-key": { type: "string", required: true, description: "API Key for authentication", source: "config" }
864
- },
865
- response: {
866
- id: { type: "string", description: "Disabled payment method ID" },
867
- status: { type: "string", description: "DISABLED" },
868
- revoked_tokens_count: { type: "int", description: "Number of payment tokens revoked by cascade" }
869
- },
870
- example: {
871
- command: "agenzo-token-cli payment-methods disable pm_01HZXD...",
872
- output_summary: "Disables the payment method and revokes any active tokens bound to it."
873
- }
874
- };
875
- var ptCreateSchema = {
876
- cli: CLI_NAME,
877
- noun: "payment-tokens",
878
- verb: "create",
879
- description: "Create a payment token (VCN, Network Token cryptogram, or x402 USDC signature)",
880
- flags: {
881
- "type": { type: "string", required: true, description: "Token type: vcn / network_token / x402", constraints: "vcn | network_token | x402" },
882
- "payment-method-id": { type: "string", required: true, description: "Source payment method ID (must be ACTIVE)" },
883
- "amount": { type: "string", required: "conditional", description: "Amount in minor units (required for vcn and x402)" },
884
- "currency": { type: "string", required: false, default: "USD", description: "ISO 4217 currency code" },
885
- "member-id": { type: "string", required: false, description: "Member ID" },
886
- "external-transaction-id": { type: "string", required: false, description: "External reference for reconciliation" },
887
- "pay-to": { type: "string", required: "conditional", description: "Recipient address (required for x402)" },
888
- "nonce": { type: "string", required: "conditional", description: "Nonce bytes32 hex (required for x402)" },
889
- "network": { type: "string", required: "conditional", description: "Chain network (required for x402, e.g. base-sepolia)" },
890
- "deadline": { type: "int", required: "conditional", description: "Epoch seconds deadline (required for x402)" },
891
- "api-key": { type: "string", required: true, description: "API Key for authentication", source: "config" }
892
- },
893
- response: {
894
- id: { type: "string", description: "Payment token ID" },
895
- type: { type: "string", description: "vcn / network_token / x402" },
896
- status: { type: "string", description: "ACTIVE / REVOKED / EXPIRED" },
897
- token_data: { type: "object", description: "Type-specific token payload (cryptogram / VCN number / x402 signature)" },
898
- expires_at: { type: "string|null", description: "Expiration time (ISO 8601)" }
899
- },
900
- example: {
901
- command: "agenzo-token-cli payment-tokens create --type network_token --payment-method-id pm_01HZXD...",
902
- output_summary: "Returns token ID and cryptogram/VCN/signature data for payment execution."
903
- },
904
- error_recovery: {
905
- INVALID_PAYMENT_METHOD: "Payment method is not ACTIVE or not found. Verify status with payment-methods get.",
906
- UNSUPPORTED_TOKEN_TYPE: "Use vcn, network_token, or x402."
907
- }
908
- };
909
- var ptListSchema = {
910
- cli: CLI_NAME,
911
- noun: "payment-tokens",
912
- verb: "list",
913
- description: "List payment tokens for the authenticated developer",
914
- flags: {
915
- "type": { type: "string", required: false, description: "Filter by token type (vcn / network_token / x402)" },
916
- "member-id": { type: "string", required: false, description: "Filter by member ID" },
917
- "payment-method-id": { type: "string", required: false, description: "Filter by source payment method" },
918
- "api-key": { type: "string", required: true, description: "API Key for authentication", source: "config" }
919
- },
920
- response: {
921
- payment_tokens: {
922
- type: "array",
923
- description: "List of payment tokens",
924
- items: {
925
- id: { type: "string", description: "Token ID" },
926
- type: { type: "string", description: "Token type" },
927
- status: { type: "string", description: "ACTIVE / REVOKED / EXPIRED" },
928
- payment_method_id: { type: "string", description: "Source payment method" },
929
- created_at: { type: "string", description: "Creation time" }
930
- }
931
- }
932
- },
933
- example: {
934
- command: "agenzo-token-cli payment-tokens list --type network_token",
935
- output_summary: "Returns array of payment tokens filtered by type."
936
- }
937
- };
938
- var ptGetSchema = {
939
- cli: CLI_NAME,
940
- noun: "payment-tokens",
941
- verb: "get",
942
- description: "Get a payment token by ID",
943
- flags: {
944
- "payment-token-id": { type: "string", required: true, description: "Payment token ID" },
945
- "api-key": { type: "string", required: true, description: "API Key for authentication", source: "config" }
946
- },
947
- response: {
948
- id: { type: "string", description: "Token ID" },
949
- type: { type: "string", description: "Token type" },
950
- status: { type: "string", description: "ACTIVE / REVOKED / EXPIRED" },
951
- token_data: { type: "object", description: "Type-specific payload" },
952
- payment_method_id: { type: "string", description: "Source payment method" },
953
- created_at: { type: "string", description: "Creation time" },
954
- expires_at: { type: "string|null", description: "Expiration time" }
955
- },
956
- example: {
957
- command: "agenzo-token-cli payment-tokens get pt_01HZXD...",
958
- output_summary: "Returns full token details including token_data payload."
959
- }
960
- };
961
- var ptRevokeSchema = {
962
- cli: CLI_NAME,
963
- noun: "payment-tokens",
964
- verb: "revoke",
965
- description: "Revoke an active payment token",
966
- flags: {
967
- "payment-token-id": { type: "string", required: true, description: "Payment token ID to revoke" },
968
- "api-key": { type: "string", required: true, description: "API Key for authentication", source: "config" }
969
- },
970
- response: {
971
- id: { type: "string", description: "Revoked token ID" },
972
- status: { type: "string", description: "REVOKED" }
973
- },
974
- example: {
975
- command: "agenzo-token-cli payment-tokens revoke pt_01HZXD...",
976
- output_summary: "Marks the token as REVOKED. Cannot be undone."
977
- }
978
- };
979
-
980
746
  // src/payment-methods/add.ts
981
747
  var POLL_INTERVAL_MS = 3e3;
982
748
  var POLL_TIMEOUT_MS = 15 * 60 * 1e3;
983
749
  function registerAddCommand(parent, deps) {
984
- const cmd = parent.command("add").description("Add a payment method (card binding + 3DS)").option("--api-key <key>", "API Key for authentication").option("--type <type>", "Payment method type (default: card)", "card").option("--email <email>", "Email for 3DS verification").option("--card-number <number>", "Card number").option("--expiry <mmyy>", "Expiry date (MMYY format)").option("--cvv <cvv>", "Card CVV").option(
750
+ const cmd = parent.command("add").description("Add a payment method (with 3DS verification)").option("--api-key <key>", "API Key for authentication").option("--type <type>", "Payment method type (default: card)", "card").option("--email <email>", "Email for 3DS verification").option("--card-number <number>", "Card number").option("--expiry <mmyy>", "Expiry date (MMYY format)").option("--cvv <cvv>", "Card CVV").option(
985
751
  "--idempotency-key <key>",
986
752
  "Idempotency key forwarded verbatim as the Idempotency-Key header"
987
753
  );
988
- attachSchemaHelp(cmd, pmAddSchema);
989
754
  cmd.action(async () => {
990
755
  const opts = cmd.optsWithGlobals();
991
756
  const format = resolveFormat(opts.format);
992
757
  const isYes = Boolean(opts.yes);
993
758
  const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
994
759
  message: "API Key:",
995
- type: "password",
996
- envVar: "AGENZO_API_KEY"
760
+ type: "password"
997
761
  });
998
762
  const type = opts.type || "card";
999
763
  const flags = {
@@ -1134,14 +898,12 @@ function sleep(ms) {
1134
898
  // src/payment-methods/list.ts
1135
899
  function registerListCommand(parent, deps) {
1136
900
  const cmd = parent.command("list").description("List payment methods").option("--api-key <key>", "API Key for authentication").option("--member <member_id>", "Filter by member ID");
1137
- attachSchemaHelp(cmd, pmListSchema);
1138
901
  cmd.action(async () => {
1139
902
  const opts = cmd.optsWithGlobals();
1140
903
  const format = resolveFormat(opts.format);
1141
904
  const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
1142
905
  message: "API Key:",
1143
- type: "password",
1144
- envVar: "AGENZO_API_KEY"
906
+ type: "password"
1145
907
  });
1146
908
  const params = {};
1147
909
  if (opts.member) {
@@ -1182,14 +944,12 @@ function registerListCommand(parent, deps) {
1182
944
  // src/payment-methods/get.ts
1183
945
  function registerGetCommand(parent, deps) {
1184
946
  const cmd = parent.command("get <pm_id>").description("Get a payment method by ID").option("--api-key <key>", "API key for authentication");
1185
- attachSchemaHelp(cmd, pmGetSchema);
1186
947
  cmd.action(async (pmId) => {
1187
948
  const opts = cmd.optsWithGlobals();
1188
949
  const format = resolveFormat(opts.format);
1189
950
  const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
1190
951
  message: "API Key:",
1191
- type: "password",
1192
- envVar: "AGENZO_API_KEY"
952
+ type: "password"
1193
953
  });
1194
954
  const result = await deps.apiClient.get(
1195
955
  `/payment-methods/${pmId}`,
@@ -1229,14 +989,12 @@ function registerDisableCommand(parent, deps) {
1229
989
  "--idempotency-key <key>",
1230
990
  "Idempotency key forwarded verbatim as the Idempotency-Key header"
1231
991
  );
1232
- attachSchemaHelp(cmd, pmDisableSchema);
1233
992
  cmd.action(async (pmId) => {
1234
993
  const opts = cmd.optsWithGlobals();
1235
994
  const format = resolveFormat(opts.format);
1236
995
  const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
1237
996
  message: "API Key:",
1238
- type: "password",
1239
- envVar: "AGENZO_API_KEY"
997
+ type: "password"
1240
998
  });
1241
999
  let idempotencyKey = opts.idempotencyKey;
1242
1000
  if (!idempotencyKey) {
@@ -1387,15 +1145,13 @@ function registerCreateCommand(parent, deps) {
1387
1145
  "--idempotency-key <key>",
1388
1146
  "Idempotency key forwarded verbatim as the Idempotency-Key header"
1389
1147
  );
1390
- attachSchemaHelp(cmd, ptCreateSchema);
1391
1148
  cmd.action(async () => {
1392
1149
  const opts = cmd.optsWithGlobals();
1393
1150
  const format = resolveFormat(opts.format);
1394
1151
  const isYes = Boolean(opts.yes);
1395
1152
  const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
1396
1153
  message: "API Key:",
1397
- type: "password",
1398
- envVar: "AGENZO_API_KEY"
1154
+ type: "password"
1399
1155
  });
1400
1156
  const cliType = await PromptEngine.resolveInput(opts.type, {
1401
1157
  message: "Token type:",
@@ -1534,7 +1290,7 @@ function registerCreateCommand(parent, deps) {
1534
1290
  body.member_id = member;
1535
1291
  }
1536
1292
  if (opts.externalTxId) {
1537
- body.external_transaction_id = opts.externalTxId;
1293
+ body.external_tx_id = opts.externalTxId;
1538
1294
  }
1539
1295
  const extraHeaders = {
1540
1296
  "Idempotency-Key": idempotencyKey
@@ -1620,14 +1376,12 @@ function getSummary(token) {
1620
1376
  }
1621
1377
  function registerListCommand2(parent, deps) {
1622
1378
  const cmd = parent.command("list").description("List payment tokens").option("--api-key <key>", "API Key for authentication").option("--type <type>", "Filter by token type").option("--member <member_id>", "Filter by member ID");
1623
- attachSchemaHelp(cmd, ptListSchema);
1624
1379
  cmd.action(async () => {
1625
1380
  const opts = cmd.optsWithGlobals();
1626
1381
  const format = resolveFormat(opts.format);
1627
1382
  const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
1628
1383
  message: "API Key:",
1629
- type: "password",
1630
- envVar: "AGENZO_API_KEY"
1384
+ type: "password"
1631
1385
  });
1632
1386
  const params = {};
1633
1387
  if (opts.type) {
@@ -1758,14 +1512,12 @@ function formatCentsPlain(cents) {
1758
1512
  }
1759
1513
  function registerGetCommand2(parent, deps) {
1760
1514
  const cmd = parent.command("get <payment_token_id>").description("Get a payment token by ID").option("--api-key <key>", "API key for authentication").option("--reveal", "Reveal full VCN card number and CVC in the output");
1761
- attachSchemaHelp(cmd, ptGetSchema);
1762
1515
  cmd.action(async (paymentTokenId) => {
1763
1516
  const opts = cmd.optsWithGlobals();
1764
1517
  const format = resolveFormat(opts.format);
1765
1518
  const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
1766
1519
  message: "API Key:",
1767
- type: "password",
1768
- envVar: "AGENZO_API_KEY"
1520
+ type: "password"
1769
1521
  });
1770
1522
  const result = await deps.apiClient.get(
1771
1523
  `/payment-tokens/${paymentTokenId}`,
@@ -1791,14 +1543,12 @@ function registerRevokeCommand(parent, deps) {
1791
1543
  "--idempotency-key <key>",
1792
1544
  "Idempotency key forwarded verbatim as the Idempotency-Key header"
1793
1545
  );
1794
- attachSchemaHelp(cmd, ptRevokeSchema);
1795
1546
  cmd.action(async (paymentTokenId) => {
1796
1547
  const opts = cmd.optsWithGlobals();
1797
1548
  const format = resolveFormat(opts.format);
1798
1549
  const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
1799
1550
  message: "API Key:",
1800
- type: "password",
1801
- envVar: "AGENZO_API_KEY"
1551
+ type: "password"
1802
1552
  });
1803
1553
  let idempotencyKey = opts.idempotencyKey;
1804
1554
  if (!idempotencyKey) {
@@ -1867,7 +1617,7 @@ async function main() {
1867
1617
  const program = new Command();
1868
1618
  programRef = program;
1869
1619
  program.name("agenzo-token-cli").version(getCurrentVersion()).description(
1870
- "Agenzo token plane: payment methods (card binding + 3DS) and payment tokens (VCN / Network Token / X402)"
1620
+ "Agenzo token plane: payment methods (add payment method + 3DS) and payment tokens (VCN / Network Token / X402)"
1871
1621
  ).option("--verbose", "Show verbose logs").option("--yes", "Skip confirmation prompts (for automation/AI Agents)").option(
1872
1622
  "--format <format>",
1873
1623
  "Output format: json | table (default: table; or set AGENZO_FORMAT)"
@@ -1886,54 +1636,6 @@ async function main() {
1886
1636
  registerListCommand2(ptCmd, deps);
1887
1637
  registerGetCommand2(ptCmd, deps);
1888
1638
  registerRevokeCommand(ptCmd, deps);
1889
- const svcCmd = program.command("services").description("Token service discovery");
1890
- svcCmd.command("list").description("List available token services from platform catalog").option("--api-key <key>", "API Key for authentication").action(async () => {
1891
- const opts = svcCmd.parent.optsWithGlobals();
1892
- const format = resolveFormat(opts.format);
1893
- const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
1894
- message: "API Key:",
1895
- type: "password",
1896
- envVar: "AGENZO_API_KEY"
1897
- });
1898
- const host = (await configManager.load()).api_host || "http://localhost:8001";
1899
- const discoveryClient = new ApiClient({ baseUrl: `${host}/api/discovery/v1` });
1900
- const result = await discoveryClient.get(
1901
- "/catalog",
1902
- { type: "api-key", key: apiKey },
1903
- { category: "payment" }
1904
- );
1905
- if (!result.success) {
1906
- throw CliError.fromApi(result, { auth: "api-key" });
1907
- }
1908
- const cmdResult = {
1909
- text: () => JSON.stringify(result.data, null, 2),
1910
- data: result.data
1911
- };
1912
- await renderWithContext(cmdResult, { format }, configManager);
1913
- });
1914
- svcCmd.command("get <service_id>").description("Get a token service capability by ID").option("--api-key <key>", "API Key for authentication").action(async (serviceId) => {
1915
- const opts = svcCmd.parent.optsWithGlobals();
1916
- const format = resolveFormat(opts.format);
1917
- const apiKey = await PromptEngine.resolveInput(opts.apiKey, {
1918
- message: "API Key:",
1919
- type: "password",
1920
- envVar: "AGENZO_API_KEY"
1921
- });
1922
- const host2 = (await configManager.load()).api_host || "http://localhost:8001";
1923
- const discoveryClient2 = new ApiClient({ baseUrl: `${host2}/api/discovery/v1` });
1924
- const result = await discoveryClient2.get(
1925
- `/catalog/${serviceId}`,
1926
- { type: "api-key", key: apiKey }
1927
- );
1928
- if (!result.success) {
1929
- throw CliError.fromApi(result, { auth: "api-key" });
1930
- }
1931
- const cmdResult = {
1932
- text: () => JSON.stringify(result.data, null, 2),
1933
- data: result.data
1934
- };
1935
- await renderWithContext(cmdResult, { format }, configManager);
1936
- });
1937
1639
  await program.parseAsync(process.argv);
1938
1640
  }
1939
1641
  function resolveActiveFormat() {