camoucore 0.6.0 → 0.6.1

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.
@@ -92,8 +92,6 @@ export declare function identitySeed(config: Config, salt?: number | bigint): nu
92
92
  * would noise with it (a released one) or ignore it (this one).
93
93
  */
94
94
  export declare function dropAudioSeed(config: Record<string, unknown>): void;
95
- /** The families of one addition unit (font-groups.json), e.g. ("win", "office"). */
96
- export declare function fontUnitFamilies(osKey: string, unitId: string): Set<string>;
97
95
  /**
98
96
  * The font list of one plausible machine of the given OS
99
97
  * (`_generate_random_font_subset`): one OS-version base by weight, never
@@ -180,29 +178,6 @@ export declare function fixHardwareConcurrency(config: Config, canPin?: boolean
180
178
  export declare function fixNavigatorArch(config: Config, targetOs: string): void;
181
179
  export declare const BASELINE_TASKBAR_HEIGHT: Record<string, number>;
182
180
  export declare const BASELINE_MULTI_TOUCH_POINTS: number;
183
- export declare const RECORDED_WINDOW_CHROME: Record<string, [number, number]>;
184
- /** A page's size, or a window's position and outer size. */
185
- export interface Box {
186
- x?: number | null;
187
- y?: number | null;
188
- width: number;
189
- height: number;
190
- }
191
- /**
192
- * The smallest screen, [width, height], that holds a page's window.
193
- *
194
- * A page with `viewport` sits in a window the recorded chrome larger; the page
195
- * also reports `window` (its position and outer size), which has to be on the
196
- * screen too. The height adds the taskbar the browser takes out of the
197
- * available screen for the claimed OS (BASELINE_TASKBAR_HEIGHT), so the window
198
- * fits screen.availHeight.
199
- */
200
- export declare function screenFloor(osKey: string, viewport?: Box | null, window?: Box | null): [number, number];
201
- /**
202
- * A recorded screen of the OS at least `floor` in size, or null if the model
203
- * has none that large.
204
- */
205
- export declare function drawScreen(osKey: string, floor: [number, number]): [number, number] | null;
206
181
  /**
207
182
  * Claim the available screen and touch points the browser will report.
208
183
  * clampWindowDimensions then fits the window inside that screen.
@@ -218,7 +193,7 @@ export declare function clampScreenToDisplay(config: Config, maxWidth: number |
218
193
  /**
219
194
  * Keep the window box inside the available screen: 0 <= screenX/Y <= avail -
220
195
  * outer. The available screen, not the whole one: pages are fitted to the
221
- * window on screen.availHeight (screenFloor), and a window at y=2 whose outer
196
+ * window on screen.availHeight, and a window at y=2 whose outer
222
197
  * height is the available height ran 2 px into the taskbar, so every new
223
198
  * context drew a larger screen for it. Only `keys` are moved.
224
199
  */
@@ -241,64 +216,6 @@ export declare function drawMediaDevices(osKey: string, seed: number | bigint |
241
216
  * when the caller already set any mediaDevices: key.
242
217
  */
243
218
  export declare function setMediaDevicesDefaults(config: Config, salt?: number | bigint): void;
244
- /**
245
- * Share of machines whose one adapter carries IPv6 next to IPv4. No recorded
246
- * corpus has the ICE shape; this is Google's IPv6 adoption figure (~45% of its
247
- * users in 2025, google.com/ipv6/statistics), which counts global IPv6 only,
248
- * so it is a lower bound. A real-device measurement replaces it.
249
- */
250
- export declare const HOST_IPV6_SHARE = 0.45;
251
- /**
252
- * Draw the identity's network shape: one adapter, IPv4 only or IPv4 + IPv6
253
- * (webrtc:hostipv6, webrtc-topology-host-ipv6.patch). Mirrors Python's
254
- * set_host_ipv6_default; nothing is drawn when the caller set it.
255
- */
256
- export declare function setHostIpv6Default(config: Config, salt?: number | bigint): void;
257
- /**
258
- * Windows' location setting for desktop apps, as Firefox reads it
259
- * (GeolocationSystemWin.cpp). No recorded corpus has it; an estimate a
260
- * real-device measurement replaces. Mirrors Python's
261
- * WINDOWS_LOCATION_SETTING_SHARES.
262
- */
263
- export declare const WINDOWS_LOCATION_SETTING_SHARES: ReadonlyArray<[string, number]>;
264
- /**
265
- * Draw the identity's OS location setting (geolocation:systemPermission,
266
- * geolocation-spoofing.patch) for a Windows identity on another host. Mirrors
267
- * Python's set_location_setting_default.
268
- */
269
- export declare function setLocationSettingDefault(config: Config, salt: number | bigint, targetOs: string, hostOs: string | null): void;
270
- /**
271
- * When stock Windows Firefox's deferred font-info loader lands the legacy
272
- * styled-family aliases after the first legacy lookup (stock 158.0.1 on win-i9:
273
- * 1727, 1826, 1832 ms on a 100 ms poll). Mirrors Python's
274
- * WINDOWS_ALIAS_LOAD_MS / set_windows_alias_load_default: drawn per launch for a
275
- * Windows identity on another OS; a caller's value is kept.
276
- */
277
- export declare const WINDOWS_ALIAS_LOAD_MS: readonly [number, number];
278
- /**
279
- * How long stock Windows Firefox's character-map pass takes to land after the
280
- * first fallback within a family whose cmaps are not loaded yet
281
- * (windows-lazy-cmaps.patch; win-i9: 80, 154, 182 ms). Mirrors Python's
282
- * WINDOWS_CMAP_LOAD_MS; drawn with the alias load time.
283
- */
284
- export declare const WINDOWS_CMAP_LOAD_MS: readonly [number, number];
285
- /**
286
- * Injection point for the draws that belong to the launch, not the identity
287
- * (timing: a real machine's figure moves from launch to launch). Mirrors
288
- * Python's launch_uniform(); the launch goldens pin both to one value.
289
- */
290
- export declare const fingerprintDeps: {
291
- random: () => number;
292
- };
293
- export declare function setWindowsAliasLoadDefault(config: Config, targetOs: string, hostOs: string | null): void;
294
- /**
295
- * Draw the identity's audio output device latency (AudioContext:outputLatency,
296
- * audio-context-spoofing.patch). The device latency follows the identity seed;
297
- * the stream's opening delay is drawn per launch. Mirrors Python's
298
- * set_output_latency_default; nothing is set when the caller set the key, the
299
- * identity claims the host's OS, or the OS has no measured devices.
300
- */
301
- export declare function setOutputLatencyDefault(config: Config, salt: number | bigint, targetOs: string, hostOs: string | null): void;
302
219
  /**
303
220
  * Intel's share of the x86 desktop CPUs running Firefox (Firefox Public Data
304
221
  * Report, week of 2026-11-02: Intel 76.86%, AMD 17.61%); fingerprints.py.
@@ -353,8 +270,6 @@ export interface InitValues {
353
270
  webglRenderer?: string;
354
271
  screenWidth?: number;
355
272
  screenHeight?: number;
356
- screenAvailWidth?: number;
357
- screenAvailHeight?: number;
358
273
  screenColorDepth?: number;
359
274
  timezone?: string;
360
275
  fontList?: string[];
@@ -390,10 +305,8 @@ export declare function targetOsFromPlatform(plat: string): SupportedOS;
390
305
  * and before the init script is rendered.
391
306
  * @param webgl_config The [vendor, renderer] a drawn identity claims, instead
392
307
  * of drawing one.
393
- * @param screen_bound A bound on the drawn screen (screenFloor: one that holds
394
- * the window the context's pages report). A preset keeps its own.
395
308
  */
396
- export declare function generateContextFingerprint({ preset, os, ff_version, webrtc_ip, timezone, locale, config_overrides, webgl_config, screen_bound, }?: {
309
+ export declare function generateContextFingerprint({ preset, os, ff_version, webrtc_ip, timezone, locale, config_overrides, webgl_config, }?: {
397
310
  preset?: Preset | null;
398
311
  os?: string | null;
399
312
  ff_version?: string | null;
@@ -402,15 +315,9 @@ export declare function generateContextFingerprint({ preset, os, ff_version, web
402
315
  locale?: string | null;
403
316
  config_overrides?: Config | null;
404
317
  webgl_config?: [string, string] | null;
405
- screen_bound?: Screen | null;
406
318
  }): ContextFingerprint;
407
319
  /** Converts an fpgen fingerprint to a Camoufox config. */
408
320
  export declare function fromFpgen(fingerprint: Record<string, any>, ffVersion?: string | number | null): Config;
409
- /**
410
- * handleWindowSize() for a config: its geometry is final, where a drawn
411
- * fingerprint's is still rescaled when its devicePixelRatio moves.
412
- */
413
- export declare function placeWindow(config: Config, outerWidth: number, outerHeight: number): void;
414
321
  /** Sets a custom outer window size and centers it in the screen (in place). */
415
322
  export declare function handleWindowSize(fp: Record<string, any>, outerWidth: number, outerHeight: number): void;
416
323
  export interface GenerateFingerprintOptions {
@@ -207,11 +207,6 @@ function loadFontGroups() {
207
207
  }
208
208
  return fontGroupsCache;
209
209
  }
210
- /** The families of one addition unit (font-groups.json), e.g. ("win", "office"). */
211
- export function fontUnitFamilies(osKey, unitId) {
212
- const unit = (loadFontGroups()[osKey] ?? []).find((u) => u.id === unitId);
213
- return new Set(unit?.fonts ?? []);
214
- }
215
210
  let fontBasesCache = null;
216
211
  /** The OS-version bases per OS (font-bases.json), drawn entire by weight. */
217
212
  function loadFontBases() {
@@ -764,58 +759,6 @@ export function fixNavigatorArch(config, targetOs) {
764
759
  // and more than one touch point reads as 5 (CollapseMaxTouchPoints).
765
760
  export const BASELINE_TASKBAR_HEIGHT = LAUNCHER_CONSTANTS.baselineTaskbarHeight;
766
761
  export const BASELINE_MULTI_TOUCH_POINTS = LAUNCHER_CONSTANTS.baselineMultiTouchPoints;
767
- // The browser chrome around a page, outer minus inner, as [width, height] CSS
768
- // px per claimed OS. From fpgen's recorded Firefox windows (every record whose
769
- // window has a toolbar, outerHeight > innerHeight): the most common value per
770
- // axis, raised to the largest recorded within 2 px of it, the spread DPR
771
- // rounding gives one layout. Linux 85 -> 86 tall, macOS 84 -> 86, Windows 129
772
- // -> 130 and 16 -> 18 wide. No recorded window has a page taller than its
773
- // screen leaves room for: the 1366x768 records peak at innerHeight 683.
774
- // python/camoucore/tests/camoufox/test_viewport_fit.py derives these from the model again.
775
- export const RECORDED_WINDOW_CHROME = LAUNCHER_CONSTANTS.recordedWindowChrome;
776
- /**
777
- * The smallest screen, [width, height], that holds a page's window.
778
- *
779
- * A page with `viewport` sits in a window the recorded chrome larger; the page
780
- * also reports `window` (its position and outer size), which has to be on the
781
- * screen too. The height adds the taskbar the browser takes out of the
782
- * available screen for the claimed OS (BASELINE_TASKBAR_HEIGHT), so the window
783
- * fits screen.availHeight.
784
- */
785
- export function screenFloor(osKey, viewport, window) {
786
- let width = 0;
787
- let height = 0;
788
- if (viewport) {
789
- const [chromeW, chromeH] = RECORDED_WINDOW_CHROME[osKey];
790
- width = viewport.width + chromeW;
791
- height = viewport.height + chromeH;
792
- }
793
- if (window) {
794
- width = Math.max(width, Math.max(0, window.x || 0) + window.width);
795
- height = Math.max(height, Math.max(0, window.y || 0) + window.height);
796
- }
797
- return [width, height + BASELINE_TASKBAR_HEIGHT[osKey]];
798
- }
799
- /**
800
- * A recorded screen of the OS at least `floor` in size, or null if the model
801
- * has none that large.
802
- */
803
- export function drawScreen(osKey, floor) {
804
- const conditions = new Screen({
805
- minWidth: floor[0],
806
- minHeight: floor[1],
807
- }).asConditions();
808
- let screen;
809
- try {
810
- screen = generate({ browser: "Firefox", os: FPGEN_OS[osKey], ...conditions }, { target: "screen" });
811
- }
812
- catch (err) {
813
- if (!(err instanceof InvalidConstraints))
814
- throw err;
815
- return null;
816
- }
817
- return [screen.width, screen.height];
818
- }
819
762
  /**
820
763
  * Claim the available screen and touch points the browser will report.
821
764
  * clampWindowDimensions then fits the window inside that screen.
@@ -885,7 +828,7 @@ export function clampScreenToDisplay(config, maxWidth, maxHeight) {
885
828
  /**
886
829
  * Keep the window box inside the available screen: 0 <= screenX/Y <= avail -
887
830
  * outer. The available screen, not the whole one: pages are fitted to the
888
- * window on screen.availHeight (screenFloor), and a window at y=2 whose outer
831
+ * window on screen.availHeight, and a window at y=2 whose outer
889
832
  * height is the available height ran 2 px into the taskbar, so every new
890
833
  * context drew a larger screen for it. Only `keys` are moved.
891
834
  */
@@ -960,9 +903,6 @@ const MEDIA_P_BUILTIN_CAM = {
960
903
  mac: 0.0,
961
904
  lin: 0.45,
962
905
  };
963
- // A camera media-devices.json has no camera_modes entry for: a 720p laptop
964
- // camera, as most are (width, height, frame rate of its largest mode).
965
- const DEFAULT_CAMERA_MODE = [1280, 720, 30];
966
906
  /**
967
907
  * Draw one machine's media devices for `osKey` ('win'|'mac'|'lin'): the
968
908
  * mediaDevices:* config keys, counts plus aligned label and group lists.
@@ -1020,11 +960,6 @@ export function drawMediaDevices(osKey, seed) {
1020
960
  for (const [label, grp] of [...outs])
1021
961
  mics.push([`Monitor of ${label}`, grp]);
1022
962
  }
1023
- // What each device reports once captured (media-device-spoofing.patch):
1024
- // a camera's largest mode, a microphone's channel count.
1025
- const modes = cat.camera_modes ?? {};
1026
- const mono = new Set(cat.mono_mics ?? []);
1027
- const camModes = cams.map(([c]) => Object.hasOwn(modes, c) ? modes[c] : DEFAULT_CAMERA_MODE);
1028
963
  return {
1029
964
  "mediaDevices:enabled": true,
1030
965
  "mediaDevices:micros": mics.length,
@@ -1036,10 +971,6 @@ export function drawMediaDevices(osKey, seed) {
1036
971
  "mediaDevices:webcamGroups": cams.map(([, g]) => g),
1037
972
  "mediaDevices:speakerLabels": outs.map(([o]) => o),
1038
973
  "mediaDevices:speakerGroups": outs.map(([, g]) => g),
1039
- "mediaDevices:webcamMaxWidths": camModes.map((m) => m[0]),
1040
- "mediaDevices:webcamMaxHeights": camModes.map((m) => m[1]),
1041
- "mediaDevices:webcamMaxFrameRates": camModes.map((m) => m[2]),
1042
- "mediaDevices:microphoneChannels": mics.map(([m]) => (mono.has(m) ? 1 : 2)),
1043
974
  };
1044
975
  }
1045
976
  /**
@@ -1058,135 +989,6 @@ export function setMediaDevicesDefaults(config, salt = 0) {
1058
989
  : "lin";
1059
990
  Object.assign(config, drawMediaDevices(osKey, identitySeed(config, salt)));
1060
991
  }
1061
- /**
1062
- * Share of machines whose one adapter carries IPv6 next to IPv4. No recorded
1063
- * corpus has the ICE shape; this is Google's IPv6 adoption figure (~45% of its
1064
- * users in 2025, google.com/ipv6/statistics), which counts global IPv6 only,
1065
- * so it is a lower bound. A real-device measurement replaces it.
1066
- */
1067
- export const HOST_IPV6_SHARE = 0.45;
1068
- /**
1069
- * Draw the identity's network shape: one adapter, IPv4 only or IPv4 + IPv6
1070
- * (webrtc:hostipv6, webrtc-topology-host-ipv6.patch). Mirrors Python's
1071
- * set_host_ipv6_default; nothing is drawn when the caller set it.
1072
- */
1073
- export function setHostIpv6Default(config, salt = 0) {
1074
- if ("webrtc:hostipv6" in config)
1075
- return;
1076
- if (config["network:ipv4Only"]) {
1077
- // The host's own IPv6 is turned off: a machine on an IPv4-only network.
1078
- config["webrtc:hostipv6"] = false;
1079
- }
1080
- else if ("webrtc:ipv6" in config) {
1081
- // The exit address is IPv6, so the machine has IPv6.
1082
- config["webrtc:hostipv6"] = true;
1083
- }
1084
- else {
1085
- const draw = rng((identitySeed(config, salt) ^ 0x1ce6) >>> 0).random();
1086
- config["webrtc:hostipv6"] = draw < HOST_IPV6_SHARE;
1087
- }
1088
- }
1089
- /**
1090
- * Windows' location setting for desktop apps, as Firefox reads it
1091
- * (GeolocationSystemWin.cpp). No recorded corpus has it; an estimate a
1092
- * real-device measurement replaces. Mirrors Python's
1093
- * WINDOWS_LOCATION_SETTING_SHARES.
1094
- */
1095
- export const WINDOWS_LOCATION_SETTING_SHARES = [
1096
- ["allowed", 0.55],
1097
- ["prompt", 0.3],
1098
- ["denied", 0.15],
1099
- ];
1100
- /**
1101
- * Draw the identity's OS location setting (geolocation:systemPermission,
1102
- * geolocation-spoofing.patch) for a Windows identity on another host. Mirrors
1103
- * Python's set_location_setting_default.
1104
- */
1105
- export function setLocationSettingDefault(config, salt, targetOs, hostOs) {
1106
- if ("geolocation:systemPermission" in config ||
1107
- targetOs !== "win" ||
1108
- hostOs === "win")
1109
- return;
1110
- if ("geolocation:latitude" in config && "geolocation:longitude" in config) {
1111
- config["geolocation:systemPermission"] = "allowed";
1112
- return;
1113
- }
1114
- // No coordinates: nothing at the exit to report, so location is never on.
1115
- const shares = WINDOWS_LOCATION_SETTING_SHARES.filter(([name]) => name !== "allowed");
1116
- let draw = rng((identitySeed(config, salt) ^ 0x10ca) >>> 0).random() *
1117
- shares.reduce((sum, [, share]) => sum + share, 0);
1118
- let state = shares[0][0];
1119
- for (const [name, share] of shares) {
1120
- state = name;
1121
- draw -= share;
1122
- if (draw < 0)
1123
- break;
1124
- }
1125
- config["geolocation:systemPermission"] = state;
1126
- }
1127
- let audioOutputLatencyCache;
1128
- /** Measured AudioContext.outputLatency per OS (audio-output-latency.json). */
1129
- function loadAudioOutputLatency() {
1130
- audioOutputLatencyCache ??= loadDataFile("audio-output-latency.json");
1131
- return audioOutputLatencyCache;
1132
- }
1133
- /**
1134
- * When stock Windows Firefox's deferred font-info loader lands the legacy
1135
- * styled-family aliases after the first legacy lookup (stock 158.0.1 on win-i9:
1136
- * 1727, 1826, 1832 ms on a 100 ms poll). Mirrors Python's
1137
- * WINDOWS_ALIAS_LOAD_MS / set_windows_alias_load_default: drawn per launch for a
1138
- * Windows identity on another OS; a caller's value is kept.
1139
- */
1140
- export const WINDOWS_ALIAS_LOAD_MS = [1630, 1832];
1141
- /**
1142
- * How long stock Windows Firefox's character-map pass takes to land after the
1143
- * first fallback within a family whose cmaps are not loaded yet
1144
- * (windows-lazy-cmaps.patch; win-i9: 80, 154, 182 ms). Mirrors Python's
1145
- * WINDOWS_CMAP_LOAD_MS; drawn with the alias load time.
1146
- */
1147
- export const WINDOWS_CMAP_LOAD_MS = [80, 182];
1148
- /**
1149
- * Injection point for the draws that belong to the launch, not the identity
1150
- * (timing: a real machine's figure moves from launch to launch). Mirrors
1151
- * Python's launch_uniform(); the launch goldens pin both to one value.
1152
- */
1153
- export const fingerprintDeps = {
1154
- random: () => Math.random(),
1155
- };
1156
- export function setWindowsAliasLoadDefault(config, targetOs, hostOs) {
1157
- if (targetOs !== "win" || targetOs === hostOs)
1158
- return;
1159
- for (const [key, [low, high]] of [
1160
- ["fonts:windowsAliasLoadMs", WINDOWS_ALIAS_LOAD_MS],
1161
- ["fonts:windowsCmapLoadMs", WINDOWS_CMAP_LOAD_MS],
1162
- ]) {
1163
- if (key in config)
1164
- continue;
1165
- config[key] = low + Math.floor(fingerprintDeps.random() * (high - low + 1));
1166
- }
1167
- }
1168
- /**
1169
- * Draw the identity's audio output device latency (AudioContext:outputLatency,
1170
- * audio-context-spoofing.patch). The device latency follows the identity seed;
1171
- * the stream's opening delay is drawn per launch. Mirrors Python's
1172
- * set_output_latency_default; nothing is set when the caller set the key, the
1173
- * identity claims the host's OS, or the OS has no measured devices.
1174
- */
1175
- export function setOutputLatencyDefault(config, salt, targetOs, hostOs) {
1176
- if ("AudioContext:outputLatency" in config || targetOs === hostOs)
1177
- return;
1178
- const table = loadAudioOutputLatency()[targetOs] ?? {};
1179
- const devices = table.device_latency_s ?? [];
1180
- if (!devices.length)
1181
- return;
1182
- const device = weightedChoice(rng((identitySeed(config, salt) ^ 0xa0d1) >>> 0), devices);
1183
- config["AudioContext:outputLatency"] = Number(device.v);
1184
- const [low, high] = table.open_delay_ms ?? [20, 60];
1185
- if (!("AudioContext:outputLatencyDelayMs" in config)) {
1186
- config["AudioContext:outputLatencyDelayMs"] =
1187
- low + (high - low) * fingerprintDeps.random();
1188
- }
1189
- }
1190
992
  /**
1191
993
  * Intel's share of the x86 desktop CPUs running Firefox (Firefox Public Data
1192
994
  * Report, week of 2026-11-02: Intel 76.86%, AMD 17.61%); fingerprints.py.
@@ -1494,18 +1296,11 @@ export function buildInitScript(values) {
1494
1296
  lines.push(` if (typeof w.${fnName} === "function") w.${fnName}(${pyJsonDumps(val)});`);
1495
1297
  }
1496
1298
  }
1497
- // Screen dimensions (requires width + height together). The available rect
1498
- // rides along when the identity has one; a build that keeps only the full
1499
- // size ignores the extra arguments.
1299
+ // Screen dimensions (requires width + height together)
1500
1300
  const sw = values.screenWidth;
1501
1301
  const sh = values.screenHeight;
1502
1302
  if (pyTruthy(sw) && pyTruthy(sh)) {
1503
- const aw = values.screenAvailWidth;
1504
- const ah = values.screenAvailHeight;
1505
- const dims = pyTruthy(aw) && pyTruthy(ah)
1506
- ? `${sw}, ${sh}, ${aw}, ${ah}`
1507
- : `${sw}, ${sh}`;
1508
- lines.push(` if (typeof w.setScreenDimensions === "function") w.setScreenDimensions(${dims});`);
1303
+ lines.push(` if (typeof w.setScreenDimensions === "function") w.setScreenDimensions(${sw}, ${sh});`);
1509
1304
  const scd = values.screenColorDepth;
1510
1305
  if (pyTruthy(scd)) {
1511
1306
  lines.push(` if (typeof w.setScreenColorDepth === "function") w.setScreenColorDepth(${scd});`);
@@ -1587,10 +1382,8 @@ export function targetOsFromPlatform(plat) {
1587
1382
  * and before the init script is rendered.
1588
1383
  * @param webgl_config The [vendor, renderer] a drawn identity claims, instead
1589
1384
  * of drawing one.
1590
- * @param screen_bound A bound on the drawn screen (screenFloor: one that holds
1591
- * the window the context's pages report). A preset keeps its own.
1592
1385
  */
1593
- export function generateContextFingerprint({ preset, os, ff_version, webrtc_ip, timezone, locale, config_overrides, webgl_config, screen_bound, } = {}) {
1386
+ export function generateContextFingerprint({ preset, os, ff_version, webrtc_ip, timezone, locale, config_overrides, webgl_config, } = {}) {
1594
1387
  let config;
1595
1388
  let nav;
1596
1389
  let screen;
@@ -1605,10 +1398,7 @@ export function generateContextFingerprint({ preset, os, ff_version, webrtc_ip,
1605
1398
  resolvedPreset = p;
1606
1399
  }
1607
1400
  else {
1608
- const fp = generateFingerprint({
1609
- os: os ?? undefined,
1610
- screen: screen_bound ?? undefined,
1611
- });
1401
+ const fp = generateFingerprint({ os: os ?? undefined });
1612
1402
  config = fromFpgen(fp, ff_version);
1613
1403
  // fpgen's Linux pool now and then pairs the Linux UA with a Windows
1614
1404
  // platform and oscpu. launchOptions() corrects that; this path did not,
@@ -1713,8 +1503,6 @@ export function generateContextFingerprint({ preset, os, ff_version, webrtc_ip,
1713
1503
  webglRenderer: webgl.unmaskedRenderer,
1714
1504
  screenWidth: screen.width,
1715
1505
  screenHeight: screen.height,
1716
- screenAvailWidth: config["screen.availWidth"],
1717
- screenAvailHeight: config["screen.availHeight"],
1718
1506
  screenColorDepth: screen.colorDepth,
1719
1507
  timezone: typeof resolvedPreset.timezone === "string"
1720
1508
  ? resolvedPreset.timezone
@@ -1730,38 +1518,13 @@ export function generateContextFingerprint({ preset, os, ff_version, webrtc_ip,
1730
1518
  const ua = config["navigator.userAgent"];
1731
1519
  if (pyTruthy(ua))
1732
1520
  contextOptions.userAgent = ua;
1733
- // No viewport: the pages are the browser's window, whose size the page
1734
- // reads in outerWidth/outerHeight, and the screen is drawn to hold it
1735
- // (screen_bound). A viewport the size of the screen sat in that window as a
1736
- // page larger than its own window.
1737
- // Playwright takes a device scale factor only with a viewport: a context
1738
- // with its own devicePixelRatio gets the drawn page size as its viewport,
1739
- // and Juggler sizes the window to it plus the claimed OS's chrome.
1521
+ const sw = screen.width;
1522
+ const sh = screen.height;
1523
+ if (pyTruthy(sw) && pyTruthy(sh))
1524
+ contextOptions.viewport = { width: sw, height: Math.max(sh - 28, 600) };
1740
1525
  const dpr = screen.devicePixelRatio;
1741
- let innerW = config["window.innerWidth"];
1742
- let innerH = config["window.innerHeight"];
1743
- const availW = config["screen.availWidth"];
1744
- const availH = config["screen.availHeight"];
1745
- if (pyTruthy(dpr) &&
1746
- !(pyTruthy(innerW) && pyTruthy(innerH)) &&
1747
- pyTruthy(availW) &&
1748
- pyTruthy(availH)) {
1749
- // A preset records its screen but no window: a maximised one, the
1750
- // available screen less the recorded chrome of the OS it claims.
1751
- const [chromeW, chromeH] = RECORDED_WINDOW_CHROME[OS_TO_KEY[targetOsFromPlatform(pyStr(get(config, "navigator.platform", "")))]];
1752
- innerW = num(availW) - chromeW;
1753
- innerH = num(availH) - chromeH;
1754
- }
1755
- if (pyTruthy(dpr) && pyTruthy(innerW) && pyTruthy(innerH)) {
1756
- contextOptions.viewport = {
1757
- width: Math.trunc(Number(innerW)),
1758
- height: Math.trunc(Number(innerH)),
1759
- };
1526
+ if (pyTruthy(dpr))
1760
1527
  contextOptions.deviceScaleFactor = dpr;
1761
- }
1762
- else {
1763
- contextOptions.viewport = null;
1764
- }
1765
1528
  let tz = config.timezone;
1766
1529
  if (!pyTruthy(tz))
1767
1530
  tz = resolvedPreset.timezone;
@@ -1847,23 +1610,6 @@ export function fromFpgen(fingerprint, ffVersion) {
1847
1610
  setAppVersion(camoufoxData);
1848
1611
  return camoufoxData;
1849
1612
  }
1850
- /**
1851
- * handleWindowSize() for a config: its geometry is final, where a drawn
1852
- * fingerprint's is still rescaled when its devicePixelRatio moves.
1853
- */
1854
- export function placeWindow(config, outerWidth, outerHeight) {
1855
- for (const [axis, outer, position] of [
1856
- ["Width", outerWidth, "X"],
1857
- ["Height", outerHeight, "Y"],
1858
- ]) {
1859
- const inner = config[`window.inner${axis}`];
1860
- if (pyTruthy(inner)) {
1861
- config[`window.inner${axis}`] = Math.max(outer - (config[`window.outer${axis}`] || 0) + inner, 0);
1862
- }
1863
- config[`window.outer${axis}`] = outer;
1864
- config[`window.screen${position}`] = Math.floor(((config[`screen.${axis.toLowerCase()}`] || outer) - outer) / 2);
1865
- }
1866
- }
1867
1613
  /** Sets a custom outer window size and centers it in the screen (in place). */
1868
1614
  export function handleWindowSize(fp, outerWidth, outerHeight) {
1869
1615
  fp.screen ??= {};
@@ -354,15 +354,10 @@ export async function installVersioned(fetcher, replace = false) {
354
354
  fs.rmSync(installPath, { recursive: true, force: true });
355
355
  }
356
356
  const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "camoufox-"));
357
- const tempFilePath = fetcher.partial ?? path.join(tempDir, "camoufox.zip");
357
+ const tempFilePath = path.join(tempDir, "camoufox.zip");
358
358
  try {
359
359
  fs.mkdirSync(installPath, { recursive: true });
360
- // Mark the install dir as compatible with this version. Before the
361
- // download, so that one kept to be resumed is not cleaned as old data.
362
- fs.writeFileSync(COMPAT_FLAG, "");
363
- const tempFileStream = fs.createWriteStream(tempFilePath, {
364
- flags: fetcher.partial ? "a" : "w",
365
- });
360
+ const tempFileStream = fs.createWriteStream(tempFilePath);
366
361
  // finished() listens for the stream's 'error' from the start. Without a
367
362
  // listener, a failed write (disk full) is an uncaught 'error' event that
368
363
  // kills the process before the catch below can remove the partial
@@ -370,7 +365,9 @@ export async function installVersioned(fetcher, replace = false) {
370
365
  const written = finished(tempFileStream);
371
366
  written.catch(() => { }); // awaited below; a download error wins
372
367
  try {
373
- await fetcher.download(tempFileStream);
368
+ // Through the instance's class, as Python's fetcher.download_file(),
369
+ // so a subclass can override it.
370
+ await fetcher.constructor.downloadFile(tempFileStream, fetcher.url);
374
371
  }
375
372
  finally {
376
373
  tempFileStream.end();
@@ -397,6 +394,8 @@ export async function installVersioned(fetcher, replace = false) {
397
394
  makeExecutable(installPath);
398
395
  }
399
396
  setActive(`browsers/${repoName}/${versionFolder}`);
397
+ // Mark the install dir as compatible with this version
398
+ fs.writeFileSync(COMPAT_FLAG, "");
400
399
  rprint(`\nCamoufox v${fetcher.verstr} installed.`, "green");
401
400
  rprint(`Path: ${installPath}`, "green");
402
401
  return true;
@@ -17,15 +17,12 @@ export const INSTALL_DIR = PRODUCT.cacheDir;
17
17
  * tarball, so one seed draws one identity in either launcher.
18
18
  */
19
19
  export const DATA_FILES = [
20
- "audio-output-latency.json",
21
20
  "browser-pin.json",
22
- "display-profiles.json",
23
21
  "essential-fonts.json",
24
22
  "fingerprint-presets.json",
25
23
  "fingerprint-presets-v150.json",
26
24
  "font-bases.json",
27
25
  "font-groups.json",
28
- "font-prefs.json",
29
26
  "fonts.json",
30
27
  "fpgen.yml",
31
28
  "launcher-constants.json",
@@ -1,6 +1,5 @@
1
1
  import type { Writable } from "node:stream";
2
- import { type ProgressCallback } from "../download.js";
3
- export { GITHUB_TOKEN, type ProgressCallback, unzip, verifySha256, } from "../download.js";
2
+ export { GITHUB_TOKEN, type ProgressCallback, unzip, verifySha256, webdl, } from "../download.js";
4
3
  /**
5
4
  * Ensure Firefox's Linux application directory exists before startup.
6
5
  *
@@ -225,11 +224,6 @@ export declare class CamoufoxFetcher {
225
224
  _versionObj?: Version;
226
225
  _selectedVersion?: AvailableVersion;
227
226
  _url?: string;
228
- /**
229
- * Where the download is kept between runs, so that a later fetch resumes
230
- * it; unset downloads into a temporary file.
231
- */
232
- partial?: string;
233
227
  constructor(repoConfig?: RepoConfig, selectedVersion?: AvailableVersion);
234
228
  /**
235
229
  * The Python constructor calls fetch_latest() inline; downloads are async in
@@ -260,11 +254,6 @@ export declare class CamoufoxFetcher {
260
254
  */
261
255
  fetchLatest(): Promise<void>;
262
256
  static downloadFile(file: Writable, url: string): Promise<void>;
263
- /**
264
- * Download this build's archive into `file`. Through the instance's class,
265
- * as Python's fetcher.download_file(), so a subclass can override either.
266
- */
267
- download(file: Writable): Promise<void>;
268
257
  /**
269
258
  * Download and install camoufox to a versioned subdirectory.
270
259
  */
@@ -331,25 +320,6 @@ export declare function launchPath(browserPath?: string): string;
331
320
  * downloads, and it warns when the build is not the paired one.
332
321
  */
333
322
  export declare function selectedLaunchPath(specifier: string): string;
334
- /**
335
- * camoucore.download.webdl cannot resume (no `offset`, `restart`); this stays
336
- * until it can.
337
- *
338
- * Download a file from the given URL. Streams into `buffer` when one is given,
339
- * otherwise accumulates and returns the bytes.
340
- *
341
- * An HTTP error raises requests' "<status> Client Error: ... for url: ..."
342
- * message, like the Python twin; see request() for network failures.
343
- *
344
- * `offset` resumes a download whose first `offset` bytes `buffer` already
345
- * appends to. `restart` empties what `buffer` writes to: it is called when the
346
- * server sends the whole file, not the rest of it.
347
- */
348
- export declare function webdl(url: string, desc?: string, bar?: boolean, buffer?: Writable | null, { progressCallback, offset, restart, }?: {
349
- progressCallback?: ProgressCallback;
350
- offset?: number;
351
- restart?: () => void;
352
- }): Promise<Buffer>;
353
323
  /**
354
324
  * chmod -R 755 on POSIX so the freshly-extracted binaries are executable.
355
325
  * (The zip does not carry usable permission bits on every platform.)