@fingerly/web-js 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +320 -51
- package/dist/browser.global.js +48 -1
- package/dist/index.cjs +1273 -622
- package/dist/index.d.cts +57 -53
- package/dist/index.d.ts +57 -53
- package/dist/index.js +1274 -624
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,61 @@
|
|
|
1
|
-
import { SOURCE,
|
|
1
|
+
import { SOURCE, UnsupportedSignal, TimedOutSignal, BlockedSignal, hash64, own, EMBEDDED_SAFE_SOURCES, valueOf, FingerlyClient } from '@fingerly/core';
|
|
2
2
|
export { ConsentError, FingerlyClient, SOURCE, TransportError, isSuspiciousLevel } from '@fingerly/core';
|
|
3
3
|
|
|
4
4
|
// src/index.ts
|
|
5
|
+
|
|
6
|
+
// src/embedding.ts
|
|
7
|
+
var THIRD_PARTY_IN_APP_BROWSERS = [
|
|
8
|
+
"fban/",
|
|
9
|
+
"fbav/",
|
|
10
|
+
"fb_iab",
|
|
11
|
+
"instagram",
|
|
12
|
+
"musical_ly",
|
|
13
|
+
"bytedancewebview",
|
|
14
|
+
"snapchat",
|
|
15
|
+
"linkedinapp",
|
|
16
|
+
"line/",
|
|
17
|
+
"micromessenger",
|
|
18
|
+
"pinterest/",
|
|
19
|
+
"gsa/"
|
|
20
|
+
];
|
|
21
|
+
function pageEnvironment() {
|
|
22
|
+
const g = globalThis;
|
|
23
|
+
return {
|
|
24
|
+
...typeof g.navigator?.userAgent === "string" ? { userAgent: g.navigator.userAgent } : {},
|
|
25
|
+
...typeof g.location?.protocol === "string" ? { protocol: g.location.protocol } : {},
|
|
26
|
+
window: globalThis
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function bridgeOf(win) {
|
|
30
|
+
try {
|
|
31
|
+
const capacitor = win["Capacitor"];
|
|
32
|
+
if (capacitor && typeof capacitor.isNativePlatform === "function" && capacitor.isNativePlatform() === true) {
|
|
33
|
+
return "capacitor";
|
|
34
|
+
}
|
|
35
|
+
if (win["cordova"] !== void 0 || win["_cordovaNative"] !== void 0) return "cordova";
|
|
36
|
+
if (win["ReactNativeWebView"] !== void 0) return "react-native-webview";
|
|
37
|
+
if (win["flutter_inappwebview"] !== void 0) return "flutter-webview";
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
function userAgentEmbedding(userAgent) {
|
|
43
|
+
const ua = userAgent.toLowerCase();
|
|
44
|
+
if (ua === "") return void 0;
|
|
45
|
+
if (ua.includes("electron/")) return "electron";
|
|
46
|
+
if (THIRD_PARTY_IN_APP_BROWSERS.some((needle) => ua.includes(needle))) return void 0;
|
|
47
|
+
if (ua.includes("android") && ua.includes("; wv)")) return "android-webview";
|
|
48
|
+
const appleDevice = ["iphone", "ipad", "ipod", "macintosh"].some((device) => ua.includes(device));
|
|
49
|
+
if (appleDevice && ua.includes("applewebkit/") && !ua.includes("safari/")) return "apple-webview";
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
function detectEmbedding(environment = pageEnvironment()) {
|
|
53
|
+
const protocol = (environment.protocol ?? "").toLowerCase();
|
|
54
|
+
if (protocol !== "" && !["http:", "https:", "about:", "blob:"].includes(protocol)) return "app-scheme";
|
|
55
|
+
const bridge = environment.window ? bridgeOf(environment.window) : void 0;
|
|
56
|
+
if (bridge) return bridge;
|
|
57
|
+
return userAgentEmbedding(environment.userAgent ?? "");
|
|
58
|
+
}
|
|
5
59
|
function compact(value) {
|
|
6
60
|
const out = {};
|
|
7
61
|
for (const [key, entry] of Object.entries(value)) {
|
|
@@ -33,8 +87,471 @@ function asBlockedIfRefused(error) {
|
|
|
33
87
|
throw error;
|
|
34
88
|
}
|
|
35
89
|
|
|
90
|
+
// src/lies/natives.ts
|
|
91
|
+
var INITIAL_FN_TO_STRING = Function.prototype.toString;
|
|
92
|
+
var INITIAL_GET_OWN_PROP_DESC = Object.getOwnPropertyDescriptor;
|
|
93
|
+
var INITIAL_GET_PROTOTYPE_OF = Object.getPrototypeOf;
|
|
94
|
+
var INITIAL_REFLECT_APPLY = Reflect.apply;
|
|
95
|
+
function createRealmStringifier(toStringFn = INITIAL_FN_TO_STRING) {
|
|
96
|
+
return (fn) => {
|
|
97
|
+
try {
|
|
98
|
+
const source = INITIAL_REFLECT_APPLY(toStringFn, fn, []);
|
|
99
|
+
return typeof source === "string" ? { ok: true, source } : { ok: false };
|
|
100
|
+
} catch {
|
|
101
|
+
return { ok: false };
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function escapeRegExp(text) {
|
|
106
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
107
|
+
}
|
|
108
|
+
function isNativeFunctionSource(fn, source, expectedName, isGetter = false) {
|
|
109
|
+
const fnName = attempt(() => fn.name);
|
|
110
|
+
if (typeof fnName === "string" && fnName.startsWith("bound ")) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
const escaped = escapeRegExp(expectedName);
|
|
114
|
+
const pattern = isGetter ? new RegExp(`^\\s*function\\s+(?:get\\s+)?${escaped}\\s*\\(\\s*\\)\\s*\\{\\s*\\[native code\\]\\s*\\}\\s*$`) : new RegExp(`^\\s*function\\s+${escaped}\\s*\\(\\s*\\)\\s*\\{\\s*\\[native code\\]\\s*\\}\\s*$`);
|
|
115
|
+
return pattern.test(source);
|
|
116
|
+
}
|
|
117
|
+
function isTypeErrorLike(error) {
|
|
118
|
+
if (error instanceof TypeError) return true;
|
|
119
|
+
return typeof error === "object" && error !== null && error.name === "TypeError";
|
|
120
|
+
}
|
|
121
|
+
function passesWebIdlBrandCheck(fn, argsList) {
|
|
122
|
+
for (const args of argsList) {
|
|
123
|
+
let threwTypeError = false;
|
|
124
|
+
try {
|
|
125
|
+
INITIAL_REFLECT_APPLY(fn, {}, [...args]);
|
|
126
|
+
} catch (error) {
|
|
127
|
+
threwTypeError = isTypeErrorLike(error);
|
|
128
|
+
}
|
|
129
|
+
if (!threwTypeError) return false;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
function prototypeGetter(proto, prop) {
|
|
134
|
+
if (!proto) return void 0;
|
|
135
|
+
return attempt(() => INITIAL_GET_OWN_PROP_DESC(proto, prop)?.get);
|
|
136
|
+
}
|
|
137
|
+
function accessorOf(holder, prop) {
|
|
138
|
+
let current = holder;
|
|
139
|
+
for (let depth = 0; depth < 8 && current !== null && current !== void 0; depth++) {
|
|
140
|
+
const desc = attempt(() => INITIAL_GET_OWN_PROP_DESC(current, prop));
|
|
141
|
+
if (desc) return desc.get ?? ("value" in desc ? desc.value : void 0);
|
|
142
|
+
current = attempt(() => INITIAL_GET_PROTOTYPE_OF(current));
|
|
143
|
+
}
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
var GL_BRAND_ARGS = [[7936], [37445], [37446]];
|
|
147
|
+
var MATH_FUNCTIONS = [
|
|
148
|
+
"acos",
|
|
149
|
+
"acosh",
|
|
150
|
+
"asin",
|
|
151
|
+
"asinh",
|
|
152
|
+
"atan",
|
|
153
|
+
"atanh",
|
|
154
|
+
"cbrt",
|
|
155
|
+
"cos",
|
|
156
|
+
"cosh",
|
|
157
|
+
"exp",
|
|
158
|
+
"expm1",
|
|
159
|
+
"log",
|
|
160
|
+
"log1p",
|
|
161
|
+
"pow",
|
|
162
|
+
"sin",
|
|
163
|
+
"sinh",
|
|
164
|
+
"sqrt",
|
|
165
|
+
"tan",
|
|
166
|
+
"tanh"
|
|
167
|
+
];
|
|
168
|
+
function member(w, ctor, prop) {
|
|
169
|
+
const holder = w[ctor];
|
|
170
|
+
return holder?.prototype?.[prop];
|
|
171
|
+
}
|
|
172
|
+
var TARGETS = [
|
|
173
|
+
// The primitives this layer itself depends on to borrow a fresh realm.
|
|
174
|
+
{
|
|
175
|
+
path: "Document.prototype.createElement",
|
|
176
|
+
expectedName: "createElement",
|
|
177
|
+
brandArgsList: [["div"]],
|
|
178
|
+
resolve: (w) => member(w, "Document", "createElement")
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
path: "Node.prototype.appendChild",
|
|
182
|
+
expectedName: "appendChild",
|
|
183
|
+
brandArgsList: [[]],
|
|
184
|
+
resolve: (w) => member(w, "Node", "appendChild")
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
path: "HTMLIFrameElement.prototype.contentWindow",
|
|
188
|
+
expectedName: "contentWindow",
|
|
189
|
+
isGetter: true,
|
|
190
|
+
brandArgsList: [[]],
|
|
191
|
+
resolve: (w) => prototypeGetter(
|
|
192
|
+
w.HTMLIFrameElement?.prototype,
|
|
193
|
+
"contentWindow"
|
|
194
|
+
)
|
|
195
|
+
},
|
|
196
|
+
// The window accessors every navigator and screen read goes through.
|
|
197
|
+
{
|
|
198
|
+
path: "window.navigator",
|
|
199
|
+
expectedName: "navigator",
|
|
200
|
+
isGetter: true,
|
|
201
|
+
resolve: (w) => accessorOf(w, "navigator")
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
path: "window.screen",
|
|
205
|
+
expectedName: "screen",
|
|
206
|
+
isGetter: true,
|
|
207
|
+
resolve: (w) => accessorOf(w, "screen")
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
path: "window.devicePixelRatio",
|
|
211
|
+
expectedName: "devicePixelRatio",
|
|
212
|
+
isGetter: true,
|
|
213
|
+
resolve: (w) => accessorOf(w, "devicePixelRatio")
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
path: "window.matchMedia",
|
|
217
|
+
expectedName: "matchMedia",
|
|
218
|
+
resolve: (w) => w.matchMedia
|
|
219
|
+
},
|
|
220
|
+
// What `worker_realm` builds its worker from (`WEB-03`).
|
|
221
|
+
{
|
|
222
|
+
path: "Worker",
|
|
223
|
+
expectedName: "Worker",
|
|
224
|
+
resolve: (w) => w.Worker
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
path: "Blob",
|
|
228
|
+
expectedName: "Blob",
|
|
229
|
+
resolve: (w) => w.Blob
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
path: "URL.createObjectURL",
|
|
233
|
+
expectedName: "createObjectURL",
|
|
234
|
+
resolve: (w) => w.URL?.createObjectURL
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
path: "OffscreenCanvas",
|
|
238
|
+
expectedName: "OffscreenCanvas",
|
|
239
|
+
resolve: (w) => w.OffscreenCanvas
|
|
240
|
+
},
|
|
241
|
+
...MATH_FUNCTIONS.map(
|
|
242
|
+
(name) => ({
|
|
243
|
+
path: `Math.${name}`,
|
|
244
|
+
expectedName: name,
|
|
245
|
+
resolve: () => Math[name]
|
|
246
|
+
})
|
|
247
|
+
),
|
|
248
|
+
{
|
|
249
|
+
path: "Intl.DateTimeFormat.prototype.resolvedOptions",
|
|
250
|
+
expectedName: "resolvedOptions",
|
|
251
|
+
brandArgsList: [[]],
|
|
252
|
+
resolve: () => Intl?.DateTimeFormat?.prototype?.resolvedOptions
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
path: "NavigatorUAData.prototype.getHighEntropyValues",
|
|
256
|
+
expectedName: "getHighEntropyValues",
|
|
257
|
+
resolve: (w) => member(w, "NavigatorUAData", "getHighEntropyValues")
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
path: "StorageManager.prototype.getDirectory",
|
|
261
|
+
expectedName: "getDirectory",
|
|
262
|
+
resolve: (w) => member(w, "StorageManager", "getDirectory")
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
path: "WebGLRenderingContext.prototype.getShaderPrecisionFormat",
|
|
266
|
+
expectedName: "getShaderPrecisionFormat",
|
|
267
|
+
brandArgsList: [[35633, 36338]],
|
|
268
|
+
resolve: (w) => member(w, "WebGLRenderingContext", "getShaderPrecisionFormat")
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
path: "WebGLRenderingContext.prototype.getSupportedExtensions",
|
|
272
|
+
expectedName: "getSupportedExtensions",
|
|
273
|
+
brandArgsList: [[]],
|
|
274
|
+
resolve: (w) => member(w, "WebGLRenderingContext", "getSupportedExtensions")
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
path: "Function.prototype.toString",
|
|
278
|
+
expectedName: "toString",
|
|
279
|
+
resolve: () => Function.prototype.toString
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
path: "Function.prototype.bind",
|
|
283
|
+
expectedName: "bind",
|
|
284
|
+
resolve: () => Function.prototype.bind
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
path: "Object.getOwnPropertyDescriptor",
|
|
288
|
+
expectedName: "getOwnPropertyDescriptor",
|
|
289
|
+
resolve: () => Object.getOwnPropertyDescriptor
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
path: "Object.defineProperty",
|
|
293
|
+
expectedName: "defineProperty",
|
|
294
|
+
resolve: () => Object.defineProperty
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
path: "Date.prototype.getTimezoneOffset",
|
|
298
|
+
expectedName: "getTimezoneOffset",
|
|
299
|
+
resolve: () => Date.prototype.getTimezoneOffset
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
path: "Number.prototype.toFixed",
|
|
303
|
+
expectedName: "toFixed",
|
|
304
|
+
resolve: () => Number.prototype.toFixed
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
path: "Error.prototype.toString",
|
|
308
|
+
expectedName: "toString",
|
|
309
|
+
resolve: () => Error.prototype.toString
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
path: "Intl.DateTimeFormat",
|
|
313
|
+
expectedName: "DateTimeFormat",
|
|
314
|
+
resolve: () => Intl?.DateTimeFormat
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
path: "Navigator.prototype.javaEnabled",
|
|
318
|
+
expectedName: "javaEnabled",
|
|
319
|
+
resolve: (w) => w.Navigator?.prototype?.javaEnabled
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
path: "Permissions.prototype.query",
|
|
323
|
+
expectedName: "query",
|
|
324
|
+
resolve: (w) => w.Permissions?.prototype?.query
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
path: "MediaDevices.prototype.enumerateDevices",
|
|
328
|
+
expectedName: "enumerateDevices",
|
|
329
|
+
resolve: (w) => w.MediaDevices?.prototype?.enumerateDevices
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
path: "HTMLCanvasElement.prototype.getContext",
|
|
333
|
+
expectedName: "getContext",
|
|
334
|
+
brandArgsList: [["2d"]],
|
|
335
|
+
resolve: (w) => w.HTMLCanvasElement?.prototype?.getContext
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
path: "HTMLCanvasElement.prototype.toDataURL",
|
|
339
|
+
expectedName: "toDataURL",
|
|
340
|
+
resolve: (w) => w.HTMLCanvasElement?.prototype?.toDataURL
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
path: "CanvasRenderingContext2D.prototype.getImageData",
|
|
344
|
+
expectedName: "getImageData",
|
|
345
|
+
resolve: (w) => w.CanvasRenderingContext2D?.prototype?.getImageData
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
path: "WebGLRenderingContext.prototype.getParameter",
|
|
349
|
+
expectedName: "getParameter",
|
|
350
|
+
brandArgsList: GL_BRAND_ARGS,
|
|
351
|
+
resolve: (w) => w.WebGLRenderingContext?.prototype?.getParameter
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
path: "WebGLRenderingContext.prototype.getExtension",
|
|
355
|
+
expectedName: "getExtension",
|
|
356
|
+
brandArgsList: [["WEBGL_lose_context"]],
|
|
357
|
+
resolve: (w) => w.WebGLRenderingContext?.prototype?.getExtension
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
path: "WebGL2RenderingContext.prototype.getParameter",
|
|
361
|
+
expectedName: "getParameter",
|
|
362
|
+
brandArgsList: GL_BRAND_ARGS,
|
|
363
|
+
resolve: (w) => w.WebGL2RenderingContext?.prototype?.getParameter
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
path: "OfflineAudioContext.prototype.startRendering",
|
|
367
|
+
expectedName: "startRendering",
|
|
368
|
+
resolve: (w) => w.OfflineAudioContext?.prototype?.startRendering
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
path: "AudioBuffer.prototype.getChannelData",
|
|
372
|
+
expectedName: "getChannelData",
|
|
373
|
+
brandArgsList: [[0]],
|
|
374
|
+
resolve: (w) => w.AudioBuffer?.prototype?.getChannelData
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
path: "StorageManager.prototype.estimate",
|
|
378
|
+
expectedName: "estimate",
|
|
379
|
+
resolve: (w) => w.StorageManager?.prototype?.estimate
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
path: "Element.prototype.getBoundingClientRect",
|
|
383
|
+
expectedName: "getBoundingClientRect",
|
|
384
|
+
resolve: (w) => w.Element?.prototype?.getBoundingClientRect
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
path: "HTMLElement.prototype.offsetWidth",
|
|
388
|
+
expectedName: "offsetWidth",
|
|
389
|
+
isGetter: true,
|
|
390
|
+
brandArgsList: [[]],
|
|
391
|
+
resolve: (w) => prototypeGetter(w.HTMLElement?.prototype, "offsetWidth")
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
path: "HTMLElement.prototype.offsetHeight",
|
|
395
|
+
expectedName: "offsetHeight",
|
|
396
|
+
isGetter: true,
|
|
397
|
+
brandArgsList: [[]],
|
|
398
|
+
resolve: (w) => prototypeGetter(w.HTMLElement?.prototype, "offsetHeight")
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
path: "Performance.prototype.now",
|
|
402
|
+
expectedName: "now",
|
|
403
|
+
resolve: (w) => w.Performance?.prototype?.now
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
path: "Screen.prototype.constructor",
|
|
407
|
+
expectedName: "Screen",
|
|
408
|
+
resolve: (w) => w.Screen
|
|
409
|
+
}
|
|
410
|
+
];
|
|
411
|
+
function unverified(reason) {
|
|
412
|
+
return {
|
|
413
|
+
stringify: createRealmStringifier(INITIAL_FN_TO_STRING),
|
|
414
|
+
clean: false,
|
|
415
|
+
...reason === void 0 ? {} : { reason }
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function fingerlyRealmProbe() {
|
|
419
|
+
return "fingerly-realm-probe-7c1e";
|
|
420
|
+
}
|
|
421
|
+
function looksNative(fn, name, isGetter = false) {
|
|
422
|
+
if (typeof fn !== "function") return false;
|
|
423
|
+
const source = attempt(() => INITIAL_REFLECT_APPLY(INITIAL_FN_TO_STRING, fn, []));
|
|
424
|
+
return typeof source === "string" && isNativeFunctionSource(fn, source, name, isGetter);
|
|
425
|
+
}
|
|
426
|
+
function plausibleStringifier(stringify, own2) {
|
|
427
|
+
const probe = stringify(fingerlyRealmProbe);
|
|
428
|
+
if (!probe.ok || !probe.source.includes("fingerly-realm-probe-7c1e")) return false;
|
|
429
|
+
if (probe.source.includes("[native code]")) return false;
|
|
430
|
+
const self = stringify(own2);
|
|
431
|
+
return self.ok && isNativeFunctionSource(own2, self.source, "toString", false);
|
|
432
|
+
}
|
|
433
|
+
function borrowRealmToString() {
|
|
434
|
+
try {
|
|
435
|
+
return borrowRealm();
|
|
436
|
+
} catch {
|
|
437
|
+
return unverified("inspection-threw");
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
function borrowRealm() {
|
|
441
|
+
if (typeof document === "undefined") return unverified();
|
|
442
|
+
const g = globalThis;
|
|
443
|
+
const doc = document;
|
|
444
|
+
const createElement = attempt(() => member(g, "Document", "createElement"));
|
|
445
|
+
const appendChild = attempt(() => member(g, "Node", "appendChild"));
|
|
446
|
+
const iframeProto = attempt(
|
|
447
|
+
() => g.HTMLIFrameElement?.prototype
|
|
448
|
+
);
|
|
449
|
+
const contentWindowGetter = prototypeGetter(iframeProto, "contentWindow");
|
|
450
|
+
if (typeof createElement !== "function" || typeof appendChild !== "function" || typeof contentWindowGetter !== "function") {
|
|
451
|
+
return unverified();
|
|
452
|
+
}
|
|
453
|
+
if (!looksNative(createElement, "createElement") || !looksNative(appendChild, "appendChild") || !looksNative(contentWindowGetter, "contentWindow", true)) {
|
|
454
|
+
return unverified("borrow-primitive-not-native");
|
|
455
|
+
}
|
|
456
|
+
const host = attempt(() => doc.body ?? doc.documentElement);
|
|
457
|
+
if (!host) return unverified();
|
|
458
|
+
const frame = attempt(() => {
|
|
459
|
+
const element = INITIAL_REFLECT_APPLY(createElement, doc, ["iframe"]);
|
|
460
|
+
element.setAttribute("sandbox", "allow-same-origin");
|
|
461
|
+
element.style.display = "none";
|
|
462
|
+
INITIAL_REFLECT_APPLY(appendChild, host, [element]);
|
|
463
|
+
return element;
|
|
464
|
+
});
|
|
465
|
+
if (!frame) return unverified();
|
|
466
|
+
try {
|
|
467
|
+
const frameWindow = attempt(
|
|
468
|
+
() => INITIAL_REFLECT_APPLY(contentWindowGetter, frame, [])
|
|
469
|
+
);
|
|
470
|
+
if (!frameWindow) return unverified();
|
|
471
|
+
if (frameWindow === globalThis) return unverified("realm-not-distinct");
|
|
472
|
+
const borrowed = attempt(() => frameWindow.Function?.prototype?.toString);
|
|
473
|
+
if (typeof borrowed !== "function") return unverified();
|
|
474
|
+
if (borrowed === INITIAL_FN_TO_STRING) return unverified("realm-not-distinct");
|
|
475
|
+
const candidate = createRealmStringifier(borrowed);
|
|
476
|
+
if (!plausibleStringifier(candidate, borrowed)) return unverified("stringifier-implausible");
|
|
477
|
+
attempt(() => frame.remove());
|
|
478
|
+
if (!candidate(INITIAL_FN_TO_STRING).ok) return unverified();
|
|
479
|
+
return { stringify: candidate, clean: true };
|
|
480
|
+
} finally {
|
|
481
|
+
attempt(() => frame.remove());
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function markPatched(patched, path) {
|
|
485
|
+
if (!patched.includes(path)) patched.push(path);
|
|
486
|
+
}
|
|
487
|
+
function findPatchedNatives(w, realm = borrowRealmToString()) {
|
|
488
|
+
const patched = [];
|
|
489
|
+
const lies = [];
|
|
490
|
+
const { stringify, clean, reason } = realm;
|
|
491
|
+
if (!clean) {
|
|
492
|
+
lies.push(
|
|
493
|
+
reason === void 0 ? { id: "realm", kind: "unverified_realm" } : { id: "realm", kind: "unverified_realm", detail: reason }
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
for (const targetSpec of TARGETS) {
|
|
497
|
+
const { path, expectedName, isGetter = false, brandArgsList, resolve } = targetSpec;
|
|
498
|
+
const target = attempt(() => resolve(w));
|
|
499
|
+
if (target === void 0 || target === null) {
|
|
500
|
+
lies.push({ id: path, kind: "missing" });
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
if (typeof target !== "function") {
|
|
504
|
+
markPatched(patched, path);
|
|
505
|
+
lies.push({ id: path, kind: "not-native" });
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
const stringified = stringify(target);
|
|
509
|
+
if (!stringified.ok) {
|
|
510
|
+
markPatched(patched, path);
|
|
511
|
+
lies.push({ id: path, kind: "to-string-threw" });
|
|
512
|
+
} else if (!isNativeFunctionSource(target, stringified.source, expectedName, isGetter)) {
|
|
513
|
+
markPatched(patched, path);
|
|
514
|
+
lies.push({ id: path, kind: "not-native" });
|
|
515
|
+
}
|
|
516
|
+
if (brandArgsList && !passesWebIdlBrandCheck(target, brandArgsList)) {
|
|
517
|
+
markPatched(patched, path);
|
|
518
|
+
lies.push({ id: path, kind: "brand" });
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
const currentOwn = attempt(() => Function.prototype.toString);
|
|
522
|
+
if (currentOwn !== INITIAL_FN_TO_STRING) {
|
|
523
|
+
markPatched(patched, "Function.prototype.toString");
|
|
524
|
+
if (!lies.some((lie) => lie.id === "Function.prototype.toString" && lie.kind !== "missing")) {
|
|
525
|
+
lies.push({
|
|
526
|
+
id: "Function.prototype.toString",
|
|
527
|
+
kind: "not-native",
|
|
528
|
+
detail: "replaced-after-init"
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
} else if (clean && typeof currentOwn === "function") {
|
|
532
|
+
const viaBorrowed = stringify(currentOwn);
|
|
533
|
+
if (!viaBorrowed.ok) {
|
|
534
|
+
markPatched(patched, "Function.prototype.toString");
|
|
535
|
+
lies.push({
|
|
536
|
+
id: "Function.prototype.toString",
|
|
537
|
+
kind: "to-string-threw",
|
|
538
|
+
detail: "caught-via-fresh-realm"
|
|
539
|
+
});
|
|
540
|
+
} else if (!isNativeFunctionSource(currentOwn, viaBorrowed.source, "toString", false)) {
|
|
541
|
+
markPatched(patched, "Function.prototype.toString");
|
|
542
|
+
if (!lies.some((lie) => lie.id === "Function.prototype.toString" && lie.kind === "not-native")) {
|
|
543
|
+
lies.push({
|
|
544
|
+
id: "Function.prototype.toString",
|
|
545
|
+
kind: "not-native",
|
|
546
|
+
detail: "caught-via-fresh-realm"
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
return { patched, lies, clean, stringify };
|
|
552
|
+
}
|
|
553
|
+
|
|
36
554
|
// src/lies/descriptors.ts
|
|
37
|
-
var NATIVE_PATTERN = /\{\s*\[native code\]\s*\}\s*$/;
|
|
38
555
|
var INSTANCE_SHOULD_NOT_OWN = [
|
|
39
556
|
["navigator", "webdriver"],
|
|
40
557
|
["navigator", "userAgent"],
|
|
@@ -53,15 +570,52 @@ var INSTANCE_SHOULD_NOT_OWN = [
|
|
|
53
570
|
["screen", "height"],
|
|
54
571
|
["screen", "availWidth"],
|
|
55
572
|
["screen", "availHeight"],
|
|
56
|
-
["screen", "colorDepth"]
|
|
573
|
+
["screen", "colorDepth"],
|
|
574
|
+
["screen", "pixelDepth"],
|
|
575
|
+
["screen", "orientation"]
|
|
57
576
|
];
|
|
58
|
-
|
|
577
|
+
var EMPTY_BRAND_ARGS = [[]];
|
|
578
|
+
function sameReading(a, b) {
|
|
579
|
+
if (Object.is(a, b)) return true;
|
|
580
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
581
|
+
return a.length === b.length && a.every((item, index) => Object.is(item, b[index]));
|
|
582
|
+
}
|
|
583
|
+
return false;
|
|
584
|
+
}
|
|
585
|
+
function wrapperLies(holderName, holder, property, getter, lies) {
|
|
586
|
+
let viaGetter;
|
|
587
|
+
try {
|
|
588
|
+
viaGetter = INITIAL_REFLECT_APPLY(getter, holder, []);
|
|
589
|
+
} catch {
|
|
590
|
+
if (!lies.some((lie) => lie.id === holderName && lie.kind === "brand")) {
|
|
591
|
+
lies.push({ id: holderName, kind: "brand", detail: "receiver-rejected" });
|
|
592
|
+
}
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
let viaRead;
|
|
596
|
+
try {
|
|
597
|
+
viaRead = holder[property];
|
|
598
|
+
} catch {
|
|
599
|
+
lies.push({ id: `${holderName}.${property}`, kind: "contradiction", detail: "read-threw" });
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
const comparable = (viaGetter === null || typeof viaGetter !== "object" || Array.isArray(viaGetter)) && (viaRead === null || typeof viaRead !== "object" || Array.isArray(viaRead));
|
|
603
|
+
if (comparable && !sameReading(viaGetter, viaRead)) {
|
|
604
|
+
lies.push({ id: `${holderName}.${property}`, kind: "contradiction", detail: "read-differs-from-getter" });
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
function findRedefinedProperties(w, stringify = createRealmStringifier(), options = {}) {
|
|
608
|
+
const readValues = options.readValues !== false;
|
|
59
609
|
const lies = [];
|
|
610
|
+
const holders = {
|
|
611
|
+
navigator: attempt(() => w.navigator),
|
|
612
|
+
screen: attempt(() => w.screen)
|
|
613
|
+
};
|
|
60
614
|
for (const [holderName, property] of INSTANCE_SHOULD_NOT_OWN) {
|
|
61
|
-
const holder = holderName
|
|
615
|
+
const holder = holders[holderName];
|
|
62
616
|
if (!holder) continue;
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
617
|
+
const own2 = attempt(() => INITIAL_GET_OWN_PROP_DESC(holder, property));
|
|
618
|
+
if (own2) {
|
|
65
619
|
lies.push({
|
|
66
620
|
id: `${holderName}.${property}`,
|
|
67
621
|
kind: "descriptor",
|
|
@@ -69,118 +623,60 @@ function findRedefinedProperties(w) {
|
|
|
69
623
|
});
|
|
70
624
|
continue;
|
|
71
625
|
}
|
|
72
|
-
const proto = attempt(() =>
|
|
626
|
+
const proto = attempt(() => INITIAL_GET_PROTOTYPE_OF(holder));
|
|
73
627
|
if (!proto) continue;
|
|
74
|
-
const inherited = attempt(() =>
|
|
75
|
-
if (!inherited
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
628
|
+
const inherited = attempt(() => INITIAL_GET_OWN_PROP_DESC(proto, property));
|
|
629
|
+
if (!inherited) continue;
|
|
630
|
+
const getterId = `${holderName}.${property}.getter`;
|
|
631
|
+
if ("value" in inherited && inherited.get === void 0) {
|
|
632
|
+
lies.push({
|
|
633
|
+
id: getterId,
|
|
634
|
+
kind: "descriptor",
|
|
635
|
+
detail: "data-property-replaces-getter"
|
|
636
|
+
});
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
639
|
+
const getter = inherited.get;
|
|
640
|
+
if (typeof getter !== "function") continue;
|
|
641
|
+
const stringified = stringify(getter);
|
|
642
|
+
if (!stringified.ok) {
|
|
78
643
|
lies.push({
|
|
79
|
-
id:
|
|
644
|
+
id: getterId,
|
|
645
|
+
kind: "to-string-threw"
|
|
646
|
+
});
|
|
647
|
+
} else if (!isNativeFunctionSource(getter, stringified.source, property, true)) {
|
|
648
|
+
lies.push({
|
|
649
|
+
id: getterId,
|
|
80
650
|
kind: "descriptor",
|
|
81
651
|
detail: "getter-is-not-native"
|
|
82
652
|
});
|
|
83
653
|
}
|
|
654
|
+
if (!passesWebIdlBrandCheck(getter, EMPTY_BRAND_ARGS)) {
|
|
655
|
+
lies.push({
|
|
656
|
+
id: getterId,
|
|
657
|
+
kind: "brand",
|
|
658
|
+
detail: "getter-accepted-invalid-receiver"
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
if (readValues) {
|
|
662
|
+
wrapperLies(holderName, holder, property, getter, lies);
|
|
663
|
+
}
|
|
84
664
|
}
|
|
85
|
-
const
|
|
86
|
-
|
|
665
|
+
const NavigatorCtor = attempt(() => w.Navigator);
|
|
666
|
+
const navigatorProto = holders.navigator ? attempt(() => INITIAL_GET_PROTOTYPE_OF(holders.navigator)) : void 0;
|
|
667
|
+
const navigatorPrototype = attempt(() => NavigatorCtor?.prototype);
|
|
668
|
+
if (NavigatorCtor && navigatorProto !== void 0 && navigatorProto !== navigatorPrototype) {
|
|
87
669
|
lies.push({ id: "navigator", kind: "prototype", detail: "not-Navigator.prototype" });
|
|
88
670
|
}
|
|
89
|
-
const
|
|
90
|
-
|
|
671
|
+
const ScreenCtor = attempt(() => w.Screen);
|
|
672
|
+
const screenProto = holders.screen ? attempt(() => INITIAL_GET_PROTOTYPE_OF(holders.screen)) : void 0;
|
|
673
|
+
const screenPrototype = attempt(() => ScreenCtor?.prototype);
|
|
674
|
+
if (ScreenCtor && screenProto !== void 0 && screenProto !== screenPrototype) {
|
|
91
675
|
lies.push({ id: "screen", kind: "prototype", detail: "not-Screen.prototype" });
|
|
92
676
|
}
|
|
93
677
|
return lies;
|
|
94
678
|
}
|
|
95
679
|
|
|
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
680
|
// src/lies/index.ts
|
|
185
681
|
function inspectIntegrity(sources) {
|
|
186
682
|
const w = windowOrNull();
|
|
@@ -189,7 +685,6 @@ function inspectIntegrity(sources) {
|
|
|
189
685
|
schema: 1,
|
|
190
686
|
budget_ms: 0,
|
|
191
687
|
elapsed_ms: 0,
|
|
192
|
-
tiers: [],
|
|
193
688
|
sources,
|
|
194
689
|
integrity: { patched_natives: [], lies: [], engine: {} }
|
|
195
690
|
},
|
|
@@ -202,11 +697,24 @@ function inspectIntegrity(sources) {
|
|
|
202
697
|
if (!w) {
|
|
203
698
|
return { patched_natives: [], lies: [], engine: identity };
|
|
204
699
|
}
|
|
205
|
-
const
|
|
206
|
-
|
|
700
|
+
const realm = borrowRealmToString();
|
|
701
|
+
let patched = [];
|
|
702
|
+
const lies = [];
|
|
703
|
+
try {
|
|
704
|
+
const natives = findPatchedNatives(w, realm);
|
|
705
|
+
patched = natives.patched;
|
|
706
|
+
lies.push(...natives.lies);
|
|
707
|
+
} catch {
|
|
708
|
+
lies.push({ id: "natives", kind: "unverified_realm", detail: "inspection-threw" });
|
|
709
|
+
}
|
|
710
|
+
try {
|
|
711
|
+
lies.push(...findRedefinedProperties(w, realm.stringify, { readValues: !detectEmbedding() }));
|
|
712
|
+
} catch {
|
|
713
|
+
lies.push({ id: "descriptors", kind: "unverified_realm", detail: "inspection-threw" });
|
|
714
|
+
}
|
|
207
715
|
return {
|
|
208
|
-
patched_natives:
|
|
209
|
-
lies
|
|
716
|
+
patched_natives: patched,
|
|
717
|
+
lies,
|
|
210
718
|
engine: identity
|
|
211
719
|
};
|
|
212
720
|
}
|
|
@@ -248,8 +756,8 @@ async function render(ctx) {
|
|
|
248
756
|
}
|
|
249
757
|
var audioSource = {
|
|
250
758
|
id: SOURCE.audio,
|
|
251
|
-
|
|
252
|
-
timeoutMs:
|
|
759
|
+
stage: "collect",
|
|
760
|
+
timeoutMs: 250,
|
|
253
761
|
async run(ctx) {
|
|
254
762
|
const first = await render(ctx);
|
|
255
763
|
if (first === 0) throw new BlockedSignal("audio-silent");
|
|
@@ -263,7 +771,7 @@ var audioSource = {
|
|
|
263
771
|
};
|
|
264
772
|
var audioLatencySource = {
|
|
265
773
|
id: SOURCE.audioLatency,
|
|
266
|
-
|
|
774
|
+
stage: "collect",
|
|
267
775
|
timeoutMs: 200,
|
|
268
776
|
run() {
|
|
269
777
|
const w = globalThis;
|
|
@@ -283,7 +791,7 @@ var audioLatencySource = {
|
|
|
283
791
|
};
|
|
284
792
|
var hardwareSource = {
|
|
285
793
|
id: SOURCE.hardware,
|
|
286
|
-
|
|
794
|
+
stage: "collect",
|
|
287
795
|
run() {
|
|
288
796
|
if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
|
|
289
797
|
const nav = navigator;
|
|
@@ -295,7 +803,7 @@ var hardwareSource = {
|
|
|
295
803
|
};
|
|
296
804
|
var touchSource = {
|
|
297
805
|
id: SOURCE.touch,
|
|
298
|
-
|
|
806
|
+
stage: "collect",
|
|
299
807
|
run() {
|
|
300
808
|
const w = requireWindow();
|
|
301
809
|
return compact({
|
|
@@ -307,58 +815,14 @@ var touchSource = {
|
|
|
307
815
|
}),
|
|
308
816
|
pointer_coarse: attempt(() => w.matchMedia?.("(pointer: coarse)").matches),
|
|
309
817
|
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
818
|
device_motion: attempt(() => "DeviceMotionEvent" in w),
|
|
314
819
|
device_orientation: attempt(() => "DeviceOrientationEvent" in w)
|
|
315
820
|
});
|
|
316
821
|
}
|
|
317
822
|
};
|
|
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
823
|
var mediaDevicesSource = {
|
|
360
824
|
id: SOURCE.mediaDevices,
|
|
361
|
-
|
|
825
|
+
stage: "collect",
|
|
362
826
|
timeoutMs: 120,
|
|
363
827
|
async run() {
|
|
364
828
|
if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
|
|
@@ -376,7 +840,7 @@ var mediaDevicesSource = {
|
|
|
376
840
|
};
|
|
377
841
|
var networkSource = {
|
|
378
842
|
id: SOURCE.network,
|
|
379
|
-
|
|
843
|
+
stage: "collect",
|
|
380
844
|
run() {
|
|
381
845
|
const connection = navigator.connection;
|
|
382
846
|
if (!connection) throw new UnsupportedSignal("no-network-information");
|
|
@@ -390,22 +854,16 @@ var networkSource = {
|
|
|
390
854
|
};
|
|
391
855
|
var intlSource = {
|
|
392
856
|
id: SOURCE.intl,
|
|
393
|
-
|
|
857
|
+
stage: "collect",
|
|
394
858
|
run() {
|
|
395
859
|
if (typeof Intl === "undefined") throw new UnsupportedSignal("no-intl");
|
|
396
860
|
const resolved = attempt(() => new Intl.DateTimeFormat().resolvedOptions());
|
|
397
861
|
return compact({
|
|
398
862
|
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
863
|
timezone_offset: attempt(() => (/* @__PURE__ */ new Date()).getTimezoneOffset()),
|
|
403
864
|
locale: resolved?.locale,
|
|
404
865
|
calendar: resolved?.calendar,
|
|
405
866
|
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
867
|
formatted: attempt(
|
|
410
868
|
() => new Intl.DateTimeFormat(void 0, {
|
|
411
869
|
dateStyle: "full",
|
|
@@ -417,7 +875,7 @@ var intlSource = {
|
|
|
417
875
|
};
|
|
418
876
|
var timezoneSource = {
|
|
419
877
|
id: SOURCE.timezone,
|
|
420
|
-
|
|
878
|
+
stage: "collect",
|
|
421
879
|
run() {
|
|
422
880
|
if (typeof Intl === "undefined") throw new UnsupportedSignal("no-intl");
|
|
423
881
|
return compact({
|
|
@@ -426,59 +884,9 @@ var timezoneSource = {
|
|
|
426
884
|
});
|
|
427
885
|
}
|
|
428
886
|
};
|
|
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
887
|
var screenSource = {
|
|
480
888
|
id: SOURCE.screen,
|
|
481
|
-
|
|
889
|
+
stage: "collect",
|
|
482
890
|
run() {
|
|
483
891
|
const w = requireWindow();
|
|
484
892
|
const s = w.screen;
|
|
@@ -517,7 +925,7 @@ function readFrame(w) {
|
|
|
517
925
|
}
|
|
518
926
|
var screenFrameSource = {
|
|
519
927
|
id: SOURCE.screenFrame,
|
|
520
|
-
|
|
928
|
+
stage: "collect",
|
|
521
929
|
run() {
|
|
522
930
|
const w = requireWindow();
|
|
523
931
|
const frame = readFrame(w);
|
|
@@ -540,7 +948,7 @@ function matchFirst(w, queries) {
|
|
|
540
948
|
}
|
|
541
949
|
var mediaQueriesSource = {
|
|
542
950
|
id: SOURCE.mediaQueries,
|
|
543
|
-
|
|
951
|
+
stage: "collect",
|
|
544
952
|
run() {
|
|
545
953
|
const w = requireWindow();
|
|
546
954
|
if (typeof w.matchMedia !== "function") throw new UnsupportedSignal("no-match-media");
|
|
@@ -571,7 +979,7 @@ var mediaQueriesSource = {
|
|
|
571
979
|
};
|
|
572
980
|
var colorGamutSource = {
|
|
573
981
|
id: SOURCE.colorGamut,
|
|
574
|
-
|
|
982
|
+
stage: "collect",
|
|
575
983
|
run() {
|
|
576
984
|
const w = requireWindow();
|
|
577
985
|
if (typeof w.matchMedia !== "function") throw new UnsupportedSignal("no-match-media");
|
|
@@ -585,10 +993,9 @@ var colorGamutSource = {
|
|
|
585
993
|
}
|
|
586
994
|
};
|
|
587
995
|
var PAYLOAD_BYTES = 16384;
|
|
588
|
-
var WRITES_PER_BLOCK =
|
|
589
|
-
var MAX_ROUNDS =
|
|
590
|
-
var
|
|
591
|
-
var CAP_MS = 600;
|
|
996
|
+
var WRITES_PER_BLOCK = 4;
|
|
997
|
+
var MAX_ROUNDS = 3;
|
|
998
|
+
var CAP_MS = 60;
|
|
592
999
|
function openDatabase(name) {
|
|
593
1000
|
return new Promise((resolve, reject) => {
|
|
594
1001
|
const request = indexedDB.open(name, 1);
|
|
@@ -632,9 +1039,9 @@ function timeBlock(db, durability, payload) {
|
|
|
632
1039
|
}
|
|
633
1040
|
var storageDurabilitySource = {
|
|
634
1041
|
id: SOURCE.storageDurability,
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
timeoutMs:
|
|
1042
|
+
stage: "collect",
|
|
1043
|
+
optIn: "extended-incognito",
|
|
1044
|
+
timeoutMs: 80,
|
|
638
1045
|
async run(ctx) {
|
|
639
1046
|
requireWindow();
|
|
640
1047
|
if (typeof indexedDB !== "object" || indexedDB === null) {
|
|
@@ -647,20 +1054,19 @@ var storageDurabilitySource = {
|
|
|
647
1054
|
const payload = new Uint8Array(PAYLOAD_BYTES);
|
|
648
1055
|
let db;
|
|
649
1056
|
try {
|
|
1057
|
+
const started = performance.now();
|
|
1058
|
+
const deadline = started + Math.min(CAP_MS, Math.max(0, ctx.budgetRemainingMs()));
|
|
650
1059
|
db = await openDatabase(name);
|
|
651
1060
|
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
1061
|
const ratios = [];
|
|
657
1062
|
while (ratios.length < MAX_ROUNDS) {
|
|
658
|
-
if (ctx.signal.aborted) break;
|
|
1063
|
+
if (ctx.signal.aborted || performance.now() >= deadline) break;
|
|
659
1064
|
if (ratios.length > 0) {
|
|
660
1065
|
const perRound = (performance.now() - started) / ratios.length;
|
|
661
1066
|
if (performance.now() + perRound > deadline) break;
|
|
662
1067
|
}
|
|
663
1068
|
const relaxed = await timeBlock(db, "relaxed", payload);
|
|
1069
|
+
if (ctx.signal.aborted || performance.now() >= deadline) break;
|
|
664
1070
|
const strict = await timeBlock(db, "strict", payload);
|
|
665
1071
|
if (relaxed > 0) ratios.push(strict / relaxed);
|
|
666
1072
|
else break;
|
|
@@ -681,90 +1087,6 @@ var storageDurabilitySource = {
|
|
|
681
1087
|
}
|
|
682
1088
|
}
|
|
683
1089
|
};
|
|
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
1090
|
function toFixedErrorLength() {
|
|
769
1091
|
return attempt(() => {
|
|
770
1092
|
try {
|
|
@@ -819,9 +1141,44 @@ function claimedEngine(userAgent) {
|
|
|
819
1141
|
if (/Safari\//.test(userAgent)) return "webkit";
|
|
820
1142
|
return void 0;
|
|
821
1143
|
}
|
|
1144
|
+
function cssSupports(property, value) {
|
|
1145
|
+
return attempt(
|
|
1146
|
+
() => typeof CSS !== "undefined" && typeof CSS.supports === "function" ? CSS.supports(property, value) : void 0
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
function hasMotionPermissionFn() {
|
|
1150
|
+
return typeof DeviceMotionEvent !== "undefined" && typeof DeviceMotionEvent.requestPermission === "function";
|
|
1151
|
+
}
|
|
1152
|
+
function isGeckoEngine(ctx) {
|
|
1153
|
+
const completed = ctx?.completed?.(SOURCE.engine);
|
|
1154
|
+
if (completed?.status === "ok") {
|
|
1155
|
+
const val = completed.value;
|
|
1156
|
+
if (val?.observed === "gecko" || val?.claimed === "gecko") return true;
|
|
1157
|
+
if (val?.moz_appearance === true && cssSupports("-fingerly-nonexistent", "none") !== true) {
|
|
1158
|
+
return true;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
if (observedEngine(toFixedErrorLength(), evalLength(), stackStyle()) === "gecko") {
|
|
1162
|
+
return true;
|
|
1163
|
+
}
|
|
1164
|
+
const ua = attempt(() => typeof navigator === "undefined" ? void 0 : navigator.userAgent);
|
|
1165
|
+
if (claimedEngine(ua) === "gecko") return true;
|
|
1166
|
+
if (ua && /\bGecko\/\d/i.test(ua) && !/like Gecko|FxiOS/i.test(ua)) return true;
|
|
1167
|
+
if (cssSupports("-moz-appearance", "none") === true && cssSupports("-fingerly-nonexistent", "none") !== true) {
|
|
1168
|
+
return true;
|
|
1169
|
+
}
|
|
1170
|
+
const rootStyle = attempt(
|
|
1171
|
+
() => typeof document === "undefined" ? void 0 : document.documentElement?.style
|
|
1172
|
+
);
|
|
1173
|
+
if (rootStyle && "MozAppearance" in rootStyle && !("FingerlyNonexistent" in rootStyle)) {
|
|
1174
|
+
return true;
|
|
1175
|
+
}
|
|
1176
|
+
return false;
|
|
1177
|
+
}
|
|
822
1178
|
var engineSource = {
|
|
823
1179
|
id: SOURCE.engine,
|
|
824
|
-
|
|
1180
|
+
stage: "prerequisite",
|
|
1181
|
+
embeddedSafe: true,
|
|
825
1182
|
run() {
|
|
826
1183
|
const toFixed = toFixedErrorLength();
|
|
827
1184
|
const evalLen = evalLength();
|
|
@@ -835,9 +1192,10 @@ var engineSource = {
|
|
|
835
1192
|
eval_length: evalLen,
|
|
836
1193
|
stack_style: stack,
|
|
837
1194
|
observed,
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
1195
|
+
claimed,
|
|
1196
|
+
has_motion_permission_fn: attempt(hasMotionPermissionFn),
|
|
1197
|
+
moz_appearance: cssSupports("-moz-appearance", "none"),
|
|
1198
|
+
webkit_touch_callout: cssSupports("-webkit-touch-callout", "none")
|
|
841
1199
|
});
|
|
842
1200
|
}
|
|
843
1201
|
};
|
|
@@ -867,28 +1225,21 @@ function identitiesHold() {
|
|
|
867
1225
|
}
|
|
868
1226
|
var mathSource = {
|
|
869
1227
|
id: SOURCE.math,
|
|
870
|
-
|
|
1228
|
+
stage: "collect",
|
|
1229
|
+
embeddedSafe: true,
|
|
871
1230
|
timeoutMs: 50,
|
|
872
1231
|
run() {
|
|
873
|
-
const results = [];
|
|
874
1232
|
let probed = 0;
|
|
875
1233
|
const values = /* @__PURE__ */ new Map();
|
|
876
|
-
for (const [name,
|
|
877
|
-
const value = attempt(
|
|
1234
|
+
for (const [name, probe] of MATH_PROBES) {
|
|
1235
|
+
const value = attempt(probe);
|
|
878
1236
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
879
1237
|
probed += 1;
|
|
880
1238
|
values.set(name, value);
|
|
881
|
-
results.push(`${name}:${value}`);
|
|
882
|
-
} else {
|
|
883
|
-
results.push(`${name}:`);
|
|
884
1239
|
}
|
|
885
1240
|
}
|
|
886
1241
|
return compact({
|
|
887
|
-
hash: hash64(results.join("|")),
|
|
888
1242
|
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
1243
|
atanh_half: values.get("atanh"),
|
|
893
1244
|
expm1_1: values.get("expm1"),
|
|
894
1245
|
identities_hold: attempt(identitiesHold)
|
|
@@ -906,26 +1257,26 @@ function thrownMessageLength(throwing) {
|
|
|
906
1257
|
return void 0;
|
|
907
1258
|
});
|
|
908
1259
|
}
|
|
909
|
-
function
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
}
|
|
914
|
-
return false;
|
|
915
|
-
}
|
|
1260
|
+
function regexpSyntaxError() {
|
|
1261
|
+
return new RegExp("(");
|
|
1262
|
+
}
|
|
1263
|
+
function redefineFrozen() {
|
|
1264
|
+
return Object.defineProperty(Object.freeze({ x: 1 }), "x", { value: 2 });
|
|
916
1265
|
}
|
|
917
1266
|
function observedFromErrors(errors) {
|
|
918
1267
|
const votes = [];
|
|
919
|
-
const
|
|
920
|
-
if (
|
|
921
|
-
if (
|
|
922
|
-
else if (
|
|
923
|
-
else if (
|
|
1268
|
+
const own2 = errors.own_properties;
|
|
1269
|
+
if (own2 !== void 0) {
|
|
1270
|
+
if (own2.includes("sourceURL")) votes.push("webkit", "webkit");
|
|
1271
|
+
else if (own2.includes("lineNumber")) votes.push("gecko", "gecko");
|
|
1272
|
+
else if (own2 === "message,stack") votes.push("chromium", "chromium");
|
|
924
1273
|
}
|
|
925
1274
|
if (errors.null_property_length === 44) votes.push("chromium");
|
|
926
1275
|
else if (errors.null_property_length === 33) votes.push("gecko");
|
|
927
|
-
if (errors.
|
|
928
|
-
else if (errors.
|
|
1276
|
+
if (errors.regexp_syntax_length === 51) votes.push("chromium");
|
|
1277
|
+
else if (errors.regexp_syntax_length === 37) votes.push("webkit");
|
|
1278
|
+
if (errors.redefine_length === 27) votes.push("chromium");
|
|
1279
|
+
else if (errors.redefine_length === 50) votes.push("webkit");
|
|
929
1280
|
if (votes.length === 0) return void 0;
|
|
930
1281
|
const tally = /* @__PURE__ */ new Map();
|
|
931
1282
|
for (const vote of votes) tally.set(vote, (tally.get(vote) ?? 0) + 1);
|
|
@@ -954,24 +1305,23 @@ function errorOwnProperties() {
|
|
|
954
1305
|
}
|
|
955
1306
|
var errorsSource = {
|
|
956
1307
|
id: SOURCE.errors,
|
|
957
|
-
|
|
1308
|
+
stage: "collect",
|
|
1309
|
+
embeddedSafe: true,
|
|
958
1310
|
timeoutMs: 50,
|
|
1311
|
+
// No `new Function` or `eval` call (`WEB-10`): under a policy without
|
|
1312
|
+
// 'unsafe-eval' each one raised a CSP violation report on every run, and
|
|
1313
|
+
// three per run in report-only mode. Every probe here throws without
|
|
1314
|
+
// evaluating code.
|
|
959
1315
|
run() {
|
|
960
|
-
const compiles = evalAllowed();
|
|
961
1316
|
const shapes = compact({
|
|
962
1317
|
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
1318
|
json_parse_length: thrownMessageLength(() => JSON.parse("{")),
|
|
968
1319
|
invalid_array_length: thrownMessageLength(() => {
|
|
969
1320
|
const array = [];
|
|
970
1321
|
array.length = -1;
|
|
971
1322
|
}),
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
}) : void 0,
|
|
1323
|
+
regexp_syntax_length: thrownMessageLength(regexpSyntaxError),
|
|
1324
|
+
redefine_length: thrownMessageLength(redefineFrozen),
|
|
975
1325
|
own_properties: errorOwnProperties(),
|
|
976
1326
|
capture_stack_trace: attempt(
|
|
977
1327
|
() => typeof Error.captureStackTrace === "function"
|
|
@@ -983,10 +1333,18 @@ var errorsSource = {
|
|
|
983
1333
|
};
|
|
984
1334
|
var navigatorSource = {
|
|
985
1335
|
id: SOURCE.navigator,
|
|
986
|
-
|
|
1336
|
+
stage: "collect",
|
|
1337
|
+
embeddedSafe: true,
|
|
987
1338
|
run() {
|
|
988
1339
|
if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
|
|
989
1340
|
const nav = navigator;
|
|
1341
|
+
if (detectEmbedding()) {
|
|
1342
|
+
return compact({
|
|
1343
|
+
user_agent: attempt(() => nav.userAgent),
|
|
1344
|
+
platform: attempt(() => nav.platform),
|
|
1345
|
+
webdriver: attempt(() => nav.webdriver)
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
990
1348
|
return compact({
|
|
991
1349
|
user_agent: attempt(() => nav.userAgent),
|
|
992
1350
|
platform: attempt(() => nav.platform),
|
|
@@ -1000,10 +1358,6 @@ var navigatorSource = {
|
|
|
1000
1358
|
cookie_enabled: attempt(() => nav.cookieEnabled),
|
|
1001
1359
|
pdf_viewer_enabled: attempt(() => nav.pdfViewerEnabled),
|
|
1002
1360
|
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
1361
|
plugin_count: attempt(() => nav.plugins?.length),
|
|
1008
1362
|
mime_type_count: attempt(() => nav.mimeTypes?.length),
|
|
1009
1363
|
language: attempt(() => nav.language),
|
|
@@ -1013,7 +1367,7 @@ var navigatorSource = {
|
|
|
1013
1367
|
};
|
|
1014
1368
|
var languagesSource = {
|
|
1015
1369
|
id: SOURCE.languages,
|
|
1016
|
-
|
|
1370
|
+
stage: "collect",
|
|
1017
1371
|
run() {
|
|
1018
1372
|
if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
|
|
1019
1373
|
return compact({
|
|
@@ -1024,37 +1378,16 @@ var languagesSource = {
|
|
|
1024
1378
|
};
|
|
1025
1379
|
var vendorSource = {
|
|
1026
1380
|
id: SOURCE.vendor,
|
|
1027
|
-
|
|
1381
|
+
stage: "collect",
|
|
1028
1382
|
run() {
|
|
1029
1383
|
if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
|
|
1030
1384
|
return compact({ vendor: attempt(() => navigator.vendor) });
|
|
1031
1385
|
}
|
|
1032
1386
|
};
|
|
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
1387
|
var userAgentDataSource = {
|
|
1055
1388
|
id: SOURCE.userAgentData,
|
|
1056
|
-
|
|
1057
|
-
timeoutMs:
|
|
1389
|
+
stage: "collect",
|
|
1390
|
+
timeoutMs: 150,
|
|
1058
1391
|
async run() {
|
|
1059
1392
|
if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
|
|
1060
1393
|
const data = navigator.userAgentData;
|
|
@@ -1065,208 +1398,92 @@ var userAgentDataSource = {
|
|
|
1065
1398
|
platform: data.platform
|
|
1066
1399
|
});
|
|
1067
1400
|
if (typeof data.getHighEntropyValues !== "function") return low;
|
|
1068
|
-
const high = await data.getHighEntropyValues([
|
|
1069
|
-
|
|
1070
|
-
|
|
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 };
|
|
1401
|
+
const high = await data.getHighEntropyValues(["architecture"]);
|
|
1402
|
+
const architecture = attempt(() => high.architecture);
|
|
1403
|
+
return typeof architecture === "string" ? { ...low, architecture } : low;
|
|
1079
1404
|
}
|
|
1080
1405
|
};
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
return [canvas, context];
|
|
1406
|
+
var RFP_SHARED_KEY = "rfpCanvasBlocked";
|
|
1407
|
+
var GECKO_PROBE_MAX_MS = 2.8;
|
|
1408
|
+
var GECKO_SPIN_GUARD = 25e4;
|
|
1409
|
+
var CLAMPED_STALL_RESOLUTION_MS = 16.67;
|
|
1410
|
+
function roundResolution(ms) {
|
|
1411
|
+
return Math.round(ms * 1e6) / 1e6;
|
|
1088
1412
|
}
|
|
1089
|
-
function
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
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
|
-
}
|
|
1413
|
+
function probeGeckoRfp(now) {
|
|
1414
|
+
const wallDeadline = Date.now() + GECKO_PROBE_MAX_MS;
|
|
1415
|
+
const start = now();
|
|
1416
|
+
let end = now();
|
|
1417
|
+
let guard = 0;
|
|
1418
|
+
while (end === start && guard++ < GECKO_SPIN_GUARD && Date.now() < wallDeadline) {
|
|
1419
|
+
end = now();
|
|
1159
1420
|
}
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
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
|
-
});
|
|
1421
|
+
const delta = end - start;
|
|
1422
|
+
if (delta === 0) {
|
|
1423
|
+
return { resolution: CLAMPED_STALL_RESOLUTION_MS, rfpBlocked: true };
|
|
1229
1424
|
}
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
run() {
|
|
1236
|
-
const gl = webglContext();
|
|
1237
|
-
const extensions = gl.getSupportedExtensions();
|
|
1238
|
-
if (!extensions) throw new BlockedSignal("extensions-withheld");
|
|
1239
|
-
return [...extensions].sort();
|
|
1425
|
+
if (delta >= 1.5 || !(delta > 0 && delta <= 1.2)) {
|
|
1426
|
+
return {
|
|
1427
|
+
resolution: delta > 0 ? roundResolution(delta) : CLAMPED_STALL_RESOLUTION_MS,
|
|
1428
|
+
rfpBlocked: true
|
|
1429
|
+
};
|
|
1240
1430
|
}
|
|
1241
|
-
};
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
const
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1431
|
+
return { resolution: roundResolution(delta), rfpBlocked: false };
|
|
1432
|
+
}
|
|
1433
|
+
function sampleNonGeckoClock(now) {
|
|
1434
|
+
const first = now();
|
|
1435
|
+
const second = now();
|
|
1436
|
+
return second > first ? roundResolution(second - first) : 0;
|
|
1437
|
+
}
|
|
1438
|
+
function isRfpCanvasBlocked(ctx) {
|
|
1439
|
+
const cached = ctx?.shared?.get(RFP_SHARED_KEY);
|
|
1440
|
+
if (typeof cached === "boolean") return cached;
|
|
1441
|
+
const timing = ctx?.completed?.(SOURCE.timing);
|
|
1442
|
+
if (timing?.status === "ok") {
|
|
1443
|
+
const val = timing.value;
|
|
1444
|
+
if (val?.rfp_canvas_blocked === true) return true;
|
|
1445
|
+
if (typeof val?.now_resolution === "number" && val.now_resolution >= 1.5) return true;
|
|
1446
|
+
if (typeof val?.rfp_canvas_blocked === "boolean") return val.rfp_canvas_blocked;
|
|
1447
|
+
if (typeof val?.now_resolution === "number") return false;
|
|
1251
1448
|
}
|
|
1252
|
-
if (
|
|
1253
|
-
|
|
1449
|
+
if (isGeckoEngine(ctx)) {
|
|
1450
|
+
const w = typeof window === "undefined" ? void 0 : window;
|
|
1451
|
+
if (typeof w?.performance?.now !== "function") return true;
|
|
1452
|
+
const probed = probeGeckoRfp(() => w.performance.now());
|
|
1453
|
+
ctx?.shared?.set(RFP_SHARED_KEY, probed.rfpBlocked);
|
|
1454
|
+
return probed.rfpBlocked;
|
|
1254
1455
|
}
|
|
1255
|
-
return
|
|
1456
|
+
return false;
|
|
1256
1457
|
}
|
|
1257
1458
|
var timingSource = {
|
|
1258
1459
|
id: SOURCE.timing,
|
|
1259
|
-
|
|
1260
|
-
timeoutMs:
|
|
1261
|
-
run() {
|
|
1460
|
+
stage: "prerequisite",
|
|
1461
|
+
timeoutMs: 50,
|
|
1462
|
+
run(ctx) {
|
|
1262
1463
|
const w = requireWindow();
|
|
1263
1464
|
const perf = w.performance;
|
|
1264
1465
|
if (typeof perf?.now !== "function") {
|
|
1265
|
-
|
|
1466
|
+
const gecko = isGeckoEngine(ctx);
|
|
1467
|
+
ctx?.shared?.set(RFP_SHARED_KEY, gecko);
|
|
1468
|
+
return compact({
|
|
1469
|
+
has_performance: false,
|
|
1470
|
+
rfp_canvas_blocked: gecko
|
|
1471
|
+
});
|
|
1266
1472
|
}
|
|
1473
|
+
if (!isGeckoEngine(ctx)) {
|
|
1474
|
+
ctx?.shared?.set(RFP_SHARED_KEY, false);
|
|
1475
|
+
return compact({
|
|
1476
|
+
has_performance: true,
|
|
1477
|
+
now_resolution: sampleNonGeckoClock(() => perf.now()),
|
|
1478
|
+
rfp_canvas_blocked: false
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
const probed = probeGeckoRfp(() => perf.now());
|
|
1482
|
+
ctx?.shared?.set(RFP_SHARED_KEY, probed.rfpBlocked);
|
|
1267
1483
|
return compact({
|
|
1268
1484
|
has_performance: true,
|
|
1269
|
-
now_resolution:
|
|
1485
|
+
now_resolution: probed.resolution,
|
|
1486
|
+
rfp_canvas_blocked: probed.rfpBlocked
|
|
1270
1487
|
});
|
|
1271
1488
|
}
|
|
1272
1489
|
};
|
|
@@ -1286,8 +1503,8 @@ function permissionStatus(w, name) {
|
|
|
1286
1503
|
}
|
|
1287
1504
|
var permissionsSource = {
|
|
1288
1505
|
id: SOURCE.permissions,
|
|
1289
|
-
|
|
1290
|
-
timeoutMs:
|
|
1506
|
+
stage: "collect",
|
|
1507
|
+
timeoutMs: 150,
|
|
1291
1508
|
async run() {
|
|
1292
1509
|
const w = requireWindow();
|
|
1293
1510
|
if (!w.navigator.permissions?.query) throw new UnsupportedSignal("no-permissions-api");
|
|
@@ -1299,7 +1516,9 @@ var permissionsSource = {
|
|
|
1299
1516
|
}
|
|
1300
1517
|
};
|
|
1301
1518
|
const notification = await query("notifications");
|
|
1302
|
-
const legacy = attempt(
|
|
1519
|
+
const legacy = attempt(
|
|
1520
|
+
() => w.Notification?.permission
|
|
1521
|
+
);
|
|
1303
1522
|
return compact({
|
|
1304
1523
|
notification,
|
|
1305
1524
|
notification_legacy: legacy,
|
|
@@ -1330,23 +1549,45 @@ var AUTOMATION_GLOBALS = [
|
|
|
1330
1549
|
"domAutomationController",
|
|
1331
1550
|
"__lastWatirAlert",
|
|
1332
1551
|
"__playwright",
|
|
1552
|
+
"__playwright__binding__",
|
|
1553
|
+
"__pwInitScripts",
|
|
1333
1554
|
"__puppeteer",
|
|
1334
1555
|
"__pw_manual"
|
|
1335
1556
|
];
|
|
1557
|
+
var CDC_PATTERN = /^cdc_|^\$cdc_/;
|
|
1558
|
+
function collectCdcMarkers(w) {
|
|
1559
|
+
const found = /* @__PURE__ */ new Set();
|
|
1560
|
+
const windowProps = attempt(() => Object.getOwnPropertyNames(w));
|
|
1561
|
+
if (windowProps) {
|
|
1562
|
+
for (const name of windowProps) {
|
|
1563
|
+
if (CDC_PATTERN.test(name)) found.add(name);
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
const doc = attempt(() => w.document);
|
|
1567
|
+
if (doc) {
|
|
1568
|
+
const docProps = attempt(() => Object.getOwnPropertyNames(doc));
|
|
1569
|
+
if (docProps) {
|
|
1570
|
+
for (const name of docProps) {
|
|
1571
|
+
if (CDC_PATTERN.test(name)) found.add(name);
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
return [...found];
|
|
1576
|
+
}
|
|
1336
1577
|
var automationSource = {
|
|
1337
1578
|
id: SOURCE.automation,
|
|
1338
|
-
|
|
1579
|
+
stage: "collect",
|
|
1580
|
+
embeddedSafe: true,
|
|
1339
1581
|
run() {
|
|
1340
1582
|
const w = requireWindow();
|
|
1341
|
-
const present = AUTOMATION_GLOBALS.filter(
|
|
1342
|
-
|
|
1343
|
-
() => Object.getOwnPropertyNames(w).filter((name) => /^cdc_|^\$cdc_/.test(name))
|
|
1583
|
+
const present = AUTOMATION_GLOBALS.filter(
|
|
1584
|
+
(name) => attempt(() => name in w || w.document != null && name in w.document) === true
|
|
1344
1585
|
);
|
|
1586
|
+
const cdp = collectCdcMarkers(w);
|
|
1345
1587
|
return compact({
|
|
1346
1588
|
webdriver: attempt(() => navigator.webdriver),
|
|
1347
|
-
cdp_artifacts: cdp
|
|
1589
|
+
cdp_artifacts: cdp.length > 0 ? cdp : void 0,
|
|
1348
1590
|
distinctive_properties: present.length > 0 ? [...present] : void 0,
|
|
1349
|
-
chrome_object: attempt(() => "chrome" in w),
|
|
1350
1591
|
window_external: attempt(() => {
|
|
1351
1592
|
const external = w.external;
|
|
1352
1593
|
return external ? String(external) : void 0;
|
|
@@ -1354,38 +1595,220 @@ var automationSource = {
|
|
|
1354
1595
|
});
|
|
1355
1596
|
}
|
|
1356
1597
|
};
|
|
1598
|
+
|
|
1599
|
+
// src/sources/render.ts
|
|
1600
|
+
var SHARED_CANVAS_KEY = "canvas2d";
|
|
1601
|
+
function acquireCanvas2D(ctx, width, height) {
|
|
1602
|
+
if (typeof document === "undefined") return void 0;
|
|
1603
|
+
const shared = ctx?.shared;
|
|
1604
|
+
const existing = shared?.get(SHARED_CANVAS_KEY);
|
|
1605
|
+
if (existing) {
|
|
1606
|
+
existing.canvas.width = width;
|
|
1607
|
+
existing.canvas.height = height;
|
|
1608
|
+
return [existing.canvas, existing.context];
|
|
1609
|
+
}
|
|
1610
|
+
const canvas = document.createElement("canvas");
|
|
1611
|
+
canvas.width = width;
|
|
1612
|
+
canvas.height = height;
|
|
1613
|
+
const context = canvas.getContext("2d", { willReadFrequently: true }) ?? canvas.getContext("2d");
|
|
1614
|
+
if (!context) return void 0;
|
|
1615
|
+
shared?.set(SHARED_CANVAS_KEY, { canvas, context });
|
|
1616
|
+
return [canvas, context];
|
|
1617
|
+
}
|
|
1618
|
+
function requireCanvas2D(ctx, width, height) {
|
|
1619
|
+
const pair = acquireCanvas2D(ctx, width, height);
|
|
1620
|
+
if (!pair) throw new UnsupportedSignal("no-2d-context");
|
|
1621
|
+
return pair;
|
|
1622
|
+
}
|
|
1623
|
+
function renderGeometryHash(ctx) {
|
|
1624
|
+
const width = 240;
|
|
1625
|
+
const height = 60;
|
|
1626
|
+
const [, context] = requireCanvas2D(ctx, width, height);
|
|
1627
|
+
context.globalCompositeOperation = "multiply";
|
|
1628
|
+
for (const [colour, x, y] of [
|
|
1629
|
+
["#f2f", 40, 40],
|
|
1630
|
+
["#2ff", 80, 40],
|
|
1631
|
+
["#ff2", 60, 80]
|
|
1632
|
+
]) {
|
|
1633
|
+
context.fillStyle = colour;
|
|
1634
|
+
context.beginPath();
|
|
1635
|
+
context.arc(x, y, 40, 0, Math.PI * 2, true);
|
|
1636
|
+
context.closePath();
|
|
1637
|
+
context.fill();
|
|
1638
|
+
}
|
|
1639
|
+
context.fillStyle = "#f9c";
|
|
1640
|
+
context.arc(100, 50, 50, 0, Math.PI * 2, true);
|
|
1641
|
+
context.arc(100, 50, 20, 0, Math.PI * 2, true);
|
|
1642
|
+
context.fill("evenodd");
|
|
1643
|
+
return hash64(context.getImageData(0, 0, width, height).data);
|
|
1644
|
+
}
|
|
1645
|
+
function renderTextHash(ctx) {
|
|
1646
|
+
const width = 300;
|
|
1647
|
+
const height = 60;
|
|
1648
|
+
const [, context] = requireCanvas2D(ctx, width, height);
|
|
1649
|
+
context.textBaseline = "alphabetic";
|
|
1650
|
+
context.fillStyle = "#f60";
|
|
1651
|
+
context.fillRect(100, 1, 62, 20);
|
|
1652
|
+
context.fillStyle = "#069";
|
|
1653
|
+
context.font = '11pt "Times New Roman"';
|
|
1654
|
+
context.fillText("Fingerly <canvas> 1.0 \u{1F512}\u0416\u4E2D", 2, 15);
|
|
1655
|
+
context.font = "18pt Arial";
|
|
1656
|
+
context.fillStyle = "rgba(102, 204, 0, 0.7)";
|
|
1657
|
+
context.fillText("Fingerly <canvas> 1.0", 4, 45);
|
|
1658
|
+
return hash64(context.getImageData(0, 0, width, height).data);
|
|
1659
|
+
}
|
|
1660
|
+
function supportsWinding(ctx) {
|
|
1661
|
+
const [, context] = requireCanvas2D(ctx, 1, 1);
|
|
1662
|
+
context.rect(0, 0, 10, 10);
|
|
1663
|
+
context.rect(2, 2, 6, 6);
|
|
1664
|
+
return context.isPointInPath(5, 5, "evenodd") === false;
|
|
1665
|
+
}
|
|
1666
|
+
var canvasSource = {
|
|
1667
|
+
id: SOURCE.canvas,
|
|
1668
|
+
stage: "collect",
|
|
1669
|
+
timeoutMs: 250,
|
|
1670
|
+
run(ctx) {
|
|
1671
|
+
requireWindow();
|
|
1672
|
+
if (typeof document === "undefined") throw new UnsupportedSignal("no-document");
|
|
1673
|
+
if (isRfpCanvasBlocked(ctx)) {
|
|
1674
|
+
throw new BlockedSignal("rfp-canvas-prompt-avoided");
|
|
1675
|
+
}
|
|
1676
|
+
try {
|
|
1677
|
+
const geometryFirst = renderGeometryHash(ctx);
|
|
1678
|
+
const geometrySecond = renderGeometryHash(ctx);
|
|
1679
|
+
const textFirst = renderTextHash(ctx);
|
|
1680
|
+
const textSecond = renderTextHash(ctx);
|
|
1681
|
+
const unstable = geometryFirst !== geometrySecond || textFirst !== textSecond;
|
|
1682
|
+
return compact({
|
|
1683
|
+
geometry: geometryFirst,
|
|
1684
|
+
text: textFirst,
|
|
1685
|
+
winding: attempt(() => supportsWinding(ctx)),
|
|
1686
|
+
unstable
|
|
1687
|
+
});
|
|
1688
|
+
} catch (error) {
|
|
1689
|
+
asBlockedIfRefused(error);
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
};
|
|
1693
|
+
function webglContext() {
|
|
1694
|
+
if (typeof document === "undefined") throw new UnsupportedSignal("no-document");
|
|
1695
|
+
const canvas = document.createElement("canvas");
|
|
1696
|
+
const gl = canvas.getContext("webgl") ?? canvas.getContext("experimental-webgl");
|
|
1697
|
+
if (!gl) throw new UnsupportedSignal("no-webgl-context");
|
|
1698
|
+
return gl;
|
|
1699
|
+
}
|
|
1700
|
+
var webglSource = {
|
|
1701
|
+
id: SOURCE.webgl,
|
|
1702
|
+
stage: "collect",
|
|
1703
|
+
timeoutMs: 250,
|
|
1704
|
+
run() {
|
|
1705
|
+
const gl = webglContext();
|
|
1706
|
+
try {
|
|
1707
|
+
const debug = attempt(() => gl.getExtension("WEBGL_debug_renderer_info"));
|
|
1708
|
+
const parameters = {};
|
|
1709
|
+
for (const name of [
|
|
1710
|
+
"MAX_TEXTURE_SIZE",
|
|
1711
|
+
"MAX_VIEWPORT_DIMS",
|
|
1712
|
+
"MAX_VERTEX_ATTRIBS",
|
|
1713
|
+
"MAX_VARYING_VECTORS",
|
|
1714
|
+
"MAX_COMBINED_TEXTURE_IMAGE_UNITS",
|
|
1715
|
+
"MAX_CUBE_MAP_TEXTURE_SIZE",
|
|
1716
|
+
"MAX_FRAGMENT_UNIFORM_VECTORS",
|
|
1717
|
+
"MAX_RENDERBUFFER_SIZE",
|
|
1718
|
+
"MAX_TEXTURE_IMAGE_UNITS",
|
|
1719
|
+
"MAX_VERTEX_TEXTURE_IMAGE_UNITS",
|
|
1720
|
+
"MAX_VERTEX_UNIFORM_VECTORS",
|
|
1721
|
+
"ALIASED_LINE_WIDTH_RANGE",
|
|
1722
|
+
"ALIASED_POINT_SIZE_RANGE",
|
|
1723
|
+
"RED_BITS",
|
|
1724
|
+
"GREEN_BITS",
|
|
1725
|
+
"BLUE_BITS",
|
|
1726
|
+
"ALPHA_BITS",
|
|
1727
|
+
"DEPTH_BITS",
|
|
1728
|
+
"STENCIL_BITS"
|
|
1729
|
+
]) {
|
|
1730
|
+
const constant = gl[name];
|
|
1731
|
+
if (typeof constant !== "number") continue;
|
|
1732
|
+
const value = attempt(() => gl.getParameter(constant));
|
|
1733
|
+
if (value !== void 0 && value !== null) {
|
|
1734
|
+
parameters[name] = ArrayBuffer.isView(value) ? Array.from(value) : value;
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
const precisions = [];
|
|
1738
|
+
for (const shader of [gl.VERTEX_SHADER, gl.FRAGMENT_SHADER]) {
|
|
1739
|
+
for (const precision of [gl.LOW_FLOAT, gl.MEDIUM_FLOAT, gl.HIGH_FLOAT]) {
|
|
1740
|
+
const format = attempt(() => gl.getShaderPrecisionFormat(shader, precision));
|
|
1741
|
+
if (format) precisions.push(format.rangeMin, format.rangeMax, format.precision);
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
return compact({
|
|
1745
|
+
vendor: attempt(() => gl.getParameter(gl.VENDOR)),
|
|
1746
|
+
renderer: attempt(() => gl.getParameter(gl.RENDERER)),
|
|
1747
|
+
unmasked_vendor: debug ? attempt(() => gl.getParameter(debug.UNMASKED_VENDOR_WEBGL)) : void 0,
|
|
1748
|
+
unmasked_renderer: debug ? attempt(() => gl.getParameter(debug.UNMASKED_RENDERER_WEBGL)) : void 0,
|
|
1749
|
+
version: attempt(() => gl.getParameter(gl.VERSION)),
|
|
1750
|
+
shading_language_version: attempt(
|
|
1751
|
+
() => gl.getParameter(gl.SHADING_LANGUAGE_VERSION)
|
|
1752
|
+
),
|
|
1753
|
+
max_texture_size: attempt(() => gl.getParameter(gl.MAX_TEXTURE_SIZE)),
|
|
1754
|
+
max_render_buffer_size: attempt(() => gl.getParameter(gl.MAX_RENDERBUFFER_SIZE)),
|
|
1755
|
+
parameters_hash: Object.keys(parameters).length > 0 ? hash64(JSON.stringify(parameters)) : void 0,
|
|
1756
|
+
shader_precision_hash: precisions.length > 0 ? hash64(precisions.join(",")) : void 0
|
|
1757
|
+
});
|
|
1758
|
+
} finally {
|
|
1759
|
+
attempt(() => gl.getExtension("WEBGL_lose_context")?.loseContext());
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
};
|
|
1763
|
+
var webglExtensionsSource = {
|
|
1764
|
+
id: SOURCE.webglExtensions,
|
|
1765
|
+
stage: "collect",
|
|
1766
|
+
timeoutMs: 200,
|
|
1767
|
+
run() {
|
|
1768
|
+
const gl = webglContext();
|
|
1769
|
+
try {
|
|
1770
|
+
const extensions = gl.getSupportedExtensions();
|
|
1771
|
+
if (!extensions) throw new BlockedSignal("extensions-withheld");
|
|
1772
|
+
return [...extensions].sort();
|
|
1773
|
+
} finally {
|
|
1774
|
+
attempt(() => gl.getExtension("WEBGL_lose_context")?.loseContext());
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1357
1778
|
var VENDOR_API_MS = 50;
|
|
1358
1779
|
var TIMED_OUT = /* @__PURE__ */ Symbol("timed-out");
|
|
1359
1780
|
async function askBrave(nav) {
|
|
1360
|
-
|
|
1781
|
+
const brave = attempt(() => nav.brave);
|
|
1782
|
+
if (brave === void 0 || brave === null) return "absent";
|
|
1783
|
+
const isBrave = attempt(() => brave.isBrave);
|
|
1784
|
+
if (typeof isBrave !== "function") return "not-function";
|
|
1361
1785
|
try {
|
|
1362
1786
|
const answer = await Promise.race([
|
|
1363
|
-
|
|
1787
|
+
isBrave.call(brave),
|
|
1364
1788
|
new Promise((resolve) => setTimeout(() => resolve(TIMED_OUT), VENDOR_API_MS))
|
|
1365
1789
|
]);
|
|
1366
|
-
|
|
1790
|
+
if (answer === TIMED_OUT) return "timeout";
|
|
1791
|
+
return answer === true ? "true" : "false";
|
|
1367
1792
|
} catch {
|
|
1368
|
-
return
|
|
1793
|
+
return "threw";
|
|
1369
1794
|
}
|
|
1370
1795
|
}
|
|
1371
|
-
function
|
|
1372
|
-
const brands = nav.userAgentData?.brands;
|
|
1796
|
+
function brandsOf(nav) {
|
|
1797
|
+
const brands = attempt(() => nav.userAgentData?.brands);
|
|
1373
1798
|
if (!Array.isArray(brands)) return void 0;
|
|
1374
|
-
return brands.
|
|
1799
|
+
return brands.map((entry) => attempt(() => entry?.brand)).filter((brand) => typeof brand === "string");
|
|
1375
1800
|
}
|
|
1376
1801
|
var CANARY_COLOURS = [
|
|
1377
1802
|
[30, 60, 90],
|
|
1378
1803
|
[210, 180, 140]
|
|
1379
1804
|
];
|
|
1380
1805
|
var CANARY_SIZE = 8;
|
|
1381
|
-
function
|
|
1806
|
+
function readCanary(ctx) {
|
|
1382
1807
|
if (typeof document === "undefined") return void 0;
|
|
1383
1808
|
try {
|
|
1384
|
-
const
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
const context = canvas.getContext("2d", { willReadFrequently: true });
|
|
1388
|
-
if (!context) return void 0;
|
|
1809
|
+
const pair = acquireCanvas2D(ctx, CANARY_SIZE, CANARY_SIZE);
|
|
1810
|
+
if (!pair) return void 0;
|
|
1811
|
+
const [, context] = pair;
|
|
1389
1812
|
for (let y = 0; y < CANARY_SIZE; y++) {
|
|
1390
1813
|
for (let x = 0; x < CANARY_SIZE; x++) {
|
|
1391
1814
|
const [r, g, b] = CANARY_COLOURS[(x + y) % 2];
|
|
@@ -1394,31 +1817,51 @@ function canvasNoise() {
|
|
|
1394
1817
|
}
|
|
1395
1818
|
}
|
|
1396
1819
|
const pixels = context.getImageData(0, 0, CANARY_SIZE, CANARY_SIZE).data;
|
|
1397
|
-
|
|
1820
|
+
let mismatched = 0;
|
|
1821
|
+
let maxDelta = 0;
|
|
1822
|
+
const total = CANARY_SIZE * CANARY_SIZE;
|
|
1823
|
+
for (let index = 0; index < total; index++) {
|
|
1398
1824
|
const x = index % CANARY_SIZE;
|
|
1399
1825
|
const y = Math.floor(index / CANARY_SIZE);
|
|
1400
1826
|
const [r, g, b] = CANARY_COLOURS[(x + y) % 2];
|
|
1401
1827
|
const at = index * 4;
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1828
|
+
const deltas = [
|
|
1829
|
+
Math.abs((pixels[at] ?? 0) - r),
|
|
1830
|
+
Math.abs((pixels[at + 1] ?? 0) - g),
|
|
1831
|
+
Math.abs((pixels[at + 2] ?? 0) - b),
|
|
1832
|
+
Math.abs((pixels[at + 3] ?? 0) - 255)
|
|
1833
|
+
];
|
|
1834
|
+
const worst = Math.max(...deltas);
|
|
1835
|
+
if (worst > 0) mismatched += 1;
|
|
1836
|
+
if (worst > maxDelta) maxDelta = worst;
|
|
1405
1837
|
}
|
|
1406
|
-
return
|
|
1838
|
+
return { pixels: total, mismatched, maxDelta };
|
|
1407
1839
|
} catch {
|
|
1408
1840
|
return void 0;
|
|
1409
1841
|
}
|
|
1410
1842
|
}
|
|
1411
1843
|
var shieldsSource = {
|
|
1412
1844
|
id: SOURCE.shields,
|
|
1413
|
-
|
|
1845
|
+
stage: "collect",
|
|
1414
1846
|
timeoutMs: 100,
|
|
1415
|
-
async run() {
|
|
1847
|
+
async run(ctx) {
|
|
1848
|
+
if (isRfpCanvasBlocked(ctx)) {
|
|
1849
|
+
throw new BlockedSignal("rfp-canvas-prompt-avoided");
|
|
1850
|
+
}
|
|
1416
1851
|
if (typeof navigator === "undefined") throw new UnsupportedSignal("no-navigator");
|
|
1417
1852
|
const nav = navigator;
|
|
1853
|
+
const braveApi = await askBrave(nav);
|
|
1854
|
+
const brands = brandsOf(nav);
|
|
1855
|
+
const canary = readCanary(ctx);
|
|
1418
1856
|
return compact({
|
|
1419
|
-
brave:
|
|
1420
|
-
brave_claimed:
|
|
1421
|
-
canvas_noise:
|
|
1857
|
+
brave: braveApi === "true" ? true : braveApi === "false" ? false : void 0,
|
|
1858
|
+
brave_claimed: brands === void 0 ? void 0 : brands.includes("Brave"),
|
|
1859
|
+
canvas_noise: canary === void 0 ? void 0 : canary.mismatched > 0,
|
|
1860
|
+
brave_api: braveApi,
|
|
1861
|
+
brands,
|
|
1862
|
+
canary_pixels: canary?.pixels,
|
|
1863
|
+
canary_mismatched: canary?.mismatched,
|
|
1864
|
+
canary_max_delta: canary?.maxDelta
|
|
1422
1865
|
});
|
|
1423
1866
|
}
|
|
1424
1867
|
};
|
|
@@ -1488,7 +1931,7 @@ function serviceWorkerAvailable() {
|
|
|
1488
1931
|
}
|
|
1489
1932
|
var storageSource = {
|
|
1490
1933
|
id: SOURCE.storage,
|
|
1491
|
-
|
|
1934
|
+
stage: "collect",
|
|
1492
1935
|
timeoutMs: 250,
|
|
1493
1936
|
async run() {
|
|
1494
1937
|
requireWindow();
|
|
@@ -1531,7 +1974,7 @@ var storageSource = {
|
|
|
1531
1974
|
};
|
|
1532
1975
|
var storageQuotaSource = {
|
|
1533
1976
|
id: SOURCE.storageQuota,
|
|
1534
|
-
|
|
1977
|
+
stage: "collect",
|
|
1535
1978
|
run() {
|
|
1536
1979
|
requireWindow();
|
|
1537
1980
|
if (typeof document === "undefined") throw new UnsupportedSignal("no-document");
|
|
@@ -1640,10 +2083,10 @@ var CANDIDATES = [
|
|
|
1640
2083
|
];
|
|
1641
2084
|
var fontsSource = {
|
|
1642
2085
|
id: SOURCE.fonts,
|
|
1643
|
-
|
|
2086
|
+
stage: "collect",
|
|
1644
2087
|
// Generous: this measures ~300 spans, and forcing layout on a busy page is
|
|
1645
2088
|
// genuinely slow. Still bounded, which is the part that matters.
|
|
1646
|
-
timeoutMs:
|
|
2089
|
+
timeoutMs: 250,
|
|
1647
2090
|
run() {
|
|
1648
2091
|
if (typeof document === "undefined") throw new UnsupportedSignal("no-document");
|
|
1649
2092
|
const holder = document.createElement("div");
|
|
@@ -1688,7 +2131,7 @@ var fontsSource = {
|
|
|
1688
2131
|
};
|
|
1689
2132
|
var fontPreferencesSource = {
|
|
1690
2133
|
id: SOURCE.fontPreferences,
|
|
1691
|
-
|
|
2134
|
+
stage: "collect",
|
|
1692
2135
|
timeoutMs: 250,
|
|
1693
2136
|
run() {
|
|
1694
2137
|
if (typeof document === "undefined" || !document.body) {
|
|
@@ -1725,17 +2168,229 @@ var fontPreferencesSource = {
|
|
|
1725
2168
|
}
|
|
1726
2169
|
}
|
|
1727
2170
|
};
|
|
2171
|
+
var WORKER_WAIT_MS = 330;
|
|
2172
|
+
var WORKER_WAIT_FLOOR_MS = 60;
|
|
2173
|
+
var WORKER_WAIT_MARGIN_MS = 15;
|
|
2174
|
+
function workerWaitMs(budgetRemainingMs) {
|
|
2175
|
+
const left = Number.isFinite(budgetRemainingMs) ? budgetRemainingMs - WORKER_WAIT_MARGIN_MS : WORKER_WAIT_MS;
|
|
2176
|
+
return Math.max(WORKER_WAIT_FLOOR_MS, Math.min(WORKER_WAIT_MS, left));
|
|
2177
|
+
}
|
|
2178
|
+
var sessionCspBlocked;
|
|
2179
|
+
function workerScript(full) {
|
|
2180
|
+
return `(function (full) {
|
|
2181
|
+
var out = {};
|
|
2182
|
+
try {
|
|
2183
|
+
if (typeof navigator !== 'undefined') {
|
|
2184
|
+
if (typeof navigator.userAgent === 'string') out.user_agent = navigator.userAgent;
|
|
2185
|
+
if (typeof navigator.platform === 'string') out.platform = navigator.platform;
|
|
2186
|
+
if (full && typeof navigator.hardwareConcurrency === 'number') out.hardware_concurrency = navigator.hardwareConcurrency;
|
|
2187
|
+
if (full && typeof navigator.deviceMemory === 'number') out.device_memory = navigator.deviceMemory;
|
|
2188
|
+
if (full && Array.isArray(navigator.languages)) out.languages = Array.prototype.slice.call(navigator.languages);
|
|
2189
|
+
}
|
|
2190
|
+
} catch (_) {}
|
|
2191
|
+
if (!full) { self.postMessage(out); return; }
|
|
2192
|
+
try {
|
|
2193
|
+
var tz0 = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
2194
|
+
if (typeof tz0 === 'string' && tz0) out.timezone = tz0;
|
|
2195
|
+
} catch (_) {}
|
|
2196
|
+
// The navigator values first: a first WebGL context can take longer than
|
|
2197
|
+
// the whole collection budget on a cold page.
|
|
2198
|
+
self.postMessage({ partial: true, values: out });
|
|
2199
|
+
try {
|
|
2200
|
+
if (typeof OffscreenCanvas !== 'undefined') {
|
|
2201
|
+
var canvas = new OffscreenCanvas(1, 1);
|
|
2202
|
+
var gl = canvas.getContext('webgl') || canvas.getContext('webgl2');
|
|
2203
|
+
if (gl) {
|
|
2204
|
+
try {
|
|
2205
|
+
var dbg = gl.getExtension('WEBGL_debug_renderer_info');
|
|
2206
|
+
if (dbg) {
|
|
2207
|
+
var vendor = gl.getParameter(dbg.UNMASKED_VENDOR_WEBGL);
|
|
2208
|
+
var renderer = gl.getParameter(dbg.UNMASKED_RENDERER_WEBGL);
|
|
2209
|
+
if (typeof vendor === 'string' && vendor) out.unmasked_vendor = vendor;
|
|
2210
|
+
if (typeof renderer === 'string' && renderer) out.unmasked_renderer = renderer;
|
|
2211
|
+
}
|
|
2212
|
+
} finally {
|
|
2213
|
+
try {
|
|
2214
|
+
var lose = gl.getExtension('WEBGL_lose_context');
|
|
2215
|
+
if (lose && typeof lose.loseContext === 'function') lose.loseContext();
|
|
2216
|
+
} catch (_) {}
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
} catch (_) {}
|
|
2221
|
+
self.postMessage(out);
|
|
2222
|
+
})(${full ? "true" : "false"});`;
|
|
2223
|
+
}
|
|
2224
|
+
function policyAllowsBlobWorker(policyText) {
|
|
2225
|
+
const directives = /* @__PURE__ */ new Map();
|
|
2226
|
+
for (const rawPart of policyText.split(";")) {
|
|
2227
|
+
const trimmed = rawPart.trim();
|
|
2228
|
+
if (!trimmed) continue;
|
|
2229
|
+
const tokens = trimmed.split(/\s+/).map((token) => token.toLowerCase());
|
|
2230
|
+
const name = tokens[0];
|
|
2231
|
+
if (name && !directives.has(name)) {
|
|
2232
|
+
directives.set(name, tokens.slice(1));
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
const effective = directives.get("worker-src") ?? directives.get("child-src") ?? directives.get("default-src");
|
|
2236
|
+
if (!effective) return true;
|
|
2237
|
+
return effective.some((token) => token === "blob:" || token.startsWith("blob:"));
|
|
2238
|
+
}
|
|
2239
|
+
function headMetaDisallowsBlobWorker(doc) {
|
|
2240
|
+
const head = attempt(() => doc?.head);
|
|
2241
|
+
if (!head) return false;
|
|
2242
|
+
const children = attempt(() => Array.from(head.children));
|
|
2243
|
+
if (!children) return false;
|
|
2244
|
+
for (const meta of children) {
|
|
2245
|
+
if (attempt(() => meta.tagName.toLowerCase()) !== "meta") continue;
|
|
2246
|
+
const equiv = attempt(() => meta.getAttribute("http-equiv")?.trim().toLowerCase());
|
|
2247
|
+
if (equiv !== "content-security-policy") continue;
|
|
2248
|
+
const content = attempt(() => meta.getAttribute("content"));
|
|
2249
|
+
if (typeof content === "string" && !policyAllowsBlobWorker(content)) {
|
|
2250
|
+
return true;
|
|
2251
|
+
}
|
|
2252
|
+
}
|
|
2253
|
+
return false;
|
|
2254
|
+
}
|
|
2255
|
+
function isCspSecurityError(error) {
|
|
2256
|
+
if (!(error instanceof Error)) return false;
|
|
2257
|
+
if (error.name === "SecurityError") return true;
|
|
2258
|
+
const msg = error.message.toLowerCase();
|
|
2259
|
+
return msg.includes("content security policy") || msg.includes("securityerror");
|
|
2260
|
+
}
|
|
2261
|
+
function normalizeWorkerPayload(raw, full) {
|
|
2262
|
+
if (!raw || typeof raw !== "object") return {};
|
|
2263
|
+
const data = raw;
|
|
2264
|
+
const user_agent = typeof data.user_agent === "string" ? data.user_agent : void 0;
|
|
2265
|
+
const platform = typeof data.platform === "string" ? data.platform : void 0;
|
|
2266
|
+
if (!full) return compact({ user_agent, platform });
|
|
2267
|
+
return compact({
|
|
2268
|
+
user_agent,
|
|
2269
|
+
platform,
|
|
2270
|
+
hardware_concurrency: typeof data.hardware_concurrency === "number" && Number.isFinite(data.hardware_concurrency) ? data.hardware_concurrency : void 0,
|
|
2271
|
+
device_memory: typeof data.device_memory === "number" && Number.isFinite(data.device_memory) ? data.device_memory : void 0,
|
|
2272
|
+
languages: Array.isArray(data.languages) ? data.languages.filter((item) => typeof item === "string") : void 0,
|
|
2273
|
+
timezone: typeof data.timezone === "string" ? data.timezone : void 0,
|
|
2274
|
+
unmasked_vendor: typeof data.unmasked_vendor === "string" ? data.unmasked_vendor : void 0,
|
|
2275
|
+
unmasked_renderer: typeof data.unmasked_renderer === "string" ? data.unmasked_renderer : void 0,
|
|
2276
|
+
gpu_unanswered: data.gpu_unanswered === true ? true : void 0
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
var workerRealmSource = {
|
|
2280
|
+
id: SOURCE.workerRealm,
|
|
2281
|
+
stage: "collect",
|
|
2282
|
+
embeddedSafe: true,
|
|
2283
|
+
timeoutMs: WORKER_WAIT_MS + WORKER_WAIT_MARGIN_MS + 5,
|
|
2284
|
+
async run(ctx) {
|
|
2285
|
+
const w = requireWindow();
|
|
2286
|
+
const doc = attempt(() => w.document);
|
|
2287
|
+
if (sessionCspBlocked) {
|
|
2288
|
+
throw new BlockedSignal(sessionCspBlocked);
|
|
2289
|
+
}
|
|
2290
|
+
if (typeof Worker !== "function" || typeof Blob !== "function" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function" || typeof URL.revokeObjectURL !== "function") {
|
|
2291
|
+
throw new UnsupportedSignal("no-worker");
|
|
2292
|
+
}
|
|
2293
|
+
const refusal = headMetaDisallowsBlobWorker(doc) ? "csp-meta" : "csp-blocked";
|
|
2294
|
+
const refused = () => {
|
|
2295
|
+
sessionCspBlocked = refusal;
|
|
2296
|
+
return new BlockedSignal(refusal);
|
|
2297
|
+
};
|
|
2298
|
+
const full = !detectEmbedding();
|
|
2299
|
+
const blobUrl = URL.createObjectURL(new Blob([workerScript(full)], { type: "text/javascript" }));
|
|
2300
|
+
let worker;
|
|
2301
|
+
let onCspViolation;
|
|
2302
|
+
try {
|
|
2303
|
+
try {
|
|
2304
|
+
worker = new Worker(blobUrl);
|
|
2305
|
+
} catch (error) {
|
|
2306
|
+
if (isCspSecurityError(error)) throw refused();
|
|
2307
|
+
throw error;
|
|
2308
|
+
}
|
|
2309
|
+
const activeWorker = worker;
|
|
2310
|
+
const raw = await new Promise((resolve, reject) => {
|
|
2311
|
+
let settled = false;
|
|
2312
|
+
const settle = (fn) => {
|
|
2313
|
+
if (settled) return;
|
|
2314
|
+
settled = true;
|
|
2315
|
+
clearTimeout(timer);
|
|
2316
|
+
ctx.signal?.removeEventListener("abort", onAbort);
|
|
2317
|
+
if (doc && onCspViolation) {
|
|
2318
|
+
doc.removeEventListener("securitypolicyviolation", onCspViolation);
|
|
2319
|
+
}
|
|
2320
|
+
fn();
|
|
2321
|
+
};
|
|
2322
|
+
const onAbort = () => settle(() => reject(ctx.signal?.reason ?? new TimedOutSignal("aborted")));
|
|
2323
|
+
let partial;
|
|
2324
|
+
const timer = setTimeout(() => {
|
|
2325
|
+
setTimeout(
|
|
2326
|
+
() => settle(
|
|
2327
|
+
() => partial ? resolve({ ...partial, gpu_unanswered: true }) : reject(new TimedOutSignal("worker-timeout"))
|
|
2328
|
+
),
|
|
2329
|
+
0
|
|
2330
|
+
);
|
|
2331
|
+
}, workerWaitMs(attempt(() => ctx.budgetRemainingMs()) ?? WORKER_WAIT_MS));
|
|
2332
|
+
ctx.signal?.addEventListener("abort", onAbort, { once: true });
|
|
2333
|
+
onCspViolation = (event) => {
|
|
2334
|
+
const spv = event;
|
|
2335
|
+
const directive = (spv.effectiveDirective || spv.violatedDirective || "").toLowerCase();
|
|
2336
|
+
const blockedUri = (spv.blockedURI || "").toLowerCase();
|
|
2337
|
+
if (blockedUri.startsWith("blob") || directive.startsWith("worker-src") || directive.startsWith("child-src") || directive.startsWith("default-src")) {
|
|
2338
|
+
settle(() => reject(refused()));
|
|
2339
|
+
}
|
|
2340
|
+
};
|
|
2341
|
+
doc?.addEventListener("securitypolicyviolation", onCspViolation);
|
|
2342
|
+
activeWorker.onmessage = (event) => {
|
|
2343
|
+
const data = event?.data;
|
|
2344
|
+
if (data && data.partial === true) {
|
|
2345
|
+
partial = data.values && typeof data.values === "object" ? data.values : {};
|
|
2346
|
+
return;
|
|
2347
|
+
}
|
|
2348
|
+
settle(() => resolve(event?.data));
|
|
2349
|
+
};
|
|
2350
|
+
activeWorker.onerror = (event) => {
|
|
2351
|
+
event?.preventDefault?.();
|
|
2352
|
+
const message = String(event?.message ?? "").toLowerCase();
|
|
2353
|
+
if (refusal === "csp-meta" || message.includes("content security policy") || message.includes("securityerror")) {
|
|
2354
|
+
settle(() => reject(refused()));
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
settle(() => reject(new BlockedSignal("worker-error")));
|
|
2358
|
+
};
|
|
2359
|
+
});
|
|
2360
|
+
return normalizeWorkerPayload(raw, full);
|
|
2361
|
+
} finally {
|
|
2362
|
+
if (doc && onCspViolation) {
|
|
2363
|
+
attempt(() => doc.removeEventListener("securitypolicyviolation", onCspViolation));
|
|
2364
|
+
}
|
|
2365
|
+
attempt(() => worker?.terminate());
|
|
2366
|
+
attempt(() => URL.revokeObjectURL(blobUrl));
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
};
|
|
1728
2370
|
|
|
1729
2371
|
// src/sources/index.ts
|
|
1730
|
-
|
|
1731
|
-
|
|
2372
|
+
function guarded(source) {
|
|
2373
|
+
const safeInEmbedded = own(source, "embeddedSafe") === true || EMBEDDED_SAFE_SOURCES.has(source.id);
|
|
2374
|
+
return {
|
|
2375
|
+
...source,
|
|
2376
|
+
run: (ctx) => {
|
|
2377
|
+
if (!safeInEmbedded && detectEmbedding()) throw new UnsupportedSignal("embedded");
|
|
2378
|
+
return source.run(ctx);
|
|
2379
|
+
}
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2382
|
+
var allBrowserSources = [
|
|
2383
|
+
// Stage 1: prerequisite barrier (completes before shields & canvas run)
|
|
1732
2384
|
engineSource,
|
|
2385
|
+
timingSource,
|
|
2386
|
+
// Stage 2: single-pass collect
|
|
1733
2387
|
errorsSource,
|
|
1734
2388
|
mathSource,
|
|
1735
2389
|
navigatorSource,
|
|
1736
2390
|
languagesSource,
|
|
1737
|
-
pluginsSource,
|
|
1738
2391
|
vendorSource,
|
|
2392
|
+
userAgentDataSource,
|
|
2393
|
+
workerRealmSource,
|
|
1739
2394
|
screenSource,
|
|
1740
2395
|
screenFrameSource,
|
|
1741
2396
|
mediaQueriesSource,
|
|
@@ -1747,26 +2402,20 @@ var browserSources = [
|
|
|
1747
2402
|
timezoneSource,
|
|
1748
2403
|
storageSource,
|
|
1749
2404
|
storageQuotaSource,
|
|
2405
|
+
storageDurabilitySource,
|
|
1750
2406
|
shieldsSource,
|
|
1751
|
-
timingSource,
|
|
1752
2407
|
permissionsSource,
|
|
1753
2408
|
automationSource,
|
|
1754
2409
|
webglSource,
|
|
2410
|
+
webglExtensionsSource,
|
|
1755
2411
|
mediaDevicesSource,
|
|
1756
|
-
// deferred
|
|
1757
2412
|
canvasSource,
|
|
1758
|
-
webglExtensionsSource,
|
|
1759
2413
|
audioSource,
|
|
1760
2414
|
audioLatencySource,
|
|
1761
2415
|
fontsSource,
|
|
1762
|
-
fontPreferencesSource
|
|
1763
|
-
batterySource,
|
|
1764
|
-
speechSource,
|
|
1765
|
-
sensorsSource,
|
|
1766
|
-
userAgentDataSource,
|
|
1767
|
-
domBlockersSource,
|
|
1768
|
-
storageDurabilitySource
|
|
2416
|
+
fontPreferencesSource
|
|
1769
2417
|
];
|
|
2418
|
+
var browserSources = allBrowserSources.map(guarded);
|
|
1770
2419
|
function load(options) {
|
|
1771
2420
|
return new Promise(
|
|
1772
2421
|
(resolve) => resolve(
|
|
@@ -1774,10 +2423,11 @@ function load(options) {
|
|
|
1774
2423
|
...options,
|
|
1775
2424
|
platform: "web",
|
|
1776
2425
|
sources: options.sources ?? browserSources,
|
|
1777
|
-
integrity: (report) => inspectIntegrity(report.sources)
|
|
2426
|
+
integrity: (report) => inspectIntegrity(report.sources),
|
|
2427
|
+
embedding: () => detectEmbedding()
|
|
1778
2428
|
})
|
|
1779
2429
|
)
|
|
1780
2430
|
);
|
|
1781
2431
|
}
|
|
1782
2432
|
|
|
1783
|
-
export { browserSources, inspectIntegrity, load };
|
|
2433
|
+
export { browserSources, detectEmbedding, inspectIntegrity, load };
|