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 ( *
{safeText}
; * } * ``` */ export declare function useSafeText(content: string): string; /** * Hook for context-aware encoding * * @example * ```tsx * function SearchHighlight({ term }: { term: string }) { * const encode = useContextEncoder(); * * // Safe for HTML content * const htmlSafe = encode(term, 'html-content'); * * // Safe for URL parameter * const urlSafe = encode(term, 'url-param'); * * return ( * * Search for: {htmlSafe} * * ); * } * ``` */ export declare function useContextEncoder(): (content: string, context: HTMLEncodingContext) => string; /** * Hook for creating safe HTML props with threat reporting * * @example * ```tsx * function ModeratedContent({ html }: { html: string }) { * const { props, report } = useSafeHTMLWithReport(html, { * onReport: (report) => analytics.track('xss_attempt', report), * }); * * return ; * } * ``` */ export declare function useSafeHTMLWithReport(content: string, options?: { sanitizationOptions?: SanitizationOptions; onReport?: (report: { originalContent: string; threats: readonly ThreatDetail[]; sanitizedContent: string; timestamp: number; }) => void; }): { props: ReturnType