@wlfi-agent/cli 1.4.13 → 1.4.14

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 (289) hide show
  1. package/Cargo.lock +3968 -0
  2. package/Cargo.toml +50 -0
  3. package/README.md +426 -6
  4. package/crates/vault-cli-admin/Cargo.toml +26 -0
  5. package/crates/vault-cli-admin/src/io_utils.rs +500 -0
  6. package/crates/vault-cli-admin/src/main.rs +3990 -0
  7. package/crates/vault-cli-admin/src/shared_config.rs +624 -0
  8. package/crates/vault-cli-admin/src/tui/amounts.rs +180 -0
  9. package/crates/vault-cli-admin/src/tui/token_rpc.rs +250 -0
  10. package/crates/vault-cli-admin/src/tui/utils.rs +82 -0
  11. package/crates/vault-cli-admin/src/tui.rs +3410 -0
  12. package/crates/vault-cli-agent/Cargo.toml +24 -0
  13. package/crates/vault-cli-agent/src/io_utils.rs +576 -0
  14. package/crates/vault-cli-agent/src/main.rs +833 -0
  15. package/crates/vault-cli-daemon/Cargo.toml +28 -0
  16. package/crates/vault-cli-daemon/src/bin/wlfi-agent-system-keychain.rs +216 -0
  17. package/crates/vault-cli-daemon/src/main.rs +644 -0
  18. package/crates/vault-cli-daemon/src/relay_sync.rs +894 -0
  19. package/crates/vault-cli-daemon/tests/system_keychain_helper_acl.rs +167 -0
  20. package/crates/vault-daemon/Cargo.toml +32 -0
  21. package/crates/vault-daemon/src/daemon_parts/api_impl_and_utils.rs +1041 -0
  22. package/crates/vault-daemon/src/daemon_parts/core_helpers.rs +1256 -0
  23. package/crates/vault-daemon/src/daemon_parts/types_api_rpc.rs +622 -0
  24. package/crates/vault-daemon/src/lib.rs +54 -0
  25. package/crates/vault-daemon/src/persistence.rs +441 -0
  26. package/crates/vault-daemon/src/tests.rs +237 -0
  27. package/crates/vault-daemon/src/tests_parts/part1.rs +1224 -0
  28. package/crates/vault-daemon/src/tests_parts/part2.rs +1021 -0
  29. package/crates/vault-daemon/src/tests_parts/part3.rs +835 -0
  30. package/crates/vault-daemon/src/tests_parts/part4.rs +604 -0
  31. package/crates/vault-domain/Cargo.toml +20 -0
  32. package/crates/vault-domain/src/action.rs +849 -0
  33. package/crates/vault-domain/src/address.rs +51 -0
  34. package/crates/vault-domain/src/approval.rs +90 -0
  35. package/crates/vault-domain/src/constants.rs +4 -0
  36. package/crates/vault-domain/src/error.rs +54 -0
  37. package/crates/vault-domain/src/keys.rs +71 -0
  38. package/crates/vault-domain/src/lib.rs +42 -0
  39. package/crates/vault-domain/src/nonce.rs +102 -0
  40. package/crates/vault-domain/src/policy.rs +172 -0
  41. package/crates/vault-domain/src/request.rs +53 -0
  42. package/crates/vault-domain/src/scope.rs +24 -0
  43. package/crates/vault-domain/src/session.rs +50 -0
  44. package/crates/vault-domain/src/signature.rs +34 -0
  45. package/crates/vault-domain/src/tests.rs +651 -0
  46. package/crates/vault-domain/src/u128_as_decimal_string.rs +44 -0
  47. package/crates/vault-policy/Cargo.toml +17 -0
  48. package/crates/vault-policy/src/engine.rs +301 -0
  49. package/crates/vault-policy/src/error.rs +81 -0
  50. package/crates/vault-policy/src/lib.rs +17 -0
  51. package/crates/vault-policy/src/report.rs +34 -0
  52. package/crates/vault-policy/src/tests.rs +891 -0
  53. package/crates/vault-policy/src/tests_explain.rs +78 -0
  54. package/crates/vault-sdk-agent/Cargo.toml +21 -0
  55. package/crates/vault-sdk-agent/src/lib.rs +711 -0
  56. package/crates/vault-signer/Cargo.toml +25 -0
  57. package/crates/vault-signer/src/lib.rs +731 -0
  58. package/crates/vault-signer/tests/secure_enclave_acl.rs +54 -0
  59. package/crates/vault-transport-unix/Cargo.toml +24 -0
  60. package/crates/vault-transport-unix/src/lib.rs +1640 -0
  61. package/crates/vault-transport-xpc/Cargo.toml +25 -0
  62. package/crates/vault-transport-xpc/src/client_codec_api.rs +635 -0
  63. package/crates/vault-transport-xpc/src/lib.rs +680 -0
  64. package/crates/vault-transport-xpc/src/tests.rs +818 -0
  65. package/crates/vault-transport-xpc/tests/e2e_flow.rs +773 -0
  66. package/dist/cli.cjs +35088 -0
  67. package/dist/cli.cjs.map +1 -0
  68. package/package.json +49 -43
  69. package/packages/cache/.turbo/turbo-build.log +52 -0
  70. package/packages/cache/dist/chunk-2QFWMUXT.cjs +43 -0
  71. package/packages/cache/dist/chunk-2QFWMUXT.cjs.map +1 -0
  72. package/packages/cache/dist/chunk-4U63TZTQ.js +43 -0
  73. package/packages/cache/dist/chunk-4U63TZTQ.js.map +1 -0
  74. package/packages/cache/dist/chunk-ALQ6H7KG.cjs +404 -0
  75. package/packages/cache/dist/chunk-ALQ6H7KG.cjs.map +1 -0
  76. package/packages/cache/dist/chunk-FGJEEF5N.js +404 -0
  77. package/packages/cache/dist/chunk-FGJEEF5N.js.map +1 -0
  78. package/packages/cache/dist/chunk-UYNEHZHB.cjs +45 -0
  79. package/packages/cache/dist/chunk-UYNEHZHB.cjs.map +1 -0
  80. package/packages/cache/dist/chunk-VXVMPG3W.js +45 -0
  81. package/packages/cache/dist/chunk-VXVMPG3W.js.map +1 -0
  82. package/packages/cache/dist/client/index.cjs +11 -0
  83. package/packages/cache/dist/client/index.cjs.map +1 -0
  84. package/packages/cache/dist/client/index.d.cts +15 -0
  85. package/packages/cache/dist/client/index.d.ts +15 -0
  86. package/packages/cache/dist/client/index.js +11 -0
  87. package/packages/cache/dist/client/index.js.map +1 -0
  88. package/packages/cache/dist/errors/index.cjs +11 -0
  89. package/packages/cache/dist/errors/index.cjs.map +1 -0
  90. package/packages/cache/dist/errors/index.d.cts +26 -0
  91. package/packages/cache/dist/errors/index.d.ts +26 -0
  92. package/packages/cache/dist/errors/index.js +11 -0
  93. package/packages/cache/dist/errors/index.js.map +1 -0
  94. package/packages/cache/dist/index.cjs +29 -0
  95. package/packages/cache/dist/index.cjs.map +1 -0
  96. package/packages/cache/dist/index.d.cts +4 -0
  97. package/packages/cache/dist/index.d.ts +4 -0
  98. package/packages/cache/dist/index.js +29 -0
  99. package/packages/cache/dist/index.js.map +1 -0
  100. package/packages/cache/dist/service/index.cjs +15 -0
  101. package/packages/cache/dist/service/index.cjs.map +1 -0
  102. package/packages/cache/dist/service/index.d.cts +184 -0
  103. package/packages/cache/dist/service/index.d.ts +184 -0
  104. package/packages/cache/dist/service/index.js +15 -0
  105. package/packages/cache/dist/service/index.js.map +1 -0
  106. package/packages/cache/node_modules/.bin/jiti +17 -0
  107. package/packages/cache/node_modules/.bin/tsc +17 -0
  108. package/packages/cache/node_modules/.bin/tsserver +17 -0
  109. package/packages/cache/node_modules/.bin/tsup +17 -0
  110. package/packages/cache/node_modules/.bin/tsup-node +17 -0
  111. package/packages/cache/node_modules/.bin/tsx +17 -0
  112. package/packages/cache/node_modules/.bin/vitest +17 -0
  113. package/packages/cache/package.json +48 -0
  114. package/packages/cache/src/client/index.ts +56 -0
  115. package/packages/cache/src/errors/index.ts +53 -0
  116. package/packages/cache/src/index.ts +3 -0
  117. package/packages/cache/src/service/index.test.ts +263 -0
  118. package/packages/cache/src/service/index.ts +678 -0
  119. package/packages/cache/tsconfig.json +13 -0
  120. package/packages/cache/tsup.config.ts +13 -0
  121. package/packages/cache/vitest.config.ts +16 -0
  122. package/packages/config/.turbo/turbo-build.log +18 -0
  123. package/packages/config/dist/index.cjs +1037 -0
  124. package/packages/config/dist/index.cjs.map +1 -0
  125. package/packages/config/dist/index.d.ts +131 -0
  126. package/packages/config/node_modules/.bin/jiti +17 -0
  127. package/packages/config/node_modules/.bin/tsc +17 -0
  128. package/packages/config/node_modules/.bin/tsserver +17 -0
  129. package/packages/config/node_modules/.bin/tsup +17 -0
  130. package/packages/config/node_modules/.bin/tsup-node +17 -0
  131. package/packages/config/node_modules/.bin/tsx +17 -0
  132. package/packages/config/package.json +21 -0
  133. package/packages/config/src/index.js +1 -0
  134. package/packages/config/src/index.ts +1282 -0
  135. package/packages/config/tsconfig.json +4 -0
  136. package/packages/rpc/.turbo/turbo-build.log +32 -0
  137. package/packages/rpc/dist/_esm-BCLXDO2R.cjs +3660 -0
  138. package/packages/rpc/dist/_esm-BCLXDO2R.cjs.map +1 -0
  139. package/packages/rpc/dist/ccip-OWJLAW55.cjs +16 -0
  140. package/packages/rpc/dist/ccip-OWJLAW55.cjs.map +1 -0
  141. package/packages/rpc/dist/chunk-APQIFZ3B.cjs +6247 -0
  142. package/packages/rpc/dist/chunk-APQIFZ3B.cjs.map +1 -0
  143. package/packages/rpc/dist/chunk-CDO2GWRD.cjs +410 -0
  144. package/packages/rpc/dist/chunk-CDO2GWRD.cjs.map +1 -0
  145. package/packages/rpc/dist/chunk-QGTNTFJ7.cjs +2249 -0
  146. package/packages/rpc/dist/chunk-QGTNTFJ7.cjs.map +1 -0
  147. package/packages/rpc/dist/chunk-TZDTAHWR.cjs +44 -0
  148. package/packages/rpc/dist/chunk-TZDTAHWR.cjs.map +1 -0
  149. package/packages/rpc/dist/index.cjs +7342 -0
  150. package/packages/rpc/dist/index.cjs.map +1 -0
  151. package/packages/rpc/dist/index.d.ts +3857 -0
  152. package/packages/rpc/dist/secp256k1-WCNM675D.cjs +18 -0
  153. package/packages/rpc/dist/secp256k1-WCNM675D.cjs.map +1 -0
  154. package/packages/rpc/node_modules/.bin/jiti +17 -0
  155. package/packages/rpc/node_modules/.bin/tsc +17 -0
  156. package/packages/rpc/node_modules/.bin/tsserver +17 -0
  157. package/packages/rpc/node_modules/.bin/tsup +17 -0
  158. package/packages/rpc/node_modules/.bin/tsup-node +17 -0
  159. package/packages/rpc/node_modules/.bin/tsx +17 -0
  160. package/packages/rpc/package.json +25 -0
  161. package/packages/rpc/src/index.ts +206 -0
  162. package/packages/rpc/tsconfig.json +4 -0
  163. package/packages/typescript/base.json +36 -0
  164. package/packages/typescript/nextjs.json +17 -0
  165. package/packages/typescript/package.json +10 -0
  166. package/packages/ui/.turbo/turbo-build.log +44 -0
  167. package/packages/ui/dist/chunk-MOAFBKSA.js +11 -0
  168. package/packages/ui/dist/chunk-MOAFBKSA.js.map +1 -0
  169. package/packages/ui/dist/components/badge.d.ts +12 -0
  170. package/packages/ui/dist/components/badge.js +31 -0
  171. package/packages/ui/dist/components/badge.js.map +1 -0
  172. package/packages/ui/dist/components/button.d.ts +13 -0
  173. package/packages/ui/dist/components/button.js +40 -0
  174. package/packages/ui/dist/components/button.js.map +1 -0
  175. package/packages/ui/dist/components/card.d.ts +10 -0
  176. package/packages/ui/dist/components/card.js +39 -0
  177. package/packages/ui/dist/components/card.js.map +1 -0
  178. package/packages/ui/dist/components/input.d.ts +5 -0
  179. package/packages/ui/dist/components/input.js +28 -0
  180. package/packages/ui/dist/components/input.js.map +1 -0
  181. package/packages/ui/dist/components/label.d.ts +5 -0
  182. package/packages/ui/dist/components/label.js +13 -0
  183. package/packages/ui/dist/components/label.js.map +1 -0
  184. package/packages/ui/dist/components/separator.d.ts +5 -0
  185. package/packages/ui/dist/components/separator.js +13 -0
  186. package/packages/ui/dist/components/separator.js.map +1 -0
  187. package/packages/ui/dist/components/textarea.d.ts +5 -0
  188. package/packages/ui/dist/components/textarea.js +27 -0
  189. package/packages/ui/dist/components/textarea.js.map +1 -0
  190. package/packages/ui/dist/tailwind.d.ts +56 -0
  191. package/packages/ui/dist/tailwind.js +60 -0
  192. package/packages/ui/dist/tailwind.js.map +1 -0
  193. package/packages/ui/dist/utils/cn.d.ts +5 -0
  194. package/packages/ui/dist/utils/cn.js +7 -0
  195. package/packages/ui/dist/utils/cn.js.map +1 -0
  196. package/packages/ui/node_modules/.bin/jiti +17 -0
  197. package/packages/ui/node_modules/.bin/tsc +17 -0
  198. package/packages/ui/node_modules/.bin/tsserver +17 -0
  199. package/packages/ui/node_modules/.bin/tsup +17 -0
  200. package/packages/ui/node_modules/.bin/tsup-node +17 -0
  201. package/packages/ui/node_modules/.bin/tsx +17 -0
  202. package/packages/ui/package.json +69 -0
  203. package/packages/ui/src/components/badge.tsx +27 -0
  204. package/packages/ui/src/components/button.tsx +40 -0
  205. package/packages/ui/src/components/card.tsx +31 -0
  206. package/packages/ui/src/components/input.tsx +21 -0
  207. package/packages/ui/src/components/label.tsx +6 -0
  208. package/packages/ui/src/components/separator.tsx +6 -0
  209. package/packages/ui/src/components/textarea.tsx +20 -0
  210. package/packages/ui/src/globals.css +70 -0
  211. package/packages/ui/src/tailwind.ts +56 -0
  212. package/packages/ui/src/utils/cn.ts +6 -0
  213. package/packages/ui/tsconfig.json +20 -0
  214. package/packages/ui/tsup.config.ts +20 -0
  215. package/pnpm-workspace.yaml +4 -0
  216. package/scripts/install-rust-binaries.mjs +84 -0
  217. package/scripts/launchd/install-user-daemon.sh +358 -0
  218. package/scripts/launchd/run-vault-daemon.sh +5 -0
  219. package/scripts/launchd/run-wlfi-agent-daemon.sh +73 -0
  220. package/scripts/launchd/uninstall-user-daemon.sh +103 -0
  221. package/src/cli.ts +2121 -0
  222. package/src/lib/admin-guard.js +1 -0
  223. package/src/lib/admin-guard.ts +185 -0
  224. package/src/lib/admin-passthrough.ts +33 -0
  225. package/src/lib/admin-reset.ts +751 -0
  226. package/src/lib/admin-setup.ts +1612 -0
  227. package/src/lib/agent-auth-clear.js +1 -0
  228. package/src/lib/agent-auth-clear.ts +58 -0
  229. package/src/lib/agent-auth-forwarding.js +1 -0
  230. package/src/lib/agent-auth-forwarding.ts +149 -0
  231. package/src/lib/agent-auth-migrate.js +1 -0
  232. package/src/lib/agent-auth-migrate.ts +150 -0
  233. package/src/lib/agent-auth-revoke.ts +103 -0
  234. package/src/lib/agent-auth-rotate.ts +107 -0
  235. package/src/lib/agent-auth-token.js +1 -0
  236. package/src/lib/agent-auth-token.ts +25 -0
  237. package/src/lib/agent-auth.ts +89 -0
  238. package/src/lib/asset-broadcast.js +1 -0
  239. package/src/lib/asset-broadcast.ts +285 -0
  240. package/src/lib/bootstrap-artifacts.js +1 -0
  241. package/src/lib/bootstrap-artifacts.ts +205 -0
  242. package/src/lib/bootstrap-credentials.js +1 -0
  243. package/src/lib/bootstrap-credentials.ts +832 -0
  244. package/src/lib/config-amounts.js +1 -0
  245. package/src/lib/config-amounts.ts +189 -0
  246. package/src/lib/config-mutation.ts +27 -0
  247. package/src/lib/fs-trust.js +1 -0
  248. package/src/lib/fs-trust.ts +537 -0
  249. package/src/lib/keychain.js +1 -0
  250. package/src/lib/keychain.ts +225 -0
  251. package/src/lib/local-admin-access.ts +106 -0
  252. package/src/lib/network-selection.js +1 -0
  253. package/src/lib/network-selection.ts +71 -0
  254. package/src/lib/passthrough-security.js +1 -0
  255. package/src/lib/passthrough-security.ts +114 -0
  256. package/src/lib/rpc-guard.js +1 -0
  257. package/src/lib/rpc-guard.ts +7 -0
  258. package/src/lib/rust-spawn-options.js +1 -0
  259. package/src/lib/rust-spawn-options.ts +98 -0
  260. package/src/lib/rust.js +1 -0
  261. package/src/lib/rust.ts +143 -0
  262. package/src/lib/signed-tx.js +1 -0
  263. package/src/lib/signed-tx.ts +116 -0
  264. package/src/lib/status-repair-cli.ts +116 -0
  265. package/src/lib/sudo.js +1 -0
  266. package/src/lib/sudo.ts +172 -0
  267. package/src/lib/vault-password-forwarding.js +1 -0
  268. package/src/lib/vault-password-forwarding.ts +155 -0
  269. package/src/lib/wallet-profile.js +1 -0
  270. package/src/lib/wallet-profile.ts +332 -0
  271. package/src/lib/wallet-repair.js +1 -0
  272. package/src/lib/wallet-repair.ts +304 -0
  273. package/src/lib/wallet-setup.js +1 -0
  274. package/src/lib/wallet-setup.ts +1466 -0
  275. package/src/lib/wallet-status.js +1 -0
  276. package/src/lib/wallet-status.ts +640 -0
  277. package/tsconfig.base.json +17 -0
  278. package/tsconfig.json +10 -0
  279. package/tsup.config.ts +25 -0
  280. package/turbo.json +41 -0
  281. package/LICENSE.md +0 -1
  282. package/dist/wlfa/index.cjs +0 -250
  283. package/dist/wlfa/index.d.cts +0 -1
  284. package/dist/wlfa/index.d.ts +0 -1
  285. package/dist/wlfa/index.js +0 -250
  286. package/dist/wlfc/index.cjs +0 -1839
  287. package/dist/wlfc/index.d.cts +0 -1
  288. package/dist/wlfc/index.d.ts +0 -1
  289. package/dist/wlfc/index.js +0 -1839
@@ -1,1839 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict"; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3
- // src/wlfc/index.ts
4
- var _promises = require('fs/promises');
5
- var _http = require('http');
6
- var _os = require('os');
7
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
8
- var _process = require('process'); var _process2 = _interopRequireDefault(_process);
9
-
10
-
11
-
12
- var _prompts = require('@inquirer/prompts');
13
-
14
-
15
-
16
-
17
- var _agentwalletsdk = require('@wlfi-agent/agent-wallet-sdk');
18
- var _commander = require('commander');
19
- var CONFIG_DIR = _path2.default.join(_os.homedir.call(void 0, ), ".config", "wlfc-agent");
20
- var CONFIG_FILE = _path2.default.join(CONFIG_DIR, "config.json");
21
- var OTP_DIR = _path2.default.join(_os.homedir.call(void 0, ), ".test_otp");
22
- var DEFAULT_CALLBACK_PORT = 54545;
23
- var DEFAULT_LOGIN_TIMEOUT_MS = 15 * 60 * 1e3;
24
- var DEFAULT_WALLET_CHAIN_ID = 56;
25
- var DEFAULT_WALLET_NETWORK = "evm";
26
- var MAX_CALLBACK_BODY_BYTES = 1024 * 1024;
27
- var MAX_LIST_ITEMS_TO_PRINT = 20;
28
- var createEmptyAliases = () => ({
29
- destination: {},
30
- project: {},
31
- wallet: {}
32
- });
33
- var normalizeAliasMap = (raw) => {
34
- const defaults = createEmptyAliases();
35
- if (!(raw && typeof raw === "object")) {
36
- return defaults;
37
- }
38
- for (const type of Object.keys(defaults)) {
39
- const source = raw[type];
40
- if (!(source && typeof source === "object")) {
41
- continue;
42
- }
43
- const entries = Object.entries(source);
44
- for (const [alias, id] of entries) {
45
- const normalizedAlias = alias.trim();
46
- const normalizedId = typeof id === "string" ? id.trim() : "";
47
- if (!(normalizedAlias && normalizedId)) {
48
- continue;
49
- }
50
- defaults[type][normalizedAlias] = normalizedId;
51
- }
52
- }
53
- return defaults;
54
- };
55
- var resolveBaseUrl = () => (_nullishCoalesce(_nullishCoalesce(_process2.default.env.WLFI_AGENT_BACKEND_URL, () => ( _process2.default.env.WLF_AGENT_BACKEND_URL)), () => ( _agentwalletsdk.DEFAULT_BASE_URL))).trim();
56
- var toFlagKey = (key) => key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
57
- var optionsToFlags = (options) => {
58
- const flags = {};
59
- for (const [key, value] of Object.entries(options)) {
60
- if (value === void 0 || value === null) {
61
- continue;
62
- }
63
- const flagKey = toFlagKey(key);
64
- if (typeof value === "boolean") {
65
- if (value) {
66
- flags[flagKey] = "true";
67
- }
68
- continue;
69
- }
70
- if (typeof value === "number" || typeof value === "string") {
71
- flags[flagKey] = String(value);
72
- }
73
- }
74
- return flags;
75
- };
76
- var collectFlags = (command) => {
77
- const lineage = [];
78
- let cursor = command;
79
- while (cursor) {
80
- lineage.unshift(cursor);
81
- cursor = _nullishCoalesce(cursor.parent, () => ( null));
82
- }
83
- const flags = {};
84
- for (const node of lineage) {
85
- Object.assign(flags, optionsToFlags(node.opts()));
86
- }
87
- return flags;
88
- };
89
- var withJsonOption = (command) => command.option("--json", "Print machine-readable JSON output");
90
- var withTokenOption = (command) => command.option("--token <token>", "Session token override");
91
- var withUnsupportedBaseUrlOption = (command) => command.addOption(new (0, _commander.Option)("--base-url <url>").hideHelp());
92
- var assertNoBaseUrlFlag = (flags) => {
93
- if (flags["base-url"]) {
94
- throw new Error(
95
- "--base-url is not supported. Use WLFI_AGENT_BACKEND_URL or WLF_AGENT_BACKEND_URL instead."
96
- );
97
- }
98
- };
99
- var getCommandFlags = (command) => {
100
- const flags = collectFlags(command);
101
- assertNoBaseUrlFlag(flags);
102
- return flags;
103
- };
104
- var loadConfig = async () => {
105
- try {
106
- const raw = await _promises.readFile.call(void 0, CONFIG_FILE, "utf8");
107
- const parsed = JSON.parse(raw);
108
- const token = typeof parsed.token === "string" && parsed.token.trim().length > 0 ? parsed.token.trim() : void 0;
109
- const aliases = normalizeAliasMap(parsed.aliases);
110
- return { aliases, token };
111
- } catch (e) {
112
- return {
113
- aliases: createEmptyAliases()
114
- };
115
- }
116
- };
117
- var saveConfig = async (config) => {
118
- await _promises.mkdir.call(void 0, CONFIG_DIR, { mode: 448, recursive: true });
119
- await _promises.writeFile.call(void 0, CONFIG_FILE, JSON.stringify(config, null, 2), {
120
- mode: 384
121
- });
122
- await _promises.chmod.call(void 0, CONFIG_FILE, 384);
123
- };
124
- var parseCallbackPort = (value) => {
125
- if (!value) {
126
- return DEFAULT_CALLBACK_PORT;
127
- }
128
- const parsed = Number(value);
129
- if (!Number.isInteger(parsed) || parsed <= 0 || parsed > 65535) {
130
- throw new Error("--callback-port must be a valid TCP port (1-65535)");
131
- }
132
- return parsed;
133
- };
134
- var parsePositiveInteger = (value, flagName) => {
135
- const parsed = Number(value);
136
- if (!Number.isInteger(parsed) || parsed <= 0) {
137
- throw new Error(`${flagName} must be a positive integer`);
138
- }
139
- return parsed;
140
- };
141
- var readRequestBody = async (request) => new Promise((resolve, reject) => {
142
- const chunks = [];
143
- let size = 0;
144
- request.on("data", (chunk) => {
145
- size += chunk.length;
146
- if (size > MAX_CALLBACK_BODY_BYTES) {
147
- reject(new Error("Callback request body is too large"));
148
- request.destroy();
149
- return;
150
- }
151
- chunks.push(chunk);
152
- });
153
- request.on("end", () => {
154
- resolve(Buffer.concat(chunks).toString("utf8"));
155
- });
156
- request.on("error", (error) => {
157
- reject(error);
158
- });
159
- });
160
- var getErrorPayload = (error) => {
161
- if (error instanceof _agentwalletsdk.AgentWalletSdkError) {
162
- if (typeof error.payload === "object" && error.payload !== null) {
163
- return {
164
- ...error.payload,
165
- message: error.message
166
- };
167
- }
168
- return { message: error.message };
169
- }
170
- if (error instanceof Error) {
171
- return { message: error.message };
172
- }
173
- return { message: String(error) };
174
- };
175
- var getErrorMessage = (error) => {
176
- if (error instanceof Error) {
177
- return error.message;
178
- }
179
- return String(error);
180
- };
181
- var WC_STATUS_POLL_INTERVAL_MS = 1500;
182
- var sleep = (ms) => new Promise((resolve) => {
183
- setTimeout(resolve, ms);
184
- });
185
- var waitForWcCompletionToken = async (client, requestId) => {
186
- const deadline = Date.now() + DEFAULT_LOGIN_TIMEOUT_MS;
187
- while (Date.now() < deadline) {
188
- const status = await client.wcStatus({
189
- consume: true,
190
- requestId
191
- });
192
- const completed = status.completed === true;
193
- const token = typeof status.token === "string" ? status.token.trim() : void 0;
194
- if (completed && token) {
195
- return token;
196
- }
197
- if (completed && !token) {
198
- throw new Error(
199
- "Backend reported wc completion without a session token payload"
200
- );
201
- }
202
- await sleep(WC_STATUS_POLL_INTERVAL_MS);
203
- }
204
- throw new Error("Timed out waiting for wc completion; request expired");
205
- };
206
- var printJson = (value) => {
207
- console.log(JSON.stringify(value, null, 2));
208
- };
209
- var shouldOutputJson = (flags) => flags.json === "true";
210
- var summarizeRecord = (record) => {
211
- const priorityKeys = [
212
- "id",
213
- "type",
214
- "alias",
215
- "name",
216
- "label",
217
- "ok",
218
- "statusCode",
219
- "status",
220
- "eventType",
221
- "webhookId",
222
- "webhookUrl",
223
- "walletId",
224
- "projectId",
225
- "address",
226
- "approveId",
227
- "paymentId",
228
- "txHash",
229
- "url",
230
- "message"
231
- ];
232
- const parts = [];
233
- for (const key of priorityKeys) {
234
- if (!(key in record)) {
235
- continue;
236
- }
237
- const value = record[key];
238
- if (value === null || value === void 0) {
239
- continue;
240
- }
241
- const rendered = typeof value === "string" || typeof value === "number" ? String(value) : JSON.stringify(value);
242
- parts.push(`${key}=${rendered}`);
243
- }
244
- if (parts.length > 0) {
245
- return parts.join(" | ");
246
- }
247
- const fallback = Object.entries(record).slice(0, 4).map(([key, value]) => {
248
- let rendered = String(value);
249
- if (typeof value === "string" || typeof value === "number") {
250
- rendered = String(value);
251
- } else if (Array.isArray(value)) {
252
- rendered = `array(${value.length})`;
253
- } else if (value && typeof value === "object") {
254
- rendered = "object";
255
- }
256
- return `${key}=${rendered}`;
257
- });
258
- return fallback.join(" | ");
259
- };
260
- var printHumanValue = (value, title) => {
261
- if (title) {
262
- console.log(title);
263
- }
264
- if (Array.isArray(value)) {
265
- if (value.length === 0) {
266
- console.log("No results.");
267
- return;
268
- }
269
- console.log(`Found ${value.length} item(s):`);
270
- const visibleItems = value.slice(0, MAX_LIST_ITEMS_TO_PRINT);
271
- for (const [index, item] of visibleItems.entries()) {
272
- if (item && typeof item === "object" && !Array.isArray(item)) {
273
- console.log(`${index + 1}. ${summarizeRecord(item)}`);
274
- } else {
275
- console.log(`${index + 1}. ${String(item)}`);
276
- }
277
- }
278
- if (value.length > MAX_LIST_ITEMS_TO_PRINT) {
279
- console.log(
280
- `... ${value.length - MAX_LIST_ITEMS_TO_PRINT} more item(s). Use --json for full output.`
281
- );
282
- }
283
- return;
284
- }
285
- if (value && typeof value === "object") {
286
- const record = value;
287
- const hasOnlyOkResult = Object.keys(record).every(
288
- (key) => key === "ok" || key === "message"
289
- );
290
- if (hasOnlyOkResult && "ok" in record && typeof record.ok === "boolean") {
291
- console.log(record.ok ? "Success." : "Failed.");
292
- if (typeof record.message === "string" && record.message.trim()) {
293
- console.log(record.message);
294
- }
295
- return;
296
- }
297
- console.log(summarizeRecord(record));
298
- return;
299
- }
300
- console.log(String(value));
301
- };
302
- var printValue = (flags, value, options) => {
303
- if (shouldOutputJson(flags)) {
304
- printJson(value);
305
- return;
306
- }
307
- printHumanValue(value, _optionalChain([options, 'optionalAccess', _ => _.title]));
308
- if (_optionalChain([options, 'optionalAccess', _2 => _2.nextSteps]) && options.nextSteps.length > 0) {
309
- console.log("\nNext steps:");
310
- for (const step of options.nextSteps) {
311
- console.log(`- ${step}`);
312
- }
313
- }
314
- };
315
- var parseAliasType = (value, flagName = "--type") => {
316
- if (value === "destination" || value === "project" || value === "wallet") {
317
- return value;
318
- }
319
- throw new Error(`${flagName} must be one of: wallet, project, destination`);
320
- };
321
- var resolveAliasId = async (type, rawValue) => {
322
- const value = rawValue.trim();
323
- if (!value) {
324
- return "";
325
- }
326
- const config = await loadConfig();
327
- return _nullishCoalesce(config.aliases[type][value], () => ( value));
328
- };
329
- var parseNetwork = (value) => {
330
- if (value !== "evm" && value !== "solana") {
331
- throw new Error("--network must be either evm or solana");
332
- }
333
- return value;
334
- };
335
- var parseApprovalPayload = async (flags) => {
336
- const inline = flags["approval-payload-json"];
337
- const file = flags["approval-payload-file"];
338
- if (!(inline || file)) {
339
- return void 0;
340
- }
341
- if (inline && file) {
342
- throw new Error(
343
- "Use either --approval-payload-json or --approval-payload-file, not both"
344
- );
345
- }
346
- const raw = inline ? inline : await _promises.readFile.call(void 0, file, "utf8");
347
- try {
348
- const parsed = JSON.parse(raw);
349
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
350
- throw new Error("approval payload must be a JSON object");
351
- }
352
- return parsed;
353
- } catch (error) {
354
- throw new Error(
355
- `Failed to parse approval payload JSON: ${getErrorMessage(error)}`
356
- );
357
- }
358
- };
359
- var parsePolicyDestinations = async (flags) => {
360
- const inline = flags["destinations-json"];
361
- const file = flags["destinations-file"];
362
- if (!(inline || file)) {
363
- throw new Error(
364
- "policy put requires exactly one of --destinations-json or --destinations-file"
365
- );
366
- }
367
- if (inline && file) {
368
- throw new Error(
369
- "policy put requires exactly one of --destinations-json or --destinations-file"
370
- );
371
- }
372
- const raw = inline ? inline : await _promises.readFile.call(void 0, file, "utf8");
373
- try {
374
- const parsed = JSON.parse(raw);
375
- if (!Array.isArray(parsed)) {
376
- throw new Error("Policy destinations must be a JSON array");
377
- }
378
- return parsed;
379
- } catch (error) {
380
- throw new Error(
381
- `Failed to parse policy destinations JSON: ${getErrorMessage(error)}`
382
- );
383
- }
384
- };
385
- var getAuthedClient = async (flags) => {
386
- const config = await loadConfig();
387
- const token = (_nullishCoalesce(_nullishCoalesce(flags.token, () => ( config.token)), () => ( ""))).trim();
388
- if (!token) {
389
- throw new Error(
390
- "Token is missing. Run `wlfc login --token <token>` or `wlfc login --email <email>` first."
391
- );
392
- }
393
- return _agentwalletsdk.createAgentWalletClient.call(void 0, {
394
- baseUrl: resolveBaseUrl(),
395
- token
396
- });
397
- };
398
- var verifySessionToken = async (token) => {
399
- const authedClient = _agentwalletsdk.createAgentWalletClient.call(void 0, {
400
- baseUrl: resolveBaseUrl(),
401
- token
402
- });
403
- try {
404
- await authedClient.listProjects();
405
- } catch (error) {
406
- if (error instanceof _agentwalletsdk.AgentWalletSdkError && (error.status === 401 || error.status === 403)) {
407
- throw new Error("Session token is not authorized");
408
- }
409
- console.warn(
410
- `Warning: session token saved, but backend project query failed: ${getErrorMessage(error)}`
411
- );
412
- }
413
- };
414
- var saveSessionToken = async (token) => {
415
- const config = await loadConfig();
416
- await saveConfig({
417
- ...config,
418
- token
419
- });
420
- console.log("Saved credentials to ~/.config/wlfc-agent/config.json");
421
- };
422
- var startCallbackServer = async (options) => {
423
- const { port } = options;
424
- const client = _agentwalletsdk.createAgentWalletClient.call(void 0, { baseUrl: resolveBaseUrl() });
425
- const server = _http.createServer.call(void 0, async (request, response) => {
426
- const requestUrl = new URL(_nullishCoalesce(request.url, () => ( "/")), `http://127.0.0.1:${port}`);
427
- if (request.method === "GET" && requestUrl.pathname === "/") {
428
- response.statusCode = 200;
429
- response.setHeader("Content-Type", "text/html; charset=utf-8");
430
- response.end(`<!doctype html>
431
- <html>
432
- <head>
433
- <meta charset="utf-8" />
434
- <meta name="viewport" content="width=device-width, initial-scale=1" />
435
- <title>wlfc callback server</title>
436
- </head>
437
- <body style="font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; margin: 24px; line-height: 1.5;">
438
- <h1>wlfc callback server is running</h1>
439
- <p>Open the link from your email. For manual testing:</p>
440
- <ul>
441
- <li><a href="/login">/login?requestId=&lt;id&gt;</a></li>
442
- <li><a href="/register">/register?requestId=&lt;id&gt;</a></li>
443
- </ul>
444
- <p>This server hosts local login/register pages while your terminal polls backend status.</p>
445
- </body>
446
- </html>`);
447
- return;
448
- }
449
- if (request.method === "GET" && requestUrl.pathname === "/login") {
450
- response.statusCode = 200;
451
- response.setHeader("Content-Type", "text/html; charset=utf-8");
452
- response.end(`<!doctype html>
453
- <html lang="en">
454
- <head>
455
- <meta charset="utf-8" />
456
- <meta name="viewport" content="width=device-width, initial-scale=1" />
457
- <title>wlfc login</title>
458
- <style>
459
- body { font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 24px; color: #10212f; background: #f2f5f8; }
460
- .panel { max-width: 720px; margin: 0 auto; background: #fff; border: 1px solid #dce3ea; border-radius: 12px; padding: 20px; box-shadow: 0 10px 25px rgba(2, 30, 62, 0.06); }
461
- h1 { margin-top: 0; }
462
- textarea { width: 100%; min-height: 130px; border: 1px solid #cfd9e3; border-radius: 8px; padding: 10px; box-sizing: border-box; font-size: 14px; }
463
- button { border: 0; border-radius: 8px; background: #0d5f4f; color: #fff; padding: 10px 14px; font-weight: 600; cursor: pointer; margin-top: 12px; }
464
- code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f5f8fb; padding: 2px 6px; border-radius: 6px; border: 1px solid #dbe4ee; }
465
- .status { margin-top: 12px; min-height: 20px; font-size: 14px; }
466
- .status.error { color: #ab2d2d; }
467
- .status.ok { color: #1b7a36; }
468
- </style>
469
- </head>
470
- <body>
471
- <main class="panel">
472
- <h1>wlfc login</h1>
473
- <p>Request ID: <code id="request-id">(missing)</code></p>
474
- <p>Paste OTP signature from your CubeSigner login email.</p>
475
- <form id="login-form">
476
- <textarea id="otp-signature" placeholder="Paste OTP signature or full token" required></textarea>
477
- <button type="submit">Complete login</button>
478
- </form>
479
- <div id="status" class="status"></div>
480
- </main>
481
- <script>
482
- const requestId = (new URLSearchParams(window.location.search).get("requestId") || "").trim();
483
- const requestIdEl = document.getElementById("request-id");
484
- const form = document.getElementById("login-form");
485
- const otpInput = document.getElementById("otp-signature");
486
- const statusEl = document.getElementById("status");
487
- requestIdEl.textContent = requestId || "(missing)";
488
- const setStatus = (text, isError = false) => {
489
- statusEl.textContent = text;
490
- statusEl.className = "status " + (isError ? "error" : "ok");
491
- };
492
-
493
- if (!requestId) {
494
- setStatus("Missing requestId query parameter", true);
495
- form.style.display = "none";
496
- }
497
-
498
- form.addEventListener("submit", async (event) => {
499
- event.preventDefault();
500
- const otpSignature = (otpInput.value || "").trim();
501
- if (!otpSignature) {
502
- setStatus("OTP signature is required", true);
503
- return;
504
- }
505
-
506
- setStatus("Submitting OTP...");
507
- try {
508
- const response = await fetch("/internal/login/complete", {
509
- method: "POST",
510
- headers: { "Content-Type": "application/json" },
511
- body: JSON.stringify({ requestId, otpSignature }),
512
- });
513
- const payload = await response.json().catch(() => ({}));
514
- if (!response.ok) {
515
- throw new Error(payload?.message || ("HTTP " + response.status));
516
- }
517
- setStatus("Success. Login completed. Return to terminal; it is polling for your session.");
518
- form.style.display = "none";
519
- } catch (error) {
520
- const message = error instanceof Error ? error.message : String(error);
521
- setStatus(message, true);
522
- }
523
- });
524
- </script>
525
- </body>
526
- </html>`);
527
- return;
528
- }
529
- if (request.method === "GET" && (requestUrl.pathname === "/register" || requestUrl.pathname === "/agent-wallet/register")) {
530
- response.statusCode = 200;
531
- response.setHeader("Content-Type", "text/html; charset=utf-8");
532
- response.end(`<!doctype html>
533
- <html lang="en">
534
- <head>
535
- <meta charset="utf-8" />
536
- <meta name="viewport" content="width=device-width, initial-scale=1" />
537
- <title>wlfc register</title>
538
- <style>
539
- body { font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; margin: 24px; color: #10212f; background: #f2f5f8; }
540
- .panel { max-width: 760px; margin: 0 auto; background: #fff; border: 1px solid #dce3ea; border-radius: 12px; padding: 20px; box-shadow: 0 10px 25px rgba(2, 30, 62, 0.06); }
541
- h1 { margin-top: 0; }
542
- label { display: block; margin: 10px 0 6px; font-weight: 600; }
543
- input { width: 100%; border: 1px solid #cfd9e3; border-radius: 8px; padding: 10px; box-sizing: border-box; font-size: 14px; }
544
- button { border: 0; border-radius: 8px; background: #0d5f4f; color: #fff; padding: 10px 14px; font-weight: 600; cursor: pointer; margin-top: 12px; }
545
- code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: #f5f8fb; padding: 2px 6px; border-radius: 6px; border: 1px solid #dbe4ee; word-break: break-all; }
546
- .status { margin-top: 12px; min-height: 20px; font-size: 14px; }
547
- .status.error { color: #ab2d2d; }
548
- .status.ok { color: #1b7a36; }
549
- .totp-box { margin-top: 16px; padding-top: 16px; border-top: 1px solid #e5ebf2; display: none; }
550
- .qr { margin: 10px 0; width: 220px; height: 220px; border: 1px solid #dce3ea; border-radius: 8px; }
551
- </style>
552
- <script src="https://cdn.jsdelivr.net/npm/qrcodejs@1.0.0/qrcode.min.js"></script>
553
- </head>
554
- <body>
555
- <main class="panel">
556
- <h1>wlfc register</h1>
557
- <p>Request ID: <code id="request-id">(from query)</code></p>
558
- <ol>
559
- <li>Open the invite link from your CubeSigner email.</li>
560
- <li>Set a password and submit below.</li>
561
- <li>Scan TOTP QR, then enter the OTP code.</li>
562
- </ol>
563
-
564
- <form id="accept-form">
565
- <label for="password">Password</label>
566
- <input id="password" type="password" autocomplete="new-password" required />
567
- <button type="submit">Accept invite</button>
568
- </form>
569
-
570
- <section id="totp-section" class="totp-box">
571
- <h2>Set up OTP</h2>
572
- <p>Scan this QR code with your authenticator app:</p>
573
- <div id="totp-qr" class="qr" aria-label="TOTP QR code"></div>
574
- <p><strong>Fallback URL:</strong> <code id="totp-url"></code></p>
575
- <form id="totp-form">
576
- <label for="otp-code">Current OTP code</label>
577
- <input id="otp-code" type="text" inputmode="numeric" pattern="[0-9]*" required />
578
- <button type="submit">Complete registration</button>
579
- </form>
580
- </section>
581
-
582
- <div id="status" class="status"></div>
583
- </main>
584
- <script>
585
- const searchParams = new URLSearchParams(window.location.search);
586
- let requestId = (searchParams.get("requestId") || "").trim();
587
- const inviteTokenFromQuery = (
588
- searchParams.get("inviteToken") ||
589
- searchParams.get("token") ||
590
- ""
591
- ).trim();
592
- const inviteProofFromQuery = (
593
- searchParams.get("inviteProof") ||
594
- searchParams.get("proof") ||
595
- ""
596
- ).trim();
597
- const requestIdEl = document.getElementById("request-id");
598
- const acceptForm = document.getElementById("accept-form");
599
- const totpSection = document.getElementById("totp-section");
600
- const totpForm = document.getElementById("totp-form");
601
- const passwordInput = document.getElementById("password");
602
- const otpCodeInput = document.getElementById("otp-code");
603
- const totpQr = document.getElementById("totp-qr");
604
- const totpUrlEl = document.getElementById("totp-url");
605
- const statusEl = document.getElementById("status");
606
- let totpId = "";
607
-
608
- requestIdEl.textContent = requestId || "(from query)";
609
- const setStatus = (text, isError = false) => {
610
- statusEl.textContent = text;
611
- statusEl.className = "status " + (isError ? "error" : "ok");
612
- };
613
-
614
- if (!requestId) {
615
- setStatus("Missing requestId query parameter in invite link.", true);
616
- }
617
-
618
- if (!(inviteTokenFromQuery || inviteProofFromQuery)) {
619
- setStatus("Invite link is missing inviteToken/inviteProof.", true);
620
- }
621
-
622
- if (inviteTokenFromQuery && inviteProofFromQuery) {
623
- setStatus("Invite link contains both inviteToken and inviteProof; expected only one.", true);
624
- }
625
-
626
- acceptForm.addEventListener("submit", async (event) => {
627
- event.preventDefault();
628
- const password = (passwordInput.value || "").trim();
629
-
630
- if (!password) {
631
- setStatus("Password is required", true);
632
- return;
633
- }
634
-
635
- if (!requestId) {
636
- setStatus("Missing requestId query parameter in invite link.", true);
637
- return;
638
- }
639
-
640
- if (!(inviteTokenFromQuery || inviteProofFromQuery)) {
641
- setStatus("Invite link is missing inviteToken/inviteProof.", true);
642
- return;
643
- }
644
-
645
- if (inviteTokenFromQuery && inviteProofFromQuery) {
646
- setStatus("Invite link contains both inviteToken and inviteProof; expected only one.", true);
647
- return;
648
- }
649
-
650
- setStatus("Accepting invite...");
651
- try {
652
- const payloadBody = {
653
- ...(inviteProofFromQuery
654
- ? { inviteProof: inviteProofFromQuery }
655
- : { inviteToken: inviteTokenFromQuery }),
656
- password,
657
- requestId,
658
- };
659
-
660
- const response = await fetch("/internal/register/accept", {
661
- method: "POST",
662
- headers: { "Content-Type": "application/json" },
663
- body: JSON.stringify(payloadBody),
664
- });
665
- const payload = await response.json().catch(() => ({}));
666
- if (!response.ok) {
667
- throw new Error(payload?.message || ("HTTP " + response.status));
668
- }
669
-
670
- const nextRequestId = (payload?.requestId || "").trim();
671
- totpId = (payload?.totpId || "").trim();
672
- const totpUrl = (payload?.totpUrl || "").trim();
673
- if (!nextRequestId || !totpId || !totpUrl) {
674
- throw new Error("Missing TOTP challenge response");
675
- }
676
-
677
- if (typeof window.QRCode !== "function") {
678
- throw new Error("QR code library did not load");
679
- }
680
-
681
- requestId = nextRequestId;
682
- requestIdEl.textContent = requestId;
683
- totpQr.innerHTML = "";
684
- new window.QRCode(totpQr, {
685
- height: 220,
686
- text: totpUrl,
687
- width: 220,
688
- });
689
- totpUrlEl.textContent = totpUrl;
690
- totpSection.style.display = "block";
691
- setStatus("Invite accepted. Scan QR and enter OTP code.");
692
- acceptForm.style.display = "none";
693
- } catch (error) {
694
- const message = error instanceof Error ? error.message : String(error);
695
- setStatus(message, true);
696
- }
697
- });
698
-
699
- totpForm.addEventListener("submit", async (event) => {
700
- event.preventDefault();
701
- const otpCode = (otpCodeInput.value || "").trim();
702
- if (!(requestId && totpId && otpCode)) {
703
- setStatus("Request ID, TOTP challenge, and OTP code are required", true);
704
- return;
705
- }
706
-
707
- setStatus("Verifying OTP...");
708
- try {
709
- const response = await fetch("/internal/register/complete", {
710
- method: "POST",
711
- headers: { "Content-Type": "application/json" },
712
- body: JSON.stringify({ otpCode, requestId, totpId }),
713
- });
714
- const payload = await response.json().catch(() => ({}));
715
- if (!response.ok) {
716
- throw new Error(payload?.message || ("HTTP " + response.status));
717
- }
718
-
719
- setStatus("Success. Registration completed. Return to terminal; it is polling for your session.");
720
- totpForm.style.display = "none";
721
- } catch (error) {
722
- const message = error instanceof Error ? error.message : String(error);
723
- setStatus(message, true);
724
- }
725
- });
726
- </script>
727
- </body>
728
- </html>`);
729
- return;
730
- }
731
- if (request.method === "POST" && requestUrl.pathname === "/internal/login/complete") {
732
- try {
733
- const rawBody = await readRequestBody(request);
734
- const parsed = JSON.parse(rawBody);
735
- const payload = await client.wcLoginComplete({
736
- otpSignature: typeof parsed.otpSignature === "string" ? parsed.otpSignature : "",
737
- requestId: typeof parsed.requestId === "string" ? parsed.requestId : ""
738
- });
739
- response.statusCode = 200;
740
- response.setHeader("Content-Type", "application/json");
741
- response.end(JSON.stringify(payload));
742
- } catch (error) {
743
- const status = error instanceof _agentwalletsdk.AgentWalletSdkError ? error.status : 400;
744
- response.statusCode = status;
745
- response.setHeader("Content-Type", "application/json");
746
- response.end(JSON.stringify(getErrorPayload(error)));
747
- }
748
- return;
749
- }
750
- if (request.method === "POST" && requestUrl.pathname === "/internal/register/accept") {
751
- try {
752
- const rawBody = await readRequestBody(request);
753
- const parsed = JSON.parse(rawBody);
754
- const payload = await client.wcRegisterAcceptInvite({
755
- callbackUrl: typeof parsed.callbackUrl === "string" ? parsed.callbackUrl : "",
756
- email: typeof parsed.email === "string" ? parsed.email : "",
757
- inviteProof: typeof parsed.inviteProof === "string" ? parsed.inviteProof : "",
758
- inviteToken: typeof parsed.inviteToken === "string" ? parsed.inviteToken : "",
759
- password: typeof parsed.password === "string" ? parsed.password : "",
760
- requestId: typeof parsed.requestId === "string" ? parsed.requestId : ""
761
- });
762
- response.statusCode = 200;
763
- response.setHeader("Content-Type", "application/json");
764
- response.end(JSON.stringify(payload));
765
- } catch (error) {
766
- const status = error instanceof _agentwalletsdk.AgentWalletSdkError ? error.status : 400;
767
- response.statusCode = status;
768
- response.setHeader("Content-Type", "application/json");
769
- response.end(JSON.stringify(getErrorPayload(error)));
770
- }
771
- return;
772
- }
773
- if (request.method === "POST" && requestUrl.pathname === "/internal/register/complete") {
774
- try {
775
- const rawBody = await readRequestBody(request);
776
- const parsed = JSON.parse(rawBody);
777
- const payload = await client.wcRegisterComplete({
778
- otpCode: typeof parsed.otpCode === "string" ? parsed.otpCode : "",
779
- requestId: typeof parsed.requestId === "string" ? parsed.requestId : "",
780
- totpId: typeof parsed.totpId === "string" ? parsed.totpId : ""
781
- });
782
- response.statusCode = 200;
783
- response.setHeader("Content-Type", "application/json");
784
- response.end(JSON.stringify(payload));
785
- } catch (error) {
786
- const status = error instanceof _agentwalletsdk.AgentWalletSdkError ? error.status : 400;
787
- response.statusCode = status;
788
- response.setHeader("Content-Type", "application/json");
789
- response.end(JSON.stringify(getErrorPayload(error)));
790
- }
791
- return;
792
- }
793
- if (requestUrl.pathname === "/callback") {
794
- response.statusCode = 410;
795
- response.setHeader("Content-Type", "application/json");
796
- response.end(
797
- JSON.stringify({
798
- message: "Callback endpoint is no longer used. Complete the flow in browser and wait for CLI polling."
799
- })
800
- );
801
- return;
802
- }
803
- response.statusCode = 404;
804
- response.setHeader("Content-Type", "application/json");
805
- response.end(JSON.stringify({ message: "Not found" }));
806
- });
807
- await new Promise((resolve, reject) => {
808
- server.once("error", (error) => {
809
- reject(error);
810
- });
811
- server.listen(port, "127.0.0.1", () => {
812
- resolve();
813
- });
814
- });
815
- const close = async () => {
816
- await new Promise((resolve) => {
817
- server.close(() => resolve());
818
- });
819
- };
820
- return {
821
- callbackUrl: `http://127.0.0.1:${port}/callback`,
822
- close
823
- };
824
- };
825
- var login = async (args, flags) => {
826
- const token = (_nullishCoalesce(flags.token, () => ( ""))).trim();
827
- if (token) {
828
- await verifySessionToken(token);
829
- await saveSessionToken(token);
830
- return;
831
- }
832
- const email = (_nullishCoalesce(_nullishCoalesce(flags.email, () => ( args[0])), () => ( ""))).trim().toLowerCase();
833
- if (!email) {
834
- throw new Error(
835
- "login requires --token <token> or --email <email>. Run `wlfc login --help` for details."
836
- );
837
- }
838
- const password = (await _prompts.password.call(void 0, { message: `Password for ${email}` })).trim();
839
- if (!password) {
840
- throw new Error("Password is required");
841
- }
842
- const client = _agentwalletsdk.createAgentWalletClient.call(void 0, { baseUrl: resolveBaseUrl() });
843
- let otpCode = (_nullishCoalesce(flags.otp, () => ( ""))).trim();
844
- let loginResult;
845
- try {
846
- loginResult = await client.wcLoginPassword({
847
- email,
848
- ...otpCode ? { otpCode } : {},
849
- password
850
- });
851
- } catch (error) {
852
- const message = getErrorMessage(error);
853
- if (!otpCode && message.includes("TOTP code is required")) {
854
- otpCode = (await _prompts.input.call(void 0, { message: "TOTP code" })).trim();
855
- if (!otpCode) {
856
- throw new Error("TOTP code is required");
857
- }
858
- loginResult = await client.wcLoginPassword({
859
- email,
860
- otpCode,
861
- password
862
- });
863
- } else {
864
- throw error;
865
- }
866
- }
867
- if (!loginResult.token) {
868
- throw new Error("Login response did not include a session token");
869
- }
870
- await verifySessionToken(loginResult.token);
871
- await saveSessionToken(loginResult.token);
872
- };
873
- var register = async (args, flags) => {
874
- const email = _optionalChain([args, 'access', _3 => _3[0], 'optionalAccess', _4 => _4.trim, 'call', _5 => _5(), 'access', _6 => _6.toLowerCase, 'call', _7 => _7()]);
875
- if (!email) {
876
- throw new Error("register requires an email argument");
877
- }
878
- const callbackPort = parseCallbackPort(flags["callback-port"]);
879
- const callback = await startCallbackServer({
880
- port: callbackPort
881
- });
882
- const client = _agentwalletsdk.createAgentWalletClient.call(void 0, {
883
- baseUrl: resolveBaseUrl()
884
- });
885
- try {
886
- const start = await client.wcRegisterStart({
887
- callbackUrl: callback.callbackUrl,
888
- email
889
- });
890
- console.log("Check your email. We sent you a registration link.");
891
- console.log(
892
- "Open the link from your email. It already includes requestId and invite token/proof."
893
- );
894
- if (!start.emailSent) {
895
- console.log(
896
- `Email delivery is unavailable in this environment. Open this local link instead:
897
- ${start.setupUrl}`
898
- );
899
- }
900
- console.log("Waiting for registration completion...");
901
- const callbackToken = await waitForWcCompletionToken(
902
- client,
903
- start.requestId
904
- );
905
- await verifySessionToken(callbackToken);
906
- await saveSessionToken(callbackToken);
907
- } finally {
908
- await callback.close();
909
- }
910
- };
911
- var logout = async () => {
912
- const config = await loadConfig();
913
- await saveConfig({
914
- aliases: config.aliases
915
- });
916
- console.log("Cleared session token from ~/.config/wlfc-agent/config.json");
917
- };
918
- var printDoctorReport = (flags, report) => {
919
- if (shouldOutputJson(flags)) {
920
- printJson(report);
921
- return;
922
- }
923
- console.log(`Doctor report (${report.generatedAt})`);
924
- console.log(`Backend URL: ${report.baseUrl}`);
925
- for (const check of report.checks) {
926
- let marker = "[FAIL]";
927
- if (check.status === "ok") {
928
- marker = "[OK] ";
929
- } else if (check.status === "warn") {
930
- marker = "[WARN]";
931
- }
932
- console.log(`${marker} ${check.name}: ${check.detail}`);
933
- }
934
- };
935
- var doctor = async (flags) => {
936
- const baseUrl = resolveBaseUrl();
937
- const checks = [];
938
- try {
939
- const response = await fetch(`${baseUrl}/rest/custody/agent/pay`, {
940
- body: "{}",
941
- headers: {
942
- "content-type": "application/json"
943
- },
944
- method: "POST"
945
- });
946
- checks.push({
947
- detail: `Reachable (HTTP ${response.status})`,
948
- name: "backend",
949
- status: "ok"
950
- });
951
- } catch (error) {
952
- checks.push({
953
- detail: getErrorMessage(error),
954
- name: "backend",
955
- status: "fail"
956
- });
957
- }
958
- const config = await loadConfig();
959
- if (config.token) {
960
- checks.push({
961
- detail: "Session token is configured",
962
- name: "token",
963
- status: "ok"
964
- });
965
- } else {
966
- checks.push({
967
- detail: "No session token configured. Run `wlfc login`.",
968
- name: "token",
969
- status: "warn"
970
- });
971
- }
972
- const aliasCount = Object.values(config.aliases).reduce(
973
- (count, aliasMap) => count + Object.keys(aliasMap).length,
974
- 0
975
- );
976
- checks.push({
977
- detail: aliasCount > 0 ? `${aliasCount} alias(es) configured` : "No aliases configured",
978
- name: "aliases",
979
- status: aliasCount > 0 ? "ok" : "warn"
980
- });
981
- try {
982
- const files = await _promises.readdir.call(void 0, OTP_DIR);
983
- const otpFileContents = await Promise.all(
984
- files.map(async (filename) => {
985
- const fullPath = _path2.default.join(OTP_DIR, filename);
986
- return (await _promises.readFile.call(void 0, fullPath, "utf8")).trim();
987
- })
988
- );
989
- const otpSecrets = otpFileContents.reduce((count, content) => {
990
- if (!content.startsWith("otpauth://")) {
991
- return count;
992
- }
993
- const secret = new URL(content).searchParams.get("secret");
994
- return _optionalChain([secret, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()]) ? count + 1 : count;
995
- }, 0);
996
- checks.push({
997
- detail: otpSecrets > 0 ? `${otpSecrets} OTP secret file(s) found in ${OTP_DIR}` : `No valid OTP secret found in ${OTP_DIR}`,
998
- name: "otp",
999
- status: otpSecrets > 0 ? "ok" : "warn"
1000
- });
1001
- } catch (e2) {
1002
- checks.push({
1003
- detail: `Directory not found: ${OTP_DIR}`,
1004
- name: "otp",
1005
- status: "warn"
1006
- });
1007
- }
1008
- if (config.token) {
1009
- const client = _agentwalletsdk.createAgentWalletClient.call(void 0, {
1010
- baseUrl,
1011
- token: config.token
1012
- });
1013
- try {
1014
- const projects = await client.listProjects();
1015
- checks.push({
1016
- detail: `Token valid (${projects.length} visible project(s))`,
1017
- name: "auth",
1018
- status: "ok"
1019
- });
1020
- } catch (error) {
1021
- checks.push({
1022
- detail: getErrorMessage(error),
1023
- name: "auth",
1024
- status: "fail"
1025
- });
1026
- }
1027
- try {
1028
- const wallets = await client.listWallets();
1029
- checks.push({
1030
- detail: `${wallets.length} wallet(s) visible`,
1031
- name: "wallet visibility",
1032
- status: wallets.length > 0 ? "ok" : "warn"
1033
- });
1034
- } catch (error) {
1035
- checks.push({
1036
- detail: getErrorMessage(error),
1037
- name: "wallet visibility",
1038
- status: "fail"
1039
- });
1040
- }
1041
- try {
1042
- const configs = await client.listWalletConfigs();
1043
- const activePolicies = configs.filter(
1044
- (configItem) => Boolean(configItem.policy) && _optionalChain([configItem, 'access', _10 => _10.policy, 'optionalAccess', _11 => _11.status]) !== "deleted"
1045
- ).length;
1046
- checks.push({
1047
- detail: `${activePolicies} wallet policy config(s) visible`,
1048
- name: "policy visibility",
1049
- status: activePolicies > 0 ? "ok" : "warn"
1050
- });
1051
- } catch (error) {
1052
- checks.push({
1053
- detail: getErrorMessage(error),
1054
- name: "policy visibility",
1055
- status: "fail"
1056
- });
1057
- }
1058
- }
1059
- printDoctorReport(flags, {
1060
- baseUrl,
1061
- checks,
1062
- generatedAt: (/* @__PURE__ */ new Date()).toISOString()
1063
- });
1064
- };
1065
- var aliasList = async (flags) => {
1066
- const config = await loadConfig();
1067
- const typeRaw = (_nullishCoalesce(flags.type, () => ( ""))).trim();
1068
- if (!typeRaw) {
1069
- const entries2 = Object.keys(config.aliases).flatMap(
1070
- (aliasType) => Object.entries(config.aliases[aliasType]).map(([alias, id]) => ({
1071
- alias,
1072
- id,
1073
- type: aliasType
1074
- }))
1075
- );
1076
- printValue(flags, entries2, {
1077
- title: "Aliases"
1078
- });
1079
- return;
1080
- }
1081
- const type = parseAliasType(typeRaw);
1082
- const entries = Object.entries(config.aliases[type]).map(([alias, id]) => ({
1083
- alias,
1084
- id,
1085
- type
1086
- }));
1087
- printValue(flags, entries, {
1088
- title: `${type} aliases`
1089
- });
1090
- };
1091
- var aliasSet = async (flags) => {
1092
- const type = parseAliasType((_nullishCoalesce(flags.type, () => ( ""))).trim());
1093
- const name = (_nullishCoalesce(flags.name, () => ( ""))).trim();
1094
- const id = (_nullishCoalesce(flags.id, () => ( ""))).trim();
1095
- if (!(name && id)) {
1096
- throw new Error("alias set requires --type, --name, and --id");
1097
- }
1098
- const config = await loadConfig();
1099
- const nextAliases = {
1100
- ...config.aliases,
1101
- [type]: {
1102
- ...config.aliases[type],
1103
- [name]: id
1104
- }
1105
- };
1106
- await saveConfig({
1107
- ...config,
1108
- aliases: nextAliases
1109
- });
1110
- printValue(
1111
- flags,
1112
- { alias: name, id, type },
1113
- {
1114
- nextSteps: [
1115
- `Use --${type}-id ${name} in CLI commands to resolve to ${id}`
1116
- ],
1117
- title: "Alias saved"
1118
- }
1119
- );
1120
- };
1121
- var aliasRemove = async (flags) => {
1122
- const type = parseAliasType((_nullishCoalesce(flags.type, () => ( ""))).trim());
1123
- const name = (_nullishCoalesce(flags.name, () => ( ""))).trim();
1124
- if (!name) {
1125
- throw new Error("alias rm requires --type and --name");
1126
- }
1127
- const config = await loadConfig();
1128
- if (!(name in config.aliases[type])) {
1129
- throw new Error(`Alias not found: ${name}`);
1130
- }
1131
- const nextTypeAliases = { ...config.aliases[type] };
1132
- delete nextTypeAliases[name];
1133
- await saveConfig({
1134
- ...config,
1135
- aliases: {
1136
- ...config.aliases,
1137
- [type]: nextTypeAliases
1138
- }
1139
- });
1140
- printValue(
1141
- flags,
1142
- { ok: true },
1143
- {
1144
- title: `Removed alias ${name} (${type})`
1145
- }
1146
- );
1147
- };
1148
- var walletList = async (flags) => {
1149
- const client = await getAuthedClient(flags);
1150
- const wallets = await client.listWallets();
1151
- printValue(flags, wallets, {
1152
- title: "Wallets"
1153
- });
1154
- };
1155
- var walletNew = async (flags) => {
1156
- const projectIdInput = (_nullishCoalesce(flags["project-id"], () => ( ""))).trim();
1157
- const label = (_nullishCoalesce(flags.label, () => ( ""))).trim();
1158
- const network = (_nullishCoalesce(flags.network, () => ( DEFAULT_WALLET_NETWORK))).trim();
1159
- const chainId = (_nullishCoalesce(flags["chain-id"], () => ( String(DEFAULT_WALLET_CHAIN_ID)))).trim();
1160
- if (!(projectIdInput && label)) {
1161
- throw new Error("wallet new requires --project-id and --label");
1162
- }
1163
- const projectId = await resolveAliasId("project", projectIdInput);
1164
- const client = await getAuthedClient(flags);
1165
- const wallet = await client.createWallet({
1166
- chainId: parsePositiveInteger(chainId, "--chain-id"),
1167
- label,
1168
- network: parseNetwork(network),
1169
- projectId
1170
- });
1171
- printValue(flags, wallet, {
1172
- nextSteps: [
1173
- `wlfc alias set --type wallet --name <name> --id ${_nullishCoalesce(wallet.id, () => ( "<wallet-id>"))}`,
1174
- `wlfc agent-key new --wallet-id ${_nullishCoalesce(wallet.id, () => ( "<wallet-id>"))}`
1175
- ],
1176
- title: "Wallet created"
1177
- });
1178
- };
1179
- var walletBalances = async (flags) => {
1180
- const client = await getAuthedClient(flags);
1181
- const balances = await client.listWalletBalances();
1182
- printValue(flags, balances, {
1183
- title: "Wallet balances"
1184
- });
1185
- };
1186
- var walletConfigs = async (flags) => {
1187
- const client = await getAuthedClient(flags);
1188
- const configs = await client.listWalletConfigs();
1189
- printValue(flags, configs, {
1190
- title: "Wallet configs"
1191
- });
1192
- };
1193
- var walletAuditLogs = async (flags) => {
1194
- const walletIdInput = (_nullishCoalesce(flags["wallet-id"], () => ( ""))).trim();
1195
- if (!walletIdInput) {
1196
- throw new Error("wallet audit-logs requires --wallet-id <id>");
1197
- }
1198
- const limitRaw = (_nullishCoalesce(flags.limit, () => ( ""))).trim();
1199
- const walletId = await resolveAliasId("wallet", walletIdInput);
1200
- const client = await getAuthedClient(flags);
1201
- const logs = await client.listWalletAuditLogs({
1202
- action: flags.action,
1203
- browser: flags.browser,
1204
- cursor: flags.cursor,
1205
- ipAddress: flags["ip-address"],
1206
- ...limitRaw ? { limit: parsePositiveInteger(limitRaw, "--limit") } : {},
1207
- location: flags.location,
1208
- query: flags.query,
1209
- user: flags.user,
1210
- walletId
1211
- });
1212
- printValue(flags, logs, {
1213
- title: "Wallet audit logs"
1214
- });
1215
- };
1216
- var destinationList = async (flags) => {
1217
- const client = await getAuthedClient(flags);
1218
- const destinations = await client.listDestinations();
1219
- printValue(flags, destinations, {
1220
- title: "Destinations"
1221
- });
1222
- };
1223
- var destinationNew = async (flags) => {
1224
- const projectIdInput = (_nullishCoalesce(flags["project-id"], () => ( ""))).trim();
1225
- const label = (_nullishCoalesce(flags.label, () => ( ""))).trim();
1226
- const network = (_nullishCoalesce(flags.network, () => ( ""))).trim();
1227
- const chainId = (_nullishCoalesce(flags["chain-id"], () => ( ""))).trim();
1228
- const address = (_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(flags.address, () => ( flags["vendor-address"])), () => ( flags["destination-address"])), () => ( ""))).trim();
1229
- if (!(projectIdInput && label && network && chainId && address)) {
1230
- throw new Error(
1231
- "destination new requires --project-id, --label, --network, --chain-id, and --address"
1232
- );
1233
- }
1234
- const projectId = await resolveAliasId("project", projectIdInput);
1235
- const client = await getAuthedClient(flags);
1236
- const destination = await client.createDestination({
1237
- chainId: parsePositiveInteger(chainId, "--chain-id"),
1238
- label,
1239
- network: parseNetwork(network),
1240
- projectId,
1241
- vendor_address: address
1242
- });
1243
- printValue(flags, destination, {
1244
- nextSteps: [
1245
- `wlfc alias set --type destination --name <name> --id ${_nullishCoalesce(destination.id, () => ( "<destination-id>"))}`,
1246
- "wlfc policy put --wallet-id <wallet-id-or-alias> --destinations-file ./policy.json"
1247
- ],
1248
- title: "Destination created"
1249
- });
1250
- };
1251
- var agentKeyList = async (flags) => {
1252
- const client = await getAuthedClient(flags);
1253
- const agentKeys = await client.listAgentKeys();
1254
- printValue(flags, agentKeys, {
1255
- title: "Agent keys"
1256
- });
1257
- };
1258
- var agentKeyGet = async (flags) => {
1259
- const id = (_nullishCoalesce(_nullishCoalesce(flags.id, () => ( flags["agent-key-id"])), () => ( ""))).trim();
1260
- if (!id) {
1261
- throw new Error("agent-key get requires --id <agent-key-id>");
1262
- }
1263
- const client = await getAuthedClient(flags);
1264
- const agentKey = await client.getAgentKey(id);
1265
- printValue(flags, agentKey, {
1266
- title: "Agent key"
1267
- });
1268
- };
1269
- var agentKeyNew = async (flags) => {
1270
- const walletIdInput = (_nullishCoalesce(flags["wallet-id"], () => ( ""))).trim();
1271
- if (!walletIdInput) {
1272
- throw new Error("agent-key new requires --wallet-id <id>");
1273
- }
1274
- const walletId = await resolveAliasId("wallet", walletIdInput);
1275
- const client = await getAuthedClient(flags);
1276
- const created = await client.createAgentKey({ walletId });
1277
- const keyValue = typeof created.key === "string" ? _nullishCoalesce(created.key, () => ( "")) : "";
1278
- printValue(flags, created, {
1279
- nextSteps: [
1280
- keyValue ? `wlfa login --agent-key ${keyValue}` : "wlfa login --agent-key <key-from-output>",
1281
- "wlfa pay --address <destination> --amount <amount>"
1282
- ],
1283
- title: "Agent key created"
1284
- });
1285
- };
1286
- var agentKeyRemove = async (flags) => {
1287
- const id = (_nullishCoalesce(_nullishCoalesce(flags.id, () => ( flags["agent-key-id"])), () => ( ""))).trim();
1288
- if (!id) {
1289
- throw new Error("agent-key rm requires --id <agent-key-id>");
1290
- }
1291
- const client = await getAuthedClient(flags);
1292
- const deleted = await client.deleteAgentKey(id);
1293
- printValue(flags, deleted, {
1294
- title: "Agent key revoked"
1295
- });
1296
- };
1297
- var policyGet = async (flags) => {
1298
- const walletIdInput = (_nullishCoalesce(flags["wallet-id"], () => ( ""))).trim();
1299
- if (!walletIdInput) {
1300
- throw new Error("policy get requires --wallet-id <id>");
1301
- }
1302
- const walletId = await resolveAliasId("wallet", walletIdInput);
1303
- const client = await getAuthedClient(flags);
1304
- const policy = await client.getPolicy(walletId);
1305
- printValue(flags, policy, {
1306
- title: "Policy"
1307
- });
1308
- };
1309
- var policyPut = async (flags) => {
1310
- const walletIdInput = (_nullishCoalesce(flags["wallet-id"], () => ( ""))).trim();
1311
- if (!walletIdInput) {
1312
- throw new Error("policy put requires --wallet-id <id>");
1313
- }
1314
- const walletId = await resolveAliasId("wallet", walletIdInput);
1315
- const destinations = await parsePolicyDestinations(flags);
1316
- const client = await getAuthedClient(flags);
1317
- const updated = await client.putPolicy({
1318
- destinations,
1319
- walletId
1320
- });
1321
- printValue(flags, updated, {
1322
- nextSteps: [
1323
- "wlfa pay --address <destination-address> --amount <amount>",
1324
- `wlfc wallet audit-logs --wallet-id ${walletId}`
1325
- ],
1326
- title: "Policy updated"
1327
- });
1328
- };
1329
- var policyRemove = async (flags) => {
1330
- const walletIdInput = (_nullishCoalesce(flags["wallet-id"], () => ( ""))).trim();
1331
- if (!walletIdInput) {
1332
- throw new Error("policy rm requires --wallet-id <id>");
1333
- }
1334
- const walletId = await resolveAliasId("wallet", walletIdInput);
1335
- const client = await getAuthedClient(flags);
1336
- const removed = await client.deletePolicy(walletId);
1337
- printValue(flags, removed, {
1338
- title: "Policy removed"
1339
- });
1340
- };
1341
- var projectList = async (flags) => {
1342
- const client = await getAuthedClient(flags);
1343
- const projects = await client.listProjects();
1344
- printValue(flags, projects, {
1345
- title: "Projects"
1346
- });
1347
- };
1348
- var projectNew = async (args, flags) => {
1349
- const projectName = (_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(flags.name, () => ( flags["project-name"])), () => ( args[0])), () => ( ""))).trim();
1350
- if (!projectName) {
1351
- throw new Error("project new requires --name <project-name>");
1352
- }
1353
- const client = await getAuthedClient(flags);
1354
- const project = await client.createProject({ projectName });
1355
- printValue(flags, project, {
1356
- nextSteps: [
1357
- `wlfc alias set --type project --name <name> --id ${_nullishCoalesce(project.id, () => ( "<project-id>"))}`,
1358
- `wlfc wallet new --project-id ${_nullishCoalesce(project.id, () => ( "<project-id>"))} --label <wallet-label>`
1359
- ],
1360
- title: "Project created"
1361
- });
1362
- };
1363
- var approvalList = async (flags) => {
1364
- const limitRaw = (_nullishCoalesce(flags.limit, () => ( ""))).trim();
1365
- const walletIdInput = (_nullishCoalesce(flags["wallet-id"], () => ( ""))).trim();
1366
- const walletId = walletIdInput ? await resolveAliasId("wallet", walletIdInput) : void 0;
1367
- const client = await getAuthedClient(flags);
1368
- const approvals = await client.listPendingApprovals({
1369
- ...limitRaw ? { limit: parsePositiveInteger(limitRaw, "--limit") } : {},
1370
- ...walletId ? { walletId } : {}
1371
- });
1372
- printValue(flags, approvals, {
1373
- title: "Pending approvals"
1374
- });
1375
- };
1376
- var approvalApprove = async (flags) => {
1377
- const approveId = (_nullishCoalesce(_nullishCoalesce(flags.id, () => ( flags["approve-id"])), () => ( ""))).trim();
1378
- const mfaType = (_nullishCoalesce(flags["mfa-type"], () => ( ""))).trim();
1379
- const otp = (_nullishCoalesce(flags.otp, () => ( ""))).trim();
1380
- if (!approveId) {
1381
- throw new Error("approval approve requires --id <approve-id>");
1382
- }
1383
- const approvalPayload = await parseApprovalPayload(flags);
1384
- const client = await getAuthedClient(flags);
1385
- const runApprove = async (otpCode) => client.approveManual({
1386
- ...approvalPayload ? { approvalPayload } : {},
1387
- approveId,
1388
- ...mfaType ? { mfaType } : {},
1389
- ...otpCode ? { otp: otpCode } : {}
1390
- });
1391
- let approved;
1392
- try {
1393
- approved = await runApprove(otp || void 0);
1394
- } catch (error) {
1395
- if (!otp && getErrorMessage(error).toLowerCase().includes("otp code is required")) {
1396
- const promptedOtp = (await _prompts.input.call(void 0, { message: "TOTP code" })).trim();
1397
- if (!promptedOtp) {
1398
- throw new Error("TOTP code is required");
1399
- }
1400
- approved = await runApprove(promptedOtp);
1401
- } else {
1402
- throw error;
1403
- }
1404
- }
1405
- printValue(flags, approved, {
1406
- nextSteps: [
1407
- "wlfc approval ls",
1408
- "wlfc wallet audit-logs --wallet-id <wallet-id-or-alias>"
1409
- ],
1410
- title: "Approval submitted"
1411
- });
1412
- };
1413
- var parseWebhookEventType = (value) => {
1414
- if (value === "approval" || value === "payment") {
1415
- return value;
1416
- }
1417
- throw new Error("--event-type must be either approval or payment");
1418
- };
1419
- var parseWebhookStatus = (value) => {
1420
- if (value === "active" || value === "disabled") {
1421
- return value;
1422
- }
1423
- throw new Error("--status must be either active or disabled");
1424
- };
1425
- var webhookList = async (flags) => {
1426
- const client = await getAuthedClient(flags);
1427
- const webhooks = await client.listWebhooks();
1428
- printValue(flags, webhooks, {
1429
- title: "Webhooks"
1430
- });
1431
- };
1432
- var webhookGet = async (flags) => {
1433
- const webhookId = (_nullishCoalesce(_nullishCoalesce(flags.id, () => ( flags["webhook-id"])), () => ( ""))).trim();
1434
- if (!webhookId) {
1435
- throw new Error("webhook get requires --id <webhook-id>");
1436
- }
1437
- const client = await getAuthedClient(flags);
1438
- const webhook = await client.getWebhook(webhookId);
1439
- printValue(flags, webhook, {
1440
- title: "Webhook"
1441
- });
1442
- };
1443
- var webhookNew = async (flags) => {
1444
- const projectIdInput = (_nullishCoalesce(flags["project-id"], () => ( ""))).trim();
1445
- const eventTypeRaw = (_nullishCoalesce(flags["event-type"], () => ( ""))).trim();
1446
- const url = (_nullishCoalesce(flags.url, () => ( ""))).trim();
1447
- const secret = (_nullishCoalesce(flags.secret, () => ( ""))).trim();
1448
- if (!(projectIdInput && eventTypeRaw && url)) {
1449
- throw new Error(
1450
- "webhook new requires --project-id, --event-type, and --url"
1451
- );
1452
- }
1453
- const projectId = await resolveAliasId("project", projectIdInput);
1454
- const client = await getAuthedClient(flags);
1455
- const webhook = await client.createWebhook({
1456
- eventType: parseWebhookEventType(eventTypeRaw),
1457
- projectId,
1458
- ...secret ? { secret } : {},
1459
- url
1460
- });
1461
- printValue(flags, webhook, {
1462
- nextSteps: [
1463
- `wlfc webhook test --id ${_nullishCoalesce(webhook.id, () => ( "<webhook-id>"))}`,
1464
- `wlfc webhook deliveries --id ${_nullishCoalesce(webhook.id, () => ( "<webhook-id>"))}`
1465
- ],
1466
- title: "Webhook created"
1467
- });
1468
- };
1469
- var webhookUpdate = async (flags) => {
1470
- const webhookId = (_nullishCoalesce(_nullishCoalesce(flags.id, () => ( flags["webhook-id"])), () => ( ""))).trim();
1471
- const eventTypeRaw = (_nullishCoalesce(flags["event-type"], () => ( ""))).trim();
1472
- const statusRaw = (_nullishCoalesce(flags.status, () => ( ""))).trim();
1473
- const url = (_nullishCoalesce(flags.url, () => ( ""))).trim();
1474
- const secret = (_nullishCoalesce(flags.secret, () => ( ""))).trim();
1475
- if (!webhookId) {
1476
- throw new Error("webhook update requires --id <webhook-id>");
1477
- }
1478
- if (!(eventTypeRaw || statusRaw || url || secret)) {
1479
- throw new Error(
1480
- "webhook update requires at least one of --event-type, --status, --url, or --secret"
1481
- );
1482
- }
1483
- const client = await getAuthedClient(flags);
1484
- const updated = await client.updateWebhook({
1485
- ...eventTypeRaw ? { eventType: parseWebhookEventType(eventTypeRaw) } : {},
1486
- ...secret ? { secret } : {},
1487
- ...statusRaw ? { status: parseWebhookStatus(statusRaw) } : {},
1488
- ...url ? { url } : {},
1489
- webhookId
1490
- });
1491
- printValue(flags, updated, {
1492
- title: "Webhook updated"
1493
- });
1494
- };
1495
- var webhookRemove = async (flags) => {
1496
- const webhookId = (_nullishCoalesce(_nullishCoalesce(flags.id, () => ( flags["webhook-id"])), () => ( ""))).trim();
1497
- if (!webhookId) {
1498
- throw new Error("webhook rm requires --id <webhook-id>");
1499
- }
1500
- const client = await getAuthedClient(flags);
1501
- const removed = await client.deleteWebhook(webhookId);
1502
- printValue(flags, removed, {
1503
- title: "Webhook removed"
1504
- });
1505
- };
1506
- var webhookDeliveries = async (flags) => {
1507
- const webhookId = (_nullishCoalesce(_nullishCoalesce(flags.id, () => ( flags["webhook-id"])), () => ( ""))).trim();
1508
- if (!webhookId) {
1509
- throw new Error("webhook deliveries requires --id <webhook-id>");
1510
- }
1511
- const limitRaw = (_nullishCoalesce(flags.limit, () => ( ""))).trim();
1512
- const config = await loadConfig();
1513
- const token = (_nullishCoalesce(_nullishCoalesce(flags.token, () => ( config.token)), () => ( ""))).trim();
1514
- if (!token) {
1515
- throw new Error(
1516
- "Token is missing. Run `wlfc login --token <token>` or `wlfc login --email <email>` first."
1517
- );
1518
- }
1519
- const url = new URL(
1520
- `${resolveBaseUrl()}/rest/custody/agent/webhooks/${encodeURIComponent(webhookId)}/deliveries`
1521
- );
1522
- if (limitRaw) {
1523
- url.searchParams.set(
1524
- "limit",
1525
- String(parsePositiveInteger(limitRaw, "--limit"))
1526
- );
1527
- }
1528
- const response = await fetch(url, {
1529
- headers: {
1530
- Authorization: token
1531
- },
1532
- method: "GET"
1533
- });
1534
- const payload = await response.json().catch(async () => ({
1535
- message: await response.text().catch(() => "Unknown error")
1536
- }));
1537
- if (!response.ok) {
1538
- if (typeof payload === "object" && payload !== null && "message" in payload && typeof payload.message === "string") {
1539
- throw new Error(payload.message);
1540
- }
1541
- throw new Error(
1542
- `Failed to list webhook deliveries (HTTP ${response.status})`
1543
- );
1544
- }
1545
- printValue(flags, payload, {
1546
- title: "Webhook deliveries"
1547
- });
1548
- };
1549
- var webhookTest = async (flags) => {
1550
- const webhookId = (_nullishCoalesce(_nullishCoalesce(flags.id, () => ( flags["webhook-id"])), () => ( ""))).trim();
1551
- if (!webhookId) {
1552
- throw new Error("webhook test requires --id <webhook-id>");
1553
- }
1554
- const client = await getAuthedClient(flags);
1555
- const webhook = await client.getWebhook(webhookId);
1556
- const eventType = webhook.eventType === "approval" ? "approval" : "payment";
1557
- const payload = eventType === "approval" ? {
1558
- approveId: `test_approve_${Date.now()}`,
1559
- paymentId: `test_payment_${Date.now()}`,
1560
- status: "success",
1561
- txHash: `0xtest${Date.now().toString(16)}`,
1562
- walletId: "test_wallet"
1563
- } : {
1564
- destinationAddress: "0x0000000000000000000000000000000000000000",
1565
- paymentId: `test_payment_${Date.now()}`,
1566
- reason: "webhook_test_event",
1567
- status: "failed",
1568
- walletId: "test_wallet"
1569
- };
1570
- const response = await fetch(webhook.url, {
1571
- body: JSON.stringify(payload),
1572
- headers: {
1573
- "content-type": "application/json",
1574
- "x-wlfc-webhook-test": "true"
1575
- },
1576
- method: "POST"
1577
- });
1578
- const responseBody = (await response.text()).slice(0, 1e3);
1579
- printValue(
1580
- flags,
1581
- {
1582
- eventType,
1583
- ok: response.ok,
1584
- responseBody,
1585
- statusCode: response.status,
1586
- webhookId,
1587
- webhookUrl: webhook.url
1588
- },
1589
- {
1590
- nextSteps: [`wlfc webhook deliveries --id ${webhookId}`],
1591
- title: "Webhook test result"
1592
- }
1593
- );
1594
- };
1595
- var withCommandOptions = (command, options = {}) => {
1596
- const { auth = false, json = true } = options;
1597
- if (json) {
1598
- withJsonOption(command);
1599
- }
1600
- if (auth) {
1601
- withTokenOption(command);
1602
- }
1603
- withUnsupportedBaseUrlOption(command);
1604
- return command;
1605
- };
1606
- var createProgram = () => {
1607
- const program = new (0, _commander.Command)();
1608
- program.name("wlfc").description("WLFI Custody CLI").showHelpAfterError().showSuggestionAfterError().addHelpText(
1609
- "after",
1610
- `
1611
- Environment:
1612
- WLFI_AGENT_BACKEND_URL Backend URL override (default: ${_agentwalletsdk.DEFAULT_BASE_URL})
1613
- `
1614
- );
1615
- withUnsupportedBaseUrlOption(program);
1616
- withCommandOptions(
1617
- program.command("login [email]").description("Login with token or email/password").option("--email <email>", "Email address").option("--otp <code>", "TOTP code"),
1618
- { auth: true, json: false }
1619
- ).action(async (emailArg, _options, command) => {
1620
- const flags = getCommandFlags(command);
1621
- await login(emailArg ? [emailArg] : [], flags);
1622
- });
1623
- withCommandOptions(
1624
- program.command("register <email>").description("Start registration flow").option(
1625
- "--callback-port <port>",
1626
- "Local callback TCP port",
1627
- String(DEFAULT_CALLBACK_PORT)
1628
- ),
1629
- { json: false }
1630
- ).action(async (emailArg, _options, command) => {
1631
- const flags = getCommandFlags(command);
1632
- await register([emailArg], flags);
1633
- });
1634
- withCommandOptions(program.command("doctor").description("Run diagnostics"), {
1635
- json: true
1636
- }).action(async (_options, command) => {
1637
- await doctor(getCommandFlags(command));
1638
- });
1639
- withCommandOptions(
1640
- program.command("logout").description("Clear saved session token"),
1641
- { json: false }
1642
- ).action(async () => {
1643
- await logout();
1644
- });
1645
- const alias = program.command("alias").description("Manage aliases");
1646
- withCommandOptions(
1647
- alias.command("ls").description("List aliases").option("--type <wallet|project|destination>", "Filter alias type"),
1648
- { json: true }
1649
- ).action(async (_options, command) => {
1650
- await aliasList(getCommandFlags(command));
1651
- });
1652
- withCommandOptions(
1653
- alias.command("set").description("Set alias mapping").requiredOption("--type <wallet|project|destination>", "Alias type").requiredOption("--name <alias>", "Alias name").requiredOption("--id <resource-id>", "Resource id"),
1654
- { json: true }
1655
- ).action(async (_options, command) => {
1656
- await aliasSet(getCommandFlags(command));
1657
- });
1658
- withCommandOptions(
1659
- alias.command("rm").description("Remove alias mapping").requiredOption("--type <wallet|project|destination>", "Alias type").requiredOption("--name <alias>", "Alias name"),
1660
- { json: true }
1661
- ).action(async (_options, command) => {
1662
- await aliasRemove(getCommandFlags(command));
1663
- });
1664
- const destination = program.command("destination").description("Manage destinations");
1665
- withCommandOptions(
1666
- destination.command("ls").description("List destinations"),
1667
- { auth: true, json: true }
1668
- ).action(async (_options, command) => {
1669
- await destinationList(getCommandFlags(command));
1670
- });
1671
- withCommandOptions(
1672
- destination.command("new").description("Create destination").requiredOption("--project-id <id>", "Project id or alias").requiredOption("--label <label>", "Destination label").requiredOption("--network <evm|solana>", "Destination network").requiredOption("--chain-id <id>", "Chain id").requiredOption("--address <address>", "Destination address").addOption(new (0, _commander.Option)("--vendor-address <address>").hideHelp()).addOption(new (0, _commander.Option)("--destination-address <address>").hideHelp()),
1673
- { auth: true, json: true }
1674
- ).action(async (_options, command) => {
1675
- await destinationNew(getCommandFlags(command));
1676
- });
1677
- const agentKey = program.command("agent-key").description("Manage agent keys");
1678
- withCommandOptions(agentKey.command("ls").description("List agent keys"), {
1679
- auth: true,
1680
- json: true
1681
- }).action(async (_options, command) => {
1682
- await agentKeyList(getCommandFlags(command));
1683
- });
1684
- withCommandOptions(
1685
- agentKey.command("get").description("Get one agent key").option("--id <agent-key-id>", "Agent key id").addOption(new (0, _commander.Option)("--agent-key-id <agent-key-id>").hideHelp()),
1686
- { auth: true, json: true }
1687
- ).action(async (_options, command) => {
1688
- await agentKeyGet(getCommandFlags(command));
1689
- });
1690
- withCommandOptions(
1691
- agentKey.command("new").description("Create agent key").requiredOption("--wallet-id <id>", "Wallet id or alias"),
1692
- { auth: true, json: true }
1693
- ).action(async (_options, command) => {
1694
- await agentKeyNew(getCommandFlags(command));
1695
- });
1696
- withCommandOptions(
1697
- agentKey.command("rm").description("Revoke agent key").option("--id <agent-key-id>", "Agent key id").addOption(new (0, _commander.Option)("--agent-key-id <agent-key-id>").hideHelp()),
1698
- { auth: true, json: true }
1699
- ).action(async (_options, command) => {
1700
- await agentKeyRemove(getCommandFlags(command));
1701
- });
1702
- const policy = program.command("policy").description("Manage wallet policy");
1703
- withCommandOptions(
1704
- policy.command("get").description("Get policy").requiredOption("--wallet-id <id>", "Wallet id or alias"),
1705
- { auth: true, json: true }
1706
- ).action(async (_options, command) => {
1707
- await policyGet(getCommandFlags(command));
1708
- });
1709
- withCommandOptions(
1710
- policy.command("put").description("Create or update policy").requiredOption("--wallet-id <id>", "Wallet id or alias").option("--destinations-json <json>", "Inline JSON destinations array").option("--destinations-file <path>", "Path to destinations JSON"),
1711
- { auth: true, json: true }
1712
- ).action(async (_options, command) => {
1713
- await policyPut(getCommandFlags(command));
1714
- });
1715
- withCommandOptions(
1716
- policy.command("rm").description("Delete policy").requiredOption("--wallet-id <id>", "Wallet id or alias"),
1717
- { auth: true, json: true }
1718
- ).action(async (_options, command) => {
1719
- await policyRemove(getCommandFlags(command));
1720
- });
1721
- const project = program.command("project").description("Manage projects");
1722
- withCommandOptions(project.command("ls").description("List projects"), {
1723
- auth: true,
1724
- json: true
1725
- }).action(async (_options, command) => {
1726
- await projectList(getCommandFlags(command));
1727
- });
1728
- withCommandOptions(
1729
- project.command("new [name]").description("Create project").option("--name <project-name>", "Project name").addOption(new (0, _commander.Option)("--project-name <project-name>").hideHelp()),
1730
- { auth: true, json: true }
1731
- ).action(async (nameArg, _options, command) => {
1732
- const flags = getCommandFlags(command);
1733
- await projectNew(nameArg ? [nameArg] : [], flags);
1734
- });
1735
- const wallet = program.command("wallet").description("Manage wallets");
1736
- withCommandOptions(wallet.command("ls").description("List wallets"), {
1737
- auth: true,
1738
- json: true
1739
- }).action(async (_options, command) => {
1740
- await walletList(getCommandFlags(command));
1741
- });
1742
- withCommandOptions(
1743
- wallet.command("new").description("Create wallet").requiredOption("--project-id <id>", "Project id or alias").requiredOption("--label <label>", "Wallet label").option(
1744
- "--network <evm|solana>",
1745
- "Wallet network",
1746
- DEFAULT_WALLET_NETWORK
1747
- ).option("--chain-id <id>", "Chain id", String(DEFAULT_WALLET_CHAIN_ID)),
1748
- { auth: true, json: true }
1749
- ).action(async (_options, command) => {
1750
- await walletNew(getCommandFlags(command));
1751
- });
1752
- withCommandOptions(
1753
- wallet.command("balances").description("List balances for each wallet"),
1754
- { auth: true, json: true }
1755
- ).action(async (_options, command) => {
1756
- await walletBalances(getCommandFlags(command));
1757
- });
1758
- withCommandOptions(
1759
- wallet.command("configs").description("List config for each wallet"),
1760
- { auth: true, json: true }
1761
- ).action(async (_options, command) => {
1762
- await walletConfigs(getCommandFlags(command));
1763
- });
1764
- withCommandOptions(
1765
- wallet.command("audit-logs").description("List wallet audit logs").requiredOption("--wallet-id <id>", "Wallet id or alias").option("--limit <n>", "Result limit").option("--cursor <cursor>", "Pagination cursor").option("--query <query>", "Free text query").option("--action <action>", "Action filter").option("--user <user>", "User filter").option("--browser <browser>", "Browser filter").option("--ip-address <ip>", "IP filter").option("--location <location>", "Location filter"),
1766
- { auth: true, json: true }
1767
- ).action(async (_options, command) => {
1768
- await walletAuditLogs(getCommandFlags(command));
1769
- });
1770
- const webhook = program.command("webhook").description("Manage webhooks");
1771
- withCommandOptions(webhook.command("ls").description("List webhooks"), {
1772
- auth: true,
1773
- json: true
1774
- }).action(async (_options, command) => {
1775
- await webhookList(getCommandFlags(command));
1776
- });
1777
- withCommandOptions(
1778
- webhook.command("get").description("Get webhook").option("--id <webhook-id>", "Webhook id").addOption(new (0, _commander.Option)("--webhook-id <webhook-id>").hideHelp()),
1779
- { auth: true, json: true }
1780
- ).action(async (_options, command) => {
1781
- await webhookGet(getCommandFlags(command));
1782
- });
1783
- withCommandOptions(
1784
- webhook.command("new").description("Create webhook").requiredOption("--project-id <id>", "Project id or alias").requiredOption("--event-type <approval|payment>", "Webhook event type").requiredOption("--url <https://...>", "Webhook destination URL").option("--secret <value>", "Webhook secret"),
1785
- { auth: true, json: true }
1786
- ).action(async (_options, command) => {
1787
- await webhookNew(getCommandFlags(command));
1788
- });
1789
- withCommandOptions(
1790
- webhook.command("update").description("Update webhook").option("--id <webhook-id>", "Webhook id").option("--event-type <approval|payment>", "Webhook event type").option("--status <active|disabled>", "Webhook status").option("--url <https://...>", "Webhook destination URL").option("--secret <value>", "Webhook secret").addOption(new (0, _commander.Option)("--webhook-id <webhook-id>").hideHelp()),
1791
- { auth: true, json: true }
1792
- ).action(async (_options, command) => {
1793
- await webhookUpdate(getCommandFlags(command));
1794
- });
1795
- withCommandOptions(
1796
- webhook.command("rm").description("Delete webhook").option("--id <webhook-id>", "Webhook id").addOption(new (0, _commander.Option)("--webhook-id <webhook-id>").hideHelp()),
1797
- { auth: true, json: true }
1798
- ).action(async (_options, command) => {
1799
- await webhookRemove(getCommandFlags(command));
1800
- });
1801
- withCommandOptions(
1802
- webhook.command("deliveries").description("List webhook deliveries").option("--id <webhook-id>", "Webhook id").option("--limit <n>", "Result limit").addOption(new (0, _commander.Option)("--webhook-id <webhook-id>").hideHelp()),
1803
- { auth: true, json: true }
1804
- ).action(async (_options, command) => {
1805
- await webhookDeliveries(getCommandFlags(command));
1806
- });
1807
- withCommandOptions(
1808
- webhook.command("test").description("Send webhook test payload").option("--id <webhook-id>", "Webhook id").addOption(new (0, _commander.Option)("--webhook-id <webhook-id>").hideHelp()),
1809
- { auth: true, json: true }
1810
- ).action(async (_options, command) => {
1811
- await webhookTest(getCommandFlags(command));
1812
- });
1813
- const approval = program.command("approval").description("Manage pending approvals");
1814
- withCommandOptions(
1815
- approval.command("ls").description("List pending approvals").option("--wallet-id <id>", "Wallet id or alias").option("--limit <n>", "Result limit"),
1816
- { auth: true, json: true }
1817
- ).action(async (_options, command) => {
1818
- await approvalList(getCommandFlags(command));
1819
- });
1820
- withCommandOptions(
1821
- approval.command("approve").description("Submit manual approval").option("--id <approve-id>", "Approval id").option("--mfa-type <type>", "MFA type").option("--otp <code>", "TOTP code").option("--approval-payload-json <json>", "Inline approval payload JSON").option("--approval-payload-file <path>", "Path to approval payload JSON").addOption(new (0, _commander.Option)("--approve-id <approve-id>").hideHelp()),
1822
- { auth: true, json: true }
1823
- ).action(async (_options, command) => {
1824
- await approvalApprove(getCommandFlags(command));
1825
- });
1826
- return program;
1827
- };
1828
- var main = async () => {
1829
- const program = createProgram();
1830
- if (_process2.default.argv.length <= 2) {
1831
- program.outputHelp();
1832
- return;
1833
- }
1834
- await program.parseAsync(_process2.default.argv);
1835
- };
1836
- main().catch((error) => {
1837
- console.error(getErrorMessage(error));
1838
- _process2.default.exit(1);
1839
- });