apiblaze 0.19.18 → 0.19.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 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -932,7 +932,7 @@ var import_commander = require("commander");
932
932
  var import_chalk44 = __toESM(require("chalk"));
933
933
 
934
934
  // package.json
935
- var version = "0.19.18";
935
+ var version = "0.19.19";
936
936
 
937
937
  // src/index.ts
938
938
  init_types();
@@ -1689,6 +1689,9 @@ async function probeLocalServer(port) {
1689
1689
  }
1690
1690
  }
1691
1691
  async function runDev(options) {
1692
+ if (options.newSession && !(loadCredentials() && Date.now() < loadCredentials().expiresAt)) {
1693
+ clearAnonCred();
1694
+ }
1692
1695
  let auth = resolveDevAuth();
1693
1696
  let keyAuth = auth.mode === "key" ? { apiKey: auth.apiKey } : void 0;
1694
1697
  let teamId = "";
@@ -1933,6 +1936,7 @@ ${projects.length} project${projects.length === 1 ? "" : "s"}`));
1933
1936
 
1934
1937
  // src/commands/create.ts
1935
1938
  var import_fs2 = __toESM(require("fs"));
1939
+ var import_yaml = require("yaml");
1936
1940
  var import_chalk10 = __toESM(require("chalk"));
1937
1941
  var import_ora5 = __toESM(require("ora"));
1938
1942
  init_auth();
@@ -1964,8 +1968,22 @@ async function loadOpenapiSource(ref) {
1964
1968
  }
1965
1969
  }
1966
1970
  if (!text.trim()) fail(`The OpenAPI spec is empty: ${ref}`);
1967
- if (!/["']?(openapi|swagger|paths)["']?\s*:/i.test(text)) {
1968
- fail(`That does not look like an OpenAPI/Swagger document (no openapi/swagger/paths): ${ref}`);
1971
+ let parsed;
1972
+ try {
1973
+ parsed = text.trimStart().startsWith("{") ? JSON.parse(text) : (0, import_yaml.parse)(text);
1974
+ } catch (err) {
1975
+ fail(`Could not parse the OpenAPI spec at ${ref} as JSON or YAML \u2014 ${err.message}`);
1976
+ }
1977
+ const doc = parsed;
1978
+ if (!doc || typeof doc !== "object") {
1979
+ fail(`${ref} is not an OpenAPI/Swagger document.
1980
+ If that link opens a web page, use the raw file URL instead.`);
1981
+ }
1982
+ if (typeof doc.openapi !== "string" && typeof doc.swagger !== "string") {
1983
+ fail(
1984
+ `${ref} has no "openapi" or "swagger" version field, so it is not a usable API description.
1985
+ If the file looks right otherwise, check its first line \u2014 the copy at that URL may be damaged.`
1986
+ );
1969
1987
  }
1970
1988
  return text;
1971
1989
  }
@@ -5752,7 +5770,7 @@ var path6 = __toESM(require("path"));
5752
5770
  var crypto2 = __toESM(require("crypto"));
5753
5771
  var import_chalk39 = __toESM(require("chalk"));
5754
5772
  var import_ora21 = __toESM(require("ora"));
5755
- var import_yaml = require("yaml");
5773
+ var import_yaml2 = require("yaml");
5756
5774
  init_auth();
5757
5775
  init_anon_cred();
5758
5776
  init_api();
@@ -5855,7 +5873,7 @@ function parseSpec(text) {
5855
5873
  parsed = JSON.parse(text);
5856
5874
  } catch {
5857
5875
  try {
5858
- parsed = (0, import_yaml.parse)(text);
5876
+ parsed = (0, import_yaml2.parse)(text);
5859
5877
  } catch {
5860
5878
  fail4("Could not parse the spec as JSON or YAML.");
5861
5879
  }
@@ -7505,14 +7523,14 @@ withSetupOptions(sidecar.command("setup").description("Wire a Next.js app to rou
7505
7523
  sidecar.command("approve").description("Route an origin through APIblaze (creates its proxy)").argument("<origin>", "Origin, e.g. api.stripe.com").option("--team <id|name>", "Team (defaults to active team)").option("--json", "Machine-readable output").action(action((origin, opts) => runOriginsApprove(origin, opts)));
7506
7524
  sidecar.command("deny").description("Dismiss a candidate origin so it stops being suggested").argument("<origin>", "Origin, e.g. sentry.io").option("--team <id|name>", "Team (defaults to active team)").action(action((origin, opts) => runOriginsDeny(origin, opts)));
7507
7525
  sidecar.command("remove").description("Un-route an approved origin (deletes its proxy; the app goes direct again)").argument("<origin>", "Origin, e.g. api.stripe.com").option("--team <id|name>", "Team (defaults to active team)").action(action((origin, opts) => runOriginsRemove(origin, opts)));
7508
- program.command("dev").description("Put your localhost behind a public URL (dev tunnel)").argument("[port]", "Local port to tunnel (positional; overrides --port)").option("-p, --port <number>", "Local port to tunnel", "3000").option("--project <nameOrId>", "Tunnel this specific project (skips the picker \u2014 for scripts)").option("-y, --yes", "Skip confirmation prompts (non-interactive)").option("-o, --capture-file <path>", "Stream full request/response traffic to a file (JSON lines)").action(async (port, opts) => {
7526
+ program.command("dev").description("Put your localhost behind a public URL (dev tunnel)").argument("[port]", "Local port to tunnel (positional; overrides --port)").option("-p, --port <number>", "Local port to tunnel", "3000").option("--project <nameOrId>", "Tunnel this specific project (skips the picker \u2014 for scripts)").option("-y, --yes", "Skip confirmation prompts (non-interactive)").option("-o, --capture-file <path>", "Stream full request/response traffic to a file (JSON lines)").option("--new-session", "Logged-out only: start a fresh anonymous workspace instead of reusing this machine's (each run = a throwaway proxy)").action(async (port, opts) => {
7509
7527
  try {
7510
7528
  const resolved = parseInt(port ?? opts.port, 10);
7511
7529
  if (Number.isNaN(resolved)) {
7512
7530
  console.error(import_chalk44.default.red(`Invalid port: ${port ?? opts.port}`));
7513
7531
  process.exit(1);
7514
7532
  }
7515
- await runDev({ port: resolved, project: opts.project, yes: opts.yes, captureFile: opts.captureFile });
7533
+ await runDev({ port: resolved, project: opts.project, yes: opts.yes, captureFile: opts.captureFile, newSession: opts.newSession });
7516
7534
  } catch (err) {
7517
7535
  await printError(err);
7518
7536
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apiblaze",
3
- "version": "0.19.18",
3
+ "version": "0.19.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",