UNPKG

xss-safe-display

Version:

A TypeScript library for safe display and sanitization to prevent XSS attacks.

28 lines (25 loc) 858 B
/** * Strip all HTML tags from a string. */ declare const sanitizeString: (value: string) => string; /** * Sanitize HTML while allowing a configurable set of tags and attributes. */ declare const sanitizeHTML: (html: string, allowedTags?: string[]) => string; /** * Recursively sanitize strings in objects or arrays. */ declare const sanitizeObject: <T>(obj: T) => T; /** * Escape HTML entities in a string. */ declare const escapeHTML: (text: string) => string; declare const sanitizeUrl: (url: string | undefined | null) => string; declare const safeDisplay: { text: (value: string | number | undefined | null) => string; html: (content: string, allowedTags?: string[]) => { __html: string; }; url: (url: string) => string; }; export { escapeHTML, safeDisplay, sanitizeHTML, sanitizeObject, sanitizeString, sanitizeUrl };