unbrowse 12.1.1 → 12.1.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/cli.js +15 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -440,6 +440,16 @@ function save(stored) {
440
440
  function clear() {
441
441
  rmSync(configPath(), { force: true });
442
442
  }
443
+ function v1Key(baseUrl) {
444
+ if (!/^https:\/\/(www\.|api\.|v3\.)?unbrowse\.ai\/?$/.test(baseUrl))
445
+ return;
446
+ try {
447
+ const key = JSON.parse(readFileSync(join(process.env.HOME || homedir(), ".unbrowse", "config.json"), "utf8")).api_key;
448
+ return typeof key === "string" && /^ubr_[0-9a-f]{48}$/.test(key) ? key : undefined;
449
+ } catch {
450
+ return;
451
+ }
452
+ }
443
453
  async function currentToken(baseUrl, fetchImpl = fetch) {
444
454
  if (process.env.UNBROWSE_API_KEY)
445
455
  return process.env.UNBROWSE_API_KEY;
@@ -450,7 +460,7 @@ async function currentToken(baseUrl, fetchImpl = fetch) {
450
460
  return stored.apiKey;
451
461
  const o = stored.oauth;
452
462
  if (!o)
453
- return;
463
+ return v1Key(baseUrl);
454
464
  if (o.expiresAt && o.refreshToken && Date.now() > o.expiresAt - 60000) {
455
465
  try {
456
466
  const fresh = await tokenRequest(baseUrl, { grant_type: "refresh_token", refresh_token: o.refreshToken, client_id: o.clientId, resource: apiResource(baseUrl) }, fetchImpl);
@@ -472,6 +482,9 @@ function describe(baseUrl) {
472
482
  return `API key ${mask(stored.apiKey)} in ${configPath()}`;
473
483
  if (stored.oauth)
474
484
  return `OAuth sign-in in ${configPath()}`;
485
+ const v1 = !stored.baseUrl ? v1Key(baseUrl) : undefined;
486
+ if (v1)
487
+ return `v1 API key ${mask(v1)} from ~/.unbrowse/config.json (still works; \`unbrowse login\` replaces it)`;
475
488
  return "not signed in";
476
489
  }
477
490
  function mask(key) {
@@ -556,7 +569,7 @@ ${url.toString()}`);
556
569
 
557
570
  // src/cli.ts
558
571
  init_src();
559
- var VERSION = "12.1.1";
572
+ var VERSION = "12.1.2";
560
573
  var DEFAULT_ORIGIN = "https://unbrowse.ai";
561
574
  var HELP = `unbrowse ${VERSION} — call websites as APIs through the Unbrowse API
562
575
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unbrowse",
3
- "version": "12.1.1",
3
+ "version": "12.1.2",
4
4
  "mcpName": "io.github.unbrowse-ai/unbrowse",
5
5
  "description": "Call websites as APIs: a thin CLI over the Unbrowse API.",
6
6
  "license": "MIT",