camoucore 0.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/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JWriter20 and the CamouCore contributors
4
+ Copyright (c) 2024-2026 daijro and the Camoufox contributors
5
+
6
+ CamouCore is derived from the Camoufox Python launcher
7
+ (https://github.com/daijro/camoufox, python/), which is distributed under this
8
+ same license, by way of the Camouwolf launcher.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
@@ -0,0 +1,64 @@
1
+ # Third-party notices
2
+
3
+ The camoucore TypeScript package is MIT-licensed (see `LICENSE`). It contains
4
+ ports of the third-party code below, each under its own licence.
5
+
6
+ ## NumPy — `src/locales.ts`
7
+
8
+ A port of NumPy's pairwise float64 summation (`np.sum`):
9
+
10
+ ```
11
+ Copyright (c) 2005-2025, NumPy Developers.
12
+ All rights reserved.
13
+
14
+ Redistribution and use in source and binary forms, with or without
15
+ modification, are permitted provided that the following conditions are
16
+ met:
17
+
18
+ * Redistributions of source code must retain the above copyright
19
+ notice, this list of conditions and the following disclaimer.
20
+
21
+ * Redistributions in binary form must reproduce the above
22
+ copyright notice, this list of conditions and the following
23
+ disclaimer in the documentation and/or other materials provided
24
+ with the distribution.
25
+
26
+ * Neither the name of the NumPy Developers nor the names of any
27
+ contributors may be used to endorse or promote products derived
28
+ from this software without specific prior written permission.
29
+
30
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41
+ ```
42
+
43
+ The PCG64 bit generator it drives:
44
+
45
+ ```
46
+ PCG Random Number Generation for C.
47
+
48
+ Copyright 2014 Melissa O'Neill <oneill@pcg-random.org>
49
+
50
+ Permission is hereby granted, free of charge, to any person obtaining
51
+ a copy of this software and associated documentation files (the "Software"),
52
+ to deal in the Software without restriction, including without limitation
53
+ the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
54
+
55
+ The above copyright notice and this permission notice shall be included in
56
+ all copies or substantial portions of the Software.
57
+
58
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
59
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
60
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
61
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
62
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
63
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
64
+ ```
@@ -0,0 +1,49 @@
1
+ /** Whether this host can constrain a process to a subset of its cores. */
2
+ export declare function supported(): boolean;
3
+ /** Parse a Linux cpu list ("0-3,8,10-11") into sorted core numbers. */
4
+ export declare function parseCpuList(list: string): number[];
5
+ /** The cores this process may run on, in order. */
6
+ export declare function hostCores(): number[] | null;
7
+ /**
8
+ * How many cores the host lets this process use, as read before this process
9
+ * first pinned itself. playwright-core spawns the browser from this process,
10
+ * so pin() narrows this process's own mask during a launch; a live reading
11
+ * taken then by a concurrent launch (hostCores(), or Node's
12
+ * availableParallelism()) would see the pinned count and pass it off as the
13
+ * host's. Python pins a separate driver process and never has this problem.
14
+ */
15
+ export declare function hostCoreCount(): number;
16
+ /**
17
+ * `count` adjacent cores from a random starting point (wrapping). Always
18
+ * taking the first `count` stacked every browser on one host onto cores
19
+ * 0..count-1, so concurrent browsers measured far less parallelism than they
20
+ * report; adjacent cores keep the SMT topology a real machine of that size
21
+ * would have.
22
+ */
23
+ export declare function pick(cores: readonly number[], count: number): number[];
24
+ /**
25
+ * Restrict `pid` to `count` of its cores. Returns the previous set so it can
26
+ * be handed back to `restore()`, or null if nothing was changed.
27
+ *
28
+ * The caller must not pin the same process for two launches at once: the
29
+ * browser inherits whatever mask the driver has when it is spawned.
30
+ */
31
+ export declare function pin(pid: number, count: number): number[] | null;
32
+ /** Give `pid` back the cores it had before `pin()`. */
33
+ export declare function restore(pid: number, previous: readonly number[] | null): void;
34
+ export declare function maskToCores(mask: bigint): number[];
35
+ export declare function coresToMask(cores: Iterable<number>): bigint;
36
+ /**
37
+ * Run `fn` while holding the process-wide pin lock. The browser inherits the
38
+ * driver's mask at spawn, so two concurrent launches must not interleave
39
+ * pin/restore: the second pin would land on the first browser, and the first
40
+ * restore would leave the driver pinned. (Python: async_api._pin_lock.)
41
+ */
42
+ export declare function withPinLock<T>(fn: () => Promise<T>): Promise<T>;
43
+ /**
44
+ * Run an UNPINNED launch. It spawns a browser too, which inherits whatever
45
+ * mask this process has at that moment, so once any launch in this process
46
+ * has pinned, it waits for the lock rather than spawning into another
47
+ * launch's pin. Until then (pin_cpu_cores is opt-in) it runs straight away.
48
+ */
49
+ export declare function withUnpinnedLaunch<T>(fn: () => Promise<T>): Promise<T>;
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Pin the browser to as many cores as the identity reports, so the cores a page
3
+ * can measure agree with navigator.hardwareConcurrency. Twin of cpu_affinity.py;
4
+ * the driver is this process, so its main thread is pinned around the launch.
5
+ */
6
+ import { execFileSync } from "node:child_process";
7
+ import * as fs from "node:fs";
8
+ import * as os from "node:os";
9
+ function run(command, args) {
10
+ try {
11
+ return execFileSync(command, args, {
12
+ encoding: "utf-8",
13
+ stdio: ["ignore", "pipe", "ignore"],
14
+ timeout: 10_000,
15
+ windowsHide: true,
16
+ });
17
+ }
18
+ catch {
19
+ return null;
20
+ }
21
+ }
22
+ let tasksetAvailable;
23
+ /** Whether this host can constrain a process to a subset of its cores. */
24
+ export function supported() {
25
+ if (process.platform === "linux") {
26
+ // Python checks hasattr(os, 'sched_setaffinity'), which is always true on
27
+ // Linux. The equivalent capability here is the taskset binary.
28
+ tasksetAvailable ??= run("taskset", ["-V"]) !== null;
29
+ return tasksetAvailable;
30
+ }
31
+ return process.platform === "win32";
32
+ }
33
+ /** Parse a Linux cpu list ("0-3,8,10-11") into sorted core numbers. */
34
+ export function parseCpuList(list) {
35
+ const cores = new Set();
36
+ for (const part of list.trim().split(",")) {
37
+ if (!part)
38
+ continue;
39
+ const [lo, hi] = part.split("-").map((n) => Number.parseInt(n, 10));
40
+ if (Number.isNaN(lo))
41
+ continue;
42
+ const top = hi === undefined || Number.isNaN(hi) ? lo : hi;
43
+ for (let c = lo; c <= top; c++) {
44
+ cores.add(c);
45
+ }
46
+ }
47
+ return [...cores].sort((a, b) => a - b);
48
+ }
49
+ function linuxGetAffinity(pid) {
50
+ try {
51
+ const status = fs.readFileSync(`/proc/${pid}/status`, "utf-8");
52
+ const match = status.match(/^Cpus_allowed_list:\s*(.+)$/m);
53
+ if (match) {
54
+ const cores = parseCpuList(match[1]);
55
+ if (cores.length)
56
+ return cores;
57
+ }
58
+ }
59
+ catch {
60
+ // fall through
61
+ }
62
+ return null;
63
+ }
64
+ function linuxSetAffinity(pid, cores) {
65
+ const list = [...cores].sort((a, b) => a - b).join(",");
66
+ return run("taskset", ["-p", "-c", list, String(pid)]) !== null;
67
+ }
68
+ /** The cores this process may run on, in order. */
69
+ export function hostCores() {
70
+ if (process.platform === "linux") {
71
+ const cores = linuxGetAffinity(process.pid);
72
+ if (cores)
73
+ return cores;
74
+ }
75
+ if (process.platform === "win32") {
76
+ const mask = winGetMask(process.pid);
77
+ if (mask)
78
+ return maskToCores(mask);
79
+ }
80
+ const n = os.cpus().length;
81
+ return n ? Array.from({ length: n }, (_, i) => i) : null;
82
+ }
83
+ let hostCountSnapshot;
84
+ /**
85
+ * How many cores the host lets this process use, as read before this process
86
+ * first pinned itself. playwright-core spawns the browser from this process,
87
+ * so pin() narrows this process's own mask during a launch; a live reading
88
+ * taken then by a concurrent launch (hostCores(), or Node's
89
+ * availableParallelism()) would see the pinned count and pass it off as the
90
+ * host's. Python pins a separate driver process and never has this problem.
91
+ */
92
+ export function hostCoreCount() {
93
+ hostCountSnapshot ??=
94
+ hostCores()?.length || os.availableParallelism() || os.cpus().length;
95
+ return hostCountSnapshot;
96
+ }
97
+ /**
98
+ * `count` adjacent cores from a random starting point (wrapping). Always
99
+ * taking the first `count` stacked every browser on one host onto cores
100
+ * 0..count-1, so concurrent browsers measured far less parallelism than they
101
+ * report; adjacent cores keep the SMT topology a real machine of that size
102
+ * would have.
103
+ */
104
+ export function pick(cores, count) {
105
+ const start = Math.floor(Math.random() * cores.length);
106
+ return [...cores.slice(start), ...cores.slice(0, start)]
107
+ .slice(0, count)
108
+ .sort((a, b) => a - b);
109
+ }
110
+ /**
111
+ * Restrict `pid` to `count` of its cores. Returns the previous set so it can
112
+ * be handed back to `restore()`, or null if nothing was changed.
113
+ *
114
+ * The caller must not pin the same process for two launches at once: the
115
+ * browser inherits whatever mask the driver has when it is spawned.
116
+ */
117
+ export function pin(pid, count) {
118
+ if (count < 1 || !supported())
119
+ return null;
120
+ if (pid === process.pid)
121
+ hostCoreCount(); // read the host before narrowing it
122
+ if (process.platform === "linux") {
123
+ const before = linuxGetAffinity(pid);
124
+ if (!before || count >= before.length)
125
+ return null;
126
+ return linuxSetAffinity(pid, pick(before, count)) ? before : null;
127
+ }
128
+ if (process.platform === "win32") {
129
+ const beforeMask = winGetMask(pid);
130
+ if (!beforeMask)
131
+ return null;
132
+ const before = maskToCores(beforeMask);
133
+ if (count >= before.length)
134
+ return null;
135
+ return winSetMask(pid, coresToMask(pick(before, count))) ? before : null;
136
+ }
137
+ return null;
138
+ }
139
+ /** Give `pid` back the cores it had before `pin()`. */
140
+ export function restore(pid, previous) {
141
+ if (!previous?.length)
142
+ return;
143
+ if (process.platform === "linux") {
144
+ linuxSetAffinity(pid, previous);
145
+ }
146
+ else if (process.platform === "win32") {
147
+ winSetMask(pid, coresToMask(previous));
148
+ }
149
+ }
150
+ // -- Windows ---------------------------------------------------------------
151
+ export function maskToCores(mask) {
152
+ const cores = [];
153
+ for (let i = 0; mask >> BigInt(i) > 0n; i++) {
154
+ if ((mask >> BigInt(i)) & 1n)
155
+ cores.push(i);
156
+ }
157
+ return cores;
158
+ }
159
+ export function coresToMask(cores) {
160
+ let mask = 0n;
161
+ for (const c of cores)
162
+ mask |= 1n << BigInt(c);
163
+ return mask;
164
+ }
165
+ function winGetMask(pid) {
166
+ const out = run("powershell", [
167
+ "-NoProfile",
168
+ "-Command",
169
+ `[int64](Get-Process -Id ${pid}).ProcessorAffinity`,
170
+ ]);
171
+ if (!out)
172
+ return 0n;
173
+ try {
174
+ return BigInt(out.trim());
175
+ }
176
+ catch {
177
+ return 0n;
178
+ }
179
+ }
180
+ function winSetMask(pid, mask) {
181
+ return (run("powershell", [
182
+ "-NoProfile",
183
+ "-Command",
184
+ `(Get-Process -Id ${pid}).ProcessorAffinity = [IntPtr][int64]${mask}`,
185
+ ]) !== null);
186
+ }
187
+ // -- launch serialisation --------------------------------------------------
188
+ let pinChain = Promise.resolve();
189
+ let everPinned = false;
190
+ /**
191
+ * Run `fn` while holding the process-wide pin lock. The browser inherits the
192
+ * driver's mask at spawn, so two concurrent launches must not interleave
193
+ * pin/restore: the second pin would land on the first browser, and the first
194
+ * restore would leave the driver pinned. (Python: async_api._pin_lock.)
195
+ */
196
+ export function withPinLock(fn) {
197
+ everPinned = true;
198
+ const result = pinChain.then(fn, fn);
199
+ pinChain = result.catch(() => undefined);
200
+ return result;
201
+ }
202
+ /**
203
+ * Run an UNPINNED launch. It spawns a browser too, which inherits whatever
204
+ * mask this process has at that moment, so once any launch in this process
205
+ * has pinned, it waits for the lock rather than spawning into another
206
+ * launch's pin. Until then (pin_cpu_cores is opt-in) it runs straight away.
207
+ */
208
+ export function withUnpinnedLaunch(fn) {
209
+ return everPinned ? withPinLock(fn) : fn();
210
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "tag": "model-2/2026",
3
+ "asset": "model-release.zip",
4
+ "size": 1564571,
5
+ "sha256": "6530b8322cdaa4ec042921c8d9a0369a0e6e0269ba636c01a7203e4a2f109936",
6
+ "url": "https://github.com/scrapfly/fingerprint-generator/releases/download/model-2/2026/model-release.zip",
7
+ "repo": "scrapfly/fingerprint-generator",
8
+ "files": [
9
+ "fingerprint-network.json.zst",
10
+ "values.dat.zst",
11
+ "values.json.zst"
12
+ ],
13
+ "file_sha256": {
14
+ "fingerprint-network.json.zst": "e1b0a7e60837c347f4b7d5dad4a20c356d521e0593e1bf4a8be39ea1e6a41ac4",
15
+ "values.dat.zst": "3da2cf0891a4a85ef6458f0fbdf9346acfcd04e5fd279a0ea22d7919e4eaf122",
16
+ "values.json.zst": "294decde5b6a1a52ed53d50a894130fa5c58f7cc804b78198f5c33f55b3ba66f"
17
+ },
18
+ "decompressed_sha256": {
19
+ "values.dat": "9ce7d16630e91654e73988f7d37e8c99987c09b9c779a7bb9dc7ad6355dcc2f0"
20
+ },
21
+ "note": "fpgen's model data, pinned. fpgen fetches this itself on first import with TLS verification DISABLED, no checksum, and a release selection that cannot reach this tag -- see fpgen_model.py. The TypeScript launcher loads the model the fpgen npm package pins (its MODEL_PIN), which typescript/tests/fpgen-model.test.ts holds equal to this file: bump both together. The sha256 values are the gate."
22
+ }
@@ -0,0 +1,40 @@
1
+ # GeoIP database sources, shared by every launcher built on camoucore
2
+ #
3
+ # Every URL points at the source's newest build, never a pinned one: the
4
+ # launcher re-downloads once the build it has is a week old (see
5
+ # needs_update() in geolocation.py), and tests/test_geoip_sources.py fails CI
6
+ # when a source stops publishing.
7
+ #
8
+ # `deprecated: true` sources still work when chosen by name, with a warning.
9
+ # A cache that holds one without an explicit `set --geoip` choice
10
+ # (every install that predates the switch to AIO) moves to the default.
11
+ default: GeoIP AIO by daijro
12
+
13
+ geoip:
14
+ # GeoIP All-in-One - Combined IPv4/IPv6 with all fields. Merges several
15
+ # databases per range; rebuilt weekly by daijro/geoip-all-in-one.
16
+ - name: GeoIP AIO by daijro
17
+ extract: true
18
+ urls:
19
+ combined:
20
+ - https://github.com/daijro/geoip-all-in-one/releases/latest/download/geoip-aio-all.mmdb.zip
21
+ paths:
22
+ iso_code: country.iso_code
23
+ longitude: location.longitude
24
+ latitude: location.latitude
25
+ timezone: location.time_zone
26
+
27
+ # GeoLite2 City via sapics/ip-location-db, which publishes to GitHub
28
+ # Releases since 2026-06-18.
29
+ - name: MaxMind GeoLite2
30
+ deprecated: true
31
+ urls:
32
+ ipv4:
33
+ - https://github.com/sapics/ip-location-db/releases/download/latest/geolite2-city-ipv4.mmdb
34
+ ipv6:
35
+ - https://github.com/sapics/ip-location-db/releases/download/latest/geolite2-city-ipv6.mmdb
36
+ paths:
37
+ iso_code: country_code
38
+ longitude: longitude
39
+ latitude: latitude
40
+ timezone: timezone