//#region src/privacy.d.ts /** * Privacy controls for autotel-web * * Provides origin filtering and privacy signal respecting (DNT, GPC) * to ensure compliance with GDPR, CCPA, and user privacy preferences. */ interface PrivacyConfig { /** * Only inject traceparent headers on requests to these origins (whitelist) * * If specified, traceparent will ONLY be injected on matching origins. * Origins are matched using substring matching (e.g., "example.com" matches "https://api.example.com"). * * @example * ```typescript * { * allowedOrigins: ['api.myapp.com', 'myapp.com'] * } * ``` */ allowedOrigins?: string[]; /** * Never inject traceparent headers on requests to these origins (blacklist) * * Takes precedence over allowedOrigins. * Origins are matched using substring matching. * * @example * ```typescript * { * blockedOrigins: ['analytics.google.com', 'facebook.com'] * } * ``` */ blockedOrigins?: string[]; /** * Respect the Do Not Track (DNT) browser setting * * If true and user has DNT enabled, no traceparent headers will be injected. * * @default false * @see https://developer.mozilla.org/en-US/docs/Web/API/Navigator/doNotTrack */ respectDoNotTrack?: boolean; /** * Respect the Global Privacy Control (GPC) browser signal * * If true and user has GPC enabled, no traceparent headers will be injected. * * @default false * @see https://globalprivacycontrol.org/ */ respectGPC?: boolean; } /** * Manages privacy controls for traceparent header injection * * Checks user privacy preferences (DNT, GPC) and origin filtering rules * to determine if traceparent headers should be injected on a given request. */ declare class PrivacyManager { private readonly config; constructor(config: PrivacyConfig); /** * Check if traceparent header should be injected for a given URL * * Decision order: * 1. Check Do Not Track (if enabled) * 2. Check Global Privacy Control (if enabled) * 3. Check blockedOrigins (explicit deny) * 4. Check allowedOrigins (explicit allow, if configured) * 5. Default: allow * * @param url - Full URL or relative path of the request * @returns true if traceparent should be injected, false otherwise */ shouldInjectTraceparent(url: string): boolean; /** * Check if Do Not Track is enabled in the browser */ private isDoNotTrackEnabled; /** * Check if Global Privacy Control is enabled in the browser */ private isGPCEnabled; /** * Extract origin from a URL (handles both absolute and relative URLs) * * @param url - Full URL or relative path * @returns Origin string (e.g., "https://api.example.com") */ private extractOrigin; /** * Check if a target origin matches any of the configured origins * * Uses substring matching for flexibility (e.g., "example.com" matches "https://api.example.com") * * @param targetOrigin - Origin to check * @param configuredOrigins - List of allowed or blocked origins * @returns true if any origin matches */ private matchesAnyOrigin; } /** * Get reason why traceparent injection was denied (for debugging) * * Returns a human-readable reason if injection would be blocked, * or null if injection would be allowed. * * @param privacyManager - Configured PrivacyManager instance * @param url - URL to check * @returns Denial reason or null if allowed * * @example * ```typescript * const manager = new PrivacyManager({ respectDoNotTrack: true }) * const reason = getDenialReason(manager, 'https://api.example.com') * if (reason) { * console.log('Traceparent blocked:', reason) * } * ``` */ declare function getDenialReason(privacyManager: PrivacyManager, url: string): string | null; //#endregion export { PrivacyConfig, PrivacyManager, getDenialReason };