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.
Files changed (163) hide show
  1. package/LICENSE +35 -0
  2. package/README.md +208 -2
  3. package/dist/canvas.d.ts +55 -0
  4. package/dist/canvas.d.ts.map +1 -0
  5. package/dist/canvas.js +82 -0
  6. package/dist/canvas.js.map +1 -0
  7. package/dist/chromium-version.d.ts +22 -0
  8. package/dist/chromium-version.d.ts.map +1 -0
  9. package/dist/chromium-version.js +22 -0
  10. package/dist/chromium-version.js.map +1 -0
  11. package/dist/claim-hints.d.ts +36 -0
  12. package/dist/claim-hints.d.ts.map +1 -0
  13. package/dist/claim-hints.js +9 -0
  14. package/dist/claim-hints.js.map +1 -0
  15. package/dist/cleanup.d.ts +35 -0
  16. package/dist/cleanup.d.ts.map +1 -0
  17. package/dist/cleanup.js +106 -0
  18. package/dist/cleanup.js.map +1 -0
  19. package/dist/content.d.ts +11 -0
  20. package/dist/content.d.ts.map +1 -0
  21. package/dist/content.js +52 -0
  22. package/dist/content.js.map +1 -0
  23. package/dist/download.d.ts +24 -0
  24. package/dist/download.d.ts.map +1 -0
  25. package/dist/download.js +227 -0
  26. package/dist/download.js.map +1 -0
  27. package/dist/errors.d.ts +49 -0
  28. package/dist/errors.d.ts.map +1 -0
  29. package/dist/errors.js +53 -0
  30. package/dist/errors.js.map +1 -0
  31. package/dist/fingerprint.d.ts +218 -0
  32. package/dist/fingerprint.d.ts.map +1 -0
  33. package/dist/fingerprint.js +475 -0
  34. package/dist/fingerprint.js.map +1 -0
  35. package/dist/fontpack.d.ts +13 -0
  36. package/dist/fontpack.d.ts.map +1 -0
  37. package/dist/fontpack.js +150 -0
  38. package/dist/fontpack.js.map +1 -0
  39. package/dist/fonts.d.ts +15 -0
  40. package/dist/fonts.d.ts.map +1 -0
  41. package/dist/fonts.js +86 -0
  42. package/dist/fonts.js.map +1 -0
  43. package/dist/geoip.d.ts +45 -0
  44. package/dist/geoip.d.ts.map +1 -0
  45. package/dist/geoip.js +290 -0
  46. package/dist/geoip.js.map +1 -0
  47. package/dist/geometry.d.ts +32 -0
  48. package/dist/geometry.d.ts.map +1 -0
  49. package/dist/geometry.js +85 -0
  50. package/dist/geometry.js.map +1 -0
  51. package/dist/humanize.d.ts +20 -0
  52. package/dist/humanize.d.ts.map +1 -0
  53. package/dist/humanize.js +921 -0
  54. package/dist/humanize.js.map +1 -0
  55. package/dist/identity-persistence.d.ts +88 -0
  56. package/dist/identity-persistence.d.ts.map +1 -0
  57. package/dist/identity-persistence.js +381 -0
  58. package/dist/identity-persistence.js.map +1 -0
  59. package/dist/identity.d.ts +81 -0
  60. package/dist/identity.d.ts.map +1 -0
  61. package/dist/identity.js +370 -0
  62. package/dist/identity.js.map +1 -0
  63. package/dist/index.d.ts +281 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +790 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/launch-ticket.d.ts +191 -0
  68. package/dist/launch-ticket.d.ts.map +1 -0
  69. package/dist/launch-ticket.js +549 -0
  70. package/dist/launch-ticket.js.map +1 -0
  71. package/dist/launchopts.d.ts +266 -0
  72. package/dist/launchopts.d.ts.map +1 -0
  73. package/dist/launchopts.js +623 -0
  74. package/dist/launchopts.js.map +1 -0
  75. package/dist/motion.d.ts +106 -0
  76. package/dist/motion.d.ts.map +1 -0
  77. package/dist/motion.js +311 -0
  78. package/dist/motion.js.map +1 -0
  79. package/dist/motionscore.d.ts +57 -0
  80. package/dist/motionscore.d.ts.map +1 -0
  81. package/dist/motionscore.js +215 -0
  82. package/dist/motionscore.js.map +1 -0
  83. package/dist/native/linux-x64/PRODUCT-LICENSE.txt +28 -0
  84. package/dist/native/linux-x64/ant0_runtime.node +0 -0
  85. package/dist/native/windows-x64/PRODUCT-LICENSE.txt +28 -0
  86. package/dist/native/windows-x64/ant0_runtime.node +0 -0
  87. package/dist/persona-migration.d.ts +54 -0
  88. package/dist/persona-migration.d.ts.map +1 -0
  89. package/dist/persona-migration.js +97 -0
  90. package/dist/persona-migration.js.map +1 -0
  91. package/dist/persona-profile-v2.d.ts +169 -0
  92. package/dist/persona-profile-v2.d.ts.map +1 -0
  93. package/dist/persona-profile-v2.js +454 -0
  94. package/dist/persona-profile-v2.js.map +1 -0
  95. package/dist/persona-profile-v4.d.ts +61 -0
  96. package/dist/persona-profile-v4.d.ts.map +1 -0
  97. package/dist/persona-profile-v4.js +79 -0
  98. package/dist/persona-profile-v4.js.map +1 -0
  99. package/dist/persona-rejected.d.ts +36 -0
  100. package/dist/persona-rejected.d.ts.map +1 -0
  101. package/dist/persona-rejected.js +40 -0
  102. package/dist/persona-rejected.js.map +1 -0
  103. package/dist/population-model.d.ts +45 -0
  104. package/dist/population-model.d.ts.map +1 -0
  105. package/dist/population-model.js +245 -0
  106. package/dist/population-model.js.map +1 -0
  107. package/dist/profile-file.d.ts +201 -0
  108. package/dist/profile-file.d.ts.map +1 -0
  109. package/dist/profile-file.js +736 -0
  110. package/dist/profile-file.js.map +1 -0
  111. package/dist/release-fetch.d.ts +74 -0
  112. package/dist/release-fetch.d.ts.map +1 -0
  113. package/dist/release-fetch.js +395 -0
  114. package/dist/release-fetch.js.map +1 -0
  115. package/dist/release.d.ts +16 -0
  116. package/dist/release.d.ts.map +1 -0
  117. package/dist/release.js +26 -0
  118. package/dist/release.js.map +1 -0
  119. package/dist/render.d.ts +38 -0
  120. package/dist/render.d.ts.map +1 -0
  121. package/dist/render.js +104 -0
  122. package/dist/render.js.map +1 -0
  123. package/dist/runtime-client.d.ts +47 -0
  124. package/dist/runtime-client.d.ts.map +1 -0
  125. package/dist/runtime-client.js +327 -0
  126. package/dist/runtime-client.js.map +1 -0
  127. package/dist/runtime-launch.d.ts +22 -0
  128. package/dist/runtime-launch.d.ts.map +1 -0
  129. package/dist/runtime-launch.js +92 -0
  130. package/dist/runtime-launch.js.map +1 -0
  131. package/dist/scale.d.ts +29 -0
  132. package/dist/scale.d.ts.map +1 -0
  133. package/dist/scale.js +105 -0
  134. package/dist/scale.js.map +1 -0
  135. package/dist/shaderdialect.d.ts +33 -0
  136. package/dist/shaderdialect.d.ts.map +1 -0
  137. package/dist/shaderdialect.js +47 -0
  138. package/dist/shaderdialect.js.map +1 -0
  139. package/dist/speech-coherence.d.ts +52 -0
  140. package/dist/speech-coherence.d.ts.map +1 -0
  141. package/dist/speech-coherence.js +254 -0
  142. package/dist/speech-coherence.js.map +1 -0
  143. package/dist/template-selection.d.ts +14 -0
  144. package/dist/template-selection.d.ts.map +1 -0
  145. package/dist/template-selection.js +66 -0
  146. package/dist/template-selection.js.map +1 -0
  147. package/dist/warnings.d.ts +50 -0
  148. package/dist/warnings.d.ts.map +1 -0
  149. package/dist/warnings.js +273 -0
  150. package/dist/warnings.js.map +1 -0
  151. package/dist/webgl-coherence.d.ts +30 -0
  152. package/dist/webgl-coherence.d.ts.map +1 -0
  153. package/dist/webgl-coherence.js +98 -0
  154. package/dist/webgl-coherence.js.map +1 -0
  155. package/dist/webgpu-override.d.ts +14 -0
  156. package/dist/webgpu-override.d.ts.map +1 -0
  157. package/dist/webgpu-override.js +82 -0
  158. package/dist/webgpu-override.js.map +1 -0
  159. package/dist/widevine.d.ts +44 -0
  160. package/dist/widevine.d.ts.map +1 -0
  161. package/dist/widevine.js +203 -0
  162. package/dist/widevine.js.map +1 -0
  163. package/package.json +56 -4
@@ -0,0 +1,549 @@
1
+ // Engine launch ticket (engine patch 0037; ant0/docs/PHASE3-CONTRACT.md §10).
2
+ //
3
+ // Since patch 0037 the engine refuses to start without `--ant0-launch=<ticket>`: a licence token
4
+ // signed by the Ant0 server, plus a 15-minute claim the local device signed, bound to the engine's
5
+ // release version. The SDK never mints tickets (it has no device key); it either passes the one the
6
+ // caller hands in (`launchTicket`) or asks the local daemon for one
7
+ // (`GET /v1/licence/ticket?engine=<version>`) when a daemon is reachable. Without either the launch
8
+ // proceeds and the engine exits with code 90 and `ant0: launch ticket invalid (<reason>)` on stderr,
9
+ // which the SDK surfaces as a {@link LaunchTicketRejectedError} (`code: "engine.launch_ticket_rejected"`).
10
+ //
11
+ // Daemon discovery follows the CLI (`@ant0/api-client` `discoverDaemon`): `ANT0_URL` (+ `ANT0_TOKEN`)
12
+ // when set; else the data folder (`ANT0_HOME`, the platform default, or a legacy `~/.ant0`) gives
13
+ // `ant0d.pid` (port/host) and `ant0d.token`; `ANT0D_HOST`/`ANT0D_PORT` are the fallbacks. No token
14
+ // means no daemon, and no request is made.
15
+ import { existsSync, readFileSync, realpathSync } from "node:fs";
16
+ import { homedir } from "node:os";
17
+ import { basename, dirname, join, posix, resolve as resolvePath, win32 } from "node:path";
18
+ import { SdkTypeError } from "./errors.js";
19
+ import { PersonaFileRejectedError, personaFileRejection, playwrightExitCode } from "./persona-rejected.js";
20
+ /** The engine switch; the value is the five-segment ticket. */
21
+ export const LAUNCH_TICKET_SWITCH = "ant0-launch";
22
+ /** The environment variable the engine child also reads the ticket from (engine patch 949 and later). */
23
+ export const LAUNCH_TICKET_ENV = "ANT0_LAUNCH";
24
+ /** Exit code of an engine that refused its ticket (or got none). */
25
+ export const LAUNCH_TICKET_EXIT_CODE = 90;
26
+ /** Error code carried by {@link LaunchTicketRejectedError}. */
27
+ export const LAUNCH_TICKET_REJECTED_CODE = "engine.launch_ticket_rejected";
28
+ /** Env override for the engine's release version when it cannot be inferred from the install. */
29
+ export const ENGINE_VERSION_ENV = "ANT0_BROWSER_ENGINE_VERSION";
30
+ const STDERR_LINE = /ant0: launch ticket invalid \(([a-z_]+)\)/;
31
+ const RELEASE_VERSION = /^\d+\.\d+\.\d+\.\d+-ant0\.\d+$/;
32
+ /** A development build (`ant0_release_version` left empty) identifies as `<chromium>-ant0.dev`. */
33
+ const DEV_VERSION = /^\d+\.\d+\.\d+\.\d+-ant0\.dev$/;
34
+ const DEFAULT_HOST = "127.0.0.1";
35
+ const DEFAULT_PORT = 27100;
36
+ const DEFAULT_TIMEOUT_MS = 3000;
37
+ // Playwright's launch failure quotes the whole command line, including the ticket and the persona-file
38
+ // path; neither may reach a log through this SDK's own errors. The value runs to the next switch or the
39
+ // end of the line (a path can hold spaces). A value the exact step already replaced is left alone (it may
40
+ // sit inside quotes that must survive).
41
+ const SECRET_SWITCH = /--(ant0-launch|fingerprint-profile-file)(?:=|[ \t]+)(?![ \t]*(?:\\*["'])?<redacted>)[^\r\n]*?(?=[ \t]--[A-Za-z]|[\r\n]|$)/g;
42
+ /** Switches whose values are launch secrets (the ticket, the persona file, the profile directory). */
43
+ const SECRET_ARG_SWITCHES = ["ant0-launch", "fingerprint-profile-file", "user-data-dir"];
44
+ /**
45
+ * A value that is not a path is replaced on its own (outside `--switch=`) only from this length on: a short
46
+ * bare word (`chrome`, `exit`, `data`) would mangle Playwright's own text. A path (it holds a separator) is
47
+ * replaced on its own from 4 characters. Right after a secret switch any length is replaced.
48
+ */
49
+ const MIN_STANDALONE_SECRET = 16;
50
+ const MIN_STANDALONE_PATH = 4;
51
+ /** A `--ant0-launch` value is matched anywhere only from this length; a shorter one is boundary-only. Only a malformed value a user typed is that short: a minted ticket carries a 64-byte signature (about 86 characters). */
52
+ const MIN_EXACT_TICKET = 16;
53
+ // Where an exact value may end: whitespace, a quote (also a backslash-escaped one), a comma or closing
54
+ // bracket, or sentence punctuation before one of those or the end. Never inside a longer path or word.
55
+ const VALUE_END = String.raw `(?=[\s"',\]})]|\\+["']|[.;:]*(?:[\s"']|$))`;
56
+ // Where a bare value may start: the start, whitespace, a quote, an opening bracket, a comma or `=`.
57
+ const VALUE_START = String.raw `(?<![^\s"'\[(,=])`;
58
+ const SWITCH_PREFIX = String.raw `(--(?:${SECRET_ARG_SWITCHES.join("|")})(?:=|[ \t]+)(?:\\*["'])?)`;
59
+ // Only objects built by launchSecretValues() are accepted: a hand-built lookalike is rejected.
60
+ const PRODUCED = new WeakSet();
61
+ const NO_SECRETS = Object.freeze({ exact: Object.freeze([]), boundary: Object.freeze([]) });
62
+ /** Runtime guard (JS callers bypass the types): only a {@link LaunchSecrets} or nothing (regex layer only). */
63
+ function checkSecrets(secrets) {
64
+ if (secrets === undefined)
65
+ return NO_SECRETS;
66
+ if (secrets === null || typeof secrets !== "object" || !PRODUCED.has(secrets)) {
67
+ throw new TypeError("secrets must be the LaunchSecrets from launchSecretValues(), not an array or a hand-built object");
68
+ }
69
+ return secrets;
70
+ }
71
+ /** An absolute, normalised path (Playwright logs the profile directory in that form). */
72
+ function absolutePath(p) {
73
+ try {
74
+ return resolvePath(p);
75
+ }
76
+ catch {
77
+ return p;
78
+ }
79
+ }
80
+ /**
81
+ * The values of the secret switches among the argv the SDK passed (`--name=value` and `--name value`), plus
82
+ * `extra` (such as a `userDataDir` handed over as a positional). A profile directory is listed as passed
83
+ * and as an absolute, normalised path. Feed the result to {@link redactLaunchSecrets} so a value is removed
84
+ * exactly, whatever it contains.
85
+ */
86
+ export function launchSecretValues(args, extra = [], env) {
87
+ const boundary = new Set();
88
+ const exact = new Set();
89
+ const add = (name, value) => {
90
+ if (name === "fingerprint-profile-file" || (name === "ant0-launch" && value.length >= MIN_EXACT_TICKET)) {
91
+ exact.add(value);
92
+ return;
93
+ }
94
+ boundary.add(value);
95
+ if (name === "user-data-dir" && value)
96
+ boundary.add(absolutePath(value));
97
+ };
98
+ const list = args.map((a) => String(a));
99
+ for (let i = 0; i < list.length; i++) {
100
+ for (const name of SECRET_ARG_SWITCHES) {
101
+ const flag = `--${name}`;
102
+ if (list[i].startsWith(`${flag}=`))
103
+ add(name, list[i].slice(flag.length + 1));
104
+ else if (list[i] === flag && i + 1 < list.length)
105
+ add(name, list[i + 1]);
106
+ }
107
+ }
108
+ for (const e of extra)
109
+ if (e)
110
+ add("user-data-dir", e);
111
+ // The same ticket also travels in ANT0_LAUNCH of the engine's environment: an exact secret like the argv one.
112
+ const fromEnv = env?.[LAUNCH_TICKET_ENV];
113
+ if (typeof fromEnv === "string" && fromEnv)
114
+ add(LAUNCH_TICKET_SWITCH, fromEnv);
115
+ const result = Object.freeze({ exact: Object.freeze([...exact]), boundary: Object.freeze([...boundary]) });
116
+ PRODUCED.add(result);
117
+ return result;
118
+ }
119
+ /** Each secret raw and JSON-escaped (backslashes doubled), without duplicates, longest first. */
120
+ function secretForms(secrets) {
121
+ const forms = new Set();
122
+ for (const v of secrets) {
123
+ if (typeof v !== "string" || v.length === 0)
124
+ continue;
125
+ forms.add(v);
126
+ forms.add(JSON.stringify(v).slice(1, -1));
127
+ }
128
+ return [...forms].sort((a, b) => b.length - a.length);
129
+ }
130
+ const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
131
+ const standaloneSecret = (v) => /[\\/]/.test(v) ? v.length >= MIN_STANDALONE_PATH : v.length >= MIN_STANDALONE_SECRET;
132
+ /**
133
+ * `text` with the launch secrets replaced. First by exact match of the `secrets` (the actual argv values, see
134
+ * {@link launchSecretValues}), only at an argument boundary: right after `--ant0-launch`, `--fingerprint-profile-file`
135
+ * or `--user-data-dir` (`=`, a space, a quote), or as a whole token for a long value or a path, and ending at a
136
+ * token boundary (so `data`, `exit` or `/tmp` do not mangle `--user-data-dir`, `exitCode` or `/tmp/eng/chrome`).
137
+ * The full known value is matched, so a path holding ` --x` goes whole, and quotes around it are kept. Then by
138
+ * the switch pattern, a second layer for values not passed in.
139
+ */
140
+ export function redactLaunchSecrets(text, secrets, options = {}) {
141
+ let out = String(text);
142
+ const { exact, boundary } = checkSecrets(secrets);
143
+ const forms = secretForms([...exact, ...boundary]);
144
+ if (forms.length > 0) {
145
+ const flags = (options.caseInsensitive ?? process.platform === "win32") ? "gi" : "g";
146
+ // Ticket and persona-file path: everywhere, no boundary, whatever surrounds them (quotes stay).
147
+ const loose = secretForms(exact.filter((v) => v.length >= MIN_STANDALONE_PATH)).map(escapeRegExp).join("|");
148
+ if (loose)
149
+ out = out.replace(new RegExp(loose, flags), "<redacted>");
150
+ const all = forms.map(escapeRegExp).join("|");
151
+ out = out.replace(new RegExp(`${SWITCH_PREFIX}(?:${all})${VALUE_END}`, flags), (_m, prefix) => `${prefix}<redacted>`);
152
+ const bare = forms.filter(standaloneSecret).map(escapeRegExp).join("|");
153
+ if (bare)
154
+ out = out.replace(new RegExp(`${VALUE_START}(?:${bare})${VALUE_END}`, flags), "<redacted>");
155
+ }
156
+ return out.replace(SECRET_SWITCH, "--$1=<redacted>");
157
+ }
158
+ /**
159
+ * `error` itself when nothing in it needs redacting, else a new Error of the same class carrying the redacted
160
+ * `message` and `stack`, the original `name` and own string/number properties (such as `code`), and no `cause`.
161
+ * The original object is not modified. Everything that can quote a command line goes through here.
162
+ */
163
+ export function redactError(error, secrets) {
164
+ checkSecrets(secrets);
165
+ if (!(error instanceof Error)) {
166
+ if (typeof error !== "string")
167
+ return error;
168
+ const clean = redactLaunchSecrets(error, secrets);
169
+ return clean === error ? error : clean;
170
+ }
171
+ const message = redactLaunchSecrets(error.message, secrets);
172
+ const stack = error.stack === undefined ? undefined : redactLaunchSecrets(error.stack, secrets);
173
+ const own = Object.getOwnPropertyNames(error).filter((k) => k !== "message" && k !== "stack" && k !== "cause");
174
+ const props = {};
175
+ // A child_process spawn error lists the whole argument vector (`spawnargs`): it is dropped.
176
+ // `spawnargs` lists the whole argument vector and `env` the whole environment (the ticket is in both): both are dropped.
177
+ let changed = "spawnargs" in error || "env" in error || message !== error.message || stack !== error.stack || error.cause !== undefined;
178
+ for (const k of own) {
179
+ const v = error[k];
180
+ if (typeof v === "string") {
181
+ const c = redactLaunchSecrets(v, secrets);
182
+ if (c !== v)
183
+ changed = true;
184
+ props[k] = c;
185
+ }
186
+ else if (typeof v === "number" || typeof v === "boolean")
187
+ props[k] = v;
188
+ }
189
+ if (!changed)
190
+ return error;
191
+ const fresh = Object.create(Object.getPrototypeOf(error));
192
+ Object.defineProperty(fresh, "message", { value: message, writable: true, configurable: true, enumerable: false });
193
+ Object.defineProperty(fresh, "stack", { value: stack, writable: true, configurable: true, enumerable: false });
194
+ for (const [k, v] of Object.entries(props))
195
+ Object.defineProperty(fresh, k, { value: v, writable: true, configurable: true, enumerable: true });
196
+ if (!own.includes("name") && error.name !== fresh.name)
197
+ Object.defineProperty(fresh, "name", { value: error.name, writable: true, configurable: true, enumerable: false });
198
+ return fresh;
199
+ }
200
+ /** A tail cut at a byte limit may start inside a switch and so hide its name from the redaction: drop the partial first line. */
201
+ export function dropPartialFirstLine(text, truncated) {
202
+ if (!truncated)
203
+ return text;
204
+ const i = text.indexOf("\n");
205
+ return i < 0 ? "" : text.slice(i + 1);
206
+ }
207
+ /** The engine exited with code 90 because its launch ticket was missing or invalid. */
208
+ export class LaunchTicketRejectedError extends Error {
209
+ reason;
210
+ code = LAUNCH_TICKET_REJECTED_CODE;
211
+ errorClass = "expected";
212
+ constructor(
213
+ /** The engine's reason: missing, malformed, unknown_kid, bad_signature, past_grace, bad_claim_signature, claim_mismatch, claim_expired, claim_stale (engine 949+), wrong_engine. */
214
+ reason, detail) {
215
+ super(`ant0-browser: the engine rejected its launch ticket (${reason}). ` +
216
+ (reason === "missing"
217
+ ? "Start it through ant0d, pass launchTicket, or run a daemon the SDK can reach (ANT0_URL / ANT0_HOME)."
218
+ : "Ask the daemon for a fresh ticket (GET /v1/licence/ticket) for this exact engine version.") +
219
+ (detail ? `\n${redactLaunchSecrets(detail)}` : ""));
220
+ this.reason = reason;
221
+ this.name = "LaunchTicketRejectedError";
222
+ }
223
+ }
224
+ /** The engine's reason if `text` (stderr, or an error message quoting it) contains the rejection line. */
225
+ export function launchTicketRejection(text) {
226
+ if (!text)
227
+ return undefined;
228
+ const m = STDERR_LINE.exec(text);
229
+ return m ? m[1] : undefined;
230
+ }
231
+ /**
232
+ * Rethrow a launch failure as the engine's own refusal when Playwright's message quotes it: the launch
233
+ * ticket (exit code 90, {@link LaunchTicketRejectedError}) or the persona file (exit code 91, the fatal line,
234
+ * {@link PersonaFileRejectedError}); otherwise rethrow as is. Playwright's message carries the exit code and
235
+ * the stderr lines; the process itself is not visible here. The new errors carry no `cause` and their detail
236
+ * is redacted: Playwright's message quotes the command line, ticket and persona-file path included.
237
+ */
238
+ export function rethrowIfTicketRejected(error, secrets) {
239
+ checkSecrets(secrets);
240
+ const text = error instanceof Error ? error.message : String(error);
241
+ const exitCode = playwrightExitCode(text);
242
+ const reason = launchTicketRejection(text) ?? (exitCode === LAUNCH_TICKET_EXIT_CODE ? "missing" : undefined);
243
+ if (reason)
244
+ throw new LaunchTicketRejectedError(reason, redactLaunchSecrets(`Playwright: ${text.split("\n")[0]}`, secrets));
245
+ const persona = personaFileRejection(text, exitCode);
246
+ if (persona)
247
+ throw new PersonaFileRejectedError(persona);
248
+ // Any other launch failure: Playwright's message and stack quote the command line too.
249
+ throw redactError(error, secrets);
250
+ }
251
+ /** Engine exit-90 reasons that mean "this ticket went stale before it was used": worth one fresh ticket. */
252
+ const RETRYABLE_TICKET_REASONS = new Set(["claim_expired", "claim_stale"]);
253
+ /** True when `ticketArgs` carry a ticket the SDK fetched from the daemon: not the caller's `launchTicket`, argv or `env` one. */
254
+ export function sdkFetchedTicket(launchTicket, ticketArgs) {
255
+ return typeof launchTicket !== "string" && launchTicket !== false && ticketArgs.length > 0;
256
+ }
257
+ /**
258
+ * Run a launch attempt; if the engine rejects the ticket as `claim_expired` or `claim_stale` and the SDK itself
259
+ * fetched that ticket, run it ONE more time (it fetches a fresh ticket right before the respawn). A caller's own
260
+ * ticket (the `launchTicket` option, an argv ticket, an explicit `env` one) and every other reason surface as is,
261
+ * and so does the second failure: there is never a third attempt.
262
+ */
263
+ export async function withTicketRetry(attempt) {
264
+ let fetchedBySdk = false;
265
+ try {
266
+ return await attempt((value) => { fetchedBySdk = value; });
267
+ }
268
+ catch (error) {
269
+ if (fetchedBySdk && error instanceof LaunchTicketRejectedError && RETRYABLE_TICKET_REASONS.has(error.reason)) {
270
+ return await attempt(() => { });
271
+ }
272
+ throw error;
273
+ }
274
+ }
275
+ /** True when the caller already put `--ant0-launch=` in the engine args. */
276
+ export function hasLaunchTicketArg(args) {
277
+ return args.some((a) => a === `--${LAUNCH_TICKET_SWITCH}` || a.startsWith(`--${LAUNCH_TICKET_SWITCH}=`));
278
+ }
279
+ const nonEmpty = (v) => (typeof v === "string" && v ? v : undefined);
280
+ /**
281
+ * The value of the last `--ant0-launch=<v>` in `args`, if any. The space form (`--ant0-launch <v>`) is not
282
+ * parsed: Chromium does not read it, so it is left to the engine like any other caller argument.
283
+ */
284
+ export function launchTicketArgValue(args) {
285
+ let found;
286
+ for (const a of args) {
287
+ const text = String(a);
288
+ if (text.startsWith(`--${LAUNCH_TICKET_SWITCH}=`))
289
+ found = nonEmpty(text.slice(LAUNCH_TICKET_SWITCH.length + 3));
290
+ }
291
+ return found;
292
+ }
293
+ /** The environment key that names the ticket: exact everywhere, case-insensitive on Windows. */
294
+ const isTicketKey = (key, windows) => (windows ? key.toUpperCase() === LAUNCH_TICKET_ENV : key === LAUNCH_TICKET_ENV);
295
+ /**
296
+ * The ticket the caller put in the `env` option they passed. An `ANT0_LAUNCH` in the SDK's own environment
297
+ * (`process.env`) is NOT the caller's ticket: it is inherited ambient state and is never read here.
298
+ */
299
+ export function callerEnvTicket(callerEnv, windows = process.platform === "win32") {
300
+ let found;
301
+ for (const [key, value] of Object.entries(callerEnv ?? {}))
302
+ if (isTicketKey(key, windows))
303
+ found = nonEmpty(value) ?? found;
304
+ return found;
305
+ }
306
+ /** `args` for the "did the caller already provide a ticket" decision: a ticket in the caller's `env` option counts like a caller's `--ant0-launch=`. */
307
+ export function argsForTicketDecision(args, callerEnv, windows = process.platform === "win32") {
308
+ const fromEnv = callerEnvTicket(callerEnv, windows);
309
+ if (!fromEnv || hasLaunchTicketArg(args ?? []))
310
+ return args;
311
+ return [...(args ?? []), `--${LAUNCH_TICKET_SWITCH}=${fromEnv}`];
312
+ }
313
+ /**
314
+ * Put the launch ticket in both places the engine reads it, with the same value: `--ant0-launch=<t>` in the
315
+ * args (all engines) and `ANT0_LAUNCH=<t>` in the ENGINE CHILD's environment (engine patch 949 and later; the
316
+ * engine reads the environment first).
317
+ *
318
+ * `env` is the child's environment as built so far (undefined: inherited from `process.env`); `callerEnv` is
319
+ * the `env` option the caller passed, if any. The result's env is ALWAYS a fresh copy (`process.env` itself is
320
+ * never written) and an `ANT0_LAUNCH` that was merely inherited never reaches the engine:
321
+ * - the caller put a ticket in `callerEnv`: nothing is overwritten and nothing is refused. If the args hold
322
+ * one too, both stay as they are; otherwise the env value is mirrored into the args;
323
+ * - otherwise the env value is the resolved argv ticket, or the key is deleted when there is none.
324
+ * On Windows the key is matched case-insensitively, so the copy never holds two spellings of it.
325
+ */
326
+ export function applyTicketEnv(args, env, callerEnv, windows = process.platform === "win32") {
327
+ const inArgs = launchTicketArgValue(args);
328
+ const inCaller = callerEnvTicket(callerEnv, windows);
329
+ const child = {};
330
+ for (const [key, value] of Object.entries(env ?? process.env))
331
+ if (!isTicketKey(key, windows))
332
+ child[key] = value;
333
+ const outArgs = [...args];
334
+ const ticket = inCaller ?? inArgs;
335
+ if (inCaller && !inArgs)
336
+ outArgs.push(`--${LAUNCH_TICKET_SWITCH}=${inCaller}`);
337
+ if (ticket)
338
+ child[LAUNCH_TICKET_ENV] = ticket;
339
+ return { args: outArgs, env: child };
340
+ }
341
+ /**
342
+ * The release version an installed engine identifies as: `.release.json` next to its `browser/`
343
+ * directory (what the SDK's installer and ant0d write), else a `<version>` path component, else
344
+ * `ANT0_BROWSER_ENGINE_VERSION`. Undefined for a bare binary (tests, hand-built trees).
345
+ */
346
+ export function inferEngineVersion(executable, env = process.env) {
347
+ let dir = dirname(executable);
348
+ for (let depth = 0; depth < 6; depth++) {
349
+ const file = join(dir, ".release.json");
350
+ if (existsSync(file)) {
351
+ try {
352
+ const version = JSON.parse(readFileSync(file, "utf8")).version;
353
+ if (typeof version === "string" && RELEASE_VERSION.test(version))
354
+ return version;
355
+ }
356
+ catch {
357
+ /* fall through to the path heuristics */
358
+ }
359
+ }
360
+ if (RELEASE_VERSION.test(basename(dir)))
361
+ return basename(dir);
362
+ const parent = dirname(dir);
363
+ if (parent === dir)
364
+ break;
365
+ dir = parent;
366
+ }
367
+ const fromEnv = env[ENGINE_VERSION_ENV]?.trim();
368
+ return fromEnv && RELEASE_VERSION.test(fromEnv) ? fromEnv : undefined;
369
+ }
370
+ /**
371
+ * STRICT engine version for security gates (such as `--webrtc-ip`): only the release record the
372
+ * installer wrote for THIS executable counts. The executable's own directory and each parent up to
373
+ * and including the install's `browser/` directory are not searched for anything but that record,
374
+ * which must sit in the install base directly above `browser/`. A path component, an environment
375
+ * variable or a `.release.json` in some far ancestor is not evidence about this binary, so those give
376
+ * undefined (treated as an old engine). {@link inferEngineVersion} stays as is for the ticket.
377
+ * `allowDev` also returns a development build's `<chromium>-ant0.dev` label (advisory warnings
378
+ * only, never a gate).
379
+ */
380
+ export function installedEngineVersion(executable, allowDev = false) {
381
+ let dir;
382
+ try {
383
+ dir = dirname(realpathSync(executable));
384
+ }
385
+ catch {
386
+ return undefined;
387
+ }
388
+ for (let depth = 0; depth < 4; depth++) {
389
+ if (basename(dir) === "browser") {
390
+ const file = join(dirname(dir), ".release.json");
391
+ try {
392
+ const version = JSON.parse(readFileSync(file, "utf8")).version;
393
+ return typeof version === "string" && (RELEASE_VERSION.test(version) || (allowDev && DEV_VERSION.test(version))) ? version : undefined;
394
+ }
395
+ catch {
396
+ return undefined;
397
+ }
398
+ }
399
+ const parent = dirname(dir);
400
+ if (parent === dir)
401
+ break;
402
+ dir = parent;
403
+ }
404
+ return undefined;
405
+ }
406
+ function isLoopback(host) {
407
+ const h = host.replace(/^\[|\]$/g, "").toLowerCase();
408
+ return h === "localhost" || h === "::1" || h.startsWith("127.");
409
+ }
410
+ function homeExists(dir) {
411
+ return existsSync(join(dir, "ant0.db")) || existsSync(join(dir, "profiles"));
412
+ }
413
+ function readToken(file) {
414
+ try {
415
+ const token = readFileSync(file, "utf8").trim();
416
+ return token.length > 0 ? token : undefined;
417
+ }
418
+ catch {
419
+ return undefined;
420
+ }
421
+ }
422
+ /** The data folder, as ant0d/CLI resolve it (explicit env, platform default, legacy `~/.ant0`). */
423
+ export function resolveDaemonHome(env = process.env, platform = process.platform, userHome = homedir()) {
424
+ const explicit = env.ANT0_HOME?.trim();
425
+ if (explicit)
426
+ return explicit;
427
+ const p = platform === "win32" ? win32 : posix;
428
+ let def;
429
+ if (platform === "win32") {
430
+ def = env.LOCALAPPDATA ? win32.join(env.LOCALAPPDATA, "Ant0") : win32.join(userHome, "AppData", "Local", "Ant0");
431
+ }
432
+ else if (platform === "darwin") {
433
+ def = posix.join(userHome, "Library", "Application Support", "Ant0");
434
+ }
435
+ else {
436
+ def = env.XDG_DATA_HOME ? posix.join(env.XDG_DATA_HOME, "ant0") : posix.join(userHome, ".local", "share", "ant0");
437
+ }
438
+ const legacy = p.join(userHome, ".ant0");
439
+ return !homeExists(def) && homeExists(legacy) ? legacy : def;
440
+ }
441
+ /** Where a running daemon is, or undefined when there is no token to send (= not running). */
442
+ export function discoverDaemon(env = process.env, platform = process.platform, userHome = homedir()) {
443
+ const home = resolveDaemonHome(env, platform, userHome);
444
+ const token = env.ANT0_TOKEN?.trim() || readToken(join(home, "ant0d.token"));
445
+ if (!token)
446
+ return undefined;
447
+ const url = env.ANT0_URL?.trim();
448
+ if (url)
449
+ return { baseUrl: url.replace(/\/+$/, ""), token };
450
+ let host;
451
+ let port;
452
+ try {
453
+ const pid = JSON.parse(readFileSync(join(home, "ant0d.pid"), "utf8"));
454
+ if (typeof pid.port === "number" && Number.isInteger(pid.port) && pid.port > 0 && pid.port <= 65535)
455
+ port = pid.port;
456
+ if (typeof pid.host === "string" && pid.host.length > 0 && isLoopback(pid.host))
457
+ host = pid.host;
458
+ }
459
+ catch {
460
+ /* no pid file: fall back to the environment */
461
+ }
462
+ const envPort = Number(env.ANT0D_PORT);
463
+ port ??= Number.isInteger(envPort) && envPort > 0 && envPort <= 65535 ? envPort : DEFAULT_PORT;
464
+ host ??= env.ANT0D_HOST && isLoopback(env.ANT0D_HOST) ? env.ANT0D_HOST : DEFAULT_HOST;
465
+ const h = host.includes(":") && !host.startsWith("[") ? `[${host}]` : host;
466
+ return { baseUrl: `http://${h}:${port}`, token };
467
+ }
468
+ const DAEMON_CODE = /^(?:(?:licence|workspace|browser|ticket|runtime|auth|device)\.[a-z][a-z0-9_]{0,40}|http_[1-5][0-9]{2}|bad_response)$/;
469
+ /** Thrown by {@link fetchLaunchTicket} when the daemon answers but will not issue a ticket. */
470
+ export class LaunchTicketUnavailableError extends Error {
471
+ code;
472
+ errorClass;
473
+ constructor(
474
+ /** Daemon error code, e.g. `licence.required`, `workspace.suspended`, or `http_<status>`. */
475
+ code, message) {
476
+ super(`ant0-browser: the daemon did not issue a launch ticket (${code}): ${message}`);
477
+ this.code = code;
478
+ this.name = "LaunchTicketUnavailableError";
479
+ this.errorClass = /^(licence|workspace)\./.test(code) ? "expected" : "environment";
480
+ }
481
+ /** The daemon's code when it has a known shape, else a fixed code. Safe to report. */
482
+ get reportCode() {
483
+ return DAEMON_CODE.test(this.code) ? this.code : "sdk.launch_ticket_unavailable";
484
+ }
485
+ }
486
+ /** `GET /v1/licence/ticket?engine=<engine>` with the daemon token; resolves to the `launch` value. */
487
+ export async function fetchLaunchTicket(engine, daemon, opts = {}) {
488
+ const doFetch = opts.fetchImpl ?? fetch;
489
+ const controller = new AbortController();
490
+ const timer = setTimeout(() => controller.abort(), opts.timeoutMs ?? DEFAULT_TIMEOUT_MS);
491
+ try {
492
+ const res = await doFetch(`${daemon.baseUrl}/v1/licence/ticket?engine=${encodeURIComponent(engine)}`, {
493
+ headers: { Authorization: `Bearer ${daemon.token}`, Accept: "application/json" },
494
+ signal: controller.signal,
495
+ });
496
+ const body = (await res.json().catch(() => undefined));
497
+ if (!res.ok) {
498
+ const code = typeof body?.error?.code === "string" ? body.error.code : `http_${res.status}`;
499
+ const message = typeof body?.error?.message === "string" ? body.error.message : res.statusText;
500
+ throw new LaunchTicketUnavailableError(code, message);
501
+ }
502
+ if (typeof body?.launch !== "string" || body.launch.split(".").length !== 5) {
503
+ throw new LaunchTicketUnavailableError("bad_response", "response has no five-segment `launch`");
504
+ }
505
+ return body.launch;
506
+ }
507
+ finally {
508
+ clearTimeout(timer);
509
+ }
510
+ }
511
+ /**
512
+ * The `--ant0-launch=` arg to append: the caller's ticket, or one fetched from the local daemon for
513
+ * the engine's release version. Empty when the caller disabled it, already passed the switch, no
514
+ * version can be inferred, no daemon is reachable, or the daemon refused (a note goes to stderr
515
+ * unless `quiet`; the engine's own exit-90 then names the outcome).
516
+ */
517
+ export async function resolveLaunchTicketArgs(opts) {
518
+ if (opts.launchTicket === false || hasLaunchTicketArg(opts.args))
519
+ return [];
520
+ if (typeof opts.launchTicket === "string") {
521
+ if (opts.launchTicket.split(".").length !== 5) {
522
+ throw new SdkTypeError("sdk.launch_ticket_invalid", "launchTicket must be the five-segment `lic.claim.csig` value the daemon issues");
523
+ }
524
+ return [`--${LAUNCH_TICKET_SWITCH}=${opts.launchTicket}`];
525
+ }
526
+ const env = opts.env ?? process.env;
527
+ const note = (msg) => {
528
+ if (!opts.quiet && env.ANT0_BROWSER_NO_WARN === undefined)
529
+ process.stderr.write(`[ant0-browser] [launch-ticket] ${msg}\n`);
530
+ };
531
+ const engine = opts.engineVersion ?? inferEngineVersion(opts.executable, env);
532
+ if (!engine)
533
+ return []; // bare binary: nothing to bind a ticket to (tests, hand-built trees)
534
+ const daemon = discoverDaemon(env);
535
+ if (!daemon) {
536
+ note(`no ant0d found (no token under ${resolveDaemonHome(env)}); launching ${engine} without a ticket`);
537
+ return [];
538
+ }
539
+ try {
540
+ const launch = await fetchLaunchTicket(engine, daemon, { fetchImpl: opts.fetchImpl, timeoutMs: opts.timeoutMs });
541
+ return [`--${LAUNCH_TICKET_SWITCH}=${launch}`];
542
+ }
543
+ catch (error) {
544
+ const why = error instanceof LaunchTicketUnavailableError ? error.code : error?.name === "AbortError" ? "timeout" : String(error);
545
+ note(`${daemon.baseUrl} issued no ticket for ${engine} (${why}); launching without one`);
546
+ return [];
547
+ }
548
+ }
549
+ //# sourceMappingURL=launch-ticket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