import { HTMLEncodingContext, SanitizationOptions, ThreatDetail, UseSanitizedContentResult } from '../types'; import { createSafeHTMLProps } from '../xss-prevention'; /** * Options for the useSanitizedContent hook */ export interface UseSanitizedContentOptions extends SanitizationOptions { /** Whether to auto-sanitize on content change */ autoSanitize?: boolean; /** Callback when threats are detected */ onThreatsDetected?: (threats: readonly ThreatDetail[]) => void; } /** * Hook for XSS-safe content handling * * Provides sanitized HTML content, threat detection, and * context-aware encoding utilities. * * @param content - The content to sanitize * @param options - Sanitization options * @returns Sanitized content and utilities * * @example * ```tsx * function UserContent({ html }: { html: string }) { * const { * sanitizedHTML, * wasModified, * threats, * isSafe, * } = useSanitizedContent(html); * * if (!isSafe) { * console.warn('Threats detected:', threats); * } * * return ( *
* {wasModified && ( *
Content was sanitized for safety
* )} *
*
* ); * } * ``` */ export declare function useSanitizedContent(content: string, options?: UseSanitizedContentOptions): UseSanitizedContentResult; /** * Hook for creating safe innerHTML props * * Convenience hook that returns props ready for React elements. * * @example * ```tsx * function RichText({ content }: { content: string }) { * const { props, isSafe, warnings } = useSafeInnerHTML(content); * * return ( *
* ); * } * ``` */ export declare function useSafeInnerHTML(content: string, options?: SanitizationOptions): { props: { dangerouslySetInnerHTML: { __html: string; }; }; isSafe: boolean; warnings: readonly string[]; }; /** * Hook for validating user input in real-time * * @example * ```tsx * function CommentInput() { * const [value, setValue] = useState(''); * const { isValid, threats, preview } = useValidatedInput(value); * * return ( *
*