@fingerly/web-js 0.0.0-stage → 0.1.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.
package/dist/index.js ADDED
@@ -0,0 +1,1783 @@
1
+ import { SOURCE, valueOf, BlockedSignal, UnsupportedSignal, hash64, FingerlyClient } from '@fingerly/core';
2
+ export { ConsentError, FingerlyClient, SOURCE, TransportError, isSuspiciousLevel } from '@fingerly/core';
3
+
4
+ // src/index.ts
5
+ function compact(value) {
6
+ const out = {};
7
+ for (const [key, entry] of Object.entries(value)) {
8
+ if (entry !== void 0) out[key] = entry;
9
+ }
10
+ return out;
11
+ }
12
+ function attempt(read) {
13
+ try {
14
+ return read();
15
+ } catch {
16
+ return void 0;
17
+ }
18
+ }
19
+ function windowOrNull() {
20
+ return typeof window === "undefined" ? void 0 : window;
21
+ }
22
+ function requireWindow() {
23
+ const w = windowOrNull();
24
+ if (!w) throw new UnsupportedSignal("no-window");
25
+ return w;
26
+ }
27
+ function asBlockedIfRefused(error) {
28
+ if (error instanceof Error) {
29
+ if (error.name === "SecurityError" || error.name === "NotAllowedError" || error.name === "NotSupportedError") {
30
+ throw new BlockedSignal(error.name);
31
+ }
32
+ }
33
+ throw error;
34
+ }
35
+
36
+ // src/lies/descriptors.ts
37
+ var NATIVE_PATTERN = /\{\s*\[native code\]\s*\}\s*$/;
38
+ var INSTANCE_SHOULD_NOT_OWN = [
39
+ ["navigator", "webdriver"],
40
+ ["navigator", "userAgent"],
41
+ ["navigator", "platform"],
42
+ ["navigator", "plugins"],
43
+ ["navigator", "mimeTypes"],
44
+ ["navigator", "languages"],
45
+ ["navigator", "language"],
46
+ ["navigator", "hardwareConcurrency"],
47
+ ["navigator", "deviceMemory"],
48
+ ["navigator", "maxTouchPoints"],
49
+ ["navigator", "vendor"],
50
+ ["navigator", "appVersion"],
51
+ ["navigator", "productSub"],
52
+ ["screen", "width"],
53
+ ["screen", "height"],
54
+ ["screen", "availWidth"],
55
+ ["screen", "availHeight"],
56
+ ["screen", "colorDepth"]
57
+ ];
58
+ function findRedefinedProperties(w) {
59
+ const lies = [];
60
+ for (const [holderName, property] of INSTANCE_SHOULD_NOT_OWN) {
61
+ const holder = holderName === "navigator" ? w.navigator : w.screen;
62
+ if (!holder) continue;
63
+ const own = attempt(() => Object.getOwnPropertyDescriptor(holder, property));
64
+ if (own) {
65
+ lies.push({
66
+ id: `${holderName}.${property}`,
67
+ kind: "descriptor",
68
+ detail: "own-property-shadows-prototype"
69
+ });
70
+ continue;
71
+ }
72
+ const proto = attempt(() => Object.getPrototypeOf(holder));
73
+ if (!proto) continue;
74
+ const inherited = attempt(() => Object.getOwnPropertyDescriptor(proto, property));
75
+ if (!inherited?.get) continue;
76
+ const source = attempt(() => Function.prototype.toString.call(inherited.get));
77
+ if (source !== void 0 && !NATIVE_PATTERN.test(source)) {
78
+ lies.push({
79
+ id: `${holderName}.${property}.getter`,
80
+ kind: "descriptor",
81
+ detail: "getter-is-not-native"
82
+ });
83
+ }
84
+ }
85
+ const navigatorProto = attempt(() => Object.getPrototypeOf(w.navigator));
86
+ if (w.Navigator && navigatorProto !== void 0 && navigatorProto !== w.Navigator.prototype) {
87
+ lies.push({ id: "navigator", kind: "prototype", detail: "not-Navigator.prototype" });
88
+ }
89
+ const screenProto = attempt(() => Object.getPrototypeOf(w.screen));
90
+ if (w.Screen && screenProto !== void 0 && screenProto !== w.Screen.prototype) {
91
+ lies.push({ id: "screen", kind: "prototype", detail: "not-Screen.prototype" });
92
+ }
93
+ return lies;
94
+ }
95
+
96
+ // src/lies/natives.ts
97
+ var NATIVE_PATTERN2 = /\{\s*\[native code\]\s*\}\s*$/;
98
+ var TARGETS = [
99
+ ["Function.prototype.toString", () => Function.prototype.toString],
100
+ ["Function.prototype.bind", () => Function.prototype.bind],
101
+ ["Object.getOwnPropertyDescriptor", () => Object.getOwnPropertyDescriptor],
102
+ ["Object.defineProperty", () => Object.defineProperty],
103
+ ["Date.prototype.getTimezoneOffset", () => Date.prototype.getTimezoneOffset],
104
+ ["Number.prototype.toFixed", () => Number.prototype.toFixed],
105
+ ["Error.prototype.toString", () => Error.prototype.toString],
106
+ ["Intl.DateTimeFormat", () => Intl?.DateTimeFormat],
107
+ ["Navigator.prototype.javaEnabled", (w) => w.Navigator?.prototype?.javaEnabled],
108
+ ["Permissions.prototype.query", (w) => w.Permissions?.prototype?.query],
109
+ ["MediaDevices.prototype.enumerateDevices", (w) => w.MediaDevices?.prototype?.enumerateDevices],
110
+ ["HTMLCanvasElement.prototype.toDataURL", (w) => w.HTMLCanvasElement?.prototype?.toDataURL],
111
+ [
112
+ "CanvasRenderingContext2D.prototype.getImageData",
113
+ (w) => w.CanvasRenderingContext2D?.prototype?.getImageData
114
+ ],
115
+ [
116
+ "WebGLRenderingContext.prototype.getParameter",
117
+ (w) => w.WebGLRenderingContext?.prototype?.getParameter
118
+ ],
119
+ [
120
+ "WebGLRenderingContext.prototype.getExtension",
121
+ (w) => w.WebGLRenderingContext?.prototype?.getExtension
122
+ ],
123
+ ["AudioBuffer.prototype.getChannelData", (w) => w.AudioBuffer?.prototype?.getChannelData],
124
+ ["Element.prototype.getBoundingClientRect", (w) => w.Element?.prototype?.getBoundingClientRect],
125
+ ["Performance.prototype.now", (w) => w.Performance?.prototype?.now],
126
+ ["Screen.prototype.constructor", (w) => w.Screen]
127
+ ];
128
+ function borrowToString() {
129
+ const own = Function.prototype.toString;
130
+ if (typeof document === "undefined" || !document.body) return { fn: own, clean: false };
131
+ const frame = attempt(() => {
132
+ const element = document.createElement("iframe");
133
+ element.setAttribute("sandbox", "allow-same-origin");
134
+ element.style.display = "none";
135
+ document.body.appendChild(element);
136
+ return element;
137
+ });
138
+ if (!frame) return { fn: own, clean: false };
139
+ try {
140
+ const borrowed = attempt(
141
+ () => frame.contentWindow?.Function?.prototype?.toString
142
+ );
143
+ return borrowed ? { fn: borrowed, clean: true } : { fn: own, clean: false };
144
+ } finally {
145
+ frame.remove();
146
+ }
147
+ }
148
+ function findPatchedNatives(w) {
149
+ const patched = [];
150
+ const lies = [];
151
+ const { fn: toString, clean } = borrowToString();
152
+ const stringify = (value) => attempt(() => toString.call(value));
153
+ for (const [path, resolve] of TARGETS) {
154
+ const target = attempt(() => resolve(w));
155
+ if (target === void 0 || target === null) {
156
+ lies.push({ id: path, kind: "missing" });
157
+ continue;
158
+ }
159
+ if (typeof target !== "function") continue;
160
+ const source = stringify(target);
161
+ if (source === void 0) continue;
162
+ if (!NATIVE_PATTERN2.test(source)) {
163
+ patched.push(path);
164
+ lies.push({ id: path, kind: "not-native" });
165
+ }
166
+ }
167
+ if (clean) {
168
+ const own = Function.prototype.toString;
169
+ const viaBorrowed = stringify(own);
170
+ if (viaBorrowed !== void 0 && !NATIVE_PATTERN2.test(viaBorrowed)) {
171
+ if (!patched.includes("Function.prototype.toString")) {
172
+ patched.push("Function.prototype.toString");
173
+ }
174
+ lies.push({
175
+ id: "Function.prototype.toString",
176
+ kind: "not-native",
177
+ detail: "caught-via-fresh-realm"
178
+ });
179
+ }
180
+ }
181
+ return { patched, lies };
182
+ }
183
+
184
+ // src/lies/index.ts
185
+ function inspectIntegrity(sources) {
186
+ const w = windowOrNull();
187
+ const engine = valueOf(
188
+ {
189
+ schema: 1,
190
+ budget_ms: 0,
191
+ elapsed_ms: 0,
192
+ tiers: [],
193
+ sources,
194
+ integrity: { patched_natives: [], lies: [], engine: {} }
195
+ },
196
+ SOURCE.engine
197
+ );
198
+ const identity = {
199
+ ...engine?.claimed === void 0 ? {} : { claimed: engine.claimed },
200
+ ...engine?.observed === void 0 ? {} : { observed: engine.observed }
201
+ };
202
+ if (!w) {
203
+ return { patched_natives: [], lies: [], engine: identity };
204
+ }
205
+ const natives = findPatchedNatives(w);
206
+ const descriptors = findRedefinedProperties(w);
207
+ return {
208
+ patched_natives: natives.patched,
209
+ lies: [...natives.lies, ...descriptors],
210
+ engine: identity
211
+ };
212
+ }
213
+ function offlineConstructor() {
214
+ const w = globalThis;
215
+ const ctor = w.OfflineAudioContext ?? w.webkitOfflineAudioContext;
216
+ if (!ctor) throw new UnsupportedSignal("no-offline-audio-context");
217
+ return ctor;
218
+ }
219
+ async function render(ctx) {
220
+ const OfflineContext = offlineConstructor();
221
+ const context = new OfflineContext(1, 5e3, 44100);
222
+ const oscillator = context.createOscillator();
223
+ oscillator.type = "triangle";
224
+ oscillator.frequency.value = 1e4;
225
+ const compressor = context.createDynamicsCompressor();
226
+ compressor.threshold.value = -50;
227
+ compressor.knee.value = 40;
228
+ compressor.ratio.value = 12;
229
+ compressor.attack.value = 0;
230
+ compressor.release.value = 0.25;
231
+ oscillator.connect(compressor);
232
+ compressor.connect(context.destination);
233
+ oscillator.start(0);
234
+ const buffer = await new Promise((resolve, reject) => {
235
+ ctx.signal.addEventListener("abort", () => reject(ctx.signal.reason), { once: true });
236
+ context.oncomplete = (event) => resolve(event.renderedBuffer);
237
+ try {
238
+ const started = context.startRendering();
239
+ if (started && typeof started.then === "function") started.then(resolve, reject);
240
+ } catch (error) {
241
+ reject(error);
242
+ }
243
+ });
244
+ const samples = buffer.getChannelData(0);
245
+ let sum = 0;
246
+ for (let i = 4500; i < samples.length; i++) sum += Math.abs(samples[i] ?? 0);
247
+ return sum;
248
+ }
249
+ var audioSource = {
250
+ id: SOURCE.audio,
251
+ tier: "deferred",
252
+ timeoutMs: 500,
253
+ async run(ctx) {
254
+ const first = await render(ctx);
255
+ if (first === 0) throw new BlockedSignal("audio-silent");
256
+ const second = await render(ctx);
257
+ return compact({
258
+ value: first,
259
+ unstable: first !== second,
260
+ sample_rate: 44100
261
+ });
262
+ }
263
+ };
264
+ var audioLatencySource = {
265
+ id: SOURCE.audioLatency,
266
+ tier: "deferred",
267
+ timeoutMs: 200,
268
+ run() {
269
+ const w = globalThis;
270
+ const Ctor = w.AudioContext ?? w.webkitAudioContext;
271
+ if (!Ctor) throw new UnsupportedSignal("no-audio-context");
272
+ const context = new Ctor();
273
+ try {
274
+ return compact({
275
+ base_latency: attempt(() => context.baseLatency),
276
+ sample_rate: attempt(() => context.sampleRate),
277
+ state: attempt(() => context.state)
278
+ });
279
+ } finally {
280
+ attempt(() => void context.close());
281
+ }
282
+ }
283
+ };
284
+ var hardwareSource = {
285
+ id: SOURCE.hardware,
286
+ tier: "fast",
287
+ run() {
288
+ if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
289
+ const nav = navigator;
290
+ return compact({
291
+ hardware_concurrency: attempt(() => nav.hardwareConcurrency),
292
+ device_memory: attempt(() => nav.deviceMemory)
293
+ });
294
+ }
295
+ };
296
+ var touchSource = {
297
+ id: SOURCE.touch,
298
+ tier: "fast",
299
+ run() {
300
+ const w = requireWindow();
301
+ return compact({
302
+ max_touch_points: attempt(() => navigator.maxTouchPoints),
303
+ touch_event: attempt(() => "ontouchstart" in w),
304
+ touch_start: attempt(() => {
305
+ document.createEvent("TouchEvent");
306
+ return true;
307
+ }),
308
+ pointer_coarse: attempt(() => w.matchMedia?.("(pointer: coarse)").matches),
309
+ any_hover: attempt(() => w.matchMedia?.("(any-hover: hover)").matches),
310
+ // Presence only, and in the fast tier for that reason: the deferred
311
+ // `sensors` source is what waits to see whether an event fires. This is
312
+ // what the server's mobile-UA-with-no-motion-sensors rule reads.
313
+ device_motion: attempt(() => "DeviceMotionEvent" in w),
314
+ device_orientation: attempt(() => "DeviceOrientationEvent" in w)
315
+ });
316
+ }
317
+ };
318
+ var sensorsSource = {
319
+ id: SOURCE.sensors,
320
+ tier: "deferred",
321
+ // 150ms, not the 250 this started at. A real accelerometer delivers
322
+ // `devicemotion` at 60Hz, so anything past the first few frames is waiting
323
+ // for an event that is not coming.
324
+ timeoutMs: 150,
325
+ async run(ctx) {
326
+ const w = requireWindow();
327
+ const hasMotion = "DeviceMotionEvent" in w;
328
+ const hasOrientation = "DeviceOrientationEvent" in w;
329
+ if (!hasMotion && !hasOrientation) {
330
+ return compact({ device_motion: false, device_orientation: false });
331
+ }
332
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
333
+ return compact({
334
+ device_motion: hasMotion,
335
+ device_orientation: hasOrientation
336
+ });
337
+ }
338
+ const observed = await new Promise((resolve) => {
339
+ let settled = false;
340
+ const finish = (value) => {
341
+ if (settled) return;
342
+ settled = true;
343
+ w.removeEventListener("devicemotion", onMotion);
344
+ clearTimeout(timer);
345
+ resolve(value);
346
+ };
347
+ const onMotion = () => finish(true);
348
+ const timer = setTimeout(() => finish(false), 100);
349
+ ctx.signal.addEventListener("abort", () => finish(false), { once: true });
350
+ w.addEventListener("devicemotion", onMotion, { once: true });
351
+ });
352
+ return compact({
353
+ device_motion: hasMotion,
354
+ device_orientation: hasOrientation,
355
+ motion_observed: observed
356
+ });
357
+ }
358
+ };
359
+ var mediaDevicesSource = {
360
+ id: SOURCE.mediaDevices,
361
+ tier: "fast",
362
+ timeoutMs: 120,
363
+ async run() {
364
+ if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
365
+ if (typeof navigator.mediaDevices?.enumerateDevices !== "function") {
366
+ throw new UnsupportedSignal("no-media-devices");
367
+ }
368
+ const devices = await navigator.mediaDevices.enumerateDevices();
369
+ return compact({
370
+ audio_input: devices.filter((d) => d.kind === "audioinput").length,
371
+ audio_output: devices.filter((d) => d.kind === "audiooutput").length,
372
+ video_input: devices.filter((d) => d.kind === "videoinput").length,
373
+ labels_hidden: devices.length > 0 && devices.every((d) => d.label === "")
374
+ });
375
+ }
376
+ };
377
+ var networkSource = {
378
+ id: SOURCE.network,
379
+ tier: "fast",
380
+ run() {
381
+ const connection = navigator.connection;
382
+ if (!connection) throw new UnsupportedSignal("no-network-information");
383
+ return compact({
384
+ effective_type: attempt(() => connection.effectiveType),
385
+ downlink: attempt(() => connection.downlink),
386
+ rtt: attempt(() => connection.rtt),
387
+ save_data: attempt(() => connection.saveData)
388
+ });
389
+ }
390
+ };
391
+ var intlSource = {
392
+ id: SOURCE.intl,
393
+ tier: "fast",
394
+ run() {
395
+ if (typeof Intl === "undefined") throw new UnsupportedSignal("no-intl");
396
+ const resolved = attempt(() => new Intl.DateTimeFormat().resolvedOptions());
397
+ return compact({
398
+ timezone: resolved?.timeZone,
399
+ // Kept alongside the zone name because resistFingerprinting reports UTC
400
+ // for both, while an ordinary browser in London reports Europe/London
401
+ // with the same zero offset in winter. The pair separates them.
402
+ timezone_offset: attempt(() => (/* @__PURE__ */ new Date()).getTimezoneOffset()),
403
+ locale: resolved?.locale,
404
+ calendar: resolved?.calendar,
405
+ numbering_system: resolved?.numberingSystem,
406
+ // A fixed instant formatted in the visitor's locale. Catches differences
407
+ // in the ICU data the browser was built with, which the locale name alone
408
+ // does not.
409
+ formatted: attempt(
410
+ () => new Intl.DateTimeFormat(void 0, {
411
+ dateStyle: "full",
412
+ timeStyle: "full"
413
+ }).format(/* @__PURE__ */ new Date(0))
414
+ )
415
+ });
416
+ }
417
+ };
418
+ var timezoneSource = {
419
+ id: SOURCE.timezone,
420
+ tier: "fast",
421
+ run() {
422
+ if (typeof Intl === "undefined") throw new UnsupportedSignal("no-intl");
423
+ return compact({
424
+ name: attempt(() => new Intl.DateTimeFormat().resolvedOptions().timeZone),
425
+ offset: attempt(() => (/* @__PURE__ */ new Date()).getTimezoneOffset())
426
+ });
427
+ }
428
+ };
429
+ var batterySource = {
430
+ id: SOURCE.battery,
431
+ tier: "deferred",
432
+ timeoutMs: 250,
433
+ async run() {
434
+ if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
435
+ const getBattery = navigator.getBattery;
436
+ if (typeof getBattery !== "function") throw new UnsupportedSignal("no-battery-api");
437
+ const battery = await getBattery.call(navigator);
438
+ const finiteOrNull = (value) => value === void 0 ? void 0 : Number.isFinite(value) ? value : null;
439
+ return compact({
440
+ charging: battery.charging,
441
+ charging_time: finiteOrNull(battery.chargingTime),
442
+ discharging_time: finiteOrNull(battery.dischargingTime),
443
+ level: battery.level
444
+ });
445
+ }
446
+ };
447
+ var speechSource = {
448
+ id: SOURCE.speech,
449
+ tier: "deferred",
450
+ timeoutMs: 250,
451
+ async run(ctx) {
452
+ if (typeof speechSynthesis === "undefined") throw new UnsupportedSignal("no-speech-synthesis");
453
+ let voices = speechSynthesis.getVoices();
454
+ if (voices.length === 0) {
455
+ voices = await new Promise((resolve) => {
456
+ const finish = () => {
457
+ speechSynthesis.removeEventListener("voiceschanged", changed);
458
+ ctx.signal.removeEventListener("abort", aborted);
459
+ resolve(speechSynthesis.getVoices());
460
+ };
461
+ const changed = () => finish();
462
+ const aborted = () => finish();
463
+ speechSynthesis.addEventListener("voiceschanged", changed, { once: true });
464
+ ctx.signal.addEventListener("abort", aborted, { once: true });
465
+ setTimeout(finish, Math.min(100, ctx.budgetRemainingMs()));
466
+ });
467
+ }
468
+ return {
469
+ voices: voices.map((voice) => ({
470
+ name: voice.name,
471
+ language: voice.lang,
472
+ local_service: voice.localService,
473
+ default: voice.default,
474
+ uri: voice.voiceURI
475
+ }))
476
+ };
477
+ }
478
+ };
479
+ var screenSource = {
480
+ id: SOURCE.screen,
481
+ tier: "fast",
482
+ run() {
483
+ const w = requireWindow();
484
+ const s = w.screen;
485
+ return compact({
486
+ width: attempt(() => s.width),
487
+ height: attempt(() => s.height),
488
+ avail_width: attempt(() => s.availWidth),
489
+ avail_height: attempt(() => s.availHeight),
490
+ color_depth: attempt(() => s.colorDepth),
491
+ pixel_depth: attempt(() => s.pixelDepth),
492
+ device_pixel_ratio: attempt(() => w.devicePixelRatio),
493
+ orientation: attempt(() => s.orientation?.type),
494
+ inner_width: attempt(() => w.innerWidth),
495
+ inner_height: attempt(() => w.innerHeight),
496
+ // Window chrome insets. Zero on every side while fullscreen, which is
497
+ // why the tuple is kept rather than reduced to a boolean - a fullscreen
498
+ // window and a chromeless one are different, and the zeroes say which.
499
+ frame: attempt(() => [
500
+ s.availTop ?? null,
501
+ (s.width ?? 0) - (s.availWidth ?? 0) - (s.availLeft ?? 0),
502
+ (s.height ?? 0) - (s.availHeight ?? 0) - (s.availTop ?? 0),
503
+ s.availLeft ?? null
504
+ ])
505
+ });
506
+ }
507
+ };
508
+ var lastUsableFrame;
509
+ function readFrame(w) {
510
+ const s = w.screen;
511
+ return [
512
+ s.availTop ?? null,
513
+ (s.width ?? 0) - (s.availWidth ?? 0) - (s.availLeft ?? 0),
514
+ (s.height ?? 0) - (s.availHeight ?? 0) - (s.availTop ?? 0),
515
+ s.availLeft ?? null
516
+ ];
517
+ }
518
+ var screenFrameSource = {
519
+ id: SOURCE.screenFrame,
520
+ tier: "fast",
521
+ run() {
522
+ const w = requireWindow();
523
+ const frame = readFrame(w);
524
+ const fullscreen = w.document?.fullscreenElement != null;
525
+ const allZero = frame.every((value) => value === 0 || value === null);
526
+ if (!fullscreen && !allZero) lastUsableFrame = frame;
527
+ return { frame: fullscreen && lastUsableFrame ? [...lastUsableFrame] : frame };
528
+ }
529
+ };
530
+ function matchRange(w, feature, max) {
531
+ if (typeof w.matchMedia !== "function") return void 0;
532
+ for (let value = 0; value <= max; value++) {
533
+ if (w.matchMedia(`(${feature}: ${value})`).matches) return value;
534
+ }
535
+ return void 0;
536
+ }
537
+ function matchFirst(w, queries) {
538
+ if (typeof w.matchMedia !== "function") return void 0;
539
+ return queries.find((query) => w.matchMedia(query).matches);
540
+ }
541
+ var mediaQueriesSource = {
542
+ id: SOURCE.mediaQueries,
543
+ tier: "fast",
544
+ run() {
545
+ const w = requireWindow();
546
+ if (typeof w.matchMedia !== "function") throw new UnsupportedSignal("no-match-media");
547
+ const gamut = matchFirst(w, [
548
+ "(color-gamut: rec2020)",
549
+ "(color-gamut: p3)",
550
+ "(color-gamut: srgb)"
551
+ ]);
552
+ const contrast = matchFirst(w, [
553
+ "(prefers-contrast: more)",
554
+ "(prefers-contrast: less)",
555
+ "(prefers-contrast: custom)",
556
+ "(prefers-contrast: no-preference)"
557
+ ]);
558
+ return compact({
559
+ color_gamut: gamut?.match(/color-gamut:\s*(\w+)/)?.[1],
560
+ inverted_colors: attempt(() => w.matchMedia("(inverted-colors: inverted)").matches),
561
+ forced_colors: attempt(() => w.matchMedia("(forced-colors: active)").matches),
562
+ monochrome: matchRange(w, "monochrome", 10),
563
+ contrast: contrast?.match(/prefers-contrast:\s*([\w-]+)/)?.[1],
564
+ reduced_motion: attempt(() => w.matchMedia("(prefers-reduced-motion: reduce)").matches),
565
+ reduced_transparency: attempt(
566
+ () => w.matchMedia("(prefers-reduced-transparency: reduce)").matches
567
+ ),
568
+ hdr: attempt(() => w.matchMedia("(dynamic-range: high)").matches)
569
+ });
570
+ }
571
+ };
572
+ var colorGamutSource = {
573
+ id: SOURCE.colorGamut,
574
+ tier: "fast",
575
+ run() {
576
+ const w = requireWindow();
577
+ if (typeof w.matchMedia !== "function") throw new UnsupportedSignal("no-match-media");
578
+ const query = matchFirst(w, [
579
+ "(color-gamut: rec2020)",
580
+ "(color-gamut: p3)",
581
+ "(color-gamut: srgb)"
582
+ ]);
583
+ const gamut = query?.match(/color-gamut:\s*(\w+)/)?.[1];
584
+ return gamut === "srgb" || gamut === "p3" || gamut === "rec2020" ? { gamut } : {};
585
+ }
586
+ };
587
+ var PAYLOAD_BYTES = 16384;
588
+ var WRITES_PER_BLOCK = 15;
589
+ var MAX_ROUNDS = 9;
590
+ var BUDGET_RESERVE_MS = 250;
591
+ var CAP_MS = 600;
592
+ function openDatabase(name) {
593
+ return new Promise((resolve, reject) => {
594
+ const request = indexedDB.open(name, 1);
595
+ request.onupgradeneeded = () => request.result.createObjectStore("s");
596
+ request.onsuccess = () => resolve(request.result);
597
+ request.onerror = () => reject(request.error ?? new Error("indexeddb-open-failed"));
598
+ request.onblocked = () => reject(new Error("indexeddb-open-blocked"));
599
+ });
600
+ }
601
+ function durabilityHonored(db) {
602
+ try {
603
+ const transaction = db.transaction("s", "readwrite", {
604
+ durability: "strict"
605
+ });
606
+ const honored = transaction.durability === "strict";
607
+ transaction.abort();
608
+ return honored;
609
+ } catch {
610
+ return false;
611
+ }
612
+ }
613
+ function timeBlock(db, durability, payload) {
614
+ return new Promise((resolve, reject) => {
615
+ const started = performance.now();
616
+ let written = 0;
617
+ const step = () => {
618
+ if (written === WRITES_PER_BLOCK) {
619
+ resolve(performance.now() - started);
620
+ return;
621
+ }
622
+ const transaction = db.transaction("s", "readwrite", {
623
+ durability
624
+ });
625
+ transaction.objectStore("s").put(payload, written);
626
+ written += 1;
627
+ transaction.oncomplete = step;
628
+ transaction.onerror = transaction.onabort = () => reject(transaction.error ?? new Error("indexeddb-write-failed"));
629
+ };
630
+ step();
631
+ });
632
+ }
633
+ var storageDurabilitySource = {
634
+ id: SOURCE.storageDurability,
635
+ tier: "deferred",
636
+ // One round may overshoot the soft deadline; the slice has to cover that.
637
+ timeoutMs: CAP_MS + 400,
638
+ async run(ctx) {
639
+ requireWindow();
640
+ if (typeof indexedDB !== "object" || indexedDB === null) {
641
+ throw new UnsupportedSignal("no-indexeddb");
642
+ }
643
+ const engine = ctx.completed(SOURCE.engine);
644
+ const observed = engine?.status === "ok" ? engine.value.observed : void 0;
645
+ if (observed !== "chromium") throw new UnsupportedSignal("not-chromium");
646
+ const name = `__fingerly_durability_${Math.random().toString(36).slice(2)}`;
647
+ const payload = new Uint8Array(PAYLOAD_BYTES);
648
+ let db;
649
+ try {
650
+ db = await openDatabase(name);
651
+ if (!durabilityHonored(db)) return { honored: false };
652
+ await timeBlock(db, "relaxed", payload);
653
+ await timeBlock(db, "strict", payload);
654
+ const started = performance.now();
655
+ const deadline = started + Math.min(CAP_MS, Math.max(0, ctx.budgetRemainingMs() - BUDGET_RESERVE_MS));
656
+ const ratios = [];
657
+ while (ratios.length < MAX_ROUNDS) {
658
+ if (ctx.signal.aborted) break;
659
+ if (ratios.length > 0) {
660
+ const perRound = (performance.now() - started) / ratios.length;
661
+ if (performance.now() + perRound > deadline) break;
662
+ }
663
+ const relaxed = await timeBlock(db, "relaxed", payload);
664
+ const strict = await timeBlock(db, "strict", payload);
665
+ if (relaxed > 0) ratios.push(strict / relaxed);
666
+ else break;
667
+ }
668
+ if (ratios.length === 0) return { honored: true, rounds: 0 };
669
+ ratios.sort((a, b) => a - b);
670
+ return compact({
671
+ ratio: ratios[ratios.length >> 1],
672
+ rounds: ratios.length,
673
+ honored: true
674
+ });
675
+ } finally {
676
+ try {
677
+ db?.close();
678
+ indexedDB.deleteDatabase(name);
679
+ } catch {
680
+ }
681
+ }
682
+ }
683
+ };
684
+ var FILTER_LISTS = [
685
+ ["easylist", ".ad_300x250", ".textads"],
686
+ ["easylist_germany", ".werbung1", ".werbeblock"],
687
+ ["easylist_italy", ".pubbl", ".banner_pubblicita"],
688
+ ["easylist_dutch", ".advertentie-container", ".reclame"],
689
+ ["easyprivacy", ".trackingpixel", "#tracking-pixel"],
690
+ ["fanboy_annoyances", "#newsletter-signup-modal", ".cookie-consent-banner"],
691
+ ["fanboy_social", ".social-share-buttons", ".facebook-like-box"],
692
+ ["adguard_base", "#adsense_widget", ".adsbygoogle-container"],
693
+ ["adguard_annoyances", ".push-notification-prompt", "#app-install-banner"],
694
+ ["listekr", "#ad_wrapper_top", ".ad_zone"],
695
+ ["liste_fr", ".pub_300x250", "#pubfooter"],
696
+ ["ro_list", ".reclama-mare", "#reclama"]
697
+ ];
698
+ var SETTLE_MS = 60;
699
+ function nextPaint() {
700
+ return new Promise((resolve) => {
701
+ let settled = false;
702
+ const done = () => {
703
+ if (!settled) {
704
+ settled = true;
705
+ resolve();
706
+ }
707
+ };
708
+ setTimeout(done, SETTLE_MS);
709
+ if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => setTimeout(done, 0));
710
+ });
711
+ }
712
+ function hidden(element) {
713
+ if (element.offsetParent === null) return true;
714
+ if (element.offsetHeight === 0 || element.offsetWidth === 0) return true;
715
+ const style = getComputedStyle(element);
716
+ return style.display === "none" || style.visibility === "hidden";
717
+ }
718
+ function probe(document2, selector) {
719
+ const element = document2.createElement("div");
720
+ if (selector.startsWith("#")) element.id = selector.slice(1);
721
+ else element.className = selector.slice(1);
722
+ element.style.position = "absolute";
723
+ element.style.top = "-9999px";
724
+ element.style.left = "-9999px";
725
+ element.style.width = "1px";
726
+ element.style.height = "1px";
727
+ return element;
728
+ }
729
+ var domBlockersSource = {
730
+ id: SOURCE.domBlockers,
731
+ // Deferred: it inserts elements, waits for a paint and reads back layout,
732
+ // which is the most intrusive thing any source here does and has no business
733
+ // competing with the fast tier for the budget.
734
+ tier: "deferred",
735
+ timeoutMs: 300,
736
+ async run() {
737
+ requireWindow();
738
+ if (typeof document === "undefined" || !document.body) {
739
+ throw new UnsupportedSignal("no-document-body");
740
+ }
741
+ const container = document.createElement("div");
742
+ container.style.position = "absolute";
743
+ container.style.top = "-9999px";
744
+ container.style.left = "-9999px";
745
+ container.style.width = "1px";
746
+ container.style.height = "1px";
747
+ const control = probe(document, ".fingerly-control-element");
748
+ container.appendChild(control);
749
+ const elements = FILTER_LISTS.map(([name, ...selectors]) => ({
750
+ name,
751
+ nodes: selectors.map((selector) => {
752
+ const element = probe(document, selector);
753
+ container.appendChild(element);
754
+ return element;
755
+ })
756
+ }));
757
+ document.body.appendChild(container);
758
+ try {
759
+ await nextPaint();
760
+ if (hidden(control)) return {};
761
+ const blocked = elements.filter(({ nodes }) => nodes.some(hidden)).map(({ name }) => name);
762
+ return compact({ blocked, probed: FILTER_LISTS.length });
763
+ } finally {
764
+ container.remove();
765
+ }
766
+ }
767
+ };
768
+ function toFixedErrorLength() {
769
+ return attempt(() => {
770
+ try {
771
+ ;
772
+ (-1).toFixed(-1);
773
+ } catch (error) {
774
+ return error instanceof Error ? error.message.length : void 0;
775
+ }
776
+ return void 0;
777
+ });
778
+ }
779
+ function evalLength() {
780
+ return attempt(() => eval.toString().length);
781
+ }
782
+ function stackStyle() {
783
+ return attempt(() => {
784
+ const stack = new Error("probe").stack;
785
+ if (typeof stack !== "string" || stack === "") return void 0;
786
+ if (stack.includes(" at ")) return "v8";
787
+ if (/^@|\n@|^\w*@/m.test(stack)) {
788
+ return stack.includes("global code") ? "javascriptcore" : "spidermonkey";
789
+ }
790
+ return "unknown";
791
+ });
792
+ }
793
+ function observedEngine(toFixed, evalLen, stack) {
794
+ const votes = [];
795
+ if (toFixed === 51) votes.push("chromium");
796
+ else if (toFixed === 43 || toFixed === 44) votes.push("webkit");
797
+ else if (toFixed === 25) votes.push("gecko");
798
+ if (evalLen === 33) votes.push("chromium");
799
+ if (stack === "v8") votes.push("chromium");
800
+ else if (stack === "javascriptcore") votes.push("webkit");
801
+ else if (stack === "spidermonkey") votes.push("gecko");
802
+ if (votes.length === 0) return void 0;
803
+ const tally = /* @__PURE__ */ new Map();
804
+ for (const vote of votes) tally.set(vote, (tally.get(vote) ?? 0) + 1);
805
+ let winner;
806
+ let best = 0;
807
+ for (const [engine, count] of tally) {
808
+ if (count > best) {
809
+ best = count;
810
+ winner = engine;
811
+ }
812
+ }
813
+ return winner;
814
+ }
815
+ function claimedEngine(userAgent) {
816
+ if (!userAgent) return void 0;
817
+ if (/Firefox\//.test(userAgent)) return "gecko";
818
+ if (/Edg\/|OPR\/|Chrome\/|Chromium\//.test(userAgent)) return "chromium";
819
+ if (/Safari\//.test(userAgent)) return "webkit";
820
+ return void 0;
821
+ }
822
+ var engineSource = {
823
+ id: SOURCE.engine,
824
+ tier: "fast",
825
+ run() {
826
+ const toFixed = toFixedErrorLength();
827
+ const evalLen = evalLength();
828
+ const stack = stackStyle();
829
+ const observed = observedEngine(toFixed, evalLen, stack);
830
+ const claimed = claimedEngine(
831
+ typeof navigator === "undefined" ? void 0 : navigator.userAgent
832
+ );
833
+ return compact({
834
+ to_fixed_error_length: toFixed,
835
+ eval_length: evalLen,
836
+ stack_style: stack,
837
+ observed,
838
+ // Compared on the server, where "we could not tell" and "they disagree"
839
+ // are kept apart by which of the two is missing.
840
+ claimed
841
+ });
842
+ }
843
+ };
844
+ var MATH_PROBES = [
845
+ ["acos", () => Math.acos(0.12312423423423424)],
846
+ ["acosh", () => Math.acosh(1e308)],
847
+ ["asin", () => Math.asin(0.12312423423423424)],
848
+ ["asinh", () => Math.asinh(1)],
849
+ ["atan", () => Math.atan(0.5)],
850
+ ["atanh", () => Math.atanh(0.5)],
851
+ ["cbrt", () => Math.cbrt(100)],
852
+ ["cos", () => Math.cos(10.000000000123)],
853
+ ["cosh", () => Math.cosh(1)],
854
+ ["exp", () => Math.exp(1)],
855
+ ["expm1", () => Math.expm1(1)],
856
+ ["log", () => Math.log(10)],
857
+ ["log1p", () => Math.log1p(10)],
858
+ ["pow", () => Math.pow(Math.PI, -100)],
859
+ ["sin", () => Math.sin(1e300)],
860
+ ["sinh", () => Math.sinh(1)],
861
+ ["sqrt", () => Math.sqrt(2)],
862
+ ["tan", () => Math.tan(-1e300)],
863
+ ["tanh", () => Math.tanh(1)]
864
+ ];
865
+ function identitiesHold() {
866
+ return Object.is(Math.sin(0), 0) && Math.cos(0) === 1 && Math.sqrt(4) === 2 && Math.log(1) === 0 && Math.pow(2, 10) === 1024;
867
+ }
868
+ var mathSource = {
869
+ id: SOURCE.math,
870
+ tier: "fast",
871
+ timeoutMs: 50,
872
+ run() {
873
+ const results = [];
874
+ let probed = 0;
875
+ const values = /* @__PURE__ */ new Map();
876
+ for (const [name, probe2] of MATH_PROBES) {
877
+ const value = attempt(probe2);
878
+ if (typeof value === "number" && Number.isFinite(value)) {
879
+ probed += 1;
880
+ values.set(name, value);
881
+ results.push(`${name}:${value}`);
882
+ } else {
883
+ results.push(`${name}:`);
884
+ }
885
+ }
886
+ return compact({
887
+ hash: hash64(results.join("|")),
888
+ probed,
889
+ // The two the engines were measured to disagree about. See MathSignal
890
+ // for the numbers; the other seventeen agreed to the last bit on the
891
+ // machine they were measured on, which is why they are only in the hash.
892
+ atanh_half: values.get("atanh"),
893
+ expm1_1: values.get("expm1"),
894
+ identities_hold: attempt(identitiesHold)
895
+ });
896
+ }
897
+ };
898
+ function thrownMessageLength(throwing) {
899
+ return attempt(() => {
900
+ try {
901
+ throwing();
902
+ } catch (error) {
903
+ if (error instanceof EvalError) return void 0;
904
+ return error instanceof Error ? error.message.length : void 0;
905
+ }
906
+ return void 0;
907
+ });
908
+ }
909
+ function evalAllowed() {
910
+ try {
911
+ new Function("");
912
+ return true;
913
+ } catch {
914
+ return false;
915
+ }
916
+ }
917
+ function observedFromErrors(errors) {
918
+ const votes = [];
919
+ const own = errors.own_properties;
920
+ if (own !== void 0) {
921
+ if (own.includes("sourceURL")) votes.push("webkit", "webkit");
922
+ else if (own.includes("lineNumber")) votes.push("gecko", "gecko");
923
+ else if (own === "message,stack") votes.push("chromium", "chromium");
924
+ }
925
+ if (errors.null_property_length === 44) votes.push("chromium");
926
+ else if (errors.null_property_length === 33) votes.push("gecko");
927
+ if (errors.syntax_length === 20) votes.push("chromium");
928
+ else if (errors.syntax_length === 28) votes.push("gecko");
929
+ if (votes.length === 0) return void 0;
930
+ const tally = /* @__PURE__ */ new Map();
931
+ for (const vote of votes) tally.set(vote, (tally.get(vote) ?? 0) + 1);
932
+ let winner;
933
+ let best = 0;
934
+ let tied = false;
935
+ for (const [engine, count] of tally) {
936
+ if (count > best) {
937
+ best = count;
938
+ winner = engine;
939
+ tied = false;
940
+ } else if (count === best) {
941
+ tied = true;
942
+ }
943
+ }
944
+ return tied ? void 0 : winner;
945
+ }
946
+ function errorOwnProperties() {
947
+ return attempt(() => {
948
+ try {
949
+ throw new Error("probe");
950
+ } catch (error) {
951
+ return Object.getOwnPropertyNames(error).sort().join(",");
952
+ }
953
+ });
954
+ }
955
+ var errorsSource = {
956
+ id: SOURCE.errors,
957
+ tier: "fast",
958
+ timeoutMs: 50,
959
+ run() {
960
+ const compiles = evalAllowed();
961
+ const shapes = compact({
962
+ null_property_length: thrownMessageLength(() => null.x),
963
+ // `new Function` rather than `eval`, because a page with a strict
964
+ // Content-Security-Policy blocks both and this way the failure is one
965
+ // probe reporting nothing rather than the source throwing.
966
+ syntax_length: compiles ? thrownMessageLength(() => new Function("!")) : void 0,
967
+ json_parse_length: thrownMessageLength(() => JSON.parse("{")),
968
+ invalid_array_length: thrownMessageLength(() => {
969
+ const array = [];
970
+ array.length = -1;
971
+ }),
972
+ const_assign_length: compiles ? thrownMessageLength(() => {
973
+ new Function("const c = 1; c = 2")();
974
+ }) : void 0,
975
+ own_properties: errorOwnProperties(),
976
+ capture_stack_trace: attempt(
977
+ () => typeof Error.captureStackTrace === "function"
978
+ ),
979
+ stack_trace_limit: attempt(() => "stackTraceLimit" in Error)
980
+ });
981
+ return compact({ ...shapes, observed: observedFromErrors(shapes) });
982
+ }
983
+ };
984
+ var navigatorSource = {
985
+ id: SOURCE.navigator,
986
+ tier: "fast",
987
+ run() {
988
+ if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
989
+ const nav = navigator;
990
+ return compact({
991
+ user_agent: attempt(() => nav.userAgent),
992
+ platform: attempt(() => nav.platform),
993
+ vendor: attempt(() => nav.vendor),
994
+ product_sub: attempt(() => nav.productSub),
995
+ app_version: attempt(() => nav.appVersion),
996
+ hardware_concurrency: attempt(() => nav.hardwareConcurrency),
997
+ device_memory: attempt(() => nav.deviceMemory),
998
+ max_touch_points: attempt(() => nav.maxTouchPoints),
999
+ webdriver: attempt(() => nav.webdriver),
1000
+ cookie_enabled: attempt(() => nav.cookieEnabled),
1001
+ pdf_viewer_enabled: attempt(() => nav.pdfViewerEnabled),
1002
+ do_not_track: attempt(() => nav.doNotTrack),
1003
+ // The count rather than the list. The names are long, largely constant,
1004
+ // and the only thing any detector reads is whether there are none - a
1005
+ // desktop Chromium with zero plugins has no built-in PDF viewer, which
1006
+ // means it was built headless.
1007
+ plugin_count: attempt(() => nav.plugins?.length),
1008
+ mime_type_count: attempt(() => nav.mimeTypes?.length),
1009
+ language: attempt(() => nav.language),
1010
+ languages: attempt(() => nav.languages ? [...nav.languages] : void 0)
1011
+ });
1012
+ }
1013
+ };
1014
+ var languagesSource = {
1015
+ id: SOURCE.languages,
1016
+ tier: "fast",
1017
+ run() {
1018
+ if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
1019
+ return compact({
1020
+ primary: attempt(() => navigator.language),
1021
+ accepted: attempt(() => navigator.languages ? [...navigator.languages] : void 0)
1022
+ });
1023
+ }
1024
+ };
1025
+ var vendorSource = {
1026
+ id: SOURCE.vendor,
1027
+ tier: "fast",
1028
+ run() {
1029
+ if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
1030
+ return compact({ vendor: attempt(() => navigator.vendor) });
1031
+ }
1032
+ };
1033
+ var pluginsSource = {
1034
+ id: SOURCE.plugins,
1035
+ tier: "fast",
1036
+ run() {
1037
+ if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
1038
+ const plugins = navigator.plugins;
1039
+ if (!plugins) throw new UnsupportedSignal("no-plugins");
1040
+ return {
1041
+ plugins: Array.from(plugins, (plugin) => ({
1042
+ name: plugin.name,
1043
+ filename: plugin.filename,
1044
+ description: plugin.description,
1045
+ mime_types: Array.from(plugin, (mime) => ({
1046
+ type: mime.type,
1047
+ suffixes: mime.suffixes,
1048
+ description: mime.description
1049
+ }))
1050
+ }))
1051
+ };
1052
+ }
1053
+ };
1054
+ var userAgentDataSource = {
1055
+ id: SOURCE.userAgentData,
1056
+ tier: "deferred",
1057
+ timeoutMs: 200,
1058
+ async run() {
1059
+ if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
1060
+ const data = navigator.userAgentData;
1061
+ if (!data) throw new UnsupportedSignal("no-user-agent-data");
1062
+ const low = compact({
1063
+ brands: data.brands,
1064
+ mobile: data.mobile,
1065
+ platform: data.platform
1066
+ });
1067
+ if (typeof data.getHighEntropyValues !== "function") return low;
1068
+ const high = await data.getHighEntropyValues([
1069
+ "architecture",
1070
+ "bitness",
1071
+ "model",
1072
+ "platformVersion",
1073
+ // Not uaFullVersion: deprecated in the client hints spec, and
1074
+ // fullVersionList already carries the same version per brand.
1075
+ "fullVersionList",
1076
+ "wow64"
1077
+ ]);
1078
+ return { ...low, ...high };
1079
+ }
1080
+ };
1081
+ function makeCanvas(width, height) {
1082
+ const canvas = document.createElement("canvas");
1083
+ canvas.width = width;
1084
+ canvas.height = height;
1085
+ const context = canvas.getContext("2d");
1086
+ if (!context) throw new UnsupportedSignal("no-2d-context");
1087
+ return [canvas, context];
1088
+ }
1089
+ function renderGeometry() {
1090
+ const [canvas, ctx] = makeCanvas(240, 60);
1091
+ ctx.globalCompositeOperation = "multiply";
1092
+ for (const [colour, x, y] of [
1093
+ ["#f2f", 40, 40],
1094
+ ["#2ff", 80, 40],
1095
+ ["#ff2", 60, 80]
1096
+ ]) {
1097
+ ctx.fillStyle = colour;
1098
+ ctx.beginPath();
1099
+ ctx.arc(x, y, 40, 0, Math.PI * 2, true);
1100
+ ctx.closePath();
1101
+ ctx.fill();
1102
+ }
1103
+ ctx.fillStyle = "#f9c";
1104
+ ctx.arc(100, 50, 50, 0, Math.PI * 2, true);
1105
+ ctx.arc(100, 50, 20, 0, Math.PI * 2, true);
1106
+ ctx.fill("evenodd");
1107
+ return canvas.toDataURL();
1108
+ }
1109
+ function renderText() {
1110
+ const [canvas, ctx] = makeCanvas(300, 60);
1111
+ ctx.textBaseline = "alphabetic";
1112
+ ctx.fillStyle = "#f60";
1113
+ ctx.fillRect(100, 1, 62, 20);
1114
+ ctx.fillStyle = "#069";
1115
+ ctx.font = '11pt "Times New Roman"';
1116
+ ctx.fillText("Fingerly <canvas> 1.0 \u{1F512}\u0416\u4E2D", 2, 15);
1117
+ ctx.font = "18pt Arial";
1118
+ ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
1119
+ ctx.fillText("Fingerly <canvas> 1.0", 4, 45);
1120
+ return canvas.toDataURL();
1121
+ }
1122
+ function supportsWinding() {
1123
+ const [, ctx] = makeCanvas(1, 1);
1124
+ ctx.rect(0, 0, 10, 10);
1125
+ ctx.rect(2, 2, 6, 6);
1126
+ return ctx.isPointInPath(5, 5, "evenodd") === false;
1127
+ }
1128
+ function resistFingerprintingActive(ctx) {
1129
+ const timing = ctx.completed(SOURCE.timing);
1130
+ if (timing?.status !== "ok") return false;
1131
+ const resolution = timing.value?.now_resolution;
1132
+ return typeof resolution === "number" && resolution >= 16;
1133
+ }
1134
+ var canvasSource = {
1135
+ id: SOURCE.canvas,
1136
+ tier: "deferred",
1137
+ timeoutMs: 400,
1138
+ run(ctx) {
1139
+ requireWindow();
1140
+ if (typeof document === "undefined") throw new UnsupportedSignal("no-document");
1141
+ if (resistFingerprintingActive(ctx)) {
1142
+ throw new BlockedSignal("rfp-canvas-prompt-avoided");
1143
+ }
1144
+ try {
1145
+ const geometryFirst = renderGeometry();
1146
+ const geometrySecond = renderGeometry();
1147
+ const textFirst = renderText();
1148
+ const textSecond = renderText();
1149
+ const unstable = geometryFirst !== geometrySecond || textFirst !== textSecond;
1150
+ return compact({
1151
+ geometry: hash64(geometryFirst),
1152
+ text: hash64(textFirst),
1153
+ winding: attempt(supportsWinding),
1154
+ unstable
1155
+ });
1156
+ } catch (error) {
1157
+ asBlockedIfRefused(error);
1158
+ }
1159
+ }
1160
+ };
1161
+ function webglContext() {
1162
+ if (typeof document === "undefined") throw new UnsupportedSignal("no-document");
1163
+ const canvas = document.createElement("canvas");
1164
+ const gl = canvas.getContext("webgl") ?? canvas.getContext("experimental-webgl");
1165
+ if (!gl) throw new UnsupportedSignal("no-webgl-context");
1166
+ return gl;
1167
+ }
1168
+ var webglSource = {
1169
+ id: SOURCE.webgl,
1170
+ // Renderer and GPU strings are hard identity components, and context setup
1171
+ // is synchronous; keep them in the authoritative initial report.
1172
+ tier: "fast",
1173
+ timeoutMs: 400,
1174
+ run() {
1175
+ const gl = webglContext();
1176
+ const debug = attempt(() => gl.getExtension("WEBGL_debug_renderer_info"));
1177
+ const parameters = {};
1178
+ for (const name of [
1179
+ "MAX_TEXTURE_SIZE",
1180
+ "MAX_VIEWPORT_DIMS",
1181
+ "MAX_VERTEX_ATTRIBS",
1182
+ "MAX_VARYING_VECTORS",
1183
+ "MAX_COMBINED_TEXTURE_IMAGE_UNITS",
1184
+ "MAX_CUBE_MAP_TEXTURE_SIZE",
1185
+ "MAX_FRAGMENT_UNIFORM_VECTORS",
1186
+ "MAX_RENDERBUFFER_SIZE",
1187
+ "MAX_TEXTURE_IMAGE_UNITS",
1188
+ "MAX_VERTEX_TEXTURE_IMAGE_UNITS",
1189
+ "MAX_VERTEX_UNIFORM_VECTORS",
1190
+ "ALIASED_LINE_WIDTH_RANGE",
1191
+ "ALIASED_POINT_SIZE_RANGE",
1192
+ "RED_BITS",
1193
+ "GREEN_BITS",
1194
+ "BLUE_BITS",
1195
+ "ALPHA_BITS",
1196
+ "DEPTH_BITS",
1197
+ "STENCIL_BITS"
1198
+ ]) {
1199
+ const constant = gl[name];
1200
+ if (typeof constant !== "number") continue;
1201
+ const value = attempt(() => gl.getParameter(constant));
1202
+ if (value !== void 0 && value !== null) {
1203
+ parameters[name] = ArrayBuffer.isView(value) ? Array.from(value) : value;
1204
+ }
1205
+ }
1206
+ const precisions = [];
1207
+ for (const shader of [gl.VERTEX_SHADER, gl.FRAGMENT_SHADER]) {
1208
+ for (const precision of [gl.LOW_FLOAT, gl.MEDIUM_FLOAT, gl.HIGH_FLOAT]) {
1209
+ const format = attempt(() => gl.getShaderPrecisionFormat(shader, precision));
1210
+ if (format) precisions.push(format.rangeMin, format.rangeMax, format.precision);
1211
+ }
1212
+ }
1213
+ return compact({
1214
+ vendor: attempt(() => gl.getParameter(gl.VENDOR)),
1215
+ renderer: attempt(() => gl.getParameter(gl.RENDERER)),
1216
+ unmasked_vendor: debug ? attempt(() => gl.getParameter(debug.UNMASKED_VENDOR_WEBGL)) : void 0,
1217
+ unmasked_renderer: debug ? attempt(() => gl.getParameter(debug.UNMASKED_RENDERER_WEBGL)) : void 0,
1218
+ version: attempt(() => gl.getParameter(gl.VERSION)),
1219
+ shading_language_version: attempt(
1220
+ () => gl.getParameter(gl.SHADING_LANGUAGE_VERSION)
1221
+ ),
1222
+ max_texture_size: attempt(() => gl.getParameter(gl.MAX_TEXTURE_SIZE)),
1223
+ max_render_buffer_size: attempt(() => gl.getParameter(gl.MAX_RENDERBUFFER_SIZE)),
1224
+ // Hashed rather than sent whole: twenty parameters is a kilobyte of JSON
1225
+ // that no detector reads field by field, and the report has a budget.
1226
+ parameters_hash: Object.keys(parameters).length > 0 ? hash64(JSON.stringify(parameters)) : void 0,
1227
+ shader_precision_hash: precisions.length > 0 ? hash64(precisions.join(",")) : void 0
1228
+ });
1229
+ }
1230
+ };
1231
+ var webglExtensionsSource = {
1232
+ id: SOURCE.webglExtensions,
1233
+ tier: "deferred",
1234
+ timeoutMs: 200,
1235
+ run() {
1236
+ const gl = webglContext();
1237
+ const extensions = gl.getSupportedExtensions();
1238
+ if (!extensions) throw new BlockedSignal("extensions-withheld");
1239
+ return [...extensions].sort();
1240
+ }
1241
+ };
1242
+ function clockResolution(now) {
1243
+ const deltas = [];
1244
+ const deadline = Date.now() + 12;
1245
+ while (deltas.length < 25 && Date.now() < deadline) {
1246
+ const start = now();
1247
+ let end = now();
1248
+ let guard = 0;
1249
+ while (end === start && guard++ < 1e5 && Date.now() < deadline) end = now();
1250
+ if (end !== start) deltas.push(end - start);
1251
+ }
1252
+ if (deltas.length === 0) {
1253
+ return 100;
1254
+ }
1255
+ return Math.round(Math.min(...deltas) * 1e6) / 1e6;
1256
+ }
1257
+ var timingSource = {
1258
+ id: SOURCE.timing,
1259
+ tier: "fast",
1260
+ timeoutMs: 150,
1261
+ run() {
1262
+ const w = requireWindow();
1263
+ const perf = w.performance;
1264
+ if (typeof perf?.now !== "function") {
1265
+ return compact({ has_performance: false });
1266
+ }
1267
+ return compact({
1268
+ has_performance: true,
1269
+ now_resolution: clockResolution(() => perf.now())
1270
+ });
1271
+ }
1272
+ };
1273
+ var permissionStatuses = /* @__PURE__ */ new WeakMap();
1274
+ function permissionStatus(w, name) {
1275
+ let byName = permissionStatuses.get(w.navigator);
1276
+ if (!byName) {
1277
+ byName = /* @__PURE__ */ new Map();
1278
+ permissionStatuses.set(w.navigator, byName);
1279
+ }
1280
+ let status = byName.get(name);
1281
+ if (!status) {
1282
+ status = w.navigator.permissions.query({ name });
1283
+ byName.set(name, status);
1284
+ }
1285
+ return status;
1286
+ }
1287
+ var permissionsSource = {
1288
+ id: SOURCE.permissions,
1289
+ tier: "fast",
1290
+ timeoutMs: 200,
1291
+ async run() {
1292
+ const w = requireWindow();
1293
+ if (!w.navigator.permissions?.query) throw new UnsupportedSignal("no-permissions-api");
1294
+ const query = async (name) => {
1295
+ try {
1296
+ return (await permissionStatus(w, name)).state;
1297
+ } catch {
1298
+ return void 0;
1299
+ }
1300
+ };
1301
+ const notification = await query("notifications");
1302
+ const legacy = attempt(() => w.Notification?.permission);
1303
+ return compact({
1304
+ notification,
1305
+ notification_legacy: legacy,
1306
+ geolocation: await query("geolocation")
1307
+ });
1308
+ }
1309
+ };
1310
+ var AUTOMATION_GLOBALS = [
1311
+ "__nightmare",
1312
+ "_phantom",
1313
+ "callPhantom",
1314
+ "__phantomas",
1315
+ "Buffer",
1316
+ "emit",
1317
+ "spawn",
1318
+ "__selenium_evaluate",
1319
+ "__selenium_unwrapped",
1320
+ "__webdriver_evaluate",
1321
+ "__webdriver_script_fn",
1322
+ "__webdriver_script_func",
1323
+ "__webdriver_unwrapped",
1324
+ "__fxdriver_evaluate",
1325
+ "__fxdriver_unwrapped",
1326
+ "__driver_evaluate",
1327
+ "__driver_unwrapped",
1328
+ "_Selenium_IDE_Recorder",
1329
+ "domAutomation",
1330
+ "domAutomationController",
1331
+ "__lastWatirAlert",
1332
+ "__playwright",
1333
+ "__puppeteer",
1334
+ "__pw_manual"
1335
+ ];
1336
+ var automationSource = {
1337
+ id: SOURCE.automation,
1338
+ tier: "fast",
1339
+ run() {
1340
+ const w = requireWindow();
1341
+ const present = AUTOMATION_GLOBALS.filter((name) => attempt(() => name in w) === true);
1342
+ const cdp = attempt(
1343
+ () => Object.getOwnPropertyNames(w).filter((name) => /^cdc_|^\$cdc_/.test(name))
1344
+ );
1345
+ return compact({
1346
+ webdriver: attempt(() => navigator.webdriver),
1347
+ cdp_artifacts: cdp && cdp.length > 0 ? cdp : void 0,
1348
+ distinctive_properties: present.length > 0 ? [...present] : void 0,
1349
+ chrome_object: attempt(() => "chrome" in w),
1350
+ window_external: attempt(() => {
1351
+ const external = w.external;
1352
+ return external ? String(external) : void 0;
1353
+ })
1354
+ });
1355
+ }
1356
+ };
1357
+ var VENDOR_API_MS = 50;
1358
+ var TIMED_OUT = /* @__PURE__ */ Symbol("timed-out");
1359
+ async function askBrave(nav) {
1360
+ if (typeof nav.brave?.isBrave !== "function") return void 0;
1361
+ try {
1362
+ const answer = await Promise.race([
1363
+ nav.brave.isBrave(),
1364
+ new Promise((resolve) => setTimeout(() => resolve(TIMED_OUT), VENDOR_API_MS))
1365
+ ]);
1366
+ return answer === TIMED_OUT ? void 0 : answer === true;
1367
+ } catch {
1368
+ return void 0;
1369
+ }
1370
+ }
1371
+ function claimsBrave(nav) {
1372
+ const brands = nav.userAgentData?.brands;
1373
+ if (!Array.isArray(brands)) return void 0;
1374
+ return brands.some((entry) => entry?.brand === "Brave");
1375
+ }
1376
+ var CANARY_COLOURS = [
1377
+ [30, 60, 90],
1378
+ [210, 180, 140]
1379
+ ];
1380
+ var CANARY_SIZE = 8;
1381
+ function canvasNoise() {
1382
+ if (typeof document === "undefined") return void 0;
1383
+ try {
1384
+ const canvas = document.createElement("canvas");
1385
+ canvas.width = CANARY_SIZE;
1386
+ canvas.height = CANARY_SIZE;
1387
+ const context = canvas.getContext("2d", { willReadFrequently: true });
1388
+ if (!context) return void 0;
1389
+ for (let y = 0; y < CANARY_SIZE; y++) {
1390
+ for (let x = 0; x < CANARY_SIZE; x++) {
1391
+ const [r, g, b] = CANARY_COLOURS[(x + y) % 2];
1392
+ context.fillStyle = `rgb(${r}, ${g}, ${b})`;
1393
+ context.fillRect(x, y, 1, 1);
1394
+ }
1395
+ }
1396
+ const pixels = context.getImageData(0, 0, CANARY_SIZE, CANARY_SIZE).data;
1397
+ for (let index = 0; index < CANARY_SIZE * CANARY_SIZE; index++) {
1398
+ const x = index % CANARY_SIZE;
1399
+ const y = Math.floor(index / CANARY_SIZE);
1400
+ const [r, g, b] = CANARY_COLOURS[(x + y) % 2];
1401
+ const at = index * 4;
1402
+ if (pixels[at] !== r || pixels[at + 1] !== g || pixels[at + 2] !== b || pixels[at + 3] !== 255) {
1403
+ return true;
1404
+ }
1405
+ }
1406
+ return false;
1407
+ } catch {
1408
+ return void 0;
1409
+ }
1410
+ }
1411
+ var shieldsSource = {
1412
+ id: SOURCE.shields,
1413
+ tier: "fast",
1414
+ timeoutMs: 100,
1415
+ async run() {
1416
+ if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
1417
+ const nav = navigator;
1418
+ return compact({
1419
+ brave: await askBrave(nav),
1420
+ brave_claimed: claimsBrave(nav),
1421
+ canvas_noise: canvasNoise()
1422
+ });
1423
+ }
1424
+ };
1425
+ function storageWorks(area) {
1426
+ try {
1427
+ const store = window[area];
1428
+ if (!store) return false;
1429
+ const key = "__fingerly_probe__";
1430
+ store.setItem(key, "1");
1431
+ store.removeItem(key);
1432
+ return true;
1433
+ } catch {
1434
+ return false;
1435
+ }
1436
+ }
1437
+ function indexedDbWorks() {
1438
+ try {
1439
+ return typeof window.indexedDB === "object" && window.indexedDB !== null;
1440
+ } catch {
1441
+ return false;
1442
+ }
1443
+ }
1444
+ function classifyFilesystemRefusal(error) {
1445
+ const name = error instanceof Error ? error.name : "";
1446
+ const message = error instanceof Error ? error.message : String(error);
1447
+ if (message.includes("unknown transient reason")) return "transient";
1448
+ if (name === "SecurityError" || message.includes("Security error")) return "refused";
1449
+ return "failed";
1450
+ }
1451
+ var FILESYSTEM_PROBE_MS = 200;
1452
+ async function originFilesystem() {
1453
+ const storage = navigator.storage;
1454
+ if (typeof storage?.getDirectory !== "function") return void 0;
1455
+ return Promise.race([
1456
+ storage.getDirectory().then(
1457
+ () => "ok",
1458
+ (error) => classifyFilesystemRefusal(error)
1459
+ ),
1460
+ new Promise((resolve) => setTimeout(resolve, FILESYSTEM_PROBE_MS))
1461
+ ]);
1462
+ }
1463
+ var LEGACY_QUOTA_PROBE_MS = 150;
1464
+ function legacyQuota() {
1465
+ const storage = navigator.webkitTemporaryStorage;
1466
+ if (typeof storage?.queryUsageAndQuota !== "function") return Promise.resolve(void 0);
1467
+ return new Promise((resolve) => {
1468
+ let settled = false;
1469
+ const settle = (value) => {
1470
+ if (settled) return;
1471
+ settled = true;
1472
+ resolve(value);
1473
+ };
1474
+ setTimeout(() => settle(void 0), LEGACY_QUOTA_PROBE_MS);
1475
+ try {
1476
+ storage.queryUsageAndQuota(
1477
+ (_usage, quota) => settle(typeof quota === "number" ? quota : void 0),
1478
+ () => settle(void 0)
1479
+ );
1480
+ } catch {
1481
+ settle(void 0);
1482
+ }
1483
+ });
1484
+ }
1485
+ function serviceWorkerAvailable() {
1486
+ if (!window.isSecureContext) return void 0;
1487
+ return "serviceWorker" in navigator;
1488
+ }
1489
+ var storageSource = {
1490
+ id: SOURCE.storage,
1491
+ tier: "fast",
1492
+ timeoutMs: 250,
1493
+ async run() {
1494
+ requireWindow();
1495
+ const estimated = attempt(async () => {
1496
+ if (typeof navigator.storage?.estimate !== "function") return void 0;
1497
+ const estimate2 = await navigator.storage.estimate();
1498
+ return { quota: estimate2.quota, usage: estimate2.usage };
1499
+ });
1500
+ const legacy = legacyQuota();
1501
+ const filesystem = originFilesystem();
1502
+ const [estimate, legacyValue, originFilesystemValue] = await Promise.all([
1503
+ estimated,
1504
+ legacy,
1505
+ filesystem
1506
+ ]);
1507
+ const quota = estimate?.quota;
1508
+ const deviceMemory = navigator.deviceMemory;
1509
+ return compact({
1510
+ local_storage: storageWorks("localStorage"),
1511
+ session_storage: storageWorks("sessionStorage"),
1512
+ indexed_db: indexedDbWorks(),
1513
+ quota,
1514
+ usage: estimate?.usage,
1515
+ legacy_quota: legacyValue,
1516
+ // Chromium's incognito quota is derived from device memory on recent
1517
+ // builds rather than being a fixed number, so the ratio is the form of
1518
+ // the test that survives the next change to it. Reported alongside the
1519
+ // absolute value rather than instead, because older builds need the
1520
+ // absolute one.
1521
+ //
1522
+ // Both inputs are farbled on Brave, which is why the detector recomputes
1523
+ // this from the quota and the memory reading it decided to trust rather
1524
+ // than taking it. Kept because reports stored by shipped SDKs carry it
1525
+ // and the server's copy of the rules still has to read them.
1526
+ quota_ratio: typeof quota === "number" && typeof deviceMemory === "number" && deviceMemory > 0 ? quota / (deviceMemory * 1024 * 1024 * 1024) : void 0,
1527
+ origin_filesystem: originFilesystemValue,
1528
+ service_worker: serviceWorkerAvailable()
1529
+ });
1530
+ }
1531
+ };
1532
+ var storageQuotaSource = {
1533
+ id: SOURCE.storageQuota,
1534
+ tier: "fast",
1535
+ run() {
1536
+ requireWindow();
1537
+ if (typeof document === "undefined") throw new UnsupportedSignal("no-document");
1538
+ return { partitioned: typeof document.hasStorageAccess === "function" };
1539
+ }
1540
+ };
1541
+ var BASE_FONTS = ["monospace", "sans-serif", "serif"];
1542
+ var TEST_SIZE = "72px";
1543
+ var TEST_STRING = "mmmmmmmmmmlli WwMmIi 0123";
1544
+ var CANDIDATES = [
1545
+ // Windows
1546
+ "Arial",
1547
+ "Arial Black",
1548
+ "Calibri",
1549
+ "Cambria",
1550
+ "Candara",
1551
+ "Comic Sans MS",
1552
+ "Consolas",
1553
+ "Constantia",
1554
+ "Corbel",
1555
+ "Courier New",
1556
+ "Ebrima",
1557
+ "Franklin Gothic",
1558
+ "Gabriola",
1559
+ "Georgia",
1560
+ "Impact",
1561
+ "Lucida Console",
1562
+ "Lucida Sans Unicode",
1563
+ "Malgun Gothic",
1564
+ "Marlett",
1565
+ "Microsoft Himalaya",
1566
+ "MS Gothic",
1567
+ "MV Boli",
1568
+ "Nirmala UI",
1569
+ "Palatino Linotype",
1570
+ "Segoe UI",
1571
+ "Segoe UI Emoji",
1572
+ "Sylfaen",
1573
+ "Tahoma",
1574
+ "Times New Roman",
1575
+ "Trebuchet MS",
1576
+ "Verdana",
1577
+ "Webdings",
1578
+ "Wingdings",
1579
+ // macOS / iOS
1580
+ "American Typewriter",
1581
+ "Andale Mono",
1582
+ "Apple Chancery",
1583
+ "Arial Hebrew",
1584
+ "Avenir",
1585
+ "Avenir Next",
1586
+ "Baskerville",
1587
+ "Big Caslon",
1588
+ "Bodoni 72",
1589
+ "Chalkboard",
1590
+ "Cochin",
1591
+ "Copperplate",
1592
+ "Didot",
1593
+ "Futura",
1594
+ "Geneva",
1595
+ "Gill Sans",
1596
+ "Helvetica",
1597
+ "Helvetica Neue",
1598
+ "Herculanum",
1599
+ "Hoefler Text",
1600
+ "Lucida Grande",
1601
+ "Luminari",
1602
+ "Menlo",
1603
+ "Monaco",
1604
+ "Optima",
1605
+ "Papyrus",
1606
+ "Phosphate",
1607
+ "Rockwell",
1608
+ "SF Pro",
1609
+ "Skia",
1610
+ "Snell Roundhand",
1611
+ "Trattatello",
1612
+ "Zapfino",
1613
+ // Linux
1614
+ "Cantarell",
1615
+ "DejaVu Sans",
1616
+ "DejaVu Serif",
1617
+ "FreeSans",
1618
+ "Liberation Sans",
1619
+ "Liberation Serif",
1620
+ "Nimbus Sans",
1621
+ "Noto Sans",
1622
+ "Ubuntu",
1623
+ "Ubuntu Mono",
1624
+ // Android
1625
+ "Droid Sans",
1626
+ "Roboto",
1627
+ "Roboto Condensed",
1628
+ // Bundled with common applications - each one names an installed product
1629
+ "Bahnschrift",
1630
+ "Bookshelf Symbol 7",
1631
+ "Cascadia Code",
1632
+ "Fira Code",
1633
+ "HoloLens MDL2 Assets",
1634
+ "Inter",
1635
+ "JetBrains Mono",
1636
+ "MT Extra",
1637
+ "Source Code Pro",
1638
+ "Wingdings 2",
1639
+ "Wingdings 3"
1640
+ ];
1641
+ var fontsSource = {
1642
+ id: SOURCE.fonts,
1643
+ tier: "deferred",
1644
+ // Generous: this measures ~300 spans, and forcing layout on a busy page is
1645
+ // genuinely slow. Still bounded, which is the part that matters.
1646
+ timeoutMs: 700,
1647
+ run() {
1648
+ if (typeof document === "undefined") throw new UnsupportedSignal("no-document");
1649
+ const holder = document.createElement("div");
1650
+ holder.style.cssText = "position:absolute;left:-9999px;top:-9999px;visibility:hidden;width:auto;height:auto;margin:0;padding:0;white-space:nowrap;";
1651
+ const span = (fontFamily) => {
1652
+ const element = document.createElement("span");
1653
+ element.style.cssText = `position:absolute;font-size:${TEST_SIZE};margin:0;padding:0;font-family:${fontFamily};`;
1654
+ element.textContent = TEST_STRING;
1655
+ holder.appendChild(element);
1656
+ return element;
1657
+ };
1658
+ const baseSpans = BASE_FONTS.map((base) => span(base));
1659
+ const candidateSpans = CANDIDATES.map(
1660
+ (candidate) => BASE_FONTS.map((base) => span(`'${candidate}',${base}`))
1661
+ );
1662
+ document.body.appendChild(holder);
1663
+ try {
1664
+ const baseWidths = baseSpans.map((element) => element.offsetWidth);
1665
+ const baseHeights = baseSpans.map((element) => element.offsetHeight);
1666
+ const available = [];
1667
+ CANDIDATES.forEach((candidate, index) => {
1668
+ const spans = candidateSpans[index];
1669
+ if (!spans) return;
1670
+ const differs = spans.every((element, baseIndex) => {
1671
+ const width = baseWidths[baseIndex];
1672
+ const height = baseHeights[baseIndex];
1673
+ return element.offsetWidth !== width || element.offsetHeight !== height;
1674
+ });
1675
+ if (differs) available.push(candidate);
1676
+ });
1677
+ return compact({
1678
+ available,
1679
+ // The denominator, so a consumer reads a ratio rather than a count -
1680
+ // and so that adding a candidate later does not silently change what
1681
+ // "12 fonts" meant in a stored report.
1682
+ probed: CANDIDATES.length
1683
+ });
1684
+ } finally {
1685
+ holder.remove();
1686
+ }
1687
+ }
1688
+ };
1689
+ var fontPreferencesSource = {
1690
+ id: SOURCE.fontPreferences,
1691
+ tier: "deferred",
1692
+ timeoutMs: 250,
1693
+ run() {
1694
+ if (typeof document === "undefined" || !document.body) {
1695
+ throw new UnsupportedSignal("no-document-body");
1696
+ }
1697
+ const frame = document.createElement("iframe");
1698
+ frame.setAttribute("aria-hidden", "true");
1699
+ frame.style.cssText = "position:absolute;left:-9999px;width:1px;height:1px;border:0";
1700
+ document.body.appendChild(frame);
1701
+ try {
1702
+ const doc = frame.contentDocument;
1703
+ if (!doc?.body) throw new UnsupportedSignal("no-frame-document");
1704
+ const text = "mmMwWLliI0O&1";
1705
+ const families = {
1706
+ default: "",
1707
+ serif: "serif",
1708
+ sans: "sans-serif",
1709
+ mono: "monospace",
1710
+ system: "system-ui",
1711
+ apple: "-apple-system",
1712
+ min: "Arial, sans-serif"
1713
+ };
1714
+ const widths = {};
1715
+ for (const [name, family] of Object.entries(families)) {
1716
+ const span = doc.createElement("span");
1717
+ span.textContent = text;
1718
+ span.style.cssText = `font:72px ${family || "initial"};white-space:nowrap;position:absolute`;
1719
+ doc.body.appendChild(span);
1720
+ widths[name] = Math.round(span.getBoundingClientRect().width * 1e3) / 1e3;
1721
+ }
1722
+ return { widths };
1723
+ } finally {
1724
+ frame.remove();
1725
+ }
1726
+ }
1727
+ };
1728
+
1729
+ // src/sources/index.ts
1730
+ var browserSources = [
1731
+ // fast
1732
+ engineSource,
1733
+ errorsSource,
1734
+ mathSource,
1735
+ navigatorSource,
1736
+ languagesSource,
1737
+ pluginsSource,
1738
+ vendorSource,
1739
+ screenSource,
1740
+ screenFrameSource,
1741
+ mediaQueriesSource,
1742
+ colorGamutSource,
1743
+ hardwareSource,
1744
+ touchSource,
1745
+ networkSource,
1746
+ intlSource,
1747
+ timezoneSource,
1748
+ storageSource,
1749
+ storageQuotaSource,
1750
+ shieldsSource,
1751
+ timingSource,
1752
+ permissionsSource,
1753
+ automationSource,
1754
+ webglSource,
1755
+ mediaDevicesSource,
1756
+ // deferred
1757
+ canvasSource,
1758
+ webglExtensionsSource,
1759
+ audioSource,
1760
+ audioLatencySource,
1761
+ fontsSource,
1762
+ fontPreferencesSource,
1763
+ batterySource,
1764
+ speechSource,
1765
+ sensorsSource,
1766
+ userAgentDataSource,
1767
+ domBlockersSource,
1768
+ storageDurabilitySource
1769
+ ];
1770
+ function load(options) {
1771
+ return new Promise(
1772
+ (resolve) => resolve(
1773
+ new FingerlyClient({
1774
+ ...options,
1775
+ platform: "web",
1776
+ sources: options.sources ?? browserSources,
1777
+ integrity: (report) => inspectIntegrity(report.sources)
1778
+ })
1779
+ )
1780
+ );
1781
+ }
1782
+
1783
+ export { browserSources, inspectIntegrity, load };