What is safevalues?
mainsafevalues is a security library designed to prevent Cross-Site Scripting (XSS) vulnerabilities in TypeScript and JavaScript. It works by providing safe-by-construction values through escaping or sanitization, making security decisions so developers don't have to.
Key capabilities include:
- Trusted Types Integration: It defines policies to produce Trusted Types when the browser API is available, providing runtime protection.
- Extended Sink Protection: It provides types and builders for DOM APIs that are not covered by the standard Trusted Types specification.
- DOM Sink Wrappers: It offers wrappers for dangerous DOM APIs (e.g.,
setLocationHreffromsafevalues/dom) that sanitize arguments before assignment. - Transparent Polyfilling: If Trusted Types is not supported by the browser,
safevaluestransparently uses its own internal types so the application continues to function.