@elhamdev/tracejs
Version:
A modern, privacy-conscious alternative to browser fingerprinting for unique user identification.
65 lines (64 loc) • 1.96 kB
TypeScript
import { ConsentCategory, ConsentOptions, ConsentState } from "../interfaces/ConsentOptions";
/**
* Service for managing user consent for various fingerprinting methods
* in compliance with privacy regulations like GDPR, CCPA, etc.
*/
export declare class ConsentManager {
private options;
private consentState;
private initialized;
private STORAGE_KEY;
constructor(options?: ConsentOptions);
/**
* Initialize the consent manager
*/
initialize(): Promise<void>;
/**
* Check if a specific fingerprinting method has consent
* @param method The fingerprinting method to check
* @returns Whether the method has consent
*/
hasConsent(method: string): boolean;
/**
* Update consent for a specific category
* @param category The category to update
* @param granted Whether consent is granted
*/
updateConsent(category: ConsentCategory, granted: boolean): void;
/**
* Update consent for multiple categories at once
* @param categories Map of categories to consent values
*/
updateMultipleConsent(categories: Partial<Record<ConsentCategory, boolean>>): void;
/**
* Get the current consent state
* @returns The current consent state
*/
getConsentState(): ConsentState;
/**
* Check if consent is expired and needs renewal
* @returns Whether consent needs renewal
*/
needsConsentRenewal(): boolean;
/**
* Reset consent to default values
*/
resetConsent(): void;
/**
* Load saved consent from localStorage
*/
private loadSavedConsent;
/**
* Save consent to localStorage
*/
private saveConsent;
/**
* Apply default consent values based on the region
*/
private applyRegionalDefaults;
/**
* Detect the user's region based on browser locale or IP geolocation
* @returns The detected region
*/
private detectRegion;
}