ant0-browser 0.1.1 → 0.2.0-beta.2
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 +112 -4
- package/dist/canvas.d.ts +55 -0
- package/dist/canvas.d.ts.map +1 -0
- package/dist/canvas.js +82 -0
- package/dist/canvas.js.map +1 -0
- package/dist/chromium-version.d.ts +3 -3
- package/dist/chromium-version.js +3 -3
- package/dist/claim-hints.d.ts +36 -0
- package/dist/claim-hints.d.ts.map +1 -0
- package/dist/claim-hints.js +9 -0
- package/dist/claim-hints.js.map +1 -0
- package/dist/cleanup.d.ts +35 -0
- package/dist/cleanup.d.ts.map +1 -0
- package/dist/cleanup.js +106 -0
- package/dist/cleanup.js.map +1 -0
- package/dist/content.d.ts +11 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +52 -0
- package/dist/content.js.map +1 -0
- package/dist/download.d.ts +2 -0
- package/dist/download.d.ts.map +1 -1
- package/dist/download.js +14 -6
- package/dist/download.js.map +1 -1
- package/dist/errors.d.ts +49 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +53 -0
- package/dist/errors.js.map +1 -0
- package/dist/fingerprint.d.ts +42 -37
- package/dist/fingerprint.d.ts.map +1 -1
- package/dist/fingerprint.js +124 -24
- package/dist/fingerprint.js.map +1 -1
- package/dist/fontpack.d.ts.map +1 -1
- package/dist/fontpack.js +2 -1
- package/dist/fontpack.js.map +1 -1
- package/dist/fonts.js +1 -1
- package/dist/fonts.js.map +1 -1
- package/dist/geoip.d.ts.map +1 -1
- package/dist/geoip.js +3 -2
- package/dist/geoip.js.map +1 -1
- package/dist/geometry.d.ts +4 -0
- package/dist/geometry.d.ts.map +1 -1
- package/dist/geometry.js +9 -3
- package/dist/geometry.js.map +1 -1
- package/dist/identity-persistence.d.ts +38 -1
- package/dist/identity-persistence.d.ts.map +1 -1
- package/dist/identity-persistence.js +90 -10
- package/dist/identity-persistence.js.map +1 -1
- package/dist/identity.d.ts +41 -3
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +199 -26
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +69 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +415 -218
- package/dist/index.js.map +1 -1
- package/dist/launch-ticket.d.ts +109 -5
- package/dist/launch-ticket.d.ts.map +1 -1
- package/dist/launch-ticket.js +327 -11
- package/dist/launch-ticket.js.map +1 -1
- package/dist/launchopts.d.ts +181 -48
- package/dist/launchopts.d.ts.map +1 -1
- package/dist/launchopts.js +470 -51
- package/dist/launchopts.js.map +1 -1
- package/dist/native/linux-x64/PRODUCT-LICENSE.txt +28 -0
- package/dist/native/linux-x64/ant0_runtime.node +0 -0
- package/dist/native/windows-x64/PRODUCT-LICENSE.txt +28 -0
- package/dist/native/windows-x64/ant0_runtime.node +0 -0
- package/dist/persona-migration.d.ts +3 -0
- package/dist/persona-migration.d.ts.map +1 -1
- package/dist/persona-migration.js +2 -0
- package/dist/persona-migration.js.map +1 -1
- package/dist/persona-profile-v2.d.ts +15 -1
- package/dist/persona-profile-v2.d.ts.map +1 -1
- package/dist/persona-profile-v2.js +35 -2
- package/dist/persona-profile-v2.js.map +1 -1
- package/dist/persona-profile-v4.d.ts +61 -0
- package/dist/persona-profile-v4.d.ts.map +1 -0
- package/dist/persona-profile-v4.js +79 -0
- package/dist/persona-profile-v4.js.map +1 -0
- package/dist/persona-rejected.d.ts +36 -0
- package/dist/persona-rejected.d.ts.map +1 -0
- package/dist/persona-rejected.js +40 -0
- package/dist/persona-rejected.js.map +1 -0
- package/dist/population-model.d.ts +3 -0
- package/dist/population-model.d.ts.map +1 -1
- package/dist/population-model.js +24 -3
- package/dist/population-model.js.map +1 -1
- package/dist/profile-file.d.ts +201 -0
- package/dist/profile-file.d.ts.map +1 -0
- package/dist/profile-file.js +736 -0
- package/dist/profile-file.js.map +1 -0
- package/dist/release-fetch.d.ts +4 -0
- package/dist/release-fetch.d.ts.map +1 -1
- package/dist/release-fetch.js +3 -0
- package/dist/release-fetch.js.map +1 -1
- package/dist/render.js +2 -2
- package/dist/render.js.map +1 -1
- package/dist/runtime-client.d.ts +47 -0
- package/dist/runtime-client.d.ts.map +1 -0
- package/dist/runtime-client.js +327 -0
- package/dist/runtime-client.js.map +1 -0
- package/dist/runtime-launch.d.ts +22 -0
- package/dist/runtime-launch.d.ts.map +1 -0
- package/dist/runtime-launch.js +92 -0
- package/dist/runtime-launch.js.map +1 -0
- package/dist/scale.d.ts +29 -0
- package/dist/scale.d.ts.map +1 -0
- package/dist/scale.js +105 -0
- package/dist/scale.js.map +1 -0
- package/dist/shaderdialect.d.ts.map +1 -1
- package/dist/shaderdialect.js +2 -1
- package/dist/shaderdialect.js.map +1 -1
- package/dist/speech-coherence.d.ts +52 -0
- package/dist/speech-coherence.d.ts.map +1 -0
- package/dist/speech-coherence.js +254 -0
- package/dist/speech-coherence.js.map +1 -0
- package/dist/template-selection.d.ts.map +1 -1
- package/dist/template-selection.js +8 -7
- package/dist/template-selection.js.map +1 -1
- package/dist/warnings.d.ts +35 -4
- package/dist/warnings.d.ts.map +1 -1
- package/dist/warnings.js +139 -25
- package/dist/warnings.js.map +1 -1
- package/dist/webgl-coherence.d.ts +30 -0
- package/dist/webgl-coherence.d.ts.map +1 -0
- package/dist/webgl-coherence.js +98 -0
- package/dist/webgl-coherence.js.map +1 -0
- package/dist/webgpu-override.d.ts +14 -0
- package/dist/webgpu-override.d.ts.map +1 -0
- package/dist/webgpu-override.js +82 -0
- package/dist/webgpu-override.js.map +1 -0
- package/dist/widevine.d.ts.map +1 -1
- package/dist/widevine.js +11 -10
- package/dist/widevine.js.map +1 -1
- package/package.json +5 -5
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* SHA-256 counter DRBG and integer weighted sampling. The same identity key, device key, and model
|
|
6
6
|
* always produce the same profile; golden vectors prove parity with Python. */
|
|
7
7
|
import { type PersonaProfileV2 } from "./persona-profile-v2.js";
|
|
8
|
+
import type { ErrorClass } from "./errors.js";
|
|
8
9
|
export declare const GENERATE_ALGORITHM = "ant0/persona-generate/v1";
|
|
9
10
|
export declare const GENERATOR_NAME = "ant0-population-generator";
|
|
10
11
|
export declare const GENERATOR_VERSION = "1.0.0";
|
|
@@ -33,6 +34,8 @@ export interface PopulationModel {
|
|
|
33
34
|
}>;
|
|
34
35
|
}
|
|
35
36
|
export declare class PopulationModelError extends Error {
|
|
37
|
+
readonly code: string;
|
|
38
|
+
readonly errorClass: ErrorClass;
|
|
36
39
|
constructor(message: string);
|
|
37
40
|
}
|
|
38
41
|
/** Load and structurally validate a population model from a path, directory, or object. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"population-model.d.ts","sourceRoot":"","sources":["../src/population-model.ts"],"names":[],"mappings":"AAAA;;;;;+EAK+E;AAM/E,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"population-model.d.ts","sourceRoot":"","sources":["../src/population-model.ts"],"names":[],"mappings":"AAAA;;;;;+EAK+E;AAM/E,OAAO,EAA0B,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAC7D,eAAO,MAAM,cAAc,8BAA8B,CAAC;AAC1D,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAGzC,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,yEAA0E,CAAC;AAOxG,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;CAC9C;AACD,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;YAAE,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;IACzE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,oBAAoB,EAAE,CAAA;KAAE,CAAC,CAAC;CAC5D;AAED,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAkC;IACvD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAc;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAwGD,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe,GAAG,eAAe,CAyBrF;AASD,qFAAqF;AACrF,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,eAAe,GACrB,gBAAgB,CAwElB"}
|
package/dist/population-model.js
CHANGED
|
@@ -9,6 +9,8 @@ import { lstatSync, readFileSync } from "node:fs";
|
|
|
9
9
|
import { resolve } from "node:path";
|
|
10
10
|
import { CHROMIUM_MAJOR } from "./chromium-version.js";
|
|
11
11
|
import { assertPersonaProfileV2 } from "./persona-profile-v2.js";
|
|
12
|
+
import { SdkTypeError } from "./errors.js";
|
|
13
|
+
import { builtinSpeechVoices, speechValuesForLocale } from "./speech-coherence.js";
|
|
12
14
|
export const GENERATE_ALGORITHM = "ant0/persona-generate/v1";
|
|
13
15
|
export const GENERATOR_NAME = "ant0-population-generator";
|
|
14
16
|
export const GENERATOR_VERSION = "1.0.0";
|
|
@@ -21,6 +23,8 @@ const DISPLAY_VARIABLE_KEYS = [
|
|
|
21
23
|
"color_depth", "pixel_depth", "device_pixel_ratio",
|
|
22
24
|
];
|
|
23
25
|
export class PopulationModelError extends Error {
|
|
26
|
+
code = "sdk.population_model_invalid";
|
|
27
|
+
errorClass = "expected";
|
|
24
28
|
constructor(message) {
|
|
25
29
|
super(message);
|
|
26
30
|
this.name = "PopulationModelError";
|
|
@@ -28,7 +32,7 @@ export class PopulationModelError extends Error {
|
|
|
28
32
|
}
|
|
29
33
|
function keyBytes(value, name) {
|
|
30
34
|
if (typeof value !== "string")
|
|
31
|
-
throw new
|
|
35
|
+
throw new SdkTypeError("sdk.population_invalid", `${name} must be a string`);
|
|
32
36
|
for (let index = 0; index < value.length; index += 1) {
|
|
33
37
|
const unit = value.charCodeAt(index);
|
|
34
38
|
if (unit >= 0xd800 && unit <= 0xdbff) {
|
|
@@ -36,10 +40,10 @@ function keyBytes(value, name) {
|
|
|
36
40
|
if (next >= 0xdc00 && next <= 0xdfff)
|
|
37
41
|
index += 1;
|
|
38
42
|
else
|
|
39
|
-
throw new
|
|
43
|
+
throw new SdkTypeError("sdk.population_invalid", `${name} must contain only Unicode scalar values`);
|
|
40
44
|
}
|
|
41
45
|
else if (unit >= 0xdc00 && unit <= 0xdfff) {
|
|
42
|
-
throw new
|
|
46
|
+
throw new SdkTypeError("sdk.population_invalid", `${name} must contain only Unicode scalar values`);
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
return Buffer.from(value, "utf8");
|
|
@@ -175,6 +179,23 @@ export function generatePersonaProfile(identityKey, deviceKey, model) {
|
|
|
175
179
|
const chosen = {};
|
|
176
180
|
for (const group of GENERATION_ORDER) {
|
|
177
181
|
const values = [...model.groups[group].values].sort((left, right) => (left.id < right.id ? -1 : left.id > right.id ? 1 : 0));
|
|
182
|
+
if (group === "speech") {
|
|
183
|
+
// The speech group is independent of the other groups and holds captures of every language. Draw
|
|
184
|
+
// only from sets whose default voice is in the persona's language (constants.locale.primary_language);
|
|
185
|
+
// with none, use the engine's built-in Windows set, which the engine localises by Accept-Language.
|
|
186
|
+
// One draw either way, so the stream stays aligned.
|
|
187
|
+
const pool = speechValuesForLocale(values, constants.locale?.primary_language);
|
|
188
|
+
const picked = choose(pool.length ? pool : values, drbg);
|
|
189
|
+
if (pool.length) {
|
|
190
|
+
if (picked.support < kFloor)
|
|
191
|
+
throw new PopulationModelError(`group ${group} selected a value below k_floor`);
|
|
192
|
+
chosen[group] = structuredClone(picked.payload);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
chosen[group] = { voices: builtinSpeechVoices() };
|
|
196
|
+
}
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
178
199
|
const selected = choose(values, drbg);
|
|
179
200
|
if (selected.support < kFloor) {
|
|
180
201
|
throw new PopulationModelError(`group ${group} selected a value below k_floor`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"population-model.js","sourceRoot":"","sources":["../src/population-model.ts"],"names":[],"mappings":"AAAA;;;;;+EAK+E;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAyB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"population-model.js","sourceRoot":"","sources":["../src/population-model.ts"],"names":[],"mappings":"AAAA;;;;;+EAK+E;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAyB,MAAM,yBAAyB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AAO,GAAG;QACd,cAAc,EAAE,CAAC;QACjB,QAAQ,EAAE;YACR,MAAM,EAAE,WAAW;YACnB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,SAAS,EAAE;gBACT,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE,iBAAiB;gBAC1B,aAAa,EAAE,KAAK,CAAC,aAAa;aACnC;YACD,iBAAiB,EAAE,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC;SAClD;QACD,aAAa,EAAE;YACb,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ;YAC5C,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,cAAc;SAC1D;QACD,QAAQ,EAAE;YACR,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;YACjD,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;YACzC,kBAAkB,EAAE,SAAS,CAAC,kBAAkB;SACjD;QACD,OAAO,EAAE,EAAE,GAAG,eAAe,EAAE,GAAG,eAAe,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE;QAC9E,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC;QACzC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE;YACL,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,MAAM,CAAC;YACzC,OAAO,EAAE,eAAe,CAAC,SAAS,CAAC,OAAO,CAAC;SAC5C;KACF,CAAC;IACF,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAChC,OAAO,OAA2B,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport for schema 4 personas: a private file next to the browser profile.
|
|
3
|
+
*
|
|
4
|
+
* A schema 4 persona is far larger than the command line allows and must not sit in `ps` output, so
|
|
5
|
+
* it goes through `--fingerprint-profile-file=<absolute path>` and never inline. The file holds the
|
|
6
|
+
* same text the inline `--fingerprint-profile` switch carries today (gzip, then base64, of the
|
|
7
|
+
* persona's JSON; see `encodeProfile`). The engine reads it once, at startup.
|
|
8
|
+
*
|
|
9
|
+
* The SDK sends schema 4 only to an engine that says it can read it. `--ant0-sdk-info` reports
|
|
10
|
+
* `persona.schemas`; an engine that reports `sdk_protocol` 1, prints nothing, or cannot be run is
|
|
11
|
+
* taken to read `[2]` only. A schema 4 persona is then refused (`sdk.persona_requires_engine`);
|
|
12
|
+
* it is never converted down.
|
|
13
|
+
*
|
|
14
|
+
* Permissions. POSIX: the file is created with mode 0600 (owner read/write) through an exclusive
|
|
15
|
+
* temporary file in the same directory and `fchmod`ed (by handle) to 0600 again, then renamed over the target, so
|
|
16
|
+
* a reader sees the old or the new file, never a partial one. Windows: the same temporary-file and
|
|
17
|
+
* rename sequence, but the empty temporary file is restricted BEFORE any content is written: its
|
|
18
|
+
* inherited ACL is removed and replaced with a single entry that grants the current user (by SID,
|
|
19
|
+
* from `whoami /user`) full control (`icacls <file> /inheritance:r /grant:r *<SID>:F`). If that
|
|
20
|
+
* fails the write fails: the persona is never left readable by others. Known window: the empty file is
|
|
21
|
+
* created with the inherited ACL and restricted an instant later (Node cannot create it restricted); it holds
|
|
22
|
+
* nothing until the restriction has succeeded, but in that instant a principal that the inherited ACL lets read
|
|
23
|
+
* could open the empty file and keep its handle. The Python SDK has the same window. Closing it would need
|
|
24
|
+
* the security descriptor set at creation, or a private parent directory; neither is done.
|
|
25
|
+
*
|
|
26
|
+
* Probing the engine (`--ant0-sdk-info`) is asynchronous and bounded: a 5 s limit enforced with
|
|
27
|
+
* SIGKILL, a cap on the output, and the answer is taken when the process exits. The probe child gets
|
|
28
|
+
* the private probe directory as its TMPDIR/TMP/TEMP, so whatever an engine without the switch
|
|
29
|
+
* creates (a Chromium singleton socket, for one) is removed with it. A probe that ran to completion
|
|
30
|
+
* is cached by executable path, size and mtime; a completed old-engine answer (no schema 4) is
|
|
31
|
+
* cached for 10 minutes and a timeout for 30 s only, so an old engine does not cost 5 s per launch, a
|
|
32
|
+
* slow first run is retried soon, and a replaced or fixed engine is picked up. A spawn error is never cached.
|
|
33
|
+
* A binary without the Ant0 capability marker is never run: it has no persona support (a completed answer,
|
|
34
|
+
* cached like an old engine). The probe runs with a dead proxy (`--proxy-server=127.0.0.1:9`), and a probe child
|
|
35
|
+
* does not outlive the process (see `killLiveProbesSync` and `sweepStaleProbeDirs`).
|
|
36
|
+
*/
|
|
37
|
+
import { spawn } from "node:child_process";
|
|
38
|
+
import { type FingerprintOptions } from "./fingerprint.js";
|
|
39
|
+
export { PROFILE_FILE_SWITCH } from "./fingerprint.js";
|
|
40
|
+
/** Engine switch that prints the capability record. */
|
|
41
|
+
export declare const SDK_INFO_SWITCH = "--ant0-sdk-info";
|
|
42
|
+
/** File name inside the user data directory. */
|
|
43
|
+
export declare const PROFILE_FILE_NAME = "ant0-persona.profile";
|
|
44
|
+
/** The persona schema this module transports. */
|
|
45
|
+
export declare const PERSONA_SCHEMA_FILE = 4;
|
|
46
|
+
/** Limits of the `--ant0-sdk-info` probe. */
|
|
47
|
+
export declare const SDK_INFO_TIMEOUT_MS = 5000;
|
|
48
|
+
export declare const SDK_INFO_MAX_BYTES: number;
|
|
49
|
+
/** After the process exits, how long to wait for its stdout to close before using what was read. */
|
|
50
|
+
export declare const SDK_INFO_DRAIN_MS = 200;
|
|
51
|
+
/** Arguments that keep a probe of an engine without `--ant0-sdk-info` away from the user's profile and the
|
|
52
|
+
* network: a build that is not an Ant0 engine (Chrome for Testing, say) would otherwise start normally, reach
|
|
53
|
+
* out to the vendor and write to the real profile and certificate store within the 5 s. */
|
|
54
|
+
export declare const PROBE_DEAD_PROXY = "--proxy-server=127.0.0.1:9";
|
|
55
|
+
export declare const SDK_INFO_ISOLATION_ARGS: (userDataDir: string) => string[];
|
|
56
|
+
/** The probe child's environment: everything that points at a home or data directory is the probe dir, so a
|
|
57
|
+
* stock browser writes nothing under the real user's home (~/.config, ~/.local/share/pki, %APPDATA%). */
|
|
58
|
+
export declare function sdkInfoProbeEnv(probeDir: string, base?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
59
|
+
/** A fresh private probe directory with a short path: a long TMPDIR makes Chromium fail with "Socket path
|
|
60
|
+
* too long" (a unix socket path holds about 100 characters, and the profile's singleton socket lives in it). */
|
|
61
|
+
export declare const PROBE_DIR_MAX_LENGTH = 60;
|
|
62
|
+
/** Distinctive enough that no unrelated directory carries it; `mkdtemp` adds 6 characters of `[A-Za-z0-9]`, and a
|
|
63
|
+
* probe directory without a record is only recognised by exactly that shape. */
|
|
64
|
+
export declare const PROBE_DIR_PREFIX = "ant0sdk-probe-";
|
|
65
|
+
export declare function makeProbeDir(): string;
|
|
66
|
+
/** How long to wait for `taskkill /T` on Windows before going on. */
|
|
67
|
+
export declare const TASKKILL_BOUND_MS = 3000;
|
|
68
|
+
/**
|
|
69
|
+
* KNOWN LIMITATION (Windows, not verified on Windows): on the drain path the probe's leader has already
|
|
70
|
+
* exited (a descendant still holds the stdout pipe), so `taskkill /T /F /PID <leader>` names a process that is
|
|
71
|
+
* gone. `taskkill /T` walks the tree from a live process, so it may report "not found" and leave the orphaned
|
|
72
|
+
* descendant running; the pid may even have been reused. The probe dir is still removed (a still-open file in
|
|
73
|
+
* it can make that removal incomplete), and a later `sweepStaleProbeDirs` retries it. Needs a check on a
|
|
74
|
+
* Windows machine before the behaviour is relied on. POSIX is not affected: the group id outlives the leader.
|
|
75
|
+
* See docs/FINGERPRINT-MODES.md ("Known limitations").
|
|
76
|
+
*/
|
|
77
|
+
/** Stop the probe and everything it started. POSIX: the child leads its own process group, so the whole
|
|
78
|
+
* group gets SIGKILL (synchronous). Windows: `taskkill /T /F` takes the tree; the returned promise settles
|
|
79
|
+
* when it has finished or after `boundMs`, whichever is first. Best effort, never rejects. */
|
|
80
|
+
export declare function killProbeTree(child: ReturnType<typeof spawn>, boundMs?: number): Promise<void>;
|
|
81
|
+
/** A probe dir older than this belongs to a process that is gone (a probe lasts 5 s). */
|
|
82
|
+
export declare const STALE_PROBE_DIR_MS: number;
|
|
83
|
+
/** Remove probe directories (and kill the probe left in them) that an earlier SDK process abandoned when
|
|
84
|
+
* it was killed. Only our own `ant0sdk-probe-*` directories, owned by this user, older than
|
|
85
|
+
* `STALE_PROBE_DIR_MS`; one without a record (`.ant0-probe.json`) must also have exactly the shape `mkdtemp`
|
|
86
|
+
* produces, so an unrelated directory that merely starts with the prefix is never touched. Directories of earlier
|
|
87
|
+
* SDKs (`ant0-probe-*`) are NOT swept, record or not: they are left to the OS temp sweeper. Best effort,
|
|
88
|
+
* never throws; returns the directories removed. `roots`, `now` and `uid` exist for tests. */
|
|
89
|
+
export declare function sweepStaleProbeDirs(roots?: string[], now?: number, uid?: number | undefined): string[];
|
|
90
|
+
export interface SdkInfoProbeResult {
|
|
91
|
+
/** The process ran to completion by itself: false after a timeout, a spawn error or too much output. */
|
|
92
|
+
completed: boolean;
|
|
93
|
+
/** The probe was stopped for running too long or printing too much (not a spawn error). */
|
|
94
|
+
timedOut?: boolean;
|
|
95
|
+
/** The binary is not an Ant0 engine (no capability marker), so it was not run at all. */
|
|
96
|
+
notAnt0?: boolean;
|
|
97
|
+
/** What it printed; empty unless it completed with exit code 0. */
|
|
98
|
+
stdout: string;
|
|
99
|
+
}
|
|
100
|
+
export type SdkInfoProbe = (executable: string) => Promise<SdkInfoProbeResult>;
|
|
101
|
+
/** Run `executable --ant0-sdk-info` without blocking the event loop. Never rejects. */
|
|
102
|
+
export declare function probeSdkInfo(executable: string, limits?: {
|
|
103
|
+
timeoutMs?: number;
|
|
104
|
+
maxBytes?: number;
|
|
105
|
+
drainMs?: number;
|
|
106
|
+
requireAnt0?: boolean;
|
|
107
|
+
}): Promise<SdkInfoProbeResult>;
|
|
108
|
+
/** What `--ant0-sdk-info` says about persona support (the `persona` member of protocol 2). Every field
|
|
109
|
+
* but `schemas` is absent when the engine does not say; unknown extra fields are ignored. */
|
|
110
|
+
export interface EnginePersonaInfo {
|
|
111
|
+
schemas: number[];
|
|
112
|
+
revision?: number;
|
|
113
|
+
engineFamily?: string;
|
|
114
|
+
engineMajor?: number;
|
|
115
|
+
os?: string[];
|
|
116
|
+
arch?: string[];
|
|
117
|
+
brands?: string[];
|
|
118
|
+
/** The capability ids the engine serves from a schema 4 persona; undefined when not advertised. */
|
|
119
|
+
capabilities?: string[];
|
|
120
|
+
}
|
|
121
|
+
/** How long a completed old-engine answer is remembered. A schema 4 answer is kept for good (it is keyed
|
|
122
|
+
* by size and mtime, so a replaced binary is probed again). */
|
|
123
|
+
export declare const OLD_ENGINE_CACHE_MS: number;
|
|
124
|
+
/** How long a timed-out probe is remembered. Short, because a just-installed engine can be slow on its
|
|
125
|
+
* first run (cold disk, antivirus) and must not be treated as old for long. */
|
|
126
|
+
export declare const PROBE_TIMEOUT_CACHE_MS: number;
|
|
127
|
+
/** What the engine at `executable` says about persona support. Never throws: unknown means schemas
|
|
128
|
+
* `[2]` and nothing else. The answer is cached per executable path, size and modification time: an
|
|
129
|
+
* engine that serves schema 4 for good, a completed old-engine answer for `OLD_ENGINE_CACHE_MS`, a
|
|
130
|
+
* timeout for `PROBE_TIMEOUT_CACHE_MS`. A spawn error is not cached and is retried on the next call. `now` exists for tests. */
|
|
131
|
+
export declare function enginePersonaInfo(executable: string, probe?: SdkInfoProbe, now?: () => number): Promise<EnginePersonaInfo>;
|
|
132
|
+
/** Persona schemas the engine at `executable` can load. Never throws: unknown means `[2]`. */
|
|
133
|
+
export declare function enginePersonaSchemas(executable: string, probe?: SdkInfoProbe, now?: () => number): Promise<number[]>;
|
|
134
|
+
/** Test hook: forget every cached probe answer. */
|
|
135
|
+
export declare function resetEngineProbeCache(): void;
|
|
136
|
+
/** Read the persona member out of `--ant0-sdk-info` output. Protocol 1 or a missing `persona` block
|
|
137
|
+
* means schemas `[2]` and nothing else. The record is one JSON object: the whole trimmed output, else
|
|
138
|
+
* the last line that is a complete JSON object (an engine may print a banner first). `sdk_protocol`
|
|
139
|
+
* and the numbers must be integers; a string such as "2" does not count. Unknown fields are ignored. */
|
|
140
|
+
export declare function parseSdkInfo(output: string): EnginePersonaInfo;
|
|
141
|
+
/** Read the accepted persona schemas out of `--ant0-sdk-info` output (see `parseSdkInfo`). */
|
|
142
|
+
export declare function parseSdkInfoSchemas(output: string): number[];
|
|
143
|
+
/** Throw `sdk.persona_requires_engine` unless the engine at `executable` can load schema 4. Returns
|
|
144
|
+
* what the engine said, for the checks that follow. */
|
|
145
|
+
export declare function assertEngineAcceptsSchema4(executable: string, probe?: SdkInfoProbe): Promise<EnginePersonaInfo>;
|
|
146
|
+
/** Throw `sdk.persona_capability_missing` unless the engine serves every id the persona `requires`.
|
|
147
|
+
* An engine that takes schema 4 but lists no capabilities cannot be checked and is refused too: it
|
|
148
|
+
* would otherwise run without the profile and say so only in a log line. */
|
|
149
|
+
export declare function assertEngineServesRequires(requires: readonly string[], info: EnginePersonaInfo): void;
|
|
150
|
+
/** The engine refuses a persona file larger than this (patch 937). */
|
|
151
|
+
export declare const PERSONA_FILE_MAX_BYTES: number;
|
|
152
|
+
/** Throw `sdk.persona_too_large` when the encoded persona would not be accepted from a file. */
|
|
153
|
+
export declare function assertPersonaFileSize(text: string): void;
|
|
154
|
+
/** A notice for the caller to print (respecting quiet): a persona that works but not as written. */
|
|
155
|
+
export interface PersonaNotice {
|
|
156
|
+
code: string;
|
|
157
|
+
message: string;
|
|
158
|
+
}
|
|
159
|
+
/** Code and text of the brand-version warning (same in the Python SDK). */
|
|
160
|
+
export declare const BRAND_VERSION_MAJOR_CODE = "persona-brand-version-major";
|
|
161
|
+
export declare function brandVersionNotice(profile: unknown, info: EnginePersonaInfo): PersonaNotice | undefined;
|
|
162
|
+
/** Runs one command and resolves with its stdout; rejects when it cannot run or exits non-zero.
|
|
163
|
+
* Injected in tests; the default uses execFile with an argument array (no shell). */
|
|
164
|
+
export type CommandRunner = (file: string, args: string[]) => Promise<string>;
|
|
165
|
+
/** The current user's SID from `whoami /user /fo csv /nh` (one line: "DOMAIN\\user","S-1-5-..."). */
|
|
166
|
+
export declare function currentUserSid(run?: CommandRunner): Promise<string>;
|
|
167
|
+
/** Remove inherited access from `path` and grant the current user, by SID, full control. */
|
|
168
|
+
export declare function restrictToCurrentUserWindows(path: string, run?: CommandRunner): Promise<void>;
|
|
169
|
+
/** Write a schema 4 persona to `<userDataDir>/ant0-persona.profile` and return its absolute path.
|
|
170
|
+
* `run` and `platform` exist for tests. */
|
|
171
|
+
export declare function writePersonaProfileFile(userDataDir: string, profile: unknown, run?: CommandRunner, platform?: string): Promise<string>;
|
|
172
|
+
/** Remove a stale `ant0-persona.profile` from `userDataDir`: only that exact name, and a symlink is
|
|
173
|
+
* unlinked itself, never followed. Best effort; returns whether something was removed. */
|
|
174
|
+
export declare function removeStalePersonaFile(userDataDir: string): boolean;
|
|
175
|
+
export interface StagedPersona {
|
|
176
|
+
/** Things worth telling the user about this persona and engine; print them with `emitPersonaNotices`. */
|
|
177
|
+
notices: PersonaNotice[];
|
|
178
|
+
/** The options to hand to `fingerprintArgs`: for schema 4, `fingerprintProfileFile` is set. */
|
|
179
|
+
fingerprint: FingerprintOptions;
|
|
180
|
+
/** Remove the temporary directory created for the file, if any. Safe to call twice. */
|
|
181
|
+
cleanup(): void;
|
|
182
|
+
/** Delete the persona file itself, wherever it is (also in a profile directory the caller keeps). The
|
|
183
|
+
* engine reads it once at startup, so call this once the browser is up, or when the launch failed.
|
|
184
|
+
* Safe to call twice and when no file was written. */
|
|
185
|
+
removeFile(): void;
|
|
186
|
+
}
|
|
187
|
+
/** Throw unless the engine at `executable` can load the persona and serves what it requires (a schema 2 or
|
|
188
|
+
* absent persona passes). For the binary a launch plan actually spawns when it is not the one staged for. */
|
|
189
|
+
export declare function assertPersonaFitsEngine(profile: unknown, executable: string, probe?: SdkInfoProbe): Promise<void>;
|
|
190
|
+
/** Prepare the persona transport for one launch. A schema 2 or absent persona is returned
|
|
191
|
+
* untouched, and a stale persona file in `userDataDir` is removed. A schema 4 persona is checked
|
|
192
|
+
* against the engine and written to a private file in `userDataDir`, or, when the launch has no
|
|
193
|
+
* profile directory of its own (an incognito launch), in a private temporary directory that
|
|
194
|
+
* `cleanup()` removes (an empty `userDataDir` counts as none; callers run it when the browser closes; a process-exit handler is the
|
|
195
|
+
* fallback). */
|
|
196
|
+
export declare function stagePersonaProfile(fingerprint: FingerprintOptions, executable: string, userDataDir?: string, deps?: {
|
|
197
|
+
probe?: SdkInfoProbe;
|
|
198
|
+
run?: CommandRunner;
|
|
199
|
+
platform?: string;
|
|
200
|
+
}): Promise<StagedPersona>;
|
|
201
|
+
//# sourceMappingURL=profile-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile-file.d.ts","sourceRoot":"","sources":["../src/profile-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,OAAO,EAA0B,KAAK,EAAa,MAAM,oBAAoB,CAAC;AAU9E,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,uDAAuD;AACvD,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,gDAAgD;AAChD,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AACxD,iDAAiD;AACjD,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,OAAO,CAAC;AACxC,eAAO,MAAM,kBAAkB,QAAU,CAAC;AAC1C,oGAAoG;AACpG,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC;;2FAE2F;AAC3F,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAC7D,eAAO,MAAM,uBAAuB,GAAI,aAAa,MAAM,KAAG,MAAM,EAKnE,CAAC;AAEF;yGACyG;AACzG,wB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