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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../src/content.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,4FAA4F;AAC5F,mGAAmG;AACnG,yDAAyD;AAYzD,4FAA4F;AAC5F,SAAS,aAAa,CAAC,IA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@
|
|
|
1
|
+
/** Whether the binary (or its chrome.dll) carries the Ant0 capability marker. Reads the file; a positive answer is cached. Throws when the path cannot be read. */
|
|
2
|
+
export declare function isAnt0Binary(exe: string): boolean;
|
|
1
3
|
export declare function incompatibleBinaryError(exe: string): Error;
|
|
2
4
|
export interface DownloadOptions {
|
|
3
5
|
/** Override the legacy local cache directory. No network access is performed. */
|
package/dist/download.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AA0CA,mKAAmK;AACnK,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAYjD;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAM1D;AAED,MAAM,WAAW,eAAe;IAC9B,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AA8BD,eAAO,MAAM,QAAQ,mBAAmB,CAAC;AAWzC,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAcpE;AAkBD,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,CAYzF;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,UAAU,UAAO,GAAG,KAAK,CAWnG;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAS9C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAoBzF;AAED;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,IAAI,GAAE,eAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAuB9E"}
|
package/dist/download.js
CHANGED
|
@@ -3,8 +3,11 @@ import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, rea
|
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { platformRelease } from "./release.js";
|
|
6
|
+
import { SdkError } from "./errors.js";
|
|
6
7
|
const ANT0_CAPABILITY = Buffer.from("ant0-browser-capabilities/persona-profile-v1");
|
|
7
8
|
const capabilityChecked = new Set();
|
|
9
|
+
/** Whether the file carries the marker. Throws when it cannot be read (EBUSY, EACCES, a scan holding a lock):
|
|
10
|
+
* that says nothing about the binary, so it must never be taken for "not an Ant0 engine". */
|
|
8
11
|
function containsCapability(file) {
|
|
9
12
|
let fd;
|
|
10
13
|
try {
|
|
@@ -21,15 +24,13 @@ function containsCapability(file) {
|
|
|
21
24
|
previous = data.subarray(Math.max(0, data.length - ANT0_CAPABILITY.length + 1));
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
|
-
catch {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
27
|
finally {
|
|
28
28
|
if (fd !== undefined)
|
|
29
29
|
closeSync(fd);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
/** Whether the binary (or its chrome.dll) carries the Ant0 capability marker. Reads the file; a positive answer is cached. Throws when the path cannot be read. */
|
|
33
|
+
export function isAnt0Binary(exe) {
|
|
33
34
|
const resolved = realpathSync(exe);
|
|
34
35
|
const sibling = path.join(path.dirname(resolved), "chrome.dll");
|
|
35
36
|
const files = [resolved, ...(existsSync(sibling) ? [sibling] : [])];
|
|
@@ -170,7 +171,14 @@ export function cachedBinary(base, binary, quiet) {
|
|
|
170
171
|
const cached = findFile(browserDir, binary);
|
|
171
172
|
if (!cached)
|
|
172
173
|
return null;
|
|
173
|
-
|
|
174
|
+
let ant0;
|
|
175
|
+
try {
|
|
176
|
+
ant0 = isAnt0Binary(cached);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return null;
|
|
180
|
+
} // unreadable right now: not proof that it is foreign, nothing is deleted
|
|
181
|
+
if (!ant0) {
|
|
174
182
|
rmSync(browserDir, { recursive: true, force: true });
|
|
175
183
|
rmSync(path.join(base, ".verified"), { force: true });
|
|
176
184
|
rmSync(path.join(base, MANIFEST), { force: true });
|
|
@@ -212,7 +220,7 @@ export async function ensureBinary(opts = {}) {
|
|
|
212
220
|
checkInstall(exe);
|
|
213
221
|
return exe;
|
|
214
222
|
}
|
|
215
|
-
throw new
|
|
223
|
+
throw new SdkError("sdk.engine_not_found", "No local Ant0 Browser binary was found. Build the browser first, then pass executablePath or " +
|
|
216
224
|
"set ANT0_BROWSER_BINARY to chrome/chrome.exe. To install a published release instead, set " +
|
|
217
225
|
"ANT0_BROWSER_RELEASE_URL to your release store.");
|
|
218
226
|
}
|
package/dist/download.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"download.js","sourceRoot":"","sources":["../src/download.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,WAAW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;QAClB,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,IAAI,QAAQ,CAAC,sBAAsB,EACvC,+FAA+F;QAC7F,4FAA4F;QAC5F,iDAAiD,CACpD,CAAC;AACJ,CAAC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable error identity for SDK failures.
|
|
3
|
+
*
|
|
4
|
+
* Every SDK error carries a `code` (a fixed dotted word), an `errorClass` (`defect`,
|
|
5
|
+
* `environment` or `expected`) and an optional local `cause`. Nothing here reports, logs or
|
|
6
|
+
* sends anything: the SDK stays offline. {@link reportFields} returns the only two values that
|
|
7
|
+
* are safe to forward to a reporter; messages and causes may hold paths or values.
|
|
8
|
+
*
|
|
9
|
+
* The subclasses extend the builtin types the SDK threw before, so `instanceof Error`,
|
|
10
|
+
* `TypeError` and `RangeError` checks keep working.
|
|
11
|
+
*/
|
|
12
|
+
export type ErrorClass = "defect" | "environment" | "expected";
|
|
13
|
+
export interface SdkErrorOptions {
|
|
14
|
+
cause?: unknown;
|
|
15
|
+
errorClass?: ErrorClass;
|
|
16
|
+
}
|
|
17
|
+
export interface CodedError extends Error {
|
|
18
|
+
readonly code: string;
|
|
19
|
+
readonly errorClass: ErrorClass;
|
|
20
|
+
/** A code already clamped to a known shape, for errors whose `code` comes from outside. */
|
|
21
|
+
readonly reportCode?: string;
|
|
22
|
+
}
|
|
23
|
+
/** The fixed fields that are safe to report. Never the message or cause. */
|
|
24
|
+
export declare function reportFields(error: CodedError): {
|
|
25
|
+
code: string;
|
|
26
|
+
class: ErrorClass;
|
|
27
|
+
};
|
|
28
|
+
export declare class SdkError extends Error implements CodedError {
|
|
29
|
+
readonly code: string;
|
|
30
|
+
readonly errorClass: ErrorClass;
|
|
31
|
+
constructor(code: string, message: string, options?: SdkErrorOptions);
|
|
32
|
+
}
|
|
33
|
+
export declare class SdkTypeError extends TypeError implements CodedError {
|
|
34
|
+
readonly code: string;
|
|
35
|
+
readonly errorClass: ErrorClass;
|
|
36
|
+
constructor(code: string, message: string, options?: SdkErrorOptions);
|
|
37
|
+
}
|
|
38
|
+
export declare class SdkRangeError extends RangeError implements CodedError {
|
|
39
|
+
readonly code: string;
|
|
40
|
+
readonly errorClass: ErrorClass;
|
|
41
|
+
constructor(code: string, message: string, options?: SdkErrorOptions);
|
|
42
|
+
}
|
|
43
|
+
/** Invalid input from the caller (a bad option or file). */
|
|
44
|
+
export declare class SdkInputError extends Error implements CodedError {
|
|
45
|
+
readonly code: string;
|
|
46
|
+
readonly errorClass: ErrorClass;
|
|
47
|
+
constructor(code: string, message: string, options?: SdkErrorOptions);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,aAAa,GAAG,UAAU,CAAC;AAE/D,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,WAAW,UAAW,SAAQ,KAAK;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,2FAA2F;IAC3F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,4EAA4E;AAC5E,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,CAEnF;AAED,qBAAa,QAAS,SAAQ,KAAM,YAAW,UAAU;IAE3C,QAAQ,CAAC,IAAI,EAAE,MAAM;IADjC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;gBACX,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAIlF;AAED,qBAAa,YAAa,SAAQ,SAAU,YAAW,UAAU;IAEnD,QAAQ,CAAC,IAAI,EAAE,MAAM;IADjC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;gBACX,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAIlF;AAED,qBAAa,aAAc,SAAQ,UAAW,YAAW,UAAU;IAErD,QAAQ,CAAC,IAAI,EAAE,MAAM;IADjC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;gBACX,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAIlF;AAED,4DAA4D;AAC5D,qBAAa,aAAc,SAAQ,KAAM,YAAW,UAAU;IAEhD,QAAQ,CAAC,IAAI,EAAE,MAAM;IADjC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;gBACX,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;CAIlF"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stable error identity for SDK failures.
|
|
3
|
+
*
|
|
4
|
+
* Every SDK error carries a `code` (a fixed dotted word), an `errorClass` (`defect`,
|
|
5
|
+
* `environment` or `expected`) and an optional local `cause`. Nothing here reports, logs or
|
|
6
|
+
* sends anything: the SDK stays offline. {@link reportFields} returns the only two values that
|
|
7
|
+
* are safe to forward to a reporter; messages and causes may hold paths or values.
|
|
8
|
+
*
|
|
9
|
+
* The subclasses extend the builtin types the SDK threw before, so `instanceof Error`,
|
|
10
|
+
* `TypeError` and `RangeError` checks keep working.
|
|
11
|
+
*/
|
|
12
|
+
/** The fixed fields that are safe to report. Never the message or cause. */
|
|
13
|
+
export function reportFields(error) {
|
|
14
|
+
return { code: String(error.reportCode ?? error.code), class: error.errorClass };
|
|
15
|
+
}
|
|
16
|
+
export class SdkError extends Error {
|
|
17
|
+
code;
|
|
18
|
+
errorClass;
|
|
19
|
+
constructor(code, message, options = {}) {
|
|
20
|
+
super(message, options.cause === undefined ? undefined : { cause: options.cause });
|
|
21
|
+
this.code = code;
|
|
22
|
+
this.errorClass = options.errorClass ?? "environment";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class SdkTypeError extends TypeError {
|
|
26
|
+
code;
|
|
27
|
+
errorClass;
|
|
28
|
+
constructor(code, message, options = {}) {
|
|
29
|
+
super(message, options.cause === undefined ? undefined : { cause: options.cause });
|
|
30
|
+
this.code = code;
|
|
31
|
+
this.errorClass = options.errorClass ?? "expected";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export class SdkRangeError extends RangeError {
|
|
35
|
+
code;
|
|
36
|
+
errorClass;
|
|
37
|
+
constructor(code, message, options = {}) {
|
|
38
|
+
super(message, options.cause === undefined ? undefined : { cause: options.cause });
|
|
39
|
+
this.code = code;
|
|
40
|
+
this.errorClass = options.errorClass ?? "expected";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Invalid input from the caller (a bad option or file). */
|
|
44
|
+
export class SdkInputError extends Error {
|
|
45
|
+
code;
|
|
46
|
+
errorClass;
|
|
47
|
+
constructor(code, message, options = {}) {
|
|
48
|
+
super(message, options.cause === undefined ? undefined : { cause: options.cause });
|
|
49
|
+
this.code = code;
|
|
50
|
+
this.errorClass = options.errorClass ?? "expected";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAgBH,4EAA4E;AAC5E,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,IAAI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,CAAC;CACF;AAED,4DAA4D;AAC5D,MAAM,OAAO,aAAc,SAAQ,KAAK;IAEjB;IADZ,UAAU,CAAa;IAChC,YAAqB,IAAY,EAAE,OAAe,EAAE,UAA2B,EAAE;QAC/E,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QADhE,SAAI,GAAJ,IAAI,CAAQ;QAE/B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,UAAU,CAAC;IACrD,CAAC;CACF"}
|
package/dist/fingerprint.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CanvasMode } from "./canvas.js";
|
|
1
2
|
export interface FingerprintOptions {
|
|
2
3
|
/**
|
|
3
4
|
* Master fingerprint seed (the per-eTLD+1 farbling root). Same seed => the same stable
|
|
@@ -10,8 +11,7 @@ export interface FingerprintOptions {
|
|
|
10
11
|
* persona (seed-selected from a Pixel/Galaxy device pool): Android UA + `Sec-CH-UA-Mobile: ?1`,
|
|
11
12
|
* touch (`maxTouchPoints`), `pointer:coarse`/`hover:none`, mobile screen/DPR, Mali/Adreno WebGL,
|
|
12
13
|
* `plugins=0`, and a mobile viewport (auto-sets a phone `--window-size`). On a desktop engine the
|
|
13
|
-
* GPU *render* and fine page geometry stay desktop (documented residual tells)
|
|
14
|
-
* `canvasBridge` for render coherence.
|
|
14
|
+
* GPU *render* and fine page geometry stay desktop (documented residual tells).
|
|
15
15
|
*/
|
|
16
16
|
platform?: "windows" | "linux" | "macos" | "android";
|
|
17
17
|
/** Spoofed platform version (UA-CH high-entropy). */
|
|
@@ -117,21 +117,40 @@ export interface FingerprintOptions {
|
|
|
117
117
|
*/
|
|
118
118
|
fingerprintNoise?: boolean;
|
|
119
119
|
/**
|
|
120
|
-
* `false`
|
|
121
|
-
* the
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
120
|
+
* `false` presents the machine's REAL GPU. With real GPU strings, every GPU value (the card name,
|
|
121
|
+
* the WebGL limits and extensions, shader precision, the WebGPU adapter info, limits and
|
|
122
|
+
* features) comes from this machine's graphics stack, and only the readback noise stays; so on a
|
|
123
|
+
* Linux computer a Windows persona shows a Linux GPU. The difference from `disableGpuFingerprint`
|
|
124
|
+
* is that the noise is kept. The Windows-only Direct3D11 answers (shader precision,
|
|
125
|
+
* MAX_ELEMENT_INDEX, hidden ASTC/ETC, a bgra8unorm preferred format) are the backend's too, and
|
|
126
|
+
* an explicit `gpuRenderer` / `gpuVendor` (or a WebGPU override) loses to it.
|
|
127
|
+
* Requires engine ant0.8 or later; inert on older builds.
|
|
126
128
|
*/
|
|
127
129
|
gpuStringSpoof?: boolean;
|
|
128
130
|
/**
|
|
129
|
-
* `false` turns off the per-eTLD+1 farble on
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
131
|
+
* `false` turns off the per-eTLD+1 farble on the canvas READBACKS: `getImageData` and `toDataURL`
|
|
132
|
+
* of a 2D canvas (also bitmaprenderer and OffscreenCanvas), and the `toBlob()` /
|
|
133
|
+
* `convertToBlob()` encode path (WebP, and anything made in a worker). WebGL and WebGPU canvases,
|
|
134
|
+
* `gl.readPixels`, audio and client rects keep their noise -- unlike `fingerprintNoise: false`,
|
|
135
|
+
* which is the process-wide off switch. Requires engine ant0.8 or later; inert on older builds.
|
|
133
136
|
*/
|
|
134
137
|
canvasNoise?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Canvas mode of the profile. `"real"` (the default) presents this computer's genuine canvas
|
|
140
|
+
* output, which every profile on this computer shares. `"noise"` makes the canvas output unique
|
|
141
|
+
* to the profile and stable across launches and sites; it needs a key (`canvasNoiseKey`, or the
|
|
142
|
+
* key stored with the identity) and sends exactly one `--fingerprint-noise-key=<16 hex>`.
|
|
143
|
+
* When `canvas` is unset the mode is `"real"`: `canvasNoise: true` and `fingerprintNoise: true` never
|
|
144
|
+
* select noise (they only warn), and their `false` values keep sending `--disable-canvas-noise` /
|
|
145
|
+
* `--disable-fingerprint-noise` as before.
|
|
146
|
+
* See ./canvas.ts for the full table.
|
|
147
|
+
*/
|
|
148
|
+
canvas?: CanvasMode;
|
|
149
|
+
/** The profile's canvas noise key: 16 lowercase hex characters. Used only in `"noise"` mode. */
|
|
150
|
+
canvasNoiseKey?: string;
|
|
151
|
+
/** Internal: absolute path of the private file that carries a schema 4 persona. Set by the
|
|
152
|
+
* launch code (see ./profile-file.ts), never by a caller. */
|
|
153
|
+
fingerprintProfileFile?: string;
|
|
135
154
|
/**
|
|
136
155
|
* Import a real captured fingerprint so the browser presents *that machine's* identity instead
|
|
137
156
|
* of the synthetic seed-derived one. Accepts a path to a `.json` profile, a profile object, or a
|
|
@@ -145,31 +164,6 @@ export interface FingerprintOptions {
|
|
|
145
164
|
* machine or incognito; set a realistic on-disk value (e.g. `250000` for ~244 GB).
|
|
146
165
|
*/
|
|
147
166
|
storageQuota?: number;
|
|
148
|
-
/**
|
|
149
|
-
* Canvas bridge — forward canvas/WebGL readbacks to a remote real-GPU host so the pixels a page
|
|
150
|
-
* hashes are coherent with the GPU your persona claims. Setting `url` enables it and auto-adds
|
|
151
|
-
* `--no-sandbox` (the bridge opens its socket from the renderer process).
|
|
152
|
-
*
|
|
153
|
-
* Latency note: a synchronous readback over the bridge is a network round-trip on the renderer
|
|
154
|
-
* thread (a timing signal vs latency-aware detectors). Mitigations are built in — the engine
|
|
155
|
-
* prefetches+caches so deferred/animated/repeated reads don't block — and you can tune behavior
|
|
156
|
-
* here: `mode` restricts bridging to the origins where canvas coherence is actually scored, and
|
|
157
|
-
* `fallback: "local"` makes a cold cache miss serve the fast local render instead of stalling.
|
|
158
|
-
*/
|
|
159
|
-
canvasBridge?: {
|
|
160
|
-
/** Bridge endpoint, "ws://host:port[/path]". Required to enable the bridge. */
|
|
161
|
-
url: string;
|
|
162
|
-
/** HTTP Basic credentials "user:secret"; must match the server. */
|
|
163
|
-
auth?: string;
|
|
164
|
-
/** Per-origin policy: "off" | "all" (default) | "allow" | "deny". */
|
|
165
|
-
mode?: "off" | "all" | "allow" | "deny";
|
|
166
|
-
/** eTLD+1 list bridged when mode="allow". */
|
|
167
|
-
allow?: string[];
|
|
168
|
-
/** eTLD+1 list NOT bridged when mode="deny". */
|
|
169
|
-
deny?: string[];
|
|
170
|
-
/** Cold cache-miss behavior: "block" (default) | "local" (never stall; render locally). */
|
|
171
|
-
fallback?: "block" | "local";
|
|
172
|
-
};
|
|
173
167
|
}
|
|
174
168
|
export declare const FINGERPRINT_KEYS: (keyof FingerprintOptions)[];
|
|
175
169
|
/** Split an options object into its fingerprint half and the remaining (Playwright) half. */
|
|
@@ -209,5 +203,16 @@ export declare function resolveTlsProfile(value: FingerprintOptions["tlsProfile"
|
|
|
209
203
|
* back by language subtag, then to America/New_York (matching the en-US Accept-Language default).
|
|
210
204
|
*/
|
|
211
205
|
export declare function defaultTimezone(primaryLang: string): string | undefined;
|
|
206
|
+
/** The persona's device pixel ratio when the SDK knows it, else undefined (a native identity, or an
|
|
207
|
+
* engine-picked persona, leaves the real display scale alone). Order: the explicit
|
|
208
|
+
* `devicePixelRatio`, the `lightStealth` bundle's value, then a v2 profile's `display.device_pixel_ratio`. */
|
|
209
|
+
export declare function personaDpr(o: FingerprintOptions): number | undefined;
|
|
210
|
+
/** The persona's available screen in CSS px (explicit `availWidth`/`availHeight`, else a v2 profile). */
|
|
211
|
+
export declare function personaAvail(o: FingerprintOptions): {
|
|
212
|
+
width?: number;
|
|
213
|
+
height?: number;
|
|
214
|
+
};
|
|
215
|
+
/** Engine switch that names a persona file (schema 4). One constant, one-line change. */
|
|
216
|
+
export declare const PROFILE_FILE_SWITCH = "--fingerprint-profile-file";
|
|
212
217
|
export declare function fingerprintArgs(o: FingerprintOptions, identityApi?: boolean): string[];
|
|
213
218
|
//# sourceMappingURL=fingerprint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../src/fingerprint.ts"],"names":[],"mappings":"AAKA,OAAO,EACsD,KAAK,UAAU,EAC3E,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;IACrD,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oCAAoC;IACpC,KAAK,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAChE,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,EAAE,eAAe,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,MAAM,EAAE,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC;IACvG,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mC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to the Ant0 Browser Chromium command-line switches.
|
|
2
2
|
// Switch names mirror components/ungoogled/ungoogled_switches.cc (see patches/000-fingerprint-switches.patch).
|
|
3
3
|
import { gzipSync } from "node:zlib";
|
|
4
|
+
import { assertPersonaProfileV4 } from "./persona-profile-v4.js";
|
|
5
|
+
import { CANVAS_NOISE_KEY_SWITCH, assertCanvasNoiseKey, canvasMode, } from "./canvas.js";
|
|
6
|
+
import { SdkInputError } from "./errors.js";
|
|
7
|
+
import { webgpuOverridePlan } from "./webgpu-override.js";
|
|
4
8
|
import { assertPersonaProfileV2 } from "./persona-profile-v2.js";
|
|
5
9
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
10
|
import { createHash } from "node:crypto";
|
|
@@ -31,9 +35,11 @@ export const FINGERPRINT_KEYS = [
|
|
|
31
35
|
"fingerprintNoise",
|
|
32
36
|
"gpuStringSpoof",
|
|
33
37
|
"canvasNoise",
|
|
38
|
+
"canvas",
|
|
39
|
+
"canvasNoiseKey",
|
|
40
|
+
"fingerprintProfileFile",
|
|
34
41
|
"fingerprintProfile",
|
|
35
42
|
"storageQuota",
|
|
36
|
-
"canvasBridge",
|
|
37
43
|
"tlsProfile",
|
|
38
44
|
];
|
|
39
45
|
/** Split an options object into its fingerprint half and the remaining (Playwright) half. */
|
|
@@ -68,6 +74,8 @@ export function encodeProfile(value) {
|
|
|
68
74
|
if (typeof value === "object") {
|
|
69
75
|
if (value.schema_version === 2)
|
|
70
76
|
assertPersonaProfileV2(value);
|
|
77
|
+
if (value.schema_version === 4)
|
|
78
|
+
assertPersonaProfileV4(value);
|
|
71
79
|
raw = Buffer.from(JSON.stringify(value));
|
|
72
80
|
}
|
|
73
81
|
else if (existsSync(value)) {
|
|
@@ -83,6 +91,10 @@ export function encodeProfile(value) {
|
|
|
83
91
|
&& parsed.schema_version === 2) {
|
|
84
92
|
assertPersonaProfileV2(parsed);
|
|
85
93
|
}
|
|
94
|
+
else if (typeof parsed === "object" && parsed !== null
|
|
95
|
+
&& parsed.schema_version === 4) {
|
|
96
|
+
assertPersonaProfileV4(parsed);
|
|
97
|
+
}
|
|
86
98
|
}
|
|
87
99
|
catch (error) {
|
|
88
100
|
if (error instanceof SyntaxError) {
|
|
@@ -154,8 +166,8 @@ const LIGHT_STEALTH_PROFILES = [
|
|
|
154
166
|
* binary). The seed->row mapping matches the Python SDK (full sha256 digest as a big integer mod N).
|
|
155
167
|
*/
|
|
156
168
|
export function lightStealthValues(seed) {
|
|
157
|
-
//
|
|
158
|
-
const key = seed === undefined || seed === null || String(seed) === "" ? "
|
|
169
|
+
// Default seed string for seedless calls: the same persona every time unless an explicit seed is passed.
|
|
170
|
+
const key = seed === undefined || seed === null || String(seed) === "" ? "ant0-light-stealth" : String(seed);
|
|
159
171
|
const hex = createHash("sha256").update(key, "utf8").digest("hex");
|
|
160
172
|
const idx = Number(BigInt("0x" + hex) % BigInt(LIGHT_STEALTH_PROFILES.length));
|
|
161
173
|
const row = LIGHT_STEALTH_PROFILES[idx];
|
|
@@ -231,6 +243,69 @@ export function defaultTimezone(primaryLang) {
|
|
|
231
243
|
}
|
|
232
244
|
return "America/New_York";
|
|
233
245
|
}
|
|
246
|
+
/** The persona's device pixel ratio when the SDK knows it, else undefined (a native identity, or an
|
|
247
|
+
* engine-picked persona, leaves the real display scale alone). Order: the explicit
|
|
248
|
+
* `devicePixelRatio`, the `lightStealth` bundle's value, then a v2 profile's `display.device_pixel_ratio`. */
|
|
249
|
+
export function personaDpr(o) {
|
|
250
|
+
const ok = (v) => typeof v === "number" && Number.isFinite(v) && v > 0 && v <= 8;
|
|
251
|
+
if (ok(o.devicePixelRatio))
|
|
252
|
+
return o.devicePixelRatio;
|
|
253
|
+
if (o.devicePixelRatio === undefined && o.lightStealth) {
|
|
254
|
+
const v = lightStealthValues(o.fingerprint).devicePixelRatio;
|
|
255
|
+
if (ok(v))
|
|
256
|
+
return v;
|
|
257
|
+
}
|
|
258
|
+
const d = profileDisplay(o);
|
|
259
|
+
return ok(d?.device_pixel_ratio) ? d.device_pixel_ratio : undefined;
|
|
260
|
+
}
|
|
261
|
+
/** A v2 profile's `display` block, or undefined (no profile, unreadable, or the legacy format). */
|
|
262
|
+
function profileDisplay(o) {
|
|
263
|
+
if (o.fingerprintProfile === undefined)
|
|
264
|
+
return undefined;
|
|
265
|
+
let obj;
|
|
266
|
+
try {
|
|
267
|
+
const v = o.fingerprintProfile;
|
|
268
|
+
obj = typeof v === "object" ? v : existsSync(v) ? JSON.parse(readFileSync(v, "utf8")) : JSON.parse(v);
|
|
269
|
+
}
|
|
270
|
+
catch {
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
const root = obj;
|
|
274
|
+
if (root && root.schema_version === 4) {
|
|
275
|
+
// Schema 4 (spec 2.4): surfaces.display names the available area avail_width/avail_height;
|
|
276
|
+
// present it under the v2 key names so both formats yield the same flags for the same numbers.
|
|
277
|
+
const sd = root.surfaces?.display;
|
|
278
|
+
if (!sd || typeof sd !== "object")
|
|
279
|
+
return undefined;
|
|
280
|
+
const s4 = sd;
|
|
281
|
+
return { device_pixel_ratio: s4.device_pixel_ratio, available_width: s4.avail_width, available_height: s4.avail_height };
|
|
282
|
+
}
|
|
283
|
+
if (!root || root.schema_version !== 2)
|
|
284
|
+
return undefined;
|
|
285
|
+
const d = root.display;
|
|
286
|
+
return d && typeof d === "object" ? d : undefined;
|
|
287
|
+
}
|
|
288
|
+
/** The persona's available screen in CSS px (explicit `availWidth`/`availHeight`, else a v2 profile). */
|
|
289
|
+
export function personaAvail(o) {
|
|
290
|
+
const num = (v) => (typeof v === "number" && Number.isFinite(v) && v > 0 ? v : undefined);
|
|
291
|
+
const d = profileDisplay(o);
|
|
292
|
+
return {
|
|
293
|
+
width: num(o.availWidth) ?? num(d?.available_width),
|
|
294
|
+
height: num(o.availHeight) ?? num(d?.available_height),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
/** Engine switch that names a persona file (schema 4). One constant, one-line change. */
|
|
298
|
+
export const PROFILE_FILE_SWITCH = "--fingerprint-profile-file";
|
|
299
|
+
/** The `schema_version` of a profile given as an object, JSON text or a path; undefined if unreadable. */
|
|
300
|
+
function profileSchemaVersion(value) {
|
|
301
|
+
try {
|
|
302
|
+
const obj = typeof value === "object" ? value : existsSync(value) ? JSON.parse(readFileSync(value, "utf8")) : JSON.parse(value);
|
|
303
|
+
return obj?.schema_version;
|
|
304
|
+
}
|
|
305
|
+
catch {
|
|
306
|
+
return undefined;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
234
309
|
export function fingerprintArgs(o, identityApi = false) {
|
|
235
310
|
const args = [];
|
|
236
311
|
o = { ...o }; // never mutate the caller's options
|
|
@@ -251,6 +326,12 @@ export function fingerprintArgs(o, identityApi = false) {
|
|
|
251
326
|
args.push(`--${flag}=${value}`);
|
|
252
327
|
}
|
|
253
328
|
};
|
|
329
|
+
// The seed makes the engine noise canvas readback on its own, so `canvas` cannot be honoured with it:
|
|
330
|
+
// "real" would still be noised, and a noise key is ignored.
|
|
331
|
+
if (o.canvas !== undefined && o.fingerprint !== undefined && o.fingerprint !== null && o.fingerprint !== "") {
|
|
332
|
+
throw new SdkInputError("sdk.canvas_invalid", 'canvas cannot be combined with the fingerprint seed: with a seed the engine noises canvas readback by itself ' +
|
|
333
|
+
'("real" would still be noised and a noise key is ignored). Use an identity, which has no seed.');
|
|
334
|
+
}
|
|
254
335
|
set("fingerprint", o.fingerprint);
|
|
255
336
|
// Default the persona platform to the HOST OS so it's coherent with the binary the SDK ships for
|
|
256
337
|
// this machine (Windows binary -> windows, Linux binary -> linux). Override via
|
|
@@ -265,6 +346,8 @@ export function fingerprintArgs(o, identityApi = false) {
|
|
|
265
346
|
set("fingerprint-brand-version", o.brandVersion);
|
|
266
347
|
set("fingerprint-gpu-vendor", o.gpuVendor);
|
|
267
348
|
set("fingerprint-gpu-renderer", o.gpuRenderer);
|
|
349
|
+
// Keep WebGPU on the override's GPU family (see webgpu-override.ts).
|
|
350
|
+
args.push(...webgpuOverridePlan(o).args);
|
|
268
351
|
set("fingerprint-hardware-concurrency", o.hardwareConcurrency);
|
|
269
352
|
// Native metadata overrides (flag > persona > real). Read directly by the getters — no
|
|
270
353
|
// --fingerprint persona machinery — so they are safe to spoof individually or via lightStealth.
|
|
@@ -284,6 +367,13 @@ export function fingerprintArgs(o, identityApi = false) {
|
|
|
284
367
|
set("fingerprint-avail-height", o.availHeight);
|
|
285
368
|
set("fingerprint-color-depth", o.colorDepth);
|
|
286
369
|
set("fingerprint-device-pixel-ratio", o.devicePixelRatio);
|
|
370
|
+
// Persona scale: make the REAL scale the persona's. Without it a host at scale 2 shows through
|
|
371
|
+
// (0.5px borders, 0.5 pointer steps, 2x screenshots) while the persona claims 1. Measured on
|
|
372
|
+
// Linux: the flag closes the gap with no engine patch. A caller's own --force-device-scale-factor
|
|
373
|
+
// in `args` comes later on the command line and wins.
|
|
374
|
+
const scale = personaDpr(o);
|
|
375
|
+
if (scale !== undefined)
|
|
376
|
+
args.push(`--force-device-scale-factor=${scale}`);
|
|
287
377
|
set("fingerprint-max-touch-points", o.maxTouchPoints);
|
|
288
378
|
set("fingerprint-location", o.location);
|
|
289
379
|
set("fingerprint-storage-quota", o.storageQuota);
|
|
@@ -330,33 +420,39 @@ export function fingerprintArgs(o, identityApi = false) {
|
|
|
330
420
|
// Identity spoofs (UA/screen/GPU/persona) stay on. Default keeps the noise.
|
|
331
421
|
if (o.fingerprintNoise === false)
|
|
332
422
|
args.push("--disable-fingerprint-noise");
|
|
333
|
-
// The two INDEPENDENT halves of the bundles above (engine
|
|
423
|
+
// The two INDEPENDENT halves of the bundles above (engine ant0.8 or later).
|
|
334
424
|
if (o.gpuStringSpoof === false)
|
|
335
425
|
args.push("--disable-gpu-string-spoof");
|
|
336
426
|
if (o.canvasNoise === false)
|
|
337
427
|
args.push("--disable-canvas-noise");
|
|
428
|
+
// Canvas mode (see ./canvas.ts). Real sends nothing. Noise sends the profile's key, once. An explicit
|
|
429
|
+
// canvas: "noise" without a key is an error; the identity path (prepareIdentityOptions) supplies the key.
|
|
430
|
+
if (canvasMode(o) === "noise") {
|
|
431
|
+
assertCanvasNoiseKey(o.canvasNoiseKey);
|
|
432
|
+
if (o.canvasNoiseKey !== undefined)
|
|
433
|
+
args.push(`${CANVAS_NOISE_KEY_SWITCH}=${o.canvasNoiseKey}`);
|
|
434
|
+
else if (o.canvas === "noise") {
|
|
435
|
+
throw new SdkInputError("sdk.canvas_key_missing", 'canvas: "noise" needs a canvasNoiseKey (16 lowercase hex characters)');
|
|
436
|
+
}
|
|
437
|
+
}
|
|
338
438
|
// fingerprintProfile transports a profile to the native parser. Canonical v2 profiles are
|
|
339
439
|
// complete and activate atomically; only the deprecated unversioned format has partial-field
|
|
340
440
|
// fallback semantics.
|
|
341
|
-
if (o.fingerprintProfile)
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
args.push(
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if (cb.fallback)
|
|
357
|
-
args.push(`--canvas-bridge-fallback=${cb.fallback}`);
|
|
358
|
-
if (!args.includes("--no-sandbox"))
|
|
359
|
-
args.push("--no-sandbox");
|
|
441
|
+
if (o.fingerprintProfile) {
|
|
442
|
+
if (profileSchemaVersion(o.fingerprintProfile) === 4) {
|
|
443
|
+
// Schema 4 never goes inline: the launch code writes it to a private file first.
|
|
444
|
+
if (typeof o.fingerprintProfile === "string") {
|
|
445
|
+
throw new SdkInputError("sdk.persona_profile_invalid", "a schema_version 4 persona cannot be given to fingerprintProfile as a path or JSON text (that supports schema 2 " +
|
|
446
|
+
"only); pass it through identity: { mode: \"captured\", source }, which accepts a path or JSON text and writes the private file");
|
|
447
|
+
}
|
|
448
|
+
if (!o.fingerprintProfileFile) {
|
|
449
|
+
throw new SdkInputError("sdk.persona_file_missing", "a schema_version 4 persona travels in a private file; launch through the SDK launch functions");
|
|
450
|
+
}
|
|
451
|
+
args.push(`${PROFILE_FILE_SWITCH}=${o.fingerprintProfileFile}`);
|
|
452
|
+
}
|
|
453
|
+
else {
|
|
454
|
+
args.push(`--fingerprint-profile=${encodeProfile(o.fingerprintProfile)}`);
|
|
455
|
+
}
|
|
360
456
|
}
|
|
361
457
|
// tlsProfile keeps the TLS ClientHello coherent with the persona's claimed Chrome version (the
|
|
362
458
|
// network layer follows the UA). Default "match-persona" follows brandVersion; "chrome-<major>"
|
|
@@ -367,7 +463,11 @@ export function fingerprintArgs(o, identityApi = false) {
|
|
|
367
463
|
// The Android persona lays the page out as a mobile viewport, which needs a phone-sized window
|
|
368
464
|
// (Chromium's ~500px minimum width floor still applies). Auto-set one; a caller-supplied
|
|
369
465
|
// --window-size in `args` overrides this (Chromium takes the last --window-size).
|
|
370
|
-
|
|
466
|
+
// A schema 4 persona names its OS in the profile; no platform switch is derived from it.
|
|
467
|
+
const v4Family = typeof o.fingerprintProfile === "object" && o.fingerprintProfile !== null
|
|
468
|
+
&& o.fingerprintProfile.schema_version === 4
|
|
469
|
+
? o.fingerprintProfile.identity?.os?.family : undefined;
|
|
470
|
+
if ((o.platform ?? v4Family) === "android") {
|
|
371
471
|
args.push("--window-size=412,915");
|
|
372
472
|
}
|
|
373
473
|
return args;
|