@skrillex1224/playwright-toolkit 3.0.6 → 3.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5290,6 +5290,49 @@ var normalizeStringArray = (value) => {
5290
5290
  }
5291
5291
  return value.map((item) => String(item || "").trim()).filter(Boolean);
5292
5292
  };
5293
+ var hashStableSeed = (value = "") => {
5294
+ const raw = String(value || "").trim();
5295
+ if (!raw) return "";
5296
+ let hash = 2166136261;
5297
+ for (let index = 0; index < raw.length; index += 1) {
5298
+ hash ^= raw.charCodeAt(index);
5299
+ hash = Math.imul(hash, 16777619);
5300
+ }
5301
+ const normalized = hash >>> 0 || 1;
5302
+ return String(normalized);
5303
+ };
5304
+ var extractProxySeedSource = (proxyConfiguration = {}) => {
5305
+ const config = normalizeObject2(proxyConfiguration);
5306
+ return String(config.proxy_url || "").trim();
5307
+ };
5308
+ var resolveCloakRuntimeHints = (runtimeState = {}, proxyConfiguration = {}, cloakOptions = {}) => {
5309
+ const normalizedCloakOptions = normalizeObject2(cloakOptions);
5310
+ const browserProfileCore = RuntimeEnv.getBrowserProfileCore(runtimeState);
5311
+ const baseConfig = DefaultAntiCheat.getBaseConfig();
5312
+ const locale = String(
5313
+ normalizedCloakOptions.locale || browserProfileCore?.locale || baseConfig.locale || ""
5314
+ ).trim();
5315
+ const timezone = String(
5316
+ normalizedCloakOptions.timezone || normalizedCloakOptions.timezoneId || browserProfileCore?.timezone_id || baseConfig.timezoneId || ""
5317
+ ).trim();
5318
+ const explicitArgs = normalizeStringArray(normalizedCloakOptions.args);
5319
+ const hasExplicitFingerprint = explicitArgs.some((arg) => arg.startsWith("--fingerprint="));
5320
+ const fingerprintSeedSource = String(
5321
+ runtimeState?.envId || browserProfileCore?.schema_version && JSON.stringify({
5322
+ envId: runtimeState?.envId || "",
5323
+ timezone: browserProfileCore?.timezone_id || "",
5324
+ locale: browserProfileCore?.locale || "",
5325
+ browserMajorVersion: browserProfileCore?.browser_major_version || "",
5326
+ device: browserProfileCore?.device || ""
5327
+ }) || extractProxySeedSource(proxyConfiguration)
5328
+ ).trim();
5329
+ return {
5330
+ locale,
5331
+ timezone,
5332
+ fingerprintSeed: hasExplicitFingerprint ? "" : hashStableSeed(fingerprintSeedSource),
5333
+ hasExplicitFingerprint
5334
+ };
5335
+ };
5293
5336
  var resolveCloakProxy = (proxyConfiguration = {}) => {
5294
5337
  const config = normalizeObject2(proxyConfiguration);
5295
5338
  const proxyUrl = String(config.proxy_url || "").trim();
@@ -5425,6 +5468,7 @@ var CloakLaunch = {
5425
5468
  runInHeadfulMode = false,
5426
5469
  isRunningOnApify = false,
5427
5470
  launcher = null,
5471
+ runtimeState = null,
5428
5472
  cloakOptions = {},
5429
5473
  humanizeOptions = DEFAULT_CLOAK_HUMANIZE_OPTIONS,
5430
5474
  crawlerBaseOptions = {},
@@ -5439,6 +5483,7 @@ var CloakLaunch = {
5439
5483
  const patchedBrowsers = /* @__PURE__ */ new WeakSet();
5440
5484
  const defaultArgs = isRunningOnApify ? ["--no-sandbox", "--disable-setuid-sandbox"] : [];
5441
5485
  const extraArgs = normalizeStringArray(normalizedCloakOptions.args);
5486
+ const runtimeHints = resolveCloakRuntimeHints(runtimeState, proxyConfiguration, normalizedCloakOptions);
5442
5487
  const hasExplicitProxy = hasOwn(normalizedCloakOptions, "proxy");
5443
5488
  const proxyLaunchState = hasExplicitProxy ? resolveLaunchTraffic({ proxyConfiguration, debugMode, useMeter: false }) : resolveLaunchTraffic({ proxyConfiguration, debugMode });
5444
5489
  const proxy = hasExplicitProxy ? normalizedCloakOptions.proxy : proxyLaunchState.launchProxy;
@@ -5448,7 +5493,13 @@ var CloakLaunch = {
5448
5493
  ...normalizedCloakOptions,
5449
5494
  headless,
5450
5495
  proxy,
5451
- args: [...defaultArgs, ...extraArgs]
5496
+ ...runtimeHints.locale ? { locale: runtimeHints.locale } : {},
5497
+ ...runtimeHints.timezone ? { timezone: runtimeHints.timezone } : {},
5498
+ args: [
5499
+ ...defaultArgs,
5500
+ ...extraArgs,
5501
+ ...runtimeHints.fingerprintSeed ? [`--fingerprint=${runtimeHints.fingerprintSeed}`] : []
5502
+ ]
5452
5503
  };
5453
5504
  const launchOptions = await buildCloakLaunchOptions(mergedCloakOptions);
5454
5505
  const fingerprintArg = extractFingerprintArg(launchOptions);