bexxcv 0.0.0-stage → 1.0.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 (48) hide show
  1. package/README.md +493 -2
  2. package/dist/__main__.d.ts +2 -0
  3. package/dist/__main__.js +156 -0
  4. package/dist/__version__.d.ts +5 -0
  5. package/dist/__version__.js +5 -0
  6. package/dist/addons.d.ts +7 -0
  7. package/dist/addons.js +56 -0
  8. package/dist/browser-pin.d.ts +15 -0
  9. package/dist/browser-pin.js +34 -0
  10. package/dist/data-files/browser-pin.json +7 -0
  11. package/dist/data-files/territoryInfo.xml +2024 -0
  12. package/dist/exceptions.d.ts +79 -0
  13. package/dist/exceptions.js +159 -0
  14. package/dist/fingerprints.d.ts +5 -0
  15. package/dist/fingerprints.js +92 -0
  16. package/dist/index.d.ts +6 -0
  17. package/dist/index.js +6 -0
  18. package/dist/ip.d.ts +23 -0
  19. package/dist/ip.js +98 -0
  20. package/dist/locale.d.ts +26 -0
  21. package/dist/locale.js +292 -0
  22. package/dist/mappings/browserforge.config.d.ts +44 -0
  23. package/dist/mappings/browserforge.config.js +43 -0
  24. package/dist/mappings/fonts.config.d.ts +6 -0
  25. package/dist/mappings/fonts.config.js +822 -0
  26. package/dist/mappings/warnings.config.d.ts +16 -0
  27. package/dist/mappings/warnings.config.js +28 -0
  28. package/dist/multiversion.d.ts +27 -0
  29. package/dist/multiversion.js +88 -0
  30. package/dist/pkgman.d.ts +69 -0
  31. package/dist/pkgman.js +529 -0
  32. package/dist/selfupdate.d.ts +8 -0
  33. package/dist/selfupdate.js +84 -0
  34. package/dist/server.d.ts +3 -0
  35. package/dist/server.js +6 -0
  36. package/dist/sync_api.d.ts +11 -0
  37. package/dist/sync_api.js +47 -0
  38. package/dist/utils.d.ts +45 -0
  39. package/dist/utils.js +514 -0
  40. package/dist/virtdisplay.d.ts +12 -0
  41. package/dist/virtdisplay.js +139 -0
  42. package/dist/warnings.d.ts +4 -0
  43. package/dist/warnings.js +33 -0
  44. package/dist/webgl/sample.d.ts +19 -0
  45. package/dist/webgl/sample.js +103 -0
  46. package/dist/xvfb.d.ts +6 -0
  47. package/dist/xvfb.js +25 -0
  48. package/package.json +103 -5
@@ -0,0 +1,139 @@
1
+ import { execFileSync, spawn } from "node:child_process";
2
+ import { accessSync, constants as fsConstants, unlinkSync } from "node:fs";
3
+ import { CannotExecuteXvfb, CannotFindXvfb, VirtualDisplayNotSupported, } from "./exceptions.js";
4
+ import { OS_NAME } from "./pkgman.js";
5
+ const DISPLAYFD_READ_TIMEOUT_MS = 10_000;
6
+ export class VirtualDisplay {
7
+ debug;
8
+ proc = null;
9
+ _display = null;
10
+ constructor(debug = false) {
11
+ this.debug = debug;
12
+ }
13
+ get xvfb_args() {
14
+ return [
15
+ "-screen",
16
+ "0",
17
+ "1x1x24",
18
+ "-ac",
19
+ "-nolisten",
20
+ "tcp",
21
+ "-extension",
22
+ "RENDER",
23
+ "+extension",
24
+ "GLX",
25
+ "-extension",
26
+ "COMPOSITE",
27
+ "-extension",
28
+ "XVideo",
29
+ "-extension",
30
+ "XVideo-MotionCompensation",
31
+ "-extension",
32
+ "XINERAMA",
33
+ "-fp",
34
+ "built-ins",
35
+ "-nocursor",
36
+ "-br",
37
+ ];
38
+ }
39
+ get xvfb_path() {
40
+ let resolved;
41
+ try {
42
+ resolved = execFileSync("which", ["Xvfb"]).toString().trim();
43
+ }
44
+ catch {
45
+ throw new CannotFindXvfb("Xvfb not found. Install it with: sudo apt-get install xvfb");
46
+ }
47
+ if (!resolved) {
48
+ throw new CannotFindXvfb("Xvfb not found. Install it with: sudo apt-get install xvfb");
49
+ }
50
+ try {
51
+ accessSync(resolved, fsConstants.X_OK);
52
+ }
53
+ catch {
54
+ throw new CannotExecuteXvfb(`No execute permission on Xvfb: ${resolved}`);
55
+ }
56
+ return resolved;
57
+ }
58
+ spawnXvfb() {
59
+ const xvfbPath = this.xvfb_path;
60
+ const cmd = [xvfbPath, "-displayfd", "3", ...this.xvfb_args];
61
+ if (this.debug) {
62
+ console.log("Starting virtual display:", cmd.join(" "));
63
+ }
64
+ return spawn(cmd[0], cmd.slice(1), {
65
+ stdio: [
66
+ "ignore",
67
+ this.debug ? "inherit" : "ignore",
68
+ this.debug ? "inherit" : "ignore",
69
+ "pipe",
70
+ ],
71
+ detached: true,
72
+ env: {
73
+ ...process.env,
74
+ __GLX_VENDOR_LIBRARY_NAME: "mesa",
75
+ LIBGL_ALWAYS_SOFTWARE: "1",
76
+ },
77
+ });
78
+ }
79
+ async get() {
80
+ VirtualDisplay.assert_linux();
81
+ if (!this.proc) {
82
+ this.proc = this.spawnXvfb();
83
+ const stream = this.proc.stdio[3];
84
+ const timer = setTimeout(() => stream.destroy(new CannotExecuteXvfb(`Xvfb did not report a display within ${DISPLAYFD_READ_TIMEOUT_MS}ms`)), DISPLAYFD_READ_TIMEOUT_MS);
85
+ let buf = "";
86
+ try {
87
+ for await (const chunk of stream) {
88
+ buf += chunk;
89
+ if (buf.includes("\n"))
90
+ break;
91
+ }
92
+ }
93
+ catch (err) {
94
+ this.kill();
95
+ throw err;
96
+ }
97
+ finally {
98
+ clearTimeout(timer);
99
+ }
100
+ const n = Number.parseInt(buf, 10);
101
+ if (!Number.isFinite(n)) {
102
+ this.kill();
103
+ throw new CannotExecuteXvfb(`Xvfb did not report a display (got ${JSON.stringify(buf)}, exit=${this.proc.exitCode})`);
104
+ }
105
+ this._display = n;
106
+ }
107
+ else if (this.debug) {
108
+ console.log(`Using virtual display: ${this._display}`);
109
+ }
110
+ return `:${this._display}`;
111
+ }
112
+ kill() {
113
+ const proc = this.proc;
114
+ const display = this._display;
115
+ if (!proc || proc.exitCode !== null || proc.killed)
116
+ return;
117
+ if (this.debug) {
118
+ console.log("Terminating virtual display:", display);
119
+ }
120
+ proc.once("exit", () => {
121
+ try {
122
+ unlinkSync(`/tmp/.X${display}-lock`);
123
+ }
124
+ catch {
125
+ }
126
+ try {
127
+ unlinkSync(`/tmp/.X11-unix/X${display}`);
128
+ }
129
+ catch {
130
+ }
131
+ });
132
+ proc.kill("SIGKILL");
133
+ }
134
+ static assert_linux() {
135
+ if (OS_NAME !== "lin") {
136
+ throw new VirtualDisplayNotSupported("Virtual display is only supported on Linux.");
137
+ }
138
+ }
139
+ }
@@ -0,0 +1,4 @@
1
+ export declare class LeakWarning extends Error {
2
+ constructor(message: string);
3
+ static warn(warningKey: string, iKnowWhatImDoing?: boolean): void;
4
+ }
@@ -0,0 +1,33 @@
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import WARNINGS_DATA from "./mappings/warnings.config.js";
4
+ const currentDir = import.meta.dirname ?? path.dirname(fileURLToPath(import.meta.url));
5
+ export class LeakWarning extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = "LeakWarning";
9
+ }
10
+ static warn(warningKey, iKnowWhatImDoing) {
11
+ let warning = WARNINGS_DATA[warningKey];
12
+ if (iKnowWhatImDoing) {
13
+ return;
14
+ }
15
+ if (iKnowWhatImDoing !== undefined) {
16
+ warning += "\nIf this is intentional, pass `iKnowWhatImDoing=true`.";
17
+ }
18
+ const currentModule = currentDir;
19
+ const originalStackTrace = Error.prepareStackTrace;
20
+ Error.prepareStackTrace = (_, stack) => stack;
21
+ const err = new Error();
22
+ const stack = err.stack;
23
+ Error.prepareStackTrace = originalStackTrace;
24
+ for (const frame of stack) {
25
+ const frameFileName = frame.getFileName();
26
+ if (frameFileName && !frameFileName.startsWith(currentModule)) {
27
+ console.warn(`${warning} at ${frameFileName}:${frame.getLineNumber()}`);
28
+ return;
29
+ }
30
+ }
31
+ console.warn(warning);
32
+ }
33
+ }
@@ -0,0 +1,19 @@
1
+ interface WebGLData {
2
+ vendor: string;
3
+ renderer: string;
4
+ data: string;
5
+ win: number;
6
+ mac: number;
7
+ lin: number;
8
+ webGl2Enabled: boolean;
9
+ }
10
+ interface VendorRenderer {
11
+ vendor: string;
12
+ renderer: string;
13
+ }
14
+ interface PossiblePairs {
15
+ [key: string]: Array<VendorRenderer>;
16
+ }
17
+ export declare function sampleWebGL(os: "win" | "mac" | "lin", vendor?: string, renderer?: string): Promise<WebGLData>;
18
+ export declare function getPossiblePairs(): Promise<PossiblePairs>;
19
+ export {};
@@ -0,0 +1,103 @@
1
+ import path from "node:path";
2
+ import { fileURLToPath } from "node:url";
3
+ import { OS_ARCH_MATRIX } from "../pkgman.js";
4
+ let DatabaseConstructor = null;
5
+ async function openDatabase(pathName) {
6
+ if (!DatabaseConstructor) {
7
+ if (typeof Bun !== "undefined") {
8
+ const { Database: BunDatabase } = await import("bun:sqlite");
9
+ DatabaseConstructor = BunDatabase;
10
+ }
11
+ else if (typeof Deno !== "undefined") {
12
+ const { DatabaseSync } = await import("node:sqlite");
13
+ DatabaseConstructor = DatabaseSync;
14
+ }
15
+ else {
16
+ const { default: BetterSqlite3 } = await import("better-sqlite3");
17
+ DatabaseConstructor = BetterSqlite3;
18
+ }
19
+ }
20
+ return new DatabaseConstructor(pathName);
21
+ }
22
+ const currentDir = import.meta.dirname ?? path.dirname(fileURLToPath(import.meta.url));
23
+ const DB_PATH = path.join(currentDir, "..", "data-files", "webgl_data.db");
24
+ export async function sampleWebGL(os, vendor, renderer) {
25
+ if (!OS_ARCH_MATRIX[os]) {
26
+ throw new Error(`Invalid OS: ${os}. Must be one of: win, mac, lin`);
27
+ }
28
+ const db = await openDatabase(DB_PATH);
29
+ let query = "";
30
+ let params = [];
31
+ if (vendor && renderer) {
32
+ query = `SELECT vendor, renderer, data, ${os} FROM webgl_fingerprints WHERE vendor = ? AND renderer = ?`;
33
+ params = [vendor, renderer];
34
+ }
35
+ else {
36
+ query = `SELECT vendor, renderer, data, ${os} FROM webgl_fingerprints WHERE ${os} > 0`;
37
+ }
38
+ return new Promise((resolve, reject) => {
39
+ try {
40
+ const rows = db.prepare(query).all(...params);
41
+ if (rows.length === 0) {
42
+ reject(new Error(`No WebGL data found for OS: ${os}`));
43
+ return;
44
+ }
45
+ if (vendor && renderer) {
46
+ const result = rows[0];
47
+ if (result[os] <= 0) {
48
+ const pairs = db
49
+ .prepare(`SELECT DISTINCT vendor, renderer FROM webgl_fingerprints WHERE ${os} > 0`)
50
+ .all();
51
+ reject(new Error(`Vendor "${vendor}" and renderer "${renderer}" combination not valid for ${os}. Possible pairs: ${pairs.map((pair) => `${pair.vendor}, ${pair.renderer}`).join(", ")}`));
52
+ return;
53
+ }
54
+ resolve(JSON.parse(result.data));
55
+ }
56
+ else {
57
+ const dataStrs = rows.map((row) => row.data);
58
+ const probs = rows.map((row) => row[os]);
59
+ const total = probs.reduce((a, b) => a + b, 0);
60
+ const probsNorm = probs.map((p) => p / total);
61
+ let cumulative = 0;
62
+ const buf = new Uint32Array(1);
63
+ crypto.getRandomValues(buf);
64
+ const threshold = (buf[0] / 0xffffffff) * 1;
65
+ let idx = probsNorm.length - 1;
66
+ for (let i = 0; i < probsNorm.length; i++) {
67
+ cumulative += probsNorm[i];
68
+ if (threshold <= cumulative) {
69
+ idx = i;
70
+ break;
71
+ }
72
+ }
73
+ resolve(JSON.parse(dataStrs[idx]));
74
+ }
75
+ }
76
+ catch (err) {
77
+ reject(err);
78
+ }
79
+ }).finally(() => {
80
+ db.close();
81
+ });
82
+ }
83
+ export async function getPossiblePairs() {
84
+ const db = await openDatabase(DB_PATH);
85
+ const result = {};
86
+ return new Promise((resolve, reject) => {
87
+ try {
88
+ const osTypes = Object.keys(OS_ARCH_MATRIX);
89
+ osTypes.forEach((os_type) => {
90
+ const rows = db
91
+ .prepare(`SELECT DISTINCT vendor, renderer FROM webgl_fingerprints WHERE ${os_type} > 0 ORDER BY ${os_type} DESC`)
92
+ .all();
93
+ result[os_type] = rows;
94
+ });
95
+ resolve(result);
96
+ }
97
+ catch (err) {
98
+ reject(err);
99
+ }
100
+ }).finally(() => {
101
+ db.close();
102
+ });
103
+ }
package/dist/xvfb.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare function needsXvfb(): boolean;
2
+ export declare function startXvfb(debug?: boolean): Promise<{
3
+ display: string;
4
+ kill: () => void;
5
+ }>;
6
+ export declare function withXvfb<T>(fn: (display: string) => Promise<T>, debug?: boolean): Promise<T>;
package/dist/xvfb.js ADDED
@@ -0,0 +1,25 @@
1
+ import { OS_NAME } from "./pkgman.js";
2
+ import { VirtualDisplay } from "./virtdisplay.js";
3
+ export function needsXvfb() {
4
+ return (OS_NAME === "lin" &&
5
+ !process.env.DISPLAY &&
6
+ !process.env.WAYLAND_DISPLAY);
7
+ }
8
+ export async function startXvfb(debug = false) {
9
+ const vd = new VirtualDisplay(debug);
10
+ const display = await vd.get();
11
+ return {
12
+ display,
13
+ kill: () => vd.kill(),
14
+ };
15
+ }
16
+ export async function withXvfb(fn, debug = false) {
17
+ const vd = new VirtualDisplay(debug);
18
+ const display = await vd.get();
19
+ try {
20
+ return await fn(display);
21
+ }
22
+ finally {
23
+ vd.kill();
24
+ }
25
+ }
package/package.json CHANGED
@@ -1,6 +1,104 @@
1
1
  {
2
- "name": "bexxcv",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "bexxcv",
3
+ "version": "1.0.0",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "scripts": {
7
+ "build": "rimraf dist && tsc && pnpm copy-files",
8
+ "test": "vitest",
9
+ "copy-files": "cp -r src/data-files dist/data-files",
10
+ "check": "biome check",
11
+ "fetch": "node dist/__main__.js fetch"
12
+ },
13
+ "bin": "dist/__main__.js",
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "type": "module",
18
+ "keywords": [
19
+ "camoufox",
20
+ "playwright",
21
+ "firefox",
22
+ "stealth",
23
+ "fingerprint",
24
+ "anti-detection"
25
+ ],
26
+ "author": "",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/fidzzcodex-me/bexxcv"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/fidzzcodex-me/bexxcv/issues"
33
+ },
34
+ "engines": {
35
+ "node": ">= 22"
36
+ },
37
+ "license": "MPL-2.0",
38
+ "description": "High-performance stealth Firefox automation. Fork of camoufox-js with parallel IP resolution, crypto-grade fingerprint seeds, exponential backoff, and zero-config Xvfb.",
39
+ "packageManager": "pnpm@10.33.4",
40
+ "dependencies": {
41
+ "adm-zip": "^0.6.0",
42
+ "better-sqlite3": "^13.0.1",
43
+ "cli-progress": "^3.12.0",
44
+ "commander": "^14.0.0",
45
+ "fingerprint-generator": "^2.1.86",
46
+ "glob": "^13.0.0",
47
+ "impit": "^0.14.1",
48
+ "language-tags": "^2.0.1",
49
+ "maxmind": "^5.0.0",
50
+ "pretty-bytes": "^7.1.0",
51
+ "ua-parser-js": "^2.0.10",
52
+ "xml2js": "^0.6.2"
53
+ },
54
+ "devDependencies": {
55
+ "@biomejs/biome": "2.4.10",
56
+ "@types/adm-zip": "^0.5.7",
57
+ "@types/better-sqlite3": "^7.6.13",
58
+ "@types/cli-progress": "^3.11.6",
59
+ "@types/language-tags": "^1.0.4",
60
+ "@types/node": "^24.0.0",
61
+ "@types/xml2js": "^0.4.14",
62
+ "playwright-core": "<1.63.0",
63
+ "rimraf": "^6.0.1",
64
+ "typescript": "^5.8.3",
65
+ "vitest": "^4.0.0"
66
+ },
67
+ "peerDependencies": {
68
+ "playwright-core": "<1.63.0"
69
+ },
70
+ "devEngines": {
71
+ "packageManager": {
72
+ "name": "pnpm",
73
+ "version": "10.33.4",
74
+ "onFail": "warn"
75
+ }
76
+ },
77
+ "pnpm": {
78
+ "overrides": {
79
+ "vite": ">=8.0.16"
80
+ }
81
+ },
82
+ "exports": {
83
+ ".": {
84
+ "import": "./dist/index.js",
85
+ "types": "./dist/index.d.ts"
86
+ },
87
+ "./xvfb": {
88
+ "import": "./dist/xvfb.js",
89
+ "types": "./dist/xvfb.d.ts"
90
+ },
91
+ "./virtdisplay": {
92
+ "import": "./dist/virtdisplay.js",
93
+ "types": "./dist/virtdisplay.d.ts"
94
+ },
95
+ "./exceptions": {
96
+ "import": "./dist/exceptions.js",
97
+ "types": "./dist/exceptions.d.ts"
98
+ },
99
+ "./selfupdate": {
100
+ "import": "./dist/selfupdate.js",
101
+ "types": "./dist/selfupdate.d.ts"
102
+ }
103
+ }
104
+ }