import type { BrandExtractionOutput } from '../types.js'; type ProvenanceColors = NonNullable['colors']; type ProvenanceFonts = NonNullable['fonts']; declare function categorizeSocial(url: string): { key: string; canonical: string; } | undefined; declare function normalizeHex(hex: string): string | undefined; declare function rgbToHex(rgb: string): string | undefined; declare function hslToHex(hsl: string): string | undefined; declare function parseColorToHex(raw: string): string | undefined; interface ColorResult { colors: string[]; source: ProvenanceColors; } declare function extractColorsFromCss(css: string): ColorResult; interface FontResult { headings: string[]; body: string[]; source: ProvenanceFonts; } declare function splitFontFamilyList(value: string): string[]; /** Back-compat wrapper kept for `__internal` consumers. Operates on a CSS * blob (no DOM) and therefore can't run the inline-attribute or Google * Fonts paths — those need the live document. */ declare function extractFontsFromCss(css: string): FontResult; export interface BrandImageFetchResult { buffer: Buffer; contentType: string; } export type BrandImageFetcher = (url: string, options?: { timeoutMs?: number; }) => Promise; export interface ExtractBrandOptions { /** Base URL for resolving relative href/src; usually the page URL. */ baseUrl?: string; /** * When provided, this fetcher is used to download logo/og_image bytes * for palette extraction. Defaults to a small wrapper over * the existing `httpFetch` helper so cache + UA rotation + retries are * reused. Pass a mock in tests to keep the suite hermetic. * * Set to `null` to explicitly disable palette extraction (useful for * callers that have an already-passing CSS-var color result and want to * skip the network round-trip). */ imageFetcher?: BrandImageFetcher | null; } /** * Default image fetcher. We can't reuse `httpFetch` directly because it * decodes the response body via `response.text()`, which corrupts binary * bytes — fine for HTML, fatal for PNG/JPEG. We do a single HEAD-like * round-trip via the same Node-built-in `fetch` that `httpFetch` uses * under the hood, applying the same timeout discipline. * * SSRF safety lives HERE — not upstream. The URL we receive comes from * `safeAbsoluteUrl()`, which only filters dangerous schemes * (`javascript:`/`data:`/`file:`/`blob:`/`vbscript:`). That leaves * loopback (`http://127.0.0.1/`), RFC 1918 (`http://10.0.0.1/`), * link-local AWS metadata (`http://169.254.169.254/`), and IPv6 private * ranges wide open — a malicious page's JSON-LD logo could otherwise * force the server to make a request on its behalf. We apply `guardUrl` * BEFORE the first fetch and re-validate on every 3xx hop. * * Redirects are handled manually (`redirect: 'manual'`). A naive * `redirect: 'follow'` would let Node's fetch transparently chase a * 302 → 127.0.0.1, bypassing the guard. Each hop is re-validated; chains * cap at `MAX_REDIRECT_HOPS` to prevent open-redirect chain abuse. * * Streaming + early-abort when content-length signals an oversize body * keeps the bandwidth honest: the spec's 2s round-trip budget assumes * we don't pull a 50MB hero image just to throw it away. */ export declare const defaultImageFetcher: BrandImageFetcher; /** * Async brand extraction. Runs the synchronous extractor first, * then — when CSS-var colors come up short — fetches the logo/og_image and * runs palette quantization. Returns the augmented output with * `provenance.colors` set to `'palette-extraction'` when the image path * fires, `'unknown'` when the image fetch fails or no usable image exists. * * The synchronous `extractBrand` remains the canonical sync entry point. */ export declare function extractBrandAsync(html: string, options?: ExtractBrandOptions): Promise; export declare function extractBrand(html: string, options?: ExtractBrandOptions): BrandExtractionOutput; export declare const __internal: { parseColorToHex: typeof parseColorToHex; rgbToHex: typeof rgbToHex; hslToHex: typeof hslToHex; normalizeHex: typeof normalizeHex; categorizeSocial: typeof categorizeSocial; extractColorsFromCss: typeof extractColorsFromCss; extractFontsFromCss: typeof extractFontsFromCss; splitFontFamilyList: typeof splitFontFamilyList; }; export declare function _internalScanColors(text: string): string[]; export {}; //# sourceMappingURL=brand.d.ts.map