bexxcv 1.1.0 → 1.1.2
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 +267 -412
- package/dist/__version__.js +1 -1
- package/dist/fingerprints.d.ts +27 -2
- package/dist/fingerprints.js +122 -15
- package/dist/human_behavior.d.ts +20 -0
- package/dist/human_behavior.js +107 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -0
- package/dist/locale.js +7 -3
- package/dist/pkgman.js +5 -3
- package/dist/plugins/dodge.js +5 -2
- package/dist/plugins/gauntlet.d.ts +1 -0
- package/dist/plugins/gauntlet.js +8 -2
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/lens.js +77 -0
- package/dist/schema.js +11 -2
- package/dist/session.d.ts +26 -0
- package/dist/session.js +96 -0
- package/dist/turnstile.d.ts +2 -0
- package/dist/turnstile.js +8 -1
- package/dist/uam.d.ts +15 -1
- package/dist/uam.js +44 -81
- package/dist/utils.d.ts +12 -3
- package/dist/utils.js +177 -3
- package/dist/virtdisplay.js +23 -4
- package/dist/webgl/profiles.d.ts +12 -0
- package/dist/webgl/profiles.js +181 -0
- package/package.json +1 -1
package/dist/virtdisplay.js
CHANGED
|
@@ -2,7 +2,8 @@ import { execFileSync, spawn } from "node:child_process";
|
|
|
2
2
|
import { accessSync, constants as fsConstants, unlinkSync } from "node:fs";
|
|
3
3
|
import { CannotExecuteXvfb, CannotFindXvfb, VirtualDisplayNotSupported, } from "./exceptions.js";
|
|
4
4
|
import { OS_NAME } from "./pkgman.js";
|
|
5
|
-
const DISPLAYFD_READ_TIMEOUT_MS = 10_000;
|
|
5
|
+
const DISPLAYFD_READ_TIMEOUT_MS = Number(process.env.BEXXCV_XVFB_FD_TIMEOUT_MS) || 10_000;
|
|
6
|
+
const GRACEFUL_SHUTDOWN_TIMEOUT_MS = Number(process.env.BEXXCV_XVFB_GRACEFUL_TIMEOUT_MS) || 3_000;
|
|
6
7
|
export class VirtualDisplay {
|
|
7
8
|
debug;
|
|
8
9
|
proc = null;
|
|
@@ -117,7 +118,7 @@ export class VirtualDisplay {
|
|
|
117
118
|
if (this.debug) {
|
|
118
119
|
console.log("Terminating virtual display:", display);
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
+
const cleanupLock = () => {
|
|
121
122
|
try {
|
|
122
123
|
unlinkSync(`/tmp/.X${display}-lock`);
|
|
123
124
|
}
|
|
@@ -128,8 +129,26 @@ export class VirtualDisplay {
|
|
|
128
129
|
}
|
|
129
130
|
catch {
|
|
130
131
|
}
|
|
131
|
-
}
|
|
132
|
-
|
|
132
|
+
};
|
|
133
|
+
const tryCleanup = () => {
|
|
134
|
+
proc.removeListener("exit", tryCleanup);
|
|
135
|
+
cleanupLock();
|
|
136
|
+
};
|
|
137
|
+
proc.once("exit", tryCleanup);
|
|
138
|
+
proc.kill("SIGTERM");
|
|
139
|
+
const shutdownTimer = setTimeout(() => {
|
|
140
|
+
proc.removeListener("exit", tryCleanup);
|
|
141
|
+
if (proc.exitCode === null && !proc.killed) {
|
|
142
|
+
if (this.debug) {
|
|
143
|
+
console.log("Xvfb did not exit after SIGTERM, sending SIGKILL");
|
|
144
|
+
}
|
|
145
|
+
proc.kill("SIGKILL");
|
|
146
|
+
cleanupLock();
|
|
147
|
+
}
|
|
148
|
+
}, GRACEFUL_SHUTDOWN_TIMEOUT_MS);
|
|
149
|
+
if (!shutdownTimer.unref) {
|
|
150
|
+
shutdownTimer.unref();
|
|
151
|
+
}
|
|
133
152
|
}
|
|
134
153
|
static assert_linux() {
|
|
135
154
|
if (OS_NAME !== "lin") {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const KNOWN_GPUS: Record<"win" | "mac" | "lin", Array<{
|
|
2
|
+
vendor: string;
|
|
3
|
+
renderer: string;
|
|
4
|
+
weight: number;
|
|
5
|
+
}>>;
|
|
6
|
+
export declare function sampleGPUProfile(os: "win" | "mac" | "lin"): {
|
|
7
|
+
vendor: string;
|
|
8
|
+
renderer: string;
|
|
9
|
+
webglExtensions: string[];
|
|
10
|
+
glslVersion: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function resolveUAOS(userAgent: string): "win" | "mac" | "lin";
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { UAParser } from "ua-parser-js";
|
|
2
|
+
export const KNOWN_GPUS = {
|
|
3
|
+
win: [
|
|
4
|
+
// Intel integrated — most common on office/home PCs
|
|
5
|
+
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 630", weight: 28 },
|
|
6
|
+
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 620", weight: 18 },
|
|
7
|
+
{ vendor: "Intel", renderer: "Intel(R) Iris Xe Graphics", weight: 14 },
|
|
8
|
+
{ vendor: "Intel", renderer: "Intel(R) HD Graphics 620", weight: 8 },
|
|
9
|
+
{ vendor: "Intel", renderer: "Intel(R) HD Graphics 530", weight: 5 },
|
|
10
|
+
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 730", weight: 3 },
|
|
11
|
+
// NVIDIA discrete — gaming/workstations
|
|
12
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce GTX 1650", weight: 10 },
|
|
13
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce GTX 1050 Ti", weight: 7 },
|
|
14
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 3060", weight: 5 },
|
|
15
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 3060 Ti", weight: 3 },
|
|
16
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 4060", weight: 2 },
|
|
17
|
+
// AMD discrete
|
|
18
|
+
{ vendor: "AMD", renderer: "AMD Radeon RX 6600", weight: 4 },
|
|
19
|
+
{ vendor: "AMD", renderer: "AMD Radeon RX 580", weight: 3 },
|
|
20
|
+
{ vendor: "AMD", renderer: "AMD Radeon RX 7800 XT", weight: 2 },
|
|
21
|
+
// Microsoft basic — VM fallback
|
|
22
|
+
{ vendor: "Microsoft", renderer: "Microsoft Basic Render Driver", weight: 2 },
|
|
23
|
+
],
|
|
24
|
+
mac: [
|
|
25
|
+
// Apple Silicon
|
|
26
|
+
{ vendor: "Apple", renderer: "Apple M1", weight: 22 },
|
|
27
|
+
{ vendor: "Apple", renderer: "Apple M1 Pro", weight: 14 },
|
|
28
|
+
{ vendor: "Apple", renderer: "Apple M1 Max", weight: 8 },
|
|
29
|
+
{ vendor: "Apple", renderer: "Apple M2", weight: 18 },
|
|
30
|
+
{ vendor: "Apple", renderer: "Apple M2 Pro", weight: 10 },
|
|
31
|
+
{ vendor: "Apple", renderer: "Apple M3", weight: 8 },
|
|
32
|
+
{ vendor: "Apple", renderer: "Apple M3 Pro", weight: 6 },
|
|
33
|
+
{ vendor: "Apple", renderer: "Apple M4", weight: 4 },
|
|
34
|
+
{ vendor: "Apple", renderer: "Apple M4 Pro", weight: 3 },
|
|
35
|
+
// Intel Macs (still common in enterprise)
|
|
36
|
+
{ vendor: "Apple", renderer: "Apple Integrated GPU", weight: 5 },
|
|
37
|
+
{ vendor: "Apple", renderer: "Apple MacBook Pro GPU", weight: 2 },
|
|
38
|
+
],
|
|
39
|
+
lin: [
|
|
40
|
+
// Intel on Linux desktops
|
|
41
|
+
{ vendor: "Intel", renderer: "Intel(R) HD Graphics 630 (KBL GT2)", weight: 18 },
|
|
42
|
+
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 630 (CFL GT2)", weight: 10 },
|
|
43
|
+
{ vendor: "Intel", renderer: "Intel(R) UHD Graphics 770 (ADL GT2)", weight: 7 },
|
|
44
|
+
{ vendor: "Intel", renderer: "Mesa Intel(R) UHD Graphics 620 (KBL GT2)", weight: 6 },
|
|
45
|
+
{ vendor: "Intel", renderer: "Mesa Intel(R) UHD Graphics 630 (KBL GT2)", weight: 4 },
|
|
46
|
+
// NVIDIA on Linux
|
|
47
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 3080", weight: 8 },
|
|
48
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 3060", weight: 6 },
|
|
49
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce RTX 4090", weight: 3 },
|
|
50
|
+
{ vendor: "NVIDIA", renderer: "NVIDIA GeForce GTX 1650", weight: 4 },
|
|
51
|
+
// AMD on Linux
|
|
52
|
+
{ vendor: "AMD", renderer: "AMD Radeon RX 6600 (RADV NAVI23)", weight: 5 },
|
|
53
|
+
{ vendor: "AMD", renderer: "AMD Radeon RX 7800 XT (RADV NAVI32)", weight: 4 },
|
|
54
|
+
{ vendor: "AMD", renderer: "AMD Radeon Graphics (RADV NAVI21)", weight: 5 },
|
|
55
|
+
{ vendor: "AMD", renderer: "AMD Radeon RX 7900 XTX (RADV NAVI31)", weight: 3 },
|
|
56
|
+
// Software renderers (VMs, CI servers)
|
|
57
|
+
{ vendor: "llvmpipe", renderer: "llvmpipe (LLVM 15.0.7 256 bits)", weight: 8 },
|
|
58
|
+
{ vendor: "llvmpipe", renderer: "llvmpipe (LLVM 16.0.6 256 bits)", weight: 4 },
|
|
59
|
+
{ vendor: "Google Inc.", renderer: "ANGLE (Intel, Intel(R) UHD Graphics 630, OpenGL 4.6)", weight: 5 },
|
|
60
|
+
{ vendor: "Mozilla", renderer: "WebRender (NVIDIA Corporation -- 4.6 (Compatibility))", weight: 3 },
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
const BASE_WEBGL_EXTENSIONS = [
|
|
64
|
+
"WEBGL_lose_context",
|
|
65
|
+
"WEBGL_compressed_texture_s3tc",
|
|
66
|
+
"WEBGL_compressed_texture_astc",
|
|
67
|
+
"WEBGL_compressed_texture_ETC1",
|
|
68
|
+
"WEBGL_depth_texture",
|
|
69
|
+
"WEBGL_draw_buffers",
|
|
70
|
+
"WEBGL_debug_renderer_info",
|
|
71
|
+
"WEBGL_debug_shaders",
|
|
72
|
+
"EXT_blend_minmax",
|
|
73
|
+
"EXT_color_buffer_half_float",
|
|
74
|
+
"EXT_float_blend",
|
|
75
|
+
"EXT_frag_depth",
|
|
76
|
+
"EXT_shader_texture_lod",
|
|
77
|
+
"EXT_texture_compression_rgtc",
|
|
78
|
+
"EXT_texture_filter_anisotropic",
|
|
79
|
+
"KHR_parallel_shader_compile",
|
|
80
|
+
"OES_element_index_uint",
|
|
81
|
+
"OES_standard_derivatives",
|
|
82
|
+
"OES_vertex_array_object",
|
|
83
|
+
"WEBGL_color_buffer_float",
|
|
84
|
+
"WEBGL_provoking_vertex",
|
|
85
|
+
];
|
|
86
|
+
// Optional extensions that some GPUs/drivers support
|
|
87
|
+
const OPTIONAL_EXTENSIONS_WIN = ["WEBGL_sample_variables", "EXT_color_buffer_float"];
|
|
88
|
+
const OPTIONAL_EXTENSIONS_MAC = ["WEBGL_sample_variables", "EXT_color_buffer_float"];
|
|
89
|
+
const OPTIONAL_EXTENSIONS_LIN = [
|
|
90
|
+
"WEBGL_sample_variables",
|
|
91
|
+
"EXT_color_buffer_float",
|
|
92
|
+
"WEBGL_polygon_mode",
|
|
93
|
+
"EXT_shader_texture_lod",
|
|
94
|
+
"WEBGL_clip_cull_distance",
|
|
95
|
+
];
|
|
96
|
+
function pickWeighted(items, weights) {
|
|
97
|
+
const total = weights.reduce((a, b) => a + b, 0);
|
|
98
|
+
const buf = new Uint32Array(1);
|
|
99
|
+
crypto.getRandomValues(buf);
|
|
100
|
+
let threshold = (buf[0] / 0x100000000) * total;
|
|
101
|
+
for (let i = 0; i < items.length; i++) {
|
|
102
|
+
threshold -= weights[i];
|
|
103
|
+
if (threshold <= 0)
|
|
104
|
+
return items[i];
|
|
105
|
+
}
|
|
106
|
+
return items[items.length - 1];
|
|
107
|
+
}
|
|
108
|
+
export function sampleGPUProfile(os) {
|
|
109
|
+
const pool = KNOWN_GPUS[os];
|
|
110
|
+
const gpu = pickWeighted(pool.map(g => g.renderer), pool.map(g => g.weight));
|
|
111
|
+
const vendorEntry = pool.find(g => g.renderer === gpu);
|
|
112
|
+
const vendor = vendorEntry.vendor;
|
|
113
|
+
// Build base extension list
|
|
114
|
+
const baseExts = [...BASE_WEBGL_EXTENSIONS];
|
|
115
|
+
// Add optional extensions probabilistically
|
|
116
|
+
const optionalPool = os === "win"
|
|
117
|
+
? OPTIONAL_EXTENSIONS_WIN
|
|
118
|
+
: os === "mac"
|
|
119
|
+
? OPTIONAL_EXTENSIONS_MAC
|
|
120
|
+
: OPTIONAL_EXTENSIONS_LIN;
|
|
121
|
+
const numOptional = cryptoRandInt(0, Math.min(2, optionalPool.length));
|
|
122
|
+
for (let i = 0; i < numOptional; i++) {
|
|
123
|
+
const ext = optionalPool[cryptoRandInt(0, optionalPool.length - 1)];
|
|
124
|
+
if (!baseExts.includes(ext))
|
|
125
|
+
baseExts.push(ext);
|
|
126
|
+
}
|
|
127
|
+
baseExts.sort();
|
|
128
|
+
// GLSL version varies by vendor/driver generation
|
|
129
|
+
const glslVersionsByVendor = {
|
|
130
|
+
Intel: [
|
|
131
|
+
"OpenGL ES GLSL 3.00 (Build 31.0.101.2115)",
|
|
132
|
+
"OpenGL GLSL 4.60",
|
|
133
|
+
"OpenGL ES GLSL 3.00 (Build 31.0.101.2139)",
|
|
134
|
+
],
|
|
135
|
+
NVIDIA: [
|
|
136
|
+
"OpenGL GLSL 4.60 NVIDIA",
|
|
137
|
+
"OpenGL ES GLSL 3.00 NVIDIA",
|
|
138
|
+
"OpenGL GLSL 4.50 NVIDIA",
|
|
139
|
+
],
|
|
140
|
+
AMD: [
|
|
141
|
+
"OpenGL GLSL 4.60",
|
|
142
|
+
"OpenGL ES GLSL 3.00 (Builder ID:808)",
|
|
143
|
+
"OpenGL GLSL 4.50 AMD",
|
|
144
|
+
],
|
|
145
|
+
Mesa: [
|
|
146
|
+
"OpenGL GLSL 4.60 (adapter: Mesa; driver: ",
|
|
147
|
+
"OpenGL ES GLSL 3.00 (Mesa 23.2.1-1debian)",
|
|
148
|
+
"OpenGL GLSL 4.50 (Mesa 22.3.6)",
|
|
149
|
+
],
|
|
150
|
+
Apple: [
|
|
151
|
+
"OpenGL GLSL 4.1",
|
|
152
|
+
"OpenGL ES GLSL 3.00",
|
|
153
|
+
"Metal API GLSL 1.3.0",
|
|
154
|
+
],
|
|
155
|
+
"llvmpipe": [
|
|
156
|
+
"OpenGL GLSL 4.50 (Mesa 23.2.1)",
|
|
157
|
+
"OpenGL ES GLSL 3.00 (llvmpipe LLVM 15.0.7)",
|
|
158
|
+
],
|
|
159
|
+
Microsoft: ["OpenGL ES GLSL 1.0.0"],
|
|
160
|
+
Mozilla: ["OpenGL GLSL 4.60"],
|
|
161
|
+
Google: ["OpenGL ES GLSL 3.00"],
|
|
162
|
+
};
|
|
163
|
+
const vendorGlsl = glslVersionsByVendor[vendor.toLowerCase()] ?? ["OpenGL GLSL 4.60"];
|
|
164
|
+
const glslVersion = vendorGlsl[cryptoRandInt(0, vendorGlsl.length - 1)];
|
|
165
|
+
return { vendor, renderer: gpu, webglExtensions: baseExts, glslVersion };
|
|
166
|
+
}
|
|
167
|
+
// Convenience wrapper using crypto-safe random
|
|
168
|
+
function cryptoRandInt(min, max) {
|
|
169
|
+
const buf = new Uint32Array(1);
|
|
170
|
+
crypto.getRandomValues(buf);
|
|
171
|
+
return min + (buf[0] % (max - min + 1));
|
|
172
|
+
}
|
|
173
|
+
export function resolveUAOS(userAgent) {
|
|
174
|
+
const parser = new UAParser(userAgent);
|
|
175
|
+
const osName = parser.getOS().name ?? "";
|
|
176
|
+
if (osName.startsWith("macOS") || osName.includes("Mac"))
|
|
177
|
+
return "mac";
|
|
178
|
+
if (osName.startsWith("Windows"))
|
|
179
|
+
return "win";
|
|
180
|
+
return "lin";
|
|
181
|
+
}
|