UNPKG

fingerprinter-js

Version:

Enterprise-grade browser fingerprinting with 19 collectors and advanced bot detection

60 lines 2 kB
import { IComponentCollector, CollectorResult } from '../types'; /** * Abstract base class for all component collectors * Implements common functionality and ensures consistent behavior * * This class follows the Template Method pattern and provides: * - Consistent error handling * - Performance monitoring * - Support detection * - Standardized result format */ export declare abstract class BaseComponentCollector implements IComponentCollector { abstract readonly name: string; abstract readonly version: string; /** * Default estimated collection time in milliseconds * Subclasses should override this for accurate timing */ protected abstract readonly estimatedTime: number; /** * Check if the collector is supported in the current environment */ abstract isSupported(): boolean; /** * Core collection logic to be implemented by subclasses * Should throw errors for unrecoverable situations */ protected abstract collectData(): Promise<unknown> | unknown; /** * Public collection method with standardized error handling * Implements the Template Method pattern */ collect(): Promise<CollectorResult>; /** * Get estimated collection time */ getEstimatedTime(): number; /** * Validate collected data * Subclasses can override this for custom validation */ protected validateData(data: unknown): unknown; /** * Helper method to safely execute operations with error handling */ protected safeExecute<T>(operation: () => T, defaultValue: T, errorContext?: string): T; /** * Helper method to check if we're in a browser environment */ protected isBrowser(): boolean; /** * Helper method to get navigator safely */ protected getNavigator(): Navigator | null; /** * Helper method to get window safely */ protected getWindow(): Window | null; } //# sourceMappingURL=base-collector.d.ts.map