@browserless.io/cli 0.4.0 → 0.4.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.4.2](https://github.com/browserless/browserless-cli/compare/v0.4.1...v0.4.2) (2026-10-13)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * PLT-1314 enforce secure server URLs before sending tokens ([#120](https://github.com/browserless/browserless-cli/issues/120)) ([de84550](https://github.com/browserless/browserless-cli/commit/de8455044faa84d99627475db49eb76a7feadfc1))
9
+
10
+ ## [0.4.1](https://github.com/browserless/browserless-cli/compare/v0.4.0...v0.4.1) (2026-10-06)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * PLT-1315 restrict telemetry to trusted API hosts ([#119](https://github.com/browserless/browserless-cli/issues/119)) ([c67453c](https://github.com/browserless/browserless-cli/commit/c67453c272feb00f890013e3d334f7c8a226a35d))
16
+
3
17
  ## [0.4.0](https://github.com/browserless/browserless-cli/compare/v0.3.0...v0.4.0) (2026-09-22)
4
18
 
5
19
 
package/README.md CHANGED
@@ -60,7 +60,6 @@
60
60
  - [Why use the CLI?](#-why-use-the-cli)
61
61
  - [Licensing](#-licensing)
62
62
 
63
-
64
63
  ## 🚀 Get Started in Seconds!
65
64
 
66
65
  ### Step 1: Install
@@ -97,8 +96,8 @@ browserless profile upload \
97
96
  --browser chrome --profile Default --name my-chrome
98
97
  ```
99
98
 
100
- **✅ Success!** Any Browserless cloud session can now start *already
101
- authenticated* by attaching `?profile=my-chrome` to its launch URL.
99
+ **✅ Success!** Any Browserless cloud session can now start _already
100
+ authenticated_ by attaching `?profile=my-chrome` to its launch URL.
102
101
 
103
102
  ### Picking a server
104
103
 
@@ -119,13 +118,12 @@ Per-invocation overrides: `--region <code>` or `--server <url>`.
119
118
  Passing both flags (or having both keys set in config) is an error —
120
119
  they're mutually exclusive.
121
120
 
122
-
123
121
  ## 🗂 Capture Commands
124
122
 
125
123
  > **First-run note (macOS only).** The first time you run `profile upload`
126
124
  > or `profile refresh`, macOS may show a one-time Keychain prompt:
127
- > *"Google Chrome wants to access key 'Chrome Safe Storage' in your
128
- > keychain"*. This is the launched Chrome reading its own existing
125
+ > _"Google Chrome wants to access key 'Chrome Safe Storage' in your
126
+ > keychain"_. This is the launched Chrome reading its own existing
129
127
  > keychain entry — not the CLI asking for new access. Click
130
128
  > **Always Allow** and you won't see it again.
131
129
  >
@@ -168,19 +166,19 @@ browserless profile delete my-chrome-v2
168
166
 
169
167
  `--browser` accepts either the short key or the display name in quotes:
170
168
 
171
- | Key | Display name |
172
- | --------------- | -------------------------------------------------- |
173
- | `chrome` | Google Chrome |
174
- | `chrome-beta` | Google Chrome Beta |
175
- | `chrome-dev` | Google Chrome Dev |
176
- | `chrome-canary` | Google Chrome Canary |
177
- | `brave` | Brave |
178
- | `edge` | Microsoft Edge |
179
- | `vivaldi` | Vivaldi |
180
- | `opera` | Opera |
181
- | `arc` | Arc |
182
- | `chromium` | Chromium (incl. Snap on Linux) |
183
- | (custom) | whatever you registered via `profile sources add` |
169
+ | Key | Display name |
170
+ | --------------- | ------------------------------------------------- |
171
+ | `chrome` | Google Chrome |
172
+ | `chrome-beta` | Google Chrome Beta |
173
+ | `chrome-dev` | Google Chrome Dev |
174
+ | `chrome-canary` | Google Chrome Canary |
175
+ | `brave` | Brave |
176
+ | `edge` | Microsoft Edge |
177
+ | `vivaldi` | Vivaldi |
178
+ | `opera` | Opera |
179
+ | `arc` | Arc |
180
+ | `chromium` | Chromium (incl. Snap on Linux) |
181
+ | (custom) | whatever you registered via `profile sources add` |
184
182
 
185
183
  The match is case-insensitive: `--browser CHROME`, `--browser Chrome`,
186
184
  and `--browser "google chrome"` all resolve to the same entry.
@@ -191,7 +189,6 @@ State` (e.g. `Personal`, `Work`) or the on-disk directory name
191
189
  names should be unique within a browser), the CLI prints all candidates
192
190
  so you can disambiguate by passing the directory name.
193
191
 
194
-
195
192
  ## 🔒 Privacy & Domain Filtering
196
193
 
197
194
  Cookies and origin storage for sensitive domains can be filtered out
@@ -220,7 +217,7 @@ browserless profile upload \
220
217
  ```
221
218
 
222
219
  Use `--no-default-excludes` to ignore the persistent list for a single
223
- invocation (e.g. when refreshing a profile that *needs* a domain that's
220
+ invocation (e.g. when refreshing a profile that _needs_ a domain that's
224
221
  normally excluded).
225
222
 
226
223
  > **In addition to your list**, the CLI always filters out cookies and
@@ -229,7 +226,6 @@ normally excluded).
229
226
  > uploading intranet / corp / local-network state that would never apply
230
227
  > to a cloud session anyway.
231
228
 
232
-
233
229
  ## 📦 Managing Artifact Size
234
230
 
235
231
  The Browserless server caps uploaded profiles at **2 MB** of serialized
@@ -240,10 +236,10 @@ capture exceeds the cap, the CLI prints the heaviest origins on stderr
240
236
  and the upload returns HTTP 400 — pick one of the flags below to fit
241
237
  under it.
242
238
 
243
- | Flag | Effect |
244
- | ------------------- | --------------------------------------------------------------------------------------------------------------- |
245
- | `--auto-fit` | Drop the heaviest origins (largest first) until the artifact fits under the cap. Cookies are never dropped. |
246
- | `--keep-domain <d>` | Protect a domain from `--auto-fit` drops — suffix-match (same syntax as `--exclude-domain`), repeatable. |
239
+ | Flag | Effect |
240
+ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
241
+ | `--auto-fit` | Drop the heaviest origins (largest first) until the artifact fits under the cap. Cookies are never dropped. |
242
+ | `--keep-domain <d>` | Protect a domain from `--auto-fit` drops — suffix-match (same syntax as `--exclude-domain`), repeatable. |
247
243
  | `--only-domain <d>` | Allowlist: capture only cookies / origins matching these domains, discard everything else. Suffix-match, repeatable. Applies after `--exclude-domain`. |
248
244
 
249
245
  ```bash
@@ -263,7 +259,6 @@ reports how many cookies / origins it kept and dropped. If `--auto-fit`
263
259
  can't reach the cap because every remaining heavy origin is protected
264
260
  by `--keep-domain`, the CLI tells you which `--keep-domain` to relax.
265
261
 
266
-
267
262
  ## 🧩 Custom Chromium Browsers
268
263
 
269
264
  Register any Chromium-based binary the built-in registry doesn't know
@@ -283,7 +278,6 @@ If the binary or `user-data-dir` later goes missing, `profile sources
283
278
  list` flags the entry under "Registered custom browsers with missing
284
279
  paths" so you can clean it up with `profile sources rm`.
285
280
 
286
-
287
281
  ## ⚙️ Shared Flags
288
282
 
289
283
  Every command that hits the cloud API accepts:
@@ -297,17 +291,16 @@ Every command that hits the cloud API accepts:
297
291
 
298
292
  Capture commands (`upload`, `refresh`, `inspect`) also accept:
299
293
 
300
- | Flag | Effect |
301
- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
302
- | `--exclude-domain <d>` | Append a domain to the exclusion list for this run (repeatable) |
303
- | `--no-default-excludes` | Skip the persistent exclusion list for this run |
304
- | `--only-domain <d>` | Allowlist: capture only domains matching this pattern (repeatable, applies after `--exclude-domain`) |
294
+ | Flag | Effect |
295
+ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
296
+ | `--exclude-domain <d>` | Append a domain to the exclusion list for this run (repeatable) |
297
+ | `--no-default-excludes` | Skip the persistent exclusion list for this run |
298
+ | `--only-domain <d>` | Allowlist: capture only domains matching this pattern (repeatable, applies after `--exclude-domain`) |
305
299
  | `--auto-fit` | If the artifact exceeds the 2 MB server cap, drop the heaviest origins until it fits (see [Managing Artifact Size](#-managing-artifact-size)) |
306
- | `--keep-domain <d>` | Domain that `--auto-fit` must never drop (repeatable) |
307
- | `--accept-terms` | Pre-accept the liability disclaimer |
308
- | `--terms-ttl-days <n>` | Override the re-prompt TTL for this run (0 = every run) |
309
- | `--password-store <s>` | Linux only — pass `basic` / `gnome-libsecret` / `kwallet5` through to the launched browser if auto-detection picks wrong |
310
-
300
+ | `--keep-domain <d>` | Domain that `--auto-fit` must never drop (repeatable) |
301
+ | `--accept-terms` | Pre-accept the liability disclaimer |
302
+ | `--terms-ttl-days <n>` | Override the re-prompt TTL for this run (0 = every run) |
303
+ | `--password-store <s>` | Linux only — pass `basic` / `gnome-libsecret` / `kwallet5` through to the launched browser if auto-detection picks wrong |
311
304
 
312
305
  ## 🛠 Configuration
313
306
 
@@ -315,16 +308,16 @@ Capture commands (`upload`, `refresh`, `inspect`) also accept:
315
308
  Manage user-managed keys via the commands below; CLI-managed keys are
316
309
  written automatically and not user-editable.
317
310
 
318
- | Key | Kind | How to change |
319
- | ------------------- | ----------- | ------------------------------------------------------------------------ |
320
- | `server` | user scalar | `browserless config set server <url>` (mutually exclusive with `region`) |
321
- | `region` | user scalar | `browserless config set region <sfo\|lon\|ams>` |
322
- | `terms_ttl_days` | user scalar | `browserless config set terms_ttl_days <n>` (default 7) |
311
+ | Key | Kind | How to change |
312
+ | ------------------- | ----------- | -------------------------------------------------------------------------------------------------------- |
313
+ | `server` | user scalar | `browserless config set server <url>` (mutually exclusive with `region`) |
314
+ | `region` | user scalar | `browserless config set region <sfo\|lon\|ams>` |
315
+ | `terms_ttl_days` | user scalar | `browserless config set terms_ttl_days <n>` (default 7) |
323
316
  | `telemetry` | user scalar | `browserless config set telemetry <true\|false>` (default on) — see [Usage Analytics](#-usage-analytics) |
324
- | `excluded_domains` | user list | `browserless profile exclude add/rm/list` |
325
- | `accepted_terms_at` | CLI-managed | written when you accept the disclaimer |
326
- | `token_storage` | CLI-managed | written by `auth login` (`keychain` or `file`) |
327
- | `api_key` | CLI-managed | written by `auth login` only when keychain is unavailable |
317
+ | `excluded_domains` | user list | `browserless profile exclude add/rm/list` |
318
+ | `accepted_terms_at` | CLI-managed | written when you accept the disclaimer |
319
+ | `token_storage` | CLI-managed | written by `auth login` (`keychain` or `file`) |
320
+ | `api_key` | CLI-managed | written by `auth login` only when keychain is unavailable |
328
321
 
329
322
  ```bash
330
323
  browserless config get server
@@ -338,21 +331,20 @@ browserless config unset region
338
331
  `profile exclude`, CLI-managed keys can't be set directly (they have
339
332
  side-effects the CLI itself owns).
340
333
 
341
-
342
334
  ## 🌍 Environment Variables
343
335
 
344
- | Variable | Effect |
345
- | ------------------------------ | ---------------------------------------------------------------------- |
346
- | `BROWSERLESS_TOKEN` | Use this token without a stored credential (overrides keychain + file) |
347
- | `BROWSERLESS_ACCEPT_TERMS` | `1` to pre-accept the liability disclaimer |
348
- | `BROWSERLESS_CONFIG_DIR` | Override `~/.browserless/` location (CI / multi-tenant) |
349
- | `BROWSERLESS_DISABLE_KEYCHAIN` | `1` to force plaintext config-file storage even if the keychain works |
350
- | `BROWSERLESS_CDP_WAIT_MS` | Override the 15 s CDP-readiness timeout (raise on slow CI runners) |
351
- | `BROWSERLESS_TELEMETRY_DISABLED` | `1` to disable usage analytics for the run (see [Usage Analytics](#-usage-analytics)) |
352
- | `DO_NOT_TRACK` | `1` also disables usage analytics (cross-tool standard) |
353
- | `BROWSERLESS_API_URL` | Override the analytics endpoint host (default `https://api.browserless.io`) |
354
- | `BROWSERLESS_TELEMETRY_TIMEOUT_MS` | Override the 2 s analytics flush timeout (ignored unless a positive number) |
355
-
336
+ | Variable | Effect |
337
+ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
338
+ | `BROWSERLESS_TOKEN` | Use this token without a stored credential (overrides keychain + file) |
339
+ | `BROWSERLESS_ACCEPT_TERMS` | `1` to pre-accept the liability disclaimer |
340
+ | `BROWSERLESS_CONFIG_DIR` | Override `~/.browserless/` location (CI / multi-tenant) |
341
+ | `BROWSERLESS_DISABLE_KEYCHAIN` | `1` to force plaintext config-file storage even if the keychain works |
342
+ | `BROWSERLESS_CDP_WAIT_MS` | Override the 15 s CDP-readiness timeout (raise on slow CI runners) |
343
+ | `BROWSERLESS_TELEMETRY_DISABLED` | `1` to disable usage analytics for the run (see [Usage Analytics](#-usage-analytics)) |
344
+ | `DO_NOT_TRACK` | `1` also disables usage analytics (cross-tool standard) |
345
+ | `BROWSERLESS_API_URL` | Override the analytics endpoint (default `https://api.browserless.io`); must use HTTPS on `browserless.io` or `*.browserless.io`, or HTTP(S) loopback for local development. Telemetry is skipped otherwise. |
346
+ | `BROWSERLESS_ALLOW_INSECURE_HTTP` | `1` to allow sending the token over `http://` to a non-loopback server (prints a warning) |
347
+ | `BROWSERLESS_TELEMETRY_TIMEOUT_MS` | Override the 2 s analytics flush timeout (ignored unless a positive number) |
356
348
 
357
349
  ## 📊 Usage Analytics
358
350
 
@@ -390,7 +382,6 @@ BROWSERLESS_TELEMETRY_DISABLED=1 ... # per-run
390
382
  DO_NOT_TRACK=1 ... # per-run (cross-tool standard)
391
383
  ```
392
384
 
393
-
394
385
  ## 🚦 Exit Codes
395
386
 
396
387
  | Code | Meaning |
@@ -402,7 +393,6 @@ DO_NOT_TRACK=1 ... # per-run (cross-tool standard)
402
393
  | 4 | Local capture pipeline failed — copy / browser launch / CDP (`CaptureError`) |
403
394
  | 5 | Server returned a non-2xx response (`ApiError`) |
404
395
 
405
-
406
396
  ## 💡 Why use the CLI?
407
397
 
408
398
  **Sharing a logged-in browser session with a cloud worker is painful.**
@@ -410,10 +400,10 @@ DO_NOT_TRACK=1 ... # per-run (cross-tool standard)
410
400
  Cookies live in OS-encrypted SQLite. localStorage and IndexedDB are
411
401
  spread across LevelDB on disk. Manually re-logging in on every cloud
412
402
  session is busywork — and rolling your own cookie export usually ends
413
- in *"why am I randomly logged out of everything?"* when Chrome Sync
403
+ in _"why am I randomly logged out of everything?"_ when Chrome Sync
414
404
  realises a copy of the profile woke up on a server farm.
415
405
 
416
- **The CLI does this once, safely.** It launches a *temporary copy* of
406
+ **The CLI does this once, safely.** It launches a _temporary copy_ of
417
407
  your profile in a controlled-headless mode that suppresses Chrome Sync
418
408
  / Safe Browsing / component-update traffic, reads cookies +
419
409
  localStorage + IndexedDB via CDP, applies your domain-exclusion list
@@ -421,8 +411,7 @@ localStorage + IndexedDB via CDP, applies your domain-exclusion list
421
411
  touched; sensitive domains never leave your machine.
422
412
 
423
413
  Once uploaded, any Browserless cloud session can attach the profile
424
- via `?profile=<name>` and start *already authenticated*.
425
-
414
+ via `?profile=<name>` and start _already authenticated_.
426
415
 
427
416
  ## 📜 Licensing
428
417
 
@@ -435,7 +424,6 @@ If you're building a commercial application on Browserless, a
435
424
  priority support, on-premise deployment, source modification, and
436
425
  the admin UI in addition to keeping your software proprietary.
437
426
 
438
-
439
427
  <div align="center">
440
428
 
441
429
  **Happy capturing!**
@@ -0,0 +1,2 @@
1
+ var s=Object.defineProperty;var o=(r,t)=>s(r,"name",{value:t,configurable:!0});import{PreconditionError as n,UsageError as e}from"../errors.js";import{isLoopbackHostname as p}from"../utils/loopback.js";const i="BROWSERLESS_ALLOW_INSECURE_HTTP",S=o(r=>{let t;try{t=new URL(r)}catch{throw new e(`server must be a valid URL (got "${r}")`)}if(t.protocol==="https:")return r;if(t.protocol==="http:"){if(p(t.hostname))return r;if(process.env[i]==="1")return process.stderr.write(`warning: sending your Browserless token over unencrypted http:// to ${t.host} (BROWSERLESS_ALLOW_INSECURE_HTTP is set)
2
+ `),r;throw new n(`Refusing to send your Browserless token over unencrypted http:// to ${t.host}. Use https://, or set BROWSERLESS_ALLOW_INSECURE_HTTP=1 to override.`,"insecure-server-url")}throw new e(`server must use https:// (got "${t.protocol}")`)},"assertSecureServerUrl");export{i as ALLOW_INSECURE_ENV,S as assertSecureServerUrl};
@@ -1 +1 @@
1
- var c=Object.defineProperty;var t=(e,r)=>c(e,"name",{value:r,configurable:!0});import{readConfig as a,updateConfig as l}from"../config/store.js";import{DEFAULT_SERVER as k}from"../config/schema.js";import{deleteFromKeychain as g,readFromKeychain as u,writeToKeychain as y}from"./keychain.js";import{PreconditionError as i}from"../errors.js";import{regionToServerUrl as f}from"../regions.js";import{recordToken as s}from"../telemetry/token-cache.js";const w="BROWSERLESS_TOKEN",S=t(async e=>{const r=typeof e=="string"?e:e?.server,o=typeof e=="string"?void 0:e?.region;if(o&&r)throw new i("--region and --server are mutually exclusive \u2014 pass one or the other.","server-region-conflict");if(o)return f(o);if(r)return r;const n=await a();if(n.region&&n.server)throw new i(`Both "region" (${n.region}) and "server" (${n.server}) are set in ~/.browserless/config.json \u2014 unset one with \`browserless config unset region\` or \`browserless config unset server\`.`,"server-region-conflict");return n.region?f(n.region):n.server??k},"resolveServer"),R=t(async e=>{if(e.flag)return s({token:e.flag,server:e.server}),{token:e.flag,source:"flag"};const r=process.env[w];if(r)return s({token:r,server:e.server}),{token:r,source:"env"};const o=await u(e.server);if(o.ok){if(o.value!==null)return s({token:o.value,server:e.server}),{token:o.value,source:"keychain"}}else if(o.reason==="op-failed")throw new i(`Keychain is available but read failed: ${o.error}. Retry, or set BROWSERLESS_DISABLE_KEYCHAIN=1 to bypass and use the plaintext fallback at ~/.browserless/config.json.`,"keychain-read-failed");const n=await a();if(n.api_key)return s({token:n.api_key,server:e.server}),{token:n.api_key,source:"file"};throw new i("No API token configured. Run `browserless auth login` to set one.","no-token")},"resolveToken"),m=t(async e=>{const r=await y(e.server,e.token);if(r.ok)return await l(o=>{o.token_storage="keychain",delete o.api_key}),{mode:"keychain"};if(r.reason==="op-failed")throw new i(`Keychain is available but write failed: ${r.error}. Retry, or set BROWSERLESS_DISABLE_KEYCHAIN=1 to store the token in plaintext at ~/.browserless/config.json instead.`,"keychain-write-failed");return await l(o=>{o.token_storage="file",o.api_key=e.token}),{mode:"file",warning:"Token stored in plaintext at ~/.browserless/config.json \u2014 keychain unavailable on this system."}},"persistToken"),T=t(async e=>{const r=await g(e);if(!r.ok&&r.reason==="op-failed")throw new i(`Could not delete the keychain entry for ${e}: ${r.error}. The token may still be stored \u2014 fix the keychain access and re-run \`browserless auth logout\`.`,"keychain-delete-failed");await l(o=>{delete o.api_key,delete o.token_storage})},"clearToken"),x=t(async()=>(await a()).token_storage??"none","getTokenStorageMode");export{T as clearToken,x as getTokenStorageMode,m as persistToken,S as resolveServer,R as resolveToken};
1
+ var k=Object.defineProperty;var t=(e,o)=>k(e,"name",{value:o,configurable:!0});import{readConfig as a,updateConfig as l}from"../config/store.js";import{DEFAULT_SERVER as g}from"../config/schema.js";import{deleteFromKeychain as u,readFromKeychain as y,writeToKeychain as w}from"./keychain.js";import{PreconditionError as i}from"../errors.js";import{regionToServerUrl as f}from"../regions.js";import{recordToken as s}from"../telemetry/token-cache.js";import{assertSecureServerUrl as c}from"./server-url.js";const h="BROWSERLESS_TOKEN",R=t(async e=>{const o=typeof e=="string"?e:e?.server,r=typeof e=="string"?void 0:e?.region;if(r&&o)throw new i("--region and --server are mutually exclusive \u2014 pass one or the other.","server-region-conflict");if(r)return f(r);if(o)return c(o);const n=await a();if(n.region&&n.server)throw new i(`Both "region" (${n.region}) and "server" (${n.server}) are set in ~/.browserless/config.json \u2014 unset one with \`browserless config unset region\` or \`browserless config unset server\`.`,"server-region-conflict");return n.region?f(n.region):c(n.server??g)},"resolveServer"),T=t(async e=>{if(e.flag)return s({token:e.flag,server:e.server}),{token:e.flag,source:"flag"};const o=process.env[h];if(o)return s({token:o,server:e.server}),{token:o,source:"env"};const r=await y(e.server);if(r.ok){if(r.value!==null)return s({token:r.value,server:e.server}),{token:r.value,source:"keychain"}}else if(r.reason==="op-failed")throw new i(`Keychain is available but read failed: ${r.error}. Retry, or set BROWSERLESS_DISABLE_KEYCHAIN=1 to bypass and use the plaintext fallback at ~/.browserless/config.json.`,"keychain-read-failed");const n=await a();if(n.api_key)return s({token:n.api_key,server:e.server}),{token:n.api_key,source:"file"};throw new i("No API token configured. Run `browserless auth login` to set one.","no-token")},"resolveToken"),x=t(async e=>{const o=await w(e.server,e.token);if(o.ok)return await l(r=>{r.token_storage="keychain",delete r.api_key}),{mode:"keychain"};if(o.reason==="op-failed")throw new i(`Keychain is available but write failed: ${o.error}. Retry, or set BROWSERLESS_DISABLE_KEYCHAIN=1 to store the token in plaintext at ~/.browserless/config.json instead.`,"keychain-write-failed");return await l(r=>{r.token_storage="file",r.api_key=e.token}),{mode:"file",warning:"Token stored in plaintext at ~/.browserless/config.json \u2014 keychain unavailable on this system."}},"persistToken"),K=t(async e=>{const o=await u(e);if(!o.ok&&o.reason==="op-failed")throw new i(`Could not delete the keychain entry for ${e}: ${o.error}. The token may still be stored \u2014 fix the keychain access and re-run \`browserless auth logout\`.`,"keychain-delete-failed");await l(r=>{delete r.api_key,delete r.token_storage})},"clearToken"),A=t(async()=>(await a()).token_storage??"none","getTokenStorageMode");export{K as clearToken,A as getTokenStorageMode,x as persistToken,R as resolveServer,T as resolveToken};
@@ -1 +1 @@
1
- var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});import{UsageError as s}from"../errors.js";import{isKnownRegion as c,KNOWN_REGIONS as d}from"../regions.js";const f="https://production-sfo.browserless.io",p=7,a={server:{kind:"scalar",sensitive:!1,parse:n(e=>{try{new URL(e)}catch{throw new s(`server must be a valid URL (got "${e}")`)}return e},"parse")},region:{kind:"scalar",sensitive:!1,parse:n(e=>{if(!c(e))throw new s(`region must be one of: ${d.join(", ")} (got "${e}"). For self-hosted or staging, use \`config set server <url>\` instead.`);return e},"parse")},terms_ttl_days:{kind:"scalar",sensitive:!1,parse:n(e=>{const t=Number(e);if(!Number.isFinite(t)||t<0||!Number.isInteger(t))throw new s(`terms_ttl_days must be a non-negative integer (got "${e}")`);return t},"parse")},telemetry:{kind:"scalar",sensitive:!1,parse:n(e=>{const t=e.trim().toLowerCase();if(["true","1","yes","on"].includes(t))return!0;if(["false","0","no","off"].includes(t))return!1;throw new s(`telemetry must be a boolean (true/false) (got "${e}")`)},"parse")},excluded_domains:{kind:"list",manageHint:"`browserless profile exclude add/rm/list`",sensitive:!1},accepted_terms_at:{kind:"cli-managed",manageHint:"set automatically when you accept the disclaimer",sensitive:!1},token_storage:{kind:"cli-managed",manageHint:"set automatically by `browserless auth login`",sensitive:!1},api_key:{kind:"cli-managed",manageHint:"managed by `browserless auth login` / `auth logout`",sensitive:!0}},w=n(e=>a[e].sensitive,"isSensitiveKey"),o=n(()=>Object.keys(a),"allConfigKeys"),r=n(e=>Object.prototype.hasOwnProperty.call(a,e),"isKnownKey"),h=n((e,t)=>{if(!r(e))throw new s(`Unknown config key "${e}". Known keys: ${o().join(", ")}.`);const i=a[e];if(i.kind==="list")throw new s(`"${e}" is a list. Manage it via ${i.manageHint} \u2014 not via \`config set\`.`);if(i.kind==="cli-managed")throw new s(`"${e}" is managed by the CLI (${i.manageHint}). Editing it directly is not supported.`);return i.parse(t)},"validateScalarSet"),v=n(e=>{if(!r(e))throw new s(`Unknown config key "${e}". Known keys: ${o().join(", ")}.`);const t=a[e];if(t.kind==="cli-managed")throw new s(`"${e}" is managed by the CLI (${t.manageHint}). Use the relevant command to clear it.`);return e},"validateUnset");export{f as DEFAULT_SERVER,p as DEFAULT_TERMS_TTL_DAYS,o as allConfigKeys,r as isKnownKey,w as isSensitiveKey,h as validateScalarSet,v as validateUnset};
1
+ var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});import{UsageError as s}from"../errors.js";import{isKnownRegion as c,KNOWN_REGIONS as d}from"../regions.js";const f="https://production-sfo.browserless.io",p=7,o={server:{kind:"scalar",sensitive:!1,parse:n(e=>{let t;try{t=new URL(e)}catch{throw new s(`server must be a valid URL (got "${e}")`)}if(t.protocol!=="http:"&&t.protocol!=="https:")throw new s(`server must use https:// (got "${t.protocol}")`);return e},"parse")},region:{kind:"scalar",sensitive:!1,parse:n(e=>{if(!c(e))throw new s(`region must be one of: ${d.join(", ")} (got "${e}"). For self-hosted or staging, use \`config set server <url>\` instead.`);return e},"parse")},terms_ttl_days:{kind:"scalar",sensitive:!1,parse:n(e=>{const t=Number(e);if(!Number.isFinite(t)||t<0||!Number.isInteger(t))throw new s(`terms_ttl_days must be a non-negative integer (got "${e}")`);return t},"parse")},telemetry:{kind:"scalar",sensitive:!1,parse:n(e=>{const t=e.trim().toLowerCase();if(["true","1","yes","on"].includes(t))return!0;if(["false","0","no","off"].includes(t))return!1;throw new s(`telemetry must be a boolean (true/false) (got "${e}")`)},"parse")},excluded_domains:{kind:"list",manageHint:"`browserless profile exclude add/rm/list`",sensitive:!1},accepted_terms_at:{kind:"cli-managed",manageHint:"set automatically when you accept the disclaimer",sensitive:!1},token_storage:{kind:"cli-managed",manageHint:"set automatically by `browserless auth login`",sensitive:!1},api_key:{kind:"cli-managed",manageHint:"managed by `browserless auth login` / `auth logout`",sensitive:!0}},w=n(e=>o[e].sensitive,"isSensitiveKey"),r=n(()=>Object.keys(o),"allConfigKeys"),a=n(e=>Object.prototype.hasOwnProperty.call(o,e),"isKnownKey"),h=n((e,t)=>{if(!a(e))throw new s(`Unknown config key "${e}". Known keys: ${r().join(", ")}.`);const i=o[e];if(i.kind==="list")throw new s(`"${e}" is a list. Manage it via ${i.manageHint} \u2014 not via \`config set\`.`);if(i.kind==="cli-managed")throw new s(`"${e}" is managed by the CLI (${i.manageHint}). Editing it directly is not supported.`);return i.parse(t)},"validateScalarSet"),v=n(e=>{if(!a(e))throw new s(`Unknown config key "${e}". Known keys: ${r().join(", ")}.`);const t=o[e];if(t.kind==="cli-managed")throw new s(`"${e}" is managed by the CLI (${t.manageHint}). Use the relevant command to clear it.`);return e},"validateUnset");export{f as DEFAULT_SERVER,p as DEFAULT_TERMS_TTL_DAYS,r as allConfigKeys,a as isKnownKey,w as isSensitiveKey,h as validateScalarSet,v as validateUnset};
@@ -1 +1 @@
1
- var c=Object.defineProperty;var o=(t,e)=>c(t,"name",{value:e,configurable:!0});import{version as l}from"../version.js";const m="https://api.browserless.io",p=o(()=>{const t=process.env.BROWSERLESS_API_URL?.trim()||m;return t.endsWith("/")?t.slice(0,-1):t},"apiBaseUrl"),u=2e3,T=`@browserless.io/cli/${l}`,A=o(async(t,e)=>{const r=e.timeoutMs??u,i=e.baseUrl??p(),s=new AbortController,a=setTimeout(()=>s.abort(),r);try{const n=await fetch(`${i}/v2/cli/events`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":T,Authorization:`Bearer ${e.token}`},body:JSON.stringify({events:t}),signal:s.signal});return await n.text().catch(()=>{}),n.ok}catch{return!1}finally{clearTimeout(a)}},"postCliEvents");export{p as apiBaseUrl,A as postCliEvents};
1
+ var c=Object.defineProperty;var o=(t,e)=>c(t,"name",{value:e,configurable:!0});import{version as l}from"../version.js";import{isLoopbackHostname as p}from"../utils/loopback.js";const h="https://api.browserless.io",u=o(()=>{const t=process.env.BROWSERLESS_API_URL?.trim()||h;return t.endsWith("/")?t.slice(0,-1):t},"apiBaseUrl"),m=o(t=>{try{const{protocol:e,hostname:s}=new URL(t);return e!=="http:"&&e!=="https:"?!1:p(s)||e==="https:"&&(s==="browserless.io"||s.endsWith(".browserless.io"))}catch{return!1}},"isTrustedApiBase"),f=2e3,b=`@browserless.io/cli/${l}`,A=o(async(t,e)=>{const s=e.timeoutMs??f,r=e.baseUrl??u();if(!m(r))return!1;const n=new AbortController,a=setTimeout(()=>n.abort(),s);try{const i=await fetch(`${r}/v2/cli/events`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":b,Authorization:`Bearer ${e.token}`},body:JSON.stringify({events:t}),signal:n.signal});return await i.text().catch(()=>{}),i.ok}catch{return!1}finally{clearTimeout(a)}},"postCliEvents");export{u as apiBaseUrl,m as isTrustedApiBase,A as postCliEvents};
@@ -1,2 +1,2 @@
1
- var E=Object.defineProperty;var t=(e,r)=>E(e,"name",{value:r,configurable:!0});import{performance as p}from"node:perf_hooks";import{readConfig as l}from"../config/store.js";import{REGION_URLS as _,KNOWN_REGIONS as v,isKnownRegion as g}from"../regions.js";import{version as R}from"../version.js";import{commandPath as h,usedFlagNames as S}from"./command-meta.js";import{getRecordedToken as T}from"./token-cache.js";import{getOrCreateDeviceId as w}from"./device-id.js";import{postCliEvents as y}from"./api.js";const L="CLI Command Run",a=t(e=>e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false","isTruthyEnv"),N=t(()=>{const e=Number(process.env.BROWSERLESS_TELEMETRY_TIMEOUT_MS);return e>0?e:2e3},"flushTimeoutMs"),i=t(e=>{a(process.env.BROWSERLESS_TELEMETRY_DEBUG)&&process.stderr.write(`[telemetry] ${e}
2
- `)},"debug");let c,s=[];const K=t(e=>{c&&s.length<6&&s.push(e)},"recordProfileSetupEvent"),k=t(async()=>{if(a(process.env.BROWSERLESS_TELEMETRY_DISABLED)||a(process.env.DO_NOT_TRACK))return!1;try{const e=await l();return e.telemetry===void 0||e.telemetry===!0}catch{return!1}},"isEnabled"),Y=t(e=>{s=[],c={command:h(e),flags:S(e),startedAt:p.now()}},"begin"),C=t(e=>{let r;try{r=new URL(e).origin}catch{return"custom"}return v.find(o=>{try{return new URL(_[o]).origin===r}catch{return!1}})??"custom"},"bucketServerUrl"),M=t(()=>Number(process.versions.node.split(".")[0])||0,"nodeMajor"),O=t((e,r,d,o)=>{const n={command:e.command,flags:e.flags,status:r.status,exit_code:r.exitCode,error_name:r.status==="error"?r.errorName:void 0,error_code:r.status==="error"?r.errorCode:void 0,duration_ms:Math.round(p.now()-e.startedAt),cli_version:R,os:process.platform,arch:process.arch,node_major:M(),is_ci:a(process.env.CI),server_region:d,cli_device_id:o};return{event_type:L,time:Date.now(),event_properties:n}},"buildEvent"),$=t(async e=>{const r=c;c=void 0;const d=s;if(s=[],!!r)try{if(!await k()){i("skipped: telemetry disabled");return}const o=T();if(!o){i("skipped: no token resolved this run");return}const n=C(o.server);if(!g(n)){i("skipped: non-cloud server");return}const m=await w(),f=O(r,e,n,m),u=await y([f,...d],{token:o.token,timeoutMs:N()});i(u?`sent (${n})`:`send failed (${n})`)}catch{i("skipped: error while flushing")}},"complete"),j=t(()=>{c=void 0,s=[]},"_resetForTests");export{j as _resetForTests,Y as begin,C as bucketServerUrl,$ as complete,N as flushTimeoutMs,k as isEnabled,K as recordProfileSetupEvent};
1
+ var E=Object.defineProperty;var t=(e,r)=>E(e,"name",{value:r,configurable:!0});import{performance as p}from"node:perf_hooks";import{readConfig as l}from"../config/store.js";import{REGION_URLS as _,KNOWN_REGIONS as v,isKnownRegion as R}from"../regions.js";import{version as g}from"../version.js";import{commandPath as h,usedFlagNames as S}from"./command-meta.js";import{getRecordedToken as T}from"./token-cache.js";import{getOrCreateDeviceId as w}from"./device-id.js";import{apiBaseUrl as L,isTrustedApiBase as y,postCliEvents as k}from"./api.js";const N="CLI Command Run",d=t(e=>e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false","isTruthyEnv"),O=t(()=>{const e=Number(process.env.BROWSERLESS_TELEMETRY_TIMEOUT_MS);return e>0?e:2e3},"flushTimeoutMs"),s=t(e=>{d(process.env.BROWSERLESS_TELEMETRY_DEBUG)&&process.stderr.write(`[telemetry] ${e}
2
+ `)},"debug");let c,i=[];const Y=t(e=>{c&&i.length<6&&i.push(e)},"recordProfileSetupEvent"),C=t(async()=>{if(d(process.env.BROWSERLESS_TELEMETRY_DISABLED)||d(process.env.DO_NOT_TRACK))return!1;try{const e=await l();return e.telemetry===void 0||e.telemetry===!0}catch{return!1}},"isEnabled"),$=t(e=>{i=[],c={command:h(e),flags:S(e),startedAt:p.now()}},"begin"),M=t(e=>{let r;try{r=new URL(e).origin}catch{return"custom"}return v.find(o=>{try{return new URL(_[o]).origin===r}catch{return!1}})??"custom"},"bucketServerUrl"),x=t(()=>Number(process.versions.node.split(".")[0])||0,"nodeMajor"),B=t((e,r,a,o)=>{const n={command:e.command,flags:e.flags,status:r.status,exit_code:r.exitCode,error_name:r.status==="error"?r.errorName:void 0,error_code:r.status==="error"?r.errorCode:void 0,duration_ms:Math.round(p.now()-e.startedAt),cli_version:g,os:process.platform,arch:process.arch,node_major:x(),is_ci:d(process.env.CI),server_region:a,cli_device_id:o};return{event_type:N,time:Date.now(),event_properties:n}},"buildEvent"),j=t(async e=>{const r=c;c=void 0;const a=i;if(i=[],!!r)try{if(!await C()){s("skipped: telemetry disabled");return}const o=T();if(!o){s("skipped: no token resolved this run");return}const n=M(o.server);if(!R(n)){s("skipped: non-cloud server");return}if(!y(L())){s("skipped: BROWSERLESS_API_URL is not a Browserless host");return}const m=await w(),f=B(r,e,n,m),u=await k([f,...a],{token:o.token,timeoutMs:O()});s(u?`sent (${n})`:`send failed (${n})`)}catch{s("skipped: error while flushing")}},"complete"),F=t(()=>{c=void 0,i=[]},"_resetForTests");export{F as _resetForTests,$ as begin,M as bucketServerUrl,j as complete,O as flushTimeoutMs,C as isEnabled,Y as recordProfileSetupEvent};
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var o=(e,t)=>r(e,"name",{value:t,configurable:!0});const n=o(e=>{const t=e.toLowerCase().replace(/^\[|\]$/g,"");return t==="localhost"||t.endsWith(".localhost")||t==="::1"?!0:/^127(\.\d{1,3}){3}$/.test(t)},"isLoopbackHostname");export{n as isLoopbackHostname};
package/build/version.js CHANGED
@@ -1 +1 @@
1
- const o="0.4.0";export{o as version};
1
+ const o="0.4.2";export{o as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserless.io/cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "description": "Browserless CLI — manage authentication profiles, sessions, and other Browserless features from your terminal.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -47,7 +47,7 @@
47
47
  "dependencies": {
48
48
  "chrome-remote-interface": "^0.34.0",
49
49
  "commander": "^15.0.0",
50
- "ws": "^8.21.3"
50
+ "ws": "^8.22.0"
51
51
  },
52
52
  "optionalDependencies": {
53
53
  "@napi-rs/keyring": "^2.1.0"
@@ -57,20 +57,20 @@
57
57
  "@types/chai": "^5.2.3",
58
58
  "@types/chrome-remote-interface": "^0.34.0",
59
59
  "@types/mocha": "^10.0.10",
60
- "@types/node": "^26.6.1",
60
+ "@types/node": "^26.6.5",
61
61
  "@types/sinon": "^22.0.0",
62
- "@types/ws": "^8.18.1",
63
- "chai": "^6.2.2",
62
+ "@types/ws": "^8.18.2",
63
+ "chai": "^6.3.0",
64
64
  "esbuild": "^0.28.2",
65
- "eslint": "^10.10.0",
66
- "globals": "^17.12.0",
65
+ "eslint": "^10.12.0",
66
+ "globals": "^17.13.0",
67
67
  "husky": "^9.1.7",
68
- "lint-staged": "^17.5.1",
69
- "mocha": "^12.0.2",
70
- "prettier": "3.9.8",
68
+ "lint-staged": "^17.6.0",
69
+ "mocha": "^12.0.3",
70
+ "prettier": "3.9.10",
71
71
  "sinon": "^22.1.0",
72
72
  "typescript": "^6.0.3",
73
- "typescript-eslint": "^8.70.0"
73
+ "typescript-eslint": "^8.71.1"
74
74
  },
75
75
  "overrides": {
76
76
  "mocha": {