jumpy-lion 0.1.6-beta.7 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -607
- package/browser/fonts/macos-bundle/40-macos-aliases.conf +515 -0
- package/browser/fonts/macos-bundle/README.md +24 -0
- package/browser/fonts/macos-bundle/install.sh +83 -0
- package/dist/browser-controller.d.ts +47 -4
- package/dist/browser-controller.d.ts.map +1 -1
- package/dist/browser-controller.js +219 -278
- package/dist/browser-controller.js.map +1 -1
- package/dist/browser-plugin.d.ts +82 -110
- package/dist/browser-plugin.d.ts.map +1 -1
- package/dist/browser-plugin.js +376 -379
- package/dist/browser-plugin.js.map +1 -1
- package/dist/browser-process/align-fingerprint-config.d.ts +36 -0
- package/dist/browser-process/align-fingerprint-config.d.ts.map +1 -0
- package/dist/browser-process/align-fingerprint-config.js +74 -0
- package/dist/browser-process/align-fingerprint-config.js.map +1 -0
- package/dist/browser-process/anti-detect-browser.d.ts +2 -2
- package/dist/browser-process/anti-detect-browser.js +7 -7
- package/dist/browser-process/anti-detect-config.d.ts +131 -2
- package/dist/browser-process/anti-detect-config.d.ts.map +1 -1
- package/dist/browser-process/anti-detect-config.js +337 -127
- package/dist/browser-process/anti-detect-config.js.map +1 -1
- package/dist/browser-process/browser.d.ts +25 -92
- package/dist/browser-process/browser.d.ts.map +1 -1
- package/dist/browser-process/browser.js +429 -73
- package/dist/browser-process/browser.js.map +1 -1
- package/dist/browser-process/fingerprint-config.d.ts +146 -0
- package/dist/browser-process/fingerprint-config.d.ts.map +1 -0
- package/dist/browser-process/fingerprint-config.js +308 -0
- package/dist/browser-process/fingerprint-config.js.map +1 -0
- package/dist/browser-process/get-chrome-executable.d.ts +6 -0
- package/dist/browser-process/get-chrome-executable.d.ts.map +1 -1
- package/dist/browser-process/get-chrome-executable.js +79 -4
- package/dist/browser-process/get-chrome-executable.js.map +1 -1
- package/dist/browser-process/gpu-family-profiles.d.ts +58 -0
- package/dist/browser-process/gpu-family-profiles.d.ts.map +1 -0
- package/dist/browser-process/gpu-family-profiles.js +480 -0
- package/dist/browser-process/gpu-family-profiles.js.map +1 -0
- package/dist/browser-process/launch-options.d.ts +301 -0
- package/dist/browser-process/launch-options.d.ts.map +1 -0
- package/dist/browser-process/launch-options.js +2 -0
- package/dist/browser-process/launch-options.js.map +1 -0
- package/dist/browser-process/port-allocator.d.ts +64 -0
- package/dist/browser-process/port-allocator.d.ts.map +1 -0
- package/dist/browser-process/port-allocator.js +198 -0
- package/dist/browser-process/port-allocator.js.map +1 -0
- package/dist/browser-process/process.d.ts +85 -0
- package/dist/browser-process/process.d.ts.map +1 -1
- package/dist/browser-process/process.js +235 -19
- package/dist/browser-process/process.js.map +1 -1
- package/dist/browser-process/signal-cleanup.d.ts +40 -0
- package/dist/browser-process/signal-cleanup.d.ts.map +1 -0
- package/dist/browser-process/signal-cleanup.js +105 -0
- package/dist/browser-process/signal-cleanup.js.map +1 -0
- package/dist/browser-process/widevine-cdm.d.ts +144 -0
- package/dist/browser-process/widevine-cdm.d.ts.map +1 -0
- package/dist/browser-process/widevine-cdm.js +298 -0
- package/dist/browser-process/widevine-cdm.js.map +1 -0
- package/dist/browser-profiles/chrome/populate-profile.d.ts.map +1 -1
- package/dist/browser-profiles/chrome/populate-profile.js +21 -22
- package/dist/browser-profiles/chrome/populate-profile.js.map +1 -1
- package/dist/connection/cdp-reconnection.d.ts +50 -0
- package/dist/connection/cdp-reconnection.d.ts.map +1 -0
- package/dist/connection/cdp-reconnection.js +75 -0
- package/dist/connection/cdp-reconnection.js.map +1 -0
- package/dist/connection/page-session.d.ts +114 -0
- package/dist/connection/page-session.d.ts.map +1 -0
- package/dist/connection/page-session.js +237 -0
- package/dist/connection/page-session.js.map +1 -0
- package/dist/connection/session-client.d.ts +34 -0
- package/dist/connection/session-client.d.ts.map +1 -0
- package/dist/connection/session-client.js +129 -0
- package/dist/connection/session-client.js.map +1 -0
- package/dist/crawler.d.ts +9 -88
- package/dist/crawler.d.ts.map +1 -1
- package/dist/crawler.js +157 -8
- package/dist/crawler.js.map +1 -1
- package/dist/fingerprinting/fingerprint-injector.d.ts +24 -114
- package/dist/fingerprinting/fingerprint-injector.d.ts.map +1 -1
- package/dist/fingerprinting/fingerprint-injector.js +305 -611
- package/dist/fingerprinting/fingerprint-injector.js.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/datadome-bypass.d.ts +1 -1
- package/dist/fingerprinting/fingerprint-overrides/datadome-bypass.d.ts.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/datadome-bypass.js +16 -14
- package/dist/fingerprinting/fingerprint-overrides/datadome-bypass.js.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/index.d.ts +6 -2
- package/dist/fingerprinting/fingerprint-overrides/index.d.ts.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/index.js +6 -2
- package/dist/fingerprinting/fingerprint-overrides/index.js.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/keyboard-humanization.d.ts +1 -1
- package/dist/fingerprinting/fingerprint-overrides/keyboard-humanization.js +4 -4
- package/dist/fingerprinting/fingerprint-overrides/keyboard-humanization.js.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/locale-spoofing.js +4 -4
- package/dist/fingerprinting/fingerprint-overrides/navigator-override.d.ts +18 -0
- package/dist/fingerprinting/fingerprint-overrides/navigator-override.d.ts.map +1 -0
- package/dist/fingerprinting/fingerprint-overrides/navigator-override.js +136 -0
- package/dist/fingerprinting/fingerprint-overrides/navigator-override.js.map +1 -0
- package/dist/fingerprinting/fingerprint-overrides/override.d.ts +151 -0
- package/dist/fingerprinting/fingerprint-overrides/override.d.ts.map +1 -0
- package/dist/fingerprinting/fingerprint-overrides/override.js +14 -0
- package/dist/fingerprinting/fingerprint-overrides/override.js.map +1 -0
- package/dist/fingerprinting/fingerprint-overrides/platform-consistency.d.ts.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/platform-consistency.js +46 -15
- package/dist/fingerprinting/fingerprint-overrides/platform-consistency.js.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/registry.d.ts +43 -0
- package/dist/fingerprinting/fingerprint-overrides/registry.d.ts.map +1 -0
- package/dist/fingerprinting/fingerprint-overrides/registry.js +342 -0
- package/dist/fingerprinting/fingerprint-overrides/registry.js.map +1 -0
- package/dist/fingerprinting/fingerprint-overrides/screen-override.d.ts +16 -0
- package/dist/fingerprinting/fingerprint-overrides/screen-override.d.ts.map +1 -0
- package/dist/fingerprinting/fingerprint-overrides/screen-override.js +175 -0
- package/dist/fingerprinting/fingerprint-overrides/screen-override.js.map +1 -0
- package/dist/fingerprinting/fingerprint-overrides/scroll-humanization.d.ts +1 -1
- package/dist/fingerprinting/fingerprint-overrides/scroll-humanization.js +4 -4
- package/dist/fingerprinting/fingerprint-overrides/scroll-humanization.js.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/stealth-script.d.ts.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/stealth-script.js +75 -9
- package/dist/fingerprinting/fingerprint-overrides/stealth-script.js.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/ua-ch.d.ts +1 -1
- package/dist/fingerprinting/fingerprint-overrides/ua-ch.d.ts.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/ua-ch.js +34 -20
- package/dist/fingerprinting/fingerprint-overrides/ua-ch.js.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/webgl-spoofing.d.ts.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/webgl-spoofing.js +25 -6
- package/dist/fingerprinting/fingerprint-overrides/webgl-spoofing.js.map +1 -1
- package/dist/fingerprinting/fingerprint-overrides/webrtc-spoofing.js +1 -1
- package/dist/fingerprinting/hardware-realism.d.ts +83 -0
- package/dist/fingerprinting/hardware-realism.d.ts.map +1 -0
- package/dist/fingerprinting/hardware-realism.js +156 -0
- package/dist/fingerprinting/hardware-realism.js.map +1 -0
- package/dist/fingerprinting/injection-planner.d.ts +133 -0
- package/dist/fingerprinting/injection-planner.d.ts.map +1 -0
- package/dist/fingerprinting/injection-planner.js +497 -0
- package/dist/fingerprinting/injection-planner.js.map +1 -0
- package/dist/fingerprinting/locale-resolver.d.ts +8 -1
- package/dist/fingerprinting/locale-resolver.d.ts.map +1 -1
- package/dist/fingerprinting/locale-resolver.js +26 -3
- package/dist/fingerprinting/locale-resolver.js.map +1 -1
- package/dist/fingerprinting/non-apify-fingerprint-generator.d.ts +4 -4
- package/dist/fingerprinting/non-apify-fingerprint-generator.d.ts.map +1 -1
- package/dist/fingerprinting/non-apify-fingerprint-generator.js +24 -58
- package/dist/fingerprinting/non-apify-fingerprint-generator.js.map +1 -1
- package/dist/fingerprinting/non-apify-profiles.json +10515 -8494
- package/dist/fingerprinting/os-consistency.d.ts +28 -0
- package/dist/fingerprinting/os-consistency.d.ts.map +1 -0
- package/dist/fingerprinting/os-consistency.js +45 -0
- package/dist/fingerprinting/os-consistency.js.map +1 -0
- package/dist/fingerprinting/profile-quality.d.ts +25 -0
- package/dist/fingerprinting/profile-quality.d.ts.map +1 -0
- package/dist/fingerprinting/profile-quality.js +310 -0
- package/dist/fingerprinting/profile-quality.js.map +1 -0
- package/dist/fingerprinting/profile-selector.d.ts +102 -0
- package/dist/fingerprinting/profile-selector.d.ts.map +1 -0
- package/dist/fingerprinting/profile-selector.js +168 -0
- package/dist/fingerprinting/profile-selector.js.map +1 -0
- package/dist/fingerprinting/ua-alignment.d.ts +83 -0
- package/dist/fingerprinting/ua-alignment.d.ts.map +1 -0
- package/dist/fingerprinting/ua-alignment.js +197 -0
- package/dist/fingerprinting/ua-alignment.js.map +1 -0
- package/dist/fingerprinting/ua-ch-brands.d.ts +88 -0
- package/dist/fingerprinting/ua-ch-brands.d.ts.map +1 -0
- package/dist/fingerprinting/ua-ch-brands.js +174 -0
- package/dist/fingerprinting/ua-ch-brands.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/input/dropdown-selector.d.ts +90 -0
- package/dist/input/dropdown-selector.d.ts.map +1 -0
- package/dist/input/dropdown-selector.js +394 -0
- package/dist/input/dropdown-selector.js.map +1 -0
- package/dist/input/element-target.d.ts +152 -0
- package/dist/input/element-target.d.ts.map +1 -0
- package/dist/input/element-target.js +461 -0
- package/dist/input/element-target.js.map +1 -0
- package/dist/input/input-emulator.d.ts +85 -0
- package/dist/input/input-emulator.d.ts.map +1 -0
- package/dist/input/input-emulator.js +325 -0
- package/dist/input/input-emulator.js.map +1 -0
- package/dist/input/input-transport.d.ts +60 -0
- package/dist/input/input-transport.d.ts.map +1 -0
- package/dist/input/input-transport.js +28 -0
- package/dist/input/input-transport.js.map +1 -0
- package/dist/input/recording-transport.d.ts +32 -0
- package/dist/input/recording-transport.d.ts.map +1 -0
- package/dist/input/recording-transport.js +43 -0
- package/dist/input/recording-transport.js.map +1 -0
- package/dist/keyboard-layout.d.ts +2 -2
- package/dist/keyboard-layout.js +2 -2
- package/dist/navigation/page-navigation.d.ts +67 -0
- package/dist/navigation/page-navigation.d.ts.map +1 -0
- package/dist/navigation/page-navigation.js +122 -0
- package/dist/navigation/page-navigation.js.map +1 -0
- package/dist/network/network-watch.d.ts +110 -0
- package/dist/network/network-watch.d.ts.map +1 -0
- package/dist/network/network-watch.js +223 -0
- package/dist/network/network-watch.js.map +1 -0
- package/dist/page.d.ts +118 -104
- package/dist/page.d.ts.map +1 -1
- package/dist/page.js +311 -1130
- package/dist/page.js.map +1 -1
- package/dist/session/inject-hook.d.ts +24 -0
- package/dist/session/inject-hook.d.ts.map +1 -0
- package/dist/session/inject-hook.js +80 -0
- package/dist/session/inject-hook.js.map +1 -0
- package/dist/session/save.d.ts +21 -0
- package/dist/session/save.d.ts.map +1 -0
- package/dist/session/save.js +163 -0
- package/dist/session/save.js.map +1 -0
- package/dist/session/tar-data-dir.d.ts +18 -0
- package/dist/session/tar-data-dir.d.ts.map +1 -0
- package/dist/session/tar-data-dir.js +105 -0
- package/dist/session/tar-data-dir.js.map +1 -0
- package/dist/session/types.d.ts +80 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +29 -0
- package/dist/session/types.js.map +1 -0
- package/dist/session-profile.d.ts +102 -0
- package/dist/session-profile.d.ts.map +1 -0
- package/dist/session-profile.js +163 -0
- package/dist/session-profile.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +17 -6
- package/scripts/postinstall.cjs +58 -0
- package/dist/fingerprinting/custom-fingerprint-injector.d.ts +0 -87
- package/dist/fingerprinting/custom-fingerprint-injector.d.ts.map +0 -1
- package/dist/fingerprinting/custom-fingerprint-injector.js +0 -342
- package/dist/fingerprinting/custom-fingerprint-injector.js.map +0 -1
- package/dist/launcher-wrap.d.ts +0 -10
- package/dist/launcher-wrap.d.ts.map +0 -1
- package/dist/launcher-wrap.js +0 -11
- package/dist/launcher-wrap.js.map +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { BrowserFingerprintWithHeaders } from 'fingerprint-generator';
|
|
2
|
+
import type { FingerprintConfigJson } from '../browser-process/anti-detect-config.js';
|
|
3
|
+
import type { ResolvedLocale } from '../fingerprinting/locale-resolver.js';
|
|
4
|
+
import type { Cookie } from '../page.js';
|
|
5
|
+
export declare const SCHEMA_VERSION: 1;
|
|
6
|
+
/**
|
|
7
|
+
* Snapshot of launch-time inputs that saveSession() needs to read off a CdpPage
|
|
8
|
+
* to assemble a bundle. Populated by CDPBrowserController before handing the
|
|
9
|
+
* page to user code, so saveSession is a pure call against the page surface.
|
|
10
|
+
*/
|
|
11
|
+
export interface LaunchSnapshot {
|
|
12
|
+
fingerprintConfig?: FingerprintConfigJson;
|
|
13
|
+
fingerprintOptions?: Record<string, unknown>;
|
|
14
|
+
resolvedLocale?: ResolvedLocale;
|
|
15
|
+
fingerprint?: BrowserFingerprintWithHeaders;
|
|
16
|
+
userDataDir?: string;
|
|
17
|
+
proxyUrl?: string;
|
|
18
|
+
/** Set when the page was launched from a previously-saved bundle. */
|
|
19
|
+
sessionBundle?: SessionBundle;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Cookie shape as accepted by CDP `Network.setCookie`. Aliased to the Cookie
|
|
23
|
+
* already used across CdpPage so save/restore round-trips byte-for-byte.
|
|
24
|
+
*/
|
|
25
|
+
export type SerializedCookie = Cookie;
|
|
26
|
+
/** Origin → key-value map for localStorage / sessionStorage. */
|
|
27
|
+
export type StorageMap = Record<string, Record<string, string>>;
|
|
28
|
+
export interface SessionBundleUserDataDir {
|
|
29
|
+
encoding: 'base64+gzip+tar';
|
|
30
|
+
bytes: string;
|
|
31
|
+
sizeBytes: number;
|
|
32
|
+
capturedFiles: number;
|
|
33
|
+
}
|
|
34
|
+
export interface SessionBundleBrowserProfile {
|
|
35
|
+
userAgent: string;
|
|
36
|
+
platform: string;
|
|
37
|
+
language: string;
|
|
38
|
+
screenWidth: number;
|
|
39
|
+
screenHeight: number;
|
|
40
|
+
devicePixelRatio: number;
|
|
41
|
+
webglRenderer: string;
|
|
42
|
+
webglVendor: string;
|
|
43
|
+
}
|
|
44
|
+
export interface SessionBundleFingerprintInput {
|
|
45
|
+
locale?: string;
|
|
46
|
+
languages?: string;
|
|
47
|
+
timezone?: string;
|
|
48
|
+
platform?: string;
|
|
49
|
+
seedKey?: string;
|
|
50
|
+
/** Pinned on restore so the captured fingerprintConfig is not regenerated. */
|
|
51
|
+
useNonApifyFingerprints: false;
|
|
52
|
+
/** Any other fingerprintOptions keys carried through verbatim. */
|
|
53
|
+
[key: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
export interface SessionBundleProxyMeta {
|
|
56
|
+
proxyUrl?: string;
|
|
57
|
+
sessionId?: string;
|
|
58
|
+
countryCode?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface SessionBundle {
|
|
61
|
+
schemaVersion: typeof SCHEMA_VERSION;
|
|
62
|
+
createdAt: string;
|
|
63
|
+
createdBy?: {
|
|
64
|
+
package: 'cdp-crawler';
|
|
65
|
+
version: string;
|
|
66
|
+
};
|
|
67
|
+
cookies: SerializedCookie[];
|
|
68
|
+
localStorage: StorageMap;
|
|
69
|
+
sessionStorage: StorageMap;
|
|
70
|
+
userDataDir: SessionBundleUserDataDir | null;
|
|
71
|
+
fingerprintConfig: FingerprintConfigJson;
|
|
72
|
+
fingerprint: BrowserFingerprintWithHeaders;
|
|
73
|
+
fingerprintInput: SessionBundleFingerprintInput;
|
|
74
|
+
resolvedLocale: ResolvedLocale;
|
|
75
|
+
browserProfile: SessionBundleBrowserProfile;
|
|
76
|
+
proxyMeta?: SessionBundleProxyMeta;
|
|
77
|
+
}
|
|
78
|
+
/** Runtime guard so a hand-edited / partial bundle fails fast with a clear message. */
|
|
79
|
+
export declare function assertValidBundle(value: unknown): asserts value is SessionBundle;
|
|
80
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/session/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC;AAE3E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC,eAAO,MAAM,cAAc,EAAG,CAAU,CAAC;AAEzC;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC3B,iBAAiB,CAAC,EAAE,qBAAqB,CAAC;IAC1C,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7C,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,WAAW,CAAC,EAAE,6BAA6B,CAAC;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IA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S,CAAC,EAAE;QAAE,OAAO,EAAE,aAAa,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAExD,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,YAAY,EAAE,UAAU,CAAC;IACzB,cAAc,EAAE,UAAU,CAAC;IAE3B,WAAW,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAE7C,iBAAiB,EAAE,qBAAqB,CAAC;IACzC,WAAW,EAAE,6BAA6B,CAAC;IAC3C,gBAAgB,EAAE,6BAA6B,CAAC;IAChD,cAAc,EAAE,cAAc,CAAC;IAE/B,cAAc,EAAE,2BAA2B,CAAC;IAE5C,SAAS,CAAC,EAAE,sBAAsB,CAAC;CACtC;AAED,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,aAAa,CA2BhF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const SCHEMA_VERSION = 1;
|
|
2
|
+
/** Runtime guard so a hand-edited / partial bundle fails fast with a clear message. */
|
|
3
|
+
export function assertValidBundle(value) {
|
|
4
|
+
if (!value || typeof value !== 'object') {
|
|
5
|
+
throw new Error('Invalid session bundle: expected an object');
|
|
6
|
+
}
|
|
7
|
+
const b = value;
|
|
8
|
+
if (b.schemaVersion !== SCHEMA_VERSION) {
|
|
9
|
+
throw new Error(`Unsupported session bundle schemaVersion: ${String(b.schemaVersion)} (expected ${SCHEMA_VERSION})`);
|
|
10
|
+
}
|
|
11
|
+
for (const key of ['cookies', 'localStorage', 'sessionStorage', 'fingerprintConfig', 'fingerprint', 'fingerprintInput', 'resolvedLocale', 'browserProfile']) {
|
|
12
|
+
if (b[key] === undefined || b[key] === null) {
|
|
13
|
+
throw new Error(`Invalid session bundle: missing required key "${key}"`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
if (!Array.isArray(b.cookies)) {
|
|
17
|
+
throw new Error('Invalid session bundle: "cookies" must be an array');
|
|
18
|
+
}
|
|
19
|
+
if (b.userDataDir !== null && typeof b.userDataDir !== 'object') {
|
|
20
|
+
throw new Error('Invalid session bundle: "userDataDir" must be an object or null');
|
|
21
|
+
}
|
|
22
|
+
if (b.userDataDir) {
|
|
23
|
+
const u = b.userDataDir;
|
|
24
|
+
if (u.encoding !== 'base64+gzip+tar' || typeof u.bytes !== 'string') {
|
|
25
|
+
throw new Error('Invalid session bundle: malformed userDataDir payload');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/session/types.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,cAAc,GAAG,CAAU,CAAC;AAoFzC,uFAAuF;AACvF,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC5C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAClE,CAAC;IACD,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,IAAI,CAAC,CAAC,aAAa,KAAK,cAAc,EAAE,CAAC;QACrC,MAAM,IAAI,KAAK,CACX,6CAA6C,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,cAAc,cAAc,GAAG,CACtG,CAAC;IACN,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,aAAa,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,CAAU,EAAE,CAAC;QACnK,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC;YAC1C,MAAM,IAAI,KAAK,CAAC,iDAAiD,GAAG,GAAG,CAAC,CAAC;QAC7E,CAAC;IACL,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IAC1E,CAAC;IACD,IAAI,CAAC,CAAC,WAAW,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;QAC9D,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;IACvF,CAAC;IACD,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;QAChB,MAAM,CAAC,GAAG,CAAC,CAAC,WAAsC,CAAC;QACnD,IAAI,CAAC,CAAC,QAAQ,KAAK,iBAAiB,IAAI,OAAO,CAAC,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAClE,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QAC7E,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SessionProfile - the single home for session-identity resolution.
|
|
3
|
+
*
|
|
4
|
+
* A session's identity (which fingerprint profile it gets, whether the C++
|
|
5
|
+
* anti-detect binary handles spoofing, which OS family it claims) is derived
|
|
6
|
+
* from the same few inputs everywhere: the proxy URL's `session-X` token, the
|
|
7
|
+
* caller's fingerprintOptions, and the host OS. These rules used to be
|
|
8
|
+
* copy-pasted across browser-plugin.ts, browser-controller.ts, and
|
|
9
|
+
* fingerprint-injector.ts; they live here now so a change to any rule is a
|
|
10
|
+
* one-file edit and each priority chain is unit-testable in isolation.
|
|
11
|
+
*/
|
|
12
|
+
export type OsHint = 'macos' | 'linux' | 'windows';
|
|
13
|
+
export type NavigatorPlatform = 'Win32' | 'MacIntel' | 'Linux x86_64';
|
|
14
|
+
/**
|
|
15
|
+
* Extract the `session-X` token from an Apify proxy URL
|
|
16
|
+
* (e.g. http://groups-RESIDENTIAL,session-abc123:pw@proxy.apify.com:8000 → "abc123").
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractProxySessionId(proxyUrl: string | null | undefined): string | null;
|
|
19
|
+
/**
|
|
20
|
+
* Seed source for deterministic fingerprint-profile selection.
|
|
21
|
+
*
|
|
22
|
+
* Production path: the proxy URL's `session-X` token, so each Apify session
|
|
23
|
+
* sticks to one profile across retries. Test/A-B path (no proxy at all):
|
|
24
|
+
* `fingerprintOptions.seedKey`, so harvest comparisons across hosts (Mac vs
|
|
25
|
+
* Linux Docker) hit the SAME bundled profile without needing a fake proxy.
|
|
26
|
+
*
|
|
27
|
+
* Note the asymmetry, preserved from the original call sites: when a proxy URL
|
|
28
|
+
* is present but carries no session token, the result is null - the explicit
|
|
29
|
+
* seedKey is only consulted when there is no proxy.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveSeedKey(input: {
|
|
32
|
+
proxyUrl?: string | null;
|
|
33
|
+
explicitSeedKey?: unknown;
|
|
34
|
+
}): string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Seed key for the JS injection bundle's `__stealth.seedKey` store.
|
|
37
|
+
* Differs from {@link resolveSeedKey}: when the proxy URL carries no
|
|
38
|
+
* `session-X` token, the full proxy URL itself is the seed (still stable per
|
|
39
|
+
* session for session-pinned proxies), and an unparseable URL falls back the
|
|
40
|
+
* same way. No proxy → null.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveInjectionSeedKey(proxyUrl: string | null | undefined): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the fingerprint-enforcement engine to a boolean "is native stealth"
|
|
45
|
+
* (issue #80). The canonical selector is `launchOptions.stealth.engine`; when
|
|
46
|
+
* set it is authoritative (explicit `'js'` forces the JS path even if a legacy
|
|
47
|
+
* flag lingers). Otherwise fall back to the legacy `useNativeStealth` locations
|
|
48
|
+
* (any truthy source wins):
|
|
49
|
+
* 1. Top-level launchOptions (e.g. CDPBrowserPlugin constructor arg)
|
|
50
|
+
* 2. Inside launchOptions.fingerprintOptions (e.g. datadome test / crawler launchOptions)
|
|
51
|
+
* 3. At launchContext root (some CDPCrawler launchContext configurations)
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveUseNativeStealth(launchOptions: {
|
|
54
|
+
stealth?: {
|
|
55
|
+
engine?: unknown;
|
|
56
|
+
};
|
|
57
|
+
useNativeStealth?: unknown;
|
|
58
|
+
fingerprintOptions?: {
|
|
59
|
+
useNativeStealth?: unknown;
|
|
60
|
+
};
|
|
61
|
+
} | undefined, launchContextRoot?: {
|
|
62
|
+
useNativeStealth?: unknown;
|
|
63
|
+
}): boolean;
|
|
64
|
+
/** Map a navigator.platform value onto its OS family. */
|
|
65
|
+
export declare function platformToOsHint(platform: NavigatorPlatform | undefined): OsHint | undefined;
|
|
66
|
+
/** Map an OS family onto its canonical navigator.platform value. */
|
|
67
|
+
export declare function osHintToPlatform(os: OsHint): NavigatorPlatform;
|
|
68
|
+
/** Map a Node `process.platform` onto an OS family (null for exotic hosts). */
|
|
69
|
+
export declare function hostPlatformToOsHint(hostPlatform: NodeJS.Platform): OsHint | null;
|
|
70
|
+
/**
|
|
71
|
+
* Map a Chrome User-Agent string onto its OS family via the UA OS token.
|
|
72
|
+
*
|
|
73
|
+
* This is the authoritative OS signal for a fingerprint: Chrome's UA OS token
|
|
74
|
+
* (and the parallel `userAgentData.platform`) is far harder for the upstream
|
|
75
|
+
* pool to contaminate than `navigator.platform`. The pool ships a recurring
|
|
76
|
+
* ~2.5% of "windows" draws whose UA + uaData say Windows but whose
|
|
77
|
+
* `navigator.platform` lies "Linux x86_64" - trusting the UA here rather than
|
|
78
|
+
* the platform field keeps OS resolution on the coherent majority signal.
|
|
79
|
+
*/
|
|
80
|
+
export declare function osHintFromUserAgent(userAgent: string | undefined): OsHint | undefined;
|
|
81
|
+
/**
|
|
82
|
+
* The OS family a session claims. Priority chain (first hit wins):
|
|
83
|
+
* 1. operatingSystems[0] from fingerprintGeneratorOptions - the single source
|
|
84
|
+
* of truth for OS selection (issue #80)
|
|
85
|
+
* 2. Explicit user platform pin (the deprecated fingerprintOptions.platform).
|
|
86
|
+
* When it contradicts #1, #1 wins; callers warn via `describeOsConflict`.
|
|
87
|
+
* 3. The existing fingerprint's UA OS token (Crawlee-generated). UA-first
|
|
88
|
+
* because `navigator.platform` is the field the upstream pool contaminates
|
|
89
|
+
* (Windows UA + "Linux x86_64" platform); the UA is the coherent signal.
|
|
90
|
+
* 4. The existing fingerprint's navigator.platform string - fallback when the
|
|
91
|
+
* UA carried no recognisable OS token.
|
|
92
|
+
* 5. Host OS (null on exotic hosts - callers that need a hard default
|
|
93
|
+
* apply their own, e.g. `?? 'windows'`)
|
|
94
|
+
*/
|
|
95
|
+
export declare function resolveOsHint(input: {
|
|
96
|
+
explicitPlatform?: NavigatorPlatform;
|
|
97
|
+
operatingSystems?: string[];
|
|
98
|
+
fingerprintUserAgent?: string;
|
|
99
|
+
fingerprintPlatform?: string;
|
|
100
|
+
hostPlatform?: NodeJS.Platform;
|
|
101
|
+
}): OsHint | null;
|
|
102
|
+
//# sourceMappingURL=session-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-profile.d.ts","sourceRoot":"","sources":["../src/session-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AACnD,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC;AAUtE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGxF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAClC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B,GAAG,MAAM,GAAG,IAAI,CAKhB;AAED;;;;;;GAMG;AACH,wBAAg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home for session-identity resolution.
|
|
3
|
+
*
|
|
4
|
+
* A session's identity (which fingerprint profile it gets, whether the C++
|
|
5
|
+
* anti-detect binary handles spoofing, which OS family it claims) is derived
|
|
6
|
+
* from the same few inputs everywhere: the proxy URL's `session-X` token, the
|
|
7
|
+
* caller's fingerprintOptions, and the host OS. These rules used to be
|
|
8
|
+
* copy-pasted across browser-plugin.ts, browser-controller.ts, and
|
|
9
|
+
* fingerprint-injector.ts; they live here now so a change to any rule is a
|
|
10
|
+
* one-file edit and each priority chain is unit-testable in isolation.
|
|
11
|
+
*/
|
|
12
|
+
// `:` and `@` are excluded so a match against a full proxy URL stops at the
|
|
13
|
+
// credential delimiters. The historical plugin/controller variant of this
|
|
14
|
+
// regex was `/session-([^,&]+)/i` run against the FULL URL, which greedily
|
|
15
|
+
// captured "abc123:pw@proxy.apify.com:8000" - the password leaked into the
|
|
16
|
+
// seed material AND the seed disagreed with the injector's variant (which
|
|
17
|
+
// matched only the URL username and got "abc123"). One regex, one answer now.
|
|
18
|
+
const SESSION_TOKEN_RE = /session-([^,&:@]+)/i;
|
|
19
|
+
/**
|
|
20
|
+
* Extract the `session-X` token from an Apify proxy URL
|
|
21
|
+
* (e.g. http://groups-RESIDENTIAL,session-abc123:pw@proxy.apify.com:8000 → "abc123").
|
|
22
|
+
*/
|
|
23
|
+
export function extractProxySessionId(proxyUrl) {
|
|
24
|
+
if (!proxyUrl)
|
|
25
|
+
return null;
|
|
26
|
+
return proxyUrl.match(SESSION_TOKEN_RE)?.[1] ?? null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Seed source for deterministic fingerprint-profile selection.
|
|
30
|
+
*
|
|
31
|
+
* Production path: the proxy URL's `session-X` token, so each Apify session
|
|
32
|
+
* sticks to one profile across retries. Test/A-B path (no proxy at all):
|
|
33
|
+
* `fingerprintOptions.seedKey`, so harvest comparisons across hosts (Mac vs
|
|
34
|
+
* Linux Docker) hit the SAME bundled profile without needing a fake proxy.
|
|
35
|
+
*
|
|
36
|
+
* Note the asymmetry, preserved from the original call sites: when a proxy URL
|
|
37
|
+
* is present but carries no session token, the result is null - the explicit
|
|
38
|
+
* seedKey is only consulted when there is no proxy.
|
|
39
|
+
*/
|
|
40
|
+
export function resolveSeedKey(input) {
|
|
41
|
+
if (input.proxyUrl) {
|
|
42
|
+
return extractProxySessionId(input.proxyUrl);
|
|
43
|
+
}
|
|
44
|
+
return typeof input.explicitSeedKey === 'string' ? input.explicitSeedKey : null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Seed key for the JS injection bundle's `__stealth.seedKey` store.
|
|
48
|
+
* Differs from {@link resolveSeedKey}: when the proxy URL carries no
|
|
49
|
+
* `session-X` token, the full proxy URL itself is the seed (still stable per
|
|
50
|
+
* session for session-pinned proxies), and an unparseable URL falls back the
|
|
51
|
+
* same way. No proxy → null.
|
|
52
|
+
*/
|
|
53
|
+
export function resolveInjectionSeedKey(proxyUrl) {
|
|
54
|
+
if (!proxyUrl)
|
|
55
|
+
return null;
|
|
56
|
+
return extractProxySessionId(proxyUrl) ?? proxyUrl;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve the fingerprint-enforcement engine to a boolean "is native stealth"
|
|
60
|
+
* (issue #80). The canonical selector is `launchOptions.stealth.engine`; when
|
|
61
|
+
* set it is authoritative (explicit `'js'` forces the JS path even if a legacy
|
|
62
|
+
* flag lingers). Otherwise fall back to the legacy `useNativeStealth` locations
|
|
63
|
+
* (any truthy source wins):
|
|
64
|
+
* 1. Top-level launchOptions (e.g. CDPBrowserPlugin constructor arg)
|
|
65
|
+
* 2. Inside launchOptions.fingerprintOptions (e.g. datadome test / crawler launchOptions)
|
|
66
|
+
* 3. At launchContext root (some CDPCrawler launchContext configurations)
|
|
67
|
+
*/
|
|
68
|
+
export function resolveUseNativeStealth(launchOptions, launchContextRoot) {
|
|
69
|
+
const engine = launchOptions?.stealth?.engine;
|
|
70
|
+
if (engine === 'native')
|
|
71
|
+
return true;
|
|
72
|
+
if (engine === 'js')
|
|
73
|
+
return false;
|
|
74
|
+
return !!launchOptions?.useNativeStealth
|
|
75
|
+
|| !!launchOptions?.fingerprintOptions?.useNativeStealth
|
|
76
|
+
|| !!launchContextRoot?.useNativeStealth;
|
|
77
|
+
}
|
|
78
|
+
/** Map a navigator.platform value onto its OS family. */
|
|
79
|
+
export function platformToOsHint(platform) {
|
|
80
|
+
if (platform === 'MacIntel')
|
|
81
|
+
return 'macos';
|
|
82
|
+
if (platform === 'Linux x86_64')
|
|
83
|
+
return 'linux';
|
|
84
|
+
if (platform === 'Win32')
|
|
85
|
+
return 'windows';
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
/** Map an OS family onto its canonical navigator.platform value. */
|
|
89
|
+
export function osHintToPlatform(os) {
|
|
90
|
+
if (os === 'macos')
|
|
91
|
+
return 'MacIntel';
|
|
92
|
+
if (os === 'linux')
|
|
93
|
+
return 'Linux x86_64';
|
|
94
|
+
return 'Win32';
|
|
95
|
+
}
|
|
96
|
+
/** Map a Node `process.platform` onto an OS family (null for exotic hosts). */
|
|
97
|
+
export function hostPlatformToOsHint(hostPlatform) {
|
|
98
|
+
if (hostPlatform === 'darwin')
|
|
99
|
+
return 'macos';
|
|
100
|
+
if (hostPlatform === 'linux')
|
|
101
|
+
return 'linux';
|
|
102
|
+
if (hostPlatform === 'win32')
|
|
103
|
+
return 'windows';
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Map a Chrome User-Agent string onto its OS family via the UA OS token.
|
|
108
|
+
*
|
|
109
|
+
* This is the authoritative OS signal for a fingerprint: Chrome's UA OS token
|
|
110
|
+
* (and the parallel `userAgentData.platform`) is far harder for the upstream
|
|
111
|
+
* pool to contaminate than `navigator.platform`. The pool ships a recurring
|
|
112
|
+
* ~2.5% of "windows" draws whose UA + uaData say Windows but whose
|
|
113
|
+
* `navigator.platform` lies "Linux x86_64" - trusting the UA here rather than
|
|
114
|
+
* the platform field keeps OS resolution on the coherent majority signal.
|
|
115
|
+
*/
|
|
116
|
+
export function osHintFromUserAgent(userAgent) {
|
|
117
|
+
const ua = userAgent ?? '';
|
|
118
|
+
// Order matters: a Mac UA carries "Mac OS X"; Windows carries "Windows NT";
|
|
119
|
+
// Linux carries "X11; Linux" / "Linux x86_64" (excluding Android / CrOS,
|
|
120
|
+
// which are not desktop-Linux families we target).
|
|
121
|
+
if (/Macintosh|Mac OS X/i.test(ua))
|
|
122
|
+
return 'macos';
|
|
123
|
+
if (/Windows NT/i.test(ua))
|
|
124
|
+
return 'windows';
|
|
125
|
+
if (/X11; Linux|Linux x86_64/i.test(ua) && !/Android|CrOS/i.test(ua))
|
|
126
|
+
return 'linux';
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The OS family a session claims. Priority chain (first hit wins):
|
|
131
|
+
* 1. operatingSystems[0] from fingerprintGeneratorOptions - the single source
|
|
132
|
+
* of truth for OS selection (issue #80)
|
|
133
|
+
* 2. Explicit user platform pin (the deprecated fingerprintOptions.platform).
|
|
134
|
+
* When it contradicts #1, #1 wins; callers warn via `describeOsConflict`.
|
|
135
|
+
* 3. The existing fingerprint's UA OS token (Crawlee-generated). UA-first
|
|
136
|
+
* because `navigator.platform` is the field the upstream pool contaminates
|
|
137
|
+
* (Windows UA + "Linux x86_64" platform); the UA is the coherent signal.
|
|
138
|
+
* 4. The existing fingerprint's navigator.platform string - fallback when the
|
|
139
|
+
* UA carried no recognisable OS token.
|
|
140
|
+
* 5. Host OS (null on exotic hosts - callers that need a hard default
|
|
141
|
+
* apply their own, e.g. `?? 'windows'`)
|
|
142
|
+
*/
|
|
143
|
+
export function resolveOsHint(input) {
|
|
144
|
+
const fromOpSys = input.operatingSystems?.[0]?.toLowerCase();
|
|
145
|
+
if (fromOpSys === 'macos' || fromOpSys === 'linux' || fromOpSys === 'windows') {
|
|
146
|
+
return fromOpSys;
|
|
147
|
+
}
|
|
148
|
+
const fromExplicit = platformToOsHint(input.explicitPlatform);
|
|
149
|
+
if (fromExplicit)
|
|
150
|
+
return fromExplicit;
|
|
151
|
+
const fromUa = osHintFromUserAgent(input.fingerprintUserAgent);
|
|
152
|
+
if (fromUa)
|
|
153
|
+
return fromUa;
|
|
154
|
+
const p = (input.fingerprintPlatform ?? '').toLowerCase();
|
|
155
|
+
if (p.includes('mac'))
|
|
156
|
+
return 'macos';
|
|
157
|
+
if (p.includes('linux'))
|
|
158
|
+
return 'linux';
|
|
159
|
+
if (p.includes('win'))
|
|
160
|
+
return 'windows';
|
|
161
|
+
return hostPlatformToOsHint(input.hostPlatform ?? process.platform);
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=session-profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-profile.js","sourceRoot":"","sources":["../src/session-profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,8EAA8E;AAC9E,MAAM,gBAAgB,GAAG,qBAAqB,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,QAAmC;IACrE,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,OAAO,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACzD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAC,KAG9B;IACG,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjB,OAAO,qBAAqB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,KAAK,CAAC,eAAe,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC;AACpF,CAAC;AAED;;;;;;GAM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