ant0-browser 0.0.0-stage → 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/LICENSE +35 -0
- package/README.md +208 -2
- 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 +22 -0
- package/dist/chromium-version.d.ts.map +1 -0
- package/dist/chromium-version.js +22 -0
- package/dist/chromium-version.js.map +1 -0
- 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 +24 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +227 -0
- package/dist/download.js.map +1 -0
- 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 +218 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +475 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/fontpack.d.ts +13 -0
- package/dist/fontpack.d.ts.map +1 -0
- package/dist/fontpack.js +150 -0
- package/dist/fontpack.js.map +1 -0
- package/dist/fonts.d.ts +15 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +86 -0
- package/dist/fonts.js.map +1 -0
- package/dist/geoip.d.ts +45 -0
- package/dist/geoip.d.ts.map +1 -0
- package/dist/geoip.js +290 -0
- package/dist/geoip.js.map +1 -0
- package/dist/geometry.d.ts +32 -0
- package/dist/geometry.d.ts.map +1 -0
- package/dist/geometry.js +85 -0
- package/dist/geometry.js.map +1 -0
- package/dist/humanize.d.ts +20 -0
- package/dist/humanize.d.ts.map +1 -0
- package/dist/humanize.js +921 -0
- package/dist/humanize.js.map +1 -0
- package/dist/identity-persistence.d.ts +88 -0
- package/dist/identity-persistence.d.ts.map +1 -0
- package/dist/identity-persistence.js +381 -0
- package/dist/identity-persistence.js.map +1 -0
- package/dist/identity.d.ts +81 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +370 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +281 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +790 -0
- package/dist/index.js.map +1 -0
- package/dist/launch-ticket.d.ts +191 -0
- package/dist/launch-ticket.d.ts.map +1 -0
- package/dist/launch-ticket.js +549 -0
- package/dist/launch-ticket.js.map +1 -0
- package/dist/launchopts.d.ts +266 -0
- package/dist/launchopts.d.ts.map +1 -0
- package/dist/launchopts.js +623 -0
- package/dist/launchopts.js.map +1 -0
- package/dist/motion.d.ts +106 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +311 -0
- package/dist/motion.js.map +1 -0
- package/dist/motionscore.d.ts +57 -0
- package/dist/motionscore.d.ts.map +1 -0
- package/dist/motionscore.js +215 -0
- package/dist/motionscore.js.map +1 -0
- 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 +54 -0
- package/dist/persona-migration.d.ts.map +1 -0
- package/dist/persona-migration.js +97 -0
- package/dist/persona-migration.js.map +1 -0
- package/dist/persona-profile-v2.d.ts +169 -0
- package/dist/persona-profile-v2.d.ts.map +1 -0
- package/dist/persona-profile-v2.js +454 -0
- package/dist/persona-profile-v2.js.map +1 -0
- 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 +45 -0
- package/dist/population-model.d.ts.map +1 -0
- package/dist/population-model.js +245 -0
- package/dist/population-model.js.map +1 -0
- 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 +74 -0
- package/dist/release-fetch.d.ts.map +1 -0
- package/dist/release-fetch.js +395 -0
- package/dist/release-fetch.js.map +1 -0
- package/dist/release.d.ts +16 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +26 -0
- package/dist/release.js.map +1 -0
- package/dist/render.d.ts +38 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +104 -0
- package/dist/render.js.map +1 -0
- 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 +33 -0
- package/dist/shaderdialect.d.ts.map +1 -0
- package/dist/shaderdialect.js +47 -0
- package/dist/shaderdialect.js.map +1 -0
- 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 +14 -0
- package/dist/template-selection.d.ts.map +1 -0
- package/dist/template-selection.js +66 -0
- package/dist/template-selection.js.map +1 -0
- package/dist/warnings.d.ts +50 -0
- package/dist/warnings.d.ts.map +1 -0
- package/dist/warnings.js +273 -0
- package/dist/warnings.js.map +1 -0
- 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 +44 -0
- package/dist/widevine.d.ts.map +1 -0
- package/dist/widevine.js +203 -0
- package/dist/widevine.js.map +1 -0
- package/package.json +56 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona-profile-v4.js","sourceRoot":"","sources":["../src/persona-profile-v4.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAyB5C,2EAA2E;AAC3E,MAAM,OAAO,oBAAqB,SAAQ,aAAa;IAChC;IAArB,YAAqB,QAAkB;QACrC,KAAK,CAAC,6BAA6B,EACjC,+DAA+D,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAFrE,aAAQ,GAAR,QAAQ,CAAU;QAGrC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAgC,EAAE,CAC5D,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAE3D,qFAAqF;AACrF,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,cAAc,KAAK,CAAC,CAAC;AACvD,CAAC;AAED,gFA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AAoC,CAAC,CAAC;IAC5G,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QAAE,QAAQ,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAC3E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,IAAI,oBAAoB,CAAC,QAAQ,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine refuses a persona file it cannot use (engine patch 937, fail-closed).
|
|
3
|
+
*
|
|
4
|
+
* When `--fingerprint-profile-file` names a file that is missing, unreadable or rejected, the browser
|
|
5
|
+
* process exits with code 91 before any profile directory, window or network activity, after writing one
|
|
6
|
+
* line to stderr:
|
|
7
|
+
*
|
|
8
|
+
* fatal: --fingerprint-profile-file: <reason>
|
|
9
|
+
*
|
|
10
|
+
* The reason is printable ASCII, at most 200 characters, and never carries a path or profile data. The
|
|
11
|
+
* SDK throws it as {@link PersonaFileRejectedError} (`code: "sdk.persona_file_rejected"`). Exit code 90 is
|
|
12
|
+
* the launch ticket's (see `launch-ticket.ts`); Chromium's own codes stay below 43.
|
|
13
|
+
*/
|
|
14
|
+
import type { ErrorClass } from "./errors.js";
|
|
15
|
+
/** Exit code of an engine that refused its persona file. */
|
|
16
|
+
export declare const PERSONA_FILE_EXIT_CODE = 91;
|
|
17
|
+
/** Error code carried by {@link PersonaFileRejectedError}. */
|
|
18
|
+
export declare const PERSONA_FILE_REJECTED_CODE = "sdk.persona_file_rejected";
|
|
19
|
+
/** The longest reason the engine prints, and the longest the SDK keeps. */
|
|
20
|
+
export declare const REASON_MAX_LENGTH = 200;
|
|
21
|
+
/** Printable ASCII only (anything else is dropped), trimmed, at most {@link REASON_MAX_LENGTH} characters. */
|
|
22
|
+
export declare function sanitizeReason(text: unknown): string;
|
|
23
|
+
/** The engine exited with code 91: its persona file was missing, unreadable or rejected. */
|
|
24
|
+
export declare class PersonaFileRejectedError extends Error {
|
|
25
|
+
readonly code = "sdk.persona_file_rejected";
|
|
26
|
+
readonly errorClass: ErrorClass;
|
|
27
|
+
/** The engine's reason, sanitised (printable ASCII, at most 200 characters). */
|
|
28
|
+
readonly reason: string;
|
|
29
|
+
constructor(reason: string);
|
|
30
|
+
}
|
|
31
|
+
/** The exit code Playwright quotes in a launch failure (`process did exit: exitCode=N`), if any. */
|
|
32
|
+
export declare function playwrightExitCode(text: string | undefined | null): number | undefined;
|
|
33
|
+
/** The engine's (sanitised) reason if `text` carries the fatal line, `"unspecified"` if only exit code 91 is
|
|
34
|
+
* known, else undefined. `exitCode` is the process exit code when the caller has it. */
|
|
35
|
+
export declare function personaFileRejection(text: string | undefined | null, exitCode?: number | null): string | undefined;
|
|
36
|
+
//# sourceMappingURL=persona-rejected.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona-rejected.d.ts","sourceRoot":"","sources":["../src/persona-rejected.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,KAAK,CAAC;AACzC,8DAA8D;AAC9D,eAAO,MAAM,0BAA0B,8BAA8B,CAAC;AACtE,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAMrC,8GAA8G;AAC9G,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED,4FAA4F;AAC5F,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,IAAI,+BAA8B;IAC3C,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAc;IAC7C,gFAAgF;IAChF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM;CAM3B;AAED,oGAAoG;AACpG,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAGtF;AAED;wFACwF;AACxF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAIlH"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Exit code of an engine that refused its persona file. */
|
|
2
|
+
export const PERSONA_FILE_EXIT_CODE = 91;
|
|
3
|
+
/** Error code carried by {@link PersonaFileRejectedError}. */
|
|
4
|
+
export const PERSONA_FILE_REJECTED_CODE = "sdk.persona_file_rejected";
|
|
5
|
+
/** The longest reason the engine prints, and the longest the SDK keeps. */
|
|
6
|
+
export const REASON_MAX_LENGTH = 200;
|
|
7
|
+
// Raw stderr has the line at the start; Playwright quotes it in its message behind a "[pid=N][err] " prefix.
|
|
8
|
+
const FATAL_LINE = /^(?:\[pid=\d+\]\[err\] ?)?fatal: --fingerprint-profile-file: ([^\r\n]*)$/m;
|
|
9
|
+
const EXIT_CODE = /process did exit: exitCode=(\d+)/;
|
|
10
|
+
/** Printable ASCII only (anything else is dropped), trimmed, at most {@link REASON_MAX_LENGTH} characters. */
|
|
11
|
+
export function sanitizeReason(text) {
|
|
12
|
+
return String(text).replace(/[^\x20-\x7e]/g, "").trim().slice(0, REASON_MAX_LENGTH).trimEnd();
|
|
13
|
+
}
|
|
14
|
+
/** The engine exited with code 91: its persona file was missing, unreadable or rejected. */
|
|
15
|
+
export class PersonaFileRejectedError extends Error {
|
|
16
|
+
code = PERSONA_FILE_REJECTED_CODE;
|
|
17
|
+
errorClass = "expected";
|
|
18
|
+
/** The engine's reason, sanitised (printable ASCII, at most 200 characters). */
|
|
19
|
+
reason;
|
|
20
|
+
constructor(reason) {
|
|
21
|
+
const clean = sanitizeReason(reason) || "unspecified";
|
|
22
|
+
super(`ant0-browser: the engine rejected the persona file (${clean}).`);
|
|
23
|
+
this.name = "PersonaFileRejectedError";
|
|
24
|
+
this.reason = clean;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** The exit code Playwright quotes in a launch failure (`process did exit: exitCode=N`), if any. */
|
|
28
|
+
export function playwrightExitCode(text) {
|
|
29
|
+
const m = EXIT_CODE.exec(text ?? "");
|
|
30
|
+
return m ? Number(m[1]) : undefined;
|
|
31
|
+
}
|
|
32
|
+
/** The engine's (sanitised) reason if `text` carries the fatal line, `"unspecified"` if only exit code 91 is
|
|
33
|
+
* known, else undefined. `exitCode` is the process exit code when the caller has it. */
|
|
34
|
+
export function personaFileRejection(text, exitCode) {
|
|
35
|
+
const m = FATAL_LINE.exec(text ?? "");
|
|
36
|
+
if (m)
|
|
37
|
+
return sanitizeReason(m[1]) || "unspecified";
|
|
38
|
+
return exitCode === PERSONA_FILE_EXIT_CODE ? "unspecified" : undefined;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=persona-rejected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persona-rejected.js","sourceRoot":"","sources":["../src/persona-rejected.ts"],"names":[],"mappings":"AAeA,4DAA4D;AAC5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AACzC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,0BAA0B,GAAG,2BAA2B,CAAC;AACtE,2EAA2E;AAC3E,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAErC,6GAA6G;AAC7G,MAAM,UAAU,GAAG,2EAA2E,CAAC;AAC/F,MAAM,SAAS,GAAG,kCAAkC,CAAC;AAErD,8GAA8G;AAC9G,MAAM,UAAU,cAAc,CAAC,IAAa;IAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,OAAO,EAAE,CAAC;AAChG,CAAC;AAED,4FAA4F;AAC5F,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACxC,IAAI,GAAG,0BAA0B,CAAC;IAClC,UAAU,GAAe,UAAU,CAAC;IAC7C,gFAAgF;IACvE,MAAM,CAAS;IACxB,YAAY,MAAc;QACxB,MAAM,KAAK,GAAG,cAAc,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC;QACtD,KAAK,CAAC,uDAAuD,KAAK,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;CACF;AAED,oGAAoG;AACpG,MAAM,UAAU,kBAAkB,CAAC,IAA+B;IAChE,MAAM,CAAC,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC;AAED;wFACwF;AACxF,MAAM,UAAU,oBAAoB,CAAC,IAA+B,EAAE,QAAwB;IAC5F,MAAM,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IACtC,IAAI,CAAC;QAAE,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC;IACpD,OAAO,QAAQ,KAAK,sBAAsB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Deterministic population-model generator for synthetic mode (ant0/persona-generate/v1).
|
|
2
|
+
*
|
|
3
|
+
* Byte-for-byte identical to the Python reference in sdk/python/ant0browser/population_model.py.
|
|
4
|
+
* Recombines validated real hardware bundles into an ordinary-looking persona-profile-v2 using a
|
|
5
|
+
* SHA-256 counter DRBG and integer weighted sampling. The same identity key, device key, and model
|
|
6
|
+
* always produce the same profile; golden vectors prove parity with Python. */
|
|
7
|
+
import { type PersonaProfileV2 } from "./persona-profile-v2.js";
|
|
8
|
+
import type { ErrorClass } from "./errors.js";
|
|
9
|
+
export declare const GENERATE_ALGORITHM = "ant0/persona-generate/v1";
|
|
10
|
+
export declare const GENERATOR_NAME = "ant0-population-generator";
|
|
11
|
+
export declare const GENERATOR_VERSION = "1.0.0";
|
|
12
|
+
/** Fixed sampling order; each group is drawn exactly once. */
|
|
13
|
+
export declare const GENERATION_ORDER: readonly ["graphics", "cpu_mem", "display", "audio", "fonts", "speech"];
|
|
14
|
+
export interface PopulationModelValue {
|
|
15
|
+
id: string;
|
|
16
|
+
support: number;
|
|
17
|
+
weight: number;
|
|
18
|
+
payload: Record<string, unknown> | unknown[];
|
|
19
|
+
}
|
|
20
|
+
export interface PopulationModel {
|
|
21
|
+
model_version: string;
|
|
22
|
+
generate_algorithm: string;
|
|
23
|
+
created_at: string;
|
|
24
|
+
k_floor: number;
|
|
25
|
+
source: {
|
|
26
|
+
revision?: string;
|
|
27
|
+
files: Record<string, {
|
|
28
|
+
sha256: string;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
constants: Record<string, any>;
|
|
32
|
+
groups: Record<string, {
|
|
33
|
+
values: PopulationModelValue[];
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
export declare class PopulationModelError extends Error {
|
|
37
|
+
readonly code: string;
|
|
38
|
+
readonly errorClass: ErrorClass;
|
|
39
|
+
constructor(message: string);
|
|
40
|
+
}
|
|
41
|
+
/** Load and structurally validate a population model from a path, directory, or object. */
|
|
42
|
+
export declare function loadPopulationModel(source: string | PopulationModel): PopulationModel;
|
|
43
|
+
/** Deterministically generate and validate one persona-profile-v2 from the model. */
|
|
44
|
+
export declare function generatePersonaProfile(identityKey: string, deviceKey: string, model: PopulationModel): PersonaProfileV2;
|
|
45
|
+
//# sourceMappingURL=population-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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B,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"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/** Deterministic population-model generator for synthetic mode (ant0/persona-generate/v1).
|
|
2
|
+
*
|
|
3
|
+
* Byte-for-byte identical to the Python reference in sdk/python/ant0browser/population_model.py.
|
|
4
|
+
* Recombines validated real hardware bundles into an ordinary-looking persona-profile-v2 using a
|
|
5
|
+
* SHA-256 counter DRBG and integer weighted sampling. The same identity key, device key, and model
|
|
6
|
+
* always produce the same profile; golden vectors prove parity with Python. */
|
|
7
|
+
import { createHash } from "node:crypto";
|
|
8
|
+
import { lstatSync, readFileSync } from "node:fs";
|
|
9
|
+
import { resolve } from "node:path";
|
|
10
|
+
import { CHROMIUM_MAJOR } from "./chromium-version.js";
|
|
11
|
+
import { assertPersonaProfileV2 } from "./persona-profile-v2.js";
|
|
12
|
+
import { SdkTypeError } from "./errors.js";
|
|
13
|
+
import { builtinSpeechVoices, speechValuesForLocale } from "./speech-coherence.js";
|
|
14
|
+
export const GENERATE_ALGORITHM = "ant0/persona-generate/v1";
|
|
15
|
+
export const GENERATOR_NAME = "ant0-population-generator";
|
|
16
|
+
export const GENERATOR_VERSION = "1.0.0";
|
|
17
|
+
const DOMAIN = Buffer.from("ant0/persona-generate/v1\0", "ascii");
|
|
18
|
+
/** Fixed sampling order; each group is drawn exactly once. */
|
|
19
|
+
export const GENERATION_ORDER = ["graphics", "cpu_mem", "display", "audio", "fonts", "speech"];
|
|
20
|
+
const CONSTANT_KEYS = ["js_heap_size_limit", "desktop_display", "codecs", "devices", "locale"];
|
|
21
|
+
const DISPLAY_VARIABLE_KEYS = [
|
|
22
|
+
"width", "height", "available_width", "available_height",
|
|
23
|
+
"color_depth", "pixel_depth", "device_pixel_ratio",
|
|
24
|
+
];
|
|
25
|
+
export class PopulationModelError extends Error {
|
|
26
|
+
code = "sdk.population_model_invalid";
|
|
27
|
+
errorClass = "expected";
|
|
28
|
+
constructor(message) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.name = "PopulationModelError";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function keyBytes(value, name) {
|
|
34
|
+
if (typeof value !== "string")
|
|
35
|
+
throw new SdkTypeError("sdk.population_invalid", `${name} must be a string`);
|
|
36
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
37
|
+
const unit = value.charCodeAt(index);
|
|
38
|
+
if (unit >= 0xd800 && unit <= 0xdbff) {
|
|
39
|
+
const next = value.charCodeAt(index + 1);
|
|
40
|
+
if (next >= 0xdc00 && next <= 0xdfff)
|
|
41
|
+
index += 1;
|
|
42
|
+
else
|
|
43
|
+
throw new SdkTypeError("sdk.population_invalid", `${name} must contain only Unicode scalar values`);
|
|
44
|
+
}
|
|
45
|
+
else if (unit >= 0xdc00 && unit <= 0xdfff) {
|
|
46
|
+
throw new SdkTypeError("sdk.population_invalid", `${name} must contain only Unicode scalar values`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return Buffer.from(value, "utf8");
|
|
50
|
+
}
|
|
51
|
+
function u64be(value) {
|
|
52
|
+
const out = Buffer.alloc(8);
|
|
53
|
+
out.writeBigUInt64BE(BigInt(value));
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function frame(value) {
|
|
57
|
+
return Buffer.concat([u64be(value.length), value]);
|
|
58
|
+
}
|
|
59
|
+
function seed(identityKey, deviceKey, modelVersion) {
|
|
60
|
+
return createHash("sha256")
|
|
61
|
+
.update(DOMAIN)
|
|
62
|
+
.update(frame(keyBytes(identityKey, "identityKey")))
|
|
63
|
+
.update(frame(keyBytes(deviceKey, "deviceKey")))
|
|
64
|
+
.update(frame(Buffer.from(modelVersion, "utf8")))
|
|
65
|
+
.digest();
|
|
66
|
+
}
|
|
67
|
+
/** SHA-256 counter DRBG: block i is SHA256(seed || u64be(i)); bytes are drawn in order. */
|
|
68
|
+
class Drbg {
|
|
69
|
+
seed;
|
|
70
|
+
counter = 0;
|
|
71
|
+
buffer = Buffer.alloc(0);
|
|
72
|
+
offset = 0;
|
|
73
|
+
constructor(seedBytes) {
|
|
74
|
+
this.seed = seedBytes;
|
|
75
|
+
}
|
|
76
|
+
drawU64() {
|
|
77
|
+
while (this.buffer.length - this.offset < 8) {
|
|
78
|
+
const block = createHash("sha256").update(this.seed).update(u64be(this.counter)).digest();
|
|
79
|
+
this.counter += 1;
|
|
80
|
+
this.buffer = Buffer.concat([this.buffer, block]);
|
|
81
|
+
}
|
|
82
|
+
const value = this.buffer.readBigUInt64BE(this.offset);
|
|
83
|
+
this.offset += 8;
|
|
84
|
+
return value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function choose(values, drbg) {
|
|
88
|
+
let total = 0n;
|
|
89
|
+
for (const value of values)
|
|
90
|
+
total += BigInt(value.weight);
|
|
91
|
+
const target = drbg.drawU64() % total;
|
|
92
|
+
let cumulative = 0n;
|
|
93
|
+
for (const value of values) {
|
|
94
|
+
cumulative += BigInt(value.weight);
|
|
95
|
+
if (target < cumulative)
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
return values[values.length - 1];
|
|
99
|
+
}
|
|
100
|
+
function ensure(condition, message) {
|
|
101
|
+
if (!condition)
|
|
102
|
+
throw new PopulationModelError(message);
|
|
103
|
+
}
|
|
104
|
+
function validateModel(model) {
|
|
105
|
+
ensure(typeof model === "object" && model !== null && !Array.isArray(model), "model must be an object");
|
|
106
|
+
const m = model;
|
|
107
|
+
ensure(m.generate_algorithm === GENERATE_ALGORITHM, "unsupported generate_algorithm");
|
|
108
|
+
ensure(typeof m.model_version === "string" && m.model_version, "model_version must be a nonempty string");
|
|
109
|
+
ensure(typeof m.created_at === "string" && m.created_at, "created_at must be a nonempty string");
|
|
110
|
+
ensure(Number.isInteger(m.k_floor) && m.k_floor >= 1, "k_floor must be >= 1");
|
|
111
|
+
ensure(typeof m.constants === "object" && m.constants !== null
|
|
112
|
+
&& CONSTANT_KEYS.every((key) => key in m.constants), "constants are incomplete");
|
|
113
|
+
ensure(typeof m.source === "object" && m.source !== null
|
|
114
|
+
&& typeof m.source.files === "object" && m.source.files !== null, "source provenance is incomplete");
|
|
115
|
+
ensure(typeof m.groups === "object" && m.groups !== null
|
|
116
|
+
&& GENERATION_ORDER.every((name) => name in m.groups)
|
|
117
|
+
&& Object.keys(m.groups).length === GENERATION_ORDER.length, "groups must be exactly the six generation bundles");
|
|
118
|
+
for (const name of GENERATION_ORDER) {
|
|
119
|
+
const values = m.groups[name]?.values;
|
|
120
|
+
ensure(Array.isArray(values) && values.length > 0, `group ${name} has no values`);
|
|
121
|
+
for (const value of values) {
|
|
122
|
+
ensure(typeof value === "object" && value !== null
|
|
123
|
+
&& typeof value.id === "string"
|
|
124
|
+
&& Number.isInteger(value.weight) && value.weight >= 1
|
|
125
|
+
&& Number.isInteger(value.support)
|
|
126
|
+
&& typeof value.payload === "object" && value.payload !== null, `group ${name} has a malformed value`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/** Load and structurally validate a population model from a path, directory, or object. */
|
|
131
|
+
export function loadPopulationModel(source) {
|
|
132
|
+
let model;
|
|
133
|
+
if (typeof source === "string") {
|
|
134
|
+
let path = resolve(source);
|
|
135
|
+
let stat;
|
|
136
|
+
try {
|
|
137
|
+
stat = lstatSync(path);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
throw new PopulationModelError(`population model is not a regular file: ${path}`);
|
|
141
|
+
}
|
|
142
|
+
if (stat.isDirectory()) {
|
|
143
|
+
path = resolve(path, "population-model-v1.json");
|
|
144
|
+
try {
|
|
145
|
+
stat = lstatSync(path);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
throw new PopulationModelError(`population model is not a regular file: ${path}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (stat.isSymbolicLink() || !stat.isFile()) {
|
|
152
|
+
throw new PopulationModelError(`population model is not a regular file: ${path}`);
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
model = JSON.parse(readFileSync(path, "utf8"));
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
throw new PopulationModelError(`cannot load population model: ${path}: ${String(error)}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
model = source;
|
|
163
|
+
}
|
|
164
|
+
validateModel(model);
|
|
165
|
+
return model;
|
|
166
|
+
}
|
|
167
|
+
function sourceReferences(source) {
|
|
168
|
+
const revision = source.revision ?? "";
|
|
169
|
+
return Object.keys(source.files).sort().map((name) => ({
|
|
170
|
+
name, revision, sha256: source.files[name].sha256,
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
/** Deterministically generate and validate one persona-profile-v2 from the model. */
|
|
174
|
+
export function generatePersonaProfile(identityKey, deviceKey, model) {
|
|
175
|
+
validateModel(model);
|
|
176
|
+
const kFloor = model.k_floor;
|
|
177
|
+
const constants = model.constants;
|
|
178
|
+
const drbg = new Drbg(seed(identityKey, deviceKey, model.model_version));
|
|
179
|
+
const chosen = {};
|
|
180
|
+
for (const group of GENERATION_ORDER) {
|
|
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
|
+
}
|
|
199
|
+
const selected = choose(values, drbg);
|
|
200
|
+
if (selected.support < kFloor) {
|
|
201
|
+
throw new PopulationModelError(`group ${group} selected a value below k_floor`);
|
|
202
|
+
}
|
|
203
|
+
chosen[group] = structuredClone(selected.payload);
|
|
204
|
+
}
|
|
205
|
+
const cpuMem = chosen.cpu_mem;
|
|
206
|
+
const display = chosen.display;
|
|
207
|
+
const displayVariable = {};
|
|
208
|
+
for (const key of DISPLAY_VARIABLE_KEYS)
|
|
209
|
+
displayVariable[key] = display[key];
|
|
210
|
+
const profile = {
|
|
211
|
+
schema_version: 2,
|
|
212
|
+
metadata: {
|
|
213
|
+
source: "synthetic",
|
|
214
|
+
created_at: model.created_at,
|
|
215
|
+
generator: {
|
|
216
|
+
name: GENERATOR_NAME,
|
|
217
|
+
version: GENERATOR_VERSION,
|
|
218
|
+
model_version: model.model_version,
|
|
219
|
+
},
|
|
220
|
+
source_references: sourceReferences(model.source),
|
|
221
|
+
},
|
|
222
|
+
compatibility: {
|
|
223
|
+
os_family: "windows", architecture: "x86_64",
|
|
224
|
+
browser_family: "chromium", browser_major: CHROMIUM_MAJOR,
|
|
225
|
+
},
|
|
226
|
+
hardware: {
|
|
227
|
+
hardware_concurrency: cpuMem.hardware_concurrency,
|
|
228
|
+
device_memory_gb: cpuMem.device_memory_gb,
|
|
229
|
+
js_heap_size_limit: constants.js_heap_size_limit,
|
|
230
|
+
},
|
|
231
|
+
display: { ...displayVariable, ...structuredClone(constants.desktop_display) },
|
|
232
|
+
locale: structuredClone(constants.locale),
|
|
233
|
+
graphics: chosen.graphics,
|
|
234
|
+
audio: chosen.audio,
|
|
235
|
+
fonts: chosen.fonts,
|
|
236
|
+
speech: chosen.speech,
|
|
237
|
+
media: {
|
|
238
|
+
codecs: structuredClone(constants.codecs),
|
|
239
|
+
devices: structuredClone(constants.devices),
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
assertPersonaProfileV2(profile);
|
|
243
|
+
return profile;
|
|
244
|
+
}
|
|
245
|
+
//# sourceMappingURL=population-model.js.map
|
|
@@ -0,0 +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;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAGnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAC7D,MAAM,CAAC,MAAM,cAAc,GAAG,2BAA2B,CAAC;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AACzC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,4BAA4B,EAAE,OAAO,CAAC,CAAC;AAElE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AACxG,MAAM,aAAa,GAAG,CAAC,oBAAoB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,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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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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