bexxcv 0.0.0-stage → 1.0.1
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/README.md +493 -2
- package/dist/__main__.d.ts +2 -0
- package/dist/__main__.js +156 -0
- package/dist/__version__.d.ts +5 -0
- package/dist/__version__.js +5 -0
- package/dist/addons.d.ts +7 -0
- package/dist/addons.js +56 -0
- package/dist/browser-pin.d.ts +15 -0
- package/dist/browser-pin.js +34 -0
- package/dist/data-files/browser-pin.json +7 -0
- package/dist/data-files/territoryInfo.xml +2024 -0
- package/dist/exceptions.d.ts +79 -0
- package/dist/exceptions.js +159 -0
- package/dist/fingerprints.d.ts +5 -0
- package/dist/fingerprints.js +92 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/ip.d.ts +23 -0
- package/dist/ip.js +98 -0
- package/dist/locale.d.ts +26 -0
- package/dist/locale.js +292 -0
- package/dist/mappings/browserforge.config.d.ts +44 -0
- package/dist/mappings/browserforge.config.js +43 -0
- package/dist/mappings/fonts.config.d.ts +6 -0
- package/dist/mappings/fonts.config.js +822 -0
- package/dist/mappings/warnings.config.d.ts +16 -0
- package/dist/mappings/warnings.config.js +28 -0
- package/dist/multiversion.d.ts +27 -0
- package/dist/multiversion.js +88 -0
- package/dist/pkgman.d.ts +69 -0
- package/dist/pkgman.js +529 -0
- package/dist/selfupdate.d.ts +8 -0
- package/dist/selfupdate.js +84 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +6 -0
- package/dist/sync_api.d.ts +11 -0
- package/dist/sync_api.js +47 -0
- package/dist/utils.d.ts +45 -0
- package/dist/utils.js +514 -0
- package/dist/virtdisplay.d.ts +12 -0
- package/dist/virtdisplay.js +139 -0
- package/dist/warnings.d.ts +4 -0
- package/dist/warnings.js +33 -0
- package/dist/webgl/sample.d.ts +19 -0
- package/dist/webgl/sample.js +107 -0
- package/dist/xvfb.d.ts +6 -0
- package/dist/xvfb.js +25 -0
- package/package.json +103 -5
package/README.md
CHANGED
|
@@ -1,3 +1,494 @@
|
|
|
1
|
-
#
|
|
1
|
+
# bexxcv
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
High-performance stealth Firefox automation built on top of [Camoufox](https://github.com/daijro/camoufox).
|
|
4
|
+
|
|
5
|
+
> **Fork notice:** Forked from [camoufox-js](https://github.com/apify/camoufox-js) by [Apify](https://github.com/apify). Full credit to the original authors for the architecture, fingerprint generation pipeline, and Playwright integration. This fork adds performance upgrades, fingerprint hardening, ergonomic improvements, and zero-config Xvfb.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What's different from camoufox-js
|
|
10
|
+
|
|
11
|
+
| Area | Original | bexxcv |
|
|
12
|
+
|---|---|---|
|
|
13
|
+
| IP resolution | Sequential fallback (up to 6s on cold start) | `Promise.any()` — all endpoints race, fastest wins |
|
|
14
|
+
| Fingerprint seeds | `Math.random()` | `crypto.getRandomValues()` — cryptographic entropy everywhere |
|
|
15
|
+
| `canvas:aaOffset` | `Math.random()` | `crypto.getRandomValues()` |
|
|
16
|
+
| `window.history.length` | Flat distribution 1–5 | Weighted toward 1–2, tapering off (mirrors real sessions) |
|
|
17
|
+
| `window.devicePixelRatio` | Not injected (always 1.0) | Injected per-OS based on real-world telemetry (2.0 on Mac, mixed on Windows) |
|
|
18
|
+
| Window position | Perfectly centered | Organic ±20px jitter + upper-biased Y (mirrors real user behavior) |
|
|
19
|
+
| Download retries | Flat 5s delay | Exponential backoff with jitter (2s → 4s → 8s → max 30s) |
|
|
20
|
+
| Screen detection | Always `undefined` | Reads actual monitor size via `xrandr` on Linux |
|
|
21
|
+
| IMPIT cache size | Hardcoded `8` | Configurable via `BEXXCV_IMPIT_CACHE` env var |
|
|
22
|
+
| Dead code | `_asyncAttachVD` was defined but never used | Removed |
|
|
23
|
+
| Xvfb trigger | `headless: "virtual"` only | `headless: false` **and** `headless: undefined` auto-start Xvfb when `$DISPLAY` is unset |
|
|
24
|
+
| Xvfb module | Internal only | Exported — `needsXvfb`, `startXvfb`, `withXvfb` |
|
|
25
|
+
| WebGL sampling | `Math.random()` for weighted choice | `crypto.getRandomValues()` |
|
|
26
|
+
| Main export | `Camoufox` | `bexxcv` (with `Camoufox` kept as alias) |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Requirements
|
|
31
|
+
|
|
32
|
+
- Node.js >= 22
|
|
33
|
+
- `playwright-core` < 1.63.0
|
|
34
|
+
- Linux headless: `Xvfb` (auto-installed suggestion below)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install bexxcv playwright-core
|
|
42
|
+
# or
|
|
43
|
+
pnpm add bexxcv playwright-core
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
After installing, fetch the Camoufox browser binary:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx bexxcv fetch
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Basic usage
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { bexxcv } from "bexxcv";
|
|
58
|
+
|
|
59
|
+
const browser = await bexxcv({ headless: true });
|
|
60
|
+
const page = await browser.newPage();
|
|
61
|
+
await page.goto("https://example.com");
|
|
62
|
+
await browser.close();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
On a headless Linux server with no `$DISPLAY` set, Xvfb starts automatically when `headless` is `false` or unset — no `xvfb-run` wrapper needed.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## All options
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
const browser = await bexxcv({
|
|
73
|
+
// --- Headless / display ---
|
|
74
|
+
headless: false, // false | true | "virtual"
|
|
75
|
+
auto_xvfb: true, // auto-start Xvfb when on Linux with no $DISPLAY
|
|
76
|
+
|
|
77
|
+
// --- OS targeting ---
|
|
78
|
+
os: "windows", // "linux" | "macos" | "windows" | array of those
|
|
79
|
+
|
|
80
|
+
// --- Fingerprint ---
|
|
81
|
+
fingerprint: undefined, // pass a custom Fingerprint object (from fingerprint-generator)
|
|
82
|
+
ff_version: undefined, // override Firefox version number in the UA
|
|
83
|
+
screen: undefined, // { maxWidth, maxHeight } — constrain generated screen size
|
|
84
|
+
window: undefined, // [width, height] — fix outer window dimensions
|
|
85
|
+
webgl_config: undefined, // [vendor, renderer] — pick a specific WebGL pair
|
|
86
|
+
|
|
87
|
+
// --- Network / locale ---
|
|
88
|
+
geoip: true, // true = detect public IP; string = use that IP for geolocation
|
|
89
|
+
locale: "en-US", // BCP 47 locale string or array
|
|
90
|
+
proxy: "http://user:pass@host:port",
|
|
91
|
+
|
|
92
|
+
// --- Privacy toggles ---
|
|
93
|
+
block_webrtc: false, // disable WebRTC (prevents IP leak via STUN)
|
|
94
|
+
block_images: false, // disable image loading (faster scraping, but detectable)
|
|
95
|
+
block_webgl: false, // disable WebGL entirely
|
|
96
|
+
disable_coop: false, // disable Cross-Origin-Opener-Policy (breaks some sites otherwise)
|
|
97
|
+
|
|
98
|
+
// --- Browser behavior ---
|
|
99
|
+
humanize: false, // true | number(ms) — add human-like random mouse delays
|
|
100
|
+
enable_cache: false, // enable disk + memory cache (off by default)
|
|
101
|
+
main_world_eval: false, // allow JS eval in main world
|
|
102
|
+
addons: [], // paths to Firefox extension XPIs to load
|
|
103
|
+
exclude_addons: [], // built-in addon keys to skip
|
|
104
|
+
fonts: [], // additional font names to inject
|
|
105
|
+
custom_fonts_only: false, // strip all built-in fonts, use only your list
|
|
106
|
+
|
|
107
|
+
// --- Low-level ---
|
|
108
|
+
executable_path: undefined, // path to a custom Firefox binary
|
|
109
|
+
firefox_user_prefs: {}, // raw Firefox about:config prefs
|
|
110
|
+
args: [], // extra CLI args passed to Firefox
|
|
111
|
+
env: {}, // extra env vars
|
|
112
|
+
debug: false, // print full config before launch
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### `headless`
|
|
117
|
+
|
|
118
|
+
| Value | Behavior |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `true` | Pure headless — no display of any kind needed |
|
|
121
|
+
| `false` (default) | Visible window. On Linux with no `$DISPLAY`, auto-starts Xvfb |
|
|
122
|
+
| `"virtual"` | Explicit virtual display — same as `false` + Xvfb, regardless of `$DISPLAY` |
|
|
123
|
+
|
|
124
|
+
### `auto_xvfb`
|
|
125
|
+
|
|
126
|
+
Controls automatic Xvfb lifecycle. Only relevant on Linux.
|
|
127
|
+
|
|
128
|
+
| Condition | Result |
|
|
129
|
+
|---|---|
|
|
130
|
+
| Linux, no `$DISPLAY`, `headless !== true`, `auto_xvfb: true` | Xvfb starts; display injected as `$DISPLAY` |
|
|
131
|
+
| Linux, `$DISPLAY` set | Real display used, Xvfb skipped |
|
|
132
|
+
| `headless: true` | No display needed at all, Xvfb never starts |
|
|
133
|
+
| `auto_xvfb: false` | You manage the display manually |
|
|
134
|
+
|
|
135
|
+
### `os`
|
|
136
|
+
|
|
137
|
+
Constrains the fingerprint generator to browsers that ran on the given OS. Accepts a single string or an array.
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
await bexxcv({ os: "windows" });
|
|
141
|
+
await bexxcv({ os: ["windows", "macos"] });
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
This affects UA string, navigator.platform, navigator.oscpu, screen dimensions, and font set.
|
|
145
|
+
|
|
146
|
+
### `geoip`
|
|
147
|
+
|
|
148
|
+
When `true`, bexxcv fetches the server's own public IP and uses it to align geolocation (timezone, locale, navigator.language, headers.Accept-Language).
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
await bexxcv({ geoip: true }); // detect public IP
|
|
152
|
+
await bexxcv({ geoip: "203.0.113.45" }); // use specific IP
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Requires the optional `geoip2` extra. Combine with `proxy` to align IP and geo to your proxy exit node:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
await bexxcv({
|
|
159
|
+
proxy: "socks5://user:pass@proxy.example.com:1080",
|
|
160
|
+
geoip: true,
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### `webgl_config`
|
|
165
|
+
|
|
166
|
+
Override the WebGL vendor/renderer pair used for fingerprinting.
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
await bexxcv({ webgl_config: ["Intel Inc.", "Intel Iris OpenGL Engine"] });
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Use `getPossiblePairs()` to list all valid combinations for each OS:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
import { launchOptions } from "bexxcv";
|
|
176
|
+
// or access via the webgl module directly:
|
|
177
|
+
import { getPossiblePairs } from "bexxcv/webgl"; // if you re-export it
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Persistent context
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import { bexxcv } from "bexxcv";
|
|
186
|
+
|
|
187
|
+
const context = await bexxcv({
|
|
188
|
+
user_data_dir: "./browser-profile",
|
|
189
|
+
headless: false,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const page = await context.newPage();
|
|
193
|
+
await page.goto("https://example.com");
|
|
194
|
+
await context.close();
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Xvfb module
|
|
200
|
+
|
|
201
|
+
bexxcv exports all Xvfb utilities so you can manage virtual displays in your own code:
|
|
202
|
+
|
|
203
|
+
```ts
|
|
204
|
+
import { needsXvfb, startXvfb, withXvfb } from "bexxcv";
|
|
205
|
+
// or from the sub-path export:
|
|
206
|
+
import { needsXvfb, startXvfb, withXvfb } from "bexxcv/xvfb";
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### `needsXvfb(): boolean`
|
|
210
|
+
|
|
211
|
+
Returns `true` when running on Linux with no `$DISPLAY` or `$WAYLAND_DISPLAY` set. Use this to branch logic before attempting a visible launch.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
if (needsXvfb()) {
|
|
215
|
+
console.log("No display — Xvfb will be used automatically.");
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### `startXvfb(debug?: boolean): Promise<{ display: string; kill: () => void }>`
|
|
220
|
+
|
|
221
|
+
Start a virtual display manually. Returns the display string (e.g. `:99`) and a `kill()` function.
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
const { display, kill } = await startXvfb();
|
|
225
|
+
console.log(`Virtual display: ${display}`);
|
|
226
|
+
|
|
227
|
+
// ... do work ...
|
|
228
|
+
|
|
229
|
+
kill();
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### `withXvfb<T>(fn: (display: string) => Promise<T>, debug?: boolean): Promise<T>`
|
|
233
|
+
|
|
234
|
+
Start a virtual display, run your callback, then kill the display automatically — even if the callback throws.
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
await withXvfb(async (display) => {
|
|
238
|
+
console.log(`Running on ${display}`);
|
|
239
|
+
// launch browsers, run tests, etc.
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### Opting out of auto-Xvfb
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
const browser = await bexxcv({
|
|
247
|
+
auto_xvfb: false,
|
|
248
|
+
headless: false,
|
|
249
|
+
});
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Manual virtual display
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
const browser = await bexxcv({
|
|
256
|
+
headless: "virtual",
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Fingerprint hardening internals
|
|
263
|
+
|
|
264
|
+
bexxcv applies several improvements over the base camoufox-js fingerprint pipeline:
|
|
265
|
+
|
|
266
|
+
### Crypto-grade randomness everywhere
|
|
267
|
+
|
|
268
|
+
All random values use `crypto.getRandomValues()`. `Math.random()` is excluded entirely. Detection tools can identify automation via statistical analysis of `Math.random()` output distribution — cryptographic CSPRNG output is indistinguishable from natural entropy.
|
|
269
|
+
|
|
270
|
+
Affected properties: fingerprint seed, canvas anti-aliasing offset, WebGL sampler, font spacing seed, audio seed, window position jitter.
|
|
271
|
+
|
|
272
|
+
### Realistic `window.history.length`
|
|
273
|
+
|
|
274
|
+
Real user sessions don't have uniformly distributed history depth. bexxcv uses a weighted distribution:
|
|
275
|
+
|
|
276
|
+
| History depth | Weight |
|
|
277
|
+
|---|---|
|
|
278
|
+
| 1 | 40% |
|
|
279
|
+
| 2 | 25% |
|
|
280
|
+
| 3 | 15% |
|
|
281
|
+
| 4 | 10% |
|
|
282
|
+
| 5 | 6% |
|
|
283
|
+
| 6 | 4% |
|
|
284
|
+
|
|
285
|
+
A flat 1–5 uniform distribution is a known automation signal.
|
|
286
|
+
|
|
287
|
+
### `window.devicePixelRatio` injection
|
|
288
|
+
|
|
289
|
+
Most automation frameworks report `devicePixelRatio = 1.0` universally. bexxcv injects a realistic DPR based on the target OS fingerprint:
|
|
290
|
+
|
|
291
|
+
| OS | Distribution |
|
|
292
|
+
|---|---|
|
|
293
|
+
| macOS | 2.0 × 70%, 1.0 × 20%, 1.5 × 10% |
|
|
294
|
+
| Windows | 1.0 × 45%, 1.25 × 20%, 1.5 × 20%, 2.0 × 15% |
|
|
295
|
+
| Linux | 1.0 × 75%, 2.0 × 15%, 1.5 × 10% |
|
|
296
|
+
|
|
297
|
+
### Organic window positioning
|
|
298
|
+
|
|
299
|
+
Perfect window centering (`screenX = (screenWidth - outerWidth) / 2`) is another automation signal. bexxcv applies:
|
|
300
|
+
- X: center offset ±20px random jitter, clamped to screen bounds
|
|
301
|
+
- Y: biased toward the upper 45% of usable height (real users don't center windows vertically)
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## CLI commands
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
npx bexxcv fetch # Download Camoufox binary
|
|
309
|
+
npx bexxcv remove # Remove Camoufox binary and GeoIP database
|
|
310
|
+
npx bexxcv version # Show installed version
|
|
311
|
+
npx bexxcv path # Print install directory
|
|
312
|
+
npx bexxcv test [url] # Open a test browser window
|
|
313
|
+
npx bexxcv server # Start a Playwright remote server
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Environment variables
|
|
319
|
+
|
|
320
|
+
| Variable | Description |
|
|
321
|
+
|---|---|
|
|
322
|
+
| `BEXXCV_IMPIT_CACHE` | Max size of the IMPIT instance LRU cache. Default: `8` |
|
|
323
|
+
| `CAMOUFOX_INSTALL_DIR` | Override install directory for the Camoufox binary |
|
|
324
|
+
| `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` | Set to `1` to skip binary download and use what's already cached |
|
|
325
|
+
| `GITHUB_TOKEN` | GitHub API token for higher rate limits during `fetch` |
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Exports
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
// Main entry — everything
|
|
333
|
+
import { bexxcv, Camoufox, NewBrowser, launchOptions, VirtualDisplay } from "bexxcv";
|
|
334
|
+
import type { BexxcvOptions, LaunchOptions } from "bexxcv";
|
|
335
|
+
|
|
336
|
+
// Xvfb utilities
|
|
337
|
+
import { needsXvfb, startXvfb, withXvfb } from "bexxcv/xvfb";
|
|
338
|
+
|
|
339
|
+
// VirtualDisplay class
|
|
340
|
+
import { VirtualDisplay } from "bexxcv/virtdisplay";
|
|
341
|
+
|
|
342
|
+
// Exception classes
|
|
343
|
+
import {
|
|
344
|
+
CannotFindXvfb,
|
|
345
|
+
CannotExecuteXvfb,
|
|
346
|
+
VirtualDisplayNotSupported,
|
|
347
|
+
CamoufoxNotInstalled,
|
|
348
|
+
UnsupportedVersion,
|
|
349
|
+
// ... etc
|
|
350
|
+
} from "bexxcv/exceptions";
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## Error troubleshooting
|
|
356
|
+
|
|
357
|
+
### `CannotFindXvfb` — Xvfb not installed
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
CannotFindXvfb: Xvfb not found. Install it with: sudo apt-get install xvfb
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
**Fix:**
|
|
364
|
+
```bash
|
|
365
|
+
# Debian / Ubuntu
|
|
366
|
+
sudo apt-get update && sudo apt-get install -y xvfb
|
|
367
|
+
|
|
368
|
+
# Alpine Linux
|
|
369
|
+
apk add xvfb-run
|
|
370
|
+
|
|
371
|
+
# Fedora / RHEL
|
|
372
|
+
dnf install xorg-x11-server-Xvfb
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
### `CamoufoxNotInstalled` — binary missing
|
|
378
|
+
|
|
379
|
+
```
|
|
380
|
+
CamoufoxNotInstalled: Camoufox is not installed. Please run `bexxcv fetch` to install.
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**Fix:**
|
|
384
|
+
```bash
|
|
385
|
+
npx bexxcv fetch
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Pre-provisioned binary (Docker / CI):
|
|
389
|
+
```bash
|
|
390
|
+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
|
391
|
+
CAMOUFOX_INSTALL_DIR=/path/to/your/binary
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
### `UnsupportedVersion` — outdated binary
|
|
397
|
+
|
|
398
|
+
```
|
|
399
|
+
UnsupportedVersion: Camoufox vX.Y.Z is not supported by this library.
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**Fix:**
|
|
403
|
+
```bash
|
|
404
|
+
npx bexxcv fetch
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
### `CorruptedDownload` — checksum mismatch
|
|
410
|
+
|
|
411
|
+
```
|
|
412
|
+
CorruptedDownload: Checksum mismatch for Camoufox vX.Y.Z
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
**Fix:**
|
|
416
|
+
```bash
|
|
417
|
+
npx bexxcv remove
|
|
418
|
+
npx bexxcv fetch
|
|
419
|
+
# or manually:
|
|
420
|
+
rm -rf ~/.cache/camoufox
|
|
421
|
+
npx bexxcv fetch
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
### `UnsupportedArchitecture` — platform not supported
|
|
427
|
+
|
|
428
|
+
Supported matrix:
|
|
429
|
+
|
|
430
|
+
| OS | Architectures |
|
|
431
|
+
|---|---|
|
|
432
|
+
| Linux | `x86_64`, `arm64`, `i686` |
|
|
433
|
+
| macOS | `x86_64`, `arm64` |
|
|
434
|
+
| Windows | `x86_64`, `i686` |
|
|
435
|
+
|
|
436
|
+
---
|
|
437
|
+
|
|
438
|
+
### `MissingRelease` — GitHub rate limit or network issue
|
|
439
|
+
|
|
440
|
+
**Fix — add a GitHub token:**
|
|
441
|
+
```bash
|
|
442
|
+
GITHUB_TOKEN=ghp_your_token npx bexxcv fetch
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
Unauthenticated GitHub API is limited to 60 requests/hour per IP.
|
|
446
|
+
|
|
447
|
+
---
|
|
448
|
+
|
|
449
|
+
### `playwright-core` version mismatch
|
|
450
|
+
|
|
451
|
+
bexxcv requires `playwright-core < 1.63.0`.
|
|
452
|
+
|
|
453
|
+
**Fix:**
|
|
454
|
+
```bash
|
|
455
|
+
npm install playwright-core@1.62.1
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
460
|
+
### Node.js version too old
|
|
461
|
+
|
|
462
|
+
bexxcv requires Node.js >= 22.
|
|
463
|
+
|
|
464
|
+
**Fix:**
|
|
465
|
+
```bash
|
|
466
|
+
node --version
|
|
467
|
+
nvm install 22 && nvm use 22
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
---
|
|
471
|
+
|
|
472
|
+
### `InvalidProxy` — proxy format wrong
|
|
473
|
+
|
|
474
|
+
Proxy must be `protocol://[user:password@]host:port`:
|
|
475
|
+
|
|
476
|
+
```ts
|
|
477
|
+
await bexxcv({
|
|
478
|
+
proxy: "http://user:pass@proxy.example.com:8080",
|
|
479
|
+
});
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
484
|
+
### `NonFirefoxFingerprint` — wrong browser fingerprint
|
|
485
|
+
|
|
486
|
+
You passed a fingerprint generated for Chrome or Safari. bexxcv only accepts Firefox fingerprints.
|
|
487
|
+
|
|
488
|
+
**Fix:** regenerate with `browsers: ["firefox"]`, or pass `i_know_what_im_doing: true` if you're intentionally mixing (detection risk).
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## License
|
|
493
|
+
|
|
494
|
+
MPL-2.0 — same as the upstream [camoufox-js](https://github.com/apify/camoufox-js).
|
package/dist/__main__.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, rmSync } from "node:fs";
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { DefaultAddons, maybeDownloadAddons } from "./addons.js";
|
|
5
|
+
import { ALLOW_GEOIP, downloadMMDB, removeMMDB } from "./locale.js";
|
|
6
|
+
import { CamoufoxFetcher, INSTALL_DIR, installedVerStr } from "./pkgman.js";
|
|
7
|
+
import { launchServer } from "./server.js";
|
|
8
|
+
import { applySelfUpdate, checkSelfUpdate } from "./selfupdate.js";
|
|
9
|
+
import { Bexxcv } from "./sync_api.js";
|
|
10
|
+
import { getAsBooleanFromENV } from "./utils.js";
|
|
11
|
+
class BexxcvUpdate extends CamoufoxFetcher {
|
|
12
|
+
currentVerStr;
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.currentVerStr = null;
|
|
16
|
+
try {
|
|
17
|
+
this.currentVerStr = installedVerStr();
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error && error.name === "FileNotFoundError") {
|
|
21
|
+
this.currentVerStr = null;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
static async create() {
|
|
29
|
+
const updater = new BexxcvUpdate();
|
|
30
|
+
await updater.init();
|
|
31
|
+
return updater;
|
|
32
|
+
}
|
|
33
|
+
isUpdateNeeded() {
|
|
34
|
+
if (getAsBooleanFromENV("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", false)) {
|
|
35
|
+
console.log("Skipping browser download / update check due to PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD set!");
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
return this.currentVerStr === null || this.currentVerStr !== this.verstr;
|
|
39
|
+
}
|
|
40
|
+
async update() {
|
|
41
|
+
if (!this.isUpdateNeeded()) {
|
|
42
|
+
if (this.currentVerStr === null) {
|
|
43
|
+
console.log(`No cached Camoufox binary found at ${INSTALL_DIR}. Provision it before launching, or unset PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD to download.`);
|
|
44
|
+
}
|
|
45
|
+
else if (getAsBooleanFromENV("PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD", false)) {
|
|
46
|
+
console.log(`Using cached Camoufox v${this.currentVerStr} (update check skipped).`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
console.log("Camoufox binaries up to date!");
|
|
50
|
+
console.log(`Current version: v${this.currentVerStr}`);
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (this.currentVerStr !== null) {
|
|
55
|
+
console.log(`Updating Camoufox binaries from v${this.currentVerStr} => v${this.verstr}`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
console.log("Fetching Camoufox binaries...");
|
|
59
|
+
}
|
|
60
|
+
await this.install();
|
|
61
|
+
}
|
|
62
|
+
async cleanup() {
|
|
63
|
+
if (!existsSync(INSTALL_DIR)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
rmSync(INSTALL_DIR, { recursive: true, force: true });
|
|
67
|
+
console.log("Camoufox binaries removed!");
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const program = new Command();
|
|
72
|
+
program.command("fetch").action(async () => {
|
|
73
|
+
const updater = await BexxcvUpdate.create();
|
|
74
|
+
await updater.update();
|
|
75
|
+
if (ALLOW_GEOIP) {
|
|
76
|
+
await downloadMMDB();
|
|
77
|
+
}
|
|
78
|
+
await maybeDownloadAddons(DefaultAddons);
|
|
79
|
+
});
|
|
80
|
+
program.command("remove").action(async () => {
|
|
81
|
+
const updater = await BexxcvUpdate.create();
|
|
82
|
+
if (!(await updater.cleanup())) {
|
|
83
|
+
console.log("Camoufox binaries not found!");
|
|
84
|
+
}
|
|
85
|
+
removeMMDB();
|
|
86
|
+
});
|
|
87
|
+
program
|
|
88
|
+
.command("test")
|
|
89
|
+
.argument("[url]", "URL to open", null)
|
|
90
|
+
.action(async (url) => {
|
|
91
|
+
const browser = await Bexxcv({
|
|
92
|
+
headless: false,
|
|
93
|
+
env: process.env,
|
|
94
|
+
config: { showcursor: true },
|
|
95
|
+
humanize: 0.5,
|
|
96
|
+
geoip: true,
|
|
97
|
+
});
|
|
98
|
+
const page = await browser.newPage();
|
|
99
|
+
if (url) {
|
|
100
|
+
await page.goto(url);
|
|
101
|
+
}
|
|
102
|
+
await page.pause();
|
|
103
|
+
});
|
|
104
|
+
program.command("server").action(async () => {
|
|
105
|
+
const server = await launchServer({});
|
|
106
|
+
console.log(`Bexxcv server started at ${server.wsEndpoint()}`);
|
|
107
|
+
console.log();
|
|
108
|
+
console.log("Connect to it using Playwright's BrowserType.connect() method.");
|
|
109
|
+
console.log("To stop the server, press Ctrl+C or close this terminal.");
|
|
110
|
+
});
|
|
111
|
+
program.command("path").action(() => {
|
|
112
|
+
console.log(INSTALL_DIR);
|
|
113
|
+
});
|
|
114
|
+
program.command("version").action(async () => {
|
|
115
|
+
const updater = await BexxcvUpdate.create();
|
|
116
|
+
const binVer = updater.currentVerStr;
|
|
117
|
+
if (!binVer) {
|
|
118
|
+
console.log("Camoufox: Not downloaded! Run `bexxcv fetch` to install.");
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
console.log(`Camoufox: v${binVer}`);
|
|
122
|
+
if (updater.isUpdateNeeded()) {
|
|
123
|
+
console.log(`(Latest supported: v${updater.verstr})`);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
console.log("(Up to date!)");
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
program.command("check-update").action(async () => {
|
|
130
|
+
console.log("Checking for bexxcv updates...");
|
|
131
|
+
try {
|
|
132
|
+
const info = await checkSelfUpdate();
|
|
133
|
+
if (info.hasUpdate) {
|
|
134
|
+
console.log(`Update available: v${info.current} → v${info.latest}`);
|
|
135
|
+
console.log(`Run \`bexxcv self-update\` to apply.`);
|
|
136
|
+
console.log(info.releaseUrl);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
console.log(`bexxcv is up to date (v${info.current}).`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
console.error("Failed to check for updates:", err instanceof Error ? err.message : err);
|
|
144
|
+
process.exit(1);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
program.command("self-update").action(async () => {
|
|
148
|
+
try {
|
|
149
|
+
await applySelfUpdate();
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
console.error("Self-update failed:", err instanceof Error ? err.message : err);
|
|
153
|
+
process.exit(1);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
program.parse(process.argv);
|
package/dist/addons.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const DefaultAddons: {
|
|
2
|
+
UBO: string;
|
|
3
|
+
};
|
|
4
|
+
export declare function confirmPaths(paths: string[]): void;
|
|
5
|
+
export declare function addDefaultAddons(addonsList: string[], excludeList?: (keyof typeof DefaultAddons)[]): Promise<void>;
|
|
6
|
+
export declare function downloadAndExtract(url: string, extractPath: string, name: string): Promise<void>;
|
|
7
|
+
export declare function maybeDownloadAddons(addons: Record<string, string>, addonsList?: string[]): Promise<void>;
|