camoucore 0.3.0 → 0.6.1

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 (168) hide show
  1. package/LICENSE +4 -3
  2. package/dist/camoufox/__main__.d.ts +10 -0
  3. package/dist/camoufox/__main__.js +1175 -0
  4. package/dist/camoufox/__version__.d.ts +31 -0
  5. package/dist/camoufox/__version__.js +32 -0
  6. package/dist/camoufox/_humanize_playwright.d.ts +54 -0
  7. package/dist/camoufox/_humanize_playwright.js +429 -0
  8. package/dist/camoufox/addons.d.ts +21 -0
  9. package/dist/camoufox/addons.js +56 -0
  10. package/dist/camoufox/async_api.d.ts +9 -0
  11. package/dist/camoufox/async_api.js +9 -0
  12. package/dist/camoufox/browser-pin.d.ts +46 -0
  13. package/dist/camoufox/browser-pin.js +96 -0
  14. package/dist/camoufox/cli.d.ts +7 -0
  15. package/dist/camoufox/cli.js +20 -0
  16. package/dist/camoufox/coherence.d.ts +141 -0
  17. package/dist/camoufox/coherence.js +708 -0
  18. package/dist/camoufox/data-files/browser-pin.json +7 -0
  19. package/dist/camoufox/data-files/essential-fonts.json +5 -0
  20. package/dist/camoufox/data-files/fingerprint-presets-v150.json +14544 -0
  21. package/dist/camoufox/data-files/fingerprint-presets.json +5192 -0
  22. package/dist/camoufox/data-files/font-bases.json +1887 -0
  23. package/dist/camoufox/data-files/font-groups.json +716 -0
  24. package/dist/camoufox/data-files/fonts.json +240 -0
  25. package/dist/camoufox/data-files/fpgen.yml +44 -0
  26. package/dist/camoufox/data-files/launcher-constants.json +66 -0
  27. package/dist/camoufox/data-files/media-devices.json +148 -0
  28. package/dist/camoufox/data-files/repos.yml +40 -0
  29. package/dist/camoufox/data-files/voice-manifests.json +1864 -0
  30. package/dist/camoufox/data-files/voice-uris.json +188 -0
  31. package/dist/camoufox/data-files/warnings.yml +132 -0
  32. package/dist/camoufox/display_profile.d.ts +17 -0
  33. package/dist/camoufox/display_profile.js +72 -0
  34. package/dist/camoufox/driver_defaults.d.ts +25 -0
  35. package/dist/camoufox/driver_defaults.js +114 -0
  36. package/dist/camoufox/exceptions.d.ts +78 -0
  37. package/dist/camoufox/exceptions.js +135 -0
  38. package/dist/camoufox/fingerprints.d.ts +341 -0
  39. package/dist/camoufox/fingerprints.js +1682 -0
  40. package/dist/camoufox/gpudisplay.d.ts +158 -0
  41. package/dist/camoufox/gpudisplay.js +695 -0
  42. package/dist/camoufox/host_rendering.d.ts +38 -0
  43. package/dist/camoufox/host_rendering.js +180 -0
  44. package/dist/camoufox/humanize.d.ts +89 -0
  45. package/dist/camoufox/humanize.js +143 -0
  46. package/dist/camoufox/index.d.ts +21 -0
  47. package/dist/camoufox/index.js +21 -0
  48. package/dist/camoufox/ip.d.ts +45 -0
  49. package/dist/camoufox/ip.js +114 -0
  50. package/dist/camoufox/multiversion.d.ts +131 -0
  51. package/dist/camoufox/multiversion.js +489 -0
  52. package/dist/camoufox/node-floor.d.ts +5 -0
  53. package/dist/camoufox/node-floor.js +17 -0
  54. package/dist/camoufox/paths.d.ts +45 -0
  55. package/dist/camoufox/paths.js +59 -0
  56. package/dist/camoufox/pkgman.d.ts +331 -0
  57. package/dist/camoufox/pkgman.js +972 -0
  58. package/dist/camoufox/product.d.ts +8 -0
  59. package/dist/camoufox/product.js +8 -0
  60. package/dist/camoufox/pycompat.d.ts +97 -0
  61. package/dist/camoufox/pycompat.js +458 -0
  62. package/dist/camoufox/server.d.ts +36 -0
  63. package/dist/camoufox/server.js +82 -0
  64. package/dist/camoufox/sync_api.d.ts +77 -0
  65. package/dist/camoufox/sync_api.js +194 -0
  66. package/dist/camoufox/utils.d.ts +515 -0
  67. package/dist/camoufox/utils.js +1995 -0
  68. package/dist/camoufox/warnings.d.ts +16 -0
  69. package/dist/camoufox/warnings.js +65 -0
  70. package/dist/camoufox/webgl.d.ts +52 -0
  71. package/dist/camoufox/webgl.js +264 -0
  72. package/dist/camouwolf/__main__.d.ts +10 -0
  73. package/dist/camouwolf/__main__.js +1180 -0
  74. package/dist/camouwolf/__version__.d.ts +31 -0
  75. package/dist/camouwolf/__version__.js +32 -0
  76. package/dist/camouwolf/_humanize_playwright.d.ts +53 -0
  77. package/dist/camouwolf/_humanize_playwright.js +427 -0
  78. package/dist/camouwolf/addons.d.ts +42 -0
  79. package/dist/camouwolf/addons.js +113 -0
  80. package/dist/camouwolf/async_api.d.ts +9 -0
  81. package/dist/camouwolf/async_api.js +9 -0
  82. package/dist/camouwolf/browser-pin.d.ts +46 -0
  83. package/dist/camouwolf/browser-pin.js +96 -0
  84. package/dist/camouwolf/cli.d.ts +7 -0
  85. package/dist/camouwolf/cli.js +20 -0
  86. package/dist/camouwolf/clienthints.d.ts +61 -0
  87. package/dist/camouwolf/clienthints.js +176 -0
  88. package/dist/camouwolf/coherence.d.ts +152 -0
  89. package/dist/camouwolf/coherence.js +554 -0
  90. package/dist/camouwolf/data-files/browser-pin.json +7 -0
  91. package/dist/camouwolf/data-files/camouwolf.defaults.json +118 -0
  92. package/dist/camouwolf/data-files/data/bundle-fonts.json +1983 -0
  93. package/dist/camouwolf/data-files/data/chrome-languages.json +517 -0
  94. package/dist/camouwolf/data-files/data/properties.json +321 -0
  95. package/dist/camouwolf/data-files/data/system-colors.json +35 -0
  96. package/dist/camouwolf/data-files/data/ubo.json +6 -0
  97. package/dist/camouwolf/data-files/fpgen.yml +41 -0
  98. package/dist/camouwolf/data-files/launcher-constants.json +26 -0
  99. package/dist/camouwolf/data-files/repos.yml +23 -0
  100. package/dist/camouwolf/data-files/warnings.yml +96 -0
  101. package/dist/camouwolf/driver_defaults.d.ts +25 -0
  102. package/dist/camouwolf/driver_defaults.js +114 -0
  103. package/dist/camouwolf/exceptions.d.ts +95 -0
  104. package/dist/camouwolf/exceptions.js +150 -0
  105. package/dist/camouwolf/fingerprints.d.ts +227 -0
  106. package/dist/camouwolf/fingerprints.js +753 -0
  107. package/dist/camouwolf/gpudisplay.d.ts +171 -0
  108. package/dist/camouwolf/gpudisplay.js +711 -0
  109. package/dist/camouwolf/host_rendering.d.ts +18 -0
  110. package/dist/camouwolf/host_rendering.js +114 -0
  111. package/dist/camouwolf/humanize.d.ts +84 -0
  112. package/dist/camouwolf/humanize.js +128 -0
  113. package/dist/camouwolf/index.d.ts +22 -0
  114. package/dist/camouwolf/index.js +21 -0
  115. package/dist/camouwolf/multiversion.d.ts +131 -0
  116. package/dist/camouwolf/multiversion.js +491 -0
  117. package/dist/camouwolf/node-floor.d.ts +5 -0
  118. package/dist/camouwolf/node-floor.js +17 -0
  119. package/dist/camouwolf/paths.d.ts +34 -0
  120. package/dist/camouwolf/paths.js +58 -0
  121. package/dist/camouwolf/pkgman.d.ts +331 -0
  122. package/dist/camouwolf/pkgman.js +972 -0
  123. package/dist/camouwolf/product.d.ts +3 -0
  124. package/dist/camouwolf/product.js +3 -0
  125. package/dist/camouwolf/pycompat.d.ts +92 -0
  126. package/dist/camouwolf/pycompat.js +461 -0
  127. package/dist/camouwolf/server.d.ts +36 -0
  128. package/dist/camouwolf/server.js +81 -0
  129. package/dist/camouwolf/switches.d.ts +77 -0
  130. package/dist/camouwolf/switches.js +222 -0
  131. package/dist/camouwolf/sync_api.d.ts +84 -0
  132. package/dist/camouwolf/sync_api.js +173 -0
  133. package/dist/camouwolf/utils.d.ts +644 -0
  134. package/dist/camouwolf/utils.js +2057 -0
  135. package/dist/camouwolf/warnings.d.ts +14 -0
  136. package/dist/camouwolf/warnings.js +59 -0
  137. package/dist/camouwolf/webgl.d.ts +41 -0
  138. package/dist/camouwolf/webgl.js +198 -0
  139. package/dist/data.d.ts +1 -1
  140. package/dist/data.js +3 -3
  141. package/dist/download.js +1 -1
  142. package/dist/exceptions.d.ts +1 -1
  143. package/dist/exceptions.js +1 -1
  144. package/dist/geolocation.js +1 -1
  145. package/dist/host.js +1 -1
  146. package/dist/ip.js +1 -1
  147. package/dist/locales.js +1 -1
  148. package/dist/mcp/cli.d.ts +15 -0
  149. package/dist/mcp/cli.js +108 -0
  150. package/dist/mcp/index.d.ts +8 -0
  151. package/dist/mcp/index.js +8 -0
  152. package/dist/mcp/main.d.ts +2 -0
  153. package/dist/mcp/main.js +8 -0
  154. package/dist/mcp/secrets.d.ts +50 -0
  155. package/dist/mcp/secrets.js +193 -0
  156. package/dist/mcp/server.d.ts +48 -0
  157. package/dist/mcp/server.js +653 -0
  158. package/dist/mcp/tree.d.ts +10 -0
  159. package/dist/mcp/tree.js +36 -0
  160. package/dist/passthrough.d.ts +1 -1
  161. package/dist/product.js +1 -1
  162. package/dist/settings.js +1 -1
  163. package/dist/telemetry.d.ts +0 -1
  164. package/dist/telemetry.js +5 -4
  165. package/dist/virtdisplay.d.ts +1 -1
  166. package/dist/virtdisplay.js +1 -1
  167. package/dist/warnings.js +1 -1
  168. package/package.json +57 -13
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Driver calls that reach the page as a person's actions would. The TypeScript
3
+ * twin of python/camoucore/src/camoucore/camouwolf/driver_defaults.py, which holds the reasoning.
4
+ *
5
+ * Screenshots default to caret: "initial", which leaves the page's style
6
+ * attributes alone. fill() clicks a text field that is not focused first, unless
7
+ * something covers it. Both apply only under a Browser or BrowserContext marked
8
+ * by a Camouwolf launch (attachDriverDefaults).
9
+ */
10
+ import { HIT_TEST_JS } from "@jwriter20/myuri";
11
+ const LAUNCHED = Symbol.for("camouwolf.driver-defaults");
12
+ const FILL_PATCHED = Symbol.for("camouwolf.driver-defaults.fill");
13
+ // Byte-identical to the Python constant (tests/package-parity.test.ts).
14
+ // Whether fill() on this target should click first: a text field a person types
15
+ // into, without focus. fill() on a label, or inside one, fills its control.
16
+ export const FILL_NEEDS_CLICK = `(e) => {
17
+ const field = e.matches('a, input, textarea, button, select') || e.isContentEditable
18
+ ? e : (e.closest('label')?.control || e);
19
+ const type = field.localName === 'input' ? field.type : null;
20
+ const typed = field.localName === 'textarea' || field.isContentEditable ||
21
+ ['text', 'search', 'email', 'url', 'tel', 'password', 'number'].includes(type);
22
+ if (!typed || field.disabled || field.readOnly)
23
+ return false;
24
+ const active = field.getRootNode().activeElement;
25
+ return active !== field && !(field.isContentEditable && field.contains(active));
26
+ }`;
27
+ /**
28
+ * The JS client sends a string as an expression and does not call what it
29
+ * evaluates to (isFunction: false), where Python's lets the page decide. A
30
+ * function whose source is the string is sent and called.
31
+ */
32
+ export function pageFunction(source) {
33
+ return Object.assign(() => undefined, { toString: () => source });
34
+ }
35
+ async function clickToFocus(target, evaluate, { timeout, force }) {
36
+ if (await evaluate(pageFunction(FILL_NEEDS_CLICK))) {
37
+ await target.scrollIntoViewIfNeeded({ timeout });
38
+ if ((await evaluate(HIT_TEST_JS)) === null)
39
+ await target.click({ timeout, force });
40
+ }
41
+ }
42
+ /** Page, Locator and Frame fill (and Locator.clear) all go through Frame.fill. */
43
+ export function patchFrameFill(prototype) {
44
+ if (Object.hasOwn(prototype, FILL_PATCHED))
45
+ return;
46
+ prototype[FILL_PATCHED] = true;
47
+ const original = prototype.fill;
48
+ prototype.fill = async function (selector, value, options = {}) {
49
+ if (launchedByCamouwolf(this)) {
50
+ const locator = this.locator(selector);
51
+ const target = options.strict ? locator : locator.first();
52
+ await clickToFocus(target, (script) => target.evaluate(script, null, { timeout: options.timeout }), options);
53
+ }
54
+ return original.call(this, selector, value, options);
55
+ };
56
+ }
57
+ function patchHandleFill(prototype) {
58
+ if (Object.hasOwn(prototype, FILL_PATCHED))
59
+ return;
60
+ prototype[FILL_PATCHED] = true;
61
+ const original = prototype.fill;
62
+ prototype.fill = async function (value, options = {}) {
63
+ if (launchedByCamouwolf(this))
64
+ await clickToFocus(this, (script) => this.evaluate(script, null), options);
65
+ return original.call(this, value, options);
66
+ };
67
+ }
68
+ /** playwright-core does not export its client classes, so they are taken from
69
+ * the objects its connection creates. */
70
+ function patchClientClass(object) {
71
+ if (object._type === "Frame")
72
+ patchFrameFill(Object.getPrototypeOf(object));
73
+ if (object._type === "ElementHandle")
74
+ patchHandleFill(Object.getPrototypeOf(object));
75
+ }
76
+ /**
77
+ * Give every page under `target` (a Browser or BrowserContext from a Camouwolf
78
+ * launch) these defaults. The caret is filled in where the client sends the
79
+ * request, so page, element and locator screenshots all get it; an explicit
80
+ * caret is kept.
81
+ */
82
+ export function attachDriverDefaults(target) {
83
+ const owner = target;
84
+ owner[LAUNCHED] = true;
85
+ const connection = owner._connection;
86
+ if (!connection || connection[LAUNCHED])
87
+ return target;
88
+ connection[LAUNCHED] = true;
89
+ const send = connection.sendMessageToServer;
90
+ connection.sendMessageToServer = function (object, method, params, ...rest) {
91
+ if (method === "screenshot" &&
92
+ params?.caret === undefined &&
93
+ launchedByCamouwolf(object))
94
+ params = { ...params, caret: "initial" };
95
+ return send.call(this, object, method, params, ...rest);
96
+ };
97
+ // A persistent context arrives with its pages, and so its frames, created.
98
+ for (const object of connection._objects.values())
99
+ patchClientClass(object);
100
+ const create = connection._createRemoteObject;
101
+ connection._createRemoteObject = function (...args) {
102
+ const object = create.apply(this, args);
103
+ patchClientClass(object);
104
+ return object;
105
+ };
106
+ return target;
107
+ }
108
+ /** ElementHandle -> Frame -> Page -> BrowserContext -> Browser. */
109
+ function launchedByCamouwolf(object) {
110
+ for (let owner = object; owner; owner = owner._parent)
111
+ if (owner[LAUNCHED])
112
+ return true;
113
+ return false;
114
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * TypeScript twin of python/camoucore/src/camoucore/camouwolf/exceptions.py.
3
+ *
4
+ * The Python hierarchy leans on builtin bases (FileNotFoundError, ValueError,
5
+ * ImportError) that have no JS analogue; those become plain Error subclasses
6
+ * here. Every relationship that callers actually catch on -- LocaleError,
7
+ * VirtualDisplayError -- is preserved.
8
+ */
9
+ export { CannotExecuteXvfb, CannotFindXvfb, CorruptedDownload, InvalidIP, InvalidLocale, InvalidProxy, LocaleError, NotInstalledGeoIPExtra, UnknownIPLocation, UnknownLanguage, UnknownTerritory, UnsupportedOS, VirtualDisplayError, VirtualDisplayNotSupported, } from "../exceptions.js";
10
+ import { VirtualDisplayError } from "../exceptions.js";
11
+ /** The Python twin relies on the builtin FileNotFoundError; JS has no such
12
+ * class, so version-lookup misses raise this instead. */
13
+ export declare class FileNotFoundError extends Error {
14
+ constructor(message?: string);
15
+ }
16
+ export declare class UnsupportedVersion extends Error {
17
+ constructor(message?: string);
18
+ }
19
+ export declare class MissingRelease extends Error {
20
+ constructor(message?: string);
21
+ }
22
+ /** Raised when a downloaded asset does not match its expected sha256 digest. */
23
+ export declare class UnsupportedArchitecture extends Error {
24
+ constructor(message?: string);
25
+ }
26
+ export declare class InvalidPropertyType extends Error {
27
+ constructor(message?: string);
28
+ }
29
+ export declare class InvalidAddonPath extends FileNotFoundError {
30
+ constructor(message?: string);
31
+ }
32
+ export declare class NonChromeFingerprint extends Error {
33
+ constructor(message?: string);
34
+ }
35
+ export declare class InvalidOS extends Error {
36
+ constructor(message?: string);
37
+ }
38
+ export declare class GpuDisplayError extends VirtualDisplayError {
39
+ constructor(message?: string);
40
+ }
41
+ export declare class NoGpuFound extends GpuDisplayError {
42
+ constructor(message?: string);
43
+ }
44
+ export declare class AmbiguousGpuSelection extends GpuDisplayError {
45
+ constructor(message?: string);
46
+ }
47
+ export declare class GpuNotFound extends GpuDisplayError {
48
+ constructor(message?: string);
49
+ }
50
+ export declare class CannotFindXorg extends GpuDisplayError {
51
+ constructor(message?: string);
52
+ }
53
+ export declare class CannotExecuteXorg extends GpuDisplayError {
54
+ constructor(message?: string);
55
+ }
56
+ export declare class GpuVtTakeover extends GpuDisplayError {
57
+ constructor(message?: string);
58
+ }
59
+ export declare class GpuSoftwareFallback extends GpuDisplayError {
60
+ constructor(message?: string);
61
+ }
62
+ export declare class CamouwolfNotInstalled extends FileNotFoundError {
63
+ constructor(message?: string);
64
+ }
65
+ /** Raised when Camouwolf's required runtime directory cannot be prepared. */
66
+ export declare class ProfileDirectoryError extends Error {
67
+ constructor(message?: string, options?: ErrorOptions);
68
+ }
69
+ /** Python's ValueError (pycompat.ts re-exports it). */
70
+ export declare class ValueError extends Error {
71
+ name: string;
72
+ }
73
+ /** Python's KeyError (pycompat.ts re-exports it). */
74
+ export declare class KeyError extends Error {
75
+ name: string;
76
+ }
77
+ /** Python's NotImplementedError: an option Camouwolf refuses rather than ignores. */
78
+ export declare class NotImplementedError extends Error {
79
+ name: string;
80
+ }
81
+ /** Raised when `config` names a property the browser does not read. */
82
+ export declare class UnknownProperty extends KeyError {
83
+ name: string;
84
+ }
85
+ /**
86
+ * Raised when the identity contradicts itself in a way a page can read, such
87
+ * as a user agent and client hints naming different operating systems.
88
+ */
89
+ export declare class IncoherentIdentity extends ValueError {
90
+ name: string;
91
+ }
92
+ /** Raised when the identity claims an OS this host cannot pass for. */
93
+ export declare class UnsupportedOSSpoof extends ValueError {
94
+ name: string;
95
+ }
@@ -0,0 +1,150 @@
1
+ /**
2
+ * TypeScript twin of python/camoucore/src/camoucore/camouwolf/exceptions.py.
3
+ *
4
+ * The Python hierarchy leans on builtin bases (FileNotFoundError, ValueError,
5
+ * ImportError) that have no JS analogue; those become plain Error subclasses
6
+ * here. Every relationship that callers actually catch on -- LocaleError,
7
+ * VirtualDisplayError -- is preserved.
8
+ */
9
+ // The core's own errors, so callers catch one class whichever side raised it.
10
+ export { CannotExecuteXvfb, CannotFindXvfb, CorruptedDownload, InvalidIP, InvalidLocale, InvalidProxy, LocaleError, NotInstalledGeoIPExtra, UnknownIPLocation, UnknownLanguage, UnknownTerritory, UnsupportedOS, VirtualDisplayError, VirtualDisplayNotSupported, } from "../exceptions.js";
11
+ import { VirtualDisplayError } from "../exceptions.js";
12
+ /** The Python twin relies on the builtin FileNotFoundError; JS has no such
13
+ * class, so version-lookup misses raise this instead. */
14
+ export class FileNotFoundError extends Error {
15
+ constructor(message) {
16
+ super(message ?? "File couldn't be found.");
17
+ this.name = "FileNotFoundError";
18
+ }
19
+ }
20
+ export class UnsupportedVersion extends Error {
21
+ constructor(message) {
22
+ super(message ?? "The Camouwolf executable is outdated.");
23
+ this.name = "UnsupportedVersion";
24
+ }
25
+ }
26
+ export class MissingRelease extends Error {
27
+ constructor(message) {
28
+ super(message ?? "A required GitHub release asset is missing.");
29
+ this.name = "MissingRelease";
30
+ }
31
+ }
32
+ /** Raised when a downloaded asset does not match its expected sha256 digest. */
33
+ export class UnsupportedArchitecture extends Error {
34
+ constructor(message) {
35
+ super(message ?? "The architecture is not supported.");
36
+ this.name = "UnsupportedArchitecture";
37
+ }
38
+ }
39
+ export class InvalidPropertyType extends Error {
40
+ constructor(message) {
41
+ super(message ?? "The property type is invalid.");
42
+ this.name = "InvalidPropertyType";
43
+ }
44
+ }
45
+ export class InvalidAddonPath extends FileNotFoundError {
46
+ constructor(message) {
47
+ super(message ?? "The addon path is invalid.");
48
+ this.name = "InvalidAddonPath";
49
+ }
50
+ }
51
+ export class NonChromeFingerprint extends Error {
52
+ constructor(message) {
53
+ super(message ?? "A passed fingerprint is not a Chrome fingerprint.");
54
+ this.name = "NonChromeFingerprint";
55
+ }
56
+ }
57
+ export class InvalidOS extends Error {
58
+ constructor(message) {
59
+ super(message ?? "The target OS is invalid.");
60
+ this.name = "InvalidOS";
61
+ }
62
+ }
63
+ export class GpuDisplayError extends VirtualDisplayError {
64
+ constructor(message) {
65
+ super(message ?? "The headless='virtual-gpu' display cannot be used.");
66
+ this.name = "GpuDisplayError";
67
+ }
68
+ }
69
+ export class NoGpuFound extends GpuDisplayError {
70
+ constructor(message) {
71
+ super(message ?? "No GPU render node with a PCI address was found.");
72
+ this.name = "NoGpuFound";
73
+ }
74
+ }
75
+ export class AmbiguousGpuSelection extends GpuDisplayError {
76
+ constructor(message) {
77
+ super(message ?? "Several GPUs match, or several exist and none was named.");
78
+ this.name = "AmbiguousGpuSelection";
79
+ }
80
+ }
81
+ export class GpuNotFound extends GpuDisplayError {
82
+ constructor(message) {
83
+ super(message ?? "The GPU selector matches no GPU.");
84
+ this.name = "GpuNotFound";
85
+ }
86
+ }
87
+ export class CannotFindXorg extends GpuDisplayError {
88
+ constructor(message) {
89
+ super(message ?? "Xorg cannot be found.");
90
+ this.name = "CannotFindXorg";
91
+ }
92
+ }
93
+ export class CannotExecuteXorg extends GpuDisplayError {
94
+ constructor(message) {
95
+ super(message ?? "Xorg cannot be started, or exited right after starting.");
96
+ this.name = "CannotExecuteXorg";
97
+ }
98
+ }
99
+ export class GpuVtTakeover extends GpuDisplayError {
100
+ constructor(message) {
101
+ super(message ?? "The Xorg server switched the active console VT.");
102
+ this.name = "GpuVtTakeover";
103
+ }
104
+ }
105
+ export class GpuSoftwareFallback extends GpuDisplayError {
106
+ constructor(message) {
107
+ super(message ?? "The browser on a GPU display never rendered on the GPU.");
108
+ this.name = "GpuSoftwareFallback";
109
+ }
110
+ }
111
+ export class CamouwolfNotInstalled extends FileNotFoundError {
112
+ constructor(message) {
113
+ super(message ?? "Camouwolf is not installed.");
114
+ this.name = "CamouwolfNotInstalled";
115
+ }
116
+ }
117
+ /** Raised when Camouwolf's required runtime directory cannot be prepared. */
118
+ export class ProfileDirectoryError extends Error {
119
+ constructor(message, options) {
120
+ super(message ?? "Camouwolf's runtime directory could not be prepared.", options);
121
+ this.name = "ProfileDirectoryError";
122
+ }
123
+ }
124
+ /** Python's ValueError (pycompat.ts re-exports it). */
125
+ export class ValueError extends Error {
126
+ name = "ValueError";
127
+ }
128
+ /** Python's KeyError (pycompat.ts re-exports it). */
129
+ export class KeyError extends Error {
130
+ name = "KeyError";
131
+ }
132
+ /** Python's NotImplementedError: an option Camouwolf refuses rather than ignores. */
133
+ export class NotImplementedError extends Error {
134
+ name = "NotImplementedError";
135
+ }
136
+ /** Raised when `config` names a property the browser does not read. */
137
+ export class UnknownProperty extends KeyError {
138
+ name = "UnknownProperty";
139
+ }
140
+ /**
141
+ * Raised when the identity contradicts itself in a way a page can read, such
142
+ * as a user agent and client hints naming different operating systems.
143
+ */
144
+ export class IncoherentIdentity extends ValueError {
145
+ name = "IncoherentIdentity";
146
+ }
147
+ /** Raised when the identity claims an OS this host cannot pass for. */
148
+ export class UnsupportedOSSpoof extends ValueError {
149
+ name = "UnsupportedOSSpoof";
150
+ }
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Chrome identities: drawing one with fpgen and turning it into Camouwolf config.
3
+ *
4
+ * An fpgen fingerprint is one recorded Chrome on one real machine, so its
5
+ * fields agree with each other; the launcher maps them and leaves them
6
+ * together. What the record cannot know is filled in afterwards: the Chromium
7
+ * milestone the binary really is, and the client hints that milestone and OS
8
+ * imply (clienthints.ts).
9
+ *
10
+ * TypeScript twin of python/camoucore/src/camoucore/camouwolf/fingerprints.py.
11
+ */
12
+ import { type OsKey } from "./clienthints.js";
13
+ type Config = Record<string, any>;
14
+ /** The fpgen mapping file. */
15
+ export declare const FPGEN_DATA: Readonly<Record<string, any>>;
16
+ /** Camouwolf's OS names and the keys the rest of the launcher uses for them. */
17
+ export declare const OS_KEYS: Readonly<Record<string, OsKey>>;
18
+ export declare const OS_NAMES: Readonly<Record<OsKey, string>>;
19
+ /** The OS name ('macos', 'windows', 'linux') a navigator.platform belongs to. */
20
+ export declare function platformToOs(platform: string): string;
21
+ /** fpgen's OS names, from Camouwolf's. */
22
+ export declare const FPGEN_OS: Readonly<Record<string, string>>;
23
+ export interface ScreenBounds {
24
+ minWidth?: number | null;
25
+ maxWidth?: number | null;
26
+ minHeight?: number | null;
27
+ maxHeight?: number | null;
28
+ }
29
+ /**
30
+ * A bound on the screen a generated fingerprint may claim: the generated
31
+ * screen must fit inside the given fields.
32
+ */
33
+ export declare class Screen {
34
+ minWidth: number | null;
35
+ maxWidth: number | null;
36
+ minHeight: number | null;
37
+ maxHeight: number | null;
38
+ constructor({ minWidth, maxWidth, minHeight, maxHeight, }?: ScreenBounds);
39
+ /**
40
+ * The bound, as fpgen conditions. fpgen takes a predicate per field and
41
+ * rejects a value the predicate refuses, so a range is a closure rather
42
+ * than a list of allowed values.
43
+ */
44
+ asConditions(): Record<string, (value: unknown) => boolean>;
45
+ /** dataclasses.asdict(), with the Python field names. */
46
+ toPyDict(): Record<string, number | null>;
47
+ }
48
+ /** Logical CPUs this process may actually run on (cgroup/affinity aware). */
49
+ export declare function hostCpuCount(): number | null;
50
+ /**
51
+ * Core counts real desktop machines ship with, from the recorded presets. 2 is
52
+ * excluded although the scraped corpus has it: no Apple Silicon part has fewer
53
+ * than 8 cores, so 2 beside the common "Apple M1" renderer is a machine that
54
+ * does not exist. A host outside the table is snapped into it.
55
+ */
56
+ export declare const PLAUSIBLE_CORE_COUNTS: readonly number[];
57
+ export interface HostCpu {
58
+ /** Logical CPUs of the host (default: hostCpuCount()). */
59
+ cpuCount?: number | null;
60
+ /** Whether the host can pin processes to cores (default: cpu_affinity.supported()). */
61
+ canPinHost?: boolean;
62
+ }
63
+ /**
64
+ * navigator.hardwareConcurrency = the host's parallelism, snapped DOWN into
65
+ * PLAUSIBLE_CORE_COUNTS -- or the fingerprint's own value (snapped, capped by
66
+ * the host) when the browser can be pinned to that many cores.
67
+ *
68
+ * @param canPin false when nothing will pin the browser (launchServer, or
69
+ * launchOptions used directly); undefined/null: whatever the host supports.
70
+ * @param host overrides for the host probes (tests).
71
+ */
72
+ export declare function fixHardwareConcurrency(config: Config, canPin?: boolean | null, host?: HostCpu): void;
73
+ /** Enforce inner <= outer <= avail <= screen on both axes. */
74
+ export declare function clampWindowDimensions(config: Config): void;
75
+ /**
76
+ * Shrink screen.width/height down to the bounds of the real display, keeping
77
+ * the taskbar delta. Run clampWindowDimensions afterwards.
78
+ */
79
+ export declare function clampScreenToDisplay(config: Config, maxWidth: number | null | undefined, maxHeight: number | null | undefined): void;
80
+ /** Keep the window box inside the screen: 0 <= screenX/Y <= screen - outer. */
81
+ export declare function clampWindowPosition(config: Config): void;
82
+ /**
83
+ * The window position and size, in CSS pixels, Chrome reads back on X11 for a
84
+ * window it was asked to open at `position` and `size`.
85
+ *
86
+ * The bounds go to device pixels as ToPixelRect (float32, enclosing rect, a
87
+ * 0.001 rounding allowance) and come back as ToDIPRect (float32 times
88
+ * 1.f/scale, enclosing rect, no allowance), so at 1.75 a 1000 px window is
89
+ * reported 1001 px wide.
90
+ */
91
+ export declare function chromeWindowReports(position: number, size: number, dpr: number): [number, number];
92
+ /**
93
+ * The innerWidth Chrome reports in a window `width` CSS pixels wide.
94
+ *
95
+ * The page spans the window, sized up to whole device pixels and read back
96
+ * to the nearest CSS pixel, so at 1.25 a window 1537 wide reports an
97
+ * innerWidth of 1538, wider than the window itself.
98
+ */
99
+ export declare function chromeViewportWidth(width: number, dpr: number): number;
100
+ /**
101
+ * Claim the nearest window Chrome can report at its devicePixelRatio.
102
+ *
103
+ * At a fractional ratio some positions and sizes are never read back (at 1.75
104
+ * no window reports screenX 7). The claim moves to the nearest one Chrome
105
+ * does report, inside the drawn window's box so it still fits the screen, and
106
+ * no narrower than the page Chrome lays out in it.
107
+ */
108
+ export declare function snapWindowToDevicePixels(config: Config): void;
109
+ /**
110
+ * The --window-position/--window-size values Chrome reports back as
111
+ * `position`, `size`; the claim itself when no input near it does.
112
+ */
113
+ export declare function windowSwitchBounds(position: number, size: number, dpr: number): [number, number];
114
+ /** The smallest screen mainstream hardware still ships. */
115
+ export declare const MODERN_SCREEN_FLOOR: readonly [number, number];
116
+ /**
117
+ * Lift netbook-era screen geometry to the modern floor, keeping the
118
+ * screen-to-avail gaps. Call BEFORE clampScreenToDisplay.
119
+ */
120
+ export declare function raiseScreenToModernFloor(config: Config): void;
121
+ /**
122
+ * Whether `renderer` is a software rasterizer rather than real hardware.
123
+ * Case-insensitive: fpgen hands a condition's predicate the value lowercased.
124
+ */
125
+ export declare function isSoftwareRenderer(renderer: string | null | undefined): boolean;
126
+ /**
127
+ * The taskbar, menu bar or panel a desktop reserves, in CSS pixels. A screen
128
+ * whose available area equals its whole area on both axes has none, which only
129
+ * a kiosk shows.
130
+ */
131
+ export declare const TASKBAR_HEIGHT: Readonly<Record<OsKey, number>>;
132
+ /** Reserve the OS's taskbar when the identity's available area is its whole screen. */
133
+ export declare function fixScreenNoTaskbar(config: Config, targetOs: OsKey): void;
134
+ /**
135
+ * Families every installation of the OS has. fpgen records the fonts a probe
136
+ * list found, so a short record (six families on some Linux machines) would
137
+ * otherwise leave a page with almost nothing to render in.
138
+ */
139
+ export declare const ESSENTIAL_FONTS: Readonly<Record<OsKey, string[]>>;
140
+ /**
141
+ * The devices a machine with nothing plugged in enumerates, before the page
142
+ * has media permission: one entry per kind, with empty id, label and group.
143
+ */
144
+ export declare const MEDIA_DEVICE_KINDS: readonly string[];
145
+ export declare const DEFAULT_MEDIA_DEVICES: Readonly<Record<OsKey, string[]>>;
146
+ /**
147
+ * fpgen's device counts as `mediaDevices:enumerated` entries.
148
+ *
149
+ * Before a page holds media permission Chrome lists at most one device of
150
+ * each kind, with empty deviceId, label and groupId.
151
+ */
152
+ export declare function mediaDevices(devices: unknown): string[] | null;
153
+ /**
154
+ * fpgen's speechSynthesis voices as `voices` entries: name|lang|uri|local|default.
155
+ *
156
+ * Network voices (Google's) only with `network`: they come with Chrome, not
157
+ * Chromium, so only a build whose product is Chrome claims them.
158
+ */
159
+ export declare function packVoices(voices: unknown, network?: boolean): string[] | null;
160
+ /** A WebCodecs codec string's prefix, as media::GetCodecName names the codec. */
161
+ export declare const CODEC_NAMES: Record<string, string>;
162
+ /**
163
+ * The receive formats Chrome's hardware decoder factory adds for a codec: H264
164
+ * High at the fixed level 3.1, and HEVC Main and Main 10 at the level of an
165
+ * 8K-capable decoder (what a recorded macOS Chrome reports).
166
+ */
167
+ export declare const RTC_DECODE_FORMATS: Record<string, string[]>;
168
+ /**
169
+ * The identity's hardware codecs, as the media:* keys.
170
+ *
171
+ * A decoder is the GPU's when the record decoded it with prefer-hardware. The
172
+ * hardware encoders are the sender formats software never offers (H264 High,
173
+ * H265). AAC is encoded by the OS on Windows and macOS. A record without the
174
+ * data claims nothing.
175
+ */
176
+ export declare function platformCodecs(fingerprint: Record<string, any>, targetOs: OsKey | null): Record<string, string[]>;
177
+ /**
178
+ * The WebGPU adapter of an fpgen record, as webGpu:* keys.
179
+ *
180
+ * The preferred canvas format is the OS's, so it is claimed from any record,
181
+ * including one of a machine that had no adapter (an empty list), except on a
182
+ * Linux identity: the browser is Chrome on Linux at its own milestone, and
183
+ * fpgen's Linux records predate the milestone that moved Linux to rgba8unorm.
184
+ * The adapter is claimed only from a record of the identity's GPU, which
185
+ * gpuInfo names in unmaskedRenderer.
186
+ */
187
+ export declare function webgpuAdapter(gpuInfo: unknown, renderer: unknown, targetOs: string | null | undefined): Record<string, unknown>;
188
+ /**
189
+ * The identity's installed families: the record's, with the OS's own, less
190
+ * any the bundle cannot render for that OS.
191
+ */
192
+ export declare function fontList(fonts: unknown, targetOs: OsKey): string[] | null;
193
+ /** Sets window.screenY based on the generated screenX value. */
194
+ export declare function handleScreenXY(camouwolfData: Config, fingerprint: Record<string, any>): void;
195
+ /** The OS key ('win', 'mac', 'lin') an fpgen fingerprint was recorded on. */
196
+ export declare function fingerprintOs(fingerprint: Record<string, any>): OsKey | null;
197
+ /**
198
+ * Converts an fpgen Chrome fingerprint to a Camouwolf config.
199
+ *
200
+ * `chromeVersion` is the Chromium milestone of the browser that will run; the
201
+ * recorded user agent is rewritten to it. `networkVoices` keeps the recorded
202
+ * network voices, for a build whose product is Chrome (packVoices).
203
+ */
204
+ export declare function fromFpgen(fingerprint: Record<string, any>, chromeVersion?: string | number | null, networkVoices?: boolean): Config;
205
+ /** Sets a custom outer window size and centers it in the screen (in place). */
206
+ export declare function handleWindowSize(fp: Record<string, any>, outerWidth: number, outerHeight: number): void;
207
+ export interface GenerateFingerprintOptions {
208
+ /** Outer window size [width, height], applied after generation. */
209
+ window?: readonly [number, number] | null;
210
+ /** A bound on the generated screen (best-effort, see below). */
211
+ screen?: Screen | null;
212
+ /** Camouwolf OS name(s): 'linux', 'macos', 'windows' (or lin/mac/win). */
213
+ os?: string | readonly string[] | null;
214
+ /** Any other fpgen conditions. */
215
+ [condition: string]: any;
216
+ }
217
+ /**
218
+ * Generates a Chrome fingerprint with fpgen (the model must be installed:
219
+ * `await ensureFpgenModel()`).
220
+ *
221
+ * `screen` bounds the generated screen; `window` overrides the outer window
222
+ * size afterwards. `os` is Camouwolf's name for the platform ('linux',
223
+ * 'macos', 'windows', or several); anything else is passed to fpgen as a
224
+ * condition.
225
+ */
226
+ export declare function generateFingerprint({ window, screen, os, ...conditions }?: GenerateFingerprintOptions): Record<string, any>;
227
+ export {};