import type { DomainClearance } from '../cache/store.js'; /** * Anti-bot clearance reuse (S-A2). Pure, browser-engine-free helpers that decide * whether a stored clearance (see {@link DomainClearance}) may be replayed for a * given fetch tier, and shape the cookie for the two injection paths (a browser * `context.addCookies(...)` cookie, or a `Cookie:` request header). Kept * dependency-light so the tiers stay decoupled and the rules are unit-testable * without a DB or a live page. */ /** The single anti-bot clearance cookie name we mint / replay. */ export declare const CLEARANCE_COOKIE_NAME = "cf_clearance"; /** The tier that will CONSUME (present) a clearance on the next fetch. */ export type ClearanceTier = 'browser' | 'tls' | 'http'; /** * Whether a clearance minted against `clearanceUa` may be presented by `tier`. * * The browser tier renders through Chromium advertising a fixed Chrome identity * (the pinned {@link STEALTH_CHROME_MAJOR}); it CANNOT present a Firefox/Safari * UA, and a Chrome UA of a different major is a fingerprint mismatch a bot wall * will reject. So the browser tier only accepts a Chrome-major-matching UA. * * The header tiers (tls/http) inject the cookie as a `Cookie:` header rather * than re-presenting the minting UA byte-for-byte; cross-tier reuse there is * deliberately BEST-EFFORT (a different JA3 may still be re-challenged, which * the re-validation path handles), so any stored UA is allowed. */ export declare function uaMatchesTier(clearanceUa: string, tier: ClearanceTier): boolean; /** * True when the clearance is still valid at `now` (epoch ms). Fails CLOSED: an * unparseable / empty `expiresAt` is treated as stale so a malformed row is * never replayed. */ export declare function isClearanceFresh(clearance: DomainClearance, now: number): boolean; /** * Extract the raw cf_clearance token from a stored cookie string * (`cf_clearance=`). Returns null when the stored value is not a * cf_clearance cookie or carries no value. */ export declare function clearanceCookieValue(cookie: string): string | null; /** * A Playwright-shaped cookie for `context.addCookies(...)`, scoped to the * originating host so it is dropped on any cross-host redirect hop (the browser * only sends a cookie back to its own domain). Returns null when the stored * value is not a clearance cookie. */ export declare function parsedClearanceCookie(cookie: string, host: string): { name: string; value: string; domain: string; path: string; } | null; /** * Convert a Playwright cookie `expires` (epoch SECONDS) to an ISO string for the * store. A non-positive value (session cookie / unknown) maps to a short default * TTL from now rather than the epoch, so it is treated as fresh-but-brief. */ export declare function clearanceExpiresIso(expiresSeconds: number): string; //# sourceMappingURL=clearance-reuse.d.ts.map