apiblaze 0.21.21 → 0.21.23

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.
@@ -67,6 +67,8 @@ declare class PlaneError extends Error {
67
67
  * `apiblaze authz` / the dashboard).
68
68
  */
69
69
 
70
+ /** Marks the short-lived per-admin keys this widget mints; the API-key widget hides them. */
71
+ declare const GROUPS_SESSION_KEY_DESCRIPTION = "Users & Groups widget (minted per admin session)";
70
72
  interface ApiblazeGroupsConfig {
71
73
  /** The producer CP key — the SAME widget key the API-key widget uses. Server-only.
72
74
  * Here it only MINTS each admin's personal key, so it must be allowed to grant
@@ -291,6 +293,9 @@ interface ApiblazeKeysConfig {
291
293
  keyExpiresInSeconds?: number;
292
294
  /** Override the apiblaze base (tests/self-host). Default https://apikeys.apiblaze.com */
293
295
  base?: string;
296
+ /** The environment the minted keys call (a key is valid on ONE environment). Default 'prod';
297
+ * a proxy tunnelled with `apiblaze dev` serves 'dev'. */
298
+ environment?: string;
294
299
  }
295
300
  type Action = {
296
301
  action: 'list';
@@ -315,4 +320,4 @@ declare function createApiblazeKeys(cfg: ApiblazeKeysConfig): {
315
320
  }>;
316
321
  };
317
322
 
318
- export { type ApiblazeChatConfig, type ApiblazeGroupsConfig, type ApiblazeKeysConfig, type AppUser, type ChatRelayUser, type GroupsAction, PlaneError, createApiblazeChat, createApiblazeGroups, createApiblazeKeys };
323
+ export { type ApiblazeChatConfig, type ApiblazeGroupsConfig, type ApiblazeKeysConfig, type AppUser, type ChatRelayUser, GROUPS_SESSION_KEY_DESCRIPTION, type GroupsAction, PlaneError, createApiblazeChat, createApiblazeGroups, createApiblazeKeys };
@@ -67,6 +67,8 @@ declare class PlaneError extends Error {
67
67
  * `apiblaze authz` / the dashboard).
68
68
  */
69
69
 
70
+ /** Marks the short-lived per-admin keys this widget mints; the API-key widget hides them. */
71
+ declare const GROUPS_SESSION_KEY_DESCRIPTION = "Users & Groups widget (minted per admin session)";
70
72
  interface ApiblazeGroupsConfig {
71
73
  /** The producer CP key — the SAME widget key the API-key widget uses. Server-only.
72
74
  * Here it only MINTS each admin's personal key, so it must be allowed to grant
@@ -291,6 +293,9 @@ interface ApiblazeKeysConfig {
291
293
  keyExpiresInSeconds?: number;
292
294
  /** Override the apiblaze base (tests/self-host). Default https://apikeys.apiblaze.com */
293
295
  base?: string;
296
+ /** The environment the minted keys call (a key is valid on ONE environment). Default 'prod';
297
+ * a proxy tunnelled with `apiblaze dev` serves 'dev'. */
298
+ environment?: string;
294
299
  }
295
300
  type Action = {
296
301
  action: 'list';
@@ -315,4 +320,4 @@ declare function createApiblazeKeys(cfg: ApiblazeKeysConfig): {
315
320
  }>;
316
321
  };
317
322
 
318
- export { type ApiblazeChatConfig, type ApiblazeGroupsConfig, type ApiblazeKeysConfig, type AppUser, type ChatRelayUser, type GroupsAction, PlaneError, createApiblazeChat, createApiblazeGroups, createApiblazeKeys };
323
+ export { type ApiblazeChatConfig, type ApiblazeGroupsConfig, type ApiblazeKeysConfig, type AppUser, type ChatRelayUser, GROUPS_SESSION_KEY_DESCRIPTION, type GroupsAction, PlaneError, createApiblazeChat, createApiblazeGroups, createApiblazeKeys };
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/server/index.ts
21
21
  var server_exports = {};
22
22
  __export(server_exports, {
23
+ GROUPS_SESSION_KEY_DESCRIPTION: () => GROUPS_SESSION_KEY_DESCRIPTION,
23
24
  PlaneError: () => PlaneError,
24
25
  createApiblazeChat: () => createApiblazeChat,
25
26
  createApiblazeGroups: () => createApiblazeGroups,
@@ -87,6 +88,7 @@ function createPlaneCore(cfg) {
87
88
  }
88
89
 
89
90
  // src/server/groups.ts
91
+ var GROUPS_SESSION_KEY_DESCRIPTION = "Users & Groups widget (minted per admin session)";
90
92
  function createApiblazeGroups(cfg) {
91
93
  if (typeof cfg.getUser !== "function") throw new Error("apiblaze: getUser is required \u2014 map your session to { tenant, userId, email }.");
92
94
  const core = createPlaneCore({ cpKey: cfg.cpKey, apikeysBase: cfg.base, iamBase: cfg.iamBase });
@@ -113,7 +115,7 @@ function createApiblazeGroups(cfg) {
113
115
  environment: "prod",
114
116
  permissions: ["call", "manage-access"],
115
117
  expires_in_seconds: KEY_TTL_SECONDS,
116
- description: "Users & Groups widget (minted per admin session)"
118
+ description: GROUPS_SESSION_KEY_DESCRIPTION
117
119
  })
118
120
  });
119
121
  if (!res.ok) throw new PlaneError(res.status, await safeErr(res));
@@ -372,13 +374,14 @@ function createApiblazeKeys(cfg) {
372
374
  catalogNames(user, tenant2)
373
375
  ]);
374
376
  const d = await listRes.json();
375
- const keys = [...d.keys ?? []];
377
+ const visible = (k) => k?.description !== GROUPS_SESSION_KEY_DESCRIPTION;
378
+ const keys = [...d.keys ?? []].filter(visible);
376
379
  let cursor = d.page?.next_cursor ?? null;
377
380
  for (let hop = 0; hop < 50 && cursor; hop++) {
378
381
  const more = await planeFetch("GET", "/apikeys", user, { query: { tenant: tenant2, limit: "200", cursor } });
379
382
  if (!more.ok) break;
380
383
  const md = await more.json();
381
- keys.push(...md.keys ?? []);
384
+ keys.push(...(md.keys ?? []).filter(visible));
382
385
  cursor = md.page?.next_cursor ?? null;
383
386
  }
384
387
  const eligible = allowed.filter((t) => catalog.includes(t));
@@ -396,7 +399,7 @@ function createApiblazeKeys(cfg) {
396
399
  }
397
400
  const chosen = op.keyType ?? (eligible.includes("call-only") ? "call-only" : eligible[0]);
398
401
  await ensureEndUser(user, tenant2);
399
- const body = { tenant: tenant2, key_type_ids: [chosen], environment: "prod" };
402
+ const body = { tenant: tenant2, key_type_ids: [chosen], environment: cfg.environment || "prod" };
400
403
  if (typeof expiresIn === "number" && expiresIn > 0) body.expires_in_seconds = expiresIn;
401
404
  const r = await planeFetch("POST", "/apikeys", user, { body });
402
405
  const d = await r.json();
@@ -447,6 +450,7 @@ function createApiblazeKeys(cfg) {
447
450
  }
448
451
  // Annotate the CommonJS export names for ESM import in node:
449
452
  0 && (module.exports = {
453
+ GROUPS_SESSION_KEY_DESCRIPTION,
450
454
  PlaneError,
451
455
  createApiblazeChat,
452
456
  createApiblazeGroups,
@@ -58,6 +58,7 @@ function createPlaneCore(cfg) {
58
58
  }
59
59
 
60
60
  // src/server/groups.ts
61
+ var GROUPS_SESSION_KEY_DESCRIPTION = "Users & Groups widget (minted per admin session)";
61
62
  function createApiblazeGroups(cfg) {
62
63
  if (typeof cfg.getUser !== "function") throw new Error("apiblaze: getUser is required \u2014 map your session to { tenant, userId, email }.");
63
64
  const core = createPlaneCore({ cpKey: cfg.cpKey, apikeysBase: cfg.base, iamBase: cfg.iamBase });
@@ -84,7 +85,7 @@ function createApiblazeGroups(cfg) {
84
85
  environment: "prod",
85
86
  permissions: ["call", "manage-access"],
86
87
  expires_in_seconds: KEY_TTL_SECONDS,
87
- description: "Users & Groups widget (minted per admin session)"
88
+ description: GROUPS_SESSION_KEY_DESCRIPTION
88
89
  })
89
90
  });
90
91
  if (!res.ok) throw new PlaneError(res.status, await safeErr(res));
@@ -343,13 +344,14 @@ function createApiblazeKeys(cfg) {
343
344
  catalogNames(user, tenant2)
344
345
  ]);
345
346
  const d = await listRes.json();
346
- const keys = [...d.keys ?? []];
347
+ const visible = (k) => k?.description !== GROUPS_SESSION_KEY_DESCRIPTION;
348
+ const keys = [...d.keys ?? []].filter(visible);
347
349
  let cursor = d.page?.next_cursor ?? null;
348
350
  for (let hop = 0; hop < 50 && cursor; hop++) {
349
351
  const more = await planeFetch("GET", "/apikeys", user, { query: { tenant: tenant2, limit: "200", cursor } });
350
352
  if (!more.ok) break;
351
353
  const md = await more.json();
352
- keys.push(...md.keys ?? []);
354
+ keys.push(...(md.keys ?? []).filter(visible));
353
355
  cursor = md.page?.next_cursor ?? null;
354
356
  }
355
357
  const eligible = allowed.filter((t) => catalog.includes(t));
@@ -367,7 +369,7 @@ function createApiblazeKeys(cfg) {
367
369
  }
368
370
  const chosen = op.keyType ?? (eligible.includes("call-only") ? "call-only" : eligible[0]);
369
371
  await ensureEndUser(user, tenant2);
370
- const body = { tenant: tenant2, key_type_ids: [chosen], environment: "prod" };
372
+ const body = { tenant: tenant2, key_type_ids: [chosen], environment: cfg.environment || "prod" };
371
373
  if (typeof expiresIn === "number" && expiresIn > 0) body.expires_in_seconds = expiresIn;
372
374
  const r = await planeFetch("POST", "/apikeys", user, { body });
373
375
  const d = await r.json();
@@ -417,6 +419,7 @@ function createApiblazeKeys(cfg) {
417
419
  return { handler, run };
418
420
  }
419
421
  export {
422
+ GROUPS_SESSION_KEY_DESCRIPTION,
420
423
  PlaneError,
421
424
  createApiblazeChat,
422
425
  createApiblazeGroups,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.21.21",
3
+ "version": "0.21.23",
4
4
  "description": "APIblaze CLI — Chat with your APIs, Manage your API keys, users and groups with the APIblaze serverless proxy",
5
5
  "keywords": [
6
6
  "apiblaze",
@@ -78,8 +78,11 @@
78
78
  "devDependencies": {
79
79
  "@types/inquirer": "^8.2.10",
80
80
  "@types/node": "^20.0.0",
81
- "@types/react": "^18.2.0",
81
+ "@types/react": "^18.3.31",
82
+ "@types/react-dom": "^18.3.7",
82
83
  "@types/ws": "^8.5.10",
84
+ "react": "^18.3.1",
85
+ "react-dom": "^18.3.1",
83
86
  "tsup": "^8.0.0",
84
87
  "typescript": "^5.4.0"
85
88
  },
@@ -90,5 +93,9 @@
90
93
  "react": {
91
94
  "optional": true
92
95
  }
96
+ },
97
+ "allowScripts": {
98
+ "esbuild": true,
99
+ "fsevents": true
93
100
  }
94
101
  }