@bussolabs/closeyourit-cli 0.0.22 → 0.0.27

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 (66) hide show
  1. package/README.md +22 -0
  2. package/dist/base.d.ts +14 -2
  3. package/dist/base.js +33 -11
  4. package/dist/commands/environments/create.d.ts +3 -0
  5. package/dist/commands/environments/create.js +11 -0
  6. package/dist/commands/environments/update.d.ts +3 -0
  7. package/dist/commands/environments/update.js +11 -0
  8. package/dist/commands/projects/set-environment-capabilities.d.ts +13 -0
  9. package/dist/commands/projects/set-environment-capabilities.js +39 -0
  10. package/dist/commands/run.d.ts +12 -0
  11. package/dist/commands/run.js +33 -0
  12. package/dist/commands/secrets/assets/archive.d.ts +11 -0
  13. package/dist/commands/secrets/assets/archive.js +17 -0
  14. package/dist/commands/secrets/assets/delegate.d.ts +10 -0
  15. package/dist/commands/secrets/assets/delegate.js +17 -0
  16. package/dist/commands/secrets/assets/download.d.ts +14 -0
  17. package/dist/commands/secrets/assets/download.js +25 -0
  18. package/dist/commands/secrets/assets/list.d.ts +10 -0
  19. package/dist/commands/secrets/assets/list.js +18 -0
  20. package/dist/commands/secrets/assets/purge.d.ts +12 -0
  21. package/dist/commands/secrets/assets/purge.js +22 -0
  22. package/dist/commands/secrets/assets/rollback.d.ts +11 -0
  23. package/dist/commands/secrets/assets/rollback.js +17 -0
  24. package/dist/commands/secrets/assets/shared-list.d.ts +5 -0
  25. package/dist/commands/secrets/assets/shared-list.js +15 -0
  26. package/dist/commands/secrets/assets/shared-upload.d.ts +11 -0
  27. package/dist/commands/secrets/assets/shared-upload.js +24 -0
  28. package/dist/commands/secrets/assets/undelegate.d.ts +10 -0
  29. package/dist/commands/secrets/assets/undelegate.js +17 -0
  30. package/dist/commands/secrets/assets/upload.d.ts +12 -0
  31. package/dist/commands/secrets/assets/upload.js +25 -0
  32. package/dist/commands/secrets/assets/versions.d.ts +10 -0
  33. package/dist/commands/secrets/assets/versions.js +18 -0
  34. package/dist/commands/secrets/delete.d.ts +13 -0
  35. package/dist/commands/secrets/delete.js +26 -0
  36. package/dist/commands/secrets/download.d.ts +12 -0
  37. package/dist/commands/secrets/download.js +41 -0
  38. package/dist/commands/secrets/get.d.ts +13 -0
  39. package/dist/commands/secrets/get.js +30 -0
  40. package/dist/commands/secrets/import.d.ts +22 -0
  41. package/dist/commands/secrets/import.js +71 -0
  42. package/dist/commands/secrets/list.d.ts +10 -0
  43. package/dist/commands/secrets/list.js +32 -0
  44. package/dist/commands/secrets/set.d.ts +15 -0
  45. package/dist/commands/secrets/set.js +36 -0
  46. package/dist/commands/secrets/sync.d.ts +9 -0
  47. package/dist/commands/secrets/sync.js +20 -0
  48. package/dist/commands/service-accounts/create.d.ts +15 -0
  49. package/dist/commands/service-accounts/create.js +46 -0
  50. package/dist/commands/service-accounts/delete.d.ts +12 -0
  51. package/dist/commands/service-accounts/delete.js +25 -0
  52. package/dist/commands/service-accounts/list.d.ts +9 -0
  53. package/dist/commands/service-accounts/list.js +25 -0
  54. package/dist/commands/service-accounts/tokens/create.d.ts +10 -0
  55. package/dist/commands/service-accounts/tokens/create.js +27 -0
  56. package/dist/commands/service-accounts/tokens/revoke.d.ts +13 -0
  57. package/dist/commands/service-accounts/tokens/revoke.js +26 -0
  58. package/dist/lib/api.js +6 -0
  59. package/dist/lib/config.js +10 -1
  60. package/dist/lib/stdin.d.ts +3 -0
  61. package/dist/lib/stdin.js +11 -0
  62. package/dist/lib/subprocess.d.ts +6 -0
  63. package/dist/lib/subprocess.js +16 -0
  64. package/oclif.manifest.json +4050 -2662
  65. package/opencli.json +142 -1
  66. package/package.json +4 -1
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_1 = require("../../../base");
5
+ class ServiceAccountsTokensCreate extends base_1.BaseCommand {
6
+ static args = {
7
+ account: core_1.Args.string({ description: 'Service account id', required: true }),
8
+ name: core_1.Args.string({ description: 'Token name (e.g. ci-deploy)', required: true }),
9
+ };
10
+ static description = 'Create a CLI token (cyi_u_) for a service account (the secret is shown only once)';
11
+ static examples = ['<%= config.bin %> service-accounts tokens create <account-id> ci-deploy'];
12
+ async run() {
13
+ const { args } = await this.parse(ServiceAccountsTokensCreate);
14
+ const res = await this.api.post(`/cli/v1/service/accounts/${encodeURIComponent(args.account)}/tokens`, { name: args.name });
15
+ const token = res.data ?? {};
16
+ if (!this.jsonEnabled()) {
17
+ this.log('Service account token created. Store the secret now — it is shown only once:');
18
+ this.log('');
19
+ this.log(` secret: ${token.secret ?? '-'}`);
20
+ this.log('');
21
+ this.log('Use it headless: CLOSEYOURIT_TOKEN=<secret> closeyourit secrets bundle -p KEY -e development');
22
+ this.warn('The secret cannot be retrieved again. If you lose it, revoke and create a new one.');
23
+ }
24
+ return res;
25
+ }
26
+ }
27
+ exports.default = ServiceAccountsTokensCreate;
@@ -0,0 +1,13 @@
1
+ import { BaseCommand } from '../../../base';
2
+ export default class ServiceAccountsTokensRevoke extends BaseCommand {
3
+ static args: {
4
+ account: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
5
+ id: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
6
+ };
7
+ static description: string;
8
+ static examples: string[];
9
+ static flags: {
10
+ confirm: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
+ };
12
+ run(): Promise<unknown>;
13
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_1 = require("../../../base");
5
+ class ServiceAccountsTokensRevoke extends base_1.BaseCommand {
6
+ static args = {
7
+ account: core_1.Args.string({ description: 'Service account id', required: true }),
8
+ id: core_1.Args.string({ description: 'Token id', required: true }),
9
+ };
10
+ static description = 'Revoke a service account CLI token (the agent using it loses access)';
11
+ static examples = ['<%= config.bin %> service-accounts tokens revoke <account-id> <token-id> --confirm'];
12
+ static flags = {
13
+ confirm: core_1.Flags.boolean({ description: 'Required: confirm the revocation' }),
14
+ };
15
+ async run() {
16
+ const { args, flags } = await this.parse(ServiceAccountsTokensRevoke);
17
+ if (!flags.confirm) {
18
+ this.error('Refusing to revoke without --confirm.', { exit: 2 });
19
+ }
20
+ await this.api.delete(`/cli/v1/service/accounts/${encodeURIComponent(args.account)}/tokens/${encodeURIComponent(args.id)}`);
21
+ if (!this.jsonEnabled())
22
+ this.log(`Revoked token ${args.id}`);
23
+ return { revoked: args.id };
24
+ }
25
+ }
26
+ exports.default = ServiceAccountsTokensRevoke;
package/dist/lib/api.js CHANGED
@@ -47,6 +47,12 @@ class CliApi {
47
47
  const form = new FormData();
48
48
  for (const file of files)
49
49
  form.append(file.field, file.data, file.filename);
50
+ if (opts.body && typeof opts.body === 'object') {
51
+ for (const [key, value] of Object.entries(opts.body)) {
52
+ if (value !== undefined && value !== null)
53
+ form.append(key, String(value));
54
+ }
55
+ }
50
56
  const url = this.resolveUrl(path);
51
57
  let res;
52
58
  try {
@@ -56,6 +56,15 @@ function defaultApiUrl() {
56
56
  const fromEnv = process.env.CLOSEYOURIT_API_URL;
57
57
  return fromEnv && fromEnv.trim() !== '' ? fromEnv : DEFAULT_API_URL;
58
58
  }
59
+ /**
60
+ * Token from CLOSEYOURIT_TOKEN env, for headless/CI/agent use (overrides the stored config token).
61
+ * Lets a service account (cyi_u_) authenticate non-interactively without the device-flow login:
62
+ * CLOSEYOURIT_TOKEN=cyi_u_... cyi secrets bundle -p KEY -e development
63
+ */
64
+ function envToken() {
65
+ const fromEnv = process.env.CLOSEYOURIT_TOKEN;
66
+ return fromEnv && fromEnv.trim() !== '' ? fromEnv.trim() : undefined;
67
+ }
59
68
  function loadConfig() {
60
69
  const file = configPath();
61
70
  let parsed = {};
@@ -70,7 +79,7 @@ function loadConfig() {
70
79
  }
71
80
  return {
72
81
  apiUrl: parsed.apiUrl && parsed.apiUrl.trim() !== '' ? parsed.apiUrl : defaultApiUrl(),
73
- token: parsed.token,
82
+ token: envToken() ?? parsed.token,
74
83
  account: parsed.account,
75
84
  organization: parsed.organization,
76
85
  };
@@ -0,0 +1,3 @@
1
+ /** Read a whole stream (default: process.stdin) into a UTF-8 string. Used by `secrets import` to accept
2
+ * piped input, e.g. `doppler secrets download --format json | cyi secrets import --format json`. */
3
+ export declare function readStream(stream?: AsyncIterable<Buffer | string>): Promise<string>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readStream = readStream;
4
+ /** Read a whole stream (default: process.stdin) into a UTF-8 string. Used by `secrets import` to accept
5
+ * piped input, e.g. `doppler secrets download --format json | cyi secrets import --format json`. */
6
+ async function readStream(stream = process.stdin) {
7
+ const chunks = [];
8
+ for await (const chunk of stream)
9
+ chunks.push(Buffer.from(chunk));
10
+ return Buffer.concat(chunks).toString('utf8');
11
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Run a child process inheriting stdio, resolving with its exit code. Unlike `openUrl` (browser.ts)
3
+ * this is NOT detached/unref'd: `cyi run` must stay attached and propagate the child's exit code
4
+ * (like `doppler run`). A terminating signal maps to a non-zero code.
5
+ */
6
+ export declare function runCommand(command: string, args: string[], env: NodeJS.ProcessEnv): Promise<number>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runCommand = runCommand;
4
+ const node_child_process_1 = require("node:child_process");
5
+ /**
6
+ * Run a child process inheriting stdio, resolving with its exit code. Unlike `openUrl` (browser.ts)
7
+ * this is NOT detached/unref'd: `cyi run` must stay attached and propagate the child's exit code
8
+ * (like `doppler run`). A terminating signal maps to a non-zero code.
9
+ */
10
+ function runCommand(command, args, env) {
11
+ return new Promise((resolve, reject) => {
12
+ const child = (0, node_child_process_1.spawn)(command, args, { stdio: 'inherit', env });
13
+ child.on('error', reject);
14
+ child.on('exit', (code, signal) => resolve(code ?? (signal ? 1 : 0)));
15
+ });
16
+ }