camoucore 0.2.0 → 0.6.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/LICENSE +4 -3
- package/dist/camoufox/__main__.d.ts +10 -0
- package/dist/camoufox/__main__.js +1175 -0
- package/dist/camoufox/__version__.d.ts +31 -0
- package/dist/camoufox/__version__.js +32 -0
- package/dist/camoufox/_humanize_playwright.d.ts +54 -0
- package/dist/camoufox/_humanize_playwright.js +429 -0
- package/dist/camoufox/addons.d.ts +21 -0
- package/dist/camoufox/addons.js +56 -0
- package/dist/camoufox/async_api.d.ts +9 -0
- package/dist/camoufox/async_api.js +9 -0
- package/dist/camoufox/browser-pin.d.ts +46 -0
- package/dist/camoufox/browser-pin.js +96 -0
- package/dist/camoufox/cli.d.ts +7 -0
- package/dist/camoufox/cli.js +20 -0
- package/dist/camoufox/coherence.d.ts +141 -0
- package/dist/camoufox/coherence.js +708 -0
- package/dist/camoufox/data-files/audio-output-latency.json +15 -0
- package/dist/camoufox/data-files/browser-pin.json +7 -0
- package/dist/camoufox/data-files/display-profiles.json +6 -0
- package/dist/camoufox/data-files/essential-fonts.json +5 -0
- package/dist/camoufox/data-files/fingerprint-presets-v150.json +14544 -0
- package/dist/camoufox/data-files/fingerprint-presets.json +5192 -0
- package/dist/camoufox/data-files/font-bases.json +1888 -0
- package/dist/camoufox/data-files/font-groups.json +716 -0
- package/dist/camoufox/data-files/font-prefs.json +1046 -0
- package/dist/camoufox/data-files/fonts.json +240 -0
- package/dist/camoufox/data-files/fpgen.yml +44 -0
- package/dist/camoufox/data-files/launcher-constants.json +136 -0
- package/dist/camoufox/data-files/media-devices.json +180 -0
- package/dist/camoufox/data-files/repos.yml +40 -0
- package/dist/camoufox/data-files/voice-manifests.json +1864 -0
- package/dist/camoufox/data-files/voice-uris.json +188 -0
- package/dist/camoufox/data-files/warnings.yml +146 -0
- package/dist/camoufox/display_profile.d.ts +21 -0
- package/dist/camoufox/display_profile.js +129 -0
- package/dist/camoufox/driver_defaults.d.ts +27 -0
- package/dist/camoufox/driver_defaults.js +119 -0
- package/dist/camoufox/exceptions.d.ts +68 -0
- package/dist/camoufox/exceptions.js +122 -0
- package/dist/camoufox/fingerprints.d.ts +434 -0
- package/dist/camoufox/fingerprints.js +1936 -0
- package/dist/camoufox/gpudisplay.d.ts +158 -0
- package/dist/camoufox/gpudisplay.js +695 -0
- package/dist/camoufox/host_rendering.d.ts +38 -0
- package/dist/camoufox/host_rendering.js +180 -0
- package/dist/camoufox/humanize.d.ts +89 -0
- package/dist/camoufox/humanize.js +143 -0
- package/dist/camoufox/index.d.ts +21 -0
- package/dist/camoufox/index.js +21 -0
- package/dist/camoufox/ip.d.ts +45 -0
- package/dist/camoufox/ip.js +114 -0
- package/dist/camoufox/multiversion.d.ts +131 -0
- package/dist/camoufox/multiversion.js +490 -0
- package/dist/camoufox/node-floor.d.ts +5 -0
- package/dist/camoufox/node-floor.js +17 -0
- package/dist/camoufox/paths.d.ts +45 -0
- package/dist/camoufox/paths.js +62 -0
- package/dist/camoufox/pkgman.d.ts +361 -0
- package/dist/camoufox/pkgman.js +1066 -0
- package/dist/camoufox/product.d.ts +8 -0
- package/dist/camoufox/product.js +8 -0
- package/dist/camoufox/pycompat.d.ts +97 -0
- package/dist/camoufox/pycompat.js +458 -0
- package/dist/camoufox/server.d.ts +36 -0
- package/dist/camoufox/server.js +82 -0
- package/dist/camoufox/sync_api.d.ts +77 -0
- package/dist/camoufox/sync_api.js +207 -0
- package/dist/camoufox/utils.d.ts +638 -0
- package/dist/camoufox/utils.js +2507 -0
- package/dist/camoufox/warnings.d.ts +16 -0
- package/dist/camoufox/warnings.js +65 -0
- package/dist/camoufox/webgl.d.ts +52 -0
- package/dist/camoufox/webgl.js +264 -0
- package/dist/camouwolf/__main__.d.ts +10 -0
- package/dist/camouwolf/__main__.js +1180 -0
- package/dist/camouwolf/__version__.d.ts +31 -0
- package/dist/camouwolf/__version__.js +32 -0
- package/dist/camouwolf/_humanize_playwright.d.ts +53 -0
- package/dist/camouwolf/_humanize_playwright.js +427 -0
- package/dist/camouwolf/addons.d.ts +42 -0
- package/dist/camouwolf/addons.js +113 -0
- package/dist/camouwolf/async_api.d.ts +9 -0
- package/dist/camouwolf/async_api.js +9 -0
- package/dist/camouwolf/browser-pin.d.ts +46 -0
- package/dist/camouwolf/browser-pin.js +96 -0
- package/dist/camouwolf/cli.d.ts +7 -0
- package/dist/camouwolf/cli.js +20 -0
- package/dist/camouwolf/clienthints.d.ts +61 -0
- package/dist/camouwolf/clienthints.js +176 -0
- package/dist/camouwolf/coherence.d.ts +152 -0
- package/dist/camouwolf/coherence.js +554 -0
- package/dist/camouwolf/data-files/browser-pin.json +7 -0
- package/dist/camouwolf/data-files/camouwolf.defaults.json +118 -0
- package/dist/camouwolf/data-files/data/bundle-fonts.json +1983 -0
- package/dist/camouwolf/data-files/data/chrome-languages.json +517 -0
- package/dist/camouwolf/data-files/data/properties.json +321 -0
- package/dist/camouwolf/data-files/data/system-colors.json +35 -0
- package/dist/camouwolf/data-files/data/ubo.json +6 -0
- package/dist/camouwolf/data-files/fpgen.yml +41 -0
- package/dist/camouwolf/data-files/launcher-constants.json +26 -0
- package/dist/camouwolf/data-files/repos.yml +23 -0
- package/dist/camouwolf/data-files/warnings.yml +96 -0
- package/dist/camouwolf/driver_defaults.d.ts +25 -0
- package/dist/camouwolf/driver_defaults.js +114 -0
- package/dist/camouwolf/exceptions.d.ts +95 -0
- package/dist/camouwolf/exceptions.js +150 -0
- package/dist/camouwolf/fingerprints.d.ts +227 -0
- package/dist/camouwolf/fingerprints.js +753 -0
- package/dist/camouwolf/gpudisplay.d.ts +171 -0
- package/dist/camouwolf/gpudisplay.js +711 -0
- package/dist/camouwolf/host_rendering.d.ts +18 -0
- package/dist/camouwolf/host_rendering.js +114 -0
- package/dist/camouwolf/humanize.d.ts +84 -0
- package/dist/camouwolf/humanize.js +128 -0
- package/dist/camouwolf/index.d.ts +22 -0
- package/dist/camouwolf/index.js +21 -0
- package/dist/camouwolf/multiversion.d.ts +131 -0
- package/dist/camouwolf/multiversion.js +491 -0
- package/dist/camouwolf/node-floor.d.ts +5 -0
- package/dist/camouwolf/node-floor.js +17 -0
- package/dist/camouwolf/paths.d.ts +34 -0
- package/dist/camouwolf/paths.js +58 -0
- package/dist/camouwolf/pkgman.d.ts +331 -0
- package/dist/camouwolf/pkgman.js +972 -0
- package/dist/camouwolf/product.d.ts +3 -0
- package/dist/camouwolf/product.js +3 -0
- package/dist/camouwolf/pycompat.d.ts +92 -0
- package/dist/camouwolf/pycompat.js +461 -0
- package/dist/camouwolf/server.d.ts +36 -0
- package/dist/camouwolf/server.js +81 -0
- package/dist/camouwolf/switches.d.ts +77 -0
- package/dist/camouwolf/switches.js +222 -0
- package/dist/camouwolf/sync_api.d.ts +84 -0
- package/dist/camouwolf/sync_api.js +173 -0
- package/dist/camouwolf/utils.d.ts +644 -0
- package/dist/camouwolf/utils.js +2057 -0
- package/dist/camouwolf/warnings.d.ts +14 -0
- package/dist/camouwolf/warnings.js +59 -0
- package/dist/camouwolf/webgl.d.ts +41 -0
- package/dist/camouwolf/webgl.js +198 -0
- package/dist/data-files/antibot-rules.json +146 -0
- package/dist/data.d.ts +1 -1
- package/dist/data.js +4 -3
- package/dist/download.js +1 -1
- package/dist/exceptions.d.ts +1 -1
- package/dist/exceptions.js +1 -1
- package/dist/geolocation.js +1 -1
- package/dist/host.d.ts +2 -0
- package/dist/host.js +17 -1
- package/dist/ip.js +1 -1
- package/dist/locales.js +1 -1
- package/dist/mcp/cli.d.ts +15 -0
- package/dist/mcp/cli.js +108 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.js +8 -0
- package/dist/mcp/main.d.ts +2 -0
- package/dist/mcp/main.js +8 -0
- package/dist/mcp/secrets.d.ts +50 -0
- package/dist/mcp/secrets.js +193 -0
- package/dist/mcp/server.d.ts +48 -0
- package/dist/mcp/server.js +653 -0
- package/dist/mcp/tree.d.ts +10 -0
- package/dist/mcp/tree.js +36 -0
- package/dist/passthrough.d.ts +16 -0
- package/dist/passthrough.js +50 -0
- package/dist/product.js +1 -1
- package/dist/settings.d.ts +12 -0
- package/dist/settings.js +95 -0
- package/dist/telemetry.d.ts +127 -0
- package/dist/telemetry.js +426 -0
- package/dist/virtdisplay.d.ts +1 -1
- package/dist/virtdisplay.js +1 -1
- package/dist/warnings.js +1 -1
- package/package.json +57 -13
package/dist/mcp/tree.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrowing an accessibility tree to what the agent asked for, so a large page
|
|
3
|
+
* is not read whole for every question about it.
|
|
4
|
+
*/
|
|
5
|
+
/** Containers that only nest other elements: no name, no value, no text. */
|
|
6
|
+
const BARE = /^- (generic|group|none|presentation|list|listitem|rowgroup)( \[ref=\w+\])?:?$/;
|
|
7
|
+
const indentOf = (line) => line.length - line.trimStart().length;
|
|
8
|
+
/**
|
|
9
|
+
* The lines of `tree` that contain `needle`, ignoring case, each under its
|
|
10
|
+
* ancestors so it is clear where it sits. Ancestors that are only containers
|
|
11
|
+
* are left out, since they say nothing and a deep page has many of them.
|
|
12
|
+
*/
|
|
13
|
+
export function findInTree(tree, needle) {
|
|
14
|
+
const lines = tree.split("\n");
|
|
15
|
+
const wanted = needle.toLowerCase();
|
|
16
|
+
const keep = new Set();
|
|
17
|
+
lines.forEach((line, index) => {
|
|
18
|
+
if (!line.toLowerCase().includes(wanted))
|
|
19
|
+
return;
|
|
20
|
+
keep.add(index);
|
|
21
|
+
let level = indentOf(line);
|
|
22
|
+
for (let above = index - 1; above >= 0 && level > 0; above--) {
|
|
23
|
+
const candidate = lines[above];
|
|
24
|
+
const depth = indentOf(candidate);
|
|
25
|
+
if (depth >= level || !candidate.trim())
|
|
26
|
+
continue;
|
|
27
|
+
level = depth;
|
|
28
|
+
if (!BARE.test(candidate.trim()))
|
|
29
|
+
keep.add(above);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return [...keep]
|
|
33
|
+
.sort((a, b) => a - b)
|
|
34
|
+
.map((index) => lines[index])
|
|
35
|
+
.join("\n");
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passthrough: launch the browser as this machine's own, with no fingerprint injected.
|
|
3
|
+
*
|
|
4
|
+
* TypeScript twin of python/camoucore/src/camoucore/passthrough.py. A passthrough launch
|
|
5
|
+
* draws no identity and sends the browser no fingerprint config; behaviour
|
|
6
|
+
* options (proxy, humanize, block_images, addons, a virtual display) still apply.
|
|
7
|
+
*/
|
|
8
|
+
import type { Product } from "./product.js";
|
|
9
|
+
/** Launch options that set or constrain an injected fingerprint (snake_case, as the launchers take them). */
|
|
10
|
+
export declare const IDENTITY_OPTIONS: readonly ["config", "os", "fingerprint", "fingerprint_preset", "webgl_config", "cpu", "screen", "window", "fonts", "custom_fonts_only", "locale", "geoip", "canvas_noise", "pin_cpu_cores", "allow_os_mismatch", "ff_version", "chrome_version"];
|
|
11
|
+
/** The identity options set in `options`, in IDENTITY_OPTIONS order. */
|
|
12
|
+
export declare function passthroughConflicts(options: Record<string, unknown>): string[];
|
|
13
|
+
/** Throw naming every identity option set alongside passthrough: true. */
|
|
14
|
+
export declare function checkPassthrough(product: Product, options: Record<string, unknown>): void;
|
|
15
|
+
/** A proxied passthrough launch reports this machine's timezone and languages. */
|
|
16
|
+
export declare function warnPassthrough(product: Product, proxy: unknown, iKnowWhatImDoing?: boolean): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LeakWarning } from "./warnings.js";
|
|
2
|
+
/** Launch options that set or constrain an injected fingerprint (snake_case, as the launchers take them). */
|
|
3
|
+
export const IDENTITY_OPTIONS = [
|
|
4
|
+
"config",
|
|
5
|
+
"os",
|
|
6
|
+
"fingerprint",
|
|
7
|
+
"fingerprint_preset",
|
|
8
|
+
"webgl_config",
|
|
9
|
+
"cpu",
|
|
10
|
+
"screen",
|
|
11
|
+
"window",
|
|
12
|
+
"fonts",
|
|
13
|
+
"custom_fonts_only",
|
|
14
|
+
"locale",
|
|
15
|
+
"geoip",
|
|
16
|
+
"canvas_noise",
|
|
17
|
+
"pin_cpu_cores",
|
|
18
|
+
"allow_os_mismatch",
|
|
19
|
+
"ff_version",
|
|
20
|
+
"chrome_version",
|
|
21
|
+
];
|
|
22
|
+
function isSet(value) {
|
|
23
|
+
if (value === undefined || value === null || value === false)
|
|
24
|
+
return false;
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return value.length > 0;
|
|
27
|
+
if (typeof value === "object")
|
|
28
|
+
return Object.keys(value).length > 0;
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
/** The identity options set in `options`, in IDENTITY_OPTIONS order. */
|
|
32
|
+
export function passthroughConflicts(options) {
|
|
33
|
+
return IDENTITY_OPTIONS.filter((name) => isSet(options[name]));
|
|
34
|
+
}
|
|
35
|
+
/** Throw naming every identity option set alongside passthrough: true. */
|
|
36
|
+
export function checkPassthrough(product, options) {
|
|
37
|
+
const conflicts = passthroughConflicts(options);
|
|
38
|
+
if (conflicts.length) {
|
|
39
|
+
throw new Error(`passthrough=True launches ${product.title} with this machine's own fingerprint, so it ` +
|
|
40
|
+
`cannot be combined with options that inject one: ${conflicts.join(", ")}. ` +
|
|
41
|
+
"Remove them, or set passthrough=False.");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** A proxied passthrough launch reports this machine's timezone and languages. */
|
|
45
|
+
export function warnPassthrough(product, proxy, iKnowWhatImDoing) {
|
|
46
|
+
if (proxy) {
|
|
47
|
+
LeakWarning.warn(`passthrough=True with a proxy: ${product.title} reports this machine's timezone, ` +
|
|
48
|
+
"languages and locale, which can disagree with where the proxy exits.", iKnowWhatImDoing);
|
|
49
|
+
}
|
|
50
|
+
}
|
package/dist/product.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The launcher using camoucore, and the engine it drives.
|
|
3
3
|
*
|
|
4
|
-
* TypeScript twin of python/src/camoucore/product.py. Every engine-specific
|
|
4
|
+
* TypeScript twin of python/camoucore/src/camoucore/product.py. Every engine-specific
|
|
5
5
|
* choice in the core reads these; core code never names a launcher.
|
|
6
6
|
*/
|
|
7
7
|
import { userCacheDir } from "./host.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Product } from "./product.js";
|
|
2
|
+
/** Where a user's own defaults live: `<NAME>_DEFAULTS`, or the user config directory. */
|
|
3
|
+
export declare function userDefaultsPath(product: Product): string;
|
|
4
|
+
/**
|
|
5
|
+
* The launch defaults: the packaged file's, overlaid with the user's own file
|
|
6
|
+
* when it exists. An unknown option or a wrong type in the user's file throws.
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadDefaults(product: Product, packaged: string, userFile?: string): Record<string, unknown>;
|
|
9
|
+
/** `options` with each one the caller left unset (null or undefined) taken from `defaults`. */
|
|
10
|
+
export declare function applyDefaults<T extends Record<string, unknown>>(defaults: Record<string, unknown>, options: T): T;
|
|
11
|
+
/** Copy the packaged defaults file to the user's path unless one is there; return that path. */
|
|
12
|
+
export declare function writeUserDefaults(product: Product, packaged: string): string;
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A launcher's defaults file: the values every launch starts from.
|
|
3
|
+
*
|
|
4
|
+
* TypeScript twin of python/camoucore/src/camoucore/settings.py. The packaged
|
|
5
|
+
* `<name>.defaults.json` documents each option as
|
|
6
|
+
* `{"default": ..., "about": "...", "examples": [...]}`; a user's file of the
|
|
7
|
+
* same shape, or the short form `{"telemetry": false}`, overrides it. A value
|
|
8
|
+
* a caller passes to the launch wins over both.
|
|
9
|
+
*/
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
import os from "node:os";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { userConfigDir } from "./host.js";
|
|
14
|
+
/** Where a user's own defaults live: `<NAME>_DEFAULTS`, or the user config directory. */
|
|
15
|
+
export function userDefaultsPath(product) {
|
|
16
|
+
const override = product.getenv("DEFAULTS");
|
|
17
|
+
if (override)
|
|
18
|
+
return override.replace(/^~(?=$|[\\/])/, os.homedir());
|
|
19
|
+
return path.join(userConfigDir(product.name), "defaults.json");
|
|
20
|
+
}
|
|
21
|
+
function read(file) {
|
|
22
|
+
let data;
|
|
23
|
+
try {
|
|
24
|
+
data = JSON.parse(fs.readFileSync(file, "utf-8"));
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
if (e instanceof SyntaxError)
|
|
28
|
+
throw new Error(`${file} is not valid JSON: ${e.message}`);
|
|
29
|
+
throw e;
|
|
30
|
+
}
|
|
31
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
32
|
+
throw new Error(`${file} must hold a JSON object of option names`);
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
const skipped = (name) => name.startsWith("$") || name.startsWith("_");
|
|
36
|
+
const typeName = (v) => Array.isArray(v) ? "array" : v === null ? "null" : typeof v;
|
|
37
|
+
function documentedDefaults(file) {
|
|
38
|
+
const out = {};
|
|
39
|
+
for (const [name, entry] of Object.entries(read(file))) {
|
|
40
|
+
if (skipped(name))
|
|
41
|
+
continue;
|
|
42
|
+
const e = entry;
|
|
43
|
+
if (!e || typeof e !== "object" || !("default" in e) || !e.about)
|
|
44
|
+
throw new Error(`${file}: "${name}" needs a "default" and an "about"`);
|
|
45
|
+
out[name] = e.default;
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
function userValues(file, known) {
|
|
50
|
+
const out = {};
|
|
51
|
+
for (const [name, entry] of Object.entries(read(file))) {
|
|
52
|
+
if (skipped(name))
|
|
53
|
+
continue;
|
|
54
|
+
if (!(name in known))
|
|
55
|
+
throw new Error(`${file}: "${name}" is not an option of the defaults file (${Object.keys(known).join(", ")})`);
|
|
56
|
+
const value = entry && typeof entry === "object" && "default" in entry
|
|
57
|
+
? entry.default
|
|
58
|
+
: entry;
|
|
59
|
+
const expected = known[name];
|
|
60
|
+
if (expected !== null &&
|
|
61
|
+
value !== null &&
|
|
62
|
+
typeName(value) !== typeName(expected))
|
|
63
|
+
throw new Error(`${file}: "${name}" is ${typeName(value)}, but its default is ${typeName(expected)}`);
|
|
64
|
+
out[name] = value;
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The launch defaults: the packaged file's, overlaid with the user's own file
|
|
70
|
+
* when it exists. An unknown option or a wrong type in the user's file throws.
|
|
71
|
+
*/
|
|
72
|
+
export function loadDefaults(product, packaged, userFile) {
|
|
73
|
+
const defaults = documentedDefaults(packaged);
|
|
74
|
+
const file = userFile ?? userDefaultsPath(product);
|
|
75
|
+
if (fs.existsSync(file) && fs.statSync(file).isFile())
|
|
76
|
+
Object.assign(defaults, userValues(file, defaults));
|
|
77
|
+
return defaults;
|
|
78
|
+
}
|
|
79
|
+
/** `options` with each one the caller left unset (null or undefined) taken from `defaults`. */
|
|
80
|
+
export function applyDefaults(defaults, options) {
|
|
81
|
+
const out = { ...options };
|
|
82
|
+
for (const [name, value] of Object.entries(defaults))
|
|
83
|
+
if (out[name] === undefined || out[name] === null)
|
|
84
|
+
out[name] = value;
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
/** Copy the packaged defaults file to the user's path unless one is there; return that path. */
|
|
88
|
+
export function writeUserDefaults(product, packaged) {
|
|
89
|
+
const file = userDefaultsPath(product);
|
|
90
|
+
if (!fs.existsSync(file)) {
|
|
91
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
92
|
+
fs.copyFileSync(packaged, file);
|
|
93
|
+
}
|
|
94
|
+
return file;
|
|
95
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Product } from "./product.js";
|
|
2
|
+
export declare const DEFAULT_ENDPOINT = "https://api.camoufox.com/v1/telemetry/antibot";
|
|
3
|
+
export declare const SCHEMA = 1;
|
|
4
|
+
export declare const OUTCOMES: readonly ["success", "challenge", "block", "unknown"];
|
|
5
|
+
export type Outcome = (typeof OUTCOMES)[number];
|
|
6
|
+
export type Counts = Record<string, Record<Outcome, number>>;
|
|
7
|
+
export declare const FLUSH_INTERVAL_MS = 600000;
|
|
8
|
+
export declare const SEND_TIMEOUT_MS = 3000;
|
|
9
|
+
export declare const BODY_LIMIT = 65536;
|
|
10
|
+
export declare const RULES_DATA: any;
|
|
11
|
+
/** Whether to report: the launch's setting, unless the environment turns it off. */
|
|
12
|
+
export declare function telemetryEnabled(product: Product, setting: boolean | null | undefined): boolean;
|
|
13
|
+
/** The domain a business registers: 'gate.example.co.uk' -> 'example.co.uk'. */
|
|
14
|
+
export declare function registrableDomain(host: string): string;
|
|
15
|
+
export type ProxySetting = null | undefined | string | {
|
|
16
|
+
server?: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The proxy provider's registrable domain, and nothing else of the proxy:
|
|
21
|
+
* 'none' without one, 'ip-address' for a bare IP, 'self-hosted' for a
|
|
22
|
+
* loopback, private or tailnet host.
|
|
23
|
+
*/
|
|
24
|
+
export declare function proxyProvider(proxy: ProxySetting): string;
|
|
25
|
+
/** What a rule may look at: one response, reduced to the fields rules test. */
|
|
26
|
+
export interface ResponseView {
|
|
27
|
+
url: string;
|
|
28
|
+
method: string;
|
|
29
|
+
status: number;
|
|
30
|
+
/** Lower-case names. */
|
|
31
|
+
headers: Record<string, string>;
|
|
32
|
+
document: boolean;
|
|
33
|
+
requestHeaderNames?: Iterable<string>;
|
|
34
|
+
/** With set-cookie, fetched on demand. */
|
|
35
|
+
allHeaders?: Record<string, string>;
|
|
36
|
+
/** Fetched on demand. */
|
|
37
|
+
body?: string;
|
|
38
|
+
}
|
|
39
|
+
/** A rule's other conditions hold, and it needs these to decide. */
|
|
40
|
+
export interface Need {
|
|
41
|
+
need: true;
|
|
42
|
+
headers: boolean;
|
|
43
|
+
body: boolean;
|
|
44
|
+
}
|
|
45
|
+
/** provider, verdict, transient, opens */
|
|
46
|
+
export type Observation = [string, string, boolean, boolean];
|
|
47
|
+
interface CompiledRule {
|
|
48
|
+
verdict: string;
|
|
49
|
+
transient: boolean;
|
|
50
|
+
opens: boolean;
|
|
51
|
+
document: boolean;
|
|
52
|
+
edge: boolean;
|
|
53
|
+
method?: string;
|
|
54
|
+
status?: string[];
|
|
55
|
+
url?: RegExp;
|
|
56
|
+
query: [string, RegExp][];
|
|
57
|
+
headers: [string, RegExp][];
|
|
58
|
+
body?: RegExp;
|
|
59
|
+
requestHeaderName?: RegExp;
|
|
60
|
+
}
|
|
61
|
+
interface CompiledProvider {
|
|
62
|
+
edge: [RegExp, RegExp | null][];
|
|
63
|
+
rules: CompiledRule[];
|
|
64
|
+
unresolved: Outcome;
|
|
65
|
+
}
|
|
66
|
+
export declare class Rules {
|
|
67
|
+
readonly providers: Map<string, CompiledProvider>;
|
|
68
|
+
constructor(data?: any);
|
|
69
|
+
private static isEdge;
|
|
70
|
+
/** The observations this response makes, or what has to be fetched first. */
|
|
71
|
+
classify(view: ResponseView): Need | Observation[];
|
|
72
|
+
unresolved(provider: string): Outcome;
|
|
73
|
+
}
|
|
74
|
+
/** Encounters in progress and the outcome counts of finished ones. */
|
|
75
|
+
export declare class Tally {
|
|
76
|
+
readonly rules: Rules;
|
|
77
|
+
private counts;
|
|
78
|
+
private readonly open;
|
|
79
|
+
constructor(rules: Rules);
|
|
80
|
+
observe(page: unknown, site: string, observation: Observation): void;
|
|
81
|
+
/** A page's main frame now shows `site`: encounters on another site are over. */
|
|
82
|
+
navigated(page: unknown, site: string): void;
|
|
83
|
+
closePage(page: unknown): void;
|
|
84
|
+
closeAll(): void;
|
|
85
|
+
/** The finished counts, reset. */
|
|
86
|
+
take(): Counts;
|
|
87
|
+
private finish;
|
|
88
|
+
}
|
|
89
|
+
export type Sender = (url: string, payload: object) => Promise<void>;
|
|
90
|
+
export interface TelemetryOptions {
|
|
91
|
+
version: string;
|
|
92
|
+
browserVersion: string;
|
|
93
|
+
crossOs: boolean;
|
|
94
|
+
passthrough: boolean;
|
|
95
|
+
proxy: ProxySetting;
|
|
96
|
+
rules?: Rules;
|
|
97
|
+
send?: Sender;
|
|
98
|
+
/** 0 turns the periodic flush off. */
|
|
99
|
+
intervalMs?: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* One launch's reporter. A launcher creates it when telemetry is enabled,
|
|
103
|
+
* hands it each browser context with `watch`, and awaits `close` when the
|
|
104
|
+
* browser closes. Counts are sent every FLUSH_INTERVAL_MS and at close.
|
|
105
|
+
*/
|
|
106
|
+
export declare class Telemetry {
|
|
107
|
+
readonly endpoint: string;
|
|
108
|
+
readonly dimensions: Record<string, string | boolean>;
|
|
109
|
+
readonly rules: Rules;
|
|
110
|
+
readonly tally: Tally;
|
|
111
|
+
private readonly send;
|
|
112
|
+
private readonly timer?;
|
|
113
|
+
private closed;
|
|
114
|
+
private readonly onExit;
|
|
115
|
+
constructor(product: Product, options: TelemetryOptions);
|
|
116
|
+
payload(counts: Counts): object;
|
|
117
|
+
flush(): Promise<void>;
|
|
118
|
+
/** Count every open encounter and send what is left. Safe to call twice. */
|
|
119
|
+
close(): Promise<void>;
|
|
120
|
+
/** Listen to a Playwright BrowserContext. */
|
|
121
|
+
watch(context: any): void;
|
|
122
|
+
/** Count and send everything when the browser closes or disconnects. */
|
|
123
|
+
watchBrowser(browser: any): void;
|
|
124
|
+
private watchPage;
|
|
125
|
+
private onResponse;
|
|
126
|
+
}
|
|
127
|
+
export {};
|