type ThreatCategory = 'bidi-embedding' | 'bidi-isolate' | 'bidi-mark' | 'joiner' | 'invisible' | 'tag' | 'variation-selector' | 'combining-marks'; /** * 'dangerous' categories have no legitimate use in a short user-supplied * string and are stripped by sanitize() by default. 'informational' * categories (bidi-mark, joiner) are real, legitimate characters that * correct RTL text, Persian/Indic text, and emoji sequences depend on; * scan() reports them so callers have full visibility, but sanitize() * never touches them unless explicitly asked to. */ type Severity = 'dangerous' | 'informational'; interface Threat { category: ThreatCategory; severity: Severity; char: string; codePoint: number; index: number; name: string; } interface ScanResult { /** True when there are zero 'dangerous' threats. Informational threats * (legitimate bidi marks, script joiners) never make a string unsafe. */ safe: boolean; /** Every threat found, dangerous and informational alike. */ threats: Threat[]; } interface SanitizeOptions { /** * Which threat categories to strip. Defaults to every 'dangerous' * category. Pass this explicitly to also strip 'bidi-mark' or 'joiner' * characters, but doing so will break correct RTL text or emoji. */ categories?: ThreatCategory[]; /** String to substitute for each stripped character. Defaults to ''. */ replacement?: string; } /** * Scans a string for bidi embedding/override characters, bidi isolates, * bidi marks, script joiners, invisible characters, Unicode Tag * characters, Variation Selectors Supplement characters, and excessive * stacked combining marks ("Zalgo text"). Iterates by Unicode code point * (not UTF-16 code unit) so supplementary-plane characters like the Tags * block (U+E0000+) and the Variation Selectors Supplement (U+E0100+) are * detected correctly instead of being read as two meaningless surrogate * halves. * * `safe` reflects only 'dangerous' threats. Legitimate bidi marks and * script joiners are still reported in `threats` for visibility, but they * never make a string unsafe. */ declare function scan(input: string): ScanResult; declare function isSafe(input: string): boolean; /** * Strips threats found by scan() from a string. By default this strips * every 'dangerous' category (bidi embeddings/overrides, bidi isolates, * invisible characters, Unicode Tag characters, Variation Selectors * Supplement characters, combining marks stacked past * MAX_COMBINING_MARKS_PER_BASE), the ones with no legitimate use in a short * user-supplied string. 'informational' threats (bidi marks, script * joiners) are never stripped unless a caller explicitly lists them in * `options.categories`, since real RTL text, Persian/Indic text, and * emoji sequences depend on them. */ declare function sanitize(input: string, options?: SanitizeOptions): string; export { type SanitizeOptions, type ScanResult, type Severity, type Threat, type ThreatCategory, isSafe, sanitize, scan };