fingerprinter-js
Version:
Enterprise-grade browser fingerprinting with 19 collectors and advanced bot detection
68 lines • 2.73 kB
TypeScript
import { ISuspectSignalDetector, SuspectSignal, SignalCategory } from '../types';
/**
* Abstract base class for all suspect signal detectors
* Implements the Strategy pattern and provides common functionality
*
* This class follows the Template Method pattern and ensures:
* - Consistent signal creation
* - Standardized error handling
* - Performance monitoring
* - Extensibility for new detection strategies
*/
export declare abstract class BaseSuspectDetector implements ISuspectSignalDetector {
abstract readonly name: string;
abstract readonly category: SignalCategory;
abstract readonly priority: number;
/**
* Core detection logic to be implemented by subclasses
* Should return null if no signal is detected
*/
protected abstract detectSignal(components: Readonly<Record<string, unknown>>): SuspectSignal | null;
/**
* Public execution method with standardized error handling
* Implements the Template Method pattern
*/
execute(components: Readonly<Record<string, unknown>>): SuspectSignal | null;
/**
* Get the list of signal types this detector can detect
* Subclasses should override this for accurate reporting
*/
getSupportedSignals(): ReadonlyArray<string>;
/**
* Helper method to create a standardized signal
*/
protected createSignal(type: string, severity: number, description: string, confidence?: number, metadata?: Readonly<Record<string, unknown>>): SuspectSignal;
/**
* Helper method to safely extract component data
*/
protected getComponent<T>(components: Readonly<Record<string, unknown>>, componentName: string, defaultValue: T): 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;
/**
* Helper method to check for property existence safely
*/
protected hasProperty(obj: unknown, path: string): boolean;
/**
* Helper method to get nested property safely
*/
protected getProperty<T>(obj: unknown, path: string, defaultValue: T): T;
/**
* Helper method to detect if a value is suspiciously common
*/
protected isSuspiciouslyCommon(value: string, commonValues: ReadonlyArray<string>, threshold?: number): boolean;
/**
* Helper method to calculate confidence based on multiple factors
*/
protected calculateConfidence(primaryFactor: number, secondaryFactors?: ReadonlyArray<number>): number;
}
//# sourceMappingURL=base-detector.d.ts.map