/** * License validation and caching for CloakBrowser Pro. * Mirrors Python cloakbrowser/license.py. * * Handles license key resolution, server validation with local caching, * and Pro version checks. */ export interface LicenseInfo { valid: boolean; plan: string; expires: string | null; } /** * The Pro binary refused to run for a license reason. Thrown when a launch * fails and the browser process exited with one of the Pro binary's license * exit codes, carrying a human-readable reason instead of the opaque * "target/browser closed" error the caller would otherwise see. */ export declare class CloakBrowserLicenseError extends Error { constructor(message: string, options?: { cause?: unknown; }); } /** * Map a launch-failure message to a license reason, or null. Returns the human * message when the browser process exited with a known license exit code, else * null so a genuine crash propagates unchanged. */ export declare function licenseErrorMessage(errorText: string): string | null; /** * Return a CloakBrowserLicenseError if a launch failure was a license deny, * else null so the original error propagates unchanged. */ export declare function licenseErrorFrom(err: unknown): CloakBrowserLicenseError | null; /** * Source of a resolved license key. Determines whether env injection * into the child browser process is needed. * * - ``param`` / ``custom_file`` -> must inject (binary can't see these). * - ``env`` -> already in parent ``os.environ``, child inherits naturally. * - ``default_file`` -> binary reads ``~/.cloakbrowser/license.key`` directly. * - ``none`` / ``undefined`` -> no key. */ export type LicenseKeySource = "param" | "env" | "default_file" | "custom_file" | "none"; /** * Like ``resolveLicenseKey`` but also returns the source for env-injection * decisions. Internal; consumers should use ``resolveLicenseKey`` or * ``buildLaunchEnv``. */ export declare function resolveLicenseKeyWithSource(licenseKey?: string): { key: string | undefined; source: LicenseKeySource; }; /** * Resolve the license key: explicit param > env var > file > undefined. */ export declare function resolveLicenseKey(licenseKey?: string): string | undefined; /** * Build a child-process env dict with any needed license key injection. * * The Pro binary reads ``CLOAKBROWSER_LICENSE_KEY`` from its own process * environment at startup. This helper merges the resolved key into the * child process env dict **only** when injection is necessary: * * * **param** / **custom_file** source -> inject into child env. * * **env** source -> child inherits from parent (no injection). * * **default_file** source -> binary reads the file directly (no injection), * unless a custom userEnv is passed (Playwright replaces the child env and * can drop HOME, hiding the file), in which case the key is injected. * * When *userEnv* is provided it is used as the base (Playwright replaces * the child env entirely when ``env`` is set), with the key injected only * when needed. * * Returns ``undefined`` when no injection is needed and no custom userEnv * was given — Playwright treats ``env=undefined`` as "inherit parent env". */ export declare function buildLaunchEnv(licenseKey?: string, userEnv?: Record): Record | undefined; /** * Validate a license key with the CloakBrowser server. * * Checks a local file cache first (24h TTL). Falls back to stale * cache if the server is unreachable. * * Returns LicenseInfo if validation succeeded, null on total failure. */ export declare function validateLicense(licenseKey: string): Promise; /** * Get the latest Pro binary version from the server. * Rate-limited to 1 call per hour via a marker file. */ export declare function getProLatestVersion(): Promise; /** * How many concurrent sessions (seats) this license is holding right now. * * Deliberately NOT cached: a cached seat count is a wrong seat count. Returns * null when the number is unknown — the server couldn't be reached, or it * reported the count as unavailable (it does that instead of a false 0 while * running in leaseless mode). Callers render null as "unavailable". */ export declare function getActiveSessionCount(licenseKey: string): Promise; //# sourceMappingURL=license.d.ts.map