bexxcv 1.1.3 → 1.1.4

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 CHANGED
@@ -3,6 +3,8 @@
3
3
  Headless Firefox automation with realistic browser fingerprints, built on top of [Camoufox](https://github.com/daijro/camoufox).
4
4
 
5
5
  > **Fork notice:** Forked from [camoufox-js](https://github.com/apify/camoufox-js) by [Apify]. Full credit to the original authors for the architecture, fingerprint generation pipeline, and Playwright integration. This fork adds entropy improvements, GPU-aware WebGL sampling, session management, and ergonomic enhancements.
6
+ >
7
+ > **v1.1.4:** Enhanced fingerprint realism (canvas anti-aliasing offset, audio sample-rate jitter, performance clock drift), expanded 2024–2026 GPU profiles, six new Cloudflare-aware plugins (`jsd`, `ephemeral`, `precursor`, `classify`, `botscore`, `brake`), and improved JSD challenge detection that only activates on real Cloudflare challenge pages.
6
8
 
7
9
  ---
8
10
 
@@ -58,14 +60,42 @@ npx bexxcv fetch
58
60
  ```ts
59
61
  import { bexxcv } from "bexxcv";
60
62
 
63
+ // Firefox mode (default)
61
64
  const browser = await bexxcv({ headless: true });
62
65
  const page = await browser.newPage();
63
66
  await page.goto("https://example.com");
64
67
  await browser.close();
68
+
69
+ // Chromium mode
70
+ const chromium = await bexxcv({ browser: "chromium", headless: true });
71
+ const cPage = await chromium.newPage();
72
+ await cPage.goto("https://example.com");
73
+ await chromium.close();
65
74
  ```
66
75
 
67
76
  On a headless Linux server without `$DISPLAY`, Xvfb starts automatically when `headless` is `false` or unset — no `xvfb-run` wrapper required.
68
77
 
78
+ ### Browser engines
79
+
80
+ | `browser` value | Engine | UA string | Fingerprint source |
81
+ |---|---|---|---|
82
+ | `"firefox"` (default) | Camoufox (Firefox) | `Firefox/xxx` | GPU-aware WebGL sampling + Camoufox config pipeline |
83
+ | `"chromium"` | Playwright Chromium | `Chrome/xxx` | Chromium-native fingerprinting via Playwright |
84
+
85
+ Chromium mode auto-detects a system-installed browser in this order:
86
+ 1. `google-chrome` / `google-chrome-stable` (apt)
87
+ 2. `chromium` / `chromium-browser` (apt)
88
+ 3. Playwright's built-in Chromium (fallback)
89
+
90
+ It skips the Camoufox-specific fingerprint pipeline (no `CAMOUFOX_CONFIG` env vars, no `properties.json` validation). All plugins (JSD, ephemeral, precursor, stealth, etc.) work identically in both modes.
91
+
92
+ ```bash
93
+ # Install system Chromium (Debian/Ubuntu)
94
+ sudo apt install -y chromium
95
+ # or
96
+ sudo apt install -y google-chrome-stable
97
+ ```
98
+
69
99
  ---
70
100
 
71
101
  ## Options
@@ -79,6 +109,11 @@ const browser = await bexxcv({
79
109
  // --- OS targeting ---
80
110
  os: "windows", // "linux" | "macos" | "windows" | array
81
111
 
112
+
113
+ // --- Browser engine ---
114
+ browser: "firefox", // "firefox" (default) | "chromium"
115
+ chromium_sandbox: true, // set false to disable Chromium sandbox (Docker/root)
116
+
82
117
  // --- Fingerprint customization ---
83
118
  fingerprint: undefined, // pass a custom Fingerprint object
84
119
  ff_version: undefined, // override Firefox version in UA string
@@ -109,7 +144,23 @@ const browser = await bexxcv({
109
144
  enable_cache: false, // enable disk + memory cache
110
145
  main_world_eval: false, // allow JS eval in main world
111
146
 
112
- // --- Addons & fonts ---
147
+ // --- Cloudflare / anti-bot plugins (v1.1.4) ---
148
+ classify: true, // auto-detect Cloudflare challenge type per response (default)
149
+ jsd: true, // intercept JSD challenges, wait for cf_clearance (auto-activates on CF pages)
150
+ ephemeral: true, // capture & replay Turnstile ephemeral IDs (default)
151
+ precursor: true, // detect cf_ cookie drift between navigations (default)
152
+ botScore: false, // monitor Cloudflare bot score per page
153
+ brake: false, // rate-limit navigation after CF 403/429 responses
154
+ gauntlet: false, // run a full fingerprint audit gauntlet before each page
155
+ wiretap: false, // intercept & log network requests/responses
156
+ stash: false, // persist fingerprint state to a file for reuse across runs
157
+ veneer: false, // apply a visual "veneer" of extra browser-like CSS properties
158
+ cocoon: false, // sandboxed session isolation
159
+ dodge: false, // avoid re-challenge by rotating ephemeral identifiers
160
+ lens: false, // run the lens audit on each page (fingerprint consistency check)
161
+ human: false, // attach human-like behavior wrapper per page
162
+
163
+ // --- Addons & fonts ---
113
164
  addons: [], // paths to Firefox extension XPIs
114
165
  exclude_addons: [], // built-in addon keys to skip
115
166
  fonts: [], // additional font names to inject
@@ -197,6 +248,162 @@ Can be combined with `turnstile`.
197
248
 
198
249
  ---
199
250
 
251
+ ## Cloudflare plugins (v1.1.4)
252
+
253
+ bexxcv ships six Cloudflare-aware plugins that are enabled by default (or opt-in). Each plugin integrates via the `PluginOptions` interface and is built into the browser context by `buildPlugins()`.
254
+
255
+ ### `classify` — challenge-classify (default: `true`)
256
+
257
+ Reads HTTP responses and page titles to detect which Cloudflare anti-bot layer fired. Classifies as `jsd`, `managed`, `interactive`, `non_interactive`, `turnstile`, `rate_limit`, or `bot_score_low`. Results are cached per-response and exposed via `challengeInfoFor(response)` and `pageChallengeHistory(page)`.
258
+
259
+ ```ts
260
+ import { bexxcv, challengeInfoFor } from "bexxcv";
261
+
262
+ const browser = await bexxcv({ classify: true });
263
+ // On response inspection:
264
+ const page = await browser.newPage();
265
+ const resp = await page.goto("https://protected-site.com");
266
+ const info = challengeInfoFor(resp);
267
+ if (info.type === "managed") console.log("Managed challenge detected");
268
+ ```
269
+
270
+ ### `jsd` — JS Detection handler (default: `true`)
271
+
272
+ Intercepts `page.goto()` and detects real Cloudflare JavaScript Detection challenges by checking for:
273
+ - "Just a moment" / "Attention required" page titles
274
+ - `window.cloudflare.jsd` with `state === "pending"` (only when Cloudflare itself injected the namespace)
275
+
276
+ If a challenge is detected, polls for `cf_clearance` cookie or JSD state transition. Pages without a Cloudflare challenge pass through instantly — no 15s penalty.
277
+
278
+ ```ts
279
+ import { bexxcv, isJsdPassed } from "bexxcv";
280
+
281
+ const browser = await bexxcv({
282
+ jsd: { timeout: 20_000, interval: 500 },
283
+ });
284
+ const page = await browser.newPage();
285
+ await page.goto("https://protected-site.com");
286
+ const passed = await isJsdPassed(page);
287
+ ```
288
+
289
+ Options: `{ timeout?: number, interval?: number }`
290
+
291
+ ### `ephemeral` — Turnstile ephemeral ID tracking (default: `true`)
292
+
293
+ Captures `ephemeral_id` from Turnstile responses and replays it on subsequent navigations to reduce re-challenge frequency. Stored per-context with a 10-minute TTL.
294
+
295
+ ```ts
296
+ import { bexxcv, getEphemeralEntries, replayEphemeral } from "bexxcv";
297
+
298
+ const browser = await bexxcv({
299
+ ephemeral: { autoReplay: true, maxAgeMs: 1_800_000 },
300
+ });
301
+ const context = (browser as any).contexts()[0];
302
+ const entries = getEphemeralEntries(context);
303
+ ```
304
+
305
+ ### `precursor` — cookie drift detection (default: `true`)
306
+
307
+ Watches `cf_` prefixed cookies on every navigation and response. When `cf_clearance` stays the same but a precursor cookie value changes, it signals a stale session. Emits a warning and optionally auto-reloads.
308
+
309
+ ```ts
310
+ import { bexxcv, getPrecursorState } from "bexxcv";
311
+
312
+ const browser = await bexxcv({
313
+ precursor: { warn: true, autoReload: true },
314
+ });
315
+ const page = await browser.newPage();
316
+ await page.goto("https://protected-site.com");
317
+ const state = getPrecursorState(page);
318
+ ```
319
+
320
+ Options: `{ warn?: boolean, autoReload?: boolean, names?: string[] }`
321
+
322
+ ### `botScore` — bot score monitor (default: `false`)
323
+
324
+ Periodically checks Cloudflare's bot score via the page's `window.__cfBotScore` (when available) and logs the value. Useful for debugging why a site is issuing managed challenges.
325
+
326
+ ```ts
327
+ import { bexxcv, getBotScores, hadLowScore } from "bexxcv";
328
+
329
+ const browser = await bexxcv({ botScore: { log: true } });
330
+ const page = await browser.newPage();
331
+ await page.goto("https://protected-site.com");
332
+ const scores = getBotScores(page);
333
+ if (hadLowScore(page, 40)) console.log("Bot score was low — expect challenges");
334
+ ```
335
+
336
+ ### `brake` — rate limiter with CF 403 support (default: `false`)
337
+
338
+ Intercepts `page.goto()` and applies exponential backoff when Cloudflare returns HTTP 403 or 429. Prevents rapid re-challenge loops.
339
+
340
+ ```ts
341
+ import { bexxcv, brake } from "bexxcv";
342
+
343
+ const browser = await bexxcv({
344
+ brake: { maxRetries: 3, baseDelayMs: 2000 },
345
+ });
346
+ ```
347
+
348
+ Options: `{ maxRetries?: number, baseDelayMs?: number }`
349
+
350
+ ### `stealth` — automation marker spoofing (default: `false`)
351
+
352
+ Patches `navigator.webdriver`, `navigator.plugins`, `navigator.languages`, and removes framework markers (`window.Cypress`, `window.__playwright`, `window._phantom`, etc.) via `addInitScript`. All patches run in the page's main world before any site JavaScript executes.
353
+
354
+ ```ts
355
+ import { bexxcv, stealth, attachStealth } from "bexxcv";
356
+
357
+ // Use as a launch option:
358
+ const browser = await bexxcv({
359
+ stealth: {
360
+ webdriver: true,
361
+ plugins: true,
362
+ languages: true,
363
+ frameworkMarkers: true,
364
+ },
365
+ });
366
+
367
+ // Or attach to an existing browser:
368
+ attachStealth(browser, { webdriver: true });
369
+ ```
370
+
371
+ Options: `{ webdriver?: boolean, plugins?: boolean, languages?: boolean, frameworkMarkers?: boolean }`
372
+
373
+ ---
374
+
375
+ ## Fingerprint quality (v1.1.4)
376
+
377
+ bexxcv generates fingerprints with per-GPU WebGL data, canvas anti-aliasing offsets, audio sample-rate jitter, and performance clock drift. The fingerprint pipeline:
378
+
379
+ 1. **OS selection** — picks a Firefox version, platform, and screen size from a weighted pool
380
+ 2. **DPR coherence** — selects a device pixel ratio such that CSS × DPR matches a known monitor resolution
381
+ 3. **WebGL sampling** — queries `webgl_data.db` for vendor/renderer pairs weighted by OS and GPU generation (2024–2026 hardware included)
382
+ 4. **Canvas AA offset** — applies a per-GPU anti-aliasing sub-pixel offset to `canvasAaOffset`
383
+ 5. **Audio jitter** — applies `audioSampleRateJitter` (±0.5 Hz) to the Web Audio API clock
384
+ 6. **Perf jitter** — applies Gaussian `perfJitterSigma` drift to `performance.now()`
385
+ 7. **Font spacing** — picks a font rendering seed from a weighted list per OS
386
+
387
+ ```ts
388
+ import { generateFingerprint, sampleGPUProfile, resolveUAOS } from "bexxcv";
389
+
390
+ const fp = generateFingerprint([1920, 1080], {
391
+ operatingSystems: ["windows"],
392
+ canvasAaOffset: true,
393
+ audioSampleRateJitter: true,
394
+ perfJitterSigma: 0.15,
395
+ });
396
+ console.log(fp.webglVendor, fp.webglRenderer, fp.canvasAaOffset);
397
+
398
+ const gpu = sampleGPUProfile("linux");
399
+ console.log(gpu.vendor, gpu.renderer);
400
+
401
+ const os = resolveUAOS(gpu.vendor, gpu.renderer);
402
+ console.log(os); // "linux" | "windows" | "macos"
403
+ ```
404
+
405
+ ---
406
+
200
407
  ## Session API
201
408
 
202
409
  Bexxcv maintains per-page session state for consistent fingerprinting and human-like behavior across multiple page navigations.
@@ -20,14 +20,10 @@ export interface ExtendedScreen extends ScreenFingerprint {
20
20
  pointerType?: "mouse" | "touch" | "pen";
21
21
  onlineState?: boolean;
22
22
  platformDeviceMemory?: number;
23
- /** Randomised canvas anti-alias offset in sub-pixel range — larger range = harder to fingerprint */
24
- canvasAaOffset?: number;
25
- /** Audio sample-rate jitter in Hz (simulates OS-level audio clock variance) */
26
- audioSampleRateJitter?: number;
27
- /** Performance.now() Gaussian jitter sigma in ms (replaces uniform range) */
28
- perfJitterSigma?: number;
29
23
  }
30
- export declare function generateFingerprint(window?: [number, number], config?: Partial<FingerprintGeneratorOptions>): Fingerprint & ExtendedScreen;
24
+ export declare function generateFingerprint(window?: [number, number], config?: Partial<FingerprintGeneratorOptions> & {
25
+ browser?: "firefox" | "chromium";
26
+ }): Fingerprint & ExtendedScreen;
31
27
  export declare function fromBrowserforge(fingerprint: Fingerprint, ffVersion?: string): Record<string, any>;
32
28
  /**
33
29
  * Returns a realistic font list for the given OS.
@@ -2,10 +2,14 @@ import { FingerprintGenerator, } from "fingerprint-generator";
2
2
  import BROWSERFORGE_DATA from "./mappings/browserforge.config.js";
3
3
  import { sampleGPUProfile, resolveUAOS } from "./webgl/profiles.js";
4
4
  export const SUPPORTED_OS = ["linux", "macos", "windows"];
5
- const FP_GENERATOR = new FingerprintGenerator({
5
+ const FP_GENERATOR_FF = new FingerprintGenerator({
6
6
  browsers: ["firefox"],
7
7
  operatingSystems: SUPPORTED_OS,
8
8
  });
9
+ const FP_GENERATOR_CR = new FingerprintGenerator({
10
+ browsers: ["chrome"],
11
+ operatingSystems: SUPPORTED_OS,
12
+ });
9
13
  export function cryptoRandInt(min, max) {
10
14
  const buf = new Uint32Array(1);
11
15
  crypto.getRandomValues(buf);
@@ -16,16 +20,12 @@ export function cryptoFloat() {
16
20
  crypto.getRandomValues(buf);
17
21
  return buf[0] / 0x100000000;
18
22
  }
19
- // Realistic font lists per OS — expanded with 2024–2025 system fonts
23
+ // Realistic font lists per OS — these are actual system fonts, not random strings
20
24
  const REALISTIC_FONTS = {
21
25
  win: [
22
26
  "Arial", "Arial Black", "Calibri", "Cambria", "Cambria Math", "Comic Sans MS",
23
27
  "Consolas", "Courier New", "Georgia", "Impact", "Segoe UI", "Times New Roman",
24
28
  "Trebuchet MS", "Verdana", "Microsoft YaHei", "Microsoft JhengHei",
25
- "Segoe MDL2 Assets", "Segoe Fluent Icons", "Ebrima", "Nirmala UI",
26
- "Malgun Gothic", "Gulim", "Batang", "Dotum", "Apple Chancery",
27
- "Lucida Console", "Palatino Linotype", "Book Antiqua", "Century Gothic",
28
- "Franklin Gothic Medium", "Helvetica", "Monaco", "System Font",
29
29
  ],
30
30
  mac: [
31
31
  "Apple SD Gothic Neo", "Avenir", "Baskerville", "Big Caslon", "Chalkboard",
@@ -33,19 +33,14 @@ const REALISTIC_FONTS = {
33
33
  "Gill Sans", "Helvetica", "Helvetica Neue", "Hiragino Kaku Gothic Pro",
34
34
  "Hiragino Maru Gothic Pro", "Menlo", "Mukta Mahee", "MV Boli", "Noto Sans",
35
35
  "Palatino", "San Francisco", "STHeiti", "Symbol", "Tahoma", "Thonburi",
36
- "Times", "Trattatello", "Zapfino", "Marker Felt", "Papyrus", "Cochin",
37
- "American Typewriter", "Arial Hebrew", "Geeza Pro", "Kailasa", "Sinhala Sangam MN",
38
- "Devanagari Sangam MN", "Oriya Sangam MN", "Tamil Sangam MN",
36
+ "Times", "Trattatello", "Zapfino",
39
37
  ],
40
38
  lin: [
41
39
  "Arial", "Cantarell", "Comfortaa", "DejaVu Sans", "DejaVu Sans Mono",
42
40
  "Fira Code", "Fira Sans", "Google Sans", "Iosevka", "Liberation Mono",
43
41
  "Liberation Sans", "Liberation Serif", "Monospace", "Noto Color Emoji",
44
42
  "Noto Sans", "Noto Sans CJK", "Roboto", "Source Code Pro", "Ubuntu",
45
- "Ubuntu Condensed", "Ubuntu Mono", "Bitstream Vera Sans", "Vera",
46
- "FreeSans", "FreeSerif", "Inconsolata", "Lato", "Open Sans",
47
- "Philosopher", "PT Sans", "Raleway", "Source Sans Pro", "Work Sans",
48
- "Overpass", "M+ 1m", "Noto Sans JP", "Noto Sans KR", "Noto Sans SC",
43
+ "Ubuntu Condensed", "Ubuntu Mono",
49
44
  ],
50
45
  };
51
46
  // Realistic canvas noise patterns that match GPU output characteristics
@@ -56,17 +51,16 @@ const CANVAS_NOISE_PATTERNS = [
56
51
  { type: "saltPepper", density: 0.02 },
57
52
  { type: "none" }, // clean renderers exist too
58
53
  ];
59
- // Subtle timing variations that differ by GPU class — expanded with more granular ranges
54
+ // Subtle timing variations that differ by GPU class
60
55
  const RENDER_TIME_VARIATIONS = {
61
- Intel: { minMs: 6, maxMs: 22 },
62
- NVIDIA: { minMs: 2, maxMs: 10 },
63
- AMD: { minMs: 3, maxMs: 12 },
64
- Mesa: { minMs: 12, maxMs: 40 },
65
- Apple: { minMs: 4, maxMs: 14 },
66
- Microsoft: { minMs: 18, maxMs: 55 },
67
- Mozilla: { minMs: 8, maxMs: 24 },
68
- Google: { minMs: 5, maxMs: 16 },
69
- llvmpipe: { minMs: 25, maxMs: 60 },
56
+ Intel: { minMs: 8, maxMs: 18 },
57
+ NVIDIA: { minMs: 3, maxMs: 8 },
58
+ AMD: { minMs: 4, maxMs: 10 },
59
+ Mesa: { minMs: 15, maxMs: 35 },
60
+ Apple: { minMs: 5, maxMs: 12 },
61
+ Microsoft: { minMs: 20, maxMs: 50 },
62
+ Mozilla: { minMs: 10, maxMs: 20 },
63
+ Google: { minMs: 6, maxMs: 14 },
70
64
  };
71
65
  function pickWeighted(items, weights) {
72
66
  const total = weights.reduce((a, b) => a + b, 0);
@@ -124,21 +118,6 @@ function handleScreenXY(camoufoxData, fpScreen) {
124
118
  camoufoxData["window.screenY"] = cryptoRandInt(screenY, 0);
125
119
  }
126
120
  }
127
- /**
128
- * Approximate Gaussian using sum of 6 uniform randoms (Central Limit Theorem).
129
- * Returns value in [min, max] with normal distribution centred at mid-point.
130
- */
131
- function gaussianBetween(min, max) {
132
- const buf = new Uint32Array(6);
133
- crypto.getRandomValues(buf);
134
- let sum = 0;
135
- for (let i = 0; i < 6; i++)
136
- sum += buf[i] / 0x100000000;
137
- // sum of 6 uniforms ≈ N(3, sqrt(6/12)) = N(3, 0.707)
138
- // map to [0, 1] then to [min, max]
139
- const clamped = Math.max(0, Math.min(6, sum)) / 6;
140
- return min + clamped * (max - min);
141
- }
142
121
  function applyRealismSeeds(fp, ua) {
143
122
  const os = resolveUAOS(ua);
144
123
  const gpu = sampleGPUProfile(os);
@@ -150,45 +129,44 @@ function applyRealismSeeds(fp, ua) {
150
129
  fp.webglRenderer = gpu.renderer;
151
130
  fp.webglGLSL = gpu.glslVersion;
152
131
  fp.webglExtensions = gpu.webglExtensions;
153
- // Performance timing jitter — Gaussian-like instead of uniform for realism
132
+ // Performance timing jitter based on GPU class
154
133
  const perfRange = RENDER_TIME_VARIATIONS[gpu.vendor] ?? { minMs: 5, maxMs: 20 };
155
- fp.perfJitter = gaussianBetween(perfRange.minMs, perfRange.maxMs) - (perfRange.minMs + perfRange.maxMs) / 2;
156
- fp.perfJitterSigma = (perfRange.maxMs - perfRange.minMs) / 4; // sigma for runtime sampling
157
- // Timezone offset jitter — ±30 min (was ±15) for stronger anti-fingerprinting
158
- fp.timezoneOffsetJitter = Math.round(gaussianBetween(-30, 30)) * 60; // seconds
159
- // Memory multiplier — tighter realistic range 0.90–1.10 (was 0.85–1.15)
160
- fp.memoryMultiplier = 0.90 + cryptoFloat() * 0.20;
161
- // Hardware concurrency — expanded pool including rare but real configs
162
- const possibleCores = [2, 3, 4, 6, 8, 10, 12, 14, 16, 20, 24, 32];
134
+ fp.perfJitter = (cryptoFloat() - 0.5) * (perfRange.maxMs - perfRange.minMs);
135
+ // Timezone offset jitter (±15 min)
136
+ fp.timezoneOffsetJitter = cryptoRandInt(-15, 15) * 60; // in seconds
137
+ // Memory multiplier (0.85–1.15x base)
138
+ fp.memoryMultiplier = 0.85 + cryptoFloat() * 0.3;
139
+ // Hardware concurrency from realistic pool
140
+ const possibleCores = [2, 4, 6, 8, 10, 12, 16, 20, 24];
163
141
  fp.hardwareConcurrencySeed = possibleCores[cryptoRandInt(0, possibleCores.length - 1)];
164
- // Touch support correlates with device type
165
- const touchChance = os === "win" ? 0.12 : os === "mac" ? 0.04 : 0.02;
142
+ // Touch support correlates with device type (more common on mobile/tablets)
143
+ const touchChance = os === "win" ? 0.15 : os === "mac" ? 0.05 : 0.02;
166
144
  fp.touchSupport = cryptoFloat() < touchChance;
167
145
  fp.touchPoints = fp.touchSupport ? cryptoRandInt(1, 5) : 0;
168
- // Pointer type consistency
146
+ // Pointer type consistency — desktop has mouse, touch devices have pointer+touch
169
147
  if (fp.touchSupport) {
170
148
  fp.pointerType = cryptoFloat() < 0.3 ? "touch" : "mouse";
171
149
  }
172
150
  else {
173
151
  fp.pointerType = cryptoFloat() < 0.05 ? "pen" : "mouse";
174
152
  }
175
- // Online state — virtually always true
153
+ // Online state is almost always true for real browsers
176
154
  fp.onlineState = cryptoFloat() > 0.001;
177
- // Canvas AA offset — wider range for level-max anti-detection (was 0..100 → now -75..75)
178
- fp.canvasAaOffset = cryptoRandInt(-75, 75);
179
- // Audio sample-rate jitter — simulates OS-level clock drift (±2 Hz around 44100/48000)
180
- const baseSampleRate = [44100, 48000][cryptoRandInt(0, 1)];
181
- fp.audioSampleRateJitter = cryptoRandInt(-2, 2); // ±2 Hz
182
155
  }
183
156
  export function generateFingerprint(window, config) {
157
+ const browser = config?.browser ?? "firefox";
158
+ const generator = browser === "chromium" ? FP_GENERATOR_CR : FP_GENERATOR_FF;
159
+ // Strip browser from config before passing to generator
160
+ const genConfig = { ...config };
161
+ delete genConfig.browser;
184
162
  let fp;
185
163
  if (window) {
186
- const generated = FP_GENERATOR.getFingerprint(config);
164
+ const generated = generator.getFingerprint(genConfig);
187
165
  fp = generated.fingerprint;
188
166
  handleWindowSize(fp, window[0], window[1]);
189
167
  }
190
168
  else {
191
- const generated = FP_GENERATOR.getFingerprint(config);
169
+ const generated = generator.getFingerprint(genConfig);
192
170
  fp = generated.fingerprint;
193
171
  }
194
172
  const ua = fp.navigator?.userAgent ?? "";
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export { dataStatus, doctor, type DataStatus } from "./doctor.js";
11
11
  export { validateOptions } from "./schema.js";
12
12
  export { applyPlugins, auditFingerprint, buildPlugins, gauntletResult, lensReport, runGauntlet, wiretapEntries, type BexxcvPlugin, type BrakeOptions, type DodgeOptions, type GauntletOptions, type GauntletResult, type LensOptions, type LensReport, type LensCheck, type PluginOptions, type StashOptions, type VeneerOptions, type WiretapOptions, } from "./plugins/index.js";
13
13
  export { solveTurnstile } from "./turnstile.js";
14
- export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap, challengePlugin, jsd, ephemeral, precursor, botScore, type HumanPluginOptions, } from "./plugins/index.js";
14
+ export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap, challengePlugin, jsd, ephemeral, precursor, botScore, stealth, attachStealth, type HumanPluginOptions, } from "./plugins/index.js";
15
15
  export { turnstile, uam } from "./plugins/solvers.js";
16
16
  export { getEphemeralEntries, replayEphemeral, isJsdPassed } from "./plugins/index.js";
17
17
  export { getPrecursorState, resetPrecursorState } from "./plugins/precursor.js";
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ export { dataStatus, doctor } from "./doctor.js";
11
11
  export { validateOptions } from "./schema.js";
12
12
  export { applyPlugins, auditFingerprint, buildPlugins, gauntletResult, lensReport, runGauntlet, wiretapEntries, } from "./plugins/index.js";
13
13
  export { solveTurnstile } from "./turnstile.js";
14
- export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap, challengePlugin, jsd, ephemeral, precursor, botScore, } from "./plugins/index.js";
14
+ export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap, challengePlugin, jsd, ephemeral, precursor, botScore, stealth, attachStealth, } from "./plugins/index.js";
15
15
  export { turnstile, uam } from "./plugins/solvers.js";
16
16
  export { getEphemeralEntries, replayEphemeral, isJsdPassed } from "./plugins/index.js";
17
17
  export { getPrecursorState, resetPrecursorState } from "./plugins/precursor.js";
@@ -12,3 +12,4 @@ export { stash, type StashOptions } from "./stash.js";
12
12
  export { veneer, type VeneerOptions } from "./veneer.js";
13
13
  export { wiretap, type WiretapOptions } from "./wiretap.js";
14
14
  export { botScore, getBotScores, avgBotScore, hadLowScore, type BotScoreOptions } from "./botscore.js";
15
+ export { stealth, attachStealth, type StealthOptions } from "./stealth.js";
@@ -13,3 +13,4 @@ export { stash } from "./stash.js";
13
13
  export { veneer } from "./veneer.js";
14
14
  export { wiretap } from "./wiretap.js";
15
15
  export { botScore, getBotScores, avgBotScore, hadLowScore } from "./botscore.js";
16
+ export { stealth, attachStealth } from "./stealth.js";
@@ -12,6 +12,7 @@ import type { BexxcvPlugin } from "./types.js";
12
12
  import { type VeneerOptions } from "./veneer.js";
13
13
  import { type WiretapOptions } from "./wiretap.js";
14
14
  import { type BotScoreOptions } from "./botscore.js";
15
+ import { type StealthOptions } from "./stealth.js";
15
16
  export interface PluginOptions {
16
17
  gauntlet?: boolean | GauntletOptions;
17
18
  wiretap?: boolean | WiretapOptions;
@@ -25,21 +26,23 @@ export interface PluginOptions {
25
26
  plugins?: BexxcvPlugin[];
26
27
  /** Enable Cloudflare challenge classification (challenge-classify). Default true. */
27
28
  classify?: boolean;
28
- /** Enable JS Detection handling (jsd). Requires gauntlet: true. Default false. */
29
+ /** Enable JS Detection handling (jsd). Requires gauntlet: true. Default true. */
29
30
  jsd?: boolean | JsdOptions;
30
- /** Enable Turnstile ephemeral ID tracking (ephemeral). Default false. */
31
+ /** Enable Turnstile ephemeral ID tracking (ephemeral). Default true. */
31
32
  ephemeral?: boolean | EphemeralOptions;
32
- /** Enable Precursor cookie drift detection (precursor). Default false. */
33
+ /** Enable Precursor cookie drift detection (precursor). Default true. */
33
34
  precursor?: boolean | PrecursorOptions;
34
35
  /** Enable Bot Management score monitoring (bot-score-monitor). Default false. */
35
36
  botScore?: boolean | BotScoreOptions;
37
+ /** Enable automation marker spoofing (stealth). Default false. */
38
+ stealth?: boolean | StealthOptions;
36
39
  }
37
- export declare const PLUGIN_KEYS: readonly ["gauntlet", "wiretap", "stash", "veneer", "brake", "dodge", "cocoon", "gauntlet", "lens", "human", "plugins", "classify", "jsd", "ephemeral", "precursor", "botScore"];
40
+ export declare const PLUGIN_KEYS: readonly ["gauntlet", "wiretap", "stash", "veneer", "brake", "dodge", "cocoon", "gauntlet", "lens", "human", "plugins", "classify", "jsd", "ephemeral", "precursor", "botScore", "stealth"];
38
41
  export declare function buildPlugins(options: PluginOptions): BexxcvPlugin[];
39
42
  export declare function stripPluginOptions<T extends Record<string, unknown>>(options: T): T;
40
43
  export { applyPlugins, runBeforeLaunch, type BexxcvPlugin } from "./types.js";
41
44
  export { auditFingerprint, lensReport } from "./lens.js";
42
45
  export { gauntletResult, runGauntlet } from "./gauntlet.js";
43
46
  export { wiretapEntries } from "./wiretap.js";
44
- export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap, challengePlugin, jsd, ephemeral, precursor, botScore, getEphemeralEntries, replayEphemeral, isJsdPassed, getPrecursorState, resetPrecursorState, getBotScores, avgBotScore, hadLowScore } from "./index-reexports.js";
47
+ export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap, challengePlugin, jsd, ephemeral, precursor, botScore, stealth, attachStealth, getEphemeralEntries, replayEphemeral, isJsdPassed, getPrecursorState, resetPrecursorState, getBotScores, avgBotScore, hadLowScore } from "./index-reexports.js";
45
48
  export type { HumanPluginOptions, BrakeOptions, DodgeOptions, GauntletOptions, GauntletResult, LensOptions, LensReport, LensCheck, StashOptions, VeneerOptions, WiretapOptions, ChallengeInfo, ChallengeType, JsdOptions, EphemeralOptions, PrecursorOptions, BotScoreOptions, };
@@ -12,6 +12,7 @@ import { stash } from "./stash.js";
12
12
  import { veneer } from "./veneer.js";
13
13
  import { wiretap } from "./wiretap.js";
14
14
  import { botScore } from "./botscore.js";
15
+ import { stealth } from "./stealth.js";
15
16
  export const PLUGIN_KEYS = [
16
17
  "gauntlet",
17
18
  "wiretap",
@@ -29,6 +30,7 @@ export const PLUGIN_KEYS = [
29
30
  "ephemeral",
30
31
  "precursor",
31
32
  "botScore",
33
+ "stealth",
32
34
  ];
33
35
  function opts(value) {
34
36
  return value === true ? {} : value;
@@ -53,6 +55,8 @@ export function buildPlugins(options) {
53
55
  list.push(botScore(typeof options.botScore === "object" ? options.botScore : {}));
54
56
  if (options.jsd !== false)
55
57
  list.push(jsd(typeof options.jsd === "object" ? options.jsd : {}));
58
+ if (options.stealth)
59
+ list.push(stealth(typeof options.stealth === "object" ? options.stealth : {}));
56
60
  if (options.ephemeral !== false)
57
61
  list.push(ephemeral(typeof options.ephemeral === "object" ? options.ephemeral : {}));
58
62
  if (options.gauntlet)
@@ -79,4 +83,4 @@ export { applyPlugins, runBeforeLaunch } from "./types.js";
79
83
  export { auditFingerprint, lensReport } from "./lens.js";
80
84
  export { gauntletResult, runGauntlet } from "./gauntlet.js";
81
85
  export { wiretapEntries } from "./wiretap.js";
82
- export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap, challengePlugin, jsd, ephemeral, precursor, botScore, getEphemeralEntries, replayEphemeral, isJsdPassed, getPrecursorState, resetPrecursorState, getBotScores, avgBotScore, hadLowScore } from "./index-reexports.js";
86
+ export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap, challengePlugin, jsd, ephemeral, precursor, botScore, stealth, attachStealth, getEphemeralEntries, replayEphemeral, isJsdPassed, getPrecursorState, resetPrecursorState, getBotScores, avgBotScore, hadLowScore } from "./index-reexports.js";
@@ -10,7 +10,13 @@ async function isJsdPage(page) {
10
10
  const hasJsd = await page.evaluate(() => {
11
11
  try {
12
12
  const w = window;
13
- return typeof window !== "undefined" && !!w?.cloudflare?.jsd;
13
+ if (!w?.cloudflare?.jsd)
14
+ return false;
15
+ // If it's our fallback (bexxcv), not a real CF challenge
16
+ if (w.cloudflare.jsd._bexxcv)
17
+ return false;
18
+ // Real CF JSD has state "pending" or a registered executeOnce
19
+ return w.cloudflare.jsd.state === "pending" || typeof w.cloudflare.jsd.executeOnce === "function";
14
20
  }
15
21
  catch {
16
22
  return false;
@@ -77,6 +83,7 @@ export function jsd(options = {}) {
77
83
  cf.jsd = {
78
84
  state: "pending",
79
85
  executeOnce(_opts = {}) { },
86
+ _bexxcv: true,
80
87
  };
81
88
  }
82
89
  const _jsd = cf.jsd;
@@ -0,0 +1,32 @@
1
+ import type { Browser, BrowserContext } from "playwright-core";
2
+ import type { BexxcvPlugin } from "./types.js";
3
+ /**
4
+ * Stealth plugin — spoofs automation markers that leak the use of
5
+ * a scripted browser.
6
+ *
7
+ * On every page, this plugin:
8
+ * 1. Sets `navigator.webdriver = false` (via init script)
9
+ * 2. Removes `window._phantom`, `window._phantomjs`, `window.casper` markers
10
+ * 3. Patches `navigator.permissions.query` so `notifications` permission
11
+ * doesn't report `prompt` status on headless browsers
12
+ * 4. Hides `window.Cypress`, `window.__playwright`, and similar markers
13
+ * 5. Sets `navigator.plugins` to a realistic 5-plugin array
14
+ * 6. Sets `navigator.languages` to a realistic 1-3 language array
15
+ * 7. Hides the `automation` channel from `MediaSource` (if present)
16
+ *
17
+ * All patches are applied via `addInitScript` so they run in the page's
18
+ * main world before any site JavaScript executes.
19
+ */
20
+ export interface StealthOptions {
21
+ /** Set `navigator.webdriver` to `false`. Default true. */
22
+ webdriver?: boolean;
23
+ /** Set a realistic `navigator.plugins` array. Default true. */
24
+ plugins?: boolean;
25
+ /** Set a realistic `navigator.languages` array. Default true. */
26
+ languages?: boolean;
27
+ /** Remove `window.Cypress` / `window.__playwright` markers. Default true. */
28
+ frameworkMarkers?: boolean;
29
+ }
30
+ export declare function stealth(options?: StealthOptions): BexxcvPlugin;
31
+ /** Attach the stealth plugin to an existing browser or context. */
32
+ export declare function attachStealth<T extends Browser | BrowserContext>(target: T, options?: StealthOptions): T;