@skrillex1224/playwright-toolkit 2.1.258 → 2.1.260
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.cjs +73 -60
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +73 -60
- package/dist/index.js.map +2 -2
- package/package.json +5 -3
package/dist/index.cjs
CHANGED
|
@@ -2501,7 +2501,8 @@ function buildFingerprintOptions({ locale = BASE_CONFIG.locale, browserMajorVers
|
|
|
2501
2501
|
browsers: browserDescriptor,
|
|
2502
2502
|
devices: [resolvedDevice],
|
|
2503
2503
|
operatingSystems: resolvedDevice === Device.Mobile ? ["android"] : ["windows", "macos", "linux"],
|
|
2504
|
-
locales: [locale]
|
|
2504
|
+
locales: [locale],
|
|
2505
|
+
strict: true
|
|
2505
2506
|
};
|
|
2506
2507
|
if (resolvedDevice === Device.Mobile) {
|
|
2507
2508
|
options.screen = {
|
|
@@ -4555,7 +4556,7 @@ var resolveProxyLaunchOptions = (proxyConfiguration = {}) => {
|
|
|
4555
4556
|
return { byPassDomains, enableProxy, proxyUrl };
|
|
4556
4557
|
};
|
|
4557
4558
|
var parseChromeMajorVersion = (rawValue = "") => {
|
|
4558
|
-
const match = String(rawValue || "").match(/Chrome
|
|
4559
|
+
const match = String(rawValue || "").match(/(?:Chrome|Chromium)(?:\/|\s+(?:for Testing\s+)?)(\d+)/i);
|
|
4559
4560
|
return match ? Number(match[1] || 0) : 0;
|
|
4560
4561
|
};
|
|
4561
4562
|
var resolveLauncherExecutablePath = (launcher) => {
|
|
@@ -4604,6 +4605,36 @@ var buildFingerprintGenerator = ({ locale, browserMajorVersion, device }) => {
|
|
|
4604
4605
|
})
|
|
4605
4606
|
);
|
|
4606
4607
|
};
|
|
4608
|
+
var generateFingerprintForCore = ({ locale, browserMajorVersion, device }) => {
|
|
4609
|
+
const requestedBrowserMajorVersion = Number(browserMajorVersion || 0);
|
|
4610
|
+
const generator = buildFingerprintGenerator({
|
|
4611
|
+
locale,
|
|
4612
|
+
browserMajorVersion: requestedBrowserMajorVersion,
|
|
4613
|
+
device
|
|
4614
|
+
});
|
|
4615
|
+
try {
|
|
4616
|
+
return {
|
|
4617
|
+
fingerprint: generator.getFingerprint(),
|
|
4618
|
+
exactBrowserMajorVersion: requestedBrowserMajorVersion > 0
|
|
4619
|
+
};
|
|
4620
|
+
} catch (error) {
|
|
4621
|
+
if (requestedBrowserMajorVersion <= 0) {
|
|
4622
|
+
throw error;
|
|
4623
|
+
}
|
|
4624
|
+
logger8.warn(
|
|
4625
|
+
`\u5F53\u524D\u6D4F\u89C8\u5668\u5927\u7248\u672C ${requestedBrowserMajorVersion} \u65E0\u53EF\u7528 strict \u6307\u7EB9\u6837\u672C\uFF0C\u9000\u56DE\u4E0D\u7ED1\u5B9A\u5927\u7248\u672C\u751F\u6210: ${error?.message || error}`
|
|
4626
|
+
);
|
|
4627
|
+
}
|
|
4628
|
+
const fallbackGenerator = buildFingerprintGenerator({
|
|
4629
|
+
locale,
|
|
4630
|
+
browserMajorVersion: 0,
|
|
4631
|
+
device
|
|
4632
|
+
});
|
|
4633
|
+
return {
|
|
4634
|
+
fingerprint: fallbackGenerator.getFingerprint(),
|
|
4635
|
+
exactBrowserMajorVersion: false
|
|
4636
|
+
};
|
|
4637
|
+
};
|
|
4607
4638
|
var buildReplayableBrowserProfile = (runtimeState, launcher) => {
|
|
4608
4639
|
const device = resolveRuntimeDevice(runtimeState);
|
|
4609
4640
|
if (!runtimeState || !RuntimeEnv.hasLoginState(runtimeState)) {
|
|
@@ -4619,12 +4650,12 @@ var buildReplayableBrowserProfile = (runtimeState, launcher) => {
|
|
|
4619
4650
|
const needsDeviceRebuild = storedDevice ? storedDevice !== device : device === Device.Mobile;
|
|
4620
4651
|
const needsRebuild = !browserProfileCore?.fingerprint || Object.keys(browserProfileCore.fingerprint || {}).length === 0 || needsDeviceRebuild || currentBrowserMajorVersion > 0 && storedBrowserMajorVersion > 0 && storedBrowserMajorVersion !== currentBrowserMajorVersion;
|
|
4621
4652
|
if (needsRebuild) {
|
|
4622
|
-
const
|
|
4653
|
+
const generated = generateFingerprintForCore({
|
|
4623
4654
|
locale,
|
|
4624
4655
|
browserMajorVersion: currentBrowserMajorVersion,
|
|
4625
4656
|
device
|
|
4626
4657
|
});
|
|
4627
|
-
const fingerprint =
|
|
4658
|
+
const fingerprint = generated.fingerprint;
|
|
4628
4659
|
const fingerprintBrowserMajorVersion = parseChromeMajorVersion(fingerprint?.fingerprint?.navigator?.userAgent || "");
|
|
4629
4660
|
browserProfileCore = {
|
|
4630
4661
|
fingerprint,
|
|
@@ -4636,7 +4667,7 @@ var buildReplayableBrowserProfile = (runtimeState, launcher) => {
|
|
|
4636
4667
|
};
|
|
4637
4668
|
nextState = RuntimeEnv.setBrowserProfileCore(nextState, browserProfileCore);
|
|
4638
4669
|
logger8.info(
|
|
4639
|
-
`\u5DF2\u751F\u6210\u6D4F\u89C8\u5668\u6307\u7EB9\u771F\u6E90 | env=${String(nextState.envId || "-")} | device=${device} | version=${browserProfileCore.browser_major_version || "-"} | timezone=${timezoneId}`
|
|
4670
|
+
`\u5DF2\u751F\u6210\u6D4F\u89C8\u5668\u6307\u7EB9\u771F\u6E90 | env=${String(nextState.envId || "-")} | device=${device} | version=${browserProfileCore.browser_major_version || "-"} | fingerprintVersion=${fingerprintBrowserMajorVersion || "-"} | exactVersion=${generated.exactBrowserMajorVersion ? "true" : "false"} | timezone=${timezoneId}`
|
|
4640
4671
|
);
|
|
4641
4672
|
return { runtimeState: nextState, browserProfileCore };
|
|
4642
4673
|
}
|
|
@@ -4658,33 +4689,36 @@ var buildReplayableBrowserProfile = (runtimeState, launcher) => {
|
|
|
4658
4689
|
browserProfileCore: normalizedBrowserProfileCore
|
|
4659
4690
|
};
|
|
4660
4691
|
};
|
|
4661
|
-
var
|
|
4692
|
+
var applyFingerprintPageOptions = (pageOptions = {}, { fingerprintWithHeaders = null, locale = "", timezoneId = "" } = {}) => {
|
|
4662
4693
|
if (!pageOptions || typeof pageOptions !== "object") return;
|
|
4663
|
-
const
|
|
4694
|
+
const fingerprint = fingerprintWithHeaders?.fingerprint || fingerprintWithHeaders;
|
|
4695
|
+
if (!fingerprint || typeof fingerprint !== "object") return;
|
|
4664
4696
|
const screen = fingerprint?.screen || {};
|
|
4697
|
+
const navigatorFingerprint = fingerprint?.navigator || {};
|
|
4698
|
+
const headers = fingerprintWithHeaders?.headers || {};
|
|
4699
|
+
const userAgent = String(navigatorFingerprint.userAgent || headers["user-agent"] || "").trim();
|
|
4700
|
+
const width = Number(screen.width || 0);
|
|
4701
|
+
const height = Number(screen.height || 0);
|
|
4665
4702
|
const dpr = Number(screen.devicePixelRatio || 0);
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
pageOptions.
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
};
|
|
4675
|
-
}
|
|
4676
|
-
if (!pageOptions.screen) {
|
|
4677
|
-
pageOptions.screen = {
|
|
4678
|
-
width: Number(screen.width || pageOptions.viewport.width || 390),
|
|
4679
|
-
height: Number(screen.height || pageOptions.viewport.height || 844)
|
|
4680
|
-
};
|
|
4681
|
-
}
|
|
4682
|
-
return;
|
|
4703
|
+
const maxTouchPoints = Number(navigatorFingerprint.maxTouchPoints || 0);
|
|
4704
|
+
const isMobile = navigatorFingerprint.userAgentData?.mobile === true || headers["sec-ch-ua-mobile"] === "?1" || /Mobile|Android/i.test(userAgent);
|
|
4705
|
+
if (userAgent) {
|
|
4706
|
+
pageOptions.userAgent = userAgent;
|
|
4707
|
+
}
|
|
4708
|
+
if (width > 0 && height > 0) {
|
|
4709
|
+
pageOptions.viewport = { width, height };
|
|
4710
|
+
pageOptions.screen = { width, height };
|
|
4683
4711
|
}
|
|
4684
|
-
pageOptions.isMobile =
|
|
4685
|
-
pageOptions.hasTouch =
|
|
4686
|
-
if (
|
|
4687
|
-
pageOptions.deviceScaleFactor = dpr
|
|
4712
|
+
pageOptions.isMobile = isMobile;
|
|
4713
|
+
pageOptions.hasTouch = maxTouchPoints > 0;
|
|
4714
|
+
if (dpr > 0) {
|
|
4715
|
+
pageOptions.deviceScaleFactor = dpr;
|
|
4716
|
+
}
|
|
4717
|
+
if (locale) {
|
|
4718
|
+
pageOptions.locale = locale;
|
|
4719
|
+
}
|
|
4720
|
+
if (timezoneId) {
|
|
4721
|
+
pageOptions.timezoneId = timezoneId;
|
|
4688
4722
|
}
|
|
4689
4723
|
};
|
|
4690
4724
|
var buildReplayBrowserPoolOptions = (browserProfileCore) => {
|
|
@@ -4698,30 +4732,10 @@ var buildReplayBrowserPoolOptions = (browserProfileCore) => {
|
|
|
4698
4732
|
prePageCreateHooks: [
|
|
4699
4733
|
(_pageId, _browserController, pageOptions = {}) => {
|
|
4700
4734
|
if (!pageOptions || typeof pageOptions !== "object") return;
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
}
|
|
4706
|
-
if (Number(screen.width || 0) > 0 && Number(screen.height || 0) > 0) {
|
|
4707
|
-
pageOptions.viewport = {
|
|
4708
|
-
width: Number(screen.width),
|
|
4709
|
-
height: Number(screen.height)
|
|
4710
|
-
};
|
|
4711
|
-
pageOptions.screen = {
|
|
4712
|
-
width: Number(screen.width),
|
|
4713
|
-
height: Number(screen.height)
|
|
4714
|
-
};
|
|
4715
|
-
}
|
|
4716
|
-
if (browserProfileCore.locale) {
|
|
4717
|
-
pageOptions.locale = browserProfileCore.locale;
|
|
4718
|
-
}
|
|
4719
|
-
if (browserProfileCore.timezone_id) {
|
|
4720
|
-
pageOptions.timezoneId = browserProfileCore.timezone_id;
|
|
4721
|
-
}
|
|
4722
|
-
applyDevicePageOptions(pageOptions, {
|
|
4723
|
-
device: browserProfileCore.device,
|
|
4724
|
-
fingerprint
|
|
4735
|
+
applyFingerprintPageOptions(pageOptions, {
|
|
4736
|
+
fingerprintWithHeaders,
|
|
4737
|
+
locale: browserProfileCore.locale,
|
|
4738
|
+
timezoneId: browserProfileCore.timezone_id
|
|
4725
4739
|
});
|
|
4726
4740
|
}
|
|
4727
4741
|
],
|
|
@@ -4839,15 +4853,14 @@ var Launch = {
|
|
|
4839
4853
|
})
|
|
4840
4854
|
},
|
|
4841
4855
|
prePageCreateHooks: [
|
|
4842
|
-
(_pageId,
|
|
4843
|
-
|
|
4844
|
-
if (launchLocale) {
|
|
4845
|
-
pageOptions.locale = launchLocale;
|
|
4846
|
-
}
|
|
4856
|
+
(_pageId, browserController, pageOptions = {}) => {
|
|
4857
|
+
const fingerprintWithHeaders = browserController?.launchContext?.fingerprint;
|
|
4847
4858
|
const timezoneId = AntiCheat.getBaseConfig().timezoneId;
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4859
|
+
applyFingerprintPageOptions(pageOptions, {
|
|
4860
|
+
fingerprintWithHeaders,
|
|
4861
|
+
locale: launchLocale,
|
|
4862
|
+
timezoneId
|
|
4863
|
+
});
|
|
4851
4864
|
}
|
|
4852
4865
|
]
|
|
4853
4866
|
},
|