isomorphic-dompurify
Makes it possible to use DOMPurify on server and client in the same way.

isomorphic-dompurify downloads isomorphic-dompurify version isomorphic-dompurify license

isomorphic-dompurifyPackages similaires:
Tendance de téléchargements npm
3 Ans
🌟 Affichez le graphique d'utilisation en temps réel sur le README.md de isomorphic-dompurify, il suffit de copier le code ci-dessous.
## Usage Trend
[![Usage Trend of isomorphic-dompurify](https://npm-compare.com/img/npm-trend/THREE_YEARS/isomorphic-dompurify.png)](https://npm-compare.com/isomorphic-dompurify#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 Affichez le graphique de tendance des GitHub Stars sur le README.md de isomorphic-dompurify, il suffit de copier le code ci-dessous.
## GitHub Stars Trend
[![GitHub Stars Trend of isomorphic-dompurify](https://npm-compare.com/img/github-trend/isomorphic-dompurify.png)](https://npm-compare.com/isomorphic-dompurify)
Détail des statistiques
Package
Téléchargements
Stars
Taille
Issues
Publication
Licence
isomorphic-dompurify1,446,2335215.71 kB13il y a 7 joursMIT
README pour isomorphic-dompurify

Isomorphic DOMPurify

npm version Test Status

The library makes it possible to seamlessly use DOMPurify on server and client in the same way. It does nothing by itself except providing an isomorphic/universal wrapper around DOMPurify, so all credits go to DOMPurify authors and contributors.

DOMPurify - a DOM-only, super-fast, uber-tolerant XSS sanitizer for HTML, MathML and SVG. DOMPurify works with a secure default, but offers a lot of configurability and hooks.

Motivation

DOMPurify needs a DOM tree to base on, which is not available in Node by default. To work on the server side, we need a fake DOM to be created and supplied to DOMPurify. It means that DOMPurify initialization logic on the server is not the same as on the client.

This project was born with the idea of encapsulating DOMPurify initialization details and providing an easy way to import the library on both, server and client, for example in Next.js apps.

It was inspired by Isomorphic Unfetch.

Requirements

| isomorphic-dompurify | Node.js | Environment | | ------------- | ------------- | ------------- | | <=0.19.0 | >=12 | Server | | >=0.20.0 | >=14 | Server | | >=1.4.0 | >=16 | Server | | >=1.10.0 | >=18 | Server | | >=2.27.0 | >=20 | Server | | >=2.30.0 | >=20.19.5 | Server |

Installation

$ npm i isomorphic-dompurify

Updates

Please note that DOMPurify library doesn't follow Semantic Versioning, so we have to release every change as a minor version because we cannot be 100% sure whether new features are added to patch DOMPurify releases or not.

Usage

Import:

import DOMPurify from "isomorphic-dompurify";

Importing the entire module for the client/browser version is recommended.

Sanitize:

const clean = DOMPurify.sanitize(dirtyString);

or with config:

const clean = DOMPurify.sanitize(dirtyString, { USE_PROFILES: { html: true } });

License

DOMPurify - Apache 2.0 or MPL 2.0 © 2015 Mario Heiderich

Isomorphic DOMPurify - MIT License © 2020 Konstantin Komelin and contributors