@browserless.io/cli 0.1.0 → 0.3.0
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 +14 -0
- package/README.md +43 -0
- package/build/api/refresh.js +1 -1
- package/build/api/upload.js +1 -1
- package/build/auth/store.js +1 -1
- package/build/cli-utils/capture-runner.js +24 -19
- package/build/cli.js +4 -4
- package/build/commands/auth/login.js +1 -1
- package/build/commands/profile/refresh.js +2 -2
- package/build/commands/profile/upload.js +2 -2
- package/build/config/schema.js +1 -1
- package/build/errors.js +1 -1
- package/build/telemetry/api.js +1 -0
- package/build/telemetry/command-meta.js +1 -0
- package/build/telemetry/device-id.js +1 -0
- package/build/telemetry/index.js +2 -0
- package/build/telemetry/token-cache.js +1 -0
- package/build/version.js +1 -1
- package/package.json +25 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.0](https://github.com/browserless/browserless-cli/compare/v0.2.0...v0.3.0) (2026-08-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* AUTO-258 DO NOT MERGE - profile refresh replays the settings a profile was captured with ([#58](https://github.com/browserless/browserless-cli/issues/58)) ([94fe959](https://github.com/browserless/browserless-cli/commit/94fe959620909e9f7e9bfe533dd0c94c1560c712))
|
|
9
|
+
|
|
10
|
+
## [0.2.0](https://github.com/browserless/browserless-cli/compare/v0.1.0...v0.2.0) (2026-06-18)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add usage telemetry ([#19](https://github.com/browserless/browserless-cli/issues/19)) ([bdaa5dd](https://github.com/browserless/browserless-cli/commit/bdaa5dd01a8c6712dcf345edae1c41a228e05097))
|
|
16
|
+
|
|
3
17
|
## [0.1.0](https://github.com/browserless/browserless-cli/compare/v0.0.3...v0.1.0) (2026-06-05)
|
|
4
18
|
|
|
5
19
|
|
package/README.md
CHANGED
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
- [Shared Flags](#-shared-flags)
|
|
56
56
|
- [Configuration](#-configuration)
|
|
57
57
|
- [Environment Variables](#-environment-variables)
|
|
58
|
+
- [Usage Analytics](#-usage-analytics)
|
|
58
59
|
- [Exit Codes](#-exit-codes)
|
|
59
60
|
- [Why use the CLI?](#-why-use-the-cli)
|
|
60
61
|
- [Licensing](#-licensing)
|
|
@@ -319,6 +320,7 @@ written automatically and not user-editable.
|
|
|
319
320
|
| `server` | user scalar | `browserless config set server <url>` (mutually exclusive with `region`) |
|
|
320
321
|
| `region` | user scalar | `browserless config set region <sfo\|lon\|ams>` |
|
|
321
322
|
| `terms_ttl_days` | user scalar | `browserless config set terms_ttl_days <n>` (default 7) |
|
|
323
|
+
| `telemetry` | user scalar | `browserless config set telemetry <true\|false>` (default on) — see [Usage Analytics](#-usage-analytics) |
|
|
322
324
|
| `excluded_domains` | user list | `browserless profile exclude add/rm/list` |
|
|
323
325
|
| `accepted_terms_at` | CLI-managed | written when you accept the disclaimer |
|
|
324
326
|
| `token_storage` | CLI-managed | written by `auth login` (`keychain` or `file`) |
|
|
@@ -346,6 +348,47 @@ side-effects the CLI itself owns).
|
|
|
346
348
|
| `BROWSERLESS_CONFIG_DIR` | Override `~/.browserless/` location (CI / multi-tenant) |
|
|
347
349
|
| `BROWSERLESS_DISABLE_KEYCHAIN` | `1` to force plaintext config-file storage even if the keychain works |
|
|
348
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
|
+
|
|
356
|
+
|
|
357
|
+
## 📊 Usage Analytics
|
|
358
|
+
|
|
359
|
+
The CLI reports lightweight usage so we know which commands to invest in
|
|
360
|
+
(and which to leave alone). It's on by default and easy to turn off.
|
|
361
|
+
|
|
362
|
+
**What is sent**, once per command, and only when the command both
|
|
363
|
+
authenticated with your token and targeted a Browserless cloud region:
|
|
364
|
+
|
|
365
|
+
- the command that ran (e.g. `profile upload`) and the **names** of the flags
|
|
366
|
+
you passed — never their values
|
|
367
|
+
- the outcome: `ok` / `error`, the exit code, and the error class/code on
|
|
368
|
+
failure (e.g. `cdp-timeout`)
|
|
369
|
+
- duration, CLI version, OS / architecture / Node major, whether it's running
|
|
370
|
+
under CI
|
|
371
|
+
- the production region (`sfo` / `lon` / `ams`) — never a raw server URL
|
|
372
|
+
- a random per-install id (`cli_device_id`), stored in
|
|
373
|
+
`~/.browserless/telemetry-device-id`
|
|
374
|
+
|
|
375
|
+
**What's never in the analytics data:** your API token, profile names,
|
|
376
|
+
captured URLs or domains, cookies, or any captured auth state. The token is
|
|
377
|
+
sent only as the request's `Authorization` header, so the Browserless API can
|
|
378
|
+
attribute the event to your account (usage is recorded per account, not
|
|
379
|
+
anonymously), and is **stripped before anything reaches analytics** — it's
|
|
380
|
+
never an event property. Commands that don't contact a
|
|
381
|
+
cloud region aren't tracked at all — that includes **self-hosted servers**
|
|
382
|
+
(`--server <url>`), where nothing is sent, and local-only commands (e.g.
|
|
383
|
+
`config`, offline `inspect`).
|
|
384
|
+
|
|
385
|
+
**Opt out** any of these ways:
|
|
386
|
+
|
|
387
|
+
```bash
|
|
388
|
+
browserless config set telemetry false # persistent
|
|
389
|
+
BROWSERLESS_TELEMETRY_DISABLED=1 ... # per-run
|
|
390
|
+
DO_NOT_TRACK=1 ... # per-run (cross-tool standard)
|
|
391
|
+
```
|
|
349
392
|
|
|
350
393
|
|
|
351
394
|
## 🚦 Exit Codes
|
package/build/api/refresh.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var a=Object.defineProperty;var t=(r,e)=>a(r,"name",{value:e,configurable:!0});import{apiFetch as i}from"./client.js";import{buildProfileBody as f,rethrowCaptureSettingsSkew as h}from"./upload.js";const c=t(async(r,e)=>{try{return await i(r,{method:"POST",path:"/profile/refresh",rawBody:f(e)})}catch(o){return h(o,r.server)}},"refreshProfile");export{c as refreshProfile};
|
package/build/api/upload.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var s=Object.defineProperty;var i=(t,e)=>s(t,"name",{value:e,configurable:!0});import{apiFetch as n}from"./client.js";import{ApiError as o}from"../errors.js";import{version as a}from"../version.js";const d=i(t=>{const e=t.serialized??JSON.stringify(t.state),r=t.captureSettings===void 0?"":`,"captureSettings":${JSON.stringify(t.captureSettings)}`;return`{"name":${JSON.stringify(t.name)},"state":${e}${r}}`},"buildProfileBody"),p=i((t,e)=>{throw!(t instanceof o)||t.status!==400||!/additional propert/i.test(`${t.body??""} ${t.message}`)?t:new o(`The server at ${e} rejected the profile capture settings this CLI (v${a}) sends \u2014 it predates either the field itself or one of its members. Deploy the server to every region before using this CLI against it. Server said: ${t.message}`,400,t.body)},"rethrowCaptureSettingsSkew"),u=i(async(t,e)=>{try{return await n(t,{method:"POST",path:"/profile/upload",rawBody:d(e)})}catch(r){return p(r,t.server)}},"uploadProfile");export{d as buildProfileBody,p as rethrowCaptureSettingsSkew,u as uploadProfile};
|
package/build/auth/store.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var t=(e,
|
|
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,21 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
`)
|
|
3
|
-
|
|
4
|
-
`))}const
|
|
5
|
-
`),
|
|
6
|
-
`)}if(
|
|
7
|
-
`),
|
|
8
|
-
`);
|
|
9
|
-
`)}if(
|
|
10
|
-
`),
|
|
11
|
-
`)
|
|
12
|
-
`)
|
|
13
|
-
`)
|
|
14
|
-
`)
|
|
15
|
-
`)
|
|
16
|
-
`)}
|
|
17
|
-
`);
|
|
18
|
-
`)
|
|
1
|
+
var B=Object.defineProperty;var l=(e,t)=>B(e,"name",{value:t,configurable:!0});import{resolveProfile as A}from"../browsers/discover.js";import{captureFromProfile as I}from"../capture/index.js";import{applyOnlyFilter as L,mergeExclusionPatterns as R,normalizeExclusion as y}from"../capture/exclusion.js";import{readConfig as P}from"../config/store.js";import{ensureTermsAccepted as z}from"../auth/disclaimer.js";import{UsageError as _}from"../errors.js";import{version as G}from"../version.js";import{collectRepeated as k,parseNonNegativeInt as M}from"./client.js";import{formatBytes as u,measureOriginSizes as j,SERVER_ARTIFACT_CAP_BYTES as x,trimStateToFit as U}from"./trim-state.js";const ne=l((e,t={})=>{const s=t.sourceOptional?e.option.bind(e):e.requiredOption.bind(e),o=t.sourceOptional?". Optional here \u2014 read from the profile's stored settings when omitted":"";return s("--browser <key>",`Source browser key (chrome / brave / edge / ...) or display name${o}`),s("--profile <name>",`Source profile display name or directory (e.g. "Personal", "Default")${o}`),e.option("--exclude-domain <domain>","Append a domain to the exclusion list for this run (repeatable)",k).option("--no-default-excludes","Skip the persistent exclusion list for this run").option("--accept-terms","Pre-accept the liability disclaimer").option("--terms-ttl-days <n>","Override the disclaimer re-prompt TTL for this run").option("--password-store <store>","Linux only: --password-store value to pass through to the headless launch (basic / gnome-libsecret / kwallet5 / ...)").option("--auto-fit","If the captured artifact exceeds the 2 MB server cap, drop the heaviest origins (largest serialized contribution first) until it fits").option("--keep-domain <domain>","Domain that --auto-fit must never drop (suffix-match, same syntax as --exclude-domain; repeatable)",k).option("--only-domain <domain>","Capture only cookies / origins matching this domain \u2014 discard everything else (suffix-match; repeatable; applies after --exclude-domain)",k)},"addCaptureFlags"),H=l(e=>{if(e.length>0&&!e.some(t=>y(t)!==null))throw new _(`--only-domain: no valid domain pattern in ${JSON.stringify(e)}. Use a hostname like "example.com" or "*.example.com".`)},"validateOnlyDomain"),b=100,J=253,v=255,C=8*1024,K=/[$`\\!\u0000-\u001f\u007f]/,X=/^[A-Za-z0-9*._-]+$/,S=l((e,t)=>{process.stderr.write(` \u2192 Not storing ${e} for refresh (${t}); a later flagless \`profile refresh\` of this profile will not replay it
|
|
2
|
+
`)},"warnDropped"),Y=l(e=>{const t=`they serialize past the server's ${C}-byte limit`;process.stderr.write(e==="upload"?` \u2192 Not storing any capture settings (${t}); a later flagless \`profile refresh\` of this profile will have nothing to replay
|
|
3
|
+
`:` \u2192 Not updating the stored capture settings (${t}); whatever this profile already had is left as it was, so it no longer matches this run and a later flagless \`profile refresh\` will not reflect these filters. Shorten the domain lists to update them
|
|
4
|
+
`)},"warnOverCap"),O=l((e,t)=>{const s=t?.trim();if(s){if(K.test(s)){S(`--${e}`,"it contains characters a shell would interpret");return}if(s.length>v){S(`--${e}`,`it exceeds ${v} characters`);return}return s}},"safeScalar"),T=l((e,t,s=!1)=>{const o=[...new Set((t??[]).map(d=>y(d)).filter(d=>d!==null))],n=o.filter(d=>d.length<=J&&X.test(d));return n.length<o.length&&S(`${o.length-n.length} of ${o.length} --${e} patterns`,"the server only stores plain hostname patterns"),n.length?(n.length>b&&S(`${n.length-b} of ${n.length} --${e} patterns`,`the server stores at most ${b}`),n.slice(0,b)):s&&!(t??[]).length?[]:void 0},"safeDomains"),m=l((e,t)=>t===void 0?{}:{[e]:t},"withKey"),ae={browser:"browser",profile:"profile",excludeDomains:"excludeDomain",onlyDomains:"onlyDomain",keepDomains:"keepDomain",autoFit:"autoFit",passwordStore:"passwordStore"},le=l((e,t,s)=>{const o={...m("browser",O("browser",e.browser)),...m("profile",O("profile",e.profile)),...m("excludeDomains",T("exclude-domain",t.excludedDomains,e.defaultExcludes===!1)),...m("onlyDomains",T("only-domain",e.onlyDomain)),...m("keepDomains",T("keep-domain",e.keepDomain)),...e.autoFit?{autoFit:!0}:{},...m("passwordStore",O("password-store",e.passwordStore)),cliVersion:G};if(Buffer.byteLength(JSON.stringify(o),"utf8")>C){Y(s);return}return o},"buildCaptureSettings"),q=l(e=>{(e??[]).filter(t=>y(t)===null).forEach(t=>{process.stderr.write(` ! --exclude-domain ${JSON.stringify(t)} is not a usable domain pattern \u2014 nothing was excluded for it
|
|
5
|
+
`)})},"warnUnusableExcludes"),de=l((e,t)=>{if(!t)return e;const s=e.defaultExcludes===!1,o=(e.excludeDomain??[]).some(d=>y(d)!==null),n=!o&&t.excludeDomains!==void 0;return{...e,browser:e.browser??t.browser,profile:e.profile??t.profile,passwordStore:e.passwordStore??t.passwordStore,excludeDomain:o?e.excludeDomain:s?[]:t.excludeDomains,onlyDomain:e.onlyDomain??t.onlyDomains,keepDomain:e.keepDomain??t.keepDomains,autoFit:e.autoFit??t.autoFit,defaultExcludes:n?!1:e.defaultExcludes}},"mergeStoredSettings"),pe=l((e,t,s={})=>{if(!t)return;const o=l(g=>process.stderr.write(`${g}
|
|
6
|
+
`),"w"),n=s.userOptedOut===!0;o("> Refreshing with these effective settings:"),e.browser&&o(` --browser ${e.browser}`),e.profile&&o(` --profile ${e.profile}`);const d=(e.excludeDomain??[]).filter(g=>y(g)!==null);d.length&&o(` --exclude-domain ${d.join(", ")}`),e.onlyDomain?.length&&(o(` --only-domain ${e.onlyDomain.join(", ")}`),o(" ! only these domains are captured \u2014 everything else in the saved"),o(" profile is replaced, not kept")),e.keepDomain?.length&&o(` --keep-domain ${e.keepDomain.join(", ")}`),e.autoFit&&o(" --auto-fit (only acts if the capture exceeds the 2 MB cap)"),e.passwordStore&&o(` --password-store ${e.passwordStore}`),n&&o(" --no-default-excludes");const D=n&&!d.length,c=t.excludeDomains?.length;D&&c&&(o(` ! --no-default-excludes drops the ${c} stored exclusion pattern(s) for this run,`),o(" and re-pass --exclude-domain if you want to keep them.")),D?(o(" ! Unless the settings exceed the 8 KB cap (reported after the capture), the"),o(" refreshed profile is stored with NO exclusion list, so later flagless refreshes"),o(" replay 'exclude nothing' and stop applying this machine's config.")):n?(o(" ! --no-default-excludes is in force: ONLY the --exclude-domain patterns above"),o(" are excluded, and this machine's own config is not applied.")):c===void 0&&(o(" (no stored exclusion list \u2014 this machine's own config applies)"),o(" This run stores the effective list on the profile, so later flagless refreshes"),o(" replay that snapshot instead of re-reading this config.")),o(" Pass --browser, --profile, --password-store or a domain flag to override."),n||(o(c===void 0?" --exclude-domain adds to this machine's config for this run; there is no stored list to replace.":" --exclude-domain replaces the stored list and re-applies this machine's config."),c&&o(" --no-default-excludes drops the stored list for good."))},"printEffectiveSettings"),ce=l(async e=>{const{flags:t,requiresDisclaimer:s}=e;if(!t.browser||!t.profile){const r=[t.browser?null:"--browser",t.profile?null:"--profile"].filter(Boolean);throw new _(`${r.join(" and ")} ${r.length>1?"are":"is"} required: this profile has no stored capture settings to read them from (it was not created by the CLI, or this server does not return them yet)`)}const o=await A(t.browser,t.profile);s&&await z({acceptViaFlag:!!t.acceptTerms,ttlDaysOverride:t.termsTtlDays!==void 0?M("--terms-ttl-days",t.termsTtlDays):void 0});const n=await P(),d=R(n.excluded_domains,t.excludeDomain,t.defaultExcludes===!1);H(t.onlyDomain??[]),q(t.excludeDomain),process.stderr.write(`> Capturing ${o.browserDisplayName} / ${o.profileDisplayName}
|
|
7
|
+
`);const D=5,c=l(r=>{process.stderr.write(` ${r}
|
|
8
|
+
`)},"writeLine"),g={copying:"copying profile data\u2026",launching:"launching headless browser\u2026","waiting-for-debugger":"waiting for browser to be ready\u2026"};let $="",N=0;const F={profile:o,excludedDomains:d,onlyDomains:t.onlyDomain??[],passwordStoreOverride:t.passwordStore,onProgress:l(r=>{if(r.phase!=="done"){if(r.phase==="capturing-origins"){if(r.attempted===0){$!=="capturing-origins"&&($="capturing-origins",c("capturing per-origin storage\u2026"));return}if(!(r.attempted===r.total)&&r.attempted-N<D)return;N=r.attempted;const f=r.origin.length>50?r.origin.slice(0,47)+"\u2026":r.origin;c(` ${r.attempted}/${r.total} ${f}`);return}r.phase!==$&&($=r.phase,c(g[r.phase]??r.phase))}},"onProgress")},a=await I(F);if(t.onlyDomain&&t.onlyDomain.length>0){const r=L(a.state,t.onlyDomain),f=a.state.cookies.length-r.state.cookies.length,i=a.diagnostics.originCountSkippedByOnlyDomain+r.originsDropped;(f>0||i>0)&&(a.state=r.state,a.serialized=JSON.stringify(r.state),process.stderr.write(` \u2192 --only-domain kept ${a.state.cookies.length} cookies / ${a.state.origins.length} origins; dropped ${f} cookies / ${i} origins not matching: ${t.onlyDomain.join(", ")}
|
|
9
|
+
`))}const p=a.diagnostics,E=Buffer.byteLength(a.serialized,"utf-8");if(process.stderr.write(`> Captured ${p.cookieCountBeforeExclusion} cookies, ${p.originCountBeforeExclusion} origins in ${p.durationMs}ms (artifact: ${u(E)})
|
|
10
|
+
`),p.cookieCountExcluded>0||p.originCountExcluded>0){const r=p.excludedDomains.length?p.excludedDomains.join(", "):"(none)";process.stderr.write(` \u2192 Excluded ${p.cookieCountExcluded} cookies / ${p.originCountExcluded} origins matching: ${r}
|
|
11
|
+
`)}if(a.capHit&&process.stderr.write(` ! Hit the per-capture origin cap \u2014 some origins may be missing
|
|
12
|
+
`),p.failedOrigins.length>0){process.stderr.write(` ! ${p.failedOrigins.length} origin(s) failed to capture \u2014 their localStorage / IndexedDB is missing from the upload:
|
|
13
|
+
`);for(const r of p.failedOrigins)process.stderr.write(` - ${r.origin}: ${r.error}
|
|
14
|
+
`)}if(a.passwordStoreDefaulted&&process.stderr.write(` ! Linux password-store could not be detected \u2014 defaulted to "basic". If decryption failed, re-run with --password-store=<your store>
|
|
15
|
+
`),E>x){const r=j(a.state),h=10;process.stderr.write(` ! artifact size ${u(E)} exceeds the ${u(x)} server cap \u2014 heaviest origins:
|
|
16
|
+
`);for(const{origin:f,bytes:i}of r.slice(0,h))process.stderr.write(` ${u(i).padStart(10)} ${f}
|
|
17
|
+
`);if(r.length>h&&process.stderr.write(` \u2026 and ${r.length-h} more origins below ${u(r[h].bytes)}
|
|
18
|
+
`),t.autoFit){const f=t.keepDomain??[],i=U(a.state,x,f);if(i.dropped.length===0&&i.finalBytes<=x)process.stderr.write(` ! --auto-fit had nothing to drop \u2014 artifact unchanged
|
|
19
|
+
`);else{if(a.state=i.state,a.serialized=i.serialized,p.failedOrigins=[...p.failedOrigins,...i.dropped.map(w=>({origin:w,error:"dropped by --auto-fit to fit under the server cap",kind:"unknown"}))],i.dropped.length>0){process.stderr.write(` --auto-fit: dropped ${i.dropped.length} origin(s), now ${u(i.finalBytes)}:
|
|
20
|
+
`);for(const w of i.dropped)process.stderr.write(` - ${w}
|
|
21
|
+
`)}if(i.protectedFromDrop.length>0){process.stderr.write(` --auto-fit: ${i.protectedFromDrop.length} heavy origin(s) protected by --keep-domain:
|
|
22
|
+
`);for(const w of i.protectedFromDrop)process.stderr.write(` - ${w}
|
|
23
|
+
`)}i.finalBytes>x&&(i.protectedFromDrop.length>0?process.stderr.write(` ! Still ${u(i.finalBytes)} after the trim \u2014 the --keep-domain origins alone exceed the cap. Remove one or more --keep-domain entries, or accept the upload will be rejected.
|
|
19
24
|
`):process.stderr.write(` ! Even after dropping every droppable origin the artifact is still over cap. The cookies alone may be too heavy.
|
|
20
25
|
`))}}else process.stderr.write(` Re-run with --auto-fit to drop the heaviest origins automatically (combine with --keep-domain <domain> to protect specific sites; or --only-domain <domain> to capture just those), or pass --exclude-domain <host> for each you want removed.
|
|
21
|
-
`)}return
|
|
26
|
+
`)}return a},"runCapture");export{ae as SETTINGS_REPLAY_SOURCE,ne as addCaptureFlags,le as buildCaptureSettings,de as mergeStoredSettings,pe as printEffectiveSettings,ce as runCapture,H as validateOnlyDomain,q as warnUnusableExcludes};
|
package/build/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as
|
|
3
|
-
`):
|
|
4
|
-
`):process.stderr.write(`${String(
|
|
5
|
-
`),process.exitCode=p(
|
|
2
|
+
import{Command as t}from"commander";import{version as i}from"./version.js";import{registerProfile as n}from"./commands/profile/index.js";import{registerAuth as a}from"./commands/auth/index.js";import{registerConfig as m}from"./commands/config/index.js";import{registerAgent as c}from"./commands/agent/index.js";import{errorCodeOf as p,exitCodeFor as f,UserFacingError as d}from"./errors.js";import*as r from"./telemetry/index.js";const o=new t;o.name("browserless").description("Browserless CLI \u2014 manage profiles, sessions, and more.").version(i),n(o),a(o),m(o),c(o),o.hook("preAction",(e,s)=>{try{r.begin(s)}catch{}}),o.hook("postAction",async()=>{try{await r.complete({status:"ok",exitCode:0})}catch{}}),o.parseAsync(process.argv).catch(async e=>{e instanceof d?process.stderr.write(`${e.message}
|
|
3
|
+
`):e instanceof Error?process.stderr.write(`${e.stack??e.message}
|
|
4
|
+
`):process.stderr.write(`${String(e)}
|
|
5
|
+
`),process.exitCode=f(e);try{await r.complete({status:"error",exitCode:process.exitCode,errorName:e instanceof Error?e.name:void 0,errorCode:p(e)})}catch{}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var t=(o,e)=>c(o,"name",{value:e,configurable:!0});import{resolveServer as d,persistToken as f}from"../../auth/store.js";import{validateToken as m}from"../../api/auth.js";import{addServerOverrideFlags as k}from"../../cli-utils/client.js";import{PreconditionError as i}from"../../errors.js";const
|
|
1
|
+
var c=Object.defineProperty;var t=(o,e)=>c(o,"name",{value:e,configurable:!0});import{resolveServer as d,persistToken as f}from"../../auth/store.js";import{validateToken as m}from"../../api/auth.js";import{addServerOverrideFlags as k}from"../../cli-utils/client.js";import{PreconditionError as i}from"../../errors.js";import{recordToken as l}from"../../telemetry/token-cache.js";const v=t(async()=>{const o=[];for await(const e of process.stdin)o.push(Buffer.from(e));return Buffer.concat(o).toString("utf-8").trim()},"readFromStdin"),g=t(async(o,e)=>{const r=await d({server:e.server,region:e.region});let n=o?.trim();if(!n){if(process.stdin.isTTY)throw new i("Pass the token as an argument or pipe it via stdin: `echo $TOKEN | browserless auth login`","no-token");n=await v()}if(!n)throw new i("No token provided.","no-token");if(!await m({server:r,token:n}))throw new i(`Token rejected by ${r} \u2014 double-check it and retry.`,"invalid-token");l({token:n,server:r});const{mode:a,warning:s}=await f({server:r,token:n});console.log(a==="keychain"?`\u2713 Token saved to OS keychain for ${r}`:`\u2713 Token saved to ~/.browserless/config.json for ${r}`),s&&console.log(`! ${s}`)},"action"),$=t(o=>{const e=o.command("login [token]").description("Validate and persist an API token (reads from stdin if no argument is given)");k(e).action(g)},"registerAuthLogin");export{$ as registerAuthLogin};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);const
|
|
1
|
+
var l=Object.defineProperty;var n=(e,r)=>l(e,"name",{value:r,configurable:!0});import{addClientFlags as c,buildClient as d,printJson as u}from"../../cli-utils/client.js";import{addCaptureFlags as f,buildCaptureSettings as g,mergeStoredSettings as p,printEffectiveSettings as m,runCapture as h}from"../../cli-utils/capture-runner.js";import{getProfile as C}from"../../api/profiles.js";import{refreshProfile as S}from"../../api/refresh.js";const $=n(async e=>{const r=await d(e),s=await C(r,e.name),a=e.defaultExcludes===!1,i=p(e,s.captureSettings);m(i,s.captureSettings,{userOptedOut:a});const o=await h({flags:i,requiresDisclaimer:!0});process.stderr.write(`> Refreshing profile "${e.name}" on ${r.server}
|
|
2
|
+
`);const t=await S(r,{name:e.name,state:o.state,serialized:o.serialized,captureSettings:g(i,o.diagnostics,"refresh")});if(e.json){u(t);return}console.log(`\u2713 Profile "${t.name}" refreshed`),console.log(` id: ${t.id}`),console.log(` cookies: ${t.cookieCount}`),console.log(` origins: ${t.originCount}`),console.log(` updated: ${t.updatedAt}`)},"action"),k=n(e=>{const r=e.command("refresh").description("Capture a local browser profile and replace an existing cloud profile in place").requiredOption("--name <name>","Name of the existing cloud profile to refresh");f(c(r),{sourceOptional:!0}).action($)},"registerRefresh");export{k as registerRefresh};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);const
|
|
1
|
+
var t=Object.defineProperty;var r=(e,o)=>t(e,"name",{value:o,configurable:!0});import{addClientFlags as n,buildClient as l,printJson as s}from"../../cli-utils/client.js";import{addCaptureFlags as c,buildCaptureSettings as d,runCapture as u}from"../../cli-utils/capture-runner.js";import{uploadProfile as p}from"../../api/upload.js";const m=r(async e=>{const o=await u({flags:e,requiresDisclaimer:!0}),a=await l(e);process.stderr.write(`> Uploading to ${a.server}
|
|
2
|
+
`);const i=await p(a,{name:e.name,state:o.state,serialized:o.serialized,captureSettings:d(e,o.diagnostics,"upload")});if(e.json){s(i);return}console.log(`\u2713 Profile "${i.name}" uploaded`),console.log(` id: ${i.id}`),console.log(` cookies: ${i.cookieCount}`),console.log(` origins: ${i.originCount}`),console.log(` created: ${i.createdAt}`)},"action"),$=r(e=>{const o=e.command("upload").description("Capture a local browser profile and upload it as a new cloud profile").requiredOption("--name <name>","Name for the new cloud profile");c(n(o)).action(m)},"registerUpload");export{$ as registerUpload};
|
package/build/config/schema.js
CHANGED
|
@@ -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
|
|
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};
|
package/build/errors.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=Object.defineProperty;var t=(e,r)=>n(e,"name",{value:r,configurable:!0});class s extends Error{static{t(this,"UserFacingError")}exitCode=1;constructor(r){super(r),this.name="UserFacingError"}}class d extends s{static{t(this,"UsageError")}constructor(r){super(r),this.name="UsageError",this.exitCode=2}}class a extends s{static{t(this,"PreconditionError")}code;constructor(r,o){super(r),this.code=o,this.name="PreconditionError",this.exitCode=3}}class x extends s{static{t(this,"CaptureError")}code;constructor(r,o){super(r),this.code=o,this.name="CaptureError",this.exitCode=4}}class p extends s{static{t(this,"ApiError")}status;body;constructor(r,o,i){super(r),this.status=o,this.body=i,this.name="ApiError",this.exitCode=5}}const u=t(e=>e instanceof s?e.exitCode:1,"exitCodeFor"),h=t(e=>{if(e&&typeof e=="object"){const r=e.code;if(typeof r=="string"&&r.length>0)return r}},"errorCodeOf");export{p as ApiError,x as CaptureError,a as PreconditionError,d as UsageError,s as UserFacingError,h as errorCodeOf,u as exitCodeFor};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=Object.defineProperty;var o=(e,t)=>r(e,"name",{value:t,configurable:!0});const s=o(e=>{const t=[];let n=e;for(;n&&n.parent;)t.unshift(n.name()),n=n.parent;return t.join(" ")},"commandPath"),c=o(e=>Object.keys(e.opts()).filter(t=>e.getOptionValueSource(t)==="cli"),"usedFlagNames");export{s as commandPath,c as usedFlagNames};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.defineProperty;var a=(t,e)=>f(t,"name",{value:e,configurable:!0});import{randomUUID as d}from"node:crypto";import r from"node:fs/promises";import c from"node:path";import{configDir as m}from"../config/paths.js";const n=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,s=a(()=>c.join(m(),"telemetry-device-id"),"deviceIdFile"),y=a(async()=>{const t=s();try{const i=(await r.readFile(t,"utf8")).trim();if(n.test(i))return i}catch{}const e=d();try{return await r.mkdir(c.dirname(t),{recursive:!0,mode:448}),await r.writeFile(t,e,{flag:"wx",mode:384}),e}catch(i){if(i?.code!=="EEXIST")return e;try{const o=(await r.readFile(t,"utf8")).trim();return n.test(o)?o:(await r.writeFile(t,e,{mode:384}),await r.chmod(t,384).catch(()=>{}),e)}catch{return e}}},"getOrCreateDeviceId");export{y as getOrCreateDeviceId};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var f=Object.defineProperty;var t=(e,r)=>f(e,"name",{value:r,configurable:!0});import{performance as a}from"node:perf_hooks";import{readConfig as u}from"../config/store.js";import{REGION_URLS as E,KNOWN_REGIONS as _,isKnownRegion as l}from"../regions.js";import{version as v}from"../version.js";import{commandPath as g,usedFlagNames as R}from"./command-meta.js";import{getRecordedToken as h}from"./token-cache.js";import{getOrCreateDeviceId as T}from"./device-id.js";import{postCliEvents as S}from"./api.js";const w="CLI Command Run",i=t(e=>e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false","isTruthyEnv"),y=t(()=>{const e=Number(process.env.BROWSERLESS_TELEMETRY_TIMEOUT_MS);return e>0?e:2e3},"flushTimeoutMs"),s=t(e=>{i(process.env.BROWSERLESS_TELEMETRY_DEBUG)&&process.stderr.write(`[telemetry] ${e}
|
|
2
|
+
`)},"debug");let c;const L=t(async()=>{if(i(process.env.BROWSERLESS_TELEMETRY_DISABLED)||i(process.env.DO_NOT_TRACK))return!1;try{const e=await u();return e.telemetry===void 0||e.telemetry===!0}catch{return!1}},"isEnabled"),W=t(e=>{c={command:g(e),flags:R(e),startedAt:a.now()}},"begin"),N=t(e=>{let r;try{r=new URL(e).origin}catch{return"custom"}return _.find(o=>{try{return new URL(E[o]).origin===r}catch{return!1}})??"custom"},"bucketServerUrl"),k=t(()=>Number(process.versions.node.split(".")[0])||0,"nodeMajor"),C=t((e,r,n,o)=>{const d={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(a.now()-e.startedAt),cli_version:v,os:process.platform,arch:process.arch,node_major:k(),is_ci:i(process.env.CI),server_region:n,cli_device_id:o};return{event_type:w,time:Date.now(),event_properties:d}},"buildEvent"),G=t(async e=>{const r=c;if(c=void 0,!!r)try{if(!await L()){s("skipped: telemetry disabled");return}const n=h();if(!n){s("skipped: no token resolved this run");return}const o=N(n.server);if(!l(o)){s("skipped: non-cloud server");return}const d=await T(),m=C(r,e,o,d),p=await S([m],{token:n.token,timeoutMs:y()});s(p?`sent (${o})`:`send failed (${o})`)}catch{s("skipped: error while flushing")}},"complete"),K=t(()=>{c=void 0},"_resetForTests");export{K as _resetForTests,W as begin,N as bucketServerUrl,G as complete,y as flushTimeoutMs,L as isEnabled};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var e=(o,t)=>d(o,"name",{value:t,configurable:!0});let r;const c=e(o=>{r=o},"recordToken"),s=e(()=>r,"getRecordedToken"),T=e(()=>{r=void 0},"_resetRecordedTokenForTests");export{T as _resetRecordedTokenForTests,s as getRecordedToken,c as recordToken};
|
package/build/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const o="0.
|
|
1
|
+
const o="0.3.0";export{o as version};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserless.io/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Browserless CLI — manage authentication profiles, sessions, and other Browserless features from your terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -32,10 +32,12 @@
|
|
|
32
32
|
"fixture:build": "npm run build && node scripts/build-fixture-profile.js",
|
|
33
33
|
"verify:platform": "bash scripts/verify-cross-platform.sh",
|
|
34
34
|
"clean": "node scripts/clean.mjs",
|
|
35
|
-
"prepack": "npm run build:publish && node scripts/minify-build.mjs && node scripts/strip-test-artifacts.mjs"
|
|
35
|
+
"prepack": "npm run build:publish && node scripts/minify-build.mjs && node scripts/strip-test-artifacts.mjs",
|
|
36
|
+
"prepare": "husky"
|
|
36
37
|
},
|
|
37
38
|
"engines": {
|
|
38
|
-
"node": ">=24"
|
|
39
|
+
"node": ">=24",
|
|
40
|
+
"npm": ">=11.10.0"
|
|
39
41
|
},
|
|
40
42
|
"mocha": {
|
|
41
43
|
"spec": "build/**/*.spec.js",
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
"dependencies": {
|
|
46
48
|
"chrome-remote-interface": "^0.34.0",
|
|
47
49
|
"commander": "^15.0.0",
|
|
48
|
-
"ws": "^8.21.
|
|
50
|
+
"ws": "^8.21.1"
|
|
49
51
|
},
|
|
50
52
|
"optionalDependencies": {
|
|
51
53
|
"@napi-rs/keyring": "^1.3.0"
|
|
@@ -55,18 +57,20 @@
|
|
|
55
57
|
"@types/chai": "^5.2.3",
|
|
56
58
|
"@types/chrome-remote-interface": "^0.34.0",
|
|
57
59
|
"@types/mocha": "^10.0.10",
|
|
58
|
-
"@types/node": "^
|
|
59
|
-
"@types/sinon": "^
|
|
60
|
+
"@types/node": "^26.1.2",
|
|
61
|
+
"@types/sinon": "^22.0.0",
|
|
60
62
|
"@types/ws": "^8.18.1",
|
|
61
63
|
"chai": "^6.2.2",
|
|
62
|
-
"esbuild": "^0.28.
|
|
63
|
-
"eslint": "^10.
|
|
64
|
-
"globals": "^17.
|
|
64
|
+
"esbuild": "^0.28.1",
|
|
65
|
+
"eslint": "^10.8.0",
|
|
66
|
+
"globals": "^17.8.0",
|
|
67
|
+
"husky": "^9.1.7",
|
|
68
|
+
"lint-staged": "^17.3.0",
|
|
65
69
|
"mocha": "^11.7.6",
|
|
66
|
-
"prettier": "
|
|
67
|
-
"sinon": "^22.
|
|
70
|
+
"prettier": "3.9.6",
|
|
71
|
+
"sinon": "^22.1.0",
|
|
68
72
|
"typescript": "^6.0.3",
|
|
69
|
-
"typescript-eslint": "^8.
|
|
73
|
+
"typescript-eslint": "^8.65.0"
|
|
70
74
|
},
|
|
71
75
|
"overrides": {
|
|
72
76
|
"mocha": {
|
|
@@ -74,5 +78,14 @@
|
|
|
74
78
|
"serialize-javascript": "^7.0.5",
|
|
75
79
|
"glob": "^13.0.0"
|
|
76
80
|
}
|
|
81
|
+
},
|
|
82
|
+
"lint-staged": {
|
|
83
|
+
"**/*": "prettier --write --ignore-unknown"
|
|
84
|
+
},
|
|
85
|
+
"prettier": {
|
|
86
|
+
"semi": true,
|
|
87
|
+
"trailingComma": "all",
|
|
88
|
+
"singleQuote": true,
|
|
89
|
+
"printWidth": 80
|
|
77
90
|
}
|
|
78
91
|
}
|