@bonhomie/react-security
Version:
A frontend security layer for React: devtools detection, screenshot blocking, anti-iframe, tamper detection, watermarking, and more.
100 lines (85 loc) • 2.86 kB
text/typescript
declare function useDevtoolsDetect(options?: {}): any;
declare function useClipboardLock(options?: {}): void;
declare function useScreenshotBlock(options?: {}): void;
declare function useRouteTamperGuard(options?: {}): void;
declare function useGhostingDetect(callback: any): void;
declare function useKeystrokeTamper(callback: any): void;
declare function AntiIframe({ children }: {
children: any;
}): any;
declare function SecurePage({ children, blurAmount, watermarkSize, }: {
children: any;
blurAmount?: string;
watermarkSize?: number;
}): any;
declare function BlockInspect({ children, detectMobile, detectContextMenu, detectZoom, }: {
children: any;
detectMobile?: boolean;
detectContextMenu?: boolean;
detectZoom?: boolean;
}): any;
declare function ReactSecurityProvider({ children, level, config, }: {
children: any;
level?: string;
config?: {};
}): any;
/**
* Basic DevTools detection using window size heuristic.
* Not bulletproof, but enough to flag suspicious behavior.
*/
declare function isDevtoolsOpen(): boolean;
declare function getRandomWatermarkPosition(): {
bottom: number;
right: number;
top?: undefined;
left?: undefined;
transform?: undefined;
} | {
top: number;
right: number;
bottom?: undefined;
left?: undefined;
transform?: undefined;
} | {
bottom: number;
left: number;
right?: undefined;
top?: undefined;
transform?: undefined;
} | {
top: number;
left: number;
bottom?: undefined;
right?: undefined;
transform?: undefined;
} | {
top: string;
left: string;
transform: string;
bottom?: undefined;
right?: undefined;
};
/**
* Apply a dynamic watermark overlay on the screen
* @param {string} text - Watermark text
* @param {number} opacity - 0.05 to 0.25 recommended
* @param {number} size - font size in px
*/
declare function applyDynamicWatermark(text?: string, opacity?: number, size?: number): void;
/**
* Remove watermark from DOM
*/
declare function clearWatermark(): void;
/**
* Low-level continuous freeze detector.
* Detects Snipping Tool, screenshot anomalies, screen freeze patterns.
*/
declare function createAIScreenshotDetector(callback: any): () => void;
/**
* High-level wrapper for easy usage.
*
* @param {Function} onDetect - Called when a suspicious freeze or screenshot signal is detected.
*/
declare function detectAIScreenshot(onDetect: Function): () => void;
declare function detectVPN(): Promise<any>;
export { AntiIframe, BlockInspect, ReactSecurityProvider, SecurePage, applyDynamicWatermark, clearWatermark, createAIScreenshotDetector, detectAIScreenshot, detectVPN, getRandomWatermarkPosition, isDevtoolsOpen, useClipboardLock, useDevtoolsDetect, useGhostingDetect, useKeystrokeTamper, useRouteTamperGuard, useScreenshotBlock };