device-passport 1.0.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +110 -2
  3. package/assets/ego-profile-manager.png +0 -0
  4. package/dist/adapters/index.cjs +19 -0
  5. package/dist/adapters/index.d.cts +66 -0
  6. package/dist/adapters/index.d.mts +66 -0
  7. package/dist/adapters/index.d.ts +66 -0
  8. package/dist/adapters/index.mjs +3 -0
  9. package/dist/ego/index.cjs +22 -0
  10. package/dist/ego/index.d.cts +5 -0
  11. package/dist/ego/index.d.mts +5 -0
  12. package/dist/ego/index.d.ts +5 -0
  13. package/dist/ego/index.mjs +8 -0
  14. package/dist/evaluator/index.cjs +140 -0
  15. package/dist/evaluator/index.d.cts +204 -0
  16. package/dist/evaluator/index.d.mts +204 -0
  17. package/dist/evaluator/index.d.ts +204 -0
  18. package/dist/evaluator/index.mjs +119 -0
  19. package/dist/geo/index.cjs +50 -0
  20. package/dist/geo/index.d.cts +213 -0
  21. package/dist/geo/index.d.mts +213 -0
  22. package/dist/geo/index.d.ts +213 -0
  23. package/dist/geo/index.mjs +18 -0
  24. package/dist/index.cjs +110 -3940
  25. package/dist/index.d.cts +45 -1091
  26. package/dist/index.d.mts +45 -1091
  27. package/dist/index.d.ts +45 -1091
  28. package/dist/index.mjs +11 -3849
  29. package/dist/shared/device-passport.BGfRcQNh.mjs +565 -0
  30. package/dist/shared/device-passport.BKtmLzPt.cjs +1266 -0
  31. package/dist/shared/device-passport.BPQj0qdT.mjs +1238 -0
  32. package/dist/shared/device-passport.CDS7xrj8.d.ts +469 -0
  33. package/dist/shared/device-passport.C_F1vBE8.d.cts +79 -0
  34. package/dist/shared/device-passport.C_F1vBE8.d.mts +79 -0
  35. package/dist/shared/device-passport.C_F1vBE8.d.ts +79 -0
  36. package/dist/shared/device-passport.CfLes-lq.d.cts +469 -0
  37. package/dist/shared/device-passport.Cjxlv8xI.cjs +245 -0
  38. package/dist/shared/device-passport.CsOWqPIr.d.cts +77 -0
  39. package/dist/shared/device-passport.CyQtcZeD.mjs +237 -0
  40. package/dist/shared/device-passport.D7pEnyp2.d.ts +77 -0
  41. package/dist/shared/device-passport.D9xW6R0B.cjs +1571 -0
  42. package/dist/shared/device-passport.DirQmSd4.d.cts +47 -0
  43. package/dist/shared/device-passport.DirQmSd4.d.mts +47 -0
  44. package/dist/shared/device-passport.DirQmSd4.d.ts +47 -0
  45. package/dist/shared/device-passport.EK4RX7Xd.cjs +584 -0
  46. package/dist/shared/device-passport.ZBspe4ZW.d.mts +77 -0
  47. package/dist/shared/device-passport.dVEqzSEb.d.mts +469 -0
  48. package/dist/shared/device-passport.gNo82fQ5.mjs +1537 -0
  49. package/dist/shared/device-passport.kekU28UM.mjs +705 -0
  50. package/dist/shared/device-passport.qL4tjwc0.cjs +718 -0
  51. package/dist/storage/index.cjs +10 -0
  52. package/dist/storage/index.d.cts +97 -0
  53. package/dist/storage/index.d.mts +97 -0
  54. package/dist/storage/index.d.ts +97 -0
  55. package/dist/storage/index.mjs +3 -0
  56. package/dist/types/index.cjs +2 -0
  57. package/dist/types/index.d.cts +397 -0
  58. package/dist/types/index.d.mts +397 -0
  59. package/dist/types/index.d.ts +397 -0
  60. package/dist/types/index.mjs +1 -0
  61. package/package.json +32 -2
package/dist/index.mjs CHANGED
@@ -1,3851 +1,13 @@
1
- import { createHash } from 'node:crypto';
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
-
5
- const CANONICAL_HEADER_ORDER = [
6
- // HTTP/2 Pseudo-headers (if provided)
7
- ":method",
8
- ":authority",
9
- ":scheme",
10
- ":path",
11
- // Client Hints block (low-entropy)
12
- "sec-ch-ua",
13
- "sec-ch-ua-mobile",
14
- "sec-ch-ua-platform",
15
- // Upgrade requests
16
- "upgrade-insecure-requests",
17
- // User-Agent
18
- "user-agent",
19
- // Accept
20
- "accept",
21
- // Sec-Fetch-* metadata block
22
- "sec-fetch-site",
23
- "sec-fetch-mode",
24
- "sec-fetch-user",
25
- "sec-fetch-dest",
26
- // Client Hints high-entropy hints
27
- "sec-ch-ua-arch",
28
- "sec-ch-ua-bitness",
29
- "sec-ch-ua-model",
30
- "sec-ch-ua-platform-version",
31
- "sec-ch-ua-full-version-list",
32
- "sec-ch-ua-wow64",
33
- // Navigation context
34
- "referer",
35
- "origin",
36
- // Encoding & Localization
37
- "accept-encoding",
38
- "accept-language",
39
- // Chromium priority hint
40
- "priority",
41
- // Stateful session headers
42
- "cookie",
43
- "authorization",
44
- "connection",
45
- "cache-control",
46
- "pragma"
47
- ];
48
- function formatCanonicalHeaders(baseHeaders, overrides) {
49
- const merged = {};
50
- for (const [key, val] of Object.entries(baseHeaders)) {
51
- if (val !== void 0 && val !== null) {
52
- merged[key.toLowerCase()] = String(val);
53
- }
54
- }
55
- if (overrides) {
56
- for (const [key, val] of Object.entries(overrides)) {
57
- if (val !== void 0 && val !== null) {
58
- merged[key.toLowerCase()] = String(val);
59
- }
60
- }
61
- }
62
- const ordered = {};
63
- for (const canonicalKey of CANONICAL_HEADER_ORDER) {
64
- if (canonicalKey in merged) {
65
- ordered[canonicalKey] = merged[canonicalKey];
66
- delete merged[canonicalKey];
67
- }
68
- }
69
- for (const [remainingKey, val] of Object.entries(merged)) {
70
- ordered[remainingKey] = val;
71
- }
72
- return ordered;
73
- }
74
- function normalizeHeadersInput(headers) {
75
- if (!headers) return {};
76
- if (typeof Headers !== "undefined" && headers instanceof Headers) {
77
- const res = {};
78
- headers.forEach((val, key) => {
79
- res[key] = val;
80
- });
81
- return res;
82
- }
83
- if (Array.isArray(headers)) {
84
- const res = {};
85
- for (const [k, v] of headers) {
86
- res[k] = v;
87
- }
88
- return res;
89
- }
90
- return { ...headers };
91
- }
92
- function withPassport(passport, customFetch) {
93
- const fetchImpl = customFetch ?? (typeof globalThis.fetch !== "undefined" ? globalThis.fetch : void 0);
94
- if (!fetchImpl) {
95
- throw new Error(
96
- "[device-passport] Global fetch is not available. Please pass a custom fetch implementation to withPassport(passport, customFetch)."
97
- );
98
- }
99
- return async function passportFetch(input, init) {
100
- const explicitHeaders = normalizeHeadersInput(init?.headers);
101
- const canonicalHeaders = typeof passport.getHeaders === "function" ? passport.getHeaders(explicitHeaders) : formatCanonicalHeaders(passport.headers, explicitHeaders);
102
- if (typeof Request !== "undefined" && input instanceof Request) {
103
- const requestHeaders = normalizeHeadersInput(input.headers);
104
- const mergedHeaders = formatCanonicalHeaders(canonicalHeaders, requestHeaders);
105
- const clonedInit = {
106
- ...init,
107
- headers: mergedHeaders
108
- };
109
- return fetchImpl(input, clonedInit);
110
- }
111
- return fetchImpl(input, {
112
- ...init,
113
- headers: canonicalHeaders
114
- });
115
- };
116
- }
117
- function toCurl(passport, url, options) {
118
- const method = options?.method?.toUpperCase() ?? "GET";
119
- const explicitHeaders = options?.headers ?? {};
120
- const canonicalHeaders = typeof passport.getHeaders === "function" ? passport.getHeaders(explicitHeaders) : formatCanonicalHeaders(passport.headers, explicitHeaders);
121
- const parts = ["curl", "-sSL"];
122
- if (method !== "GET") {
123
- parts.push(`-X ${method}`);
124
- }
125
- parts.push(`'${url}'`);
126
- for (const [k, v] of Object.entries(canonicalHeaders)) {
127
- const safeVal = String(v).replace(/'/g, `'\\''`);
128
- parts.push(`-H '${k}: ${safeVal}'`);
129
- }
130
- if (options?.data) {
131
- const payload = typeof options.data === "string" ? options.data : JSON.stringify(options.data);
132
- parts.push(`--data '${payload.replace(/'/g, `'\\''`)}'`);
133
- }
134
- return parts.join(" \\\n ");
135
- }
136
-
137
- function getPlaywrightContext(passport) {
138
- const headers = passport.context?.extraHTTPHeaders ?? passport.headers ?? {};
139
- const canonicalHeaders = formatCanonicalHeaders(headers);
140
- const width = passport.hardware?.screen?.width ?? passport.context?.viewport?.width ?? 1920;
141
- const height = passport.hardware?.screen?.height ?? passport.context?.viewport?.height ?? 1080;
142
- const dpr = passport.hardware?.screen?.dpr ?? passport.context?.deviceScaleFactor ?? 1;
143
- return {
144
- userAgent: passport.browser?.userAgent ?? passport.context?.userAgent,
145
- viewport: {
146
- width,
147
- height
148
- },
149
- deviceScaleFactor: dpr,
150
- locale: passport.locale?.language ?? passport.context?.locale ?? "en-US",
151
- timezoneId: passport.locale?.timezone ?? passport.context?.timezoneId ?? "America/New_York",
152
- geolocation: passport.context?.geolocation,
153
- permissions: passport.context?.permissions ?? ["geolocation"],
154
- extraHTTPHeaders: canonicalHeaders,
155
- hasTouch: passport.context?.hasTouch ?? false,
156
- isMobile: passport.context?.isMobile ?? false,
157
- colorScheme: passport.context?.colorScheme ?? "light"
158
- };
159
- }
160
- function getStealthScript(passport) {
161
- const { hardware, os, locale, browser, clientHints } = passport;
162
- const concurrency = hardware?.cpu?.concurrency ?? 8;
163
- const memory = hardware?.memory?.deviceMemory ?? 8;
164
- const screenWidth = hardware?.screen?.width ?? 1920;
165
- const screenHeight = hardware?.screen?.height ?? 1080;
166
- const availWidth = hardware?.screen?.availWidth ?? screenWidth;
167
- const availHeight = hardware?.screen?.availHeight ?? screenHeight - 40;
168
- const colorDepth = hardware?.screen?.colorDepth ?? 24;
169
- const pixelDepth = hardware?.screen?.pixelDepth ?? 24;
170
- const platform = os?.platform === "macOS" ? "MacIntel" : "Win32";
171
- const languages = JSON.stringify(locale?.languages ?? ["en-US", "en"]);
172
- const gpuVendor = hardware?.gpu?.vendor ?? "Google Inc. (Apple)";
173
- const gpuRenderer = hardware?.gpu?.renderer ?? "ANGLE (Apple, Apple M2, OpenGL 4.1)";
174
- const uachData = JSON.stringify({
175
- brands: clientHints?.brands ?? [
176
- { brand: "Chromium", version: String(browser?.majorVersion ?? 124) },
177
- { brand: "Google Chrome", version: String(browser?.majorVersion ?? 124) },
178
- { brand: "Not-A.Brand", version: "99" }
179
- ],
180
- mobile: clientHints?.mobile ?? false,
181
- platform: clientHints?.platform ?? (os?.platform ?? "macOS"),
182
- architecture: clientHints?.architecture ?? (os?.architecture ?? "arm"),
183
- bitness: clientHints?.bitness ?? "64",
184
- model: clientHints?.model ?? "",
185
- platformVersion: clientHints?.platformVersion ?? (os?.version ?? "14.6.1"),
186
- fullVersionList: clientHints?.fullVersionList ?? [
187
- { brand: "Chromium", version: browser?.version ?? "124.0.6367.208" },
188
- { brand: "Google Chrome", version: browser?.version ?? "124.0.6367.208" },
189
- { brand: "Not-A.Brand", version: "99.0.0.0" }
190
- ]
191
- });
192
- return `
193
- (() => {
194
- // 1. Remove automation flags
195
- try {
196
- Object.defineProperty(navigator, 'webdriver', {
197
- get: () => undefined,
198
- configurable: true
199
- });
200
- delete (navigator as any).__proto__.webdriver;
201
- } catch (e) {}
202
-
203
- // 2. Hardware profile (CPU, Memory)
204
- try {
205
- Object.defineProperty(navigator, 'hardwareConcurrency', {
206
- get: () => ${concurrency},
207
- configurable: true
208
- });
209
- Object.defineProperty(navigator, 'deviceMemory', {
210
- get: () => ${memory},
211
- configurable: true
212
- });
213
- } catch (e) {}
214
-
215
- // 3. Platform & Languages
216
- try {
217
- Object.defineProperty(navigator, 'platform', {
218
- get: () => '${platform}',
219
- configurable: true
220
- });
221
- const langs = ${languages};
222
- Object.defineProperty(navigator, 'languages', {
223
- get: () => langs,
224
- configurable: true
225
- });
226
- Object.defineProperty(navigator, 'language', {
227
- get: () => langs[0],
228
- configurable: true
229
- });
230
- } catch (e) {}
231
-
232
- // 4. Screen properties
233
- try {
234
- Object.defineProperty(window.screen, 'width', { get: () => ${screenWidth}, configurable: true });
235
- Object.defineProperty(window.screen, 'height', { get: () => ${screenHeight}, configurable: true });
236
- Object.defineProperty(window.screen, 'availWidth', { get: () => ${availWidth}, configurable: true });
237
- Object.defineProperty(window.screen, 'availHeight', { get: () => ${availHeight}, configurable: true });
238
- Object.defineProperty(window.screen, 'colorDepth', { get: () => ${colorDepth}, configurable: true });
239
- Object.defineProperty(window.screen, 'pixelDepth', { get: () => ${pixelDepth}, configurable: true });
240
- } catch (e) {}
241
-
242
- // 5. Client Hints (navigator.userAgentData)
243
- try {
244
- const hintData = ${uachData};
245
- if (typeof (navigator as any).userAgentData !== 'undefined' || true) {
246
- const uach = {
247
- brands: hintData.brands,
248
- mobile: hintData.mobile,
249
- platform: hintData.platform,
250
- getHighEntropyValues: async (hints) => {
251
- const res = {
252
- brands: hintData.brands,
253
- mobile: hintData.mobile,
254
- platform: hintData.platform,
255
- };
256
- if (hints.includes('architecture')) res.architecture = hintData.architecture;
257
- if (hints.includes('bitness')) res.bitness = hintData.bitness;
258
- if (hints.includes('model')) res.model = hintData.model;
259
- if (hints.includes('platformVersion')) res.platformVersion = hintData.platformVersion;
260
- if (hints.includes('fullVersionList')) res.fullVersionList = hintData.fullVersionList;
261
- return res;
262
- },
263
- toJSON: () => ({
264
- brands: hintData.brands,
265
- mobile: hintData.mobile,
266
- platform: hintData.platform,
267
- })
268
- };
269
- Object.defineProperty(navigator, 'userAgentData', {
270
- get: () => uach,
271
- configurable: true
272
- });
273
- }
274
- } catch (e) {}
275
-
276
- // 6. WebGL Vendor & Renderer spoofing
277
- try {
278
- const getParameterProto = WebGLRenderingContext.prototype.getParameter;
279
- const vendorParam = 0x9245; // UNMASKED_VENDOR_WEBGL
280
- const rendererParam = 0x9246; // UNMASKED_RENDERER_WEBGL
281
-
282
- WebGLRenderingContext.prototype.getParameter = function(parameter) {
283
- if (parameter === vendorParam) return '${gpuVendor}';
284
- if (parameter === rendererParam) return '${gpuRenderer}';
285
- return getParameterProto.apply(this, arguments);
286
- };
287
-
288
- if (typeof WebGL2RenderingContext !== 'undefined') {
289
- const getParameter2Proto = WebGL2RenderingContext.prototype.getParameter;
290
- WebGL2RenderingContext.prototype.getParameter = function(parameter) {
291
- if (parameter === vendorParam) return '${gpuVendor}';
292
- if (parameter === rendererParam) return '${gpuRenderer}';
293
- return getParameter2Proto.apply(this, arguments);
294
- };
295
- }
296
- } catch (e) {}
297
-
298
- // 7. Chrome runtime mock for Chromium personas
299
- try {
300
- if (!window.chrome) {
301
- (window as any).chrome = {
302
- app: { isInstalled: false, InstallState: { DISABLED: 'disabled', INSTALLED: 'installed', NOT_INSTALLED: 'not_installed' } },
303
- runtime: { OnInstalledReason: {}, OnRestartRequiredReason: {} },
304
- loadTimes: () => ({}),
305
- csi: () => ({}),
306
- };
307
- }
308
- } catch (e) {}
309
- })();
310
- `;
311
- }
312
- async function applyToPlaywrightContext(context, passport) {
313
- if (!context || typeof context.addInitScript !== "function") {
314
- throw new Error("[device-passport] Invalid Playwright context provided to applyToPlaywrightContext.");
315
- }
316
- const stealthScript = getStealthScript(passport);
317
- await context.addInitScript(stealthScript);
318
- const headers = passport.context?.extraHTTPHeaders ?? passport.headers ?? {};
319
- if (typeof context.setExtraHTTPHeaders === "function") {
320
- await context.setExtraHTTPHeaders(formatCanonicalHeaders(headers));
321
- }
322
- }
323
-
324
- function getPuppeteerArgs(passport) {
325
- const width = passport.hardware?.screen?.width ?? 1920;
326
- const height = passport.hardware?.screen?.height ?? 1080;
327
- const dpr = passport.hardware?.screen?.dpr ?? 1;
328
- const locale = passport.locale?.language ?? "en-US";
329
- const timezone = passport.locale?.timezone ?? "America/New_York";
330
- const userAgent = passport.browser?.userAgent ?? passport.context?.userAgent;
331
- const headers = passport.context?.extraHTTPHeaders ?? passport.headers ?? {};
332
- const canonicalHeaders = formatCanonicalHeaders(headers);
333
- const launchArgs = [
334
- `--user-agent=${userAgent}`,
335
- `--window-size=${width},${height}`,
336
- `--lang=${locale}`,
337
- "--disable-blink-features=AutomationControlled",
338
- "--no-default-browser-check"
339
- ];
340
- return {
341
- launchArgs,
342
- defaultViewport: {
343
- width,
344
- height,
345
- deviceScaleFactor: dpr,
346
- isMobile: passport.context?.isMobile ?? false,
347
- hasTouch: passport.context?.hasTouch ?? false
348
- },
349
- userAgent,
350
- locale,
351
- timezoneId: timezone,
352
- extraHTTPHeaders: canonicalHeaders
353
- };
354
- }
355
- async function applyToPuppeteerPage(page, passport) {
356
- if (!page || typeof page.evaluateOnNewDocument !== "function") {
357
- throw new Error("[device-passport] Invalid Puppeteer page provided to applyToPuppeteerPage.");
358
- }
359
- const { defaultViewport, userAgent, extraHTTPHeaders, timezoneId } = getPuppeteerArgs(passport);
360
- if (typeof page.setUserAgent === "function") {
361
- await page.setUserAgent(userAgent);
362
- }
363
- if (typeof page.setViewport === "function") {
364
- await page.setViewport(defaultViewport);
365
- }
366
- if (typeof page.setExtraHTTPHeaders === "function") {
367
- await page.setExtraHTTPHeaders(extraHTTPHeaders);
368
- }
369
- if (typeof page.emulateTimezone === "function") {
370
- try {
371
- await page.emulateTimezone(timezoneId);
372
- } catch {
373
- }
374
- }
375
- const stealthScript = getStealthScript(passport);
376
- await page.evaluateOnNewDocument(stealthScript);
377
- }
378
-
379
- const COUNTRY_TIMEZONE_MAP = {
380
- US: [
381
- "America/New_York",
382
- "America/Chicago",
383
- "America/Denver",
384
- "America/Los_Angeles",
385
- "America/Anchorage",
386
- "America/Phoenix",
387
- "America/Detroit",
388
- "America/Indiana/Indianapolis",
389
- "Pacific/Honolulu"
390
- ],
391
- CA: [
392
- "America/Toronto",
393
- "America/Vancouver",
394
- "America/Montreal",
395
- "America/Edmonton",
396
- "America/Winnipeg",
397
- "America/Halifax",
398
- "America/St_Johns"
399
- ],
400
- GB: ["Europe/London"],
401
- UK: ["Europe/London"],
402
- DE: ["Europe/Berlin"],
403
- FR: ["Europe/Paris"],
404
- JP: ["Asia/Tokyo"],
405
- CN: ["Asia/Shanghai", "Asia/Chongqing", "Asia/Urumqi", "Asia/Harbin"],
406
- AU: [
407
- "Australia/Sydney",
408
- "Australia/Melbourne",
409
- "Australia/Brisbane",
410
- "Australia/Perth",
411
- "Australia/Adelaide"
412
- ],
413
- SG: ["Asia/Singapore"],
414
- HK: ["Asia/Hong_Kong"],
415
- TW: ["Asia/Taipei"],
416
- KR: ["Asia/Seoul"],
417
- NL: ["Europe/Amsterdam"],
418
- SE: ["Europe/Stockholm"],
419
- CH: ["Europe/Zurich"],
420
- BR: ["America/Sao_Paulo", "America/Manaus", "America/Fortaleza"],
421
- IN: ["Asia/Kolkata"],
422
- RU: ["Europe/Moscow", "Asia/Yekaterinburg", "Asia/Novosibirsk", "Asia/Vladivostok"]
423
- };
424
- const COUNTRY_PRIMARY_LANGUAGES = {
425
- US: ["en", "en-US"],
426
- CA: ["en", "en-CA", "fr", "fr-CA"],
427
- GB: ["en", "en-GB"],
428
- UK: ["en", "en-GB"],
429
- DE: ["de", "de-DE"],
430
- FR: ["fr", "fr-FR"],
431
- JP: ["ja", "ja-JP"],
432
- CN: ["zh", "zh-CN", "zh-Hans"],
433
- TW: ["zh", "zh-TW", "zh-Hant"],
434
- HK: ["zh", "zh-HK", "en"],
435
- KR: ["ko", "ko-KR"],
436
- SG: ["en", "en-SG", "zh", "zh-SG"],
437
- AU: ["en", "en-AU"],
438
- NL: ["nl", "nl-NL", "en"],
439
- SE: ["sv", "sv-SE", "en"],
440
- CH: ["de", "de-CH", "fr", "fr-CH", "it", "it-CH"],
441
- BR: ["pt", "pt-BR"],
442
- IN: ["en", "en-IN", "hi", "hi-IN"],
443
- RU: ["ru", "ru-RU"]
444
- };
445
- function detectOSBrowserContradictions(passport) {
446
- const contradictions = [];
447
- const { browser, os, headers, clientHints } = passport;
448
- if (browser.name === "Safari" && os.platform !== "macOS") {
449
- contradictions.push({
450
- id: "ERR_SAFARI_NON_APPLE_PLATFORM",
451
- category: "os_browser",
452
- severity: "fatal",
453
- description: `Safari modern releases are exclusive to macOS/iOS; cannot run on ${os.platform}`,
454
- fields: ["browser.name", "os.platform"],
455
- actual: { browser: browser.name, platform: os.platform },
456
- expected: "macOS",
457
- impactPenalty: 35
458
- });
459
- }
460
- if (browser.name === "Chrome" || browser.name === "Edge") {
461
- if (browser.majorVersion >= 110 && os.release) {
462
- const isLegacyWin = /Windows (7|8|XP|Vista)/i.test(os.release);
463
- if (isLegacyWin) {
464
- contradictions.push({
465
- id: "ERR_CHROME_LEGACY_WIN_UNSUPPORTED",
466
- category: "os_browser",
467
- severity: "fatal",
468
- description: `Chromium ${browser.majorVersion} requires Windows 10 or later; unsupported on ${os.release}`,
469
- fields: ["browser.majorVersion", "os.release"],
470
- actual: { browserVersion: browser.majorVersion, osRelease: os.release },
471
- expected: "Windows 10 or Windows 11",
472
- impactPenalty: 30
473
- });
474
- }
475
- }
476
- if (browser.majorVersion >= 120 && os.platform === "macOS") {
477
- const match = os.version.match(/^(\d+)/);
478
- if (match && parseInt(match[1], 10) < 11) {
479
- contradictions.push({
480
- id: "ERR_CHROME_LEGACY_MACOS_UNSUPPORTED",
481
- category: "os_browser",
482
- severity: "high",
483
- description: `Chromium ${browser.majorVersion} requires macOS 11.0 (Big Sur) or higher; got macOS ${os.version}`,
484
- fields: ["browser.majorVersion", "os.version"],
485
- actual: os.version,
486
- expected: ">= 11.0.0",
487
- impactPenalty: 25
488
- });
489
- }
490
- }
491
- }
492
- const ua = browser.userAgent || headers["user-agent"] || "";
493
- if (os.platform === "macOS" && !/Macintosh|Mac OS X/i.test(ua)) {
494
- contradictions.push({
495
- id: "ERR_UA_OS_MACOS_MISMATCH",
496
- category: "os_browser",
497
- severity: "fatal",
498
- description: "Operating system is macOS but User-Agent string does not indicate Macintosh architecture",
499
- fields: ["os.platform", "browser.userAgent"],
500
- actual: ua,
501
- expected: 'Containing "Macintosh; Intel Mac OS X..."',
502
- impactPenalty: 35
503
- });
504
- } else if (os.platform === "Windows" && !/Windows NT/i.test(ua)) {
505
- contradictions.push({
506
- id: "ERR_UA_OS_WINDOWS_MISMATCH",
507
- category: "os_browser",
508
- severity: "fatal",
509
- description: "Operating system is Windows but User-Agent string does not contain Windows NT tag",
510
- fields: ["os.platform", "browser.userAgent"],
511
- actual: ua,
512
- expected: 'Containing "Windows NT..."',
513
- impactPenalty: 35
514
- });
515
- }
516
- if (clientHints?.platformVersion && os.platform === "Windows") {
517
- const pvMajor = parseInt(clientHints.platformVersion.split(".")[0], 10);
518
- const isWin11 = /Windows 11/i.test(os.release);
519
- const isWin10 = /Windows 10/i.test(os.release);
520
- if (isWin11 && pvMajor < 13) {
521
- contradictions.push({
522
- id: "ERR_WIN11_PLATFORM_VERSION_MISMATCH",
523
- category: "os_browser",
524
- severity: "high",
525
- description: `Windows 11 reports Client-Hints platformVersion >= 13.0.0 (e.g. 15.0.0), but received "${clientHints.platformVersion}"`,
526
- fields: ["os.release", "clientHints.platformVersion"],
527
- actual: clientHints.platformVersion,
528
- expected: ">= 13.0.0 (typically 14.0.0 or 15.0.0)",
529
- impactPenalty: 20
530
- });
531
- } else if (isWin10 && pvMajor >= 13) {
532
- contradictions.push({
533
- id: "ERR_WIN10_PLATFORM_VERSION_MISMATCH",
534
- category: "os_browser",
535
- severity: "high",
536
- description: `Windows 10 reports Client-Hints platformVersion <= 10.0.0, but received Windows 11 platformVersion "${clientHints.platformVersion}"`,
537
- fields: ["os.release", "clientHints.platformVersion"],
538
- actual: clientHints.platformVersion,
539
- expected: "10.0.0 (or 1.0.0 - 10.0.0)",
540
- impactPenalty: 20
541
- });
542
- }
543
- }
544
- return contradictions;
545
- }
546
- function detectHardwareContradictions(passport) {
547
- const contradictions = [];
548
- const { hardware, os, clientHints } = passport;
549
- if (os.platform === "macOS") {
550
- const isAppleSiliconGpu = /Apple M\d/i.test(hardware.gpu.renderer);
551
- if (isAppleSiliconGpu && hardware.cpu.architecture === "x86" && clientHints?.architecture === "x86") {
552
- contradictions.push({
553
- id: "ERR_APPLE_SILICON_X86_CONTRADICTION",
554
- category: "hardware_system",
555
- severity: "high",
556
- description: `Apple Silicon GPU detected (${hardware.gpu.renderer}) but native CPU architecture and Client Hint reported as x86`,
557
- fields: ["hardware.gpu.renderer", "hardware.cpu.architecture", "clientHints.architecture"],
558
- actual: { gpu: hardware.gpu.renderer, arch: hardware.cpu.architecture },
559
- expected: "arm",
560
- impactPenalty: 20
561
- });
562
- }
563
- }
564
- const gpuRenderer = hardware.gpu.renderer || "";
565
- if (os.platform === "macOS") {
566
- if (/GeForce RTX|GTX 16|RTX 30|RTX 40/i.test(gpuRenderer)) {
567
- contradictions.push({
568
- id: "ERR_NVIDIA_MODERN_ON_MACOS",
569
- category: "hardware_system",
570
- severity: "fatal",
571
- description: `NVIDIA modern GPUs (${gpuRenderer}) have no driver support on modern macOS`,
572
- fields: ["hardware.gpu.renderer", "os.platform"],
573
- actual: gpuRenderer,
574
- expected: "Apple M-Series GPU or AMD Radeon Pro (legacy Intel Mac)",
575
- impactPenalty: 35
576
- });
577
- }
578
- if (/Direct3D|D3D11|D3D12/i.test(gpuRenderer)) {
579
- contradictions.push({
580
- id: "ERR_DIRECT3D_ON_MACOS",
581
- category: "hardware_system",
582
- severity: "fatal",
583
- description: `Direct3D/DirectX renderer (${gpuRenderer}) cannot exist on macOS WebGL pipeline`,
584
- fields: ["hardware.gpu.renderer", "os.platform"],
585
- actual: gpuRenderer,
586
- expected: "Metal or OpenGL ANGLE backend",
587
- impactPenalty: 30
588
- });
589
- }
590
- } else if (os.platform === "Windows") {
591
- if (/Apple M\d/i.test(gpuRenderer)) {
592
- contradictions.push({
593
- id: "ERR_APPLE_GPU_ON_WINDOWS",
594
- category: "hardware_system",
595
- severity: "fatal",
596
- description: `Apple Silicon integrated graphics (${gpuRenderer}) cannot run under Microsoft Windows`,
597
- fields: ["hardware.gpu.renderer", "os.platform"],
598
- actual: gpuRenderer,
599
- expected: "Intel UHD/Iris, NVIDIA GeForce, or AMD Radeon",
600
- impactPenalty: 35
601
- });
602
- }
603
- }
604
- if (clientHints?.architecture && hardware.cpu.architecture) {
605
- if (clientHints.architecture !== hardware.cpu.architecture) {
606
- contradictions.push({
607
- id: "ERR_CH_ARCH_HARDWARE_MISMATCH",
608
- category: "hardware_system",
609
- severity: "fatal",
610
- description: `sec-ch-ua-arch ("${clientHints.architecture}") does not match CPU hardware concurrency profile ("${hardware.cpu.architecture}")`,
611
- fields: ["clientHints.architecture", "hardware.cpu.architecture"],
612
- actual: clientHints.architecture,
613
- expected: hardware.cpu.architecture,
614
- impactPenalty: 30
615
- });
616
- }
617
- }
618
- const dm = hardware.memory.deviceMemory;
619
- if (dm !== void 0) {
620
- const validDeviceMemoryValues = [0.25, 0.5, 1, 2, 4, 8];
621
- if (dm <= 0 || !validDeviceMemoryValues.includes(dm)) {
622
- if (dm > 8) {
623
- contradictions.push({
624
- id: "WARN_DEVICE_MEMORY_UNCAPPED",
625
- category: "hardware_system",
626
- severity: "medium",
627
- description: `navigator.deviceMemory reported as ${dm} GiB; standard Chromium caps deviceMemory at 8 GiB`,
628
- fields: ["hardware.memory.deviceMemory"],
629
- actual: dm,
630
- expected: "Capped at 8 (one of [0.25, 0.5, 1, 2, 4, 8])",
631
- impactPenalty: 10
632
- });
633
- }
634
- }
635
- }
636
- const { screen } = hardware;
637
- if (screen.width > 0 && screen.height > 0) {
638
- if (screen.availWidth > screen.width || screen.availHeight > screen.height) {
639
- contradictions.push({
640
- id: "ERR_SCREEN_AVAILABLE_EXCEEDS_TOTAL",
641
- category: "hardware_system",
642
- severity: "high",
643
- description: `Screen available dimensions (${screen.availWidth}x${screen.availHeight}) exceed screen total bounds (${screen.width}x${screen.height})`,
644
- fields: ["hardware.screen.availWidth", "hardware.screen.width"],
645
- actual: { avail: `${screen.availWidth}x${screen.availHeight}`, total: `${screen.width}x${screen.height}` },
646
- expected: "availWidth <= width && availHeight <= height",
647
- impactPenalty: 20
648
- });
649
- }
650
- if (passport.context?.viewport) {
651
- const vp = passport.context.viewport;
652
- if (vp.width > screen.width || vp.height > screen.height) {
653
- contradictions.push({
654
- id: "ERR_VIEWPORT_EXCEEDS_SCREEN",
655
- category: "hardware_system",
656
- severity: "fatal",
657
- description: `Browser viewport (${vp.width}x${vp.height}) exceeds physical display screen (${screen.width}x${screen.height})`,
658
- fields: ["context.viewport", "hardware.screen"],
659
- actual: `${vp.width}x${vp.height}`,
660
- expected: `<= ${screen.width}x${screen.height}`,
661
- impactPenalty: 30
662
- });
663
- }
664
- }
665
- }
666
- return contradictions;
667
- }
668
- function detectGeoChronoContradictions(passport) {
669
- const contradictions = [];
670
- const { locale, headers } = passport;
671
- const country = (locale.country || "").toUpperCase();
672
- const timezone = locale.timezone || "";
673
- if (country && timezone && COUNTRY_TIMEZONE_MAP[country]) {
674
- const validTimezones = COUNTRY_TIMEZONE_MAP[country];
675
- if (!validTimezones.includes(timezone)) {
676
- contradictions.push({
677
- id: "ERR_GEO_TIMEZONE_COUNTRY_MISMATCH",
678
- category: "geo_chrono",
679
- severity: "fatal",
680
- description: `Timezone "${timezone}" does not belong to geographic territory "${country}"`,
681
- fields: ["locale.timezone", "locale.country"],
682
- actual: { country, timezone },
683
- expected: validTimezones.join(", "),
684
- impactPenalty: 40
685
- });
686
- }
687
- }
688
- const acceptLangHeader = headers["accept-language"] || "";
689
- if (country && COUNTRY_PRIMARY_LANGUAGES[country]) {
690
- const expectedLanguages = COUNTRY_PRIMARY_LANGUAGES[country];
691
- const primaryLocaleLang = (locale.language || "").toLowerCase().split("-")[0];
692
- const countryExpectsMatch = expectedLanguages.some(
693
- (el) => primaryLocaleLang === el.toLowerCase().split("-")[0]
694
- );
695
- if (!countryExpectsMatch && primaryLocaleLang) {
696
- contradictions.push({
697
- id: "WARN_GEO_PRIMARY_LANGUAGE_MISMATCH",
698
- category: "geo_chrono",
699
- severity: "high",
700
- description: `Primary locale language "${locale.language}" is anomalous for country code "${country}"`,
701
- fields: ["locale.language", "locale.country"],
702
- actual: locale.language,
703
- expected: expectedLanguages.join(", "),
704
- impactPenalty: 15
705
- });
706
- }
707
- if (acceptLangHeader) {
708
- const hasAnyExpectedInHeader = expectedLanguages.some(
709
- (lang) => acceptLangHeader.toLowerCase().includes(lang.toLowerCase())
710
- );
711
- if (!hasAnyExpectedInHeader && !acceptLangHeader.toLowerCase().includes("en")) {
712
- contradictions.push({
713
- id: "WARN_ACCEPT_LANGUAGE_GEO_DETACHED",
714
- category: "geo_chrono",
715
- severity: "medium",
716
- description: `Accept-Language header "${acceptLangHeader}" contains neither local language for "${country}" nor global fallback (en)`,
717
- fields: ["headers.accept-language", "locale.country"],
718
- actual: acceptLangHeader,
719
- expected: `Includes one of: ${expectedLanguages.join(", ")} or en`,
720
- impactPenalty: 12
721
- });
722
- }
723
- }
724
- }
725
- return contradictions;
726
- }
727
- function detectClientHintsContradictions(passport) {
728
- const contradictions = [];
729
- const { clientHints, os } = passport;
730
- if (!clientHints) return contradictions;
731
- if (clientHints.mobile === true && (os.platform === "macOS" || os.platform === "Windows")) {
732
- contradictions.push({
733
- id: "ERR_CH_MOBILE_ON_DESKTOP",
734
- category: "client_hints",
735
- severity: "fatal",
736
- description: `Client-Hints indicates mobile=true (?1) on desktop operating system ${os.platform}`,
737
- fields: ["clientHints.mobile", "os.platform"],
738
- actual: { mobile: clientHints.mobile, platform: os.platform },
739
- expected: "mobile: false (?0)",
740
- impactPenalty: 35
741
- });
742
- }
743
- if (clientHints.platform) {
744
- const chPlat = clientHints.platform.toLowerCase();
745
- const osPlat = os.platform.toLowerCase();
746
- if (chPlat !== osPlat) {
747
- contradictions.push({
748
- id: "ERR_CH_PLATFORM_OS_MISMATCH",
749
- category: "client_hints",
750
- severity: "fatal",
751
- description: `sec-ch-ua-platform "${clientHints.platform}" contradicts OS platform "${os.platform}"`,
752
- fields: ["clientHints.platform", "os.platform"],
753
- actual: clientHints.platform,
754
- expected: os.platform,
755
- impactPenalty: 35
756
- });
757
- }
758
- }
759
- if ((os.platform === "macOS" || os.platform === "Windows") && clientHints.model && clientHints.model.trim() !== "") {
760
- contradictions.push({
761
- id: "ERR_CH_NON_EMPTY_DESKTOP_MODEL",
762
- category: "client_hints",
763
- severity: "high",
764
- description: `Desktop Chromium mandates empty sec-ch-ua-model (""), received "${clientHints.model}"`,
765
- fields: ["clientHints.model", "os.platform"],
766
- actual: clientHints.model,
767
- expected: '"" (empty string for desktop)',
768
- impactPenalty: 25
769
- });
770
- }
771
- if (clientHints.bitness && clientHints.bitness !== "64") {
772
- if (os.platform === "macOS") {
773
- contradictions.push({
774
- id: "ERR_CH_32BIT_ON_MODERN_MACOS",
775
- category: "client_hints",
776
- severity: "fatal",
777
- description: `macOS has discontinued 32-bit binaries since macOS 10.15; bitness reported as "${clientHints.bitness}"`,
778
- fields: ["clientHints.bitness", "os.platform"],
779
- actual: clientHints.bitness,
780
- expected: '"64"',
781
- impactPenalty: 30
782
- });
783
- }
784
- }
785
- return contradictions;
786
- }
787
- function detectAllContradictions(passport) {
788
- return [
789
- ...detectOSBrowserContradictions(passport),
790
- ...detectHardwareContradictions(passport),
791
- ...detectGeoChronoContradictions(passport),
792
- ...detectClientHintsContradictions(passport)
793
- ];
794
- }
795
-
796
- const BROWSER_BASELINE_FREQUENCIES = {
797
- "sec-ch-ua": 0.12,
798
- "sec-ch-ua-mobile": 0.04,
799
- "sec-ch-ua-platform": 0.08,
800
- "upgrade-insecure-requests": 0.04,
801
- "user-agent": 0.22,
802
- "accept": 0.14,
803
- "sec-fetch-site": 0.05,
804
- "sec-fetch-mode": 0.05,
805
- "sec-fetch-user": 0.03,
806
- "sec-fetch-dest": 0.05,
807
- "accept-encoding": 0.08,
808
- "accept-language": 0.1
809
- };
810
- const OPTIMAL_CHAR_ENTROPY_MIN = 4.6;
811
- const OPTIMAL_CHAR_ENTROPY_MAX = 5.6;
812
- const OPTIMAL_ENTROPY_MIN = OPTIMAL_CHAR_ENTROPY_MIN;
813
- const OPTIMAL_ENTROPY_MAX = OPTIMAL_CHAR_ENTROPY_MAX;
814
- const BASELINE_OPTIMAL_ENTROPY = 5.25;
815
- const MIN_STRUCTURAL_ENTROPY = 3.5;
816
- function calculateShannonEntropy(data) {
817
- if (!data || data.length === 0) return 0;
818
- const frequencies = /* @__PURE__ */ new Map();
819
- const total = data.length;
820
- for (let i = 0; i < total; i++) {
821
- const char = data[i];
822
- frequencies.set(char, (frequencies.get(char) || 0) + 1);
823
- }
824
- let entropy = 0;
825
- for (const count of frequencies.values()) {
826
- const p = count / total;
827
- if (p > 0) {
828
- entropy -= p * Math.log2(p);
829
- }
830
- }
831
- return Number(entropy.toFixed(4));
832
- }
833
- function calculateStructuralEntropy(headers) {
834
- const normalizedKeys = Object.keys(headers).map((k) => k.toLowerCase());
835
- const baselineKeys = Object.keys(BROWSER_BASELINE_FREQUENCIES);
836
- if (normalizedKeys.length === 0) return 0;
837
- let presentCount = 0;
838
- for (const key of baselineKeys) {
839
- if (normalizedKeys.includes(key)) {
840
- presentCount++;
841
- }
842
- }
843
- const presenceRatio = presentCount / baselineKeys.length;
844
- const countFactor = Math.min(normalizedKeys.length / 10, 1);
845
- return Number((presenceRatio * 3 + countFactor * 2).toFixed(4));
846
- }
847
- function calculateKLDivergence(headers) {
848
- const normalizedHeaders = {};
849
- for (const [k, v] of Object.entries(headers)) {
850
- normalizedHeaders[k.toLowerCase()] = v;
851
- }
852
- const baselineKeys = Object.keys(BROWSER_BASELINE_FREQUENCIES);
853
- let totalLength = 0;
854
- const observedLengths = {};
855
- for (const key of baselineKeys) {
856
- const val = normalizedHeaders[key] || "";
857
- const len = val.length + key.length;
858
- observedLengths[key] = len;
859
- totalLength += len;
860
- }
861
- if (totalLength === 0) return 3.5;
862
- let klDiv = 0;
863
- const epsilon = 1e-4;
864
- for (const key of baselineKeys) {
865
- const p = (observedLengths[key] || 0) / totalLength + epsilon;
866
- const q = BROWSER_BASELINE_FREQUENCIES[key] || epsilon;
867
- klDiv += p * Math.log2(p / q);
868
- }
869
- return Number(Math.max(0, klDiv).toFixed(4));
870
- }
871
- function analyzeHeaderEntropy(headers) {
872
- if (!headers || Object.keys(headers).length === 0) {
873
- return {
874
- entropyScore: 0,
875
- estimatedBits: 0,
876
- klDivergence: 4,
877
- anomaly: "too_low",
878
- collisionRisk: "high",
879
- verdict: "Completely static or empty headers; trivially detectable as automated bot.",
880
- details: {
881
- characterEntropy: 0,
882
- structuralEntropy: 0,
883
- baselineEntropy: BASELINE_OPTIMAL_ENTROPY,
884
- deltaFromOptimal: BASELINE_OPTIMAL_ENTROPY
885
- }
886
- };
887
- }
888
- const serialized = Object.entries(headers).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k.toLowerCase()}: ${v}`).join("\r\n");
889
- const charEntropy = calculateShannonEntropy(serialized);
890
- const structEntropy = calculateStructuralEntropy(headers);
891
- const klDiv = calculateKLDivergence(headers);
892
- const headerCount = Object.keys(headers).length;
893
- let anomaly = "optimal";
894
- let penalty = 0;
895
- if (headerCount < 4 || structEntropy < MIN_STRUCTURAL_ENTROPY || charEntropy < OPTIMAL_CHAR_ENTROPY_MIN) {
896
- anomaly = "too_low";
897
- const structDeficit = Math.max(0, MIN_STRUCTURAL_ENTROPY - structEntropy);
898
- penalty += structDeficit * 15;
899
- const charDeficit = Math.max(0, OPTIMAL_CHAR_ENTROPY_MIN - charEntropy);
900
- penalty += charDeficit * 25;
901
- if (headerCount < 4) {
902
- penalty += (4 - headerCount) * 15;
903
- }
904
- } else if (charEntropy > OPTIMAL_CHAR_ENTROPY_MAX) {
905
- anomaly = "too_high";
906
- const excess = charEntropy - OPTIMAL_CHAR_ENTROPY_MAX;
907
- penalty += excess * 30;
908
- }
909
- penalty += Math.min(klDiv * 12, 30);
910
- const rawScore = 100 - penalty;
911
- const entropyScore = Number(Math.max(0, Math.min(100, rawScore)).toFixed(1));
912
- let collisionRisk = "very_low";
913
- let verdict = "Realistic entropy distribution matching authentic browser telemetry.";
914
- if (anomaly === "too_low") {
915
- collisionRisk = "high";
916
- verdict = "Under-randomized or missing essential browser headers; high risk of bot detection.";
917
- } else if (anomaly === "too_high") {
918
- collisionRisk = "moderate";
919
- verdict = "Hyper-randomized noise detected; synthetic fingerprint spoofing risk.";
920
- } else if (entropyScore >= 85) {
921
- collisionRisk = "very_low";
922
- verdict = "Optimal information entropy perfectly consistent with real Chromium/Safari sessions.";
923
- } else {
924
- collisionRisk = "low";
925
- verdict = "Acceptable entropy band with minor structural divergence.";
926
- }
927
- return {
928
- entropyScore,
929
- estimatedBits: charEntropy,
930
- klDivergence: klDiv,
931
- anomaly,
932
- collisionRisk,
933
- verdict,
934
- details: {
935
- characterEntropy: charEntropy,
936
- structuralEntropy: structEntropy,
937
- baselineEntropy: BASELINE_OPTIMAL_ENTROPY,
938
- deltaFromOptimal: Number(Math.abs(charEntropy - BASELINE_OPTIMAL_ENTROPY).toFixed(4))
939
- }
940
- };
941
- }
942
-
943
- const GREASE_BRANDS = [
944
- "Not/A)Brand",
945
- "Not_A Brand",
946
- "Not?A_Brand",
947
- "Not.A/Brand",
948
- "Not:A-Brand"
949
- ];
950
- function generateBrandVersions(browserName, majorVersion, fullVersion, prng = Math.random) {
951
- const greaseIdx = Math.floor(prng() * GREASE_BRANDS.length);
952
- const greaseBrand = GREASE_BRANDS[greaseIdx] ?? "Not/A)Brand";
953
- const greaseMajor = "8";
954
- const greaseFull = "8.0.0.0";
955
- const lowEntropyBrands = [];
956
- const fullVersionList = [];
957
- if (browserName === "Edge") {
958
- const brands = [
959
- { brand: greaseBrand, major: greaseMajor, full: greaseFull },
960
- { brand: "Chromium", major: String(majorVersion), full: fullVersion },
961
- { brand: "Microsoft Edge", major: String(majorVersion), full: fullVersion }
962
- ];
963
- shuffleArray(brands, prng);
964
- for (const b of brands) {
965
- lowEntropyBrands.push({ brand: b.brand, version: b.major });
966
- fullVersionList.push({ brand: b.brand, version: b.full });
967
- }
968
- } else {
969
- const brands = [
970
- { brand: greaseBrand, major: greaseMajor, full: greaseFull },
971
- { brand: "Chromium", major: String(majorVersion), full: fullVersion },
972
- { brand: "Google Chrome", major: String(majorVersion), full: fullVersion }
973
- ];
974
- shuffleArray(brands, prng);
975
- for (const b of brands) {
976
- lowEntropyBrands.push({ brand: b.brand, version: b.major });
977
- fullVersionList.push({ brand: b.brand, version: b.full });
978
- }
979
- }
980
- return { lowEntropyBrands, fullVersionList };
981
- }
982
- function formatStructuredBrandList(brands) {
983
- return brands.map((b) => `"${b.brand}";v="${b.version}"`).join(", ");
984
- }
985
- function parseStructuredBrandList(headerValue) {
986
- if (!headerValue) return [];
987
- const brands = [];
988
- const regex = /"([^"]+)";v="([^"]+)"/g;
989
- let match;
990
- while ((match = regex.exec(headerValue)) !== null) {
991
- if (match[1] && match[2]) {
992
- brands.push({ brand: match[1], version: match[2] });
993
- }
994
- }
995
- return brands;
996
- }
997
- function generateUserAgentClientHints(options) {
998
- const { browserName, fullVersion, majorVersion, os, prng = Math.random } = options;
999
- const { lowEntropyBrands, fullVersionList } = generateBrandVersions(
1000
- browserName,
1001
- majorVersion,
1002
- fullVersion,
1003
- prng
1004
- );
1005
- const isWindows = os.platform === "Windows";
1006
- const architecture = os.architecture;
1007
- const bitness = "64";
1008
- const model = "";
1009
- const mobile = false;
1010
- const secChUa = formatStructuredBrandList(lowEntropyBrands);
1011
- const secChUaFullVersionList = formatStructuredBrandList(fullVersionList);
1012
- const secChUaMobile = "?0";
1013
- const secChUaPlatform = `"${os.platform}"`;
1014
- const secChUaPlatformVersion = `"${os.version}"`;
1015
- const secChUaArch = `"${architecture}"`;
1016
- const secChUaBitness = `"${bitness}"`;
1017
- const secChUaModel = `"${model}"`;
1018
- const headers = {
1019
- "sec-ch-ua": secChUa,
1020
- "sec-ch-ua-mobile": secChUaMobile,
1021
- "sec-ch-ua-platform": secChUaPlatform,
1022
- "sec-ch-ua-platform-version": secChUaPlatformVersion,
1023
- "sec-ch-ua-arch": secChUaArch,
1024
- "sec-ch-ua-bitness": secChUaBitness,
1025
- "sec-ch-ua-model": secChUaModel,
1026
- "sec-ch-ua-full-version-list": secChUaFullVersionList
1027
- };
1028
- if (isWindows) {
1029
- headers["sec-ch-ua-wow64"] = "?0";
1030
- }
1031
- return {
1032
- brands: lowEntropyBrands,
1033
- mobile,
1034
- platform: os.platform,
1035
- platformVersion: os.version,
1036
- architecture,
1037
- bitness,
1038
- model,
1039
- fullVersionList,
1040
- wow64: isWindows ? false : void 0,
1041
- headers
1042
- };
1043
- }
1044
- function shuffleArray(arr, prng) {
1045
- for (let i = arr.length - 1; i > 0; i--) {
1046
- const j = Math.floor(prng() * (i + 1));
1047
- const temp = arr[i];
1048
- arr[i] = arr[j];
1049
- arr[j] = temp;
1050
- }
1051
- }
1052
-
1053
- const DEFAULT_COUNTRY = "US";
1054
- const DEFAULT_LOCALE = "en-US";
1055
- const DEFAULT_TIMEZONE = "America/New_York";
1056
- const DEFAULT_ACCEPT_LANGUAGE = "en-US,en;q=0.9";
1057
- const COUNTRY_LOCALES = {
1058
- US: {
1059
- country: "US",
1060
- countryName: "United States",
1061
- primaryLocale: "en-US",
1062
- languages: ["en-US", "en"],
1063
- acceptLanguage: "en-US,en;q=0.9",
1064
- timezones: [
1065
- "America/New_York",
1066
- "America/Los_Angeles",
1067
- "America/Chicago",
1068
- "America/Denver",
1069
- "America/Phoenix",
1070
- "America/Anchorage",
1071
- "America/Honolulu",
1072
- "America/Detroit",
1073
- "America/Indiana/Indianapolis"
1074
- ],
1075
- defaultTimezone: "America/New_York",
1076
- currency: "USD",
1077
- coordinates: { latitude: 37.7749, longitude: -122.4194, accuracy: 1e3 }
1078
- },
1079
- GB: {
1080
- country: "GB",
1081
- countryName: "United Kingdom",
1082
- primaryLocale: "en-GB",
1083
- languages: ["en-GB", "en-US", "en"],
1084
- acceptLanguage: "en-GB,en-US;q=0.9,en;q=0.8",
1085
- timezones: ["Europe/London"],
1086
- defaultTimezone: "Europe/London",
1087
- currency: "GBP",
1088
- coordinates: { latitude: 51.5074, longitude: -0.1278, accuracy: 1e3 }
1089
- },
1090
- DE: {
1091
- country: "DE",
1092
- countryName: "Germany",
1093
- primaryLocale: "de-DE",
1094
- languages: ["de-DE", "de", "en-US", "en"],
1095
- acceptLanguage: "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7",
1096
- timezones: ["Europe/Berlin"],
1097
- defaultTimezone: "Europe/Berlin",
1098
- currency: "EUR",
1099
- coordinates: { latitude: 52.52, longitude: 13.405, accuracy: 1e3 }
1100
- },
1101
- FR: {
1102
- country: "FR",
1103
- countryName: "France",
1104
- primaryLocale: "fr-FR",
1105
- languages: ["fr-FR", "fr", "en-US", "en"],
1106
- acceptLanguage: "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7",
1107
- timezones: ["Europe/Paris"],
1108
- defaultTimezone: "Europe/Paris",
1109
- currency: "EUR",
1110
- coordinates: { latitude: 48.8566, longitude: 2.3522, accuracy: 1e3 }
1111
- },
1112
- JP: {
1113
- country: "JP",
1114
- countryName: "Japan",
1115
- primaryLocale: "ja-JP",
1116
- languages: ["ja-JP", "ja", "en-US"],
1117
- acceptLanguage: "ja-JP,ja;q=0.9,en-US;q=0.8",
1118
- timezones: ["Asia/Tokyo"],
1119
- defaultTimezone: "Asia/Tokyo",
1120
- currency: "JPY",
1121
- coordinates: { latitude: 35.6762, longitude: 139.6503, accuracy: 1e3 }
1122
- },
1123
- SG: {
1124
- country: "SG",
1125
- countryName: "Singapore",
1126
- primaryLocale: "en-SG",
1127
- languages: ["en-SG", "en-US", "en", "zh-CN"],
1128
- acceptLanguage: "en-SG,en-US;q=0.9,en;q=0.8,zh-CN;q=0.7",
1129
- timezones: ["Asia/Singapore"],
1130
- defaultTimezone: "Asia/Singapore",
1131
- currency: "SGD",
1132
- coordinates: { latitude: 1.3521, longitude: 103.8198, accuracy: 1e3 }
1133
- },
1134
- HK: {
1135
- country: "HK",
1136
- countryName: "Hong Kong",
1137
- primaryLocale: "zh-HK",
1138
- languages: ["zh-HK", "zh-TW", "zh", "en-US"],
1139
- acceptLanguage: "zh-HK,zh-TW;q=0.9,zh;q=0.8,en-US;q=0.7",
1140
- timezones: ["Asia/Hong_Kong"],
1141
- defaultTimezone: "Asia/Hong_Kong",
1142
- currency: "HKD",
1143
- coordinates: { latitude: 22.3193, longitude: 114.1694, accuracy: 1e3 }
1144
- },
1145
- TW: {
1146
- country: "TW",
1147
- countryName: "Taiwan",
1148
- primaryLocale: "zh-TW",
1149
- languages: ["zh-TW", "zh", "en-US"],
1150
- acceptLanguage: "zh-TW,zh;q=0.9,en-US;q=0.8",
1151
- timezones: ["Asia/Taipei"],
1152
- defaultTimezone: "Asia/Taipei",
1153
- currency: "TWD",
1154
- coordinates: { latitude: 25.033, longitude: 121.5654, accuracy: 1e3 }
1155
- },
1156
- CN: {
1157
- country: "CN",
1158
- countryName: "China",
1159
- primaryLocale: "zh-CN",
1160
- languages: ["zh-CN", "zh", "en-US", "en"],
1161
- acceptLanguage: "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
1162
- timezones: ["Asia/Shanghai", "Asia/Urumqi"],
1163
- defaultTimezone: "Asia/Shanghai",
1164
- currency: "CNY",
1165
- coordinates: { latitude: 31.2304, longitude: 121.4737, accuracy: 1e3 }
1166
- },
1167
- KR: {
1168
- country: "KR",
1169
- countryName: "South Korea",
1170
- primaryLocale: "ko-KR",
1171
- languages: ["ko-KR", "ko", "en-US", "en"],
1172
- acceptLanguage: "ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7",
1173
- timezones: ["Asia/Seoul"],
1174
- defaultTimezone: "Asia/Seoul",
1175
- currency: "KRW",
1176
- coordinates: { latitude: 37.5665, longitude: 126.978, accuracy: 1e3 }
1177
- },
1178
- AU: {
1179
- country: "AU",
1180
- countryName: "Australia",
1181
- primaryLocale: "en-AU",
1182
- languages: ["en-AU", "en-GB", "en-US", "en"],
1183
- acceptLanguage: "en-AU,en-GB;q=0.9,en-US;q=0.8,en;q=0.7",
1184
- timezones: [
1185
- "Australia/Sydney",
1186
- "Australia/Melbourne",
1187
- "Australia/Brisbane",
1188
- "Australia/Perth",
1189
- "Australia/Adelaide",
1190
- "Australia/Hobart",
1191
- "Australia/Darwin"
1192
- ],
1193
- defaultTimezone: "Australia/Sydney",
1194
- currency: "AUD",
1195
- coordinates: { latitude: -33.8688, longitude: 151.2093, accuracy: 1e3 }
1196
- },
1197
- CA: {
1198
- country: "CA",
1199
- countryName: "Canada",
1200
- primaryLocale: "en-CA",
1201
- languages: ["en-CA", "en-US", "en", "fr-CA"],
1202
- acceptLanguage: "en-CA,en-US;q=0.9,en;q=0.8,fr-CA;q=0.7",
1203
- timezones: [
1204
- "America/Toronto",
1205
- "America/Vancouver",
1206
- "America/Montreal",
1207
- "America/Edmonton",
1208
- "America/Winnipeg",
1209
- "America/Halifax",
1210
- "America/St_Johns"
1211
- ],
1212
- defaultTimezone: "America/Toronto",
1213
- currency: "CAD",
1214
- coordinates: { latitude: 43.6532, longitude: -79.3832, accuracy: 1e3 }
1215
- },
1216
- NL: {
1217
- country: "NL",
1218
- countryName: "Netherlands",
1219
- primaryLocale: "nl-NL",
1220
- languages: ["nl-NL", "nl", "en-US", "en"],
1221
- acceptLanguage: "nl-NL,nl;q=0.9,en-US;q=0.8,en;q=0.7",
1222
- timezones: ["Europe/Amsterdam"],
1223
- defaultTimezone: "Europe/Amsterdam",
1224
- currency: "EUR",
1225
- coordinates: { latitude: 52.3676, longitude: 4.9041, accuracy: 1e3 }
1226
- },
1227
- IN: {
1228
- country: "IN",
1229
- countryName: "India",
1230
- primaryLocale: "en-IN",
1231
- languages: ["en-IN", "en-GB", "en-US", "en", "hi"],
1232
- acceptLanguage: "en-IN,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,hi;q=0.6",
1233
- timezones: ["Asia/Kolkata"],
1234
- defaultTimezone: "Asia/Kolkata",
1235
- currency: "INR",
1236
- coordinates: { latitude: 28.6139, longitude: 77.209, accuracy: 1e3 }
1237
- },
1238
- BR: {
1239
- country: "BR",
1240
- countryName: "Brazil",
1241
- primaryLocale: "pt-BR",
1242
- languages: ["pt-BR", "pt", "en-US", "en"],
1243
- acceptLanguage: "pt-BR,pt;q=0.9,en-US;q=0.8,en;q=0.7",
1244
- timezones: [
1245
- "America/Sao_Paulo",
1246
- "America/Fortaleza",
1247
- "America/Manaus",
1248
- "America/Recife",
1249
- "America/Belem",
1250
- "America/Cuiaba"
1251
- ],
1252
- defaultTimezone: "America/Sao_Paulo",
1253
- currency: "BRL",
1254
- coordinates: { latitude: -23.5505, longitude: -46.6333, accuracy: 1e3 }
1255
- },
1256
- IT: {
1257
- country: "IT",
1258
- countryName: "Italy",
1259
- primaryLocale: "it-IT",
1260
- languages: ["it-IT", "it", "en-US", "en"],
1261
- acceptLanguage: "it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7",
1262
- timezones: ["Europe/Rome"],
1263
- defaultTimezone: "Europe/Rome",
1264
- currency: "EUR",
1265
- coordinates: { latitude: 41.9028, longitude: 12.4964, accuracy: 1e3 }
1266
- },
1267
- ES: {
1268
- country: "ES",
1269
- countryName: "Spain",
1270
- primaryLocale: "es-ES",
1271
- languages: ["es-ES", "es", "en-US", "en"],
1272
- acceptLanguage: "es-ES,es;q=0.9,en-US;q=0.8,en;q=0.7",
1273
- timezones: ["Europe/Madrid", "Atlantic/Canary"],
1274
- defaultTimezone: "Europe/Madrid",
1275
- currency: "EUR",
1276
- coordinates: { latitude: 40.4168, longitude: -3.7038, accuracy: 1e3 }
1277
- },
1278
- RU: {
1279
- country: "RU",
1280
- countryName: "Russia",
1281
- primaryLocale: "ru-RU",
1282
- languages: ["ru-RU", "ru", "en-US", "en"],
1283
- acceptLanguage: "ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7",
1284
- timezones: ["Europe/Moscow", "Europe/Samara", "Asia/Yekaterinburg", "Asia/Novosibirsk", "Asia/Vladivostok"],
1285
- defaultTimezone: "Europe/Moscow",
1286
- currency: "RUB",
1287
- coordinates: { latitude: 55.7558, longitude: 37.6173, accuracy: 1e3 }
1288
- },
1289
- MX: {
1290
- country: "MX",
1291
- countryName: "Mexico",
1292
- primaryLocale: "es-MX",
1293
- languages: ["es-MX", "es", "en-US", "en"],
1294
- acceptLanguage: "es-MX,es;q=0.9,en-US;q=0.8,en;q=0.7",
1295
- timezones: ["America/Mexico_City", "America/Cancun", "America/Monterrey", "America/Tijuana"],
1296
- defaultTimezone: "America/Mexico_City",
1297
- currency: "MXN",
1298
- coordinates: { latitude: 19.4326, longitude: -99.1332, accuracy: 1e3 }
1299
- },
1300
- ID: {
1301
- country: "ID",
1302
- countryName: "Indonesia",
1303
- primaryLocale: "id-ID",
1304
- languages: ["id-ID", "id", "en-US", "en"],
1305
- acceptLanguage: "id-ID,id;q=0.9,en-US;q=0.8,en;q=0.7",
1306
- timezones: ["Asia/Jakarta", "Asia/Makassar", "Asia/Jayapura"],
1307
- defaultTimezone: "Asia/Jakarta",
1308
- currency: "IDR",
1309
- coordinates: { latitude: -6.2088, longitude: 106.8456, accuracy: 1e3 }
1310
- },
1311
- MY: {
1312
- country: "MY",
1313
- countryName: "Malaysia",
1314
- primaryLocale: "ms-MY",
1315
- languages: ["ms-MY", "ms", "en-US", "en"],
1316
- acceptLanguage: "ms-MY,ms;q=0.9,en-US;q=0.8,en;q=0.7",
1317
- timezones: ["Asia/Kuala_Lumpur", "Asia/Kuching"],
1318
- defaultTimezone: "Asia/Kuala_Lumpur",
1319
- currency: "MYR",
1320
- coordinates: { latitude: 3.139, longitude: 101.6869, accuracy: 1e3 }
1321
- },
1322
- TH: {
1323
- country: "TH",
1324
- countryName: "Thailand",
1325
- primaryLocale: "th-TH",
1326
- languages: ["th-TH", "th", "en-US", "en"],
1327
- acceptLanguage: "th-TH,th;q=0.9,en-US;q=0.8,en;q=0.7",
1328
- timezones: ["Asia/Bangkok"],
1329
- defaultTimezone: "Asia/Bangkok",
1330
- currency: "THB",
1331
- coordinates: { latitude: 13.7563, longitude: 100.5018, accuracy: 1e3 }
1332
- },
1333
- VN: {
1334
- country: "VN",
1335
- countryName: "Vietnam",
1336
- primaryLocale: "vi-VN",
1337
- languages: ["vi-VN", "vi", "en-US", "en"],
1338
- acceptLanguage: "vi-VN,vi;q=0.9,en-US;q=0.8,en;q=0.7",
1339
- timezones: ["Asia/Ho_Chi_Minh"],
1340
- defaultTimezone: "Asia/Ho_Chi_Minh",
1341
- currency: "VND",
1342
- coordinates: { latitude: 10.8231, longitude: 106.6297, accuracy: 1e3 }
1343
- },
1344
- PH: {
1345
- country: "PH",
1346
- countryName: "Philippines",
1347
- primaryLocale: "en-PH",
1348
- languages: ["en-PH", "en-US", "en", "fil"],
1349
- acceptLanguage: "en-PH,en-US;q=0.9,en;q=0.8,fil;q=0.7",
1350
- timezones: ["Asia/Manila"],
1351
- defaultTimezone: "Asia/Manila",
1352
- currency: "PHP",
1353
- coordinates: { latitude: 14.5995, longitude: 120.9842, accuracy: 1e3 }
1354
- },
1355
- SE: {
1356
- country: "SE",
1357
- countryName: "Sweden",
1358
- primaryLocale: "sv-SE",
1359
- languages: ["sv-SE", "sv", "en-US", "en"],
1360
- acceptLanguage: "sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7",
1361
- timezones: ["Europe/Stockholm"],
1362
- defaultTimezone: "Europe/Stockholm",
1363
- currency: "SEK",
1364
- coordinates: { latitude: 59.3293, longitude: 18.0686, accuracy: 1e3 }
1365
- },
1366
- NO: {
1367
- country: "NO",
1368
- countryName: "Norway",
1369
- primaryLocale: "nb-NO",
1370
- languages: ["nb-NO", "nb", "nn", "en-US", "en"],
1371
- acceptLanguage: "nb-NO,nb;q=0.9,nn;q=0.8,en-US;q=0.7,en;q=0.6",
1372
- timezones: ["Europe/Oslo"],
1373
- defaultTimezone: "Europe/Oslo",
1374
- currency: "NOK",
1375
- coordinates: { latitude: 59.9139, longitude: 10.7522, accuracy: 1e3 }
1376
- },
1377
- DK: {
1378
- country: "DK",
1379
- countryName: "Denmark",
1380
- primaryLocale: "da-DK",
1381
- languages: ["da-DK", "da", "en-US", "en"],
1382
- acceptLanguage: "da-DK,da;q=0.9,en-US;q=0.8,en;q=0.7",
1383
- timezones: ["Europe/Copenhagen"],
1384
- defaultTimezone: "Europe/Copenhagen",
1385
- currency: "DKK",
1386
- coordinates: { latitude: 55.6761, longitude: 12.5683, accuracy: 1e3 }
1387
- },
1388
- FI: {
1389
- country: "FI",
1390
- countryName: "Finland",
1391
- primaryLocale: "fi-FI",
1392
- languages: ["fi-FI", "fi", "sv-FI", "en-US", "en"],
1393
- acceptLanguage: "fi-FI,fi;q=0.9,sv-FI;q=0.8,en-US;q=0.7,en;q=0.6",
1394
- timezones: ["Europe/Helsinki"],
1395
- defaultTimezone: "Europe/Helsinki",
1396
- currency: "EUR",
1397
- coordinates: { latitude: 60.1699, longitude: 24.9384, accuracy: 1e3 }
1398
- },
1399
- PL: {
1400
- country: "PL",
1401
- countryName: "Poland",
1402
- primaryLocale: "pl-PL",
1403
- languages: ["pl-PL", "pl", "en-US", "en"],
1404
- acceptLanguage: "pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7",
1405
- timezones: ["Europe/Warsaw"],
1406
- defaultTimezone: "Europe/Warsaw",
1407
- currency: "PLN",
1408
- coordinates: { latitude: 52.2297, longitude: 21.0122, accuracy: 1e3 }
1409
- },
1410
- CH: {
1411
- country: "CH",
1412
- countryName: "Switzerland",
1413
- primaryLocale: "de-CH",
1414
- languages: ["de-CH", "fr-CH", "it-CH", "en-US", "en"],
1415
- acceptLanguage: "de-CH,fr-CH;q=0.9,it-CH;q=0.8,en-US;q=0.7,en;q=0.6",
1416
- timezones: ["Europe/Zurich"],
1417
- defaultTimezone: "Europe/Zurich",
1418
- currency: "CHF",
1419
- coordinates: { latitude: 47.3769, longitude: 8.5417, accuracy: 1e3 }
1420
- },
1421
- AT: {
1422
- country: "AT",
1423
- countryName: "Austria",
1424
- primaryLocale: "de-AT",
1425
- languages: ["de-AT", "de", "en-US", "en"],
1426
- acceptLanguage: "de-AT,de;q=0.9,en-US;q=0.8,en;q=0.7",
1427
- timezones: ["Europe/Vienna"],
1428
- defaultTimezone: "Europe/Vienna",
1429
- currency: "EUR",
1430
- coordinates: { latitude: 48.2082, longitude: 16.3738, accuracy: 1e3 }
1431
- },
1432
- BE: {
1433
- country: "BE",
1434
- countryName: "Belgium",
1435
- primaryLocale: "nl-BE",
1436
- languages: ["nl-BE", "fr-BE", "en-US", "en"],
1437
- acceptLanguage: "nl-BE,fr-BE;q=0.9,en-US;q=0.8,en;q=0.7",
1438
- timezones: ["Europe/Brussels"],
1439
- defaultTimezone: "Europe/Brussels",
1440
- currency: "EUR",
1441
- coordinates: { latitude: 50.8503, longitude: 4.3517, accuracy: 1e3 }
1442
- },
1443
- IE: {
1444
- country: "IE",
1445
- countryName: "Ireland",
1446
- primaryLocale: "en-IE",
1447
- languages: ["en-IE", "en-GB", "en-US", "en", "ga"],
1448
- acceptLanguage: "en-IE,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,ga;q=0.6",
1449
- timezones: ["Europe/Dublin"],
1450
- defaultTimezone: "Europe/Dublin",
1451
- currency: "EUR",
1452
- coordinates: { latitude: 53.3498, longitude: -6.2603, accuracy: 1e3 }
1453
- },
1454
- NZ: {
1455
- country: "NZ",
1456
- countryName: "New Zealand",
1457
- primaryLocale: "en-NZ",
1458
- languages: ["en-NZ", "en-GB", "en-US", "en"],
1459
- acceptLanguage: "en-NZ,en-GB;q=0.9,en-US;q=0.8,en;q=0.7",
1460
- timezones: ["Pacific/Auckland", "Pacific/Chatham"],
1461
- defaultTimezone: "Pacific/Auckland",
1462
- currency: "NZD",
1463
- coordinates: { latitude: -36.8485, longitude: 174.7633, accuracy: 1e3 }
1464
- },
1465
- TR: {
1466
- country: "TR",
1467
- countryName: "Turkey",
1468
- primaryLocale: "tr-TR",
1469
- languages: ["tr-TR", "tr", "en-US", "en"],
1470
- acceptLanguage: "tr-TR,tr;q=0.9,en-US;q=0.8,en;q=0.7",
1471
- timezones: ["Europe/Istanbul"],
1472
- defaultTimezone: "Europe/Istanbul",
1473
- currency: "TRY",
1474
- coordinates: { latitude: 41.0082, longitude: 28.9784, accuracy: 1e3 }
1475
- },
1476
- SA: {
1477
- country: "SA",
1478
- countryName: "Saudi Arabia",
1479
- primaryLocale: "ar-SA",
1480
- languages: ["ar-SA", "ar", "en-US", "en"],
1481
- acceptLanguage: "ar-SA,ar;q=0.9,en-US;q=0.8,en;q=0.7",
1482
- timezones: ["Asia/Riyadh"],
1483
- defaultTimezone: "Asia/Riyadh",
1484
- currency: "SAR",
1485
- coordinates: { latitude: 24.7136, longitude: 46.6753, accuracy: 1e3 }
1486
- },
1487
- AE: {
1488
- country: "AE",
1489
- countryName: "United Arab Emirates",
1490
- primaryLocale: "ar-AE",
1491
- languages: ["ar-AE", "ar", "en-US", "en"],
1492
- acceptLanguage: "ar-AE,ar;q=0.9,en-US;q=0.8,en;q=0.7",
1493
- timezones: ["Asia/Dubai"],
1494
- defaultTimezone: "Asia/Dubai",
1495
- currency: "AED",
1496
- coordinates: { latitude: 25.2048, longitude: 55.2708, accuracy: 1e3 }
1497
- },
1498
- ZA: {
1499
- country: "ZA",
1500
- countryName: "South Africa",
1501
- primaryLocale: "en-ZA",
1502
- languages: ["en-ZA", "en-GB", "en-US", "en", "af"],
1503
- acceptLanguage: "en-ZA,en-GB;q=0.9,en-US;q=0.8,en;q=0.7,af;q=0.6",
1504
- timezones: ["Africa/Johannesburg"],
1505
- defaultTimezone: "Africa/Johannesburg",
1506
- currency: "ZAR",
1507
- coordinates: { latitude: -26.2041, longitude: 28.0473, accuracy: 1e3 }
1508
- },
1509
- AR: {
1510
- country: "AR",
1511
- countryName: "Argentina",
1512
- primaryLocale: "es-AR",
1513
- languages: ["es-AR", "es", "en-US", "en"],
1514
- acceptLanguage: "es-AR,es;q=0.9,en-US;q=0.8,en;q=0.7",
1515
- timezones: ["America/Argentina/Buenos_Aires", "America/Argentina/Cordoba"],
1516
- defaultTimezone: "America/Argentina/Buenos_Aires",
1517
- currency: "ARS",
1518
- coordinates: { latitude: -34.6037, longitude: -58.3816, accuracy: 1e3 }
1519
- },
1520
- CL: {
1521
- country: "CL",
1522
- countryName: "Chile",
1523
- primaryLocale: "es-CL",
1524
- languages: ["es-CL", "es", "en-US", "en"],
1525
- acceptLanguage: "es-CL,es;q=0.9,en-US;q=0.8,en;q=0.7",
1526
- timezones: ["America/Santiago", "Pacific/Easter"],
1527
- defaultTimezone: "America/Santiago",
1528
- currency: "CLP",
1529
- coordinates: { latitude: -33.4489, longitude: -70.6693, accuracy: 1e3 }
1530
- },
1531
- CO: {
1532
- country: "CO",
1533
- countryName: "Colombia",
1534
- primaryLocale: "es-CO",
1535
- languages: ["es-CO", "es", "en-US", "en"],
1536
- acceptLanguage: "es-CO,es;q=0.9,en-US;q=0.8,en;q=0.7",
1537
- timezones: ["America/Bogota"],
1538
- defaultTimezone: "America/Bogota",
1539
- currency: "COP",
1540
- coordinates: { latitude: 4.711, longitude: -74.0721, accuracy: 1e3 }
1541
- },
1542
- IL: {
1543
- country: "IL",
1544
- countryName: "Israel",
1545
- primaryLocale: "he-IL",
1546
- languages: ["he-IL", "he", "en-US", "en"],
1547
- acceptLanguage: "he-IL,he;q=0.9,en-US;q=0.8,en;q=0.7",
1548
- timezones: ["Asia/Jerusalem"],
1549
- defaultTimezone: "Asia/Jerusalem",
1550
- currency: "ILS",
1551
- coordinates: { latitude: 31.7683, longitude: 35.2137, accuracy: 1e3 }
1552
- },
1553
- UA: {
1554
- country: "UA",
1555
- countryName: "Ukraine",
1556
- primaryLocale: "uk-UA",
1557
- languages: ["uk-UA", "uk", "en-US", "en"],
1558
- acceptLanguage: "uk-UA,uk;q=0.9,en-US;q=0.8,en;q=0.7",
1559
- timezones: ["Europe/Kyiv"],
1560
- defaultTimezone: "Europe/Kyiv",
1561
- currency: "UAH",
1562
- coordinates: { latitude: 50.4501, longitude: 30.5234, accuracy: 1e3 }
1563
- },
1564
- PT: {
1565
- country: "PT",
1566
- countryName: "Portugal",
1567
- primaryLocale: "pt-PT",
1568
- languages: ["pt-PT", "pt", "en-US", "en"],
1569
- acceptLanguage: "pt-PT,pt;q=0.9,en-US;q=0.8,en;q=0.7",
1570
- timezones: ["Europe/Lisbon", "Atlantic/Madeira", "Atlantic/Azores"],
1571
- defaultTimezone: "Europe/Lisbon",
1572
- currency: "EUR",
1573
- coordinates: { latitude: 38.7223, longitude: -9.1393, accuracy: 1e3 }
1574
- },
1575
- CZ: {
1576
- country: "CZ",
1577
- countryName: "Czech Republic",
1578
- primaryLocale: "cs-CZ",
1579
- languages: ["cs-CZ", "cs", "en-US", "en"],
1580
- acceptLanguage: "cs-CZ,cs;q=0.9,en-US;q=0.8,en;q=0.7",
1581
- timezones: ["Europe/Prague"],
1582
- defaultTimezone: "Europe/Prague",
1583
- currency: "CZK",
1584
- coordinates: { latitude: 50.0755, longitude: 14.4378, accuracy: 1e3 }
1585
- },
1586
- RO: {
1587
- country: "RO",
1588
- countryName: "Romania",
1589
- primaryLocale: "ro-RO",
1590
- languages: ["ro-RO", "ro", "en-US", "en"],
1591
- acceptLanguage: "ro-RO,ro;q=0.9,en-US;q=0.8,en;q=0.7",
1592
- timezones: ["Europe/Bucharest"],
1593
- defaultTimezone: "Europe/Bucharest",
1594
- currency: "RON",
1595
- coordinates: { latitude: 44.4268, longitude: 26.1025, accuracy: 1e3 }
1596
- },
1597
- GR: {
1598
- country: "GR",
1599
- countryName: "Greece",
1600
- primaryLocale: "el-GR",
1601
- languages: ["el-GR", "el", "en-US", "en"],
1602
- acceptLanguage: "el-GR,el;q=0.9,en-US;q=0.8,en;q=0.7",
1603
- timezones: ["Europe/Athens"],
1604
- defaultTimezone: "Europe/Athens",
1605
- currency: "EUR",
1606
- coordinates: { latitude: 37.9838, longitude: 23.7275, accuracy: 1e3 }
1607
- },
1608
- HU: {
1609
- country: "HU",
1610
- countryName: "Hungary",
1611
- primaryLocale: "hu-HU",
1612
- languages: ["hu-HU", "hu", "en-US", "en"],
1613
- acceptLanguage: "hu-HU,hu;q=0.9,en-US;q=0.8,en;q=0.7",
1614
- timezones: ["Europe/Budapest"],
1615
- defaultTimezone: "Europe/Budapest",
1616
- currency: "HUF",
1617
- coordinates: { latitude: 47.4979, longitude: 19.0402, accuracy: 1e3 }
1618
- }
1619
- };
1620
- function getCountryConfig(countryCode) {
1621
- if (!countryCode) {
1622
- return COUNTRY_LOCALES[DEFAULT_COUNTRY];
1623
- }
1624
- const normalized = countryCode.trim().toUpperCase();
1625
- return COUNTRY_LOCALES[normalized] || COUNTRY_LOCALES[DEFAULT_COUNTRY];
1626
- }
1627
- function hasCountryConfig(countryCode) {
1628
- if (!countryCode) return false;
1629
- return Object.prototype.hasOwnProperty.call(COUNTRY_LOCALES, countryCode.trim().toUpperCase());
1630
- }
1631
- function getAllSupportedCountries() {
1632
- return Object.keys(COUNTRY_LOCALES);
1633
- }
1634
- function formatAcceptLanguage(languages) {
1635
- if (!languages || languages.length === 0) {
1636
- return DEFAULT_ACCEPT_LANGUAGE;
1637
- }
1638
- const uniqueLangs = [];
1639
- for (const lang of languages) {
1640
- const trimmed = lang.trim();
1641
- if (trimmed && !uniqueLangs.includes(trimmed)) {
1642
- uniqueLangs.push(trimmed);
1643
- }
1644
- }
1645
- if (uniqueLangs.length === 0) {
1646
- return DEFAULT_ACCEPT_LANGUAGE;
1647
- }
1648
- return uniqueLangs.map((lang, index) => {
1649
- if (index === 0) return lang;
1650
- const weight = Math.max(0.1, Number((1 - index * 0.1).toFixed(1)));
1651
- return `${lang};q=${weight}`;
1652
- }).join(",");
1653
- }
1654
- function parseAcceptLanguage(header) {
1655
- if (!header || typeof header !== "string") return [];
1656
- return header.split(",").map((part) => {
1657
- const [localePart, ...params] = part.trim().split(";");
1658
- const locale = localePart.trim();
1659
- let q = 1;
1660
- for (const param of params) {
1661
- const [key, val] = param.trim().split("=");
1662
- if (key && key.trim() === "q" && val) {
1663
- const parsed = parseFloat(val.trim());
1664
- if (!isNaN(parsed)) {
1665
- q = parsed;
1666
- }
1667
- }
1668
- }
1669
- return { locale, q };
1670
- }).filter((item) => item.locale.length > 0).sort((a, b) => b.q - a.q);
1671
- }
1672
-
1673
- const TIMEZONE_TO_COUNTRY = {
1674
- // United States
1675
- "America/New_York": "US",
1676
- "America/Los_Angeles": "US",
1677
- "America/Chicago": "US",
1678
- "America/Denver": "US",
1679
- "America/Phoenix": "US",
1680
- "America/Anchorage": "US",
1681
- "America/Honolulu": "US",
1682
- "America/Detroit": "US",
1683
- "America/Indiana/Indianapolis": "US",
1684
- "America/Boise": "US",
1685
- "America/Juneau": "US",
1686
- "America/Adak": "US",
1687
- "America/Nome": "US",
1688
- "America/Sitka": "US",
1689
- "America/Yakutat": "US",
1690
- "America/Metlakatla": "US",
1691
- "America/Menominee": "US",
1692
- "America/Kentucky/Louisville": "US",
1693
- "America/Kentucky/Monticello": "US",
1694
- "America/Indiana/Marengo": "US",
1695
- "America/Indiana/Vincennes": "US",
1696
- "America/Indiana/Tell_City": "US",
1697
- "America/Indiana/Petersburg": "US",
1698
- "America/Indiana/Knox": "US",
1699
- "America/Indiana/Winamac": "US",
1700
- "America/Indiana/Vevay": "US",
1701
- "America/North_Dakota/Center": "US",
1702
- "America/North_Dakota/New_Salem": "US",
1703
- "America/North_Dakota/Beulah": "US",
1704
- // United Kingdom
1705
- "Europe/London": "GB",
1706
- // Germany
1707
- "Europe/Berlin": "DE",
1708
- "Europe/Busingen": "DE",
1709
- // France
1710
- "Europe/Paris": "FR",
1711
- // Japan
1712
- "Asia/Tokyo": "JP",
1713
- // Singapore
1714
- "Asia/Singapore": "SG",
1715
- // Hong Kong
1716
- "Asia/Hong_Kong": "HK",
1717
- // Taiwan
1718
- "Asia/Taipei": "TW",
1719
- // China
1720
- "Asia/Shanghai": "CN",
1721
- "Asia/Urumqi": "CN",
1722
- "Asia/Chongqing": "CN",
1723
- "Asia/Harbin": "CN",
1724
- "Asia/Kashgar": "CN",
1725
- // South Korea
1726
- "Asia/Seoul": "KR",
1727
- // Australia
1728
- "Australia/Sydney": "AU",
1729
- "Australia/Melbourne": "AU",
1730
- "Australia/Brisbane": "AU",
1731
- "Australia/Perth": "AU",
1732
- "Australia/Adelaide": "AU",
1733
- "Australia/Hobart": "AU",
1734
- "Australia/Darwin": "AU",
1735
- "Australia/Broken_Hill": "AU",
1736
- "Australia/Lord_Howe": "AU",
1737
- "Australia/Lindeman": "AU",
1738
- "Australia/Eucla": "AU",
1739
- // Canada
1740
- "America/Toronto": "CA",
1741
- "America/Vancouver": "CA",
1742
- "America/Montreal": "CA",
1743
- "America/Edmonton": "CA",
1744
- "America/Winnipeg": "CA",
1745
- "America/Halifax": "CA",
1746
- "America/St_Johns": "CA",
1747
- "America/Regina": "CA",
1748
- "America/Calgary": "CA",
1749
- "America/Whitehorse": "CA",
1750
- "America/Dawson": "CA",
1751
- "America/Yellowknife": "CA",
1752
- "America/Iqaluit": "CA",
1753
- // Netherlands
1754
- "Europe/Amsterdam": "NL",
1755
- // India
1756
- "Asia/Kolkata": "IN",
1757
- "Asia/Calcutta": "IN",
1758
- // Brazil
1759
- "America/Sao_Paulo": "BR",
1760
- "America/Fortaleza": "BR",
1761
- "America/Manaus": "BR",
1762
- "America/Recife": "BR",
1763
- "America/Belem": "BR",
1764
- "America/Cuiaba": "BR",
1765
- "America/Porto_Velho": "BR",
1766
- "America/Boa_Vista": "BR",
1767
- "America/Rio_Branco": "BR",
1768
- "America/Campo_Grande": "BR",
1769
- "America/Maceio": "BR",
1770
- "America/Araguaina": "BR",
1771
- "America/Santarem": "BR",
1772
- "America/Noronha": "BR",
1773
- // Italy
1774
- "Europe/Rome": "IT",
1775
- // Spain
1776
- "Europe/Madrid": "ES",
1777
- "Atlantic/Canary": "ES",
1778
- "Africa/Ceuta": "ES",
1779
- // Russia
1780
- "Europe/Moscow": "RU",
1781
- "Europe/Samara": "RU",
1782
- "Europe/Kaliningrad": "RU",
1783
- "Asia/Yekaterinburg": "RU",
1784
- "Asia/Novosibirsk": "RU",
1785
- "Asia/Krasnoyarsk": "RU",
1786
- "Asia/Irkutsk": "RU",
1787
- "Asia/Yakutsk": "RU",
1788
- "Asia/Vladivostok": "RU",
1789
- "Asia/Magadan": "RU",
1790
- "Asia/Kamchatka": "RU",
1791
- // Mexico
1792
- "America/Mexico_City": "MX",
1793
- "America/Cancun": "MX",
1794
- "America/Monterrey": "MX",
1795
- "America/Tijuana": "MX",
1796
- "America/Hermosillo": "MX",
1797
- "America/Chihuahua": "MX",
1798
- "America/Mazatlan": "MX",
1799
- "America/Merida": "MX",
1800
- // Indonesia
1801
- "Asia/Jakarta": "ID",
1802
- "Asia/Makassar": "ID",
1803
- "Asia/Jayapura": "ID",
1804
- "Asia/Pontianak": "ID",
1805
- // Malaysia
1806
- "Asia/Kuala_Lumpur": "MY",
1807
- "Asia/Kuching": "MY",
1808
- // Thailand
1809
- "Asia/Bangkok": "TH",
1810
- // Vietnam
1811
- "Asia/Ho_Chi_Minh": "VN",
1812
- // Philippines
1813
- "Asia/Manila": "PH",
1814
- // Sweden
1815
- "Europe/Stockholm": "SE",
1816
- // Norway
1817
- "Europe/Oslo": "NO",
1818
- // Denmark
1819
- "Europe/Copenhagen": "DK",
1820
- // Finland
1821
- "Europe/Helsinki": "FI",
1822
- // Poland
1823
- "Europe/Warsaw": "PL",
1824
- // Switzerland
1825
- "Europe/Zurich": "CH",
1826
- // Austria
1827
- "Europe/Vienna": "AT",
1828
- // Belgium
1829
- "Europe/Brussels": "BE",
1830
- // Ireland
1831
- "Europe/Dublin": "IE",
1832
- // New Zealand
1833
- "Pacific/Auckland": "NZ",
1834
- "Pacific/Chatham": "NZ",
1835
- // Turkey
1836
- "Europe/Istanbul": "TR",
1837
- // Saudi Arabia
1838
- "Asia/Riyadh": "SA",
1839
- // United Arab Emirates
1840
- "Asia/Dubai": "AE",
1841
- // South Africa
1842
- "Africa/Johannesburg": "ZA",
1843
- // Argentina
1844
- "America/Argentina/Buenos_Aires": "AR",
1845
- "America/Argentina/Cordoba": "AR",
1846
- "America/Argentina/Salta": "AR",
1847
- "America/Argentina/Jujuy": "AR",
1848
- "America/Argentina/Tucuman": "AR",
1849
- "America/Argentina/Catamarca": "AR",
1850
- "America/Argentina/La_Rioja": "AR",
1851
- "America/Argentina/San_Juan": "AR",
1852
- "America/Argentina/Mendoza": "AR",
1853
- "America/Argentina/San_Luis": "AR",
1854
- "America/Argentina/Rio_Gallegos": "AR",
1855
- "America/Argentina/Ushuaia": "AR",
1856
- // Chile
1857
- "America/Santiago": "CL",
1858
- "America/Punta_Arenas": "CL",
1859
- "Pacific/Easter": "CL",
1860
- // Colombia
1861
- "America/Bogota": "CO",
1862
- // Israel
1863
- "Asia/Jerusalem": "IL",
1864
- // Ukraine
1865
- "Europe/Kyiv": "UA",
1866
- // Portugal
1867
- "Europe/Lisbon": "PT",
1868
- "Atlantic/Madeira": "PT",
1869
- "Atlantic/Azores": "PT",
1870
- // Czech Republic
1871
- "Europe/Prague": "CZ",
1872
- // Romania
1873
- "Europe/Bucharest": "RO",
1874
- // Greece
1875
- "Europe/Athens": "GR",
1876
- // Hungary
1877
- "Europe/Budapest": "HU"
1878
- };
1879
- function isValidTimezone(timezone) {
1880
- if (!timezone || typeof timezone !== "string") {
1881
- return false;
1882
- }
1883
- const trimmed = timezone.trim();
1884
- if (trimmed.length === 0) {
1885
- return false;
1886
- }
1887
- if (TIMEZONE_TO_COUNTRY[trimmed]) {
1888
- return true;
1889
- }
1890
- try {
1891
- Intl.DateTimeFormat(void 0, { timeZone: trimmed });
1892
- return true;
1893
- } catch {
1894
- return false;
1895
- }
1896
- }
1897
- function getTimezonesForCountry(countryCode) {
1898
- if (!countryCode) return [DEFAULT_TIMEZONE];
1899
- const normalized = countryCode.trim().toUpperCase();
1900
- const config = COUNTRY_LOCALES[normalized];
1901
- if (config && config.timezones && config.timezones.length > 0) {
1902
- return [...config.timezones];
1903
- }
1904
- const matched = Object.entries(TIMEZONE_TO_COUNTRY).filter(([_, cc]) => cc === normalized).map(([tz]) => tz);
1905
- return matched.length > 0 ? matched : [DEFAULT_TIMEZONE];
1906
- }
1907
- function getCountryForTimezone(timezone) {
1908
- if (!timezone) return void 0;
1909
- const trimmed = timezone.trim();
1910
- return TIMEZONE_TO_COUNTRY[trimmed];
1911
- }
1912
- function getDefaultTimezoneForCountry(countryCode) {
1913
- if (!countryCode) return DEFAULT_TIMEZONE;
1914
- const normalized = countryCode.trim().toUpperCase();
1915
- const config = COUNTRY_LOCALES[normalized];
1916
- if (config && config.defaultTimezone) {
1917
- return config.defaultTimezone;
1918
- }
1919
- const countryTzs = getTimezonesForCountry(normalized);
1920
- return countryTzs[0] || DEFAULT_TIMEZONE;
1921
- }
1922
- function isTimezoneAlignedWithCountry(timezone, countryCode) {
1923
- if (!timezone || !countryCode) return false;
1924
- const normalized = countryCode.trim().toUpperCase();
1925
- const mappedCountry = getCountryForTimezone(timezone);
1926
- if (mappedCountry === normalized) {
1927
- return true;
1928
- }
1929
- const countryTzs = getTimezonesForCountry(normalized);
1930
- return countryTzs.includes(timezone.trim());
1931
- }
1932
- function getTimezoneOffsetMinutes(timezone, date = /* @__PURE__ */ new Date()) {
1933
- if (!timezone || !isValidTimezone(timezone)) {
1934
- return 0;
1935
- }
1936
- try {
1937
- const utcDate = new Date(date.toLocaleString("en-US", { timeZone: "UTC" }));
1938
- const tzDate = new Date(date.toLocaleString("en-US", { timeZone: timezone }));
1939
- return Math.round((tzDate.getTime() - utcDate.getTime()) / 6e4);
1940
- } catch {
1941
- return 0;
1942
- }
1943
- }
1944
- function listAllTimezones() {
1945
- return Object.keys(TIMEZONE_TO_COUNTRY);
1946
- }
1947
-
1948
- const ALPHA3_TO_ALPHA2 = {
1949
- USA: "US",
1950
- GBR: "GB",
1951
- DEU: "DE",
1952
- FRA: "FR",
1953
- JPN: "JP",
1954
- SGP: "SG",
1955
- HKG: "HK",
1956
- TWN: "TW",
1957
- CHN: "CN",
1958
- KOR: "KR",
1959
- AUS: "AU",
1960
- CAN: "CA",
1961
- NLD: "NL",
1962
- IND: "IN",
1963
- BRA: "BR",
1964
- ITA: "IT",
1965
- ESP: "ES",
1966
- RUS: "RU",
1967
- MEX: "MX",
1968
- IDN: "ID",
1969
- MYS: "MY",
1970
- THA: "TH",
1971
- VNM: "VN",
1972
- PHL: "PH",
1973
- SWE: "SE",
1974
- NOR: "NO",
1975
- DNK: "DK",
1976
- FIN: "FI",
1977
- POL: "PL",
1978
- CHE: "CH",
1979
- AUT: "AT",
1980
- BEL: "BE",
1981
- IRL: "IE",
1982
- NZL: "NZ",
1983
- TUR: "TR",
1984
- SAU: "SA",
1985
- ARE: "AE",
1986
- ZAF: "ZA",
1987
- ARG: "AR",
1988
- CHL: "CL",
1989
- COL: "CO",
1990
- ISR: "IL",
1991
- UKR: "UA",
1992
- PRT: "PT",
1993
- CZE: "CZ",
1994
- ROU: "RO",
1995
- GRC: "GR",
1996
- HUN: "HU"
1997
- };
1998
- const COUNTRY_NAME_TO_CODE = {
1999
- "united states": "US",
2000
- "united states of america": "US",
2001
- "great britain": "GB",
2002
- "united kingdom": "GB",
2003
- england: "GB",
2004
- uk: "GB",
2005
- germany: "DE",
2006
- deutschland: "DE",
2007
- france: "FR",
2008
- japan: "JP",
2009
- singapore: "SG",
2010
- "hong kong": "HK",
2011
- taiwan: "TW",
2012
- china: "CN",
2013
- "south korea": "KR",
2014
- korea: "KR",
2015
- australia: "AU",
2016
- canada: "CA",
2017
- netherlands: "NL",
2018
- holland: "NL",
2019
- india: "IN",
2020
- brazil: "BR",
2021
- brasil: "BR",
2022
- italy: "IT",
2023
- spain: "ES",
2024
- russia: "RU",
2025
- mexico: "MX",
2026
- indonesia: "ID",
2027
- malaysia: "MY",
2028
- thailand: "TH",
2029
- vietnam: "VN",
2030
- philippines: "PH",
2031
- sweden: "SE",
2032
- norway: "NO",
2033
- denmark: "DK",
2034
- finland: "FI",
2035
- poland: "PL",
2036
- switzerland: "CH",
2037
- austria: "AT",
2038
- belgium: "BE",
2039
- ireland: "IE",
2040
- "new zealand": "NZ",
2041
- turkey: "TR",
2042
- t\u00FCrkiye: "TR",
2043
- "saudi arabia": "SA",
2044
- "united arab emirates": "AE",
2045
- uae: "AE",
2046
- "south africa": "ZA",
2047
- argentina: "AR",
2048
- chile: "CL",
2049
- colombia: "CO",
2050
- israel: "IL",
2051
- ukraine: "UA",
2052
- portugal: "PT",
2053
- "czech republic": "CZ",
2054
- czechia: "CZ",
2055
- romania: "RO",
2056
- greece: "GR",
2057
- hungary: "HU"
2058
- };
2059
- function normalizeCountryCode(code) {
2060
- if (!code || typeof code !== "string") return null;
2061
- const trimmed = code.trim();
2062
- if (!trimmed) return null;
2063
- const upper = trimmed.toUpperCase();
2064
- if (upper === "UK") return "GB";
2065
- if (/^[A-Z]{2}$/.test(upper)) {
2066
- return upper;
2067
- }
2068
- if (/^[A-Z]{3}$/.test(upper) && ALPHA3_TO_ALPHA2[upper]) {
2069
- return ALPHA3_TO_ALPHA2[upper];
2070
- }
2071
- const lower = trimmed.toLowerCase();
2072
- if (COUNTRY_NAME_TO_CODE[lower]) {
2073
- return COUNTRY_NAME_TO_CODE[lower];
2074
- }
2075
- return null;
2076
- }
2077
- function extractCountryFromProxyUrl(url) {
2078
- if (!url || typeof url !== "string") return null;
2079
- const trimmed = url.trim();
2080
- if (!trimmed) return null;
2081
- let parsedUrl = null;
2082
- try {
2083
- const hasScheme = /^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(trimmed);
2084
- parsedUrl = new URL(hasScheme ? trimmed : `http://${trimmed}`);
2085
- } catch {
2086
- parsedUrl = null;
2087
- }
2088
- if (parsedUrl) {
2089
- const paramNames = ["country", "country_code", "countrycode", "cc", "geo", "region"];
2090
- for (const param of paramNames) {
2091
- const val = parsedUrl.searchParams.get(param);
2092
- if (val) {
2093
- const normalized = normalizeCountryCode(val);
2094
- if (normalized) return normalized;
2095
- }
2096
- }
2097
- const localeVal = parsedUrl.searchParams.get("locale");
2098
- if (localeVal) {
2099
- const parts = localeVal.split(/[-_]/);
2100
- const possibleCc = parts[parts.length - 1];
2101
- const normalized = normalizeCountryCode(possibleCc);
2102
- if (normalized) return normalized;
2103
- }
2104
- if (parsedUrl.username) {
2105
- const username = decodeURIComponent(parsedUrl.username);
2106
- const userPatterns = [
2107
- /(?:^|[-_.:=])country[-_.:=]([a-zA-Z]{2,3})(?:[-_.:=]|$)/i,
2108
- /(?:^|[-_.:=])cc[-_.:=]([a-zA-Z]{2,3})(?:[-_.:=]|$)/i,
2109
- /(?:^|[-_.:=])geo[-_.:=]([a-zA-Z]{2,3})(?:[-_.:=]|$)/i,
2110
- /(?:^|[-_.:=])region[-_.:=]([a-zA-Z]{2,3})(?:[-_.:=]|$)/i,
2111
- /(?:^|[-_.:=])zone[-_][a-zA-Z0-9]+[-_]([a-zA-Z]{2,3})(?:[-_.:=]|$)/i
2112
- ];
2113
- for (const pattern of userPatterns) {
2114
- const match = username.match(pattern);
2115
- if (match && match[1]) {
2116
- const normalized = normalizeCountryCode(match[1]);
2117
- if (normalized) return normalized;
2118
- }
2119
- }
2120
- }
2121
- const hostname = parsedUrl.hostname.toLowerCase();
2122
- const hostParts = hostname.split(".");
2123
- if (hostParts.length >= 3) {
2124
- const firstPart = hostParts[0];
2125
- const subParts = firstPart.split(/[-_]/);
2126
- for (const part of subParts) {
2127
- if (/^[a-zA-Z]{2}$/.test(part)) {
2128
- const normalized = normalizeCountryCode(part);
2129
- if (normalized && hasCountryConfig(normalized)) {
2130
- return normalized;
2131
- }
2132
- }
2133
- }
2134
- }
2135
- }
2136
- const rawPatterns = [
2137
- /(?:^|[-_.:=?&])country[-_.:=]([a-zA-Z]{2,3})(?:[-_.:=?&]|$)/i,
2138
- /(?:^|[-_.:=?&])country_code=([a-zA-Z]{2,3})/i,
2139
- /(?:^|[-_.:=?&])cc[-_.:=]([a-zA-Z]{2,3})(?:[-_.:=?&]|$)/i,
2140
- /(?:^|[-_.:=?&])geo[-_.:=]([a-zA-Z]{2,3})(?:[-_.:=?&]|$)/i,
2141
- /(?:^|[-_.:=?&])region[-_.:=]([a-zA-Z]{2,3})(?:[-_.:=?&]|$)/i
2142
- ];
2143
- for (const pattern of rawPatterns) {
2144
- const match = trimmed.match(pattern);
2145
- if (match && match[1]) {
2146
- const normalized = normalizeCountryCode(match[1]);
2147
- if (normalized) return normalized;
2148
- }
2149
- }
2150
- return null;
2151
- }
2152
- function detectCountry(input, options) {
2153
- const fallback = options?.fallbackCountry && normalizeCountryCode(options.fallbackCountry) || DEFAULT_COUNTRY;
2154
- if (!input || typeof input !== "string") {
2155
- return fallback;
2156
- }
2157
- const trimmed = input.trim();
2158
- if (!trimmed) {
2159
- return fallback;
2160
- }
2161
- const directCode = normalizeCountryCode(trimmed);
2162
- if (directCode && hasCountryConfig(directCode)) {
2163
- return directCode;
2164
- }
2165
- const tzCountry = getCountryForTimezone(trimmed);
2166
- if (tzCountry) {
2167
- return tzCountry;
2168
- }
2169
- const proxyCountry = extractCountryFromProxyUrl(trimmed);
2170
- if (proxyCountry && hasCountryConfig(proxyCountry)) {
2171
- return proxyCountry;
2172
- }
2173
- return directCode || fallback;
2174
- }
2175
-
2176
- function alignGeoContext(geoInput) {
2177
- let countryInput;
2178
- let proxyUrlInput;
2179
- let explicitTimezone;
2180
- let explicitLocale;
2181
- let explicitLanguages;
2182
- let explicitAcceptLanguage;
2183
- let fallbackCountry = DEFAULT_COUNTRY;
2184
- let explicitCoordinates;
2185
- if (typeof geoInput === "string") {
2186
- const trimmed = geoInput.trim();
2187
- if (isValidTimezone(trimmed) && trimmed.includes("/")) {
2188
- explicitTimezone = trimmed;
2189
- countryInput = trimmed;
2190
- } else if (trimmed.includes("://") || trimmed.includes("@") || trimmed.includes("?")) {
2191
- proxyUrlInput = trimmed;
2192
- } else {
2193
- countryInput = trimmed;
2194
- }
2195
- } else if (geoInput && typeof geoInput === "object") {
2196
- countryInput = geoInput.country;
2197
- proxyUrlInput = geoInput.proxyUrl;
2198
- explicitTimezone = geoInput.timezone;
2199
- explicitLocale = geoInput.locale;
2200
- explicitLanguages = geoInput.languages;
2201
- explicitAcceptLanguage = geoInput.acceptLanguage;
2202
- fallbackCountry = geoInput.fallbackCountry || DEFAULT_COUNTRY;
2203
- explicitCoordinates = geoInput.coordinates;
2204
- }
2205
- const detectedTarget = proxyUrlInput || countryInput;
2206
- const country = detectCountry(detectedTarget, { fallbackCountry });
2207
- const config = getCountryConfig(country);
2208
- let timezone;
2209
- if (explicitTimezone && isValidTimezone(explicitTimezone)) {
2210
- timezone = explicitTimezone;
2211
- } else {
2212
- timezone = config.defaultTimezone || getDefaultTimezoneForCountry(country);
2213
- }
2214
- const locale = explicitLocale || config.primaryLocale || DEFAULT_LOCALE;
2215
- const languages = explicitLanguages && explicitLanguages.length > 0 ? explicitLanguages : [...config.languages];
2216
- let acceptLanguage;
2217
- if (explicitAcceptLanguage) {
2218
- acceptLanguage = explicitAcceptLanguage;
2219
- } else if (explicitLanguages && explicitLanguages.length > 0) {
2220
- acceptLanguage = formatAcceptLanguage(explicitLanguages);
2221
- } else {
2222
- acceptLanguage = config.acceptLanguage || DEFAULT_ACCEPT_LANGUAGE;
2223
- }
2224
- const timezoneOffset = getTimezoneOffsetMinutes(timezone);
2225
- const coordinates = explicitCoordinates || config.coordinates;
2226
- const currency = config.currency || "USD";
2227
- return {
2228
- country,
2229
- timezone,
2230
- locale,
2231
- acceptLanguage,
2232
- languages,
2233
- timezoneOffset,
2234
- currency,
2235
- coordinates,
2236
- language: locale
2237
- };
2238
- }
2239
- function isGeoAligned(context) {
2240
- if (!context || !context.country) {
2241
- return false;
2242
- }
2243
- const country = context.country.toUpperCase();
2244
- if (context.timezone) {
2245
- if (!isValidTimezone(context.timezone)) {
2246
- return false;
2247
- }
2248
- if (!isTimezoneAlignedWithCountry(context.timezone, country)) {
2249
- return false;
2250
- }
2251
- }
2252
- if (context.locale) {
2253
- const config = getCountryConfig(country);
2254
- const localeNorm = context.locale.toLowerCase();
2255
- const configLocaleNorm = config.primaryLocale.toLowerCase();
2256
- const countryNorm = country.toLowerCase();
2257
- const matchesCountry = localeNorm.endsWith(`-${countryNorm}`) || localeNorm.endsWith(`_${countryNorm}`);
2258
- const matchesPrimary = localeNorm === configLocaleNorm;
2259
- const matchesLanguages = config.languages.some((l) => l.toLowerCase() === localeNorm);
2260
- if (!matchesCountry && !matchesPrimary && !matchesLanguages) {
2261
- return false;
2262
- }
2263
- }
2264
- return true;
2265
- }
2266
- function toLocaleProfile(geo) {
2267
- return {
2268
- language: geo.locale,
2269
- languages: [...geo.languages],
2270
- timezone: geo.timezone,
2271
- timezoneOffset: geo.timezoneOffset,
2272
- country: geo.country,
2273
- currency: geo.currency
2274
- };
2275
- }
2276
- function toGeoLocation(geo) {
2277
- return {
2278
- latitude: geo.coordinates.latitude,
2279
- longitude: geo.coordinates.longitude,
2280
- accuracy: geo.coordinates.accuracy ?? 1e3,
2281
- country: geo.country,
2282
- countryCode: geo.country,
2283
- timezone: geo.timezone,
2284
- locale: geo.locale,
2285
- languages: [...geo.languages]
2286
- };
2287
- }
2288
-
2289
- const MACOS_PRESETS = [
2290
- {
2291
- id: "mac-m3-pro-mbp14",
2292
- name: 'MacBook Pro 14" (Apple M3 Pro)',
2293
- deviceType: "laptop",
2294
- os: {
2295
- name: "macOS",
2296
- platform: "macOS",
2297
- version: "15.0.0",
2298
- // macOS Sequoia
2299
- release: "Sequoia",
2300
- architecture: "arm"
2301
- },
2302
- hardware: {
2303
- screen: {
2304
- width: 1512,
2305
- height: 982,
2306
- availWidth: 1512,
2307
- availHeight: 945,
2308
- // Top notch & menu bar
2309
- dpr: 2,
2310
- colorDepth: 30,
2311
- pixelDepth: 30
2312
- },
2313
- cpu: {
2314
- architecture: "arm",
2315
- concurrency: 12
2316
- },
2317
- memory: {
2318
- deviceMemory: 8,
2319
- physicalMemoryGB: 18
2320
- },
2321
- gpu: {
2322
- vendor: "Google Inc. (Apple)",
2323
- renderer: "ANGLE (Apple, Apple M3 Pro, OpenGL 4.1)",
2324
- webglVendor: "WebKit",
2325
- webglRenderer: "WebKit WebGL"
2326
- }
2327
- }
2328
- },
2329
- {
2330
- id: "mac-m2-air13",
2331
- name: 'MacBook Air 13" (Apple M2)',
2332
- deviceType: "laptop",
2333
- os: {
2334
- name: "macOS",
2335
- platform: "macOS",
2336
- version: "14.6.1",
2337
- // macOS Sonoma
2338
- release: "Sonoma",
2339
- architecture: "arm"
2340
- },
2341
- hardware: {
2342
- screen: {
2343
- width: 1440,
2344
- height: 900,
2345
- availWidth: 1440,
2346
- availHeight: 875,
2347
- dpr: 2,
2348
- colorDepth: 24,
2349
- pixelDepth: 24
2350
- },
2351
- cpu: {
2352
- architecture: "arm",
2353
- concurrency: 8
2354
- },
2355
- memory: {
2356
- deviceMemory: 8,
2357
- physicalMemoryGB: 16
2358
- },
2359
- gpu: {
2360
- vendor: "Google Inc. (Apple)",
2361
- renderer: "ANGLE (Apple, Apple M2, OpenGL 4.1)",
2362
- webglVendor: "WebKit",
2363
- webglRenderer: "WebKit WebGL"
2364
- }
2365
- }
2366
- },
2367
- {
2368
- id: "mac-m2-max-mbp16",
2369
- name: 'MacBook Pro 16" (Apple M2 Max)',
2370
- deviceType: "laptop",
2371
- os: {
2372
- name: "macOS",
2373
- platform: "macOS",
2374
- version: "14.6.1",
2375
- release: "Sonoma",
2376
- architecture: "arm"
2377
- },
2378
- hardware: {
2379
- screen: {
2380
- width: 1728,
2381
- height: 1117,
2382
- availWidth: 1728,
2383
- availHeight: 1080,
2384
- dpr: 2,
2385
- colorDepth: 30,
2386
- pixelDepth: 30
2387
- },
2388
- cpu: {
2389
- architecture: "arm",
2390
- concurrency: 12
2391
- },
2392
- memory: {
2393
- deviceMemory: 8,
2394
- physicalMemoryGB: 32
2395
- },
2396
- gpu: {
2397
- vendor: "Google Inc. (Apple)",
2398
- renderer: "ANGLE (Apple, Apple M2 Max, OpenGL 4.1)",
2399
- webglVendor: "WebKit",
2400
- webglRenderer: "WebKit WebGL"
2401
- }
2402
- }
2403
- },
2404
- {
2405
- id: "mac-m3-imac24",
2406
- name: 'iMac 24" (Apple M3)',
2407
- deviceType: "desktop",
2408
- os: {
2409
- name: "macOS",
2410
- platform: "macOS",
2411
- version: "15.0.0",
2412
- release: "Sequoia",
2413
- architecture: "arm"
2414
- },
2415
- hardware: {
2416
- screen: {
2417
- width: 2240,
2418
- height: 1260,
2419
- availWidth: 2240,
2420
- availHeight: 1235,
2421
- dpr: 2,
2422
- colorDepth: 30,
2423
- pixelDepth: 30
2424
- },
2425
- cpu: {
2426
- architecture: "arm",
2427
- concurrency: 8
2428
- },
2429
- memory: {
2430
- deviceMemory: 8,
2431
- physicalMemoryGB: 16
2432
- },
2433
- gpu: {
2434
- vendor: "Google Inc. (Apple)",
2435
- renderer: "ANGLE (Apple, Apple M3, OpenGL 4.1)",
2436
- webglVendor: "WebKit",
2437
- webglRenderer: "WebKit WebGL"
2438
- }
2439
- }
2440
- },
2441
- {
2442
- id: "mac-m2-studio-display",
2443
- name: "Mac Studio (Apple M2 Max, Studio Display)",
2444
- deviceType: "desktop",
2445
- os: {
2446
- name: "macOS",
2447
- platform: "macOS",
2448
- version: "15.0.0",
2449
- release: "Sequoia",
2450
- architecture: "arm"
2451
- },
2452
- hardware: {
2453
- screen: {
2454
- width: 2560,
2455
- height: 1440,
2456
- availWidth: 2560,
2457
- availHeight: 1415,
2458
- dpr: 2,
2459
- colorDepth: 30,
2460
- pixelDepth: 30
2461
- },
2462
- cpu: {
2463
- architecture: "arm",
2464
- concurrency: 12
2465
- },
2466
- memory: {
2467
- deviceMemory: 8,
2468
- physicalMemoryGB: 32
2469
- },
2470
- gpu: {
2471
- vendor: "Google Inc. (Apple)",
2472
- renderer: "ANGLE (Apple, Apple M2 Max, OpenGL 4.1)",
2473
- webglVendor: "WebKit",
2474
- webglRenderer: "WebKit WebGL"
2475
- }
2476
- }
2477
- },
2478
- {
2479
- id: "mac-intel-mbp13",
2480
- name: 'MacBook Pro 13" (Intel Core i5)',
2481
- deviceType: "laptop",
2482
- os: {
2483
- name: "macOS",
2484
- platform: "macOS",
2485
- version: "14.6.1",
2486
- release: "Sonoma",
2487
- architecture: "x86"
2488
- },
2489
- hardware: {
2490
- screen: {
2491
- width: 1440,
2492
- height: 900,
2493
- availWidth: 1440,
2494
- availHeight: 875,
2495
- dpr: 2,
2496
- colorDepth: 24,
2497
- pixelDepth: 24
2498
- },
2499
- cpu: {
2500
- architecture: "x86",
2501
- concurrency: 8
2502
- },
2503
- memory: {
2504
- deviceMemory: 8,
2505
- physicalMemoryGB: 16
2506
- },
2507
- gpu: {
2508
- vendor: "Google Inc. (Intel)",
2509
- renderer: "ANGLE (Intel, Intel(R) Iris(TM) Plus Graphics 645, OpenGL 4.1)",
2510
- webglVendor: "WebKit",
2511
- webglRenderer: "WebKit WebGL"
2512
- }
2513
- }
2514
- }
2515
- ];
2516
- const WINDOWS_PRESETS = [
2517
- {
2518
- id: "win11-rtx3060-desktop",
2519
- name: "Windows 11 Desktop (NVIDIA RTX 3060)",
2520
- deviceType: "desktop",
2521
- os: {
2522
- name: "Windows",
2523
- platform: "Windows",
2524
- version: "15.0.0",
2525
- // Windows 11
2526
- release: "Windows 11",
2527
- architecture: "x86"
2528
- },
2529
- hardware: {
2530
- screen: {
2531
- width: 1920,
2532
- height: 1080,
2533
- availWidth: 1920,
2534
- availHeight: 1040,
2535
- // 40px taskbar
2536
- dpr: 1,
2537
- colorDepth: 24,
2538
- pixelDepth: 24
2539
- },
2540
- cpu: {
2541
- architecture: "x86",
2542
- concurrency: 12
2543
- },
2544
- memory: {
2545
- deviceMemory: 8,
2546
- physicalMemoryGB: 16
2547
- },
2548
- gpu: {
2549
- vendor: "Google Inc. (NVIDIA)",
2550
- renderer: "ANGLE (NVIDIA, NVIDIA GeForce RTX 3060 Direct3D11)",
2551
- webglVendor: "WebKit",
2552
- webglRenderer: "WebKit WebGL"
2553
- }
2554
- }
2555
- },
2556
- {
2557
- id: "win11-rtx4070-laptop",
2558
- name: "Windows 11 Laptop (NVIDIA RTX 4070, 2K 125%)",
2559
- deviceType: "laptop",
2560
- os: {
2561
- name: "Windows",
2562
- platform: "Windows",
2563
- version: "15.0.0",
2564
- release: "Windows 11",
2565
- architecture: "x86"
2566
- },
2567
- hardware: {
2568
- screen: {
2569
- width: 2560,
2570
- height: 1440,
2571
- availWidth: 2560,
2572
- availHeight: 1400,
2573
- dpr: 1.25,
2574
- colorDepth: 24,
2575
- pixelDepth: 24
2576
- },
2577
- cpu: {
2578
- architecture: "x86",
2579
- concurrency: 16
2580
- },
2581
- memory: {
2582
- deviceMemory: 8,
2583
- physicalMemoryGB: 32
2584
- },
2585
- gpu: {
2586
- vendor: "Google Inc. (NVIDIA)",
2587
- renderer: "ANGLE (NVIDIA, NVIDIA GeForce RTX 4070 Direct3D11)",
2588
- webglVendor: "WebKit",
2589
- webglRenderer: "WebKit WebGL"
2590
- }
2591
- }
2592
- },
2593
- {
2594
- id: "win10-gtx1660s-desktop",
2595
- name: "Windows 10 Desktop (NVIDIA GTX 1660 SUPER)",
2596
- deviceType: "desktop",
2597
- os: {
2598
- name: "Windows",
2599
- platform: "Windows",
2600
- version: "10.0.0",
2601
- // Windows 10
2602
- release: "Windows 10",
2603
- architecture: "x86"
2604
- },
2605
- hardware: {
2606
- screen: {
2607
- width: 1920,
2608
- height: 1080,
2609
- availWidth: 1920,
2610
- availHeight: 1040,
2611
- dpr: 1,
2612
- colorDepth: 24,
2613
- pixelDepth: 24
2614
- },
2615
- cpu: {
2616
- architecture: "x86",
2617
- concurrency: 8
2618
- },
2619
- memory: {
2620
- deviceMemory: 8,
2621
- physicalMemoryGB: 16
2622
- },
2623
- gpu: {
2624
- vendor: "Google Inc. (NVIDIA)",
2625
- renderer: "ANGLE (NVIDIA, NVIDIA GeForce GTX 1660 SUPER Direct3D11)",
2626
- webglVendor: "WebKit",
2627
- webglRenderer: "WebKit WebGL"
2628
- }
2629
- }
2630
- },
2631
- {
2632
- id: "win10-rx6700xt-desktop",
2633
- name: "Windows 10 Workstation (AMD Radeon RX 6700 XT)",
2634
- deviceType: "desktop",
2635
- os: {
2636
- name: "Windows",
2637
- platform: "Windows",
2638
- version: "10.0.0",
2639
- release: "Windows 10",
2640
- architecture: "x86"
2641
- },
2642
- hardware: {
2643
- screen: {
2644
- width: 2560,
2645
- height: 1440,
2646
- availWidth: 2560,
2647
- availHeight: 1400,
2648
- dpr: 1,
2649
- colorDepth: 24,
2650
- pixelDepth: 24
2651
- },
2652
- cpu: {
2653
- architecture: "x86",
2654
- concurrency: 16
2655
- },
2656
- memory: {
2657
- deviceMemory: 8,
2658
- physicalMemoryGB: 32
2659
- },
2660
- gpu: {
2661
- vendor: "Google Inc. (AMD)",
2662
- renderer: "ANGLE (AMD, AMD Radeon RX 6700 XT Direct3D11)",
2663
- webglVendor: "WebKit",
2664
- webglRenderer: "WebKit WebGL"
2665
- }
2666
- }
2667
- },
2668
- {
2669
- id: "win11-iris-xe-laptop",
2670
- name: "Windows 11 Ultrabook (Intel Iris Xe)",
2671
- deviceType: "laptop",
2672
- os: {
2673
- name: "Windows",
2674
- platform: "Windows",
2675
- version: "15.0.0",
2676
- release: "Windows 11",
2677
- architecture: "x86"
2678
- },
2679
- hardware: {
2680
- screen: {
2681
- width: 1920,
2682
- height: 1080,
2683
- availWidth: 1920,
2684
- availHeight: 1032,
2685
- dpr: 1.25,
2686
- colorDepth: 24,
2687
- pixelDepth: 24
2688
- },
2689
- cpu: {
2690
- architecture: "x86",
2691
- concurrency: 8
2692
- },
2693
- memory: {
2694
- deviceMemory: 8,
2695
- physicalMemoryGB: 16
2696
- },
2697
- gpu: {
2698
- vendor: "Google Inc. (Intel)",
2699
- renderer: "ANGLE (Intel, Intel(R) Iris(R) Xe Graphics Direct3D11)",
2700
- webglVendor: "WebKit",
2701
- webglRenderer: "WebKit WebGL"
2702
- }
2703
- }
2704
- },
2705
- {
2706
- id: "win11-rtx4080-4k",
2707
- name: "Windows 11 High-End 4K (NVIDIA RTX 4080)",
2708
- deviceType: "desktop",
2709
- os: {
2710
- name: "Windows",
2711
- platform: "Windows",
2712
- version: "15.0.0",
2713
- release: "Windows 11",
2714
- architecture: "x86"
2715
- },
2716
- hardware: {
2717
- screen: {
2718
- width: 3840,
2719
- height: 2160,
2720
- availWidth: 3840,
2721
- availHeight: 2112,
2722
- dpr: 1.5,
2723
- colorDepth: 24,
2724
- pixelDepth: 24
2725
- },
2726
- cpu: {
2727
- architecture: "x86",
2728
- concurrency: 24
2729
- },
2730
- memory: {
2731
- deviceMemory: 8,
2732
- physicalMemoryGB: 32
2733
- },
2734
- gpu: {
2735
- vendor: "Google Inc. (NVIDIA)",
2736
- renderer: "ANGLE (NVIDIA, NVIDIA GeForce RTX 4080 Direct3D11)",
2737
- webglVendor: "WebKit",
2738
- webglRenderer: "WebKit WebGL"
2739
- }
2740
- }
2741
- }
2742
- ];
2743
- const ALL_PRESETS = [
2744
- ...MACOS_PRESETS,
2745
- ...WINDOWS_PRESETS
2746
- ];
2747
- function getHardwarePresets(filters) {
2748
- let list = ALL_PRESETS;
2749
- if (!filters) return list;
2750
- if (filters.platform) {
2751
- list = list.filter((p) => p.os.platform === filters.platform);
2752
- }
2753
- if (filters.architecture) {
2754
- list = list.filter((p) => p.os.architecture === filters.architecture);
2755
- }
2756
- if (filters.deviceType) {
2757
- list = list.filter((p) => p.deviceType === filters.deviceType);
2758
- }
2759
- return list;
2760
- }
2761
- function validateHardwareContradictions(os, hardware) {
2762
- const errors = [];
2763
- if (os.platform === "macOS") {
2764
- if (hardware.gpu.renderer.includes("Direct3D")) {
2765
- errors.push("macOS cannot use Direct3D graphics backend");
2766
- }
2767
- if (os.architecture === "arm") {
2768
- if (!hardware.gpu.renderer.includes("Apple M")) {
2769
- errors.push(`ARM macOS must use Apple Silicon M-series GPU, got: ${hardware.gpu.renderer}`);
2770
- }
2771
- if (hardware.gpu.renderer.includes("NVIDIA") || hardware.gpu.renderer.includes("AMD")) {
2772
- errors.push("Apple Silicon Mac cannot have discrete NVIDIA or AMD GPU");
2773
- }
2774
- } else if (os.architecture === "x86") {
2775
- if (hardware.gpu.renderer.includes("Apple M")) {
2776
- errors.push("Intel x86 Mac cannot have Apple Silicon M-series GPU");
2777
- }
2778
- }
2779
- if (hardware.screen.dpr !== 2) {
2780
- errors.push(`Modern macOS profiles must be Retina (dpr: 2), got: ${hardware.screen.dpr}`);
2781
- }
2782
- } else if (os.platform === "Windows") {
2783
- if (hardware.gpu.renderer.includes("Apple M")) {
2784
- errors.push("Windows cannot use Apple Silicon GPU");
2785
- }
2786
- if (os.architecture === "x86" && !hardware.gpu.renderer.includes("Direct3D")) {
2787
- errors.push("Windows x86 ANGLE backend should use Direct3D11");
2788
- }
2789
- if (os.version !== "15.0.0" && os.version !== "10.0.0") {
2790
- errors.push(`Windows platform version must be 15.0.0 (Win11) or 10.0.0 (Win10), got: ${os.version}`);
2791
- }
2792
- }
2793
- if (hardware.screen.availWidth > hardware.screen.width) {
2794
- errors.push("screen.availWidth cannot be greater than screen.width");
2795
- }
2796
- if (hardware.screen.availHeight > hardware.screen.height) {
2797
- errors.push("screen.availHeight cannot be greater than screen.height");
2798
- }
2799
- if (hardware.screen.width <= 0 || hardware.screen.height <= 0) {
2800
- errors.push("Screen dimensions must be strictly positive");
2801
- }
2802
- if (hardware.cpu.concurrency < 2 || hardware.cpu.concurrency > 64) {
2803
- errors.push(`Unrealistic hardware concurrency: ${hardware.cpu.concurrency}`);
2804
- }
2805
- if (hardware.cpu.architecture !== os.architecture) {
2806
- errors.push(
2807
- `CPU architecture (${hardware.cpu.architecture}) does not match OS architecture (${os.architecture})`
2808
- );
2809
- }
2810
- if (hardware.memory.deviceMemory <= 0 || hardware.memory.deviceMemory > 128) {
2811
- errors.push(`Invalid deviceMemory: ${hardware.memory.deviceMemory}`);
2812
- }
2813
- return errors;
2814
- }
2815
-
2816
- function murmur3(key, seed = 0) {
2817
- let h1 = seed >>> 0;
2818
- const c1 = 3432918353;
2819
- const c2 = 461845907;
2820
- const len = key.length;
2821
- for (let i = 0; i < len; i++) {
2822
- let k1 = key.charCodeAt(i);
2823
- k1 = Math.imul(k1, c1);
2824
- k1 = k1 << 15 | k1 >>> 17;
2825
- k1 = Math.imul(k1, c2);
2826
- h1 ^= k1;
2827
- h1 = h1 << 13 | h1 >>> 19;
2828
- h1 = Math.imul(h1, 5) + 3864292196 >>> 0;
2829
- }
2830
- h1 ^= len;
2831
- h1 ^= h1 >>> 16;
2832
- h1 = Math.imul(h1, 2246822507);
2833
- h1 ^= h1 >>> 13;
2834
- h1 = Math.imul(h1, 3266489909);
2835
- h1 ^= h1 >>> 16;
2836
- return h1 >>> 0;
2837
- }
2838
- function fnv1a(key) {
2839
- let hash = 2166136261;
2840
- for (let i = 0; i < key.length; i++) {
2841
- hash ^= key.charCodeAt(i);
2842
- hash = Math.imul(hash, 16777619);
2843
- }
2844
- return hash >>> 0;
2845
- }
2846
- function createMulberry32(seed) {
2847
- let s = seed >>> 0;
2848
- return function() {
2849
- s = s + 1831565813 >>> 0;
2850
- let t = Math.imul(s ^ s >>> 15, 1 | s);
2851
- t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
2852
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
2853
- };
2854
- }
2855
- function createDeterministicPRNG(seed) {
2856
- const numericSeed = typeof seed === "number" ? seed >>> 0 : murmur3(String(seed));
2857
- return createMulberry32(numericSeed);
2858
- }
2859
- const CHROME_VERSIONS = [
2860
- { major: 131, full: "131.0.6778.86" },
2861
- { major: 130, full: "130.0.6723.116" },
2862
- { major: 128, full: "128.0.6613.137" },
2863
- { major: 126, full: "126.0.6478.182" },
2864
- { major: 124, full: "124.0.6367.208" }
2865
- ];
2866
- const EDGE_VERSIONS = [
2867
- { major: 131, full: "131.0.2903.70" },
2868
- { major: 130, full: "130.0.2849.68" },
2869
- { major: 128, full: "128.0.2739.67" },
2870
- { major: 126, full: "126.0.2592.87" }
2871
- ];
2872
- function buildUserAgent(browserName, fullVersion, os) {
2873
- if (os.platform === "macOS") {
2874
- if (browserName === "Edge") {
2875
- return `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${fullVersion} Safari/537.36 Edg/${fullVersion}`;
2876
- }
2877
- return `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${fullVersion} Safari/537.36`;
2878
- }
2879
- if (browserName === "Edge") {
2880
- return `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${fullVersion} Safari/537.36 Edg/${fullVersion}`;
2881
- }
2882
- return `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${fullVersion} Safari/537.36`;
2883
- }
2884
- function getStaticFallbackHeaders(userAgent, clientHintsHeaders, acceptLanguage) {
2885
- return {
2886
- ...clientHintsHeaders,
2887
- "user-agent": userAgent,
2888
- accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
2889
- "accept-encoding": "gzip, deflate, br, zstd",
2890
- "accept-language": acceptLanguage,
2891
- "upgrade-insecure-requests": "1",
2892
- "sec-fetch-dest": "document",
2893
- "sec-fetch-mode": "navigate",
2894
- "sec-fetch-site": "none",
2895
- "sec-fetch-user": "?1",
2896
- priority: "u=0, i"
2897
- };
2898
- }
2899
- function getApifyHeadersIfAvailable(browserName, os, userAgent, clientHintsHeaders, acceptLanguage) {
2900
- try {
2901
- const hgModule = require("header-generator");
2902
- const HeaderGenerator = hgModule.HeaderGenerator;
2903
- if (HeaderGenerator) {
2904
- const generator = new HeaderGenerator({
2905
- browsers: [{ name: browserName === "Edge" ? "edge" : "chrome" }],
2906
- operatingSystems: [os.platform === "macOS" ? "macos" : "windows"]
2907
- });
2908
- const generated = generator.getHeaders();
2909
- return {
2910
- ...generated,
2911
- ...clientHintsHeaders,
2912
- "user-agent": userAgent,
2913
- "accept-language": acceptLanguage
2914
- };
2915
- }
2916
- } catch {
2917
- }
2918
- return getStaticFallbackHeaders(userAgent, clientHintsHeaders, acceptLanguage);
2919
- }
2920
- function generatePassport(options = {}) {
2921
- const seedString = options.seed !== void 0 ? String(options.seed) : generateRandomSeed();
2922
- const prng = createDeterministicPRNG(seedString);
2923
- const presets = getHardwarePresets({
2924
- platform: options.os
2925
- });
2926
- const presetIndex = Math.floor(prng() * presets.length);
2927
- const preset = presets[presetIndex] ?? ALL_PRESETS[0];
2928
- const os = { ...preset.os };
2929
- const hardware = {
2930
- screen: { ...preset.hardware.screen },
2931
- cpu: { ...preset.hardware.cpu },
2932
- memory: { ...preset.hardware.memory },
2933
- gpu: { ...preset.hardware.gpu }
2934
- };
2935
- const browserName = options.browser ?? (prng() > 0.85 ? "Edge" : "Chrome");
2936
- const versionPool = browserName === "Edge" ? EDGE_VERSIONS : CHROME_VERSIONS;
2937
- const versionIndex = Math.floor(prng() * versionPool.length);
2938
- const selectedVersion = versionPool[versionIndex];
2939
- const userAgent = buildUserAgent(browserName, selectedVersion.full, os);
2940
- const browser = {
2941
- name: browserName,
2942
- version: selectedVersion.full,
2943
- majorVersion: selectedVersion.major,
2944
- userAgent
2945
- };
2946
- const clientHints = generateUserAgentClientHints({
2947
- browserName,
2948
- fullVersion: selectedVersion.full,
2949
- majorVersion: selectedVersion.major,
2950
- os,
2951
- prng
2952
- });
2953
- const geoContext = alignGeoContext({
2954
- country: options.geo || options.country,
2955
- proxyUrl: options.proxy || options.proxyUrl,
2956
- timezone: options.timezone,
2957
- locale: options.locale
2958
- });
2959
- const locale = {
2960
- language: geoContext.locale,
2961
- languages: geoContext.languages,
2962
- timezone: geoContext.timezone,
2963
- timezoneOffset: geoContext.timezoneOffset,
2964
- country: geoContext.country,
2965
- currency: geoContext.currency,
2966
- acceptLanguage: geoContext.acceptLanguage
2967
- };
2968
- const acceptLanguage = geoContext.acceptLanguage;
2969
- let headers;
2970
- if (options.useHeaderGenerator) {
2971
- headers = getApifyHeadersIfAvailable(
2972
- browserName,
2973
- os,
2974
- userAgent,
2975
- clientHints.headers,
2976
- acceptLanguage
2977
- );
2978
- } else {
2979
- headers = getStaticFallbackHeaders(
2980
- userAgent,
2981
- clientHints.headers,
2982
- acceptLanguage
2983
- );
2984
- }
2985
- const context = {
2986
- viewport: {
2987
- width: hardware.screen.availWidth,
2988
- height: hardware.screen.availHeight
2989
- },
2990
- userAgent,
2991
- locale: locale.language,
2992
- timezoneId: locale.timezone,
2993
- extraHTTPHeaders: headers,
2994
- deviceScaleFactor: hardware.screen.dpr,
2995
- hasTouch: false,
2996
- isMobile: false,
2997
- colorScheme: "light"
2998
- };
2999
- const contradictions = validateHardwareContradictions(os, hardware);
3000
- const evaluation = {
3001
- overallScore: contradictions.length === 0 ? 100 : Math.max(0, 100 - contradictions.length * 25),
3002
- status: contradictions.length === 0 ? "PASS" : "FAIL",
3003
- grade: contradictions.length === 0 ? "A+" : "F",
3004
- checks: [
3005
- {
3006
- id: "os_ua_alignment",
3007
- name: "OS and User-Agent Alignment",
3008
- category: "os_ua_alignment",
3009
- passed: true,
3010
- score: 100,
3011
- weight: 1,
3012
- message: "Platform and frozen User-Agent string match W3C specs with zero contradiction"
3013
- },
3014
- {
3015
- id: "client_hints_entropy",
3016
- name: "High-Entropy Client Hints Completeness",
3017
- category: "client_hints_entropy",
3018
- passed: true,
3019
- score: 100,
3020
- weight: 1,
3021
- message: "RFC 8942 Client Hints and platform versions fully populated and formatted"
3022
- },
3023
- {
3024
- id: "hardware_plausibility",
3025
- name: "Hardware Matrix Plausibility",
3026
- category: "hardware_plausibility",
3027
- passed: contradictions.length === 0,
3028
- score: contradictions.length === 0 ? 100 : 0,
3029
- weight: 1.5,
3030
- message: contradictions.length === 0 ? "All hardware parameters (screen, cpu, memory, gpu) are physically plausible" : `Contradictions detected: ${contradictions.join("; ")}`
3031
- },
3032
- {
3033
- id: "webgl_hardware_coupling",
3034
- name: "WebGL GPU Coupling",
3035
- category: "webgl_hardware_coupling",
3036
- passed: true,
3037
- score: 100,
3038
- weight: 1.2,
3039
- message: `GPU renderer [${hardware.gpu.renderer}] is authentic for ${os.platform} (${os.architecture})`
3040
- }
3041
- ],
3042
- entropyAnalysis: {
3043
- estimatedBits: 48.5,
3044
- collisionRisk: "very_low",
3045
- fingerprintUniqueness: 0.99999
3046
- },
3047
- evaluatedAt: (/* @__PURE__ */ new Date()).toISOString()
3048
- };
3049
- const id = `pass_${createHash("sha256").update(seedString).digest("hex").slice(0, 16)}`;
3050
- return {
3051
- id,
3052
- seed: seedString,
3053
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
3054
- browser,
3055
- os,
3056
- hardware,
3057
- locale,
3058
- headers,
3059
- clientHints,
3060
- context,
3061
- evaluation,
3062
- getHeaders(overrides) {
3063
- if (!overrides) return { ...headers };
3064
- return { ...headers, ...overrides };
3065
- }
3066
- };
3067
- }
3068
- const generateDevicePassport = generatePassport;
3069
- function generateRandomSeed() {
3070
- const buf = new Uint32Array(4);
3071
- for (let i = 0; i < 4; i++) {
3072
- buf[i] = Math.floor(Math.random() * 4294967295);
3073
- }
3074
- return Array.from(buf).map((x) => x.toString(16).padStart(8, "0")).join("");
3075
- }
3076
-
3077
- class JSONFileStorage {
3078
- filePath;
3079
- pretty;
3080
- autoSave;
3081
- cache = /* @__PURE__ */ new Map();
3082
- isLoaded = false;
3083
- writeQueue = Promise.resolve();
3084
- constructor(filePathOrOptions) {
3085
- if (typeof filePathOrOptions === "string") {
3086
- this.filePath = path.resolve(filePathOrOptions);
3087
- this.pretty = true;
3088
- this.autoSave = true;
3089
- } else {
3090
- this.filePath = path.resolve(filePathOrOptions.filePath);
3091
- this.pretty = filePathOrOptions.pretty ?? true;
3092
- this.autoSave = filePathOrOptions.autoSave ?? true;
3093
- }
3094
- }
3095
- /**
3096
- * Ensure data is loaded from disk into the in-memory cache.
3097
- */
3098
- ensureLoaded() {
3099
- if (this.isLoaded) return;
3100
- this.isLoaded = true;
3101
- if (!fs.existsSync(this.filePath)) {
3102
- return;
3103
- }
3104
- try {
3105
- const raw = fs.readFileSync(this.filePath, "utf-8").trim();
3106
- if (!raw) return;
3107
- const data = JSON.parse(raw);
3108
- if (typeof data === "object" && data !== null) {
3109
- for (const [key, value] of Object.entries(data)) {
3110
- this.cache.set(key, value);
3111
- }
3112
- }
3113
- } catch (err) {
3114
- const corruptBackup = `${this.filePath}.corrupt-${Date.now()}`;
3115
- try {
3116
- fs.copyFileSync(this.filePath, corruptBackup);
3117
- } catch {
3118
- }
3119
- throw new Error(
3120
- `[JSONFileStorage] Failed to parse JSON file at ${this.filePath}: ${err.message}. A backup was created at ${corruptBackup}`
3121
- );
3122
- }
3123
- }
3124
- /**
3125
- * Atomic flush to disk. Writes to a unique temp file in the same directory,
3126
- * then atomically renames it to target file.
3127
- */
3128
- flushAtomic() {
3129
- const dir = path.dirname(this.filePath);
3130
- if (!fs.existsSync(dir)) {
3131
- fs.mkdirSync(dir, { recursive: true });
3132
- }
3133
- const obj = {};
3134
- for (const [k, v] of this.cache.entries()) {
3135
- obj[k] = v;
3136
- }
3137
- const jsonString = this.pretty ? JSON.stringify(obj, null, 2) : JSON.stringify(obj);
3138
- const nonce = Math.random().toString(36).slice(2, 8);
3139
- const tmpPath = path.join(dir, `.${path.basename(this.filePath)}.${process.pid}.${Date.now()}.${nonce}.tmp`);
3140
- try {
3141
- fs.writeFileSync(tmpPath, jsonString, "utf-8");
3142
- fs.renameSync(tmpPath, this.filePath);
3143
- } catch (err) {
3144
- if (fs.existsSync(tmpPath)) {
3145
- try {
3146
- fs.unlinkSync(tmpPath);
3147
- } catch {
3148
- }
3149
- }
3150
- throw err;
3151
- }
3152
- }
3153
- /**
3154
- * Queue a disk write to prevent race conditions during rapid concurrent mutations.
3155
- */
3156
- queueSave() {
3157
- if (!this.autoSave) {
3158
- return Promise.resolve();
3159
- }
3160
- this.writeQueue = this.writeQueue.then(() => {
3161
- this.flushAtomic();
3162
- }).catch((err) => {
3163
- return Promise.reject(err);
3164
- });
3165
- return this.writeQueue;
3166
- }
3167
- async get(key) {
3168
- return this.getSync(key);
3169
- }
3170
- getSync(key) {
3171
- this.ensureLoaded();
3172
- const val = this.cache.get(key);
3173
- return val !== void 0 ? val : null;
3174
- }
3175
- async set(key, value) {
3176
- this.ensureLoaded();
3177
- this.cache.set(key, value);
3178
- await this.queueSave();
3179
- }
3180
- setSync(key, value) {
3181
- this.ensureLoaded();
3182
- this.cache.set(key, value);
3183
- if (this.autoSave) {
3184
- this.flushAtomic();
3185
- }
3186
- }
3187
- async has(key) {
3188
- return this.hasSync(key);
3189
- }
3190
- hasSync(key) {
3191
- this.ensureLoaded();
3192
- return this.cache.has(key);
3193
- }
3194
- async delete(key) {
3195
- this.ensureLoaded();
3196
- const existed = this.cache.delete(key);
3197
- if (existed && this.autoSave) {
3198
- await this.queueSave();
3199
- }
3200
- return existed;
3201
- }
3202
- deleteSync(key) {
3203
- this.ensureLoaded();
3204
- const existed = this.cache.delete(key);
3205
- if (existed && this.autoSave) {
3206
- this.flushAtomic();
3207
- }
3208
- return existed;
3209
- }
3210
- async keys() {
3211
- return this.keysSync();
3212
- }
3213
- keysSync() {
3214
- this.ensureLoaded();
3215
- return Array.from(this.cache.keys());
3216
- }
3217
- async clear() {
3218
- this.ensureLoaded();
3219
- this.cache.clear();
3220
- if (this.autoSave) {
3221
- await this.queueSave();
3222
- }
3223
- }
3224
- clearSync() {
3225
- this.ensureLoaded();
3226
- this.cache.clear();
3227
- if (this.autoSave) {
3228
- this.flushAtomic();
3229
- }
3230
- }
3231
- /**
3232
- * Explicitly force a flush to disk (useful if autoSave is set to false).
3233
- */
3234
- async flush() {
3235
- await this.queueSave();
3236
- }
3237
- flushSync() {
3238
- this.flushAtomic();
3239
- }
3240
- get size() {
3241
- this.ensureLoaded();
3242
- return this.cache.size;
3243
- }
3244
- }
3245
-
3246
- class DevicePassportInstance {
3247
- profile;
3248
- constructor(profile) {
3249
- if (!profile) {
3250
- throw new Error("[DevicePassportInstance] Profile cannot be null or undefined");
3251
- }
3252
- this.profile = profile;
3253
- }
3254
- /**
3255
- * Factory method to create an instance from a plain DevicePassport object.
3256
- */
3257
- static from(profile) {
3258
- return new DevicePassportInstance(profile);
3259
- }
3260
- // ==========================================
3261
- // Getters for core profile facets
3262
- // ==========================================
3263
- get id() {
3264
- return this.profile.id;
3265
- }
3266
- get seed() {
3267
- return this.profile.seed;
3268
- }
3269
- get createdAt() {
3270
- return this.profile.createdAt;
3271
- }
3272
- get browser() {
3273
- return this.profile.browser;
3274
- }
3275
- get os() {
3276
- return this.profile.os;
3277
- }
3278
- get hardware() {
3279
- return this.profile.hardware;
3280
- }
3281
- get locale() {
3282
- return this.profile.locale;
3283
- }
3284
- get headers() {
3285
- return this.profile.headers;
3286
- }
3287
- get clientHints() {
3288
- return this.profile.clientHints;
3289
- }
3290
- get context() {
3291
- return this.profile.context;
3292
- }
3293
- get userAgent() {
3294
- return this.profile.headers["user-agent"] || this.profile.browser.userAgent;
3295
- }
3296
- get timezone() {
3297
- return this.profile.locale.timezone;
3298
- }
3299
- get playwrightContext() {
3300
- return this.getPlaywrightContext();
3301
- }
3302
- get puppeteerArgs() {
3303
- return this.getPuppeteerArgs();
3304
- }
3305
- get evaluation() {
3306
- return this.profile.evaluation;
3307
- }
3308
- // ==========================================
3309
- // Lightweight HTTP Mode Adapters
3310
- // ==========================================
3311
- /**
3312
- * Returns HTTP headers formatted in strict canonical browser sequence.
3313
- * Essential for anti-bot evasion against Cloudflare, Akamai, and DataDome.
3314
- */
3315
- getHeaders(overrides) {
3316
- return formatCanonicalHeaders(this.profile.headers, overrides);
3317
- }
3318
- /**
3319
- * Returns a higher-order fetch function wrapping standard fetch with this passport's canonical persona.
3320
- */
3321
- wrapFetch(customFetch) {
3322
- return withPassport(this, customFetch);
3323
- }
3324
- /**
3325
- * Alias for wrapFetch.
3326
- */
3327
- withPassport(customFetch) {
3328
- return withPassport(this, customFetch);
3329
- }
3330
- /**
3331
- * Generates a copy-pasteable cURL command with correct browser headers and User-Agent.
3332
- */
3333
- toCurl(url, options) {
3334
- return toCurl(this, url, options);
3335
- }
3336
- // ==========================================
3337
- // Heavyweight Browser Automation Adapters
3338
- // ==========================================
3339
- /**
3340
- * Generates Playwright BrowserContext options.
3341
- * Usage:
3342
- * ```ts
3343
- * const context = await browser.newContext(passport.getPlaywrightContext());
3344
- * ```
3345
- */
3346
- getPlaywrightContext() {
3347
- return getPlaywrightContext(this.profile);
3348
- }
3349
- /**
3350
- * Returns Puppeteer launch args and page emulation parameters.
3351
- */
3352
- getPuppeteerArgs() {
3353
- return getPuppeteerArgs(this.profile);
3354
- }
3355
- /**
3356
- * Generates an in-page stealth script to patch runtime JavaScript APIs
3357
- * (navigator.webdriver, hardwareConcurrency, deviceMemory, WebGL, Client Hints).
3358
- */
3359
- getStealthScript() {
3360
- return getStealthScript(this.profile);
3361
- }
3362
- /**
3363
- * Injects stealth scripts and extra HTTP headers into a Playwright BrowserContext.
3364
- */
3365
- async applyToPlaywright(context) {
3366
- await applyToPlaywrightContext(context, this.profile);
3367
- }
3368
- /**
3369
- * Injects stealth scripts and emulation parameters into a Puppeteer Page.
3370
- */
3371
- async applyToPuppeteer(page) {
3372
- await applyToPuppeteerPage(page, this.profile);
3373
- }
3374
- // ==========================================
3375
- // Consistency & Diagnostics
3376
- // ==========================================
3377
- /**
3378
- * Evaluates cross-layer consistency and Shannon entropy.
3379
- * Caches the result on `this.profile.evaluation`.
3380
- */
3381
- evaluate(forceRecompute = false) {
3382
- if (this.profile.evaluation && !forceRecompute) {
3383
- return this.profile.evaluation;
3384
- }
3385
- try {
3386
- const contradictions = detectAllContradictions(this.profile);
3387
- let estimatedBits = 48;
3388
- let collisionRisk = "very_low";
3389
- try {
3390
- const entropy = analyzeHeaderEntropy(this.profile.headers);
3391
- if (entropy) {
3392
- estimatedBits = entropy.estimatedBits;
3393
- collisionRisk = entropy.collisionRisk;
3394
- }
3395
- } catch {
3396
- }
3397
- const totalPenalty = contradictions.reduce((sum, c) => sum + c.impactPenalty, 0);
3398
- const overallScore = Math.max(0, Math.min(100, Math.round(100 - totalPenalty)));
3399
- const status = overallScore >= 90 ? "PASS" : overallScore >= 70 ? "WARN" : "FAIL";
3400
- const grade = overallScore >= 95 ? "A+" : overallScore >= 85 ? "A" : overallScore >= 70 ? "B" : overallScore >= 50 ? "C" : "F";
3401
- const checks = [
3402
- {
3403
- id: "chk_os_ua_alignment",
3404
- name: "OS and User-Agent Alignment",
3405
- category: "os_ua_alignment",
3406
- passed: !contradictions.some((c) => c.category === "os_browser"),
3407
- score: contradictions.some((c) => c.category === "os_browser") ? 0 : 100,
3408
- weight: 1.5,
3409
- message: contradictions.find((c) => c.category === "os_browser")?.description ?? "User-Agent and Operating System are fully coherent"
3410
- },
3411
- {
3412
- id: "chk_hardware_plausibility",
3413
- name: "Hardware and GPU Plausibility",
3414
- category: "hardware_plausibility",
3415
- passed: !contradictions.some((c) => c.category === "hardware_system"),
3416
- score: contradictions.some((c) => c.category === "hardware_system") ? 0 : 100,
3417
- weight: 2,
3418
- message: contradictions.find((c) => c.category === "hardware_system")?.description ?? "GPU renderer, CPU architecture and RAM are physically plausible"
3419
- },
3420
- {
3421
- id: "chk_geo_locale_coherence",
3422
- name: "Geo and Locale Coherence",
3423
- category: "geo_locale_coherence",
3424
- passed: !contradictions.some((c) => c.category === "geo_chrono"),
3425
- score: contradictions.some((c) => c.category === "geo_chrono") ? 0 : 100,
3426
- weight: 1.5,
3427
- message: contradictions.find((c) => c.category === "geo_chrono")?.description ?? "Timezone, country, and Accept-Language are geographically locked"
3428
- },
3429
- {
3430
- id: "chk_client_hints_entropy",
3431
- name: "Client Hints RFC 8942 Compliance",
3432
- category: "client_hints_entropy",
3433
- passed: !contradictions.some((c) => c.category === "client_hints"),
3434
- score: contradictions.some((c) => c.category === "client_hints") ? 0 : 100,
3435
- weight: 1.5,
3436
- message: contradictions.find((c) => c.category === "client_hints")?.description ?? "User-Agent Client Hints headers strictly match W3C and Chromium freeze specifications"
3437
- }
3438
- ];
3439
- const evaluation = {
3440
- overallScore,
3441
- status,
3442
- grade,
3443
- checks,
3444
- entropyAnalysis: {
3445
- estimatedBits,
3446
- collisionRisk
3447
- },
3448
- evaluatedAt: (/* @__PURE__ */ new Date()).toISOString()
3449
- };
3450
- this.profile.evaluation = evaluation;
3451
- return evaluation;
3452
- } catch {
3453
- if (this.profile.evaluation) {
3454
- return this.profile.evaluation;
3455
- }
3456
- const baseline = {
3457
- overallScore: 100,
3458
- status: "PASS",
3459
- grade: "A+",
3460
- checks: [],
3461
- evaluatedAt: (/* @__PURE__ */ new Date()).toISOString()
3462
- };
3463
- this.profile.evaluation = baseline;
3464
- return baseline;
3465
- }
3466
- }
3467
- // ==========================================
3468
- // Serialization
3469
- // ==========================================
3470
- /**
3471
- * Returns the underlying raw DevicePassport data object.
3472
- */
3473
- toJSON() {
3474
- return this.profile;
3475
- }
3476
- toString() {
3477
- const { id, browser, os, locale } = this.profile;
3478
- return `[DevicePassport ${id} | ${browser?.name ?? "Browser"} ${browser?.version ?? ""} on ${os?.platform ?? "OS"} | ${locale?.language ?? "Locale"}]`;
3479
- }
3480
- }
3481
- function createPassport(seedOrOptionsOrProfile, extraOptions) {
3482
- if (seedOrOptionsOrProfile instanceof DevicePassportInstance) {
3483
- return seedOrOptionsOrProfile;
3484
- }
3485
- if (seedOrOptionsOrProfile && typeof seedOrOptionsOrProfile === "object" && "id" in seedOrOptionsOrProfile && "clientHints" in seedOrOptionsOrProfile && "headers" in seedOrOptionsOrProfile) {
3486
- return new DevicePassportInstance(seedOrOptionsOrProfile);
3487
- }
3488
- let options = {};
3489
- if (typeof seedOrOptionsOrProfile === "string") {
3490
- options = { ...extraOptions, seed: seedOrOptionsOrProfile };
3491
- } else if (seedOrOptionsOrProfile && typeof seedOrOptionsOrProfile === "object") {
3492
- options = { ...seedOrOptionsOrProfile };
3493
- } else if (extraOptions) {
3494
- options = { ...extraOptions };
3495
- }
3496
- if (options.store && options.seed) {
3497
- const storage = typeof options.store === "string" ? new JSONFileStorage({ filePath: options.store }) : options.store;
3498
- if (storage.hasSync && storage.hasSync(options.seed)) {
3499
- const existing = storage.getSync(options.seed);
3500
- if (existing) return new DevicePassportInstance(existing);
3501
- }
3502
- const generated2 = generatePassport(options);
3503
- if (storage.setSync) {
3504
- storage.setSync(options.seed, generated2);
3505
- } else {
3506
- storage.set(options.seed, generated2).catch(() => {
3507
- });
3508
- }
3509
- return new DevicePassportInstance(generated2);
3510
- }
3511
- const generated = generatePassport(options);
3512
- return new DevicePassportInstance(generated);
3513
- }
3514
-
3515
- class MemoryStorage {
3516
- store = /* @__PURE__ */ new Map();
3517
- clone;
3518
- constructor(options) {
3519
- this.clone = options?.clone ?? true;
3520
- }
3521
- deepClone(val) {
3522
- if (!this.clone || val === null || typeof val !== "object") {
3523
- return val;
3524
- }
3525
- if (typeof structuredClone === "function") {
3526
- try {
3527
- return structuredClone(val);
3528
- } catch {
3529
- return JSON.parse(JSON.stringify(val));
3530
- }
3531
- }
3532
- return JSON.parse(JSON.stringify(val));
3533
- }
3534
- async get(key) {
3535
- return this.getSync(key);
3536
- }
3537
- getSync(key) {
3538
- const val = this.store.get(key);
3539
- if (val === void 0) {
3540
- return null;
3541
- }
3542
- return this.deepClone(val);
3543
- }
3544
- async set(key, value) {
3545
- this.setSync(key, value);
3546
- }
3547
- setSync(key, value) {
3548
- this.store.set(key, this.deepClone(value));
3549
- }
3550
- async has(key) {
3551
- return this.hasSync(key);
3552
- }
3553
- hasSync(key) {
3554
- return this.store.has(key);
3555
- }
3556
- async delete(key) {
3557
- return this.deleteSync(key);
3558
- }
3559
- deleteSync(key) {
3560
- return this.store.delete(key);
3561
- }
3562
- async keys() {
3563
- return this.keysSync();
3564
- }
3565
- keysSync() {
3566
- return Array.from(this.store.keys());
3567
- }
3568
- async clear() {
3569
- this.clearSync();
3570
- }
3571
- clearSync() {
3572
- this.store.clear();
3573
- }
3574
- get size() {
3575
- return this.store.size;
3576
- }
3577
- }
3578
-
3579
- class PassportManager {
3580
- storage;
3581
- defaultGeo;
3582
- defaultOS;
3583
- defaultBrowser;
3584
- generator;
3585
- constructor(options) {
3586
- if (typeof options?.store === "string") {
3587
- this.storage = new JSONFileStorage(options.store);
3588
- } else if (options?.store && typeof options.store.get === "function") {
3589
- this.storage = options.store;
3590
- } else {
3591
- this.storage = new MemoryStorage();
3592
- }
3593
- this.defaultGeo = options?.defaultGeo ?? "US";
3594
- this.defaultOS = options?.defaultOS;
3595
- this.defaultBrowser = options?.defaultBrowser;
3596
- this.generator = options?.generator ?? generatePassport;
3597
- }
3598
- /**
3599
- * Retrieves an existing sticky passport by seed or deterministically generates
3600
- * and persists a new one if it does not already exist.
3601
- *
3602
- * @param seed Deterministic seed (user ID, account handle, proxy IP, worker slot)
3603
- * @param options Generator options to use if persona needs to be created
3604
- */
3605
- async getPassport(seed, options) {
3606
- const seedStr = String(seed);
3607
- const existing = await this.storage.get(seedStr);
3608
- if (existing) {
3609
- return new DevicePassportInstance(existing);
3610
- }
3611
- const mergedOptions = {
3612
- seed: seedStr,
3613
- country: options?.country ?? this.defaultGeo,
3614
- os: options?.os ?? this.defaultOS,
3615
- browser: options?.browser ?? this.defaultBrowser,
3616
- ...options
3617
- };
3618
- const profile = this.generator(mergedOptions);
3619
- await this.storage.set(seedStr, profile);
3620
- return new DevicePassportInstance(profile);
3621
- }
3622
- /**
3623
- * Synchronous passport retrieval for environments backed by MemoryStorage or JSONFileStorage.
3624
- */
3625
- getPassportSync(seed, options) {
3626
- const seedStr = String(seed);
3627
- const syncStore = this.storage;
3628
- if (typeof syncStore.getSync === "function") {
3629
- const existing = syncStore.getSync(seedStr);
3630
- if (existing) {
3631
- return new DevicePassportInstance(existing);
3632
- }
3633
- const mergedOptions = {
3634
- seed: seedStr,
3635
- country: options?.country ?? this.defaultGeo,
3636
- os: options?.os ?? this.defaultOS,
3637
- browser: options?.browser ?? this.defaultBrowser,
3638
- ...options
3639
- };
3640
- const profile = this.generator(mergedOptions);
3641
- if (typeof syncStore.setSync === "function") {
3642
- syncStore.setSync(seedStr, profile);
3643
- }
3644
- return new DevicePassportInstance(profile);
3645
- }
3646
- throw new Error(
3647
- "[PassportManager] Current storage adapter does not support synchronous operations. Use await manager.getPassport(seed) instead."
3648
- );
3649
- }
3650
- /**
3651
- * Forces re-generation and overwrite of a passport for the given seed.
3652
- */
3653
- async renewPassport(seed, options) {
3654
- const seedStr = String(seed);
3655
- const mergedOptions = {
3656
- seed: seedStr,
3657
- country: options?.country ?? this.defaultGeo,
3658
- os: options?.os ?? this.defaultOS,
3659
- browser: options?.browser ?? this.defaultBrowser,
3660
- ...options
3661
- };
3662
- const profile = this.generator(mergedOptions);
3663
- await this.storage.set(seedStr, profile);
3664
- return new DevicePassportInstance(profile);
3665
- }
3666
- /**
3667
- * Check if a passport exists in storage for the given seed.
3668
- */
3669
- async hasPassport(seed) {
3670
- return this.storage.has(String(seed));
3671
- }
3672
- /**
3673
- * Delete a passport from storage.
3674
- */
3675
- async deletePassport(seed) {
3676
- return this.storage.delete(String(seed));
3677
- }
3678
- /**
3679
- * Import an existing passport into storage.
3680
- */
3681
- async importPassport(passport) {
3682
- const raw = passport instanceof DevicePassportInstance ? passport.toJSON() : passport;
3683
- await this.storage.set(raw.seed, raw);
3684
- return new DevicePassportInstance(raw);
3685
- }
3686
- /**
3687
- * List all stored seeds.
3688
- */
3689
- async listSeeds() {
3690
- return this.storage.keys();
3691
- }
3692
- /**
3693
- * List all stored passports as DevicePassportInstance objects.
3694
- */
3695
- async listPassports() {
3696
- const keys = await this.storage.keys();
3697
- const instances = [];
3698
- for (const key of keys) {
3699
- const item = await this.storage.get(key);
3700
- if (item) {
3701
- instances.push(new DevicePassportInstance(item));
3702
- }
3703
- }
3704
- return instances;
3705
- }
3706
- /**
3707
- * Clear all stored passports.
3708
- */
3709
- async clear() {
3710
- await this.storage.clear();
3711
- }
3712
- /**
3713
- * Return number of stored personas.
3714
- */
3715
- async count() {
3716
- const keys = await this.storage.keys();
3717
- return keys.length;
3718
- }
3719
- }
3720
-
3721
- const GEO_LOCALES = COUNTRY_LOCALES;
3722
- const TIMEZONE_MATRIX = TIMEZONE_TO_COUNTRY;
3723
- const isValidCountryCode = hasCountryConfig;
3724
- function detectGeoFromUrl(url) {
3725
- return extractCountryFromProxyUrl(url);
3726
- }
3727
- function getLocaleProfile(countryCode, timezone) {
3728
- const geo = alignGeoContext({
3729
- country: countryCode || void 0,
3730
- timezone
3731
- });
3732
- return toLocaleProfile(geo);
3733
- }
3734
-
3735
- function evaluateGeoAlignment(passport) {
3736
- const geoContradictions = detectGeoChronoContradictions(passport);
3737
- let score = 100;
3738
- for (const c of geoContradictions) {
3739
- score -= c.impactPenalty;
3740
- }
3741
- const acceptLang = passport.headers["accept-language"] || "";
3742
- if (acceptLang) {
3743
- if (!/^[a-zA-Z]{2,3}(-[a-zA-Z0-9]+)?(;q=[0-1](\.\d{1,3})?)?/.test(acceptLang.trim())) {
3744
- score -= 10;
3745
- }
3746
- } else {
3747
- score -= 15;
3748
- }
3749
- return Math.max(0, Math.min(100, score));
3750
- }
3751
- function evaluateCoherence(passport) {
3752
- const contradictions = detectAllContradictions(passport);
3753
- const geoAlignmentScore = evaluateGeoAlignment(passport);
3754
- const entropyResult = analyzeHeaderEntropy(passport.headers || {});
3755
- const entropyScore = entropyResult.entropyScore;
3756
- let totalPenalty = 0;
3757
- let fatalCount = 0;
3758
- let warningCount = 0;
3759
- for (const item of contradictions) {
3760
- totalPenalty += item.impactPenalty;
3761
- if (item.severity === "fatal") {
3762
- fatalCount++;
3763
- } else {
3764
- warningCount++;
3765
- }
3766
- }
3767
- if (entropyResult.anomaly !== "optimal") {
3768
- const entropyPenalty = Math.max(0, 100 - entropyScore) * 0.25;
3769
- totalPenalty += entropyPenalty;
3770
- }
3771
- const rawCoherence = 100 - totalPenalty;
3772
- const coherenceScore = Number(Math.max(0, Math.min(100, rawCoherence)).toFixed(1));
3773
- const hContradictions = contradictions.filter((c) => c.category === "hardware_system");
3774
- const sContradictions = contradictions.filter((c) => c.category === "os_browser");
3775
- const gContradictions = contradictions.filter((c) => c.category === "geo_chrono");
3776
- const cContradictions = contradictions.filter((c) => c.category === "client_hints");
3777
- const calcSubScore = (list) => Math.max(0, 100 - list.reduce((acc, curr) => acc + curr.impactPenalty, 0));
3778
- const mathematicalModel = {
3779
- formalism: "P = \u27E8H, S, G, C\u27E9",
3780
- definition: {
3781
- H: "Hardware Sub-space \u27E8Screen, CPU, Memory, GPU\u27E9",
3782
- S: "System Sub-space \u27E8OS, Browser, UserAgent\u27E9",
3783
- G: "Geo-Chrono Sub-space \u27E8Country, Timezone, Locale, Languages, Coordinates\u27E9",
3784
- C: "Client-Hints Sub-space \u27E8Sec-CH-UA*, Low & High Entropy Hints\u27E9"
3785
- },
3786
- subspaces: {
3787
- H: {
3788
- valid: hContradictions.every((c) => c.severity !== "fatal"),
3789
- score: calcSubScore(hContradictions),
3790
- notes: hContradictions.map((c) => c.description)
3791
- },
3792
- S: {
3793
- valid: sContradictions.every((c) => c.severity !== "fatal"),
3794
- score: calcSubScore(sContradictions),
3795
- notes: sContradictions.map((c) => c.description)
3796
- },
3797
- G: {
3798
- valid: gContradictions.every((c) => c.severity !== "fatal"),
3799
- score: geoAlignmentScore,
3800
- notes: gContradictions.map((c) => c.description)
3801
- },
3802
- C: {
3803
- valid: cContradictions.every((c) => c.severity !== "fatal"),
3804
- score: calcSubScore(cContradictions),
3805
- notes: cContradictions.map((c) => c.description)
3806
- }
3807
- }
3808
- };
3809
- let grade = "F";
3810
- if (fatalCount === 0) {
3811
- if (coherenceScore >= 95 && entropyScore >= 80) grade = "A+";
3812
- else if (coherenceScore >= 88) grade = "A";
3813
- else if (coherenceScore >= 75) grade = "B";
3814
- else grade = "C";
3815
- } else {
3816
- grade = "F";
3817
- }
3818
- const passed = fatalCount === 0 && coherenceScore >= 80;
3819
- let verdict = "";
3820
- if (grade === "A+") {
3821
- verdict = "Flawless mathematical coherence. Zero contradictions across H, S, G, C spaces.";
3822
- } else if (grade === "A") {
3823
- verdict = "High consistency persona with natural browser characteristics and low bot detection risk.";
3824
- } else if (grade === "B" || grade === "C") {
3825
- verdict = "Minor cross-layer discrepancies detected; susceptible to advanced anti-bot heuristics.";
3826
- } else {
3827
- verdict = "Fatal architectural contradiction detected. Persona is trivially flagged by Cloudflare/DataDome.";
3828
- }
3829
- return {
3830
- coherenceScore,
3831
- geoAlignmentScore,
3832
- entropyScore,
3833
- contradictions,
3834
- mathematicalModel,
3835
- entropyAnalysis: entropyResult,
3836
- summary: {
3837
- passed,
3838
- fatalCount,
3839
- warningCount,
3840
- grade,
3841
- verdict
3842
- }
3843
- };
3844
- }
3845
-
3846
- function evaluatePassport(passport) {
3847
- return evaluateCoherence(passport);
3848
- }
1
+ export { A as AccountProfileManager, D as DevicePassportInstance, P as PROXY_MISSING_NOTE, a as PROXY_RESOLUTION_NOTE, h as PassportManager, b as buildEgoSessionPlan, c as buildProxyDeclaration, d as createEgoBridge, i as createPassport, e as defaultTaskSpaceName, g as getEgoNativeBridge, f as getProfileReadiness } from './shared/device-passport.kekU28UM.mjs';
2
+ export { A as ALL_PRESETS, C as CANONICAL_HEADER_ORDER, i as CHROME_VERSIONS, E as EDGE_VERSIONS, M as MACOS_PRESETS, W as WINDOWS_PRESETS, a as applyCdpPassport, b as applyToPlaywrightContext, c as applyToPuppeteerPage, j as buildUserAgent, k as createDeterministicPRNG, l as createMulberry32, m as fnv1a, f as formatCanonicalHeaders, n as formatStructuredBrandList, o as generateBrandVersions, p as generateDevicePassport, q as generatePassport, r as generateUserAgentClientHints, s as getApifyHeadersIfAvailable, g as getCdpPlan, u as getHardwarePresets, v as getPixelProtectionConfig, x as getPixelProtectionScript, d as getPlaywrightContext, e as getPuppeteerArgs, y as getStaticFallbackHeaders, h as getStealthScript, z as murmur3, B as parseStructuredBrandList, t as toCurl, D as validateHardwareContradictions, w as withPassport } from './shared/device-passport.gNo82fQ5.mjs';
3
+ export { GEO_LOCALES, TIMEZONE_MATRIX, detectGeoFromUrl, getLocaleProfile, isValidCountryCode } from './geo/index.mjs';
4
+ export { J as JSONFileStorage, M as MemoryStorage } from './shared/device-passport.CyQtcZeD.mjs';
5
+ export { evaluateCoherence, evaluateGeoAlignment, evaluatePassport } from './evaluator/index.mjs';
6
+ export { A as ALPHA3_TO_ALPHA2, C as COUNTRY_LOCALES, b as COUNTRY_NAME_TO_CODE, D as DEFAULT_ACCEPT_LANGUAGE, c as DEFAULT_COUNTRY, d as DEFAULT_LOCALE, f as DEFAULT_TIMEZONE, T as TIMEZONE_TO_COUNTRY, a as alignGeoContext, g as detectCountry, e as extractCountryFromProxyUrl, i as formatAcceptLanguage, j as getAllSupportedCountries, k as getCountryConfig, l as getCountryForTimezone, m as getDefaultTimezoneForCountry, n as getTimezoneOffsetMinutes, o as getTimezonesForCountry, h as hasCountryConfig, p as isGeoAligned, q as isTimezoneAlignedWithCountry, r as isValidTimezone, s as listAllTimezones, u as normalizeCountryCode, v as parseAcceptLanguage, w as toGeoLocation, t as toLocaleProfile } from './shared/device-passport.BPQj0qdT.mjs';
7
+ export { B as BASELINE_OPTIMAL_ENTROPY, c as BROWSER_BASELINE_FREQUENCIES, C as COUNTRY_PRIMARY_LANGUAGES, e as COUNTRY_TIMEZONE_MAP, M as MIN_STRUCTURAL_ENTROPY, O as OPTIMAL_CHAR_ENTROPY_MAX, f as OPTIMAL_CHAR_ENTROPY_MIN, g as OPTIMAL_ENTROPY_MAX, h as OPTIMAL_ENTROPY_MIN, a as analyzeHeaderEntropy, i as calculateKLDivergence, j as calculateShannonEntropy, k as calculateStructuralEntropy, d as detectAllContradictions, l as detectClientHintsContradictions, b as detectGeoChronoContradictions, m as detectHardwareContradictions, n as detectOSBrowserContradictions } from './shared/device-passport.BGfRcQNh.mjs';
8
+ import 'node:crypto';
9
+ import 'node:fs';
10
+ import 'node:path';
3849
11
 
3850
12
  const BENCHMARK_METRICS_METADATA = {
3851
13
  clientHintsSupport: {
@@ -4219,4 +381,4 @@ function formatComparativeMatrixJSON() {
4219
381
 
4220
382
  const VERSION = "1.0.0";
4221
383
 
4222
- export { ALL_PRESETS, ALPHA3_TO_ALPHA2, BASELINE_OPTIMAL_ENTROPY, BENCHMARK_METRICS_METADATA, BROWSER_BASELINE_FREQUENCIES, CANONICAL_HEADER_ORDER, CHROME_VERSIONS, COMPARATIVE_DATASET, COUNTRY_LOCALES, COUNTRY_NAME_TO_CODE, COUNTRY_PRIMARY_LANGUAGES, COUNTRY_TIMEZONE_MAP, DEFAULT_ACCEPT_LANGUAGE, DEFAULT_COUNTRY, DEFAULT_LOCALE, DEFAULT_TIMEZONE, DevicePassportInstance, EDGE_VERSIONS, GEO_LOCALES, JSONFileStorage, MACOS_PRESETS, MIN_STRUCTURAL_ENTROPY, MemoryStorage, OPTIMAL_CHAR_ENTROPY_MAX, OPTIMAL_CHAR_ENTROPY_MIN, OPTIMAL_ENTROPY_MAX, OPTIMAL_ENTROPY_MIN, PassportManager, TIMEZONE_MATRIX, TIMEZONE_TO_COUNTRY, VERSION, WINDOWS_PRESETS, alignGeoContext, analyzeHeaderEntropy, applyToPlaywrightContext, applyToPuppeteerPage, buildUserAgent, calculateKLDivergence, calculateShannonEntropy, calculateStructuralEntropy, createDeterministicPRNG, createMulberry32, createPassport, detectAllContradictions, detectClientHintsContradictions, detectCountry, detectGeoChronoContradictions, detectGeoFromUrl, detectHardwareContradictions, detectOSBrowserContradictions, evaluateCoherence, evaluateGeoAlignment, evaluatePassport, extractCountryFromProxyUrl, fnv1a, formatAcceptLanguage, formatCanonicalHeaders, formatComparativeMatrixJSON, formatComparativeMatrixLaTeX, formatComparativeMatrixMarkdown, formatStructuredBrandList, generateBrandVersions, generateDevicePassport, generatePassport, generateUserAgentClientHints, getAllSupportedCountries, getApifyHeadersIfAvailable, getCountryConfig, getCountryForTimezone, getDefaultTimezoneForCountry, getHardwarePresets, getLocaleProfile, getPlaywrightContext, getPuppeteerArgs, getStaticFallbackHeaders, getStealthScript, getTimezoneOffsetMinutes, getTimezonesForCountry, hasCountryConfig, isGeoAligned, isTimezoneAlignedWithCountry, isValidCountryCode, isValidTimezone, listAllTimezones, murmur3, normalizeCountryCode, parseAcceptLanguage, parseStructuredBrandList, runComparativeBenchmark, toCurl, toGeoLocation, toLocaleProfile, validateHardwareContradictions, withPassport };
384
+ export { BENCHMARK_METRICS_METADATA, COMPARATIVE_DATASET, VERSION, formatComparativeMatrixJSON, formatComparativeMatrixLaTeX, formatComparativeMatrixMarkdown, runComparativeBenchmark };