bexxcv 1.0.8 → 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.
Files changed (46) hide show
  1. package/README.md +70 -0
  2. package/dist/doctor.js +3 -1
  3. package/dist/human.d.ts +2 -0
  4. package/dist/human.js +12 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.js +3 -0
  7. package/dist/locale.d.ts +1 -0
  8. package/dist/locale.js +18 -1
  9. package/dist/pagehooks.d.ts +6 -0
  10. package/dist/pagehooks.js +19 -0
  11. package/dist/plugins/brake.d.ts +8 -0
  12. package/dist/plugins/brake.js +74 -0
  13. package/dist/plugins/cocoon.d.ts +5 -0
  14. package/dist/plugins/cocoon.js +18 -0
  15. package/dist/plugins/dodge.d.ts +21 -0
  16. package/dist/plugins/dodge.js +103 -0
  17. package/dist/plugins/gauntlet.d.ts +20 -0
  18. package/dist/plugins/gauntlet.js +119 -0
  19. package/dist/plugins/human.d.ts +6 -0
  20. package/dist/plugins/human.js +38 -0
  21. package/dist/plugins/index.d.ts +32 -0
  22. package/dist/plugins/index.js +61 -0
  23. package/dist/plugins/lens.d.ts +20 -0
  24. package/dist/plugins/lens.js +135 -0
  25. package/dist/plugins/solvers.d.ts +5 -0
  26. package/dist/plugins/solvers.js +16 -0
  27. package/dist/plugins/stash.d.ts +8 -0
  28. package/dist/plugins/stash.js +109 -0
  29. package/dist/plugins/types.d.ts +13 -0
  30. package/dist/plugins/types.js +49 -0
  31. package/dist/plugins/veneer.d.ts +5 -0
  32. package/dist/plugins/veneer.js +37 -0
  33. package/dist/plugins/wiretap.d.ts +26 -0
  34. package/dist/plugins/wiretap.js +128 -0
  35. package/dist/realism.d.ts +4 -0
  36. package/dist/realism.js +96 -0
  37. package/dist/schema.js +99 -0
  38. package/dist/sync_api.d.ts +5 -2
  39. package/dist/sync_api.js +25 -2
  40. package/dist/turnstile.d.ts +12 -0
  41. package/dist/turnstile.js +70 -13
  42. package/dist/uam.d.ts +4 -0
  43. package/dist/uam.js +32 -6
  44. package/dist/utils.d.ts +2 -1
  45. package/dist/utils.js +17 -2
  46. package/package.json +1 -1
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,105 @@ 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
+ ],
90
+ gauntlet: [
91
+ z.union([
92
+ z.boolean(),
93
+ z.object({
94
+ solve: z.array(z.enum(["uam", "turnstile"])).optional(),
95
+ maxTries: z.number().int().positive().optional(),
96
+ timeout: positive.optional(),
97
+ sustain: z.number().nonnegative().optional(),
98
+ }),
99
+ ]),
100
+ 'a boolean or { solve: ["uam", "turnstile"], maxTries, timeout, sustain }',
101
+ ],
102
+ wiretap: [
103
+ z.union([
104
+ z.boolean(),
105
+ z.object({
106
+ match: z.array(z.string()).optional(),
107
+ methods: z.array(z.string()).optional(),
108
+ out: z.string().min(1).optional(),
109
+ bodies: z.boolean().optional(),
110
+ maxBodyBytes: positive.optional(),
111
+ streamTimeout: positive.optional(),
112
+ redact: z.boolean().optional(),
113
+ }),
114
+ ]),
115
+ "a boolean or { match, methods, out, bodies, maxBodyBytes, streamTimeout, redact }",
116
+ ],
117
+ stash: [
118
+ z.union([
119
+ z.string().min(1),
120
+ z.object({
121
+ file: z.string().min(1),
122
+ names: z.array(z.string()).optional(),
123
+ domains: z.array(z.string()).optional(),
124
+ saveEvery: positive.optional(),
125
+ }),
126
+ ]),
127
+ "a file path or { file, names, domains, saveEvery }",
128
+ ],
129
+ veneer: [
130
+ z.union([z.boolean(), z.object({ strict: z.boolean().optional() })]),
131
+ "a boolean or { strict }",
132
+ ],
133
+ brake: [
134
+ z.union([
135
+ z.boolean(),
136
+ z.object({
137
+ maxRps: positive.optional(),
138
+ respectRetryAfter: z.boolean().optional(),
139
+ perHost: z.boolean().optional(),
140
+ maxBackoff: positive.optional(),
141
+ }),
142
+ ]),
143
+ "a boolean or { maxRps, respectRetryAfter, perHost, maxBackoff }",
144
+ ],
145
+ dodge: [
146
+ z.object({
147
+ pool: z.array(z.string().min(1)).min(1),
148
+ rotateOn: z.array(z.number().int()).optional(),
149
+ healthCheck: z.boolean().optional(),
150
+ healthTimeout: positive.optional(),
151
+ cooldown: positive.optional(),
152
+ onBlocked: z
153
+ .custom((v) => typeof v === "function")
154
+ .optional(),
155
+ }),
156
+ "{ pool: [proxy urls], rotateOn, healthCheck, healthTimeout, cooldown, onBlocked }",
157
+ ],
158
+ cocoon: [z.string().min(1), "a folder path"],
159
+ lens: [
160
+ z.union([
161
+ z.boolean(),
162
+ z.object({
163
+ audit: z.boolean().optional(),
164
+ target: z.literal("local").optional(),
165
+ quiet: z.boolean().optional(),
166
+ out: z.string().min(1).optional(),
167
+ }),
168
+ ]),
169
+ 'a boolean or { audit, target: "local", quiet, out }',
170
+ ],
171
+ plugins: [
172
+ z.array(z.custom((v) => typeof v === "object" && v !== null && typeof v.name === "string")),
173
+ "an array of plugin objects with a name",
174
+ ],
76
175
  uam: [
77
176
  z.union([
78
177
  z.boolean(),
@@ -1,15 +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 BexxcvPlugin, type PluginOptions } from "./plugins/index.js";
4
5
  import { type UamOptions } from "./uam.js";
5
6
  export interface BexxcvOptions extends LaunchOptions {
6
7
  user_data_dir?: string;
7
8
  auto_xvfb?: boolean;
8
9
  turnstile?: boolean | TurnstileOptions;
9
10
  uam?: boolean | UamOptions;
11
+ preset?: "realistic";
10
12
  }
11
- export declare function Bexxcv<UserDataDir extends string | undefined = undefined, ReturnType = UserDataDir extends string ? BrowserContext : Browser>(launch_options?: BexxcvOptions & {
13
+ export type BexxcvLaunchOptions = BexxcvOptions & PluginOptions;
14
+ export declare function Bexxcv<UserDataDir extends string | undefined = undefined, ReturnType = UserDataDir extends string ? BrowserContext : Browser>(launch_options?: BexxcvOptions & PluginOptions & {
12
15
  user_data_dir?: UserDataDir;
13
- }): Promise<ReturnType>;
16
+ }, extraPlugins?: BexxcvPlugin[]): Promise<ReturnType>;
14
17
  export declare const Camoufox: typeof Bexxcv;
15
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
@@ -3,13 +3,33 @@ import { attachNoViewportDefault, launchOptions, spoofsWindowDimensions, syncAtt
3
3
  import { warnIfDataStale } from "./doctor.js";
4
4
  import { validateOptions } from "./schema.js";
5
5
  import { attachTurnstile } from "./turnstile.js";
6
+ import { applyPlugins, buildPlugins, runBeforeLaunch, stripPluginOptions, } from "./plugins/index.js";
6
7
  import { attachUam } from "./uam.js";
7
8
  import { VirtualDisplay } from "./virtdisplay.js";
8
9
  import { needsXvfb } from "./xvfb.js";
9
- export async function Bexxcv(launch_options = {}) {
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 = []) {
10
22
  validateOptions(launch_options);
11
23
  warnIfDataStale();
12
- const { headless, user_data_dir, auto_xvfb = true, turnstile = false, uam = false, ...opts } = launch_options;
24
+ launch_options = applyPreset(launch_options);
25
+ const pluginList = [
26
+ ...buildPlugins(launch_options),
27
+ ...extraPlugins,
28
+ ];
29
+ launch_options = { ...launch_options };
30
+ await runBeforeLaunch(pluginList, launch_options);
31
+ const { headless, user_data_dir, auto_xvfb = true, turnstile = false, uam = false, preset: _preset, ...restOptions } = launch_options;
32
+ const opts = stripPluginOptions(restOptions);
13
33
  const needsDisplay = auto_xvfb && needsXvfb();
14
34
  const effectiveHeadless = (() => {
15
35
  if (headless === "virtual")
@@ -27,6 +47,9 @@ export async function Bexxcv(launch_options = {}) {
27
47
  if (uam) {
28
48
  attachUam(launched, uam === true ? {} : uam);
29
49
  }
50
+ if (pluginList.length > 0) {
51
+ await applyPlugins(launched, pluginList);
52
+ }
30
53
  return launched;
31
54
  }
32
55
  export const Camoufox = Bexxcv;
@@ -3,5 +3,17 @@ export interface TurnstileOptions {
3
3
  interval?: number;
4
4
  retryAfter?: number;
5
5
  }
6
+ export interface Widget {
7
+ x: number;
8
+ y: number;
9
+ w: number;
10
+ h: number;
11
+ solved: boolean;
12
+ key: string;
13
+ }
14
+ export declare function findWidgets(page: Page): Promise<Widget[]>;
15
+ export declare function readTurnstileToken(page: Page): Promise<string | null>;
16
+ export declare function createClicker(retryAfter?: number): (page: Page) => Promise<boolean>;
17
+ export declare function solveTurnstile(page: Page, timeout?: number, idleChecks?: number, retryAfter?: number): Promise<string | null>;
6
18
  export declare function watchTurnstile(page: Page, options?: TurnstileOptions): void;
7
19
  export declare function attachTurnstile<T extends Browser | BrowserContext>(target: T, options?: TurnstileOptions): T;
package/dist/turnstile.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { onEachPage } from "./pagehooks.js";
2
2
  import { between, sleep } from "./random.js";
3
3
  const WATCHED = new WeakSet();
4
- async function findWidgets(page) {
4
+ export async function findWidgets(page) {
5
5
  return page.evaluate(() => {
6
6
  const out = [];
7
7
  const seen = new Set();
@@ -45,6 +45,29 @@ async function findWidgets(page) {
45
45
  return out;
46
46
  });
47
47
  }
48
+ export async function readTurnstileToken(page) {
49
+ try {
50
+ return await page.evaluate(() => {
51
+ for (const el of Array.from(document.querySelectorAll('[name="cf-turnstile-response"]'))) {
52
+ if (el.value && el.value.length > 20)
53
+ return el.value;
54
+ }
55
+ try {
56
+ const w = window;
57
+ const value = w.turnstile?.getResponse?.();
58
+ if (value && value.length > 20)
59
+ return value;
60
+ }
61
+ catch {
62
+ return null;
63
+ }
64
+ return null;
65
+ });
66
+ }
67
+ catch {
68
+ return null;
69
+ }
70
+ }
48
71
  async function clickAt(page, x, y) {
49
72
  await page.mouse.move(x + between(-60, 60), y + between(-40, 40), { steps: 4 });
50
73
  await sleep(between(60, 160));
@@ -54,6 +77,51 @@ async function clickAt(page, x, y) {
54
77
  await sleep(between(60, 120));
55
78
  await page.mouse.up();
56
79
  }
80
+ async function clickPending(page, clicked, retryAfter) {
81
+ const widgets = await findWidgets(page);
82
+ let clicks = 0;
83
+ for (const widget of widgets) {
84
+ if (widget.solved)
85
+ continue;
86
+ const last = clicked.get(widget.key) ?? 0;
87
+ if (Date.now() - last < retryAfter)
88
+ continue;
89
+ clicked.set(widget.key, Date.now());
90
+ const x = widget.x + Math.min(30, widget.w / 2) + between(-4, 4);
91
+ const y = widget.y + widget.h / 2 + between(-4, 4);
92
+ await clickAt(page, x, y);
93
+ clicks++;
94
+ }
95
+ return { widgets, clicks };
96
+ }
97
+ export function createClicker(retryAfter = 8000) {
98
+ const clicked = new Map();
99
+ return async (page) => {
100
+ const result = await clickPending(page, clicked, retryAfter);
101
+ return result.clicks > 0;
102
+ };
103
+ }
104
+ export async function solveTurnstile(page, timeout = 30000, idleChecks = 4, retryAfter = 8000) {
105
+ const end = Date.now() + timeout;
106
+ const clicked = new Map();
107
+ let idle = 0;
108
+ while (Date.now() < end && !page.isClosed()) {
109
+ const token = await readTurnstileToken(page);
110
+ if (token)
111
+ return token;
112
+ try {
113
+ const result = await clickPending(page, clicked, retryAfter);
114
+ idle = result.widgets.length === 0 ? idle + 1 : 0;
115
+ }
116
+ catch {
117
+ idle++;
118
+ }
119
+ if (idle >= idleChecks)
120
+ return null;
121
+ await sleep(1000);
122
+ }
123
+ return readTurnstileToken(page);
124
+ }
57
125
  export function watchTurnstile(page, options = {}) {
58
126
  if (WATCHED.has(page))
59
127
  return;
@@ -68,18 +136,7 @@ export function watchTurnstile(page, options = {}) {
68
136
  const loop = async () => {
69
137
  while (active && !page.isClosed()) {
70
138
  try {
71
- const widgets = await findWidgets(page);
72
- for (const widget of widgets) {
73
- if (widget.solved)
74
- continue;
75
- const last = clicked.get(widget.key) ?? 0;
76
- if (Date.now() - last < retryAfter)
77
- continue;
78
- clicked.set(widget.key, Date.now());
79
- const x = widget.x + Math.min(30, widget.w / 2) + between(-4, 4);
80
- const y = widget.y + widget.h / 2 + between(-4, 4);
81
- await clickAt(page, x, y);
82
- }
139
+ await clickPending(page, clicked, retryAfter);
83
140
  }
84
141
  catch {
85
142
  await sleep(500);
package/dist/uam.d.ts CHANGED
@@ -3,12 +3,16 @@ export interface UamOptions {
3
3
  timeout?: number;
4
4
  interval?: number;
5
5
  waitOnGoto?: boolean;
6
+ assist?: (page: Page) => Promise<boolean>;
6
7
  }
7
8
  export interface UamResult {
8
9
  challenged: boolean;
9
10
  bypassed: boolean;
10
11
  cookie: string | null;
11
12
  }
13
+ export declare function trackMitigation(page: Page): void;
14
+ export declare function isChallenge(page: Page): Promise<boolean>;
15
+ export declare function humanActivity(page: Page, scale?: number): Promise<void>;
12
16
  export declare function waitForUam(page: Page, options?: UamOptions): Promise<UamResult>;
13
17
  export declare function watchUam(page: Page, options?: UamOptions): void;
14
18
  export declare function attachUam<T extends Browser | BrowserContext>(target: T, options?: UamOptions): T;
package/dist/uam.js CHANGED
@@ -13,7 +13,24 @@ const CHALLENGE_TITLES = [
13
13
  ];
14
14
  const WATCHED = new WeakSet();
15
15
  const BUSY = new WeakSet();
16
- async function isChallenge(page) {
16
+ const MITIGATED = new WeakMap();
17
+ const TRACKED = new WeakSet();
18
+ export function trackMitigation(page) {
19
+ if (TRACKED.has(page))
20
+ return;
21
+ TRACKED.add(page);
22
+ page.on("response", (response) => {
23
+ const request = response.request();
24
+ if (!request.isNavigationRequest())
25
+ return;
26
+ if (request.frame() !== page.mainFrame())
27
+ return;
28
+ MITIGATED.set(page, response.headers()["cf-mitigated"] === "challenge");
29
+ });
30
+ }
31
+ export async function isChallenge(page) {
32
+ if (MITIGATED.get(page))
33
+ return true;
17
34
  const title = (await page.title().catch(() => "")).toLowerCase();
18
35
  return CHALLENGE_TITLES.some((t) => title.includes(t));
19
36
  }
@@ -26,7 +43,7 @@ async function cookieValue(page, name) {
26
43
  return null;
27
44
  }
28
45
  }
29
- async function humanActivity(page) {
46
+ export async function humanActivity(page, scale = 1) {
30
47
  let width = 1280;
31
48
  let height = 720;
32
49
  const view = page.viewportSize();
@@ -47,18 +64,19 @@ async function humanActivity(page) {
47
64
  width = 1280;
48
65
  }
49
66
  }
50
- const moves = Math.floor(between(4, 8));
67
+ const moves = Math.max(1, Math.floor(between(4, 8) * scale));
51
68
  for (let i = 0; i < moves; i++) {
52
69
  await page.mouse.move(between(width * 0.1, width * 0.9), between(height * 0.1, height * 0.9), { steps: Math.floor(between(6, 14)) });
53
70
  await sleep(between(250, 650));
54
71
  }
55
- const scrolls = Math.floor(between(2, 5));
72
+ const scrolls = Math.max(1, Math.floor(between(2, 5) * scale));
56
73
  for (let i = 0; i < scrolls; i++) {
57
74
  await page.mouse.wheel(0, between(60, 180));
58
75
  await sleep(between(400, 900));
59
76
  }
60
77
  }
61
78
  export async function waitForUam(page, options = {}) {
79
+ trackMitigation(page);
62
80
  const timeout = options.timeout ?? 30000;
63
81
  const start = Date.now();
64
82
  let challenged = false;
@@ -66,6 +84,13 @@ export async function waitForUam(page, options = {}) {
66
84
  while (Date.now() - start < timeout && !page.isClosed()) {
67
85
  if (await isChallenge(page)) {
68
86
  challenged = true;
87
+ if (options.assist) {
88
+ const acted = await options.assist(page).catch(() => false);
89
+ if (acted) {
90
+ await sleep(1500);
91
+ continue;
92
+ }
93
+ }
69
94
  try {
70
95
  await humanActivity(page);
71
96
  }
@@ -90,12 +115,12 @@ export async function waitForUam(page, options = {}) {
90
115
  return { challenged: false, bypassed: true, cookie };
91
116
  }
92
117
  try {
93
- await humanActivity(page);
118
+ await humanActivity(page, 0.4);
94
119
  }
95
120
  catch {
96
121
  await sleep(500);
97
122
  }
98
- await sleep(3000);
123
+ await sleep(2000);
99
124
  const second = await cookieValue(page, "cf_clearance");
100
125
  const retrySecond = await cookieValue(page, "cf_chl_rc_ni");
101
126
  if (second === cookie && !retrySecond) {
@@ -120,6 +145,7 @@ export function watchUam(page, options = {}) {
120
145
  if (WATCHED.has(page))
121
146
  return;
122
147
  WATCHED.add(page);
148
+ trackMitigation(page);
123
149
  const interval = options.interval ?? 1500;
124
150
  const timeout = options.timeout ?? 30000;
125
151
  const waitOnGoto = options.waitOnGoto ?? true;
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bexxcv",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "scripts": {