apiblaze 0.17.17 → 0.17.19

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 +25 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -328,7 +328,11 @@ function saveAnonCred(cp_key, team_id, claim_code) {
328
328
  claim_code: claim_code ?? prev?.claim_code,
329
329
  created_at: prev?.created_at ?? (/* @__PURE__ */ new Date()).toISOString()
330
330
  };
331
- fs2.writeFileSync(FILE, JSON.stringify(merged, null, 2));
331
+ fs2.writeFileSync(FILE, JSON.stringify(merged, null, 2), { mode: 384 });
332
+ try {
333
+ fs2.chmodSync(FILE, 384);
334
+ } catch {
335
+ }
332
336
  } catch {
333
337
  }
334
338
  }
@@ -699,7 +703,7 @@ var import_commander = require("commander");
699
703
  var import_chalk38 = __toESM(require("chalk"));
700
704
 
701
705
  // package.json
702
- var version = "0.17.17";
706
+ var version = "0.17.19";
703
707
 
704
708
  // src/index.ts
705
709
  init_types();
@@ -5226,15 +5230,22 @@ var CLIENT_ROUND_CAP = 12;
5226
5230
  function chatUrl(p) {
5227
5231
  return `https://${p.mcpHost}/${p.version}/${p.environment}/runtime-chat`;
5228
5232
  }
5233
+ function maskKey(k) {
5234
+ return k.length <= 8 ? "****" : `${k.slice(0, 4)}\u2026${k.slice(-4)}`;
5235
+ }
5236
+ var revealAuth = false;
5229
5237
  function renderToolEvents(events, dpKey) {
5230
5238
  for (const e of events ?? []) {
5231
5239
  const ok = typeof e.status === "number" ? e.status < 400 : String(e.status).toLowerCase() === "ok";
5232
5240
  const mark = ok ? import_chalk33.default.green("\u2713") : import_chalk33.default.red("\u2717");
5233
5241
  console.log(` ${mark} ${import_chalk33.default.cyan(e.name)} ${import_chalk33.default.dim(`(${e.status}, ${e.ms}ms)`)}`);
5234
5242
  if (isVerbose() && e.method && e.url) {
5235
- const auth = dpKey ? ` \\
5236
- -H 'X-API-Key: ${maskSecret(dpKey)}'` : "";
5237
- console.log(import_chalk33.default.dim(` curl -sS -X ${e.method} '${e.url}'${auth}`));
5243
+ console.log(import_chalk33.default.dim(` curl -sS -X ${e.method} '${e.url}'${dpKey ? " \\" : ""}`));
5244
+ if (dpKey) {
5245
+ const keyLine = ` -H 'X-API-Key: ${revealAuth ? dpKey : maskKey(dpKey)}'`;
5246
+ const hint = revealAuth ? "" : import_chalk33.default.yellow(" \u2190 /showauth will reveal this");
5247
+ console.log(import_chalk33.default.dim(keyLine) + hint);
5248
+ }
5238
5249
  }
5239
5250
  }
5240
5251
  }
@@ -5387,8 +5398,8 @@ async function mintDurableProxyKey(teamId, tenant2) {
5387
5398
  const out = await admin({
5388
5399
  method: "POST",
5389
5400
  path: `/teams/${encodeURIComponent(teamId)}/tenants/${encodeURIComponent(tenant2)}/admin/keys`,
5390
- body: { key_type: "apiblaze-consumer-admin", environment: "prod" },
5391
- // no expiry durable
5401
+ body: { permissions: ["call", "wallet"], environment: "prod" },
5402
+ // key_model §2: call the API + spend the team wallet; non-expiring service key
5392
5403
  summary: "Mint a durable data-plane key for apichat"
5393
5404
  });
5394
5405
  if (!out?.key) throw new Error("key mint returned no key");
@@ -5405,7 +5416,7 @@ async function openServerProxy(project) {
5405
5416
  if (!dpKey) {
5406
5417
  console.log(import_chalk33.default.dim(` Minting an API key for tenant ${import_chalk33.default.bold(tenant2)} to query project ${import_chalk33.default.bold(project.projectName)}\u2026`));
5407
5418
  dpKey = await mintDurableProxyKey(project.teamId, tenant2);
5408
- console.log(` ${import_chalk33.default.green("\u2714")} API key: ${import_chalk33.default.dim(maskSecret(dpKey))}`);
5419
+ console.log(` ${import_chalk33.default.green("\u2714")} API key: ${import_chalk33.default.dim(maskKey(dpKey))}`);
5409
5420
  }
5410
5421
  const p = {
5411
5422
  projectId: project.projectId,
@@ -5610,8 +5621,13 @@ async function runRepl(p, initialMessages) {
5610
5621
  }
5611
5622
  continue;
5612
5623
  }
5624
+ if (text === "/showauth") {
5625
+ revealAuth = !revealAuth;
5626
+ console.log(import_chalk33.default.dim(revealAuth ? " The real API key will be shown in the next call's curl. /showauth again to re-mask." : " API key re-masked."));
5627
+ continue;
5628
+ }
5613
5629
  if (text.startsWith("/")) {
5614
- console.log(import_chalk33.default.dim(" Commands: /login /claim /exit"));
5630
+ console.log(import_chalk33.default.dim(" Commands: /login /claim /showauth /exit"));
5615
5631
  continue;
5616
5632
  }
5617
5633
  await replTurn(p, messages, text);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.17.17",
3
+ "version": "0.17.19",
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",