camoucore 0.2.0 → 0.6.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 (175) hide show
  1. package/LICENSE +4 -3
  2. package/dist/camoufox/__main__.d.ts +10 -0
  3. package/dist/camoufox/__main__.js +1175 -0
  4. package/dist/camoufox/__version__.d.ts +31 -0
  5. package/dist/camoufox/__version__.js +32 -0
  6. package/dist/camoufox/_humanize_playwright.d.ts +54 -0
  7. package/dist/camoufox/_humanize_playwright.js +429 -0
  8. package/dist/camoufox/addons.d.ts +21 -0
  9. package/dist/camoufox/addons.js +56 -0
  10. package/dist/camoufox/async_api.d.ts +9 -0
  11. package/dist/camoufox/async_api.js +9 -0
  12. package/dist/camoufox/browser-pin.d.ts +46 -0
  13. package/dist/camoufox/browser-pin.js +96 -0
  14. package/dist/camoufox/cli.d.ts +7 -0
  15. package/dist/camoufox/cli.js +20 -0
  16. package/dist/camoufox/coherence.d.ts +141 -0
  17. package/dist/camoufox/coherence.js +708 -0
  18. package/dist/camoufox/data-files/audio-output-latency.json +15 -0
  19. package/dist/camoufox/data-files/browser-pin.json +7 -0
  20. package/dist/camoufox/data-files/display-profiles.json +6 -0
  21. package/dist/camoufox/data-files/essential-fonts.json +5 -0
  22. package/dist/camoufox/data-files/fingerprint-presets-v150.json +14544 -0
  23. package/dist/camoufox/data-files/fingerprint-presets.json +5192 -0
  24. package/dist/camoufox/data-files/font-bases.json +1888 -0
  25. package/dist/camoufox/data-files/font-groups.json +716 -0
  26. package/dist/camoufox/data-files/font-prefs.json +1046 -0
  27. package/dist/camoufox/data-files/fonts.json +240 -0
  28. package/dist/camoufox/data-files/fpgen.yml +44 -0
  29. package/dist/camoufox/data-files/launcher-constants.json +136 -0
  30. package/dist/camoufox/data-files/media-devices.json +180 -0
  31. package/dist/camoufox/data-files/repos.yml +40 -0
  32. package/dist/camoufox/data-files/voice-manifests.json +1864 -0
  33. package/dist/camoufox/data-files/voice-uris.json +188 -0
  34. package/dist/camoufox/data-files/warnings.yml +146 -0
  35. package/dist/camoufox/display_profile.d.ts +21 -0
  36. package/dist/camoufox/display_profile.js +129 -0
  37. package/dist/camoufox/driver_defaults.d.ts +27 -0
  38. package/dist/camoufox/driver_defaults.js +119 -0
  39. package/dist/camoufox/exceptions.d.ts +68 -0
  40. package/dist/camoufox/exceptions.js +122 -0
  41. package/dist/camoufox/fingerprints.d.ts +434 -0
  42. package/dist/camoufox/fingerprints.js +1936 -0
  43. package/dist/camoufox/gpudisplay.d.ts +158 -0
  44. package/dist/camoufox/gpudisplay.js +695 -0
  45. package/dist/camoufox/host_rendering.d.ts +38 -0
  46. package/dist/camoufox/host_rendering.js +180 -0
  47. package/dist/camoufox/humanize.d.ts +89 -0
  48. package/dist/camoufox/humanize.js +143 -0
  49. package/dist/camoufox/index.d.ts +21 -0
  50. package/dist/camoufox/index.js +21 -0
  51. package/dist/camoufox/ip.d.ts +45 -0
  52. package/dist/camoufox/ip.js +114 -0
  53. package/dist/camoufox/multiversion.d.ts +131 -0
  54. package/dist/camoufox/multiversion.js +490 -0
  55. package/dist/camoufox/node-floor.d.ts +5 -0
  56. package/dist/camoufox/node-floor.js +17 -0
  57. package/dist/camoufox/paths.d.ts +45 -0
  58. package/dist/camoufox/paths.js +62 -0
  59. package/dist/camoufox/pkgman.d.ts +361 -0
  60. package/dist/camoufox/pkgman.js +1066 -0
  61. package/dist/camoufox/product.d.ts +8 -0
  62. package/dist/camoufox/product.js +8 -0
  63. package/dist/camoufox/pycompat.d.ts +97 -0
  64. package/dist/camoufox/pycompat.js +458 -0
  65. package/dist/camoufox/server.d.ts +36 -0
  66. package/dist/camoufox/server.js +82 -0
  67. package/dist/camoufox/sync_api.d.ts +77 -0
  68. package/dist/camoufox/sync_api.js +207 -0
  69. package/dist/camoufox/utils.d.ts +638 -0
  70. package/dist/camoufox/utils.js +2507 -0
  71. package/dist/camoufox/warnings.d.ts +16 -0
  72. package/dist/camoufox/warnings.js +65 -0
  73. package/dist/camoufox/webgl.d.ts +52 -0
  74. package/dist/camoufox/webgl.js +264 -0
  75. package/dist/camouwolf/__main__.d.ts +10 -0
  76. package/dist/camouwolf/__main__.js +1180 -0
  77. package/dist/camouwolf/__version__.d.ts +31 -0
  78. package/dist/camouwolf/__version__.js +32 -0
  79. package/dist/camouwolf/_humanize_playwright.d.ts +53 -0
  80. package/dist/camouwolf/_humanize_playwright.js +427 -0
  81. package/dist/camouwolf/addons.d.ts +42 -0
  82. package/dist/camouwolf/addons.js +113 -0
  83. package/dist/camouwolf/async_api.d.ts +9 -0
  84. package/dist/camouwolf/async_api.js +9 -0
  85. package/dist/camouwolf/browser-pin.d.ts +46 -0
  86. package/dist/camouwolf/browser-pin.js +96 -0
  87. package/dist/camouwolf/cli.d.ts +7 -0
  88. package/dist/camouwolf/cli.js +20 -0
  89. package/dist/camouwolf/clienthints.d.ts +61 -0
  90. package/dist/camouwolf/clienthints.js +176 -0
  91. package/dist/camouwolf/coherence.d.ts +152 -0
  92. package/dist/camouwolf/coherence.js +554 -0
  93. package/dist/camouwolf/data-files/browser-pin.json +7 -0
  94. package/dist/camouwolf/data-files/camouwolf.defaults.json +118 -0
  95. package/dist/camouwolf/data-files/data/bundle-fonts.json +1983 -0
  96. package/dist/camouwolf/data-files/data/chrome-languages.json +517 -0
  97. package/dist/camouwolf/data-files/data/properties.json +321 -0
  98. package/dist/camouwolf/data-files/data/system-colors.json +35 -0
  99. package/dist/camouwolf/data-files/data/ubo.json +6 -0
  100. package/dist/camouwolf/data-files/fpgen.yml +41 -0
  101. package/dist/camouwolf/data-files/launcher-constants.json +26 -0
  102. package/dist/camouwolf/data-files/repos.yml +23 -0
  103. package/dist/camouwolf/data-files/warnings.yml +96 -0
  104. package/dist/camouwolf/driver_defaults.d.ts +25 -0
  105. package/dist/camouwolf/driver_defaults.js +114 -0
  106. package/dist/camouwolf/exceptions.d.ts +95 -0
  107. package/dist/camouwolf/exceptions.js +150 -0
  108. package/dist/camouwolf/fingerprints.d.ts +227 -0
  109. package/dist/camouwolf/fingerprints.js +753 -0
  110. package/dist/camouwolf/gpudisplay.d.ts +171 -0
  111. package/dist/camouwolf/gpudisplay.js +711 -0
  112. package/dist/camouwolf/host_rendering.d.ts +18 -0
  113. package/dist/camouwolf/host_rendering.js +114 -0
  114. package/dist/camouwolf/humanize.d.ts +84 -0
  115. package/dist/camouwolf/humanize.js +128 -0
  116. package/dist/camouwolf/index.d.ts +22 -0
  117. package/dist/camouwolf/index.js +21 -0
  118. package/dist/camouwolf/multiversion.d.ts +131 -0
  119. package/dist/camouwolf/multiversion.js +491 -0
  120. package/dist/camouwolf/node-floor.d.ts +5 -0
  121. package/dist/camouwolf/node-floor.js +17 -0
  122. package/dist/camouwolf/paths.d.ts +34 -0
  123. package/dist/camouwolf/paths.js +58 -0
  124. package/dist/camouwolf/pkgman.d.ts +331 -0
  125. package/dist/camouwolf/pkgman.js +972 -0
  126. package/dist/camouwolf/product.d.ts +3 -0
  127. package/dist/camouwolf/product.js +3 -0
  128. package/dist/camouwolf/pycompat.d.ts +92 -0
  129. package/dist/camouwolf/pycompat.js +461 -0
  130. package/dist/camouwolf/server.d.ts +36 -0
  131. package/dist/camouwolf/server.js +81 -0
  132. package/dist/camouwolf/switches.d.ts +77 -0
  133. package/dist/camouwolf/switches.js +222 -0
  134. package/dist/camouwolf/sync_api.d.ts +84 -0
  135. package/dist/camouwolf/sync_api.js +173 -0
  136. package/dist/camouwolf/utils.d.ts +644 -0
  137. package/dist/camouwolf/utils.js +2057 -0
  138. package/dist/camouwolf/warnings.d.ts +14 -0
  139. package/dist/camouwolf/warnings.js +59 -0
  140. package/dist/camouwolf/webgl.d.ts +41 -0
  141. package/dist/camouwolf/webgl.js +198 -0
  142. package/dist/data-files/antibot-rules.json +146 -0
  143. package/dist/data.d.ts +1 -1
  144. package/dist/data.js +4 -3
  145. package/dist/download.js +1 -1
  146. package/dist/exceptions.d.ts +1 -1
  147. package/dist/exceptions.js +1 -1
  148. package/dist/geolocation.js +1 -1
  149. package/dist/host.d.ts +2 -0
  150. package/dist/host.js +17 -1
  151. package/dist/ip.js +1 -1
  152. package/dist/locales.js +1 -1
  153. package/dist/mcp/cli.d.ts +15 -0
  154. package/dist/mcp/cli.js +108 -0
  155. package/dist/mcp/index.d.ts +8 -0
  156. package/dist/mcp/index.js +8 -0
  157. package/dist/mcp/main.d.ts +2 -0
  158. package/dist/mcp/main.js +8 -0
  159. package/dist/mcp/secrets.d.ts +50 -0
  160. package/dist/mcp/secrets.js +193 -0
  161. package/dist/mcp/server.d.ts +48 -0
  162. package/dist/mcp/server.js +653 -0
  163. package/dist/mcp/tree.d.ts +10 -0
  164. package/dist/mcp/tree.js +36 -0
  165. package/dist/passthrough.d.ts +16 -0
  166. package/dist/passthrough.js +50 -0
  167. package/dist/product.js +1 -1
  168. package/dist/settings.d.ts +12 -0
  169. package/dist/settings.js +95 -0
  170. package/dist/telemetry.d.ts +127 -0
  171. package/dist/telemetry.js +426 -0
  172. package/dist/virtdisplay.d.ts +1 -1
  173. package/dist/virtdisplay.js +1 -1
  174. package/dist/warnings.js +1 -1
  175. package/package.json +57 -13
@@ -0,0 +1,554 @@
1
+ /**
2
+ * Whole-identity coherence: the checks that look at more than one field.
3
+ *
4
+ * An identity is assembled from several sources: an fpgen record, the client
5
+ * hints derived for the binary's milestone, the caller's own `config`, and the
6
+ * host (its core count, its display). A combination no machine has can be built
7
+ * from individually plausible parts: a Windows user agent beside a macOS
8
+ * Sec-CH-UA-Platform, a Direct3D renderer on a Linux identity, an Apple GPU
9
+ * behind an x86 Sec-CH-UA-Arch.
10
+ *
11
+ * Every identity passes through here on every launch, whatever it was built
12
+ * from. Each rule states an invariant that holds on real Chrome, says how to
13
+ * repair an identity that breaks it where a correct value is determined, and is
14
+ * checked again afterwards. `validate()` reports what is still broken;
15
+ * `apply()` repairs what it can.
16
+ *
17
+ * TypeScript twin of python/camoucore/src/camoucore/camouwolf/coherence.py.
18
+ */
19
+ import * as clienthints from "./clienthints.js";
20
+ import { ValueError } from "./exceptions.js";
21
+ import { LAUNCHER_CONSTANTS } from "./paths.js";
22
+ import { isPyInt, num, pyRepr, pyRound, pyStr, pyTruthy } from "./pycompat.js";
23
+ import { backendMatchesOs } from "./webgl.js";
24
+ /**
25
+ * screen.colorDepth: Chrome reports 24, or 30 on a deep-colour display (most
26
+ * Macs). 32 appears in scraped data and is not a value Chrome emits.
27
+ */
28
+ export const PLAUSIBLE_COLOR_DEPTH = new Set([24, 30]);
29
+ /**
30
+ * navigator.deviceMemory is bucketed: a power of two, floored at 0.25 and
31
+ * capped (at 8 until Chrome 140, at 32 on desktop since).
32
+ */
33
+ export const PLAUSIBLE_DEVICE_MEMORY = [
34
+ 0.25, 0.5, 1, 2, 4, 8, 16, 32,
35
+ ];
36
+ /**
37
+ * navigator.hardwareConcurrency: at least one logical core, and no consumer
38
+ * machine has more than this.
39
+ */
40
+ export const MAX_PLAUSIBLE_CORES = 256;
41
+ /**
42
+ * Core counts Apple Silicon ships; Chrome reports every core, as there is no
43
+ * SMT. 9, 13 and 15 are not Apple parts, which is why this is a list.
44
+ */
45
+ export const APPLE_SILICON_CORES = new Set(LAUNCHER_CONSTANTS.appleSiliconCores);
46
+ /**
47
+ * Logical core counts of Intel Macs whose WebGL runs on the integrated GPU, and
48
+ * with a discrete one, up to the 28-core Mac Pro. An eGPU can sit behind any.
49
+ */
50
+ export const INTEL_MAC_IGP_CORES = new Set(LAUNCHER_CONSTANTS.intelMacIgpCores);
51
+ export const INTEL_MAC_DGPU_CORES = new Set([
52
+ ...LAUNCHER_CONSTANTS.intelMacIgpCores,
53
+ ...LAUNCHER_CONSTANTS.intelMacDgpuExtraCores,
54
+ ]);
55
+ /**
56
+ * The notched MacBook panels' scaled resolutions and the 24" iMac's default,
57
+ * which only Apple Silicon Macs have.
58
+ */
59
+ const APPLE_SILICON_PANELS = new Set(Object.values(LAUNCHER_CONSTANTS.appleSiliconPanels).flatMap((panels) => panels.map(([width, height]) => `${width}x${height}`)));
60
+ /**
61
+ * window.devicePixelRatio: the scaling steps each OS's display settings offer.
62
+ * Scraped records also carry ratios such as 1.0909, which are a browser zoom
63
+ * folded into the display's scale.
64
+ */
65
+ export const PLAUSIBLE_DPR = LAUNCHER_CONSTANTS.plausibleDpr;
66
+ /** The CSS geometry a ratio scales: device pixels / devicePixelRatio. */
67
+ export const CSS_GEOMETRY_KEYS = [
68
+ "screen.width",
69
+ "screen.height",
70
+ "screen.availWidth",
71
+ "screen.availHeight",
72
+ "screen.availLeft",
73
+ "screen.availTop",
74
+ "window.outerWidth",
75
+ "window.outerHeight",
76
+ "window.innerWidth",
77
+ "window.innerHeight",
78
+ "window.screenX",
79
+ "window.screenY",
80
+ ];
81
+ function isNone(value) {
82
+ return value === null || value === undefined;
83
+ }
84
+ function renderer(config) {
85
+ const r = config["webGl:renderer"];
86
+ return pyTruthy(r) ? pyStr(r) : "";
87
+ }
88
+ function checkClientHints(config, _targetOs) {
89
+ const problems = clienthints.assertCoherent(config);
90
+ return problems.length ? problems.join(" ") : null;
91
+ }
92
+ function checkTargetOs(config, targetOs) {
93
+ const platform = config["navigator.platform"];
94
+ const os = targetOs;
95
+ if (pyTruthy(platform) && platform !== clienthints.NAV_PLATFORM[os]) {
96
+ return (`navigator.platform is "${pyStr(platform)}" on a ${clienthints.CH_PLATFORM[os]} ` +
97
+ `identity (expected "${clienthints.NAV_PLATFORM[os]}")`);
98
+ }
99
+ return null;
100
+ }
101
+ function checkGpuMatchesOs(config, targetOs) {
102
+ const r = renderer(config);
103
+ if (r && !backendMatchesOs(r, targetOs)) {
104
+ return (`WebGL renderer "${r}" is not on an ANGLE backend Chrome uses on ` +
105
+ `${clienthints.CH_PLATFORM[targetOs]}`);
106
+ }
107
+ return null;
108
+ }
109
+ /** The CPU architectures an identity can claim (Sec-CH-UA-Arch). */
110
+ export const CPU_ARCHES = ["x86", "arm"];
111
+ /** The CPUs each OS runs on, by architecture: who makes them. */
112
+ export const CPU_MANUFACTURERS = LAUNCHER_CONSTANTS.cpuManufacturers;
113
+ /** Logical core counts only Intel's hybrid parts report. */
114
+ export const INTEL_ONLY_CORE_COUNTS = new Set(LAUNCHER_CONSTANTS.intelOnlyCoreCounts);
115
+ // GPUs that come only with an ARM CPU, and who makes it.
116
+ const ARM_GPUS = [
117
+ ["Apple M", ["apple"]],
118
+ ["Apple GPU", ["apple"]],
119
+ ["Adreno", ["qualcomm"]],
120
+ ];
121
+ // Integrated GPUs, which name the x86 CPU they are part of.
122
+ const INTEL_IGPUS = [
123
+ "Intel(R) HD Graphics",
124
+ "Intel(R) UHD Graphics",
125
+ "Intel(R) Iris",
126
+ "Intel(R) Graphics",
127
+ "Intel(R) Arc(TM) Graphics",
128
+ "Intel(R) Arc(TM) 140",
129
+ "Intel(R) Arc(TM) Pro 140",
130
+ ];
131
+ const AMD_IGPUS = [
132
+ "AMD Radeon(TM) Graphics",
133
+ "AMD Radeon(TM) Vega",
134
+ "AMD Radeon(TM) RX Vega",
135
+ ];
136
+ // Renderers that draw on whatever CPU the machine has.
137
+ const SOFTWARE_RENDERERS = ["SwiftShader", "llvmpipe"];
138
+ /**
139
+ * The CPU architecture a machine with this GPU has, and its possible makers.
140
+ *
141
+ * [null, []] for a software renderer, which runs on any CPU. No makers leaves
142
+ * the maker open within the architecture.
143
+ */
144
+ export function gpuCpu(gpuRenderer, targetOs) {
145
+ // fpgen hands its conditions the recorded renderer lowercased.
146
+ const r = (pyTruthy(gpuRenderer) ? pyStr(gpuRenderer) : "").toLowerCase();
147
+ const has = (names) => names.some((n) => r.includes(n.toLowerCase()));
148
+ if (!r || has(SOFTWARE_RENDERERS))
149
+ return [null, []];
150
+ for (const [marker, makers] of ARM_GPUS) {
151
+ if (r.includes(marker.toLowerCase()))
152
+ return ["arm", makers];
153
+ }
154
+ if (targetOs === "mac" || has(INTEL_IGPUS))
155
+ return ["x86", ["intel"]];
156
+ if (has(AMD_IGPUS))
157
+ return ["x86", ["amd"]];
158
+ // A discrete card: no ARM machine on sale carries one Chrome would name.
159
+ return ["x86", []];
160
+ }
161
+ /**
162
+ * [arch, manufacturer] for a caller's `cpu` option on `targetOs`.
163
+ *
164
+ * Throws ValueError for anything no machine running `targetOs` is: an unknown
165
+ * key, architecture or maker, or a pair such as an AMD Mac. A maker alone
166
+ * implies its architecture.
167
+ */
168
+ export function resolveCpu(cpu, targetOs) {
169
+ if (cpu === null || typeof cpu !== "object" || Array.isArray(cpu)) {
170
+ throw new ValueError(`cpu must be a dict such as {'arch': 'x86', 'manufacturer': 'intel'}, not ${pyRepr(cpu)}`);
171
+ }
172
+ const given = cpu;
173
+ const unknown = Object.keys(given)
174
+ .filter((k) => k !== "arch" && k !== "manufacturer")
175
+ .sort();
176
+ if (unknown.length) {
177
+ throw new ValueError(`cpu takes 'arch' and 'manufacturer', not ${unknown.map((k) => pyRepr(k)).join(", ")}`);
178
+ }
179
+ let arch = (given.arch ?? null);
180
+ const maker = (given.manufacturer ?? null);
181
+ if (arch !== null && !CPU_ARCHES.includes(arch)) {
182
+ throw new ValueError(`cpu arch must be one of ('x86', 'arm'), not ${pyRepr(arch)}`);
183
+ }
184
+ const table = CPU_MANUFACTURERS[targetOs];
185
+ const name = clienthints.CH_PLATFORM[targetOs];
186
+ if (maker !== null) {
187
+ const arches = CPU_ARCHES.filter((a) => (table[a] ?? []).includes(maker));
188
+ if (!arches.length) {
189
+ const known = [...new Set(Object.values(table).flat())].sort();
190
+ throw new ValueError(`no ${name} identity has a CPU made by ${pyRepr(maker)}; on ${name} it is one of ${known.join(", ")}`);
191
+ }
192
+ if (arch !== null && !arches.includes(arch)) {
193
+ throw new ValueError(`no ${name} identity has an ${arch} CPU made by ${pyRepr(maker)}`);
194
+ }
195
+ arch = arches[0];
196
+ }
197
+ else if (arch !== null && !(table[arch] ?? []).length) {
198
+ throw new ValueError(`no ${name} identity has an ${arch} CPU`);
199
+ }
200
+ return [arch ?? "x86", maker];
201
+ }
202
+ /** Why a machine with this GPU and core count cannot have this CPU, or null. */
203
+ export function cpuMisfit(gpuRenderer, cores, targetOs, arch, maker) {
204
+ const [byGpu, makers] = gpuCpu(gpuRenderer, targetOs);
205
+ const claimed = [maker, arch].filter(Boolean).join(" ");
206
+ if (byGpu !== null &&
207
+ (byGpu !== arch || (maker && makers.length && !makers.includes(maker)))) {
208
+ return `a ${claimed} CPU beside the WebGL renderer "${pyStr(gpuRenderer)}"`;
209
+ }
210
+ if (arch === "x86" &&
211
+ maker &&
212
+ maker !== "intel" &&
213
+ isPyInt(cores) &&
214
+ INTEL_ONLY_CORE_COUNTS.has(Number(num(cores)))) {
215
+ return `a ${claimed} CPU with hardwareConcurrency ${pyStr(cores)}, which only Intel CPUs report`;
216
+ }
217
+ return null;
218
+ }
219
+ /**
220
+ * Why no Mac with this GPU has these cores and this screen, or null.
221
+ *
222
+ * It checks drawn records, which are rejected, as well as finished identities.
223
+ * fpgen's records include browsers that randomise hardwareConcurrency.
224
+ */
225
+ export function machineMisfit(gpuRenderer, targetOs, cores, width, height) {
226
+ const name = pyTruthy(gpuRenderer) ? pyStr(gpuRenderer) : "";
227
+ if (targetOs !== "mac" || !name || !isPyInt(cores))
228
+ return null;
229
+ const count = Number(num(cores));
230
+ if (name.includes("Apple M")) {
231
+ if (APPLE_SILICON_CORES.has(count))
232
+ return null;
233
+ const ships = [...APPLE_SILICON_CORES].sort((a, b) => a - b).join(", ");
234
+ return `"${name}" with hardwareConcurrency ${count}; Apple Silicon ships [${ships}]`;
235
+ }
236
+ const allowed = name.includes("Intel")
237
+ ? INTEL_MAC_IGP_CORES
238
+ : INTEL_MAC_DGPU_CORES;
239
+ if (!allowed.has(count)) {
240
+ return `"${name}" with hardwareConcurrency ${count}; no Intel Mac with that GPU reports it`;
241
+ }
242
+ if (APPLE_SILICON_PANELS.has(`${pyStr(width)}x${pyStr(height)}`)) {
243
+ return `"${name}" behind a ${pyStr(width)}x${pyStr(height)} panel, which only Apple Silicon Macs have`;
244
+ }
245
+ return null;
246
+ }
247
+ function checkMacHardware(config, targetOs) {
248
+ return machineMisfit(renderer(config), targetOs, config["navigator.hardwareConcurrency"], config["screen.width"], config["screen.height"]);
249
+ }
250
+ function checkArchitecture(config, targetOs) {
251
+ const arch = config["userAgentData.architecture"];
252
+ const r = renderer(config);
253
+ const [expected] = gpuCpu(r, targetOs);
254
+ if (pyTruthy(arch) && expected && arch !== expected) {
255
+ return (`Sec-CH-UA-Arch is "${pyStr(arch)}" beside the WebGL renderer "${r}"; ` +
256
+ `that GPU is only in ${expected} machines`);
257
+ }
258
+ return null;
259
+ }
260
+ function repairArchitecture(config, targetOs) {
261
+ config["userAgentData.architecture"] = gpuCpu(renderer(config), targetOs)[0];
262
+ }
263
+ /** Python's `value in container` for numbers: 24.0 == 24, True == 1. */
264
+ function numberIn(value, container) {
265
+ if (typeof value !== "number" &&
266
+ typeof value !== "boolean" &&
267
+ typeof value !== "bigint" &&
268
+ !(value !== null && typeof value === "object" && "value" in value)) {
269
+ return false;
270
+ }
271
+ const n = Number(num(value));
272
+ for (const item of container)
273
+ if (item === n)
274
+ return true;
275
+ return false;
276
+ }
277
+ function checkColorDepth(config, _targetOs) {
278
+ const depth = config["screen.colorDepth"];
279
+ if (!isNone(depth) && !numberIn(depth, PLAUSIBLE_COLOR_DEPTH)) {
280
+ return `screen.colorDepth ${pyStr(depth)} is not a value Chrome reports (24 or 30)`;
281
+ }
282
+ return null;
283
+ }
284
+ function repairColorDepth(config, _targetOs) {
285
+ config["screen.colorDepth"] = 24;
286
+ }
287
+ function checkPixelDepth(config, _targetOs) {
288
+ const pixel = config["screen.pixelDepth"];
289
+ const color = config["screen.colorDepth"];
290
+ if (!isNone(pixel) && !isNone(color) && num(pixel) !== num(color)) {
291
+ return `screen.pixelDepth ${pyStr(pixel)} differs from colorDepth ${pyStr(color)}; Chrome reports one number for both`;
292
+ }
293
+ return null;
294
+ }
295
+ function repairPixelDepth(config, _targetOs) {
296
+ config["screen.pixelDepth"] = config["screen.colorDepth"];
297
+ }
298
+ function checkTouchPoints(config, targetOs) {
299
+ const touch = config["navigator.maxTouchPoints"];
300
+ if (targetOs === "mac" && pyTruthy(touch)) {
301
+ return `macOS identity with maxTouchPoints ${pyStr(touch)}; no Mac has a touchscreen`;
302
+ }
303
+ return null;
304
+ }
305
+ function repairTouchPoints(config, _targetOs) {
306
+ config["navigator.maxTouchPoints"] = 0;
307
+ }
308
+ function checkDeviceMemory(config, _targetOs) {
309
+ const memory = config["navigator.deviceMemory"];
310
+ if (!isNone(memory) && !numberIn(memory, PLAUSIBLE_DEVICE_MEMORY)) {
311
+ return `navigator.deviceMemory ${pyStr(memory)} is not one of the buckets Chrome reports`;
312
+ }
313
+ return null;
314
+ }
315
+ function repairDeviceMemory(config, _targetOs) {
316
+ const memory = num(config["navigator.deviceMemory"]);
317
+ const below = PLAUSIBLE_DEVICE_MEMORY.filter((bucket) => bucket <= memory);
318
+ // int(bucket) if bucket >= 1 else bucket: an integral bucket is an int, and
319
+ // a plain number is one already.
320
+ config["navigator.deviceMemory"] = below.length
321
+ ? below[below.length - 1]
322
+ : PLAUSIBLE_DEVICE_MEMORY[0];
323
+ }
324
+ function checkCores(config, _targetOs) {
325
+ const cores = config["navigator.hardwareConcurrency"];
326
+ if (isNone(cores))
327
+ return null;
328
+ if (!isPyInt(cores) ||
329
+ typeof cores === "boolean" ||
330
+ !(Number(cores) >= 1 && Number(cores) <= MAX_PLAUSIBLE_CORES)) {
331
+ return `navigator.hardwareConcurrency ${pyRepr(cores)} is not a core count`;
332
+ }
333
+ return null;
334
+ }
335
+ function checkScreenShape(config, _targetOs) {
336
+ const width = config["screen.width"];
337
+ const height = config["screen.height"];
338
+ if (!pyTruthy(width) || !pyTruthy(height))
339
+ return null;
340
+ if (num(height) > num(width)) {
341
+ return `portrait screen ${pyStr(width)}x${pyStr(height)}; desktop panels are landscape`;
342
+ }
343
+ if (num(width) < 1024) {
344
+ return `screen ${pyStr(width)}x${pyStr(height)} is smaller than any current desktop panel`;
345
+ }
346
+ return null;
347
+ }
348
+ function checkAvailBounds(config, _targetOs) {
349
+ const width = config["screen.width"];
350
+ const height = config["screen.height"];
351
+ const availW = config["screen.availWidth"];
352
+ const availH = config["screen.availHeight"];
353
+ if (pyTruthy(width) && pyTruthy(availW) && num(availW) > num(width)) {
354
+ return `screen.availWidth ${pyStr(availW)} exceeds screen.width ${pyStr(width)}`;
355
+ }
356
+ if (pyTruthy(height) && pyTruthy(availH) && num(availH) > num(height)) {
357
+ return `screen.availHeight ${pyStr(availH)} exceeds screen.height ${pyStr(height)}`;
358
+ }
359
+ return null;
360
+ }
361
+ function repairAvailBounds(config, _targetOs) {
362
+ const width = config["screen.width"];
363
+ const height = config["screen.height"];
364
+ if (pyTruthy(width) && num(config["screen.availWidth"] ?? 0) > num(width)) {
365
+ config["screen.availWidth"] = width;
366
+ }
367
+ if (pyTruthy(height) &&
368
+ num(config["screen.availHeight"] ?? 0) > num(height)) {
369
+ config["screen.availHeight"] = height;
370
+ }
371
+ }
372
+ function checkWindowFits(config, _targetOs) {
373
+ for (const axis of ["Width", "Height"]) {
374
+ const screen = config[`screen.${axis.toLowerCase()}`];
375
+ const outer = config[`window.outer${axis}`];
376
+ if (pyTruthy(screen) && pyTruthy(outer) && num(outer) > num(screen)) {
377
+ return `window.outer${axis} ${pyStr(outer)} exceeds screen.${axis.toLowerCase()} ${pyStr(screen)}`;
378
+ }
379
+ }
380
+ return null;
381
+ }
382
+ function repairWindowFits(config, _targetOs) {
383
+ for (const axis of ["Width", "Height"]) {
384
+ const screen = config[`screen.${axis.toLowerCase()}`];
385
+ const outer = config[`window.outer${axis}`];
386
+ if (pyTruthy(screen) && pyTruthy(outer) && num(outer) > num(screen)) {
387
+ const avail = config[`screen.avail${axis}`];
388
+ config[`window.outer${axis}`] = pyTruthy(avail) ? avail : screen;
389
+ }
390
+ }
391
+ }
392
+ /** A devicePixelRatio no display mode of the OS offers. */
393
+ export function isZoomedRatio(dpr, targetOs) {
394
+ const allowed = PLAUSIBLE_DPR[targetOs];
395
+ if (!allowed || typeof dpr !== "number" || !(dpr > 0))
396
+ return false;
397
+ return !allowed.includes(dpr);
398
+ }
399
+ function checkDevicePixelRatio(config, targetOs) {
400
+ const dpr = config["window.devicePixelRatio"];
401
+ if (!isNone(dpr) && isZoomedRatio(dpr, targetOs))
402
+ return `window.devicePixelRatio ${pyRepr(dpr)} is not a display mode ${targetOs} offers`;
403
+ return null;
404
+ }
405
+ /**
406
+ * Move the ratio to the nearest display step and rescale the CSS geometry by
407
+ * the zoom that was folded in, so the screen is still the display behind it:
408
+ * 1760x990 at 1.0909 is a 1920x1080 monitor at 1.
409
+ */
410
+ /** `keep` names sizes that are not the record's (a caller's window) and stay
411
+ * as they are. */
412
+ export function repairDevicePixelRatio(config, targetOs, keep = []) {
413
+ const dpr = config["window.devicePixelRatio"];
414
+ if (!isZoomedRatio(dpr, targetOs))
415
+ return;
416
+ const step = PLAUSIBLE_DPR[targetOs].reduce((best, v) => Math.abs(v - dpr) < Math.abs(best - dpr) ? v : best);
417
+ config["window.devicePixelRatio"] = step;
418
+ const scale = dpr / step;
419
+ for (const key of CSS_GEOMETRY_KEYS) {
420
+ const value = config[key];
421
+ if (!keep.includes(key) && typeof value === "number")
422
+ config[key] = pyRound(value * scale);
423
+ }
424
+ }
425
+ export const RULES = [
426
+ { name: "client-hints", check: checkClientHints, repair: null },
427
+ { name: "target-os", check: checkTargetOs, repair: null },
428
+ { name: "gpu-matches-os", check: checkGpuMatchesOs, repair: null },
429
+ {
430
+ name: "architecture",
431
+ check: checkArchitecture,
432
+ repair: repairArchitecture,
433
+ },
434
+ { name: "mac-hardware", check: checkMacHardware, repair: null },
435
+ { name: "color-depth", check: checkColorDepth, repair: repairColorDepth },
436
+ { name: "pixel-depth", check: checkPixelDepth, repair: repairPixelDepth },
437
+ { name: "touch-points", check: checkTouchPoints, repair: repairTouchPoints },
438
+ {
439
+ name: "device-memory",
440
+ check: checkDeviceMemory,
441
+ repair: repairDeviceMemory,
442
+ },
443
+ { name: "hardware-concurrency", check: checkCores, repair: null },
444
+ {
445
+ name: "device-pixel-ratio",
446
+ check: checkDevicePixelRatio,
447
+ repair: repairDevicePixelRatio,
448
+ adjusts: CSS_GEOMETRY_KEYS,
449
+ },
450
+ { name: "screen-shape", check: checkScreenShape, repair: null },
451
+ { name: "avail-bounds", check: checkAvailBounds, repair: repairAvailBounds },
452
+ {
453
+ name: "window-fits-screen",
454
+ check: checkWindowFits,
455
+ repair: repairWindowFits,
456
+ },
457
+ ];
458
+ /**
459
+ * The rules whose violation is refused at launch rather than warned about: a
460
+ * page, or the server before any page runs, reads each of them directly.
461
+ */
462
+ export const FATAL_RULES = new Set([
463
+ "client-hints",
464
+ "target-os",
465
+ "gpu-matches-os",
466
+ ]);
467
+ /** Whether the screen is one no desktop reports (portrait, or tiny). */
468
+ export function screenIsImplausible(config) {
469
+ return checkScreenShape(config, "") !== null;
470
+ }
471
+ /**
472
+ * Turn a portrait screen landscape, keeping the panel's own dimensions.
473
+ *
474
+ * A recorded 1440x2560 screen is a phone panel, or a desktop one captured
475
+ * while rotated. Either way a desktop identity that claims it is answering a
476
+ * `matchMedia('(orientation: portrait)')` the way no desktop does, so the axes
477
+ * are swapped rather than the numbers invented. Run before the window clamps,
478
+ * which then bound the window to the new screen.
479
+ */
480
+ export function repairScreenOrientation(config) {
481
+ const width = config["screen.width"];
482
+ const height = config["screen.height"];
483
+ if (!pyTruthy(width) || !pyTruthy(height) || num(height) <= num(width))
484
+ return false;
485
+ config["screen.width"] = height;
486
+ config["screen.height"] = width;
487
+ const availW = config["screen.availWidth"];
488
+ const availH = config["screen.availHeight"];
489
+ if (pyTruthy(availW) && pyTruthy(availH)) {
490
+ config["screen.availWidth"] = availH;
491
+ config["screen.availHeight"] = availW;
492
+ }
493
+ return true;
494
+ }
495
+ function changed(before, after, keys) {
496
+ return [...keys]
497
+ .filter((k) => k in before !== k in after ||
498
+ JSON.stringify(before[k]) !== JSON.stringify(after[k]))
499
+ .sort();
500
+ }
501
+ /** Every invariant this identity breaks. Empty means coherent. */
502
+ export function validate(config, targetOs) {
503
+ const violations = [];
504
+ for (const rule of RULES) {
505
+ const detail = rule.check(config, targetOs);
506
+ if (detail)
507
+ violations.push({ rule: rule.name, detail, kept: [] });
508
+ }
509
+ return violations;
510
+ }
511
+ /**
512
+ * Repair what is determined, and report what is left.
513
+ *
514
+ * A rule with no repair -- a Windows GPU on a macOS identity, a portrait
515
+ * screen -- cannot be corrected without inventing a machine, so it is returned
516
+ * for the caller to decide about. The caller that draws the identity can
517
+ * simply draw again.
518
+ *
519
+ * `keep` names the keys the caller set. A repair that would change one of
520
+ * them is not made: the caller's value stands, and the violation comes back
521
+ * with those keys in `kept` so the launcher can warn about it. A repair that
522
+ * only touches other keys still runs.
523
+ */
524
+ export function apply(config, targetOs, keep = new Set()) {
525
+ const kept = new Map();
526
+ for (const rule of RULES) {
527
+ if (!rule.repair || !rule.check(config, targetOs))
528
+ continue;
529
+ const repaired = { ...config };
530
+ rule.repair(repaired, targetOs);
531
+ if (rule.adjusts?.some((key) => keep.has(key))) {
532
+ for (const key of rule.adjusts) {
533
+ if (key in config)
534
+ repaired[key] = config[key];
535
+ else
536
+ delete repaired[key];
537
+ }
538
+ }
539
+ const blocked = changed(config, repaired, keep);
540
+ if (blocked.length) {
541
+ kept.set(rule.name, blocked);
542
+ }
543
+ else {
544
+ for (const key of Object.keys(config))
545
+ if (!(key in repaired))
546
+ delete config[key];
547
+ Object.assign(config, repaired);
548
+ }
549
+ }
550
+ return validate(config, targetOs).map((v) => ({
551
+ ...v,
552
+ kept: kept.get(v.rule) ?? [],
553
+ }));
554
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "tag": "v158.0.8127.36-alpha.1",
3
+ "repo": "CamouBrowser/camouwolf",
4
+ "repo_name": "Official",
5
+ "version": "158.0.8127.36",
6
+ "build": "alpha.1"
7
+ }
@@ -0,0 +1,118 @@
1
+ {
2
+ "$about": "Camouwolf's launch defaults: the value every launch starts from for each option below, with what it does and example values. Change one for yourself without editing the installed package: run `camouwolf defaults`, which copies this file to your user config directory (~/.config/camouwolf/defaults.json on Linux, ~/Library/Application Support/camouwolf/defaults.json on macOS, %LOCALAPPDATA%\\camouwolf\\camouwolf\\defaults.json on Windows) and prints its path, then edit the \"default\" values there. CAMOUWOLF_DEFAULTS=<path> reads your file from another path instead. Your file may also use the short form {\"telemetry\": false}. An unknown option or a value of the wrong type in it is an error. A value passed to the launch call (Camouwolf(), NewBrowser(), launch_options(); launchOptions() in TypeScript, with the same option names) wins over both files.",
3
+ "headless": {
4
+ "default": false,
5
+ "about": "Run Chromium's own headless mode. For a headed browser on an invisible display on Linux, pass headless='virtual' (or 'virtual-gpu') in the launch call.",
6
+ "examples": [true]
7
+ },
8
+ "humanize": {
9
+ "default": false,
10
+ "about": "Move the mouse, type and scroll like a person (the myuri engine) for Playwright's input calls. The launch call also takes a per-channel dict with a seed.",
11
+ "examples": [true]
12
+ },
13
+ "passthrough": {
14
+ "default": false,
15
+ "about": "Launch with this machine's own fingerprint: no identity is drawn and nothing about the device is spoofed (user agent, screen, GPU, fonts, timezone and languages are the host's). Behaviour options (proxy, headless, humanize, addons, block_images) still apply. Cannot be combined with an option that sets the identity (os, locale, geoip, config, fingerprint, screen, window, fonts, ...).",
16
+ "examples": [true]
17
+ },
18
+ "telemetry": {
19
+ "default": true,
20
+ "about": "Anonymous proxy telemetry. What is collected: per anti-bot provider (Cloudflare, Cloudflare Turnstile, DataDome, Akamai, PerimeterX, Kasada, Imperva, AWS WAF, hCaptcha, reCAPTCHA, Arkose Labs, Queue-it, Shape (F5), ThreatMetrix, Google BotGuard), how many encounters ended in success, challenge, block or unknown; and the launch's launcher name, launcher version, browser version, whether it is cross-OS (an identity OS other than this machine's), whether it is passthrough, and the proxy provider's domain only ('none' without a proxy). What is never collected: URLs, sites, page content, cookies, IP addresses, the proxy's username, password, host or port, or any identifier of you or this machine. What it is used for: publishing the success rates of proxy providers against no proxy, by release and cross-OS or not, on the Camoufox website. How to turn it off: set this to false, set CAMOUWOLF_TELEMETRY=0, or set DO_NOT_TRACK=1.",
21
+ "examples": [false]
22
+ },
23
+ "geoip": {
24
+ "default": false,
25
+ "about": "Place the identity where its IP address is: timezone, locale, geolocation and WebRTC address from the public IP (through the proxy when there is one). Needs the geoip extra. The launch call also takes an IP address string.",
26
+ "examples": [true]
27
+ },
28
+ "geoip_db": {
29
+ "default": null,
30
+ "about": "Which GeoIP database geoip looks the IP up in; null is the one `camouwolf set --geoip` selected.",
31
+ "examples": ["GeoIP AIO by daijro"]
32
+ },
33
+ "locale": {
34
+ "default": null,
35
+ "about": "The identity's locale(s). The first is the UI and Intl locale; all of them are navigator.languages and Accept-Language. null takes it from geoip, or the host's.",
36
+ "examples": ["en-US", ["de-DE", "en-US"]]
37
+ },
38
+ "os": {
39
+ "default": null,
40
+ "about": "Operating system of the identity: \"windows\", \"macos\", \"linux\", or a list to choose from. null is what this host can pass for (its own OS, and Windows on a Linux host).",
41
+ "examples": ["windows", ["windows", "linux"]]
42
+ },
43
+ "proxy": {
44
+ "default": null,
45
+ "about": "Proxy for the whole browser, in Playwright's format. A socks5:// proxy may carry a username and password.",
46
+ "examples": [{"server": "http://proxy.example.com:8080", "username": "user", "password": "pass"}, {"server": "socks5://proxy.example.com:1080"}]
47
+ },
48
+ "block_images": {
49
+ "default": false,
50
+ "about": "Block every image. A page can tell, so it warns.",
51
+ "examples": [true]
52
+ },
53
+ "block_webrtc": {
54
+ "default": false,
55
+ "about": "Keep WebRTC to TCP through the proxy, with no UDP at all.",
56
+ "examples": [true]
57
+ },
58
+ "block_webgl": {
59
+ "default": false,
60
+ "about": "Turn WebGL off. Few real browsers lack it, so it warns.",
61
+ "examples": [true]
62
+ },
63
+ "disable_coop": {
64
+ "default": false,
65
+ "about": "Ignore Cross-Origin-Opener-Policy headers, so a popup a COOP page opens keeps its opener. It warns.",
66
+ "examples": [true]
67
+ },
68
+ "instant_animations": {
69
+ "default": false,
70
+ "about": "Finish every finite CSS and Web Animation at once. A page reads the zero duration back, so it warns.",
71
+ "examples": [true]
72
+ },
73
+ "show_cursor": {
74
+ "default": false,
75
+ "about": "Show where automation clicks, as a ripple a page cannot read, in screenshots and a watched window.",
76
+ "examples": [true]
77
+ },
78
+ "enable_cache": {
79
+ "default": false,
80
+ "about": "Keep the HTTP disk cache.",
81
+ "examples": [true]
82
+ },
83
+ "canvas_noise": {
84
+ "default": false,
85
+ "about": "Perturb canvas readback with a per-identity seed. Stock Chrome does not, so it warns.",
86
+ "examples": [true]
87
+ },
88
+ "pin_cpu_cores": {
89
+ "default": false,
90
+ "about": "Pin the browser to as many cores as the identity reports, instead of reporting the host's count. Costs real CPU; does nothing on macOS.",
91
+ "examples": [true]
92
+ },
93
+ "allow_os_mismatch": {
94
+ "default": false,
95
+ "about": "Allow an identity on an OS this host cannot render as. Its fonts and graphics then disagree with its user agent.",
96
+ "examples": [true]
97
+ },
98
+ "allow_addon_new_tab": {
99
+ "default": false,
100
+ "about": "Let extensions open tabs and windows of their own.",
101
+ "examples": [true]
102
+ },
103
+ "browser": {
104
+ "default": null,
105
+ "about": "Which installed browser build to launch (`camouwolf list`); null is the active one.",
106
+ "examples": ["official/alpha.1"]
107
+ },
108
+ "debug": {
109
+ "default": false,
110
+ "about": "Print the config sent to the browser (proxy credentials masked) and have the browser log to stderr.",
111
+ "examples": [true]
112
+ },
113
+ "i_know_what_im_doing": {
114
+ "default": false,
115
+ "about": "Silence the launcher's warnings, and drop conflicting switches instead of refusing them.",
116
+ "examples": [true]
117
+ }
118
+ }