bexxcv 1.0.9 → 1.1.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/README.md +48 -20
- package/dist/doctor.js +3 -1
- package/dist/human.d.ts +2 -0
- package/dist/human.js +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/locale.d.ts +1 -0
- package/dist/locale.js +18 -1
- package/dist/plugins/cocoon.d.ts +1 -1
- package/dist/plugins/cocoon.js +2 -1
- package/dist/plugins/dodge.d.ts +1 -1
- package/dist/plugins/dodge.js +2 -1
- package/dist/plugins/human.d.ts +6 -0
- package/dist/plugins/human.js +38 -0
- package/dist/plugins/index.d.ts +14 -9
- package/dist/plugins/index.js +6 -0
- package/dist/plugins/lens.js +47 -1
- package/dist/plugins/solvers.d.ts +5 -0
- package/dist/plugins/solvers.js +16 -0
- package/dist/plugins/stash.d.ts +1 -1
- package/dist/plugins/stash.js +2 -1
- package/dist/plugins/wiretap.d.ts +1 -1
- package/dist/plugins/wiretap.js +6 -1
- package/dist/realism.d.ts +4 -0
- package/dist/realism.js +96 -0
- package/dist/schema.js +14 -0
- package/dist/sync_api.d.ts +3 -2
- package/dist/sync_api.js +18 -3
- package/dist/utils.d.ts +2 -1
- package/dist/utils.js +17 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -338,30 +338,37 @@ node scripts/update-data.mjs --pin
|
|
|
338
338
|
|
|
339
339
|
## Plugins
|
|
340
340
|
|
|
341
|
-
Plugins
|
|
341
|
+
Plugins add behavior to the browser, its contexts and its pages. Pass them as a list in the second argument, so the options in the first argument stay about the browser itself.
|
|
342
342
|
|
|
343
343
|
```ts
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
})
|
|
344
|
+
import { bexxcv, brake, gauntlet, human, stash, wiretap } from "bexxcv";
|
|
345
|
+
|
|
346
|
+
const browser = await bexxcv(
|
|
347
|
+
{ preset: "realistic", headless: false, os: "windows" },
|
|
348
|
+
[
|
|
349
|
+
gauntlet({ solve: ["uam", "turnstile"], maxTries: 3 }),
|
|
350
|
+
human(),
|
|
351
|
+
stash("./profiles/cookies.json"),
|
|
352
|
+
wiretap("/api/"),
|
|
353
|
+
brake({ maxRps: 2 }),
|
|
354
|
+
],
|
|
355
|
+
);
|
|
350
356
|
```
|
|
351
357
|
|
|
352
|
-
|
|
358
|
+
The same plugins can also be switched on with a flat option such as `bexxcv({ gauntlet: { solve: ["uam"] } })`. It does the same thing and is only a shortcut.
|
|
359
|
+
|
|
360
|
+
| Plugin | What it does |
|
|
353
361
|
|---|---|
|
|
354
|
-
| `gauntlet` | Runs the checks after every `page.goto()`: waits out the Cloudflare challenge (`uam`) and clicks Turnstile widgets (`turnstile`), retrying up to `maxTries`. While the challenge page is up it clicks the widget between mouse movements. `sustain` keeps human-like movement going for a number of milliseconds afterwards. A background check also runs every 1.5 seconds (`watch: false` turns it off), so a challenge that appears later in the session
|
|
355
|
-
| `
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
359
|
-
| `
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
| `
|
|
363
|
-
|
|
364
|
-
`gauntlet` already includes the `uam` waiting and the Turnstile clicking, so there is no need to set `uam` or `turnstile` next to it.
|
|
362
|
+
| `gauntlet(opts)` | Runs the checks after every `page.goto()`: waits out the Cloudflare challenge (`uam`) and clicks Turnstile widgets (`turnstile`), retrying up to `maxTries`. While the challenge page is up it clicks the widget between mouse movements. `sustain` keeps human-like movement going for a number of milliseconds afterwards. A background check also runs every 1.5 seconds (`watch: false` turns it off), so a challenge that appears later in the session is handled too. Challenges are detected through the `cf-mitigated: challenge` header Cloudflare adds to every challenge page, with the page title as a fallback. Read the outcome with `gauntletResult(page)`. |
|
|
363
|
+
| `uam(opts)` and `turnstile(opts)` | The two halves of `gauntlet` as separate plugins. |
|
|
364
|
+
| `human(opts)` | Replaces `page.click`, `page.fill`, `page.type` and `page.hover` with versions that move the pointer, hold the button, type with uneven timing and occasional corrected typos. Options: `speed`, `typoRate`, `nativeCursor`, `think` (a `[min, max]` pause in milliseconds before each action, or `false`). Locator methods are not replaced. |
|
|
365
|
+
| `stash(file)` | Cookie vault, a file path or `{ file, names, domains, saveEvery }`. Cookies are restored into every new context, expired ones are dropped, and everything is saved per domain when the browser closes. The file is created with mode 600. `cf_clearance` is tied to the device and IP it was issued for, so it is restored only when the proxy matches the one in use when it was saved, while other cookies are always restored. |
|
|
366
|
+
| `cocoon(dir)` | Persistent profile folder (`user_data_dir`) that keeps localStorage, IndexedDB and cache between runs. |
|
|
367
|
+
| `wiretap(match)` | Records matching responses. Pass a substring, a list, or `{ match, methods, bodies, maxBodyBytes, streamTimeout, out, redact }`. Use `re:` plus a regular expression for patterns. Server-sent event streams are split into `events`. Sensitive headers are redacted unless `redact: false`. With `out` the capture is written to a private file when the browser closes, and `wiretapEntries(context)` returns it at any time. |
|
|
368
|
+
| `brake(opts)` | Rate limiter for `page.goto()`: `maxRps` per host, and `Retry-After` is honored after 429 and 503 answers, with exponential backoff when the header is missing. |
|
|
369
|
+
| `dodge(pool)` | Proxy pool: a list of proxy URLs or `{ pool, rotateOn, healthCheck, cooldown, onBlocked }`. Unhealthy proxies are skipped at launch, each new context gets the next proxy, and a proxy that answers a blocked status is paused. Keep the pool in one country, because the timezone and locale are derived from the launch proxy. |
|
|
370
|
+
| `veneer(opts)` | Warns when a Firefox user agent is sent together with `sec-ch-ua` headers. With `{ strict: true }` those headers are stripped. |
|
|
371
|
+
| `lens(opts)` | Local fingerprint audit after the first page load, see below. |
|
|
365
372
|
|
|
366
373
|
Writing a plugin:
|
|
367
374
|
|
|
@@ -373,9 +380,30 @@ const timing = {
|
|
|
373
380
|
},
|
|
374
381
|
};
|
|
375
382
|
|
|
376
|
-
const browser = await bexxcv({
|
|
383
|
+
const browser = await bexxcv({}, [timing]);
|
|
377
384
|
```
|
|
378
385
|
|
|
386
|
+
A plugin object can have `beforeLaunch`, `beforeContext`, `onContext`, `onPage` and `beforeClose`, and an `order` number that decides the sequence between plugins.
|
|
387
|
+
|
|
388
|
+
### Realistic preset
|
|
389
|
+
|
|
390
|
+
`preset: "realistic"` fills in the options that make a session look like a normal desktop browser, without overriding anything you set yourself:
|
|
391
|
+
|
|
392
|
+
| Option | Value | Why |
|
|
393
|
+
|---|---|---|
|
|
394
|
+
| `geoip` | `true` | Timezone, locale and geolocation follow the IP address, so they agree with where the traffic comes from |
|
|
395
|
+
| `humanize` | `true` | Natural cursor paths |
|
|
396
|
+
| `enable_cache` | `true` | Real browsers cache, and repeat visits load faster |
|
|
397
|
+
| `realism` | `true` | Adds a microphone, a webcam and a speaker to the media device list when the installed browser supports those properties. Headless servers normally report none. Run `npx bexxcv doctor` to see which properties your browser supports |
|
|
398
|
+
|
|
399
|
+
### Fingerprint audit
|
|
400
|
+
|
|
401
|
+
`lens()` checks the browser from the inside and returns a score with the failing checks (`lensReport(page)`, or `auditFingerprint(page)` on demand): `navigator.webdriver`, user agent against platform, language against `Intl`, screen size against DPR, window size, core count, touch points, WebGL availability and software renderers, replaced native functions, client hints and `window.chrome` for a Firefox user agent, the PDF viewer, window focus and the number of media devices. It never contacts an external site.
|
|
402
|
+
|
|
403
|
+
### What no module can promise
|
|
404
|
+
|
|
405
|
+
Bot detection also looks at things outside the browser: the reputation of the IP address, how many sessions share it, request timing across pages, and what the server learns over time. bexxcv keeps the browser side consistent and human-like, but it cannot make every protection treat a session as human. Use residential or ISP proxies, keep one profile per identity (`stash` or `cocoon`), avoid running many sessions from one IP, and check the result with `lens()` and `npx bexxcv doctor`.
|
|
406
|
+
|
|
379
407
|
---
|
|
380
408
|
|
|
381
409
|
## Xvfb module
|
package/dist/doctor.js
CHANGED
|
@@ -3,7 +3,7 @@ import * as fs from "node:fs";
|
|
|
3
3
|
import * as path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
import { getPath } from "./pkgman.js";
|
|
6
|
-
import { reconcileWebglKeys } from "./realism.js";
|
|
6
|
+
import { REALISM_PROPERTIES, reconcileWebglKeys } from "./realism.js";
|
|
7
7
|
const currentDir = import.meta.dirname ?? path.dirname(fileURLToPath(import.meta.url));
|
|
8
8
|
const DATA_DIR = path.join(currentDir, "data-files");
|
|
9
9
|
export const DEFAULT_MAX_AGE_DAYS = 180;
|
|
@@ -103,6 +103,8 @@ export async function doctor(options = {}) {
|
|
|
103
103
|
}
|
|
104
104
|
const props = readProperties();
|
|
105
105
|
if (props) {
|
|
106
|
+
const supported = REALISM_PROPERTIES.filter((key) => key in props);
|
|
107
|
+
lines.push(`realism properties supported by this browser: ${supported.length > 0 ? supported.join(", ") : "none"}`);
|
|
106
108
|
try {
|
|
107
109
|
const { webGl2Enabled: _skip, ...rest } = JSON.parse(sample.data);
|
|
108
110
|
reconcileWebglKeys(rest, props);
|
package/dist/human.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ export declare class Human {
|
|
|
54
54
|
pause(min?: number, max?: number): Promise<void>;
|
|
55
55
|
moveTo(x: number, y: number): Promise<void>;
|
|
56
56
|
click(target: string | Point, options?: HumanClickOptions): Promise<void>;
|
|
57
|
+
hover(target: string | Point): Promise<void>;
|
|
58
|
+
clear(selector: string): Promise<void>;
|
|
57
59
|
type(target: string | null, text: string): Promise<void>;
|
|
58
60
|
scroll(deltaY: number): Promise<void>;
|
|
59
61
|
scrollTo(selector: string): Promise<void>;
|
package/dist/human.js
CHANGED
|
@@ -97,6 +97,18 @@ export class Human {
|
|
|
97
97
|
await sleep(between(45, 130));
|
|
98
98
|
await this.page.mouse.up({ button: options.button });
|
|
99
99
|
}
|
|
100
|
+
async hover(target) {
|
|
101
|
+
const point = typeof target === "string" ? await this.pointInside(target) : target;
|
|
102
|
+
await this.moveTo(point.x, point.y);
|
|
103
|
+
await sleep(between(80, 260) / this.speed);
|
|
104
|
+
}
|
|
105
|
+
async clear(selector) {
|
|
106
|
+
await this.click(selector);
|
|
107
|
+
await sleep(between(80, 220) / this.speed);
|
|
108
|
+
await this.page.keyboard.press("ControlOrMeta+A");
|
|
109
|
+
await sleep(between(60, 160) / this.speed);
|
|
110
|
+
await this.page.keyboard.press("Backspace");
|
|
111
|
+
}
|
|
100
112
|
async type(target, text) {
|
|
101
113
|
if (target) {
|
|
102
114
|
await this.click(target);
|
package/dist/index.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ 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 LensOptions, 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, turnstile, uam, veneer, wiretap, type HumanPluginOptions, } from "./plugins/index.js";
|
package/dist/index.js
CHANGED
|
@@ -11,3 +11,4 @@ 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, turnstile, uam, veneer, wiretap, } from "./plugins/index.js";
|
package/dist/locale.d.ts
CHANGED
|
@@ -23,4 +23,5 @@ export declare function geoipAllowed(): void;
|
|
|
23
23
|
export declare function downloadMMDB(): Promise<void>;
|
|
24
24
|
export declare function removeMMDB(): void;
|
|
25
25
|
export declare function getGeolocation(ip: string): Promise<Geolocation>;
|
|
26
|
+
export declare function isBrowserLanguage(tag: string): boolean;
|
|
26
27
|
export {};
|
package/dist/locale.js
CHANGED
|
@@ -280,7 +280,9 @@ class StatisticalLocaleSelector {
|
|
|
280
280
|
}
|
|
281
281
|
fromRegion(region) {
|
|
282
282
|
const [languages, probabilities] = this.loadTerritoryData(region);
|
|
283
|
-
const
|
|
283
|
+
const weights = probabilities.map((p, i) => isBrowserLanguage(languages[i]) ? p ** 6 : 0);
|
|
284
|
+
const usable = weights.some((w) => w > 0);
|
|
285
|
+
const language = this.weightedRandomChoice(languages, usable ? weights : probabilities).replace("_", "-");
|
|
284
286
|
return normalizeLocale(`${language}-${region}`);
|
|
285
287
|
}
|
|
286
288
|
fromLanguage(language) {
|
|
@@ -290,3 +292,18 @@ class StatisticalLocaleSelector {
|
|
|
290
292
|
}
|
|
291
293
|
}
|
|
292
294
|
const SELECTOR = new StatisticalLocaleSelector();
|
|
295
|
+
export function isBrowserLanguage(tag) {
|
|
296
|
+
const normalized = tag.replace("_", "-");
|
|
297
|
+
if (!/^([a-z]{2}|fil)(-[A-Za-z]{4})?$/.test(normalized))
|
|
298
|
+
return false;
|
|
299
|
+
const base = normalized.split("-")[0].toLowerCase();
|
|
300
|
+
const UNSAFE = new Set(["jv", "su"]);
|
|
301
|
+
if (UNSAFE.has(base))
|
|
302
|
+
return false;
|
|
303
|
+
try {
|
|
304
|
+
return Intl.DateTimeFormat.supportedLocalesOf([normalized]).length > 0;
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
return false;
|
|
308
|
+
}
|
|
309
|
+
}
|
package/dist/plugins/cocoon.d.ts
CHANGED
package/dist/plugins/cocoon.js
CHANGED
package/dist/plugins/dodge.d.ts
CHANGED
|
@@ -17,5 +17,5 @@ type ProxyConfig = {
|
|
|
17
17
|
password?: string;
|
|
18
18
|
};
|
|
19
19
|
export declare function toProxyConfig(url: string): ProxyConfig;
|
|
20
|
-
export declare function dodge(
|
|
20
|
+
export declare function dodge(input: string[] | DodgeOptions): BexxcvPlugin;
|
|
21
21
|
export {};
|
package/dist/plugins/dodge.js
CHANGED
|
@@ -20,7 +20,8 @@ function timeout(promise, ms) {
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
export function dodge(
|
|
23
|
+
export function dodge(input) {
|
|
24
|
+
const options = Array.isArray(input) ? { pool: input } : input;
|
|
24
25
|
if (!options.pool || options.pool.length === 0) {
|
|
25
26
|
throw new Error("dodge needs at least one proxy in pool");
|
|
26
27
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HumanOptions } from "../human.js";
|
|
2
|
+
import type { BexxcvPlugin } from "./types.js";
|
|
3
|
+
export interface HumanPluginOptions extends HumanOptions {
|
|
4
|
+
think?: [number, number] | false;
|
|
5
|
+
}
|
|
6
|
+
export declare function human(options?: HumanPluginOptions): BexxcvPlugin;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Human } from "../human.js";
|
|
2
|
+
import { between, sleep } from "../random.js";
|
|
3
|
+
const WRAPPED = new WeakSet();
|
|
4
|
+
export function human(options = {}) {
|
|
5
|
+
const think = options.think === false ? null : (options.think ?? [150, 700]);
|
|
6
|
+
const speed = options.speed ?? 1;
|
|
7
|
+
return {
|
|
8
|
+
name: "human",
|
|
9
|
+
order: 60,
|
|
10
|
+
onPage(page) {
|
|
11
|
+
if (WRAPPED.has(page))
|
|
12
|
+
return;
|
|
13
|
+
WRAPPED.add(page);
|
|
14
|
+
const actor = new Human(page, options);
|
|
15
|
+
const pause = async () => {
|
|
16
|
+
if (think)
|
|
17
|
+
await sleep(between(think[0], think[1]) / speed);
|
|
18
|
+
};
|
|
19
|
+
page.click = (async (selector, clickOptions) => {
|
|
20
|
+
await pause();
|
|
21
|
+
await actor.click(selector, { button: clickOptions?.button });
|
|
22
|
+
});
|
|
23
|
+
page.hover = (async (selector) => {
|
|
24
|
+
await pause();
|
|
25
|
+
await actor.hover(selector);
|
|
26
|
+
});
|
|
27
|
+
page.fill = (async (selector, value) => {
|
|
28
|
+
await pause();
|
|
29
|
+
await actor.clear(selector);
|
|
30
|
+
await actor.type(null, value);
|
|
31
|
+
});
|
|
32
|
+
page.type = (async (selector, text) => {
|
|
33
|
+
await pause();
|
|
34
|
+
await actor.type(selector, text);
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { type BrakeOptions } from "./brake.js";
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
4
|
-
import { type
|
|
5
|
-
import { type
|
|
1
|
+
import { brake, type BrakeOptions } from "./brake.js";
|
|
2
|
+
import { cocoon } from "./cocoon.js";
|
|
3
|
+
import { dodge, type DodgeOptions } from "./dodge.js";
|
|
4
|
+
import { gauntlet, type GauntletOptions } from "./gauntlet.js";
|
|
5
|
+
import { human, type HumanPluginOptions } from "./human.js";
|
|
6
|
+
import { lens, type LensOptions } from "./lens.js";
|
|
7
|
+
import { stash, type StashOptions } from "./stash.js";
|
|
6
8
|
import type { BexxcvPlugin } from "./types.js";
|
|
7
|
-
import { type VeneerOptions } from "./veneer.js";
|
|
8
|
-
import { type WiretapOptions } from "./wiretap.js";
|
|
9
|
+
import { veneer, type VeneerOptions } from "./veneer.js";
|
|
10
|
+
import { wiretap, type WiretapOptions } from "./wiretap.js";
|
|
9
11
|
export interface PluginOptions {
|
|
10
12
|
gauntlet?: boolean | GauntletOptions;
|
|
11
13
|
wiretap?: boolean | WiretapOptions;
|
|
@@ -15,13 +17,16 @@ export interface PluginOptions {
|
|
|
15
17
|
dodge?: DodgeOptions;
|
|
16
18
|
cocoon?: string;
|
|
17
19
|
lens?: boolean | LensOptions;
|
|
20
|
+
human?: boolean | HumanPluginOptions;
|
|
18
21
|
plugins?: BexxcvPlugin[];
|
|
19
22
|
}
|
|
20
|
-
export declare const PLUGIN_KEYS: readonly ["gauntlet", "wiretap", "stash", "veneer", "brake", "dodge", "cocoon", "lens", "plugins"];
|
|
23
|
+
export declare const PLUGIN_KEYS: readonly ["gauntlet", "wiretap", "stash", "veneer", "brake", "dodge", "cocoon", "lens", "human", "plugins"];
|
|
21
24
|
export declare function buildPlugins(options: PluginOptions): BexxcvPlugin[];
|
|
22
25
|
export declare function stripPluginOptions<T extends Record<string, unknown>>(options: T): T;
|
|
23
26
|
export { applyPlugins, runBeforeLaunch, type BexxcvPlugin } from "./types.js";
|
|
24
27
|
export { auditFingerprint, lensReport } from "./lens.js";
|
|
25
28
|
export { gauntletResult, runGauntlet } from "./gauntlet.js";
|
|
26
29
|
export { wiretapEntries } from "./wiretap.js";
|
|
27
|
-
export
|
|
30
|
+
export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap };
|
|
31
|
+
export { turnstile, uam } from "./solvers.js";
|
|
32
|
+
export type { HumanPluginOptions, BrakeOptions, DodgeOptions, GauntletOptions, LensOptions, StashOptions, VeneerOptions, WiretapOptions, };
|
package/dist/plugins/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { brake } from "./brake.js";
|
|
|
2
2
|
import { cocoon } from "./cocoon.js";
|
|
3
3
|
import { dodge } from "./dodge.js";
|
|
4
4
|
import { gauntlet } from "./gauntlet.js";
|
|
5
|
+
import { human } from "./human.js";
|
|
5
6
|
import { lens } from "./lens.js";
|
|
6
7
|
import { stash } from "./stash.js";
|
|
7
8
|
import { veneer } from "./veneer.js";
|
|
@@ -15,6 +16,7 @@ export const PLUGIN_KEYS = [
|
|
|
15
16
|
"dodge",
|
|
16
17
|
"cocoon",
|
|
17
18
|
"lens",
|
|
19
|
+
"human",
|
|
18
20
|
"plugins",
|
|
19
21
|
];
|
|
20
22
|
function opts(value) {
|
|
@@ -37,6 +39,8 @@ export function buildPlugins(options) {
|
|
|
37
39
|
list.push(lens(opts(options.lens)));
|
|
38
40
|
if (options.gauntlet)
|
|
39
41
|
list.push(gauntlet(opts(options.gauntlet)));
|
|
42
|
+
if (options.human)
|
|
43
|
+
list.push(human(opts(options.human)));
|
|
40
44
|
if (options.brake)
|
|
41
45
|
list.push(brake(opts(options.brake)));
|
|
42
46
|
if (options.plugins)
|
|
@@ -53,3 +57,5 @@ export { applyPlugins, runBeforeLaunch } from "./types.js";
|
|
|
53
57
|
export { auditFingerprint, lensReport } from "./lens.js";
|
|
54
58
|
export { gauntletResult, runGauntlet } from "./gauntlet.js";
|
|
55
59
|
export { wiretapEntries } from "./wiretap.js";
|
|
60
|
+
export { brake, cocoon, dodge, gauntlet, human, lens, stash, veneer, wiretap };
|
|
61
|
+
export { turnstile, uam } from "./solvers.js";
|
package/dist/plugins/lens.js
CHANGED
|
@@ -8,7 +8,7 @@ export function lensReport(page) {
|
|
|
8
8
|
}
|
|
9
9
|
const PLAUSIBLE_CORES = new Set([2, 4, 6, 8, 10, 12, 14, 16, 20, 24, 32]);
|
|
10
10
|
export async function auditFingerprint(page) {
|
|
11
|
-
const probe = await page.evaluate(() => {
|
|
11
|
+
const probe = await page.evaluate(async () => {
|
|
12
12
|
let vendor = null;
|
|
13
13
|
let renderer = null;
|
|
14
14
|
try {
|
|
@@ -24,13 +24,39 @@ export async function auditFingerprint(page) {
|
|
|
24
24
|
catch {
|
|
25
25
|
vendor = null;
|
|
26
26
|
}
|
|
27
|
+
const natives = [
|
|
28
|
+
navigator.permissions && navigator.permissions.query,
|
|
29
|
+
HTMLCanvasElement.prototype.toDataURL,
|
|
30
|
+
Date.prototype.getTimezoneOffset,
|
|
31
|
+
Function.prototype.toString,
|
|
32
|
+
];
|
|
33
|
+
const nativeCode = natives.every((fn) => typeof fn !== "function" ||
|
|
34
|
+
/\[native code\]/.test(Function.prototype.toString.call(fn)));
|
|
35
|
+
let mediaDevices = null;
|
|
36
|
+
let mediaTimeout = false;
|
|
37
|
+
try {
|
|
38
|
+
if (navigator.mediaDevices && navigator.mediaDevices.enumerateDevices) {
|
|
39
|
+
const list = await Promise.race([
|
|
40
|
+
navigator.mediaDevices.enumerateDevices(),
|
|
41
|
+
new Promise((resolve) => setTimeout(() => resolve(null), 8000)),
|
|
42
|
+
]);
|
|
43
|
+
mediaDevices = list ? list.length : null;
|
|
44
|
+
mediaTimeout = list === null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
mediaDevices = null;
|
|
49
|
+
}
|
|
50
|
+
const nav = navigator;
|
|
27
51
|
return {
|
|
28
52
|
ua: navigator.userAgent,
|
|
29
53
|
platform: navigator.platform,
|
|
30
54
|
language: navigator.language,
|
|
31
55
|
languages: Array.from(navigator.languages),
|
|
56
|
+
intlLocale: Intl.DateTimeFormat().resolvedOptions().locale,
|
|
32
57
|
cores: navigator.hardwareConcurrency,
|
|
33
58
|
webdriver: navigator.webdriver === true,
|
|
59
|
+
touch: navigator.maxTouchPoints,
|
|
34
60
|
dpr: window.devicePixelRatio,
|
|
35
61
|
screenW: screen.width,
|
|
36
62
|
screenH: screen.height,
|
|
@@ -40,21 +66,41 @@ export async function auditFingerprint(page) {
|
|
|
40
66
|
outerH: window.outerHeight,
|
|
41
67
|
vendor,
|
|
42
68
|
renderer,
|
|
69
|
+
nativeCode,
|
|
70
|
+
hasChrome: "chrome" in window,
|
|
71
|
+
hasUaData: "userAgentData" in navigator,
|
|
72
|
+
pdfViewer: typeof nav.pdfViewerEnabled === "boolean" ? nav.pdfViewerEnabled : null,
|
|
73
|
+
focused: document.hasFocus(),
|
|
74
|
+
visible: document.visibilityState === "visible",
|
|
75
|
+
mediaDevices,
|
|
76
|
+
mediaTimeout,
|
|
43
77
|
};
|
|
44
78
|
});
|
|
45
79
|
const checks = [];
|
|
46
80
|
const add = (id, ok, detail) => checks.push({ id, ok, detail });
|
|
81
|
+
const firefox = /Firefox\//.test(probe.ua);
|
|
82
|
+
const desktop = !/Android|Mobile|iPhone|iPad/i.test(probe.ua);
|
|
47
83
|
add("webdriver", !probe.webdriver, `navigator.webdriver is ${probe.webdriver}`);
|
|
48
84
|
const platformOk = (/Windows/i.test(probe.ua) && /^Win/i.test(probe.platform)) ||
|
|
49
85
|
(/Macintosh|Mac OS/i.test(probe.ua) && /^Mac/i.test(probe.platform)) ||
|
|
50
86
|
(/Linux|X11/i.test(probe.ua) && !/Windows|Macintosh/i.test(probe.ua) && /Linux|X11/i.test(probe.platform));
|
|
51
87
|
add("ua-platform", platformOk, `${probe.platform} against the user agent`);
|
|
52
88
|
add("language", probe.languages[0] === probe.language, `language ${probe.language}, first of languages ${probe.languages[0]}`);
|
|
89
|
+
add("locale-intl", probe.intlLocale.split("-")[0].toLowerCase() === probe.language.split("-")[0].toLowerCase(), `Intl locale ${probe.intlLocale}, navigator language ${probe.language}`);
|
|
53
90
|
add("dpr-screen", isKnownPhysical(probe.screenW * probe.dpr, probe.screenH * probe.dpr), `${probe.screenW}x${probe.screenH} at DPR ${probe.dpr}`);
|
|
54
91
|
add("window-size", probe.innerW <= probe.outerW && probe.innerH <= probe.outerH && probe.outerW <= probe.screenW + 16, `inner ${probe.innerW}x${probe.innerH}, outer ${probe.outerW}x${probe.outerH}, screen ${probe.screenW}x${probe.screenH}`);
|
|
55
92
|
add("cores", PLAUSIBLE_CORES.has(probe.cores), `${probe.cores} logical cores`);
|
|
93
|
+
add("touch", !desktop || probe.touch === 0, `maxTouchPoints ${probe.touch}`);
|
|
56
94
|
add("webgl", probe.vendor !== null && probe.renderer !== null, probe.renderer ? `${probe.vendor} / ${probe.renderer}` : "WebGL is not available");
|
|
57
95
|
add("webgl-software", !(probe.renderer && /llvmpipe|swiftshader|software|mesa offscreen/i.test(probe.renderer)), probe.renderer ?? "no renderer");
|
|
96
|
+
add("native-code", probe.nativeCode, probe.nativeCode ? "core APIs are native" : "a core API was replaced by JavaScript");
|
|
97
|
+
add("ua-hints", firefox ? !probe.hasUaData : probe.hasUaData, `userAgentData ${probe.hasUaData ? "present" : "absent"} for a ${firefox ? "Firefox" : "non-Firefox"} user agent`);
|
|
98
|
+
add("chrome-object", firefox ? !probe.hasChrome : true, `window.chrome ${probe.hasChrome ? "present" : "absent"}`);
|
|
99
|
+
add("pdf-viewer", !firefox || probe.pdfViewer === true, `pdfViewerEnabled ${probe.pdfViewer}`);
|
|
100
|
+
add("focus", probe.focused && probe.visible, `focused ${probe.focused}, visible ${probe.visible}`);
|
|
101
|
+
add("media-devices", (probe.mediaDevices === null || probe.mediaDevices > 0), probe.mediaTimeout
|
|
102
|
+
? "enumerateDevices timeout (headless fallback, non-fatal)"
|
|
103
|
+
: `${probe.mediaDevices} media devices`);
|
|
58
104
|
const passed = checks.filter((check) => check.ok).length;
|
|
59
105
|
return { score: Math.round((passed / checks.length) * 100), checks };
|
|
60
106
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type TurnstileOptions } from "../turnstile.js";
|
|
2
|
+
import { type UamOptions } from "../uam.js";
|
|
3
|
+
import type { BexxcvPlugin } from "./types.js";
|
|
4
|
+
export declare function turnstile(options?: TurnstileOptions): BexxcvPlugin;
|
|
5
|
+
export declare function uam(options?: UamOptions): BexxcvPlugin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { watchTurnstile } from "../turnstile.js";
|
|
2
|
+
import { watchUam } from "../uam.js";
|
|
3
|
+
export function turnstile(options = {}) {
|
|
4
|
+
return {
|
|
5
|
+
name: "turnstile",
|
|
6
|
+
order: 45,
|
|
7
|
+
onPage: (page) => watchTurnstile(page, options),
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function uam(options = {}) {
|
|
11
|
+
return {
|
|
12
|
+
name: "uam",
|
|
13
|
+
order: 45,
|
|
14
|
+
onPage: (page) => watchUam(page, options),
|
|
15
|
+
};
|
|
16
|
+
}
|
package/dist/plugins/stash.d.ts
CHANGED
package/dist/plugins/stash.js
CHANGED
|
@@ -17,7 +17,8 @@ function readFile(file) {
|
|
|
17
17
|
}
|
|
18
18
|
return { version: 1, saved: new Date(0).toISOString(), domains: {} };
|
|
19
19
|
}
|
|
20
|
-
export function stash(
|
|
20
|
+
export function stash(input) {
|
|
21
|
+
const options = typeof input === "string" ? { file: input } : input;
|
|
21
22
|
const file = path.resolve(options.file);
|
|
22
23
|
const names = options.names ? new Set(options.names) : null;
|
|
23
24
|
const domains = options.domains?.map((d) => d.toLowerCase().replace(/^\./, "")) ?? null;
|
|
@@ -23,4 +23,4 @@ export interface WiretapEntry {
|
|
|
23
23
|
events?: string[];
|
|
24
24
|
}
|
|
25
25
|
export declare function wiretapEntries(context: BrowserContext): WiretapEntry[];
|
|
26
|
-
export declare function wiretap(
|
|
26
|
+
export declare function wiretap(input?: string | string[] | WiretapOptions): BexxcvPlugin;
|
package/dist/plugins/wiretap.js
CHANGED
|
@@ -44,7 +44,12 @@ function withTimeout(promise, ms) {
|
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
-
export function wiretap(
|
|
47
|
+
export function wiretap(input = {}) {
|
|
48
|
+
const options = typeof input === "string"
|
|
49
|
+
? { match: [input] }
|
|
50
|
+
: Array.isArray(input)
|
|
51
|
+
? { match: input }
|
|
52
|
+
: input;
|
|
48
53
|
const match = matcher(options.match);
|
|
49
54
|
const methods = new Set((options.methods ?? []).map((m) => m.toUpperCase()));
|
|
50
55
|
const redact = options.redact ?? true;
|
package/dist/realism.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare function isKnownPhysical(width: number, height: number): boolean;
|
|
2
2
|
export declare function coherentDprWeights(pool: [number, number][], width: number, height: number): [number[], number[]];
|
|
3
3
|
export declare function reconcileWebglKeys(data: Record<string, unknown>, known: Record<string, string>): Record<string, unknown>;
|
|
4
|
+
export declare const REALISM_PROPERTIES: string[];
|
|
5
|
+
export declare function realismDefaults(known: Record<string, string>): Record<string, unknown>;
|
|
6
|
+
export declare function snapScreen(config: Record<string, unknown>, pool: [number, number][]): boolean;
|
|
7
|
+
export declare function languageList(language: string, region: string): string;
|
package/dist/realism.js
CHANGED
|
@@ -24,7 +24,16 @@ const KNOWN_PHYSICAL = new Set([
|
|
|
24
24
|
"3456x2234",
|
|
25
25
|
"3840x2160",
|
|
26
26
|
"3840x2400",
|
|
27
|
+
"5120x1440",
|
|
27
28
|
"5120x2880",
|
|
29
|
+
"2400x1350",
|
|
30
|
+
"3200x1800",
|
|
31
|
+
"2304x1296",
|
|
32
|
+
"3072x1728",
|
|
33
|
+
"4096x2304",
|
|
34
|
+
"2000x1125",
|
|
35
|
+
"2160x1350",
|
|
36
|
+
"3840x1080",
|
|
28
37
|
]);
|
|
29
38
|
export function isKnownPhysical(width, height) {
|
|
30
39
|
return KNOWN_PHYSICAL.has(`${Math.round(width)}x${Math.round(height)}`);
|
|
@@ -55,3 +64,90 @@ export function reconcileWebglKeys(data, known) {
|
|
|
55
64
|
}
|
|
56
65
|
return out;
|
|
57
66
|
}
|
|
67
|
+
export const REALISM_PROPERTIES = [
|
|
68
|
+
"mediaDevices:enabled",
|
|
69
|
+
"mediaDevices:micros",
|
|
70
|
+
"mediaDevices:webcams",
|
|
71
|
+
"mediaDevices:speakers",
|
|
72
|
+
];
|
|
73
|
+
export function realismDefaults(known) {
|
|
74
|
+
const out = {};
|
|
75
|
+
if (known["mediaDevices:enabled"] === "bool")
|
|
76
|
+
out["mediaDevices:enabled"] = true;
|
|
77
|
+
for (const key of ["mediaDevices:micros", "mediaDevices:webcams", "mediaDevices:speakers"]) {
|
|
78
|
+
if (known[key] === "int" || known[key] === "uint")
|
|
79
|
+
out[key] = 1;
|
|
80
|
+
}
|
|
81
|
+
return out;
|
|
82
|
+
}
|
|
83
|
+
const COMMON_SCREENS = [
|
|
84
|
+
[1920, 1080],
|
|
85
|
+
[1536, 864],
|
|
86
|
+
[1366, 768],
|
|
87
|
+
[1440, 900],
|
|
88
|
+
[1600, 900],
|
|
89
|
+
[1280, 720],
|
|
90
|
+
[1680, 1050],
|
|
91
|
+
[2560, 1440],
|
|
92
|
+
[1920, 1200],
|
|
93
|
+
[1280, 800],
|
|
94
|
+
[1470, 956],
|
|
95
|
+
[1512, 982],
|
|
96
|
+
[1728, 1117],
|
|
97
|
+
[2048, 1152],
|
|
98
|
+
[1792, 1120],
|
|
99
|
+
];
|
|
100
|
+
const WIDTH_KEYS = ["screen.width", "screen.availWidth", "window.outerWidth", "window.innerWidth"];
|
|
101
|
+
const HEIGHT_KEYS = ["screen.height", "screen.availHeight", "window.outerHeight", "window.innerHeight"];
|
|
102
|
+
function shift(config, key, delta) {
|
|
103
|
+
const value = config[key];
|
|
104
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
105
|
+
config[key] = Math.max(1, Math.round(value + delta));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export function snapScreen(config, pool) {
|
|
109
|
+
const width = Number(config["screen.width"]);
|
|
110
|
+
const height = Number(config["screen.height"]);
|
|
111
|
+
if (!(width > 0 && height > 0))
|
|
112
|
+
return false;
|
|
113
|
+
const totalWeight = pool.reduce((acc, [, w]) => acc + w, 0);
|
|
114
|
+
const scoreFor = (w, h) => {
|
|
115
|
+
let score = 0;
|
|
116
|
+
for (const [dpr, weight] of pool) {
|
|
117
|
+
if (isKnownPhysical(w * dpr, h * dpr))
|
|
118
|
+
score += weight;
|
|
119
|
+
}
|
|
120
|
+
return score;
|
|
121
|
+
};
|
|
122
|
+
const currentScore = scoreFor(width, height);
|
|
123
|
+
if (currentScore >= totalWeight * 0.999)
|
|
124
|
+
return false;
|
|
125
|
+
let best = null;
|
|
126
|
+
let bestScore = currentScore;
|
|
127
|
+
let bestDistance = Number.POSITIVE_INFINITY;
|
|
128
|
+
for (const [w, h] of COMMON_SCREENS) {
|
|
129
|
+
const score = scoreFor(w, h);
|
|
130
|
+
if (score < bestScore)
|
|
131
|
+
continue;
|
|
132
|
+
const distance = Math.hypot(w - width, h - height);
|
|
133
|
+
if (score > bestScore || distance < bestDistance) {
|
|
134
|
+
bestScore = score;
|
|
135
|
+
bestDistance = distance;
|
|
136
|
+
best = [w, h];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (!best || (best[0] === width && best[1] === height))
|
|
140
|
+
return false;
|
|
141
|
+
const dw = best[0] - width;
|
|
142
|
+
const dh = best[1] - height;
|
|
143
|
+
for (const key of WIDTH_KEYS)
|
|
144
|
+
shift(config, key, dw);
|
|
145
|
+
for (const key of HEIGHT_KEYS)
|
|
146
|
+
shift(config, key, dh);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
export function languageList(language, region) {
|
|
150
|
+
if (language === "en")
|
|
151
|
+
return `en-${region}, en`;
|
|
152
|
+
return `${language}-${region}, ${language}, en-US, en`;
|
|
153
|
+
}
|
package/dist/schema.js
CHANGED
|
@@ -73,6 +73,20 @@ const SPEC = {
|
|
|
73
73
|
]),
|
|
74
74
|
"a boolean or { interval, retryAfter }",
|
|
75
75
|
],
|
|
76
|
+
preset: [z.literal("realistic"), 'the string "realistic"'],
|
|
77
|
+
realism: [z.boolean(), "a boolean"],
|
|
78
|
+
human: [
|
|
79
|
+
z.union([
|
|
80
|
+
z.boolean(),
|
|
81
|
+
z.object({
|
|
82
|
+
speed: positive.optional(),
|
|
83
|
+
nativeCursor: z.boolean().optional(),
|
|
84
|
+
typoRate: z.number().min(0).max(0.2).optional(),
|
|
85
|
+
think: z.union([z.tuple([positive, positive]), z.literal(false)]).optional(),
|
|
86
|
+
}),
|
|
87
|
+
]),
|
|
88
|
+
"a boolean or { speed, nativeCursor, typoRate, think }",
|
|
89
|
+
],
|
|
76
90
|
gauntlet: [
|
|
77
91
|
z.union([
|
|
78
92
|
z.boolean(),
|
package/dist/sync_api.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { type Browser, type BrowserContext, type BrowserType } from "playwright-core";
|
|
2
2
|
import { type LaunchOptions } from "./utils.js";
|
|
3
3
|
import { type TurnstileOptions } from "./turnstile.js";
|
|
4
|
-
import { type PluginOptions } from "./plugins/index.js";
|
|
4
|
+
import { type BexxcvPlugin, type PluginOptions } from "./plugins/index.js";
|
|
5
5
|
import { type UamOptions } from "./uam.js";
|
|
6
6
|
export interface BexxcvOptions extends LaunchOptions {
|
|
7
7
|
user_data_dir?: string;
|
|
8
8
|
auto_xvfb?: boolean;
|
|
9
9
|
turnstile?: boolean | TurnstileOptions;
|
|
10
10
|
uam?: boolean | UamOptions;
|
|
11
|
+
preset?: "realistic";
|
|
11
12
|
}
|
|
12
13
|
export type BexxcvLaunchOptions = BexxcvOptions & PluginOptions;
|
|
13
14
|
export declare function Bexxcv<UserDataDir extends string | undefined = undefined, ReturnType = UserDataDir extends string ? BrowserContext : Browser>(launch_options?: BexxcvOptions & PluginOptions & {
|
|
14
15
|
user_data_dir?: UserDataDir;
|
|
15
|
-
}): Promise<ReturnType>;
|
|
16
|
+
}, extraPlugins?: BexxcvPlugin[]): Promise<ReturnType>;
|
|
16
17
|
export declare const Camoufox: typeof Bexxcv;
|
|
17
18
|
export declare function NewBrowser<UserDataDir extends string | false = false, ReturnType = UserDataDir extends string ? BrowserContext : Browser>(playwright: BrowserType<Browser>, headless?: boolean | "virtual", fromOptions?: Record<string, any>, userDataDir?: UserDataDir, debug?: boolean, launch_options?: LaunchOptions): Promise<ReturnType>;
|
package/dist/sync_api.js
CHANGED
|
@@ -7,13 +7,28 @@ import { applyPlugins, buildPlugins, runBeforeLaunch, stripPluginOptions, } from
|
|
|
7
7
|
import { attachUam } from "./uam.js";
|
|
8
8
|
import { VirtualDisplay } from "./virtdisplay.js";
|
|
9
9
|
import { needsXvfb } from "./xvfb.js";
|
|
10
|
-
|
|
10
|
+
function applyPreset(options) {
|
|
11
|
+
if (options.preset !== "realistic")
|
|
12
|
+
return options;
|
|
13
|
+
return {
|
|
14
|
+
...options,
|
|
15
|
+
humanize: options.humanize ?? true,
|
|
16
|
+
geoip: options.geoip ?? true,
|
|
17
|
+
enable_cache: options.enable_cache ?? true,
|
|
18
|
+
realism: options.realism ?? true,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export async function Bexxcv(launch_options = {}, extraPlugins = []) {
|
|
11
22
|
validateOptions(launch_options);
|
|
12
23
|
warnIfDataStale();
|
|
13
|
-
|
|
24
|
+
launch_options = applyPreset(launch_options);
|
|
25
|
+
const pluginList = [
|
|
26
|
+
...buildPlugins(launch_options),
|
|
27
|
+
...extraPlugins,
|
|
28
|
+
];
|
|
14
29
|
launch_options = { ...launch_options };
|
|
15
30
|
await runBeforeLaunch(pluginList, launch_options);
|
|
16
|
-
const { headless, user_data_dir, auto_xvfb = true, turnstile = false, uam = false, ...restOptions } = launch_options;
|
|
31
|
+
const { headless, user_data_dir, auto_xvfb = true, turnstile = false, uam = false, preset: _preset, ...restOptions } = launch_options;
|
|
17
32
|
const opts = stripPluginOptions(restOptions);
|
|
18
33
|
const needsDisplay = auto_xvfb && needsXvfb();
|
|
19
34
|
const effectiveHeadless = (() => {
|
package/dist/utils.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export interface LaunchOptions {
|
|
|
32
32
|
firefox_user_prefs?: Record<string, any>;
|
|
33
33
|
proxy?: string | PlaywrightLaunchOptions["proxy"];
|
|
34
34
|
enable_cache?: boolean;
|
|
35
|
+
realism?: boolean;
|
|
35
36
|
args?: string[];
|
|
36
37
|
env?: Record<string, string | number | boolean>;
|
|
37
38
|
debug?: boolean;
|
|
@@ -39,7 +40,7 @@ export interface LaunchOptions {
|
|
|
39
40
|
webgl_config?: [string, string];
|
|
40
41
|
[key: string]: any;
|
|
41
42
|
}
|
|
42
|
-
export declare function launchOptions({ config, os, block_images, block_webrtc, block_webgl, disable_coop, webgl_config, geoip, humanize, locale, addons, fonts, custom_fonts_only, exclude_addons, screen, window, fingerprint, ff_version, headless, main_world_eval, executable_path, firefox_user_prefs, proxy, enable_cache, args, env, i_know_what_im_doing, debug, virtual_display, ...launch_options }: Omit<LaunchOptions, "headless"> & {
|
|
43
|
+
export declare function launchOptions({ config, os, block_images, block_webrtc, block_webgl, disable_coop, webgl_config, geoip, humanize, locale, addons, fonts, custom_fonts_only, exclude_addons, screen, window, fingerprint, ff_version, headless, main_world_eval, executable_path, firefox_user_prefs, proxy, enable_cache, realism, args, env, i_know_what_im_doing, debug, virtual_display, ...launch_options }: Omit<LaunchOptions, "headless"> & {
|
|
43
44
|
headless?: boolean;
|
|
44
45
|
}): Promise<Record<string, any>>;
|
|
45
46
|
export {};
|
package/dist/utils.js
CHANGED
|
@@ -6,7 +6,7 @@ import { addDefaultAddons, confirmPaths, } from "./addons.js";
|
|
|
6
6
|
import { InvalidOS, InvalidPropertyType, NonFirefoxFingerprint, UnknownProperty, } from "./exceptions.js";
|
|
7
7
|
import { fromBrowserforge, generateFingerprint, SUPPORTED_OS, } from "./fingerprints.js";
|
|
8
8
|
import { publicIP, validIPv4, validIPv6 } from "./ip.js";
|
|
9
|
-
import { coherentDprWeights, reconcileWebglKeys } from "./realism.js";
|
|
9
|
+
import { coherentDprWeights, languageList, realismDefaults, reconcileWebglKeys, snapScreen, } from "./realism.js";
|
|
10
10
|
import { geoipAllowed, getGeolocation, handleLocales } from "./locale.js";
|
|
11
11
|
import FONTS from "./mappings/fonts.config.js";
|
|
12
12
|
import { ensureCamoufoxInstalled, getPath, installedVerStr, launchPath, OS_NAME, } from "./pkgman.js";
|
|
@@ -327,7 +327,7 @@ function getProxyUrl(proxy) {
|
|
|
327
327
|
url.password = password;
|
|
328
328
|
return url;
|
|
329
329
|
}
|
|
330
|
-
export async function launchOptions({ config, os, block_images, block_webrtc, block_webgl, disable_coop, webgl_config, geoip, humanize, locale, addons, fonts, custom_fonts_only, exclude_addons, screen, window, fingerprint, ff_version, headless, main_world_eval, executable_path, firefox_user_prefs, proxy, enable_cache, args, env, i_know_what_im_doing, debug, virtual_display, ...launch_options }) {
|
|
330
|
+
export async function launchOptions({ config, os, block_images, block_webrtc, block_webgl, disable_coop, webgl_config, geoip, humanize, locale, addons, fonts, custom_fonts_only, exclude_addons, screen, window, fingerprint, ff_version, headless, main_world_eval, executable_path, firefox_user_prefs, proxy, enable_cache, realism, args, env, i_know_what_im_doing, debug, virtual_display, ...launch_options }) {
|
|
331
331
|
if (!config) {
|
|
332
332
|
config = {};
|
|
333
333
|
}
|
|
@@ -493,6 +493,9 @@ export async function launchOptions({ config, os, block_images, block_webrtc, bl
|
|
|
493
493
|
"canvas:aaCapOffset": true,
|
|
494
494
|
});
|
|
495
495
|
const dprPool = DPR_POOLS[targetOS] ?? DPR_POOLS.lin;
|
|
496
|
+
if (!screen && !window) {
|
|
497
|
+
snapScreen(config, dprPool);
|
|
498
|
+
}
|
|
496
499
|
const screenW = Number(config["screen.width"]);
|
|
497
500
|
const screenH = Number(config["screen.height"]);
|
|
498
501
|
const [dprValues, dprWeights] = screenW > 0 && screenH > 0
|
|
@@ -500,6 +503,18 @@ export async function launchOptions({ config, os, block_images, block_webrtc, bl
|
|
|
500
503
|
: [dprPool.map(([v]) => v), dprPool.map(([, w]) => w)];
|
|
501
504
|
const dpr = weightedPick(dprValues, dprWeights);
|
|
502
505
|
setInto(config, "window.devicePixelRatio", dpr);
|
|
506
|
+
if (realism) {
|
|
507
|
+
for (const [key, value] of Object.entries(realismDefaults(knownProperties))) {
|
|
508
|
+
setInto(config, key, value);
|
|
509
|
+
}
|
|
510
|
+
const language = config["locale:language"];
|
|
511
|
+
const region = config["locale:region"];
|
|
512
|
+
if (!("locale:all" in config) &&
|
|
513
|
+
typeof language === "string" &&
|
|
514
|
+
typeof region === "string") {
|
|
515
|
+
config["locale:all"] = languageList(language, region);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
503
518
|
if (enable_cache) {
|
|
504
519
|
mergeInto(firefox_user_prefs, CACHE_PREFS);
|
|
505
520
|
}
|