/** * Host trust tier classification. * * Classifies outbound HTTP request targets into one of four tiers before * the request is sent. Blocked hosts are denied pre-request with an * `SSRF_DENY` telemetry event, absolutely, regardless of configuration. * Localhost/loopback targets (dev servers) are their own tier: they ask once * and can be allowed per project (fetch.allowLocalhost). Unknown hosts * receive `safe-text` sanitization. Trusted hosts may opt into `none` * sanitization via config. * * Trust tiers: * - `trusted` , Host is explicitly allowlisted. Sanitization may be relaxed. * - `unknown` , Host is not in any list; apply `safe-text` sanitization. * - `localhost`, Loopback/dev-server target; requires the per-project * approval (fetch.allowLocalhost) before the request is sent. * - `blocked` , Host matches an internal address, metadata endpoint, or * explicit blocklist entry. Request is denied pre-flight. * * SSRF protections detect (always blocked): * - Private IPv4 ranges (RFC 1918) and link-local metadata (169.254.x.x) * - IPv6 link-local and unique-local ranges * - Cloud metadata endpoints (metadata.google.internal, etc.) * - DNS rebinding patterns (encoded or obfuscated IP addresses) */ /** * Trust classification for an outbound request host. * * - `trusted` , Explicitly allowlisted; sanitization may be relaxed. * - `unknown` , Not in any list; standard `safe-text` sanitization applied. * - `localhost`, Loopback dev-server target; needs the per-project approval. * - `blocked` , Sensitive host; request denied pre-request, absolutely. */ export type HostTrustTier = 'trusted' | 'unknown' | 'localhost' | 'blocked'; /** * Result of classifying a host's trust tier. */ export interface TrustTierResult { /** The classified trust tier. */ tier: HostTrustTier; /** Human-readable reason for the classification. */ reason: string; /** True when the host matched an SSRF pattern specifically. */ isSsrf: boolean; } /** * Configuration for host trust tier classification. */ export interface TrustTierConfig { /** * Hostnames or glob patterns that are explicitly trusted. * Trusted hosts may opt out of sanitization via fetch config. * Example: `['api.anthropic.com', '*.internal.example.com']` */ trustedHosts?: string[] | undefined; /** * Hostnames or glob patterns that are explicitly blocked. * Blocked hosts are denied pre-request regardless of other config. */ blockedHosts?: string[] | undefined; } /** * Telemetry event names emitted by the trust tier classifier. * These are the canonical runtime contract strings for host trust classification. */ export declare const TRUST_TIER_EVENTS: { /** Emitted when a host trust tier has been classified (all tiers). */ readonly HOST_TRUST_TIER: "HOST_TRUST_TIER"; /** Emitted when a request is denied due to SSRF detection. */ readonly SSRF_DENY: "SSRF_DENY"; }; /** * Classify the trust tier of an outbound request host. * * Classification order (first match wins): * 1. Explicit blocklist → `blocked` * 2. Plain loopback targets (localhost, 127.x, ::1) → `localhost` * 3. SSRF patterns (private IPs, metadata endpoints) → `blocked` * 4. Encoded IP bypass attempts (including encoded loopback) → `blocked` * 5. Explicit trustlist → `trusted` * 6. Default → `unknown` * * @param host - Hostname or IP to classify (without port). * @param config - Trust tier configuration with optional allow/deny lists. * @returns `TrustTierResult` with tier, reason, and SSRF flag. */ export declare function classifyHostTrustTier(host: string, config?: TrustTierConfig): TrustTierResult; /** * Emit SSRF deny telemetry to the logger as a structured event. * * Emits a log entry with event name `SSRF_DENY` that can be consumed by * the telemetry pipeline. This fulfils the runtime contract for the * `SSRF_DENY` telemetry event in fetch sanitization. * * @param host - The host that was denied. * @param url - The full URL that was attempted. * @param reason - Human-readable reason for the denial. */ export declare function emitSsrfDeny(host: string, url: string, reason: string): void; /** * Emit host trust tier telemetry to the logger as a structured event. * * Emits a log entry with event name `HOST_TRUST_TIER` that can be consumed * by the telemetry pipeline. This fulfils the runtime contract for the * `HOST_TRUST_TIER` telemetry event in fetch sanitization. * * @param host - The classified host. * @param url - The full URL being fetched. * @param result - The trust tier classification result. */ export declare function emitHostTrustTier(host: string, url: string, result: TrustTierResult): void; /** * Extract the hostname from a URL string for trust tier classification. * * Returns `null` if the URL cannot be parsed. * * @param url - Full URL string (e.g. `https://example.com/path`). * @returns Hostname string (without port), or `null` on parse failure. */ export declare function extractHostname(url: string): string | null; //# sourceMappingURL=trust-tiers.d.ts.map