Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@types/dompurify
Advanced tools
The @types/dompurify package provides TypeScript type definitions for DOMPurify, a DOM-only XSS sanitizer for HTML, MathML, and SVG. It allows developers to use DOMPurify in TypeScript projects with type checking and autocompletion features.
Sanitizing HTML strings
This feature allows you to sanitize HTML strings to prevent XSS attacks. The sanitize function removes any malicious code from the input string.
import DOMPurify from 'dompurify';
const cleanHTML = DOMPurify.sanitize('<img src=x onerror=alert(1)//>');
Configuring DOMPurify
This feature allows you to configure DOMPurify to customize the sanitization process, such as specifying which tags are allowed.
import DOMPurify from 'dompurify';
const cleanHTML = DOMPurify.sanitize(dirtyHTML, { ALLOWED_TAGS: ['a', 'p'] });
Hooking into DOMPurify
This feature allows you to add hooks to DOMPurify's sanitization process, enabling you to manipulate nodes or their attributes after sanitization.
import DOMPurify from 'dompurify';
DOMPurify.addHook('afterSanitizeAttributes', (node) => {
// manipulate node attributes after sanitization
});
sanitize-html is an HTML sanitizer that is similar to DOMPurify. It also removes unwanted HTML and protects from XSS attacks but is not limited to the DOM and can be used on the server-side with Node.js.
xss is another package that provides protection against XSS attacks. It includes a range of options for filtering and customizing the sanitization process, similar to DOMPurify, but it has a different API and may have different default settings.
npm install --save @types/dompurify
This package contains type definitions for DOM Purify (https://github.com/cure53/DOMPurify).
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/dompurify
Additional Details
These definitions were written by Dave Taylor http://davetayls.me, Samira Bazuzi https://github.com/bazuzi.
FAQs
Stub TypeScript definitions entry for dompurify, which provides its own types definitions
The npm package @types/dompurify receives a total of 1,616,206 weekly downloads. As such, @types/dompurify popularity was classified as popular.
We found that @types/dompurify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.