apiblaze 0.21.0 → 0.21.2

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 +16 -21
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1291,7 +1291,7 @@ var import_commander = require("commander");
1291
1291
  var import_chalk57 = __toESM(require("chalk"));
1292
1292
 
1293
1293
  // package.json
1294
- var version = "0.21.0";
1294
+ var version = "0.21.2";
1295
1295
 
1296
1296
  // src/index.ts
1297
1297
  init_types();
@@ -4864,13 +4864,20 @@ function printTryIt(block, highlights) {
4864
4864
  }
4865
4865
  }
4866
4866
  var VALID_AUTH = ["api_key", "none", "oauth"];
4867
+ function planSentence(args) {
4868
+ const { name, auth, families, adminEmail } = args;
4869
+ const doors = auth.doors.length === 2 ? `use an API key for your own server and an ${B.product} login (with GitHub) for people and agents` : auth.doors[0] === "api_key" ? "use an API key" : auth.doors[0] === "oauth" ? auth.ownIssuer ? "use your own login" : `use an ${B.product} login (with GitHub)` : "be open to anyone";
4870
+ const locked = families?.length ? `, lock ${describeFamilies(families.map((f) => f.key)).replace(/ \+ /, " and ")} to whoever created them` : ", stay open to every caller who gets in (no rules yet)";
4871
+ const admin2 = adminEmail ? `, and let ${adminEmail} change anything` : "";
4872
+ return `${name} will ${doors}${locked}${admin2}.`;
4873
+ }
4867
4874
  var BOTH_DOORS = (() => {
4868
4875
  const { auth_type, ...bodyPatch } = bothDoorsBody();
4869
4876
  return {
4870
4877
  auth: auth_type,
4871
4878
  doors: ["api_key", "oauth"],
4872
4879
  bodyPatch,
4873
- summary: "your backend and widget use the API key; agents sign in with GitHub",
4880
+ summary: `your backend and widget use the API key; people and agents use an ${B.product} login (with GitHub)`,
4874
4881
  provider: "GitHub"
4875
4882
  };
4876
4883
  })();
@@ -4878,7 +4885,7 @@ var MANAGED_GITHUB = {
4878
4885
  auth: "oauth",
4879
4886
  doors: ["oauth"],
4880
4887
  bodyPatch: { login: { providers: [{ type: "github", managed: true }] } },
4881
- summary: "callers sign in with GitHub (hosted sign-in) \u2014 no API key",
4888
+ summary: `callers use an ${B.product} login (with GitHub) \u2014 no API key`,
4882
4889
  provider: "GitHub"
4883
4890
  };
4884
4891
  var API_KEY = { auth: "api_key", doors: ["api_key"], bodyPatch: {}, summary: "callers send the API key (X-API-Key) \u2014 no sign-in" };
@@ -4959,12 +4966,12 @@ function afterDash(sentence) {
4959
4966
  }
4960
4967
  async function pickFamilies(families, opts = {}) {
4961
4968
  const { default: inquirer3 } = await import("inquirer");
4962
- console.log(import_chalk16.default.dim(" space toggles \xB7 a all \xB7 enter accept \xB7 uncheck everything to skip"));
4969
+ console.log(import_chalk16.default.dim(" Uncheck everything to skip."));
4963
4970
  const short = opts.compact && families.filter((f) => !f.skipped_reason).length <= 3;
4964
4971
  const { picked } = await inquirer3.prompt([{
4965
4972
  type: "checkbox",
4966
4973
  name: "picked",
4967
- message: "Lock these to the person who created them (or an admin):",
4974
+ message: "Should only creators of a resource in the API be able to amend that resource?",
4968
4975
  pageSize: 15,
4969
4976
  choices: families.map((f) => {
4970
4977
  const key = short ? lastSegment(f.key) : f.key.replace(/^\//, "");
@@ -4974,7 +4981,7 @@ async function pickFamilies(families, opts = {}) {
4974
4981
  return picked ?? [];
4975
4982
  }
4976
4983
  async function chooseSecure(args) {
4977
- const { openapi, auth, name, interactive, quiet, compact } = args;
4984
+ const { openapi, name, interactive, quiet, compact } = args;
4978
4985
  const say = (s) => {
4979
4986
  if (!quiet) console.log(s);
4980
4987
  };
@@ -4982,20 +4989,6 @@ async function chooseSecure(args) {
4982
4989
  say(import_chalk16.default.dim(` No OpenAPI spec \u2014 nothing to protect yet. Run \`${B.cli} rule ${name}\` after you add one.`));
4983
4990
  return null;
4984
4991
  }
4985
- if (interactive) {
4986
- const { default: inquirer3 } = await import("inquirer");
4987
- const { lock } = await inquirer3.prompt([{
4988
- type: "confirm",
4989
- name: "lock",
4990
- message: "Do you want to prevent unauthorized users from taking unauthorized actions?",
4991
- default: true
4992
- }]);
4993
- if (lock && auth.doors.includes("api_key")) {
4994
- console.log(import_chalk16.default.dim(" Behind the API key, the rules check who is calling: your server says so with X-End-User-Id,"));
4995
- console.log(import_chalk16.default.dim(` or the key itself is issued to a person (${B.cli} apikeys mint --for).`));
4996
- }
4997
- if (!lock) return null;
4998
- }
4999
4992
  const spinner = quiet ? null : (0, import_ora6.default)("Reading your OpenAPI spec\u2026").start();
5000
4993
  const { status, data } = await proposeFromSpec(openapi).catch((err) => ({ status: 0, data: { error: err.message } }));
5001
4994
  if (status !== 200 || !data || !Array.isArray(data.families)) {
@@ -5455,7 +5448,9 @@ Create an ${B.thing}
5455
5448
  const { families, adminEmail } = await planSetup({ openapi: openapiContent, auth, name, interactive, quiet: !!opts.json });
5456
5449
  if (interactive && !opts.yes && !opts.auto) {
5457
5450
  const { default: inquirer3 } = await import("inquirer");
5458
- console.log(`${import_chalk16.default.cyan("\u2192")} ${auth.summary}${families ? ` \xB7 ${describeFamilies(families.map((f) => f.key))} locked to their creator` : ""}${adminEmail ? ` \xB7 admin ${adminEmail}` : ""}`);
5451
+ console.log();
5452
+ console.log(` ${planSentence({ name, auth, families, adminEmail })}`);
5453
+ console.log();
5459
5454
  const { ok } = await inquirer3.prompt([{
5460
5455
  type: "confirm",
5461
5456
  name: "ok",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.21.0",
3
+ "version": "0.21.2",
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",