slybrowser 0.1.0

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 (62) hide show
  1. package/README.md +146 -0
  2. package/dist/automation.d.ts +15 -0
  3. package/dist/automation.d.ts.map +1 -0
  4. package/dist/automation.js +69 -0
  5. package/dist/automation.js.map +1 -0
  6. package/dist/browser.d.ts +31 -0
  7. package/dist/browser.d.ts.map +1 -0
  8. package/dist/browser.js +203 -0
  9. package/dist/browser.js.map +1 -0
  10. package/dist/canonical.d.ts +4 -0
  11. package/dist/canonical.d.ts.map +1 -0
  12. package/dist/canonical.js +42 -0
  13. package/dist/canonical.js.map +1 -0
  14. package/dist/cdp.d.ts +21 -0
  15. package/dist/cdp.d.ts.map +1 -0
  16. package/dist/cdp.js +139 -0
  17. package/dist/cdp.js.map +1 -0
  18. package/dist/cli.d.ts +19 -0
  19. package/dist/cli.d.ts.map +1 -0
  20. package/dist/cli.js +241 -0
  21. package/dist/cli.js.map +1 -0
  22. package/dist/errors.d.ts +21 -0
  23. package/dist/errors.d.ts.map +1 -0
  24. package/dist/errors.js +113 -0
  25. package/dist/errors.js.map +1 -0
  26. package/dist/humanize.d.ts +23 -0
  27. package/dist/humanize.d.ts.map +1 -0
  28. package/dist/humanize.js +247 -0
  29. package/dist/humanize.js.map +1 -0
  30. package/dist/index.d.ts +13 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +13 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/installer.d.ts +43 -0
  35. package/dist/installer.d.ts.map +1 -0
  36. package/dist/installer.js +669 -0
  37. package/dist/installer.js.map +1 -0
  38. package/dist/launcher.d.ts +38 -0
  39. package/dist/launcher.d.ts.map +1 -0
  40. package/dist/launcher.js +325 -0
  41. package/dist/launcher.js.map +1 -0
  42. package/dist/license.d.ts +76 -0
  43. package/dist/license.d.ts.map +1 -0
  44. package/dist/license.js +329 -0
  45. package/dist/license.js.map +1 -0
  46. package/dist/licensed.d.ts +82 -0
  47. package/dist/licensed.d.ts.map +1 -0
  48. package/dist/licensed.js +513 -0
  49. package/dist/licensed.js.map +1 -0
  50. package/dist/manifest.d.ts +66 -0
  51. package/dist/manifest.d.ts.map +1 -0
  52. package/dist/manifest.js +292 -0
  53. package/dist/manifest.js.map +1 -0
  54. package/dist/service.d.ts +206 -0
  55. package/dist/service.d.ts.map +1 -0
  56. package/dist/service.js +1271 -0
  57. package/dist/service.js.map +1 -0
  58. package/dist/webdriver.d.ts +208 -0
  59. package/dist/webdriver.d.ts.map +1 -0
  60. package/dist/webdriver.js +592 -0
  61. package/dist/webdriver.js.map +1 -0
  62. package/package.json +78 -0
package/README.md ADDED
@@ -0,0 +1,146 @@
1
+ # SlyBrowser for JavaScript
2
+
3
+ `launch()` starts the project-built W3C WebDriver shipped beside SlyBrowser. It never
4
+ uses Selenium Manager, downloads a driver, or searches for a system Chrome.
5
+
6
+ ```ts
7
+ import { launch } from "slybrowser";
8
+
9
+ await using browser = await launch(browserExecutable, shortLivedLease, {
10
+ humanize: true,
11
+ });
12
+ await browser.get("https://example.test");
13
+ console.log(await browser.title());
14
+ ```
15
+
16
+ Set `driverExecutable` or `SLYBROWSER_WEBDRIVER_PATH` only when the driver is not
17
+ beside the browser during development. Production packages require the exact
18
+ hash-matched browser and driver as sibling files. Browser and driver major versions
19
+ must match, and each process consumes a separate temporary copy of the short-lived
20
+ signed lease. Humanize for this default path executes natively in Sly WebDriver;
21
+ Playwright and Puppeteer remain optional through their explicitly named launch adapters.
22
+
23
+ ## Playwright and Puppeteer adapters
24
+
25
+ Both adapters force the supplied SlyBrowser executable and validate the installed
26
+ framework binding line. They never use a framework-downloaded browser or a system
27
+ Chrome fallback.
28
+
29
+ ```ts
30
+ import { chromium } from "playwright-core";
31
+ import puppeteer from "puppeteer-core";
32
+ import { launchPlaywright, launchPuppeteer } from "slybrowser";
33
+
34
+ const browser = await launchPlaywright(
35
+ { chromium }, browserExecutable, shortLivedLease,
36
+ { frameworkVersion: "1.62.1" },
37
+ );
38
+
39
+ const puppeteerBrowser = await launchPuppeteer(
40
+ puppeteer, browserExecutable, shortLivedLease,
41
+ { frameworkVersion: "25.8.0" },
42
+ );
43
+ ```
44
+
45
+ Use `launchPlaywrightPersistent` or `launchPuppeteerPersistent` for persistent
46
+ profiles. When `humanize: true` is set, the SDK writes a short-lived
47
+ `--sly-humanize-config` native control file for the browser process. The SDK does not
48
+ install a Playwright/Puppeteer-side movement substitute; unsupported browser builds
49
+ must fail closed at the native capability gate.
50
+
51
+ ## Install and launch the latest authorized release
52
+
53
+ Current release archives use 7z. Install `7z` (or `7zz` on Unix-like systems), or set `SLYBROWSER_7Z_PATH` to the executable before using the automatic installer.
54
+
55
+ The license service returns a signed short lease and the signed newest compatible
56
+ Stable manifest. The SDK then downloads the protected ZIP, verifies the archive plus
57
+ the exact browser/WebDriver hashes, safely caches it and enforces the plan's one-session-
58
+ per-browser-process limit.
59
+
60
+ ```ts
61
+ import { chromium } from "playwright-core";
62
+ import puppeteer from "puppeteer-core";
63
+ import { launchLatest, launchLatestPlaywright, launchLatestPuppeteer } from "slybrowser";
64
+
65
+ await using browser = await launchLatest("account.authorization.json", {
66
+ trust: {
67
+ licenseTrustedKeys: { "license-prod-v1": licensePublicKey },
68
+ releaseTrustedKeys: { "release-prod-v1": releasePublicKey },
69
+ },
70
+ humanize: true,
71
+ });
72
+
73
+ console.log(browser.licenseRuntime); // plan, limit, version and session ID
74
+ await browser.get("https://example.test");
75
+
76
+ const playwrightBrowser = await launchLatestPlaywright(
77
+ { chromium }, "account.authorization.json", {
78
+ trust: {
79
+ licenseTrustedKeys: { "license-prod-v1": licensePublicKey },
80
+ releaseTrustedKeys: { "release-prod-v1": releasePublicKey },
81
+ },
82
+ frameworkVersion: "1.62.1",
83
+ },
84
+ );
85
+
86
+ const puppeteerBrowser = await launchLatestPuppeteer(
87
+ puppeteer, "account.authorization.json", {
88
+ trust: {
89
+ licenseTrustedKeys: { "license-prod-v1": licensePublicKey },
90
+ releaseTrustedKeys: { "release-prod-v1": releasePublicKey },
91
+ },
92
+ frameworkVersion: "25.8.0",
93
+ },
94
+ );
95
+ ```
96
+
97
+ The authorized framework launchers reserve and release the same concurrency slot as
98
+ `launchLatest(...)`, expose `licenseRuntime.versionAudit`, and fail closed if the
99
+ framework reports a launched browser version that does not exactly match the signed
100
+ selected release. Persistent profile variants are available as
101
+ `launchLatestPlaywrightPersistent` and `launchLatestPuppeteerPersistent`.
102
+
103
+ The public keys are raw 32-byte Ed25519 keys. The CLI accepts them as base64url JSON in
104
+ `SLYBROWSER_LICENSE_PUBLIC_KEYS_JSON` and `SLYBROWSER_RELEASE_PUBLIC_KEYS_JSON`:
105
+
106
+ ```text
107
+ slybrowser install --authorization account.authorization.json [--cache DIR] [--kernel-major 150|latest] [--update-kernel]
108
+ ```
109
+
110
+ ## Import a paid license file on Windows
111
+
112
+ After checkout, the billing email delivers an encrypted v2 license file. Import it
113
+ once on the Windows machine that will run SlyBrowser:
114
+
115
+ ```text
116
+ set SLYBROWSER_LICENSE_FILE_PUBLIC_KEYS_JSON={"license-file-prod-v1":"BASE64URL_RAW_ED25519_PUBLIC_KEY"}
117
+ slybrowser license import --input account.slybrowser-license.json --output account.slybrowser-sealed-license.json --passphrase YOUR_PASSPHRASE
118
+ ```
119
+
120
+ The sealed output uses Windows DPAPI current-user protection. It can be passed to
121
+ the same `--authorization` option and to `launchLatest(...)`/Playwright/Puppeteer
122
+ authorized launchers without providing the license-file passphrase again. The sealed
123
+ file still grants access on that Windows account, so do not commit, log, or share it.
124
+
125
+ ## Redacted license diagnostics
126
+
127
+ Use `license info` when a customer needs support without exposing their credential:
128
+
129
+ ```text
130
+ slybrowser license info --authorization account.slybrowser-sealed-license.json [--kernel-major 150|latest] [--update-kernel]
131
+ ```
132
+
133
+ The command contacts the authorization service through `Authorization: License ...`
134
+ and prints only redacted diagnostics: plan, effective plan, paid-through time,
135
+ feature set, active/available browser-process concurrency, selected release state,
136
+ update availability and `stableErrorCode`. It does not print the license key,
137
+ session tokens, download tickets, email, PayNow identifiers, profile paths or service
138
+ access URL.
139
+
140
+ Without `--update-kernel`, the CLI keeps updates closed: it reuses the current
141
+ authorized local candidate when one exists and asks the service for an exact grant.
142
+ Use `--update-kernel` to actively move to the newest authorized Stable release in
143
+ the selected major range.
144
+
145
+ Do not commit or log the authorization file. See
146
+ `docs/authorized-release-service.md` for the server and release workflow.
@@ -0,0 +1,15 @@
1
+ export type AutomationBackend = "project-webdriver" | "playwright" | "puppeteer";
2
+ export type FrameworkBackend = Exclude<AutomationBackend, "project-webdriver">;
3
+ export interface AutomationCapability {
4
+ backend: AutomationBackend;
5
+ language: "node";
6
+ frameworkVersion?: string;
7
+ nativeHumanize: boolean;
8
+ persistentContext: boolean;
9
+ }
10
+ export declare function validateFrameworkVersion(backend: FrameworkBackend, version: string): string;
11
+ export declare function installedFrameworkVersion(backend: FrameworkBackend): string;
12
+ export declare function resolveFrameworkVersion(backend: FrameworkBackend, explicit?: string): string;
13
+ export declare function automationCapability(backend?: AutomationBackend, frameworkVersion?: string): AutomationCapability;
14
+ export declare function requireFrameworkHumanizeSupport(backend: FrameworkBackend, requested: boolean | undefined): void;
15
+ //# sourceMappingURL=automation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automation.d.ts","sourceRoot":"","sources":["../src/automation.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG,YAAY,GAAG,WAAW,CAAC;AACjF,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,iBAAiB,EAAE,mBAAmB,CAAC,CAAC;AAE/E,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAkBD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAS3F;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAe3E;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAI5F;AAED,wBAAgB,oBAAoB,CAClC,OAAO,GAAE,iBAAuC,EAChD,gBAAgB,CAAC,EAAE,MAAM,GACxB,oBAAoB,CAmBtB;AAED,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,GAAG,IAAI,CAG/G"}
@@ -0,0 +1,69 @@
1
+ import { createRequire } from "node:module";
2
+ import { ConfigurationError } from "./errors.js";
3
+ const SUPPORTED_LINES = Object.freeze({
4
+ playwright: Object.freeze(["1.62"]),
5
+ puppeteer: Object.freeze(["25"]),
6
+ });
7
+ const PACKAGE_CANDIDATES = Object.freeze({
8
+ playwright: Object.freeze(["playwright-core", "playwright"]),
9
+ puppeteer: Object.freeze(["puppeteer-core", "puppeteer"]),
10
+ });
11
+ function versionLine(version) {
12
+ const match = version.match(/^(\d+)\.(\d+)(?:\.\d+)?(?:[-+][0-9A-Za-z.-]+)?$/);
13
+ if (!match)
14
+ throw new ConfigurationError(`Invalid framework version: ${version}`, "framework_version_invalid");
15
+ return match[1] === "1" ? `${match[1]}.${match[2]}` : match[1];
16
+ }
17
+ export function validateFrameworkVersion(backend, version) {
18
+ const line = versionLine(version);
19
+ if (!SUPPORTED_LINES[backend].includes(line)) {
20
+ throw new ConfigurationError(`Unsupported ${backend} version ${version}; supported lines: ${SUPPORTED_LINES[backend].join(", ")}`, "framework_version_unsupported");
21
+ }
22
+ return version;
23
+ }
24
+ export function installedFrameworkVersion(backend) {
25
+ const require = createRequire(import.meta.url);
26
+ for (const packageName of PACKAGE_CANDIDATES[backend]) {
27
+ try {
28
+ const metadata = require(`${packageName}/package.json`);
29
+ if (typeof metadata.version === "string")
30
+ return validateFrameworkVersion(backend, metadata.version);
31
+ }
32
+ catch (error) {
33
+ const code = error.code;
34
+ if (code !== "MODULE_NOT_FOUND" && code !== "ERR_PACKAGE_PATH_NOT_EXPORTED")
35
+ throw error;
36
+ }
37
+ }
38
+ throw new ConfigurationError(`Unable to determine the installed ${backend} package version; pass frameworkVersion explicitly`, "framework_version_missing");
39
+ }
40
+ export function resolveFrameworkVersion(backend, explicit) {
41
+ return explicit === undefined
42
+ ? installedFrameworkVersion(backend)
43
+ : validateFrameworkVersion(backend, explicit);
44
+ }
45
+ export function automationCapability(backend = "project-webdriver", frameworkVersion) {
46
+ if (backend === "project-webdriver") {
47
+ if (frameworkVersion !== undefined) {
48
+ throw new ConfigurationError("Project WebDriver does not accept frameworkVersion", "framework_version_forbidden");
49
+ }
50
+ return {
51
+ backend,
52
+ language: "node",
53
+ nativeHumanize: true,
54
+ persistentContext: true,
55
+ };
56
+ }
57
+ return {
58
+ backend,
59
+ language: "node",
60
+ frameworkVersion: resolveFrameworkVersion(backend, frameworkVersion),
61
+ nativeHumanize: true,
62
+ persistentContext: true,
63
+ };
64
+ }
65
+ export function requireFrameworkHumanizeSupport(backend, requested) {
66
+ void backend;
67
+ void requested;
68
+ }
69
+ //# sourceMappingURL=automation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automation.js","sourceRoot":"","sources":["../src/automation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAajD,MAAM,eAAe,GAA0D,MAAM,CAAC,MAAM,CAAC;IAC3F,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;CACjC,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAA0D,MAA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8B;IACvG,KAAK,OAAO,CAAC;IACb,KAAK,SAAS,CAAC;AACjB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { type HumanConfig, type HumanPreset } from "./humanize.js";
2
+ export interface ChromiumLauncherLike<TBrowser = unknown, TContext = unknown> {
3
+ launch(options: Record<string, unknown>): Promise<TBrowser>;
4
+ launchPersistentContext(userDataDir: string, options: Record<string, unknown>): Promise<TContext>;
5
+ }
6
+ export interface PlaywrightLike<TBrowser = unknown, TContext = unknown> {
7
+ chromium: ChromiumLauncherLike<TBrowser, TContext>;
8
+ }
9
+ export interface PuppeteerLike<TBrowser = unknown> {
10
+ launch(options: Record<string, unknown>): Promise<TBrowser>;
11
+ }
12
+ export interface FrameworkLaunchSettings {
13
+ profile?: Record<string, unknown>;
14
+ launchOptions?: Record<string, unknown>;
15
+ tempRoot?: string;
16
+ nativeReady?: boolean;
17
+ nativeReadyTimeout?: number;
18
+ humanize?: boolean;
19
+ humanPreset?: HumanPreset;
20
+ humanConfig?: Partial<HumanConfig>;
21
+ humanSeed?: number;
22
+ frameworkVersion?: string;
23
+ runtimeHandoff?: Record<string, unknown>;
24
+ allowRuntimeActivationTicket?: boolean;
25
+ releaseRoot?: string;
26
+ }
27
+ export declare function launchPlaywright<TBrowser>(playwright: PlaywrightLike<TBrowser>, executable: string, lease: string | Buffer | Record<string, unknown>, settings?: FrameworkLaunchSettings): Promise<TBrowser>;
28
+ export declare function launchPlaywrightPersistent<TContext>(playwright: PlaywrightLike<unknown, TContext>, userDataDir: string, executable: string, lease: string | Buffer | Record<string, unknown>, settings?: FrameworkLaunchSettings): Promise<TContext>;
29
+ export declare function launchPuppeteer<TBrowser>(puppeteer: PuppeteerLike<TBrowser>, executable: string, lease: string | Buffer | Record<string, unknown>, settings?: FrameworkLaunchSettings): Promise<TBrowser>;
30
+ export declare function launchPuppeteerPersistent<TBrowser>(puppeteer: PuppeteerLike<TBrowser>, userDataDir: string, executable: string, lease: string | Buffer | Record<string, unknown>, settings?: Framewor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E,uBAA4B,GACrC,OAAO,CAAC,QAAQ,CAAC,CAcnB"}
@@ -0,0 +1,203 @@
1
+ import { dirname, resolve } from "node:path";
2
+ import { requireFrameworkHumanizeSupport, resolveFrameworkVersion, } from "./automation.js";
3
+ import { ConfigurationError } from "./errors.js";
4
+ import { prepareLaunch } from "./launcher.js";
5
+ import { resolveHumanConfig } from "./humanize.js";
6
+ function jsonObject(value) {
7
+ return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
8
+ }
9
+ function parseSignedLeaseClaims(lease) {
10
+ try {
11
+ const envelope = typeof lease === "string"
12
+ ? JSON.parse(lease)
13
+ : Buffer.isBuffer(lease)
14
+ ? JSON.parse(lease.toString("utf8"))
15
+ : lease;
16
+ const payload = jsonObject(envelope)?.payload;
17
+ if (typeof payload !== "string" || payload.length === 0)
18
+ return undefined;
19
+ return jsonObject(JSON.parse(Buffer.from(payload, "base64url").toString("utf8")));
20
+ }
21
+ catch (error) {
22
+ return undefined;
23
+ }
24
+ }
25
+ function deriveReleaseRoot(browserExecutable, artifactBrowserExecutable) {
26
+ if (typeof artifactBrowserExecutable !== "string" || !artifactBrowserExecutable.trim())
27
+ return undefined;
28
+ const expectedParts = artifactBrowserExecutable.replaceAll("\\", "/").split("/").filter(Boolean);
29
+ if (expectedParts.length === 0)
30
+ return undefined;
31
+ const actualPath = resolve(browserExecutable);
32
+ const actualParts = actualPath.replaceAll("\\", "/").split("/").filter(Boolean);
33
+ if (actualParts.length < expectedParts.length)
34
+ return undefined;
35
+ const actualSuffix = actualParts.slice(-expectedParts.length);
36
+ const matches = expectedParts.every((part, index) => {
37
+ const actualPart = actualSuffix[index];
38
+ return typeof actualPart === "string" && part.toLowerCase() === actualPart.toLowerCase();
39
+ });
40
+ if (!matches)
41
+ return undefined;
42
+ let releaseRoot = actualPath;
43
+ for (let index = 0; index < expectedParts.length; ++index) {
44
+ releaseRoot = dirname(releaseRoot);
45
+ }
46
+ return releaseRoot;
47
+ }
48
+ function releaseRootFromLease(browserExecutable, lease) {
49
+ const claims = parseSignedLeaseClaims(lease);
50
+ const artifact = jsonObject(claims?.artifact);
51
+ return deriveReleaseRoot(browserExecutable, artifact?.browserExecutable);
52
+ }
53
+ function validateFrameworkSettings(backend, settings) {
54
+ resolveFrameworkVersion(backend, settings.frameworkVersion);
55
+ requireFrameworkHumanizeSupport(backend, settings.humanize);
56
+ if (settings.nativeReady === true &&
57
+ settings.nativeReadyTimeout !== undefined &&
58
+ (!Number.isFinite(settings.nativeReadyTimeout) || settings.nativeReadyTimeout < 1)) {
59
+ throw new ConfigurationError("nativeReadyTimeout must be a positive number of milliseconds", "config_invalid");
60
+ }
61
+ }
62
+ function nativeHumanizeControl(backend, settings) {
63
+ if (settings.humanize !== true)
64
+ return undefined;
65
+ if (settings.humanSeed !== undefined &&
66
+ (!Number.isInteger(settings.humanSeed) || settings.humanSeed < 0)) {
67
+ throw new ConfigurationError("Native Humanize seed must be a non-negative integer", "humanize_seed_invalid");
68
+ }
69
+ const preset = settings.humanPreset ?? "default";
70
+ return {
71
+ schemaVersion: 1,
72
+ kind: "slybrowser.native-humanize-control",
73
+ backend,
74
+ humanize: {
75
+ enabled: true,
76
+ version: 1,
77
+ preset,
78
+ config: resolveHumanConfig({
79
+ preset,
80
+ ...(settings.humanConfig === undefined ? {} : { config: settings.humanConfig }),
81
+ }),
82
+ ...(settings.humanSeed === undefined ? {} : { seed: settings.humanSeed }),
83
+ },
84
+ };
85
+ }
86
+ function mergeLaunchOptions(launchOptions, executable, handoffArguments) {
87
+ const result = { ...(launchOptions ?? {}) };
88
+ if ("executablePath" in result || "executable_path" in result) {
89
+ throw new ConfigurationError("The browser executable must be passed to the SlyBrowser adapter", "executable_option_conflict");
90
+ }
91
+ const existingArguments = result.args ?? [];
92
+ if (!Array.isArray(existingArguments) || existingArguments.some((argument) => typeof argument !== "string")) {
93
+ throw new ConfigurationError("Framework args must be a string array", "config_invalid");
94
+ }
95
+ return {
96
+ ...result,
97
+ executablePath: executable,
98
+ args: [...handoffArguments, ...existingArguments],
99
+ };
100
+ }
101
+ function nativeReadyTimeout(settings) {
102
+ return settings.nativeReady === true ? settings.nativeReadyTimeout ?? 15_000 : undefined;
103
+ }
104
+ async function closeFrameworkRuntime(runtime) {
105
+ const candidate = runtime;
106
+ if (typeof candidate?.close !== "function")
107
+ return;
108
+ await Promise.resolve(candidate.close.call(runtime)).catch(() => undefined);
109
+ }
110
+ export async function launchPlaywright(playwright, executable, lease, settings = {}) {
111
+ validateFrameworkSettings("playwright", settings);
112
+ const readyTimeout = nativeReadyTimeout(settings);
113
+ const plan = await prepareLaunch(executable, settings.profile ?? {}, lease, {
114
+ tempRoot: settings.tempRoot,
115
+ runtimeHandoff: settings.runtimeHandoff,
116
+ allowRuntimeActivationTicket: settings.allowRuntimeActivationTicket === true,
117
+ humanizeControl: nativeHumanizeControl("playwright", settings),
118
+ nativeReady: readyTimeout !== undefined,
119
+ releaseRoot: settings.releaseRoot === undefined ? releaseRootFromLease(executable, lease) : settings.releaseRoot,
120
+ });
121
+ try {
122
+ const browser = await playwright.chromium.launch(mergeLaunchOptions(settings.launchOptions, plan.executable, plan.arguments));
123
+ try {
124
+ if (readyTimeout !== undefined)
125
+ await plan.waitForNativeReady(readyTimeout);
126
+ return browser;
127
+ }
128
+ catch (error) {
129
+ await closeFrameworkRuntime(browser);
130
+ throw error;
131
+ }
132
+ }
133
+ finally {
134
+ await plan.cleanup();
135
+ }
136
+ }
137
+ export async function launchPlaywrightPersistent(playwright, userDataDir, executable, lease, settings = {}) {
138
+ validateFrameworkSettings("playwright", settings);
139
+ const readyTimeout = nativeReadyTimeout(settings);
140
+ const plan = await prepareLaunch(executable, settings.profile ?? {}, lease, {
141
+ tempRoot: settings.tempRoot,
142
+ runtimeHandoff: settings.runtimeHandoff,
143
+ allowRuntimeActivationTicket: settings.allowRuntimeActivationTicket === true,
144
+ humanizeControl: nativeHumanizeControl("playwright", settings),
145
+ nativeReady: readyTimeout !== undefined,
146
+ releaseRoot: settings.releaseRoot === undefined ? releaseRootFromLease(executable, lease) : settings.releaseRoot,
147
+ });
148
+ try {
149
+ const context = await playwright.chromium.launchPersistentContext(resolve(userDataDir), mergeLaunchOptions(settings.launchOptions, plan.executable, plan.arguments));
150
+ try {
151
+ if (readyTimeout !== undefined)
152
+ await plan.waitForNativeReady(readyTimeout);
153
+ return context;
154
+ }
155
+ catch (error) {
156
+ await closeFrameworkRuntime(context);
157
+ throw error;
158
+ }
159
+ }
160
+ finally {
161
+ await plan.cleanup();
162
+ }
163
+ }
164
+ export async function launchPuppeteer(puppeteer, executable, lease, settings = {}) {
165
+ validateFrameworkSettings("puppeteer", settings);
166
+ const readyTimeout = nativeReadyTimeout(settings);
167
+ const plan = await prepareLaunch(executable, settings.profile ?? {}, lease, {
168
+ tempRoot: settings.tempRoot,
169
+ runtimeHandoff: settings.runtimeHandoff,
170
+ allowRuntimeActivationTicket: settings.allowRuntimeActivationTicket === true,
171
+ humanizeControl: nativeHumanizeControl("puppeteer", settings),
172
+ nativeReady: readyTimeout !== undefined,
173
+ releaseRoot: settings.releaseRoot === undefined ? releaseRootFromLease(executable, lease) : settings.releaseRoot,
174
+ });
175
+ try {
176
+ const browser = await puppeteer.launch(mergeLaunchOptions(settings.launchOptions, plan.executable, plan.arguments));
177
+ try {
178
+ if (readyTimeout !== undefined)
179
+ await plan.waitForNativeReady(readyTimeout);
180
+ return browser;
181
+ }
182
+ catch (error) {
183
+ await closeFrameworkRuntime(browser);
184
+ throw error;
185
+ }
186
+ }
187
+ finally {
188
+ await plan.cleanup();
189
+ }
190
+ }
191
+ export async function launchPuppeteerPersistent(puppeteer, userDataDir, executable, lease, settings = {}) {
192
+ if (settings.launchOptions && "userDataDir" in settings.launchOptions) {
193
+ throw new ConfigurationError("The persistent profile directory must be passed to the SlyBrowser adapter", "profile_option_conflict");
194
+ }
195
+ return launchPuppeteer(puppeteer, executable, lease, {
196
+ ...settings,
197
+ launchOptions: {
198
+ ...(settings.launchOptions ?? {}),
199
+ userDataDir: resol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AAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW;KACjH,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,CACpC,kBAAkB,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAC5E,CAAC;QACF,IAAI,CAAC;YACH,IAAI,YAAY,KAAK,SAAS;gBAAE,MAAM,IAAI,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;YAC5E,OAAO,OAAO,CAAC;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAC;YACrC,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,SAAkC,EAClC,WAAmB,EACnB,UAAkB,EAClB,KAAgD,EAChD,WAAoC,EAAE;IAEtC,IAAI,QAAQ,CAAC,aAAa,IAAI,aAAa,IAAI,QAAQ,CAAC,aAAa,EAAE,CAAC;QACtE,MAAM,IAAI,kBAAkB,CAC1B,2EAA2E,EAC3E,yBAAyB,CAC1B,CAAC;IACJ,CAAC;IACD,OAAO,eAAe,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE;QACnD,GAAG,QAAQ;QACX,aAAa,EAAE;YACb,GAAG,CAAC,QAAQ,CAAC,aAAa,IAAI,EAAE,CAAC;YACjC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;SAClC;KACF,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function canonicalJson(value: unknown): Buffer;
2
+ export declare function encodeBase64Url(value: Uint8Array): string;
3
+ export declare function decodeBase64Url(value: unknown, maxBytes: number): Buffer;
4
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../src/canonical.ts"],"names":[],"mappings":"AAmBA,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEzD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYxE"}
@@ -0,0 +1,42 @@
1
+ function normalize(value) {
2
+ if (value === null || typeof value === "string" || typeof value === "boolean")
3
+ return value;
4
+ if (typeof value === "number") {
5
+ if (!Number.isFinite(value))
6
+ throw new TypeError("JSON numbers must be finite");
7
+ return value;
8
+ }
9
+ if (Array.isArray(value))
10
+ return value.map(normalize);
11
+ if (typeof value === "object") {
12
+ const result = {};
13
+ for (const key of Object.keys(value).sort()) {
14
+ const member = value[key];
15
+ if (member === undefined)
16
+ throw new TypeError("undefined is not valid canonical JSON");
17
+ result[key] = normalize(member);
18
+ }
19
+ return result;
20
+ }
21
+ throw new TypeError(`Unsupported canonical JSON value: ${typeof value}`);
22
+ }
23
+ export function canonicalJson(value) {
24
+ return Buffer.from(JSON.stringify(normalize(value)), "utf8");
25
+ }
26
+ export function encodeBase64Url(value) {
27
+ return Buffer.from(value).toString("base64url");
28
+ }
29
+ export function decodeBase64Url(value, maxBytes) {
30
+ if (typeof value !== "string" || !value || !/^[A-Za-z0-9_-]+$/.test(value)) {
31
+ throw new TypeError("value is not unpadded base64url");
32
+ }
33
+ if (value.length > Math.ceil(maxBytes / 3) * 4) {
34
+ throw new RangeError("decoded value exceeds size limit");
35
+ }
36
+ const decoded = Buffer.from(value, "base64url");
37
+ if (decoded.length > maxBytes || decoded.toString("base64url") !== value) {
38
+ throw new TypeError("invalid base64url value");
39
+ }
40
+ return decoded;
41
+ }
42
+ //# sourceMappingURL=canonical.js.map
@@ -0,0 +1 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C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAc,EAAE,QAAgB;IAC9D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;IACzD,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,UAAU,CAAC,kCAAkC,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAChD,IAAI,OAAO,CAAC,MAAM,GAAG,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,KAAK,EAAE,CAAC;QACzE,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
package/dist/cdp.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ type JsonObject = Record<string, unknown>;
2
+ export interface CdpDiscovery {
3
+ Browser?: string;
4
+ "Protocol-Version"?: string;
5
+ webSocketDebuggerUrl?: string;
6
+ [name: string]: unknown;
7
+ }
8
+ export declare function cdpDebuggerAddress(capabilities: JsonObject): string;
9
+ export declare function fetchCdpDiscovery(capabilities: JsonObject, fetchImplementation?: typeof fetch): Promise<CdpDiscovery>;
10
+ export interface AuthenticatedCdpAdapter {
11
+ endpoint: string;
12
+ close(): Promise<void>;
13
+ }
14
+ export declare function createAuthenticatedCdpAdapter(capabilities: JsonObject, options: {
15
+ token: string;
16
+ host?: string;
17
+ port?: number;
18
+ fetch?: typeof fetch;
19
+ }): Promise<AuthenticatedCdpAdapter>;
20
+ export {};
21
+ //# sourceMappingURL=cdp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdp.d.ts","sourceRoot":"","sources":["../src/cdp.ts"],"names":[],"mappings":"AAMA,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAMD,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,UAAU,GAAG,MAAM,CAgBnE;AAED,wBAAsB,iBAAiB,CACrC,YAAY,EAAE,UAAU,EACxB,mBAAmB,GAAE,OAAO,KAAa,GACxC,OAAO,CAAC,YAAY,CAAC,CASvB;AAiCD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,wBAAsB,6BAA6B,CACjD,YAAY,EAAE,UAAU,EACxB,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CAAE,GAC7E,OAAO,CAAC,uBAAuB,CAAC,CAmElC"}