/** * Binary download and cache management for cloakbrowser. * Downloads the patched Chromium binary on first use, caches it locally. * Mirrors Python cloakbrowser/download.py. */ import type { BinaryInfo } from "./types.js"; export declare const WELCOME_FREE_INTERVAL_SEC: number; /** * A downloaded binary could not be authenticated (bad/missing signature, * version mismatch, or checksum failure). Distinct from transient * download/network errors: a verification failure is a tampering signal and * MUST surface, never silently fall back to another binary. The Pro routing in * ensureBinary re-throws this rather than downgrading to the free tier. */ export declare class BinaryVerificationError extends Error { constructor(message: string); } /** * Ensure the stealth Chromium binary is available. Download if needed. * Returns the path to the chrome executable. */ export declare function ensureBinary(licenseKey?: string, browserVersion?: string): Promise; /** Remove all cached binaries. Forces re-download on next launch. */ export declare function clearCache(): void; /** * Return info about the current binary installation. * * tier reflects what is actually installed on disk, not merely whether a license * is cached — a cached license with no Pro binary downloaded yet is still * effectively running the free binary, and the active key may differ from the * cached one. */ export declare function binaryInfo(browserVersion?: string): BinaryInfo; /** Manually check for a newer Chromium version. Returns new version or null. */ export declare function checkForUpdate(): Promise; /** * Move a Pro install to the server's latest stable. Blocks until complete. * Returns the new version when a newer Pro build is downloaded or an * already-cached newer build is activated, else null (already up to date or the * server could not be reached). Requires a valid Pro license key. */ export declare function checkForProUpdate(licenseKey: string): Promise; /** * Whether the welcome banner should be shown now. Pro: once ever (only when * the marker is absent). Free: re-show when the marker is absent or its * timestamp is older than WELCOME_FREE_INTERVAL_MS. Unreadable or legacy empty * markers count as stale (due). * * @internal Exported for testing only. */ export declare function welcomeDue(marker: string, pro: boolean): boolean; /** @internal Exported for testing only. */ export declare function verifyDownloadChecksum(filePath: string, version?: string): Promise; /** * Read the 'version=' line from a signed manifest. null if absent. * The line has no internal whitespace so older wrappers' SHA256SUMS parsers * ignore it (they only accept ' ' lines). * @internal Exported for testing only. */ export declare function parseManifestVersion(text: string): string | null; /** * Fetch (SHA256SUMS, SHA256SUMS.sig) raw bytes for a version, or null. * Both files come from the SAME origin so the signature always matches the * exact manifest bytes it certifies. Primary origin first, then GitHub mirror. * @internal Exported for testing only. */ export declare function fetchSignedManifest(version?: string): Promise<{ manifestBytes: Uint8Array; sigBytes: Uint8Array; } | null>; /** * Verify a detached Ed25519 signature over the raw manifest bytes. * sigB64Bytes is the (base64-text) content of SHA256SUMS.sig. Tries each pinned * key; succeeds if any validates. Throws if malformed or no key validates. * @internal Exported for testing only. */ export declare function verifySignature(manifestBytes: Uint8Array, sigB64Bytes: Uint8Array): void; /** @internal Exported for testing only. */ export declare function fetchChecksums(version?: string): Promise | null>; /** @internal Exported for testing only. */ export declare function parseChecksums(text: string): Map; /** @internal Exported for testing only. */ export declare function downloadProBinary(version: string, licenseKey: string): Promise; /** * Verify a Pro archive with the same non-bypassable Ed25519 signature check as * official free downloads. Pro binaries are served from cloakbrowser.dev (same * origin as the free tier), so a tampered same-origin SHA256SUMS could * otherwise certify a tampered binary (M1, #308). Fetch the Pro SHA256SUMS + * detached SHA256SUMS.sig, verify the signature against the pinned keys FIRST, * bind the manifest to the requested version, then verify the archive's * SHA-256. * * An invalid signature, checksum, or version mismatch throws * BinaryVerificationError (a tampering signal the router surfaces verbatim); * CLOAKBROWSER_SKIP_CHECKSUM cannot bypass it. A failed manifest FETCH is * transient — nothing was validated — and throws a plain Error. A valid-license * user is never silently downgraded to the free binary. * @internal Exported for testing only. */ export declare function verifyProDownload(filePath: string, version: string): Promise; /** @internal Exported for testing only. */ export declare function getLatestChromiumVersion(): Promise; /** @internal Exported for testing only. */ export declare function resetWrapperUpdateChecked(): void; /** @internal Exported for testing only. */ export declare function checkWrapperUpdate(): Promise; //# sourceMappingURL=download.d.ts.map