import { OptionsAfterDefaults } from '../options'; import { componentInterface } from '../factory'; /** * Info returned from the API (IP, classification, uniqueness, etc) */ export interface infoInterface { ip_address?: { ip_address: string; ip_identifier: string; autonomous_system_number: number; ip_version: 'v6' | 'v4'; }; classification?: { tor: boolean; vpn: boolean; bot: boolean; datacenter: boolean; danger_level: number; }; uniqueness?: { score: number | string; }; country?: { iso_code: string; name: string; continent: { code: string; name: string; }; }; visitor?: { id: string; isNew: boolean; firstSeen: string; lastSeen: string; }; signals?: { timezone_country_mismatch?: boolean; }; timed_out?: boolean; } /** * API response structure */ export interface apiResponse { info?: infoInterface; version?: string; components?: componentInterface; visitorId?: string; thumbmark?: string; requestId?: string; metadata?: string | object; /** * Present when the server could not resolve this request's JA4 (TLS * ClientHello) fingerprint and has sampled this client to help fill the * gap. Absent otherwise. Only appears on an authenticated (api_key) * response; an anonymous/no-key call never receives this field. See * src/utils/collect.ts. * * An object carrying the JA4 fingerprint the server observed for this * request (`ja4`) and which header it was read from (`source`), so the * client can validate its own JA4 computation against what the server * saw. The object being present (even empty) is itself the directive to * send a collect beacon; `ja4`/`source` may be omitted if the server has * nothing to report. */ collect?: collectDirective; } /** * Shape of `apiResponse.collect` when the server has JA4 data to report * alongside the directive to send a collect beacon. See `apiResponse.collect`. */ export interface collectDirective { ja4?: string; source?: string; } export declare class ApiError extends Error { status: number; constructor(status: number); } /** * Calls the Thumbmark API with the given components, using caching and deduplication. * Returns a promise for the API response or null on error. */ export declare const getApiPromise: (options: OptionsAfterDefaults, components: componentInterface) => Promise; /** * If a valid cached api response exists, returns it * @param options */ export declare function getCachedApiResponse(options: Pick): apiResponse | undefined; /** * Writes the api response to the cache according to the options * @param options * @param response */ export declare function setCachedApiResponse(options: Pick, response: apiResponse): void;