@nebulr-group/bridge-cli 0.6.6 → 1.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/README.md +93 -460
  2. package/dist/api/accounts.d.ts +69 -0
  3. package/dist/api/accounts.d.ts.map +1 -0
  4. package/dist/api/accounts.js +42 -0
  5. package/dist/api/accounts.js.map +1 -0
  6. package/dist/api/apps.d.ts +50 -0
  7. package/dist/api/apps.d.ts.map +1 -0
  8. package/dist/api/apps.js +62 -0
  9. package/dist/api/apps.js.map +1 -0
  10. package/dist/api/billing.d.ts +131 -0
  11. package/dist/api/billing.d.ts.map +1 -0
  12. package/dist/api/billing.js +42 -0
  13. package/dist/api/billing.js.map +1 -0
  14. package/dist/api/flags.d.ts +73 -0
  15. package/dist/api/flags.d.ts.map +1 -0
  16. package/dist/api/flags.js +108 -0
  17. package/dist/api/flags.js.map +1 -0
  18. package/dist/api/keys.d.ts +48 -0
  19. package/dist/api/keys.d.ts.map +1 -0
  20. package/dist/api/keys.js +87 -0
  21. package/dist/api/keys.js.map +1 -0
  22. package/dist/auth/browser-open.d.ts +21 -4
  23. package/dist/auth/browser-open.d.ts.map +1 -1
  24. package/dist/auth/browser-open.js +45 -65
  25. package/dist/auth/browser-open.js.map +1 -1
  26. package/dist/auth/lock.d.ts +8 -0
  27. package/dist/auth/lock.d.ts.map +1 -0
  28. package/dist/auth/lock.js +43 -0
  29. package/dist/auth/lock.js.map +1 -0
  30. package/dist/auth/loopback.d.ts +8 -12
  31. package/dist/auth/loopback.d.ts.map +1 -1
  32. package/dist/auth/loopback.js +40 -45
  33. package/dist/auth/loopback.js.map +1 -1
  34. package/dist/auth/session.d.ts +61 -0
  35. package/dist/auth/session.d.ts.map +1 -0
  36. package/dist/auth/session.js +142 -0
  37. package/dist/auth/session.js.map +1 -0
  38. package/dist/auth/sign-in.d.ts +67 -0
  39. package/dist/auth/sign-in.d.ts.map +1 -0
  40. package/dist/auth/sign-in.js +113 -0
  41. package/dist/auth/sign-in.js.map +1 -0
  42. package/dist/auth/store.d.ts +89 -0
  43. package/dist/auth/store.d.ts.map +1 -0
  44. package/dist/auth/store.js +214 -0
  45. package/dist/auth/store.js.map +1 -0
  46. package/dist/bin.js +0 -2
  47. package/dist/bin.js.map +1 -1
  48. package/dist/cli.d.ts +1 -2
  49. package/dist/cli.d.ts.map +1 -1
  50. package/dist/cli.js +13 -17
  51. package/dist/cli.js.map +1 -1
  52. package/dist/client.d.ts +31 -0
  53. package/dist/client.d.ts.map +1 -0
  54. package/dist/client.js +67 -0
  55. package/dist/client.js.map +1 -0
  56. package/dist/commands/accounts.command.d.ts +4 -0
  57. package/dist/commands/accounts.command.d.ts.map +1 -0
  58. package/dist/commands/accounts.command.js +116 -0
  59. package/dist/commands/accounts.command.js.map +1 -0
  60. package/dist/commands/app.command.d.ts +3 -2
  61. package/dist/commands/app.command.d.ts.map +1 -1
  62. package/dist/commands/app.command.js +132 -233
  63. package/dist/commands/app.command.js.map +1 -1
  64. package/dist/commands/auth.command.d.ts +2 -12
  65. package/dist/commands/auth.command.d.ts.map +1 -1
  66. package/dist/commands/auth.command.js +147 -20
  67. package/dist/commands/auth.command.js.map +1 -1
  68. package/dist/commands/billing.command.d.ts +4 -0
  69. package/dist/commands/billing.command.d.ts.map +1 -0
  70. package/dist/commands/billing.command.js +185 -0
  71. package/dist/commands/billing.command.js.map +1 -0
  72. package/dist/commands/check.command.d.ts +2 -1
  73. package/dist/commands/check.command.d.ts.map +1 -1
  74. package/dist/commands/check.command.js +11 -14
  75. package/dist/commands/check.command.js.map +1 -1
  76. package/dist/commands/context.d.ts +58 -0
  77. package/dist/commands/context.d.ts.map +1 -0
  78. package/dist/commands/context.js +78 -0
  79. package/dist/commands/context.js.map +1 -0
  80. package/dist/commands/flag.command.d.ts +3 -62
  81. package/dist/commands/flag.command.d.ts.map +1 -1
  82. package/dist/commands/flag.command.js +181 -864
  83. package/dist/commands/flag.command.js.map +1 -1
  84. package/dist/commands/key.command.d.ts +4 -0
  85. package/dist/commands/key.command.d.ts.map +1 -0
  86. package/dist/commands/key.command.js +44 -0
  87. package/dist/commands/key.command.js.map +1 -0
  88. package/dist/commands/plan.command.d.ts +3 -203
  89. package/dist/commands/plan.command.d.ts.map +1 -1
  90. package/dist/commands/plan.command.js +200 -759
  91. package/dist/commands/plan.command.js.map +1 -1
  92. package/dist/config.d.ts +19 -101
  93. package/dist/config.d.ts.map +1 -1
  94. package/dist/config.js +51 -364
  95. package/dist/config.js.map +1 -1
  96. package/dist/core/discovery.d.ts +27 -0
  97. package/dist/core/discovery.d.ts.map +1 -0
  98. package/dist/core/discovery.js +97 -0
  99. package/dist/core/discovery.js.map +1 -0
  100. package/dist/core/errors.d.ts +26 -0
  101. package/dist/core/errors.d.ts.map +1 -0
  102. package/dist/core/errors.js +33 -0
  103. package/dist/core/errors.js.map +1 -0
  104. package/dist/core/http.d.ts +23 -0
  105. package/dist/core/http.d.ts.map +1 -0
  106. package/dist/core/http.js +153 -0
  107. package/dist/core/http.js.map +1 -0
  108. package/dist/core/private-files.d.ts +6 -0
  109. package/dist/core/private-files.d.ts.map +1 -0
  110. package/dist/core/private-files.js +96 -0
  111. package/dist/core/private-files.js.map +1 -0
  112. package/dist/core/routes.d.ts +94 -0
  113. package/dist/core/routes.d.ts.map +1 -0
  114. package/dist/core/routes.js +91 -0
  115. package/dist/core/routes.js.map +1 -0
  116. package/dist/core/urls.d.ts +15 -0
  117. package/dist/core/urls.d.ts.map +1 -0
  118. package/dist/core/urls.js +55 -0
  119. package/dist/core/urls.js.map +1 -0
  120. package/dist/gate-rules.d.ts +1 -2
  121. package/dist/gate-rules.d.ts.map +1 -1
  122. package/dist/gate-rules.js +4 -5
  123. package/dist/gate-rules.js.map +1 -1
  124. package/dist/index.d.ts +23 -3
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +18 -3
  127. package/dist/index.js.map +1 -1
  128. package/dist/io.d.ts +21 -0
  129. package/dist/io.d.ts.map +1 -0
  130. package/dist/io.js +59 -0
  131. package/dist/io.js.map +1 -0
  132. package/dist/money.d.ts +42 -0
  133. package/dist/money.d.ts.map +1 -0
  134. package/dist/money.js +112 -0
  135. package/dist/money.js.map +1 -0
  136. package/dist/program.d.ts +5 -24
  137. package/dist/program.d.ts.map +1 -1
  138. package/dist/program.js +25 -113
  139. package/dist/program.js.map +1 -1
  140. package/package.json +7 -8
  141. package/dist/auth/api-client.d.ts +0 -50
  142. package/dist/auth/api-client.d.ts.map +0 -1
  143. package/dist/auth/api-client.js +0 -109
  144. package/dist/auth/api-client.js.map +0 -1
  145. package/dist/auth/relative-time.d.ts +0 -2
  146. package/dist/auth/relative-time.d.ts.map +0 -1
  147. package/dist/auth/relative-time.js +0 -27
  148. package/dist/auth/relative-time.js.map +0 -1
  149. package/dist/auth/scopes.d.ts +0 -30
  150. package/dist/auth/scopes.d.ts.map +0 -1
  151. package/dist/auth/scopes.js +0 -39
  152. package/dist/auth/scopes.js.map +0 -1
  153. package/dist/auth/workspace-client.d.ts +0 -70
  154. package/dist/auth/workspace-client.d.ts.map +0 -1
  155. package/dist/auth/workspace-client.js +0 -105
  156. package/dist/auth/workspace-client.js.map +0 -1
  157. package/dist/commands/auth/config.command.d.ts +0 -8
  158. package/dist/commands/auth/config.command.d.ts.map +0 -1
  159. package/dist/commands/auth/config.command.js +0 -60
  160. package/dist/commands/auth/config.command.js.map +0 -1
  161. package/dist/commands/auth/login.command.d.ts +0 -46
  162. package/dist/commands/auth/login.command.d.ts.map +0 -1
  163. package/dist/commands/auth/login.command.js +0 -166
  164. package/dist/commands/auth/login.command.js.map +0 -1
  165. package/dist/commands/auth/logout.command.d.ts +0 -21
  166. package/dist/commands/auth/logout.command.d.ts.map +0 -1
  167. package/dist/commands/auth/logout.command.js +0 -97
  168. package/dist/commands/auth/logout.command.js.map +0 -1
  169. package/dist/commands/auth/methods.command.d.ts +0 -68
  170. package/dist/commands/auth/methods.command.d.ts.map +0 -1
  171. package/dist/commands/auth/methods.command.js +0 -91
  172. package/dist/commands/auth/methods.command.js.map +0 -1
  173. package/dist/commands/auth/status.command.d.ts +0 -18
  174. package/dist/commands/auth/status.command.d.ts.map +0 -1
  175. package/dist/commands/auth/status.command.js +0 -104
  176. package/dist/commands/auth/status.command.js.map +0 -1
  177. package/dist/commands/auth/use.command.d.ts +0 -17
  178. package/dist/commands/auth/use.command.d.ts.map +0 -1
  179. package/dist/commands/auth/use.command.js +0 -47
  180. package/dist/commands/auth/use.command.js.map +0 -1
  181. package/dist/commands/branding.command.d.ts +0 -3
  182. package/dist/commands/branding.command.d.ts.map +0 -1
  183. package/dist/commands/branding.command.js +0 -42
  184. package/dist/commands/branding.command.js.map +0 -1
  185. package/dist/commands/event.command.d.ts +0 -3
  186. package/dist/commands/event.command.d.ts.map +0 -1
  187. package/dist/commands/event.command.js +0 -27
  188. package/dist/commands/event.command.js.map +0 -1
  189. package/dist/commands/flag-init.command.d.ts +0 -13
  190. package/dist/commands/flag-init.command.d.ts.map +0 -1
  191. package/dist/commands/flag-init.command.js +0 -463
  192. package/dist/commands/flag-init.command.js.map +0 -1
  193. package/dist/commands/guide.command.d.ts +0 -61
  194. package/dist/commands/guide.command.d.ts.map +0 -1
  195. package/dist/commands/guide.command.js +0 -655
  196. package/dist/commands/guide.command.js.map +0 -1
  197. package/dist/commands/info.command.d.ts +0 -3
  198. package/dist/commands/info.command.d.ts.map +0 -1
  199. package/dist/commands/info.command.js +0 -70
  200. package/dist/commands/info.command.js.map +0 -1
  201. package/dist/commands/integration.command.d.ts +0 -35
  202. package/dist/commands/integration.command.d.ts.map +0 -1
  203. package/dist/commands/integration.command.js +0 -290
  204. package/dist/commands/integration.command.js.map +0 -1
  205. package/dist/commands/journeys.d.ts +0 -43
  206. package/dist/commands/journeys.d.ts.map +0 -1
  207. package/dist/commands/journeys.js +0 -221
  208. package/dist/commands/journeys.js.map +0 -1
  209. package/dist/commands/ops.command.d.ts +0 -17
  210. package/dist/commands/ops.command.d.ts.map +0 -1
  211. package/dist/commands/ops.command.js +0 -129
  212. package/dist/commands/ops.command.js.map +0 -1
  213. package/dist/commands/privilege.command.d.ts +0 -16
  214. package/dist/commands/privilege.command.d.ts.map +0 -1
  215. package/dist/commands/privilege.command.js +0 -86
  216. package/dist/commands/privilege.command.js.map +0 -1
  217. package/dist/commands/role.command.d.ts +0 -3
  218. package/dist/commands/role.command.d.ts.map +0 -1
  219. package/dist/commands/role.command.js +0 -101
  220. package/dist/commands/role.command.js.map +0 -1
  221. package/dist/commands/runtime-dir.d.ts +0 -16
  222. package/dist/commands/runtime-dir.d.ts.map +0 -1
  223. package/dist/commands/runtime-dir.js +0 -18
  224. package/dist/commands/runtime-dir.js.map +0 -1
  225. package/dist/commands/setup.command.d.ts +0 -63
  226. package/dist/commands/setup.command.d.ts.map +0 -1
  227. package/dist/commands/setup.command.js +0 -148
  228. package/dist/commands/setup.command.js.map +0 -1
  229. package/dist/commands/stripe.command.d.ts +0 -29
  230. package/dist/commands/stripe.command.d.ts.map +0 -1
  231. package/dist/commands/stripe.command.js +0 -99
  232. package/dist/commands/stripe.command.js.map +0 -1
  233. package/dist/commands/tenant.command.d.ts +0 -3
  234. package/dist/commands/tenant.command.d.ts.map +0 -1
  235. package/dist/commands/tenant.command.js +0 -135
  236. package/dist/commands/tenant.command.js.map +0 -1
  237. package/dist/commands/token.command.d.ts +0 -3
  238. package/dist/commands/token.command.d.ts.map +0 -1
  239. package/dist/commands/token.command.js +0 -54
  240. package/dist/commands/token.command.js.map +0 -1
  241. package/dist/commands/user.command.d.ts +0 -3
  242. package/dist/commands/user.command.d.ts.map +0 -1
  243. package/dist/commands/user.command.js +0 -117
  244. package/dist/commands/user.command.js.map +0 -1
  245. package/dist/credentials.d.ts +0 -141
  246. package/dist/credentials.d.ts.map +0 -1
  247. package/dist/credentials.js +0 -348
  248. package/dist/credentials.js.map +0 -1
  249. package/dist/flag-coherence.d.ts +0 -42
  250. package/dist/flag-coherence.d.ts.map +0 -1
  251. package/dist/flag-coherence.js +0 -103
  252. package/dist/flag-coherence.js.map +0 -1
  253. package/dist/output.d.ts +0 -17
  254. package/dist/output.d.ts.map +0 -1
  255. package/dist/output.js +0 -107
  256. package/dist/output.js.map +0 -1
  257. package/dist/preview.d.ts +0 -9
  258. package/dist/preview.d.ts.map +0 -1
  259. package/dist/preview.js +0 -63
  260. package/dist/preview.js.map +0 -1
  261. package/dist/product-decisions.d.ts +0 -40
  262. package/dist/product-decisions.d.ts.map +0 -1
  263. package/dist/product-decisions.js +0 -52
  264. package/dist/product-decisions.js.map +0 -1
  265. package/dist/prompt-urls.d.ts +0 -31
  266. package/dist/prompt-urls.d.ts.map +0 -1
  267. package/dist/prompt-urls.js +0 -35
  268. package/dist/prompt-urls.js.map +0 -1
  269. package/dist/prompts/auth-master-integration-prompt.md +0 -255
  270. package/dist/prompts/billing/master.md +0 -332
  271. package/dist/prompts/decisions/feature-control.md +0 -131
  272. package/dist/prompts/decisions/going-live.md +0 -60
  273. package/dist/prompts/decisions/login.md +0 -71
  274. package/dist/prompts/decisions/look-and-feel.md +0 -68
  275. package/dist/prompts/decisions/payments.md +0 -97
  276. package/dist/prompts/decisions/roles.md +0 -78
  277. package/dist/prompts/decisions/teams.md +0 -61
  278. package/dist/prompts/fit-together.md +0 -97
  279. package/dist/prompts/flags/master.md +0 -220
  280. package/dist/prompts/guide-coverage.json +0 -17
  281. package/dist/prompts/integration-success.md +0 -106
  282. package/dist/prompts/mcp-tools.json +0 -90
  283. package/dist/prompts/mechanisms.md +0 -304
  284. package/dist/prompts/orientation.md +0 -42
  285. package/dist/prompts/product-decisions.json +0 -338
  286. package/dist/resolve.d.ts +0 -110
  287. package/dist/resolve.d.ts.map +0 -1
  288. package/dist/resolve.js +0 -260
  289. package/dist/resolve.js.map +0 -1
  290. package/dist/shape.d.ts +0 -25
  291. package/dist/shape.d.ts.map +0 -1
  292. package/dist/shape.js +0 -74
  293. package/dist/shape.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-dir.d.ts","sourceRoot":"","sources":["../../src/commands/runtime-dir.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,EAAE,MAAgD,CAAC"}
@@ -1,18 +0,0 @@
1
- import { dirname } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- /**
4
- * Absolute path to this module's own directory — `dist/commands` in the built
5
- * (ESM) CLI. Bundled prompts ship at `dist/prompts`, i.e. `../prompts` from
6
- * here.
7
- *
8
- * The `import.meta` token is deliberately confined to this single file. The
9
- * production build is ESM (`"type": "module"`), so `import.meta.url` resolves
10
- * correctly at runtime. Under ts-jest, however, sources are loaded as
11
- * CommonJS, where `import.meta` is an *uncatchable parse-time* SyntaxError
12
- * ("Cannot use 'import.meta' outside a module") that crashes the whole module
13
- * on import. To keep the rest of the command code importable by the jest
14
- * suite, jest maps this module to a CJS-safe stub (`runtime-dir.stub.ts`) via
15
- * `moduleNameMapper` — see jest.config.cjs.
16
- */
17
- export const commandsDir = dirname(fileURLToPath(import.meta.url));
18
- //# sourceMappingURL=runtime-dir.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"runtime-dir.js","sourceRoot":"","sources":["../../src/commands/runtime-dir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,WAAW,GAAW,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC"}
@@ -1,63 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const SSO_PROVIDERS: {
3
- readonly google: {
4
- readonly clientId: "googleClientId";
5
- readonly clientSecret: "googleClientSecret";
6
- readonly enable: "googleSsoEnabled";
7
- };
8
- readonly github: {
9
- readonly clientId: "githubClientId";
10
- readonly clientSecret: "githubClientSecret";
11
- readonly enable: "githubSsoEnabled";
12
- };
13
- readonly linkedin: {
14
- readonly clientId: "linkedinClientId";
15
- readonly clientSecret: "linkedinClientSecret";
16
- readonly enable: "linkedinSsoEnabled";
17
- };
18
- readonly facebook: {
19
- readonly clientId: "facebookClientId";
20
- readonly clientSecret: "facebookClientSecret";
21
- readonly enable: "facebookSsoEnabled";
22
- };
23
- readonly azure: {
24
- readonly clientId: "microsoftAzureADClientId";
25
- readonly clientSecret: "microsoftAzureADClientSecret";
26
- readonly tenantId: "microsoftAzureADTenantId";
27
- readonly enable: "azureAdSsoEnabled";
28
- };
29
- };
30
- export type SupportedSsoProvider = keyof typeof SSO_PROVIDERS;
31
- /** Carries a machine-readable `code`, which `outputError` reports. */
32
- export declare class SetupError extends Error {
33
- readonly code: string;
34
- constructor(message: string, code: string);
35
- }
36
- export interface SetupSsoOptions {
37
- provider: string;
38
- clientId?: string;
39
- clientSecret?: string;
40
- tenantId?: string;
41
- metadataUrl?: string;
42
- discoveryUrl?: string;
43
- }
44
- export declare function setupSso(opts: SetupSsoOptions): Promise<{
45
- provider: "google" | "linkedin" | "github" | "facebook" | "azure";
46
- enabled: boolean;
47
- callbackUrl: string;
48
- app: import("@nebulr-group/bridge-auth-core").AppResponse;
49
- }>;
50
- export interface SetupCommunicationOptions {
51
- fromAddress?: string;
52
- fromName?: string;
53
- provider?: string;
54
- apiKey?: string;
55
- }
56
- export declare function setupCommunication(opts: SetupCommunicationOptions): Promise<{
57
- configured: boolean;
58
- emailSenderEmail: string | null;
59
- emailSenderName: string | null;
60
- app: import("@nebulr-group/bridge-auth-core").AppResponse;
61
- }>;
62
- export declare function registerSetupCommands(program: Command): void;
63
- //# sourceMappingURL=setup.command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.command.d.ts","sourceRoot":"","sources":["../../src/commands/setup.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAiC5C,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;CAW6B,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG,MAAM,OAAO,aAAa,CAAC;AAS9D,sEAAsE;AACtE,qBAAa,UAAW,SAAQ,KAAK;IACN,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAtC,OAAO,EAAE,MAAM,EAAW,IAAI,EAAE,MAAM;CAInD;AASD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,QAAQ,CAAC,IAAI,EAAE,eAAe;;;;;GA4CnD;AAED,MAAM,WAAW,yBAAyB;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,yBAAyB;;;;;GA+BvE;AAKD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyC5D"}
@@ -1,148 +0,0 @@
1
- import { Option } from 'commander';
2
- import { getManagementClient } from '../config.js';
3
- import { outputSuccess, outputError } from '../output.js';
4
- export const SSO_PROVIDERS = {
5
- google: { clientId: 'googleClientId', clientSecret: 'googleClientSecret', enable: 'googleSsoEnabled' },
6
- github: { clientId: 'githubClientId', clientSecret: 'githubClientSecret', enable: 'githubSsoEnabled' },
7
- linkedin: { clientId: 'linkedinClientId', clientSecret: 'linkedinClientSecret', enable: 'linkedinSsoEnabled' },
8
- facebook: { clientId: 'facebookClientId', clientSecret: 'facebookClientSecret', enable: 'facebookSsoEnabled' },
9
- azure: {
10
- clientId: 'microsoftAzureADClientId',
11
- clientSecret: 'microsoftAzureADClientSecret',
12
- tenantId: 'microsoftAzureADTenantId',
13
- enable: 'azureAdSsoEnabled',
14
- },
15
- };
16
- const SUPPORTED = Object.keys(SSO_PROVIDERS).join(', ');
17
- const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
18
- /** Carries a machine-readable `code`, which `outputError` reports. */
19
- export class SetupError extends Error {
20
- code;
21
- constructor(message, code) {
22
- super(message);
23
- this.code = code;
24
- this.name = 'SetupError';
25
- }
26
- }
27
- const NOT_SAVED = ' Nothing was saved.';
28
- const invalid = (message) => new SetupError(message + NOT_SAVED, 'INVALID_ARGUMENT');
29
- function isSupported(provider) {
30
- return Object.prototype.hasOwnProperty.call(SSO_PROVIDERS, provider);
31
- }
32
- export async function setupSso(opts) {
33
- const provider = String(opts.provider).toLowerCase();
34
- if (!isSupported(provider)) {
35
- throw new SetupError(provider === 'saml' || provider === 'oidc'
36
- ? `SSO provider "${provider}" is not supported by the Bridge API: it has no fields for SAML or OIDC ` +
37
- `connections. Set them up in the Bridge admin UI. Supported here: ${SUPPORTED}.${NOT_SAVED}`
38
- : `Unknown SSO provider "${provider}". Supported: ${SUPPORTED}.${NOT_SAVED}`, 'SSO_PROVIDER_NOT_SUPPORTED');
39
- }
40
- for (const [flag, value] of [['--metadata-url', opts.metadataUrl], ['--discovery-url', opts.discoveryUrl]]) {
41
- if (value !== undefined) {
42
- throw new SetupError(`${flag} was removed: the Bridge API has no field for it (SAML and OIDC are set up in the Bridge admin UI).${NOT_SAVED}`, 'SSO_PROVIDER_NOT_SUPPORTED');
43
- }
44
- }
45
- if (!opts.clientId || !opts.clientSecret) {
46
- throw invalid('--client-id and --client-secret are required (from the provider console).');
47
- }
48
- const fields = SSO_PROVIDERS[provider];
49
- const credentials = {
50
- [fields.clientId]: opts.clientId,
51
- [fields.clientSecret]: opts.clientSecret,
52
- };
53
- if ('tenantId' in fields) {
54
- if (!opts.tenantId) {
55
- throw invalid('azure needs --tenant-id: the Directory (tenant) ID from the Entra ID app registration.');
56
- }
57
- credentials[fields.tenantId] = opts.tenantId;
58
- }
59
- else if (opts.tenantId !== undefined) {
60
- throw invalid(`--tenant-id applies to azure only, not "${provider}".`);
61
- }
62
- const mgmt = getManagementClient();
63
- await mgmt.app.updateCredentials(credentials);
64
- const enable = { [fields.enable]: true };
65
- await mgmt.app.update(enable);
66
- const app = await mgmt.app.get();
67
- return { provider, enabled: true, callbackUrl: app.defaultCallbackUri, app };
68
- }
69
- export async function setupCommunication(opts) {
70
- if (opts.provider !== undefined || opts.apiKey !== undefined) {
71
- throw new SetupError('--provider and --api-key were removed: Bridge sends all email through its own provider, so there is ' +
72
- 'no provider or API key to configure (the Bridge API has never accepted one). ' +
73
- `Pass only --from-address and/or --from-name.${NOT_SAVED}`, 'EMAIL_PROVIDER_NOT_SUPPORTED');
74
- }
75
- const { fromAddress, fromName } = opts;
76
- if (fromAddress === undefined && fromName === undefined) {
77
- throw invalid('Nothing to set: pass --from-address, --from-name, or both.');
78
- }
79
- if (fromAddress !== undefined && !EMAIL.test(fromAddress)) {
80
- throw invalid('--from-address must be an email address, e.g. "no-reply@example.com".');
81
- }
82
- if (fromName !== undefined && fromName.trim() === '') {
83
- throw invalid('--from-name must not be empty.');
84
- }
85
- const update = {};
86
- if (fromAddress !== undefined)
87
- update.emailSenderEmail = fromAddress;
88
- if (fromName !== undefined)
89
- update.emailSenderName = fromName;
90
- const app = await getManagementClient().app.update(update);
91
- return {
92
- configured: true,
93
- emailSenderEmail: app.emailSenderEmail ?? null,
94
- emailSenderName: app.emailSenderName ?? null,
95
- app,
96
- };
97
- }
98
- /** Accepted only to refuse it with an explanation instead of commander's bare "unknown option". */
99
- const removed = (flags, description) => new Option(flags, description).hideHelp();
100
- export function registerSetupCommands(program) {
101
- const setup = program.command('setup').description('Run setup workflows (multi-step operations)');
102
- setup.command('sso')
103
- .description('Enable an SSO login provider and get the callback URL to register with it')
104
- .requiredOption('--provider <provider>', `SSO provider: ${SUPPORTED} (SAML/OIDC are set up in the Bridge admin UI)`)
105
- .requiredOption('--client-id <id>', 'OAuth client ID from the provider console')
106
- .requiredOption('--client-secret <secret>', 'OAuth client secret from the provider console')
107
- .option('--tenant-id <id>', 'azure only, required: Entra ID Directory (tenant) ID (not a Bridge tenant)')
108
- .addOption(removed('--metadata-url <url>', 'removed: SAML is not supported by the Bridge API'))
109
- .addOption(removed('--discovery-url <url>', 'removed: OIDC is not supported by the Bridge API'))
110
- .action(async (opts) => {
111
- try {
112
- outputSuccess(await setupSso(opts));
113
- }
114
- catch (err) {
115
- outputError(err);
116
- }
117
- });
118
- setup.command('payments')
119
- .description('Connect Stripe and optionally create plans')
120
- .requiredOption('--stripe-key <key>', 'Stripe secret key')
121
- .option('--stripe-public-key <key>', 'Stripe public key')
122
- .action(async (opts) => {
123
- try {
124
- outputSuccess(await getManagementClient().workflows.setupPayments({
125
- stripeSecretKey: opts.stripeKey,
126
- stripePublicKey: opts.stripePublicKey,
127
- }));
128
- }
129
- catch (err) {
130
- outputError(err);
131
- }
132
- });
133
- setup.command('communication')
134
- .description("Set the sender name and address of your app's emails (sent through Bridge's own email provider)")
135
- .option('--from-address <email>', 'Sender email address. A new address is verified by email before Bridge uses it')
136
- .option('--from-name <name>', 'Sender display name')
137
- .addOption(removed('--provider <provider>', 'removed: email goes through Bridge\'s own provider'))
138
- .addOption(removed('--api-key <key>', 'removed: email goes through Bridge\'s own provider'))
139
- .action(async (opts) => {
140
- try {
141
- outputSuccess(await setupCommunication(opts));
142
- }
143
- catch (err) {
144
- outputError(err);
145
- }
146
- });
147
- }
148
- //# sourceMappingURL=setup.command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.command.js","sourceRoot":"","sources":["../../src/commands/setup.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,O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AS,CAAC,OAAO,CAAC,iBAAiB,EAAE,oDAAoD,CAAC,CAAC;SAC3F,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI,CAAC;YACH,aAAa,CAAC,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;QAChD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,29 +0,0 @@
1
- import { Command } from 'commander';
2
- import type { CredentialsState } from '@nebulr-group/bridge-auth-core';
3
- export type ServerCredentialsState = CredentialsState;
4
- /** Webhook health fields on the app response (TBP-658). All optional: older APIs omit them. */
5
- export interface ServerAppStripeState {
6
- stripeSetupStatus?: 'pending' | 'completed' | 'failed' | null;
7
- stripeSetupError?: string | null;
8
- stripeLastWebhookAt?: string | null;
9
- stripeLastWebhookRejectedAt?: string | null;
10
- stripeLastWebhookRejectionReason?: string | null;
11
- }
12
- /** `true` only when the server confirms stored Stripe keys; never undefined. */
13
- export declare function stripeConnectedFrom(state: unknown): boolean;
14
- /** `null` when the API does not report it (older account API), so absence is not read as broken. */
15
- export declare function stripeWebhookConfiguredFrom(state: unknown): boolean | null;
16
- export interface StripeStatus {
17
- connected: boolean;
18
- webhookConfigured: boolean | null;
19
- webhookHealthy: boolean | null;
20
- lastWebhookAt: string | null;
21
- lastWebhookRejectedAt: string | null;
22
- lastWebhookRejectionReason: string | null;
23
- setupStatus: string | null;
24
- setupError: string | null;
25
- message: string;
26
- }
27
- export declare function stripeStatusFrom(state: unknown, app: unknown): StripeStatus;
28
- export declare function registerStripeCommands(program: Command): void;
29
- //# sourceMappingURL=stripe.command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stripe.command.d.ts","sourceRoot":"","sources":["../../src/commands/stripe.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;A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.js';
3
- /** `true` only when the server confirms stored Stripe keys; never undefined. */
4
- export function stripeConnectedFrom(state) {
5
- return state?.stripeCredentialsAdded === true;
6
- }
7
- /** `null` when the API does not report it (older account API), so absence is not read as broken. */
8
- export function stripeWebhookConfiguredFrom(state) {
9
- const value = state?.stripeWebhookConfigured;
10
- return typeof value === 'boolean' ? value : null;
11
- }
12
- const CONNECT_HINT = 'run: bridge stripe connect --secret-key sk_... --publishable-key pk_...';
13
- const REPAIR_HINT = 'Checkout still works, but subscription changes, cancellations and payment failures are not ' +
14
- 'reaching Bridge. Repair: re-run `bridge setup payments` with the same keys, or use "Repair ' +
15
- 'webhook" in the Bridge admin payment settings.';
16
- /*
17
- * Mirrors bridge-api's `AppService._stripeWebhookUnhealthy` plus the two
18
- * explicit failure signals. `null` = the API gave us nothing to judge by.
19
- */
20
- function webhookHealthy(configured, app) {
21
- if (configured === false || app.stripeSetupStatus === 'failed')
22
- return false;
23
- const rejectedAt = app.stripeLastWebhookRejectedAt;
24
- if (rejectedAt) {
25
- const lastAt = app.stripeLastWebhookAt;
26
- if (!lastAt || new Date(rejectedAt).getTime() > new Date(lastAt).getTime())
27
- return false;
28
- }
29
- return configured;
30
- }
31
- export function stripeStatusFrom(state, app) {
32
- const a = (app ?? {});
33
- const connected = stripeConnectedFrom(state);
34
- const webhookConfigured = stripeWebhookConfiguredFrom(state);
35
- const healthy = connected ? webhookHealthy(webhookConfigured, a) : null;
36
- let message;
37
- if (!connected)
38
- message = `Stripe is not connected — ${CONNECT_HINT}`;
39
- else if (healthy === false)
40
- message = `Stripe is connected, but its webhook is not working. ${REPAIR_HINT}`;
41
- else if (healthy === null)
42
- message = 'Stripe is connected (webhook health not reported by this API)';
43
- else
44
- message = 'Stripe is connected and its webhook is configured';
45
- return {
46
- connected,
47
- webhookConfigured,
48
- webhookHealthy: healthy,
49
- lastWebhookAt: a.stripeLastWebhookAt ?? null,
50
- lastWebhookRejectedAt: a.stripeLastWebhookRejectedAt ?? null,
51
- lastWebhookRejectionReason: a.stripeLastWebhookRejectionReason ?? null,
52
- setupStatus: a.stripeSetupStatus ?? null,
53
- setupError: a.stripeSetupError ?? null,
54
- message,
55
- };
56
- }
57
- export function registerStripeCommands(program) {
58
- const stripe = program.command('stripe').description('Manage Stripe integration');
59
- stripe.command('status')
60
- .description('Show whether Stripe credentials are configured and whether its webhook works')
61
- .action(async () => {
62
- try {
63
- const client = getManagementClient();
64
- const [state, app] = await Promise.all([
65
- client.app.getCredentialsState(),
66
- client.app.get(),
67
- ]);
68
- outputSuccess(stripeStatusFrom(state, app));
69
- }
70
- catch (err) {
71
- outputError(err);
72
- }
73
- });
74
- stripe.command('connect')
75
- .description('Set Stripe API credentials')
76
- .requiredOption('--secret-key <key>', 'Stripe secret key (sk_live_... or sk_test_...)')
77
- .requiredOption('--publishable-key <key>', 'Stripe publishable key (pk_live_... or pk_test_...)')
78
- .action(async (opts) => {
79
- try {
80
- const state = await getManagementClient().app.updateCredentials({
81
- stripeSecretKey: opts.secretKey,
82
- stripePublicKey: opts.publishableKey,
83
- });
84
- const connected = stripeConnectedFrom(state);
85
- const webhookConfigured = stripeWebhookConfiguredFrom(state);
86
- let message = connected
87
- ? 'Stripe connected successfully'
88
- : 'Credentials saved but Stripe did not confirm — check your keys and try again';
89
- if (connected && webhookConfigured === false) {
90
- message += '. Warning: the Stripe webhook is not configured — run `bridge stripe status` for details';
91
- }
92
- outputSuccess({ connected, webhookConfigured, message });
93
- }
94
- catch (err) {
95
- outputError(err);
96
- }
97
- });
98
- }
99
- //# sourceMappingURL=stripe.command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stripe.command.js","sourceRoot":"","sources":["../../src/commands/stripe.command.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAsB1D,gFAAgF;AAChF,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD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,CAAC,CAAC;QAAC,CAAC;IACrC,CAAC,CAAC,CAAC;IAEL,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;SACtB,WAAW,CAAC,4BAA4B,CAAC;SACzC,cAAc,CAAC,oBAAoB,EAAE,gDAAgD,CAAC;SACtF,cAAc,CAAC,yBAAyB,EAAE,qDAAqD,CAAC;SAChG,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QACrB,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,mBAAmB,EAAE,CAAC,GAAG,CAAC,iBAAiB,CAAC;gBAC9D,eAAe,EAAE,IAAI,CAAC,SAAS;gBAC/B,eAAe,EAAE,IAAI,CAAC,cAAc;aACrC,CAAC,CAAC;YACH,MAAM,SAAS,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAC7C,MAAM,iBAAiB,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;YAC7D,IAAI,OAAO,GAAG,SAAS;gBACrB,CAAC,CAAC,+BAA+B;gBACjC,CAAC,CAAC,8EAA8E,CAAC;YACnF,IAAI,SAAS,IAAI,iBAAiB,KAAK,KAAK,EAAE,CAAC;gBAC7C,OAAO,IAAI,0FAA0F,CAAC;YACxG,CAAC;YACD,aAAa,CAAC,EAAE,SAAS,EAAE,iBAAiB,EAAE,OAAO,EAAE,CAAC,CAAC;QAC3D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function registerTenantCommands(program: Command): void;
3
- //# sourceMappingURL=tenant.command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tenant.command.d.ts","sourceRoot":"","sources":["../../src/commands/tenant.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA0H7D"}
@@ -1,135 +0,0 @@
1
- import { getManagementClient, getManagementHttp } from '../config.js';
2
- import { outputSuccess, outputError } from '../output.js';
3
- import { resolveTenantIdByName } from '../resolve.js';
4
- import { shapeTenant } from '../shape.js';
5
- import { dryRunPreview } from '../preview.js';
6
- export function registerTenantCommands(program) {
7
- const tenant = program.command('tenant').description('Manage tenants');
8
- tenant.command('list')
9
- .description('List all tenants')
10
- .action(async () => {
11
- try {
12
- outputSuccess((await getManagementClient().tenants.list()).map(shapeTenant));
13
- }
14
- catch (err) {
15
- outputError(err);
16
- }
17
- });
18
- tenant.command('get')
19
- .description('Get a tenant by --name or --id')
20
- .option('--name <name>', 'Tenant name to address (alternative to --id; must be unique)')
21
- .option('--id <id>', 'Tenant ID to address (alternative to --name)')
22
- .action(async (opts) => {
23
- try {
24
- const id = await resolveTenantIdByName({ id: opts.id, key: opts.name });
25
- outputSuccess(shapeTenant(await getManagementClient().tenants.get(id)));
26
- }
27
- catch (err) {
28
- outputError(err);
29
- }
30
- });
31
- tenant.command('create')
32
- .description('Create a new tenant')
33
- .requiredOption('--owner-email <email>', 'Owner email address')
34
- .option('--name <name>', 'Tenant name')
35
- .option('--plan <plan>', 'Plan key')
36
- .option('--locale <locale>', 'Locale (ISO 639-1)')
37
- .action(async (opts) => {
38
- try {
39
- outputSuccess(shapeTenant(await getManagementClient().tenants.create({
40
- owner: { email: opts.ownerEmail },
41
- name: opts.name,
42
- plan: opts.plan,
43
- locale: opts.locale,
44
- })));
45
- }
46
- catch (err) {
47
- outputError(err);
48
- }
49
- });
50
- tenant.command('update')
51
- .description('Update a tenant by --name or --id')
52
- .option('--name <name>', 'Tenant name to address when --id is absent; with --id, renames the tenant')
53
- .option('--id <id>', 'Tenant ID to address (alternative to --name)')
54
- .option('--new-name <name>', 'Rename the tenant to this name')
55
- .option('--locale <locale>', 'Locale')
56
- .option('--logo <url>', 'Logo URL')
57
- .action(async (opts) => {
58
- try {
59
- // TBP-586. `--name` is overloaded for backwards compatibility: before
60
- // name-addressing existed, `tenant update --id X --name Y` renamed the
61
- // tenant, and that still works. So `--name` addresses only when `--id`
62
- // is absent; alongside `--id` it keeps its old rename meaning.
63
- // `--new-name` renames in either addressing mode.
64
- const addressedById = opts.id !== undefined;
65
- const renameTo = opts.newName !== undefined
66
- ? opts.newName
67
- : (addressedById ? opts.name : undefined);
68
- const id = await resolveTenantIdByName({
69
- id: opts.id,
70
- key: addressedById ? undefined : opts.name,
71
- });
72
- const data = { name: renameTo, locale: opts.locale, logo: opts.logo };
73
- const cleaned = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
74
- outputSuccess(shapeTenant(await getManagementClient().tenants.update(id, cleaned)));
75
- }
76
- catch (err) {
77
- outputError(err);
78
- }
79
- });
80
- // TBP-806 — the dashboard's plan picker on a workspace, from the terminal:
81
- // the same route, which also moves a paid Stripe subscription. What clears a
82
- // plan before `plan delete`.
83
- tenant.command('set-plan')
84
- .description('Move a tenant to another plan by --name or --id (a paid Stripe subscription moves with it)')
85
- .option('--name <name>', 'Tenant name to address (alternative to --id; fails if not unique)')
86
- .option('--id <id>', 'Tenant ID to address (alternative to --name)')
87
- .requiredOption('--plan <key>', 'Plan key to move the tenant to')
88
- .option('--interval <interval>', "Which of the plan's prices: day | week | month | year (default: its first price)")
89
- .option('--currency <code>', "Which of the plan's prices: its currency, e.g. usd")
90
- .action(async (opts) => {
91
- try {
92
- const id = await resolveTenantIdByName({ id: opts.id, key: opts.name });
93
- const plans = (await getManagementClient().plans.list());
94
- const plan = plans.find((p) => p.key === opts.plan);
95
- if (!plan) {
96
- throw new Error(`Plan not found: ${opts.plan}. Existing plan keys: ${plans.map((p) => p.key).join(', ') || '(none)'}.`);
97
- }
98
- const currency = opts.currency?.toUpperCase();
99
- const prices = plan.prices ?? [];
100
- const price = prices.find((p) => (!currency || p.currency.toUpperCase() === currency) && (!opts.interval || p.recurrenceInterval === opts.interval));
101
- if (!price) {
102
- throw new Error(`Plan ${opts.plan} has no matching price. Its prices: ` +
103
- (prices.map((p) => `${p.currency} ${p.recurrenceInterval} ${p.amount}`).join(', ') || '(none)') + '.');
104
- }
105
- await getManagementHttp().post(`/v1/account/tenant/${encodeURIComponent(id)}/planDetails`, {
106
- planKey: opts.plan,
107
- priceOffer: { currency: price.currency, recurrenceInterval: price.recurrenceInterval },
108
- });
109
- outputSuccess({ id, plan: opts.plan, price: { currency: price.currency, recurrenceInterval: price.recurrenceInterval, amount: price.amount } });
110
- }
111
- catch (err) {
112
- outputError(err);
113
- }
114
- });
115
- tenant.command('delete')
116
- .description('Delete a tenant by --name or --id')
117
- .option('--name <name>', 'Tenant name to address (alternative to --id; fails if not unique)')
118
- .option('--id <id>', 'Tenant ID to address (alternative to --name)')
119
- .option('--dry-run', 'Show the members, login accounts and side effects the delete would have, and delete nothing')
120
- .action(async (opts) => {
121
- try {
122
- const id = await resolveTenantIdByName({ id: opts.id, key: opts.name });
123
- if (opts.dryRun) {
124
- outputSuccess(await dryRunPreview(`/v1/account/tenant/${encodeURIComponent(id)}`));
125
- return;
126
- }
127
- await getManagementClient().tenants.delete(id);
128
- outputSuccess({ deleted: true, id });
129
- }
130
- catch (err) {
131
- outputError(err);
132
- }
133
- });
134
- }
135
- //# sourceMappingURL=tenant.command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tenant.command.js","sourceRoot":"","sources":["../../src/commands/tenant.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MA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AAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAC/C,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function registerTokenCommands(program: Command): void;
3
- //# sourceMappingURL=token.command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"token.command.d.ts","sourceRoot":"","sources":["../../src/commands/token.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyC5D"}
@@ -1,54 +0,0 @@
1
- import { getManagementClient } from '../config.js';
2
- import { outputSuccess, outputError } from '../output.js';
3
- import { resolveTokenIdByName } from '../resolve.js';
4
- import { dryRunPreview } from '../preview.js';
5
- export function registerTokenCommands(program) {
6
- const token = program.command('token').description('Manage API tokens');
7
- token.command('list')
8
- .description('List all API tokens')
9
- .action(async () => {
10
- try {
11
- outputSuccess(await getManagementClient().tokens.list());
12
- }
13
- catch (err) {
14
- outputError(err);
15
- }
16
- });
17
- token.command('create')
18
- .description('Create a new API token')
19
- .requiredOption('--name <name>', 'Token name')
20
- .option('--privileges <list>', 'Comma-separated privilege keys', (v) => v.split(','))
21
- .option('--expire-at <date>', 'Expiration date (ISO format)')
22
- .action(async (opts) => {
23
- try {
24
- outputSuccess(await getManagementClient().tokens.create({
25
- name: opts.name,
26
- privileges: opts.privileges ?? [],
27
- expireAt: opts.expireAt,
28
- }));
29
- }
30
- catch (err) {
31
- outputError(err);
32
- }
33
- });
34
- token.command('revoke')
35
- .description('Revoke an API token by --name or --id')
36
- .option('--name <name>', 'Token name to address (alternative to --id; fails if not unique)')
37
- .option('--id <id>', 'Token ID to address (alternative to --name)')
38
- .option('--dry-run', 'Show the token\'s privileges and last use, and whether it is your own login, and revoke nothing')
39
- .action(async (opts) => {
40
- try {
41
- const id = await resolveTokenIdByName({ id: opts.id, key: opts.name });
42
- if (opts.dryRun) {
43
- outputSuccess(await dryRunPreview(`/v1/account/api-token/app/${encodeURIComponent(id)}`));
44
- return;
45
- }
46
- await getManagementClient().tokens.revoke(id);
47
- outputSuccess({ revoked: true, id });
48
- }
49
- catch (err) {
50
- outputError(err);
51
- }
52
- });
53
- }
54
- //# sourceMappingURL=token.command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"token.command.js","sourceRoot":"","sources":["../../src/commands/token.command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAExE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;SAClB,WAAW,CAAC,qBAAqB,CAAC;SAClC,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YAAC,aAAa,CAAC,MAAM,mBAAmB,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAAC,CAAC;QACjE,OAAO,GAAG,EAAE,CAAC;YAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEL,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;SACpB,WAAW,CAAC,wBAAwB,CAAC;SACrC,cAAc,CAAC,eAAe,EAA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,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare function registerUserCommands(program: Command): void;
3
- //# sourceMappingURL=user.command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.command.d.ts","sourceRoot":"","sources":["../../src/commands/user.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6BpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsF3D"}