@seekrit/cli 0.20.0 → 0.22.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 (2) hide show
  1. package/dist/index.js +21 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1976,7 +1976,7 @@ function isServiceToken(value) {
1976
1976
  }
1977
1977
  //#endregion
1978
1978
  //#region package.json
1979
- var version = "0.20.0";
1979
+ var version = "0.22.0";
1980
1980
  //#endregion
1981
1981
  //#region ../../packages/api-client/src/index.ts
1982
1982
  var SeekritApiError = class extends Error {
@@ -1993,13 +1993,16 @@ var SeekritClient = class {
1993
1993
  baseUrl;
1994
1994
  auth;
1995
1995
  fetchImpl;
1996
+ client;
1996
1997
  constructor(options) {
1997
1998
  this.baseUrl = options.baseUrl.replace(/\/$/, "");
1998
1999
  this.auth = options.auth;
1999
2000
  this.fetchImpl = options.fetch ?? ((...args) => fetch(...args));
2001
+ this.client = options.client;
2000
2002
  }
2001
2003
  async request(method, path, body) {
2002
2004
  const headers = { accept: "application/json" };
2005
+ if (this.client) headers["x-seekrit-client"] = this.client;
2003
2006
  if (this.auth.type === "bearer") headers.authorization = `Bearer ${this.auth.token}`;
2004
2007
  else if (this.auth.type === "dynamic") {
2005
2008
  const token = await this.auth.getToken();
@@ -2259,6 +2262,10 @@ var SeekritClient = class {
2259
2262
  disableKmsKey(orgId, keyId) {
2260
2263
  return this.request("POST", `/v1/orgs/${orgId}/kms/keys/${keyId}/disable`);
2261
2264
  }
2265
+ /** Soft-delete a key: it drops out of every listing and read path. */
2266
+ deleteKmsKey(orgId, keyId) {
2267
+ return this.request("DELETE", `/v1/orgs/${orgId}/kms/keys/${keyId}`);
2268
+ }
2262
2269
  /** The broker's public key — wrap the admin credential to it before registering a target. */
2263
2270
  getLeaseBrokerKey(orgId) {
2264
2271
  return this.request("GET", `/v1/orgs/${orgId}/leases/broker-key`);
@@ -2426,6 +2433,8 @@ async function readStdin() {
2426
2433
  }
2427
2434
  //#endregion
2428
2435
  //#region src/context.ts
2436
+ /** Sent as `x-seekrit-client` so the API attributes usage to the CLI (analytics). */
2437
+ const CLI_CLIENT = `cli/${version}`;
2429
2438
  /**
2430
2439
  * Build the client context from configured credentials, or return null when
2431
2440
  * none are set. `seekrit run` uses this to degrade to a plain launcher instead
@@ -2456,7 +2465,8 @@ function tryBuildContext(dotenvVars = {}) {
2456
2465
  return {
2457
2466
  client: new SeekritClient({
2458
2467
  baseUrl: apiUrl,
2459
- auth
2468
+ auth,
2469
+ client: CLI_CLIENT
2460
2470
  }),
2461
2471
  auth
2462
2472
  };
@@ -3113,6 +3123,13 @@ function registerKmsCommands(program) {
3113
3123
  await ctx.client.disableKmsKey(org.id, key.id);
3114
3124
  console.error(`disabled ${key.name}`);
3115
3125
  });
3126
+ kms.command("delete").description("delete a key (hides it from all listings; the name frees up for reuse)").requiredOption("--key <name>", "key name or id").option("--org <slug>").action(async (options) => {
3127
+ const ctx = buildContext();
3128
+ const org = await resolveOrg(ctx, options.org);
3129
+ const key = await kmsResolveKey(ctx, org.id, options.key);
3130
+ await ctx.client.deleteKmsKey(org.id, key.id);
3131
+ console.error(`deleted ${key.name}`);
3132
+ });
3116
3133
  kms.command("encrypt").description("encrypt stdin under a key (prints a ce1 ciphertext blob)").requiredOption("--key <name>", "key name or id").option("--org <slug>").option("--context <ctx>", "encryption context bound as AAD (required identically to decrypt)").action(async (options) => {
3117
3134
  const ctx = buildContext();
3118
3135
  const org = await resolveOrg(ctx, options.org);
@@ -3221,7 +3238,8 @@ async function mintAdminToken(apiUrl, creds) {
3221
3238
  type: "m2m",
3222
3239
  clientId: creds.clientId,
3223
3240
  clientSecret: creds.clientSecret
3224
- }
3241
+ },
3242
+ client: `cli/${version}`
3225
3243
  });
3226
3244
  const { orgs } = await client.listOrgs();
3227
3245
  const org = orgs[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seekrit/cli",
3
- "version": "0.20.0",
3
+ "version": "0.22.0",
4
4
  "description": "End-to-end encrypted secrets manager CLI — inject decrypted secrets into any command.",
5
5
  "type": "module",
6
6
  "publishConfig": {