export interface Sentinels { /** Stands for `{…}` / `${…}` template syntax inside a single literal. */ placeholder: string; /** Stands for a value computed by code (a non-constant concatenation operand). */ hole: string; } /** * Normalise text before any URL is read out of it. * * - Private Use Area characters are removed, so sentinels stay out of band. * - Tab, LF and CR are removed because the WHATWG URL parser removes them * before parsing: `https://example.com\n@vendor.invalid/x` is a request to * vendor.invalid with `example.com` as userinfo, and a scanner that stops at the * newline reads the opposite of what the runtime does. */ export declare function sanitizeForScanning(text: string): string; /** * Sanitiser for free text (Markdown, JSON, shell, dotenv). * * Deliberately does NOT strip newlines. Removing them is right inside a single * URL string, where the runtime parser removes them too; applied to a whole * file it concatenates unrelated lines, and a verbatim `https://vendor.invalid` at * end-of-line became `vendor.invalidUse` — invisible to every host rule. */ export declare function sanitizeProseForScanning(text: string): string; /** * Two distinct sentinel characters. * * They are not searched for: `sanitizeForScanning` deletes the whole Private Use * Area from every literal as it is read, so these characters cannot appear in * the input and no per-input search is needed. */ export declare function pickSentinels(): Sentinels; export interface UrlReference { /** The matched URL, trimmed of trailing punctuation. Sentinels removed. */ url: string; /** Host as far as it is statically known, with sentinels still in place. */ markedHost: string; /** Registrable domain, or undefined when it cannot be determined statically. */ domain?: string; /** When `domain` is undefined, what supplied the undeterminable tail. */ undeterminedBy?: "placeholder" | "hole"; } export declare function stripSentinels(text: string, sentinels: Sentinels): string; /** * Every absolute http(s) URL in a blob of text. * * `text` is expected to be already sentinel-marked when it came from folding. * Placeholder syntax inside the text is masked here so that a `{…}` body * containing `/`, `?` or `#` cannot cut the authority in half. */ export declare function extractUrlReferences(text: string, sentinels?: Sentinels): UrlReference[]; export interface ScanSource { /** Package-relative path, used for reporting. */ file: string; content: string; /** Set when the bytes could not be decoded as text; `content` is then empty. */ undecodable?: string; } export interface VendorHostFinding { file: string; url: string; host: string; } /** * Find known vendor domains even when they do not appear in a complete URL. */ export declare function findVendorDomainTokens(text: string): { domain: string; index: number; }[]; /** * WEAK backstop: known vendor domains anywhere in the shipped bytes. * * A denylist over raw text. It cannot see a vendor domain that is not on * `VENDOR_CONTROLLED_DOMAINS`, and it cannot see a host split across string * literals. Both gaps are closed for executable code by `findDisallowedCodeUrls`, * which folds constants and works from an allowlist. This check exists for prose, * which cannot issue a request. */ export declare function findVendorHostReferences(sources: Iterable): VendorHostFinding[];