/** * Consent State Management * * GDPR-compliant consent tracking for authenticated users. * Anonymous analytics don't require consent (no PII collected). * Authenticated users can opt-out of analytics tracking. * * Storage: localStorage (cs_consent) * Format: { analytics: boolean, timestamp: string } * * Philosophy: Privacy is not a feature—it's respect for the user's autonomy. * * @packageDocumentation */ export interface ConsentState { /** Whether user has consented to analytics tracking */ analytics: boolean; /** ISO timestamp of when consent was given/updated */ timestamp: string; } export interface ConsentSyncResult { success: boolean; synced: boolean; error?: string; } /** localStorage key for consent state */ export declare const CONSENT_STORAGE_KEY = "cs_consent"; /** localStorage key for cookie consent state */ export declare const COOKIE_CONSENT_STORAGE_KEY = "cs_cookie_consent"; export type CookieConsentStatus = 'pending' | 'accepted'; export interface CookieConsentState { /** Status of cookie consent */ status: CookieConsentStatus; /** ISO timestamp of when consent was given */ timestamp: string; } /** * Get current consent state from localStorage * * @returns ConsentState or null if not set */ export declare function getConsentState(): ConsentState | null; /** * Set consent state in localStorage * * @param state - The consent state to save */ export declare function setConsentState(state: ConsentState): void; /** * Update analytics consent * * @param analytics - Whether to enable analytics * @returns The new consent state */ export declare function updateAnalyticsConsent(analytics: boolean): ConsentState; /** * Clear consent state from localStorage */ export declare function clearConsentState(): void; /** * Check if user has given analytics consent * * For unauthenticated users: Always returns true (anonymous analytics allowed) * For authenticated users: Checks localStorage consent state * * @param isAuthenticated - Whether the user is authenticated * @returns true if analytics tracking is allowed */ export declare function hasAnalyticsConsent(isAuthenticated: boolean): boolean; /** * Initialize consent state if not present * Called when user logs in to ensure consent state exists * * @param analyticsOptOut - User's opt-out preference from identity-worker * @returns The consent state */ export declare function initializeConsent(analyticsOptOut?: boolean): ConsentState; /** * Sync local consent state with identity-worker * * Called when: * 1. User changes consent preference locally * 2. User logs in (to pull server-side preference) * * @param accessToken - The user's access token for authentication * @param analytics - The analytics consent value to sync * @returns Sync result */ export declare function syncConsentWithServer(accessToken: string, analytics: boolean): Promise; /** * Update consent and optionally sync with server * * @param analytics - New analytics consent value * @param accessToken - Optional access token for server sync * @returns The new consent state and sync result */ export declare function updateAndSyncConsent(analytics: boolean, accessToken?: string): Promise<{ state: ConsentState; sync: ConsentSyncResult | null; }>; /** * Check if Do Not Track is enabled in browser * DNT is always respected regardless of consent state */ export declare function isDNTEnabled(): boolean; /** * Check if analytics should be tracked for the current user * * This is the main function to call before tracking any event. * It checks: * 1. Browser DNT setting (always respected) * 2. User consent state (for authenticated users) * * @param isAuthenticated - Whether the user is authenticated * @returns true if tracking is allowed */ export declare function shouldTrackAnalytics(isAuthenticated: boolean): boolean; /** * Get current cookie consent state from localStorage * * @returns CookieConsentState or null if not set */ export declare function getCookieConsentState(): CookieConsentState | null; /** * Set cookie consent state in localStorage * * @param state - The cookie consent state to save */ export declare function setCookieConsentState(state: CookieConsentState): void; /** * Accept cookie consent for authentication cookies * * @returns The new consent state */ export declare function acceptCookieConsent(): CookieConsentState; /** * Check if user has accepted cookie consent * * @returns true if cookies can be set */ export declare function hasCookieConsent(): boolean; /** * Check if cookie consent is pending (user hasn't interacted with banner) * * @returns true if consent is pending or not set */ export declare function isCookieConsentPending(): boolean; /** * Clear cookie consent state from localStorage */ export declare function clearCookieConsentState(): void;