Socket
Socket
Sign inDemoInstall

@types/dompurify

Package Overview
Dependencies
1
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @types/dompurify

TypeScript definitions for dompurify


Version published
Weekly downloads
1.7M
increased by2.62%
Maintainers
1
Install size
16.7 kB
Created
Weekly downloads
 

Package description

What is @types/dompurify?

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.

What are @types/dompurify's main functionalities?

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
});

Other packages similar to @types/dompurify

Readme

Source

Installation

npm install --save @types/dompurify

Summary

This package contains type definitions for dompurify (https://github.com/cure53/DOMPurify).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/dompurify.

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:05 GMT
  • Dependencies: @types/trusted-types

Credits

These definitions were written by Dave Taylor https://github.com/davetayls // Samira Bazuzi, FlowCrypt, Exigerr, Piotr Błażejewicz, and Nicholas Ellul.

FAQs

Last updated on 07 Nov 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc