isomorphic-dompurify 2.36.0 → 3.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -6
- package/dist/browser.d.mts +45 -0
- package/dist/browser.d.ts +45 -0
- package/dist/browser.js +77 -0
- package/dist/browser.mjs +31 -0
- package/dist/index.d.mts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +89 -0
- package/dist/index.mjs +43 -0
- package/package.json +37 -20
- package/browser.js +0 -1
- package/index.d.ts +0 -2
- package/index.js +0 -1
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ It was inspired by [Isomorphic Unfetch](https://github.com/developit/unfetch/tre
|
|
|
27
27
|
| `>=1.10.0` | `>=18` | Server |
|
|
28
28
|
| `>=2.27.0` | `>=20` | Server |
|
|
29
29
|
| `>=2.30.0` | `>=20.19.5` | Server |
|
|
30
|
+
| `>=3.0.0` | `^20.19.0 \|\| ^22.12.0 \|\| >=24.0.0` | Server |
|
|
30
31
|
|
|
31
32
|
## Installation
|
|
32
33
|
|
|
@@ -40,21 +41,42 @@ Please note that DOMPurify library [doesn't follow Semantic Versioning](https://
|
|
|
40
41
|
|
|
41
42
|
## Usage
|
|
42
43
|
|
|
43
|
-
Import:
|
|
44
44
|
```javascript
|
|
45
45
|
import DOMPurify from "isomorphic-dompurify";
|
|
46
|
-
```
|
|
47
|
-
_Importing the entire module for the client/browser version is recommended._
|
|
48
46
|
|
|
49
|
-
Sanitize:
|
|
50
|
-
```javascript
|
|
51
47
|
const clean = DOMPurify.sanitize(dirtyString);
|
|
52
48
|
```
|
|
53
|
-
|
|
49
|
+
|
|
50
|
+
You can pass [config](https://github.com/cure53/DOMPurify/blob/main/README.md) as a second argument:
|
|
54
51
|
```javascript
|
|
55
52
|
const clean = DOMPurify.sanitize(dirtyString, { USE_PROFILES: { html: true } });
|
|
56
53
|
```
|
|
57
54
|
|
|
55
|
+
Named imports are also supported:
|
|
56
|
+
```javascript
|
|
57
|
+
import { sanitize } from "isomorphic-dompurify";
|
|
58
|
+
|
|
59
|
+
const clean = sanitize(dirtyString);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Memory Management (Server)
|
|
63
|
+
|
|
64
|
+
In long-running Node.js processes, the internal jsdom window accumulates DOM state across sanitization calls, which can cause progressive slowdown and memory growth. Use `clearWindow()` to periodically release these resources:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
import { sanitize, clearWindow } from "isomorphic-dompurify";
|
|
68
|
+
|
|
69
|
+
// Sanitize as usual
|
|
70
|
+
const clean = sanitize(dirtyString);
|
|
71
|
+
|
|
72
|
+
// Release jsdom resources when appropriate (e.g. after a request, after a batch)
|
|
73
|
+
clearWindow();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`clearWindow()` closes the current jsdom window and creates a fresh one. All import styles (default and named) continue to work after calling it.
|
|
77
|
+
|
|
78
|
+
> **Note:** Any hooks or config set via `addHook`/`setConfig` will need to be re-applied after calling `clearWindow()`. In the browser build, `clearWindow()` is a no-op.
|
|
79
|
+
|
|
58
80
|
## Web Worker Support
|
|
59
81
|
|
|
60
82
|
The `isomorphic-dompurify` library is [compatible with Web Workers](https://github.com/kkomelin/isomorphic-dompurify/pull/242),
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as trusted_types_lib from 'trusted-types/lib';
|
|
2
|
+
import * as dompurify from 'dompurify';
|
|
3
|
+
import dompurify__default from 'dompurify';
|
|
4
|
+
export { default } from 'dompurify';
|
|
5
|
+
|
|
6
|
+
declare const sanitize: {
|
|
7
|
+
(dirty: string | Node, cfg: dompurify.Config & {
|
|
8
|
+
RETURN_TRUSTED_TYPE: true;
|
|
9
|
+
}): trusted_types_lib.TrustedHTML;
|
|
10
|
+
(dirty: Node, cfg: dompurify.Config & {
|
|
11
|
+
IN_PLACE: true;
|
|
12
|
+
}): Node;
|
|
13
|
+
(dirty: string | Node, cfg: dompurify.Config & {
|
|
14
|
+
RETURN_DOM: true;
|
|
15
|
+
}): Node;
|
|
16
|
+
(dirty: string | Node, cfg: dompurify.Config & {
|
|
17
|
+
RETURN_DOM_FRAGMENT: true;
|
|
18
|
+
}): DocumentFragment;
|
|
19
|
+
(dirty: string | Node, cfg?: dompurify.Config): string;
|
|
20
|
+
};
|
|
21
|
+
declare const isSupported: boolean;
|
|
22
|
+
declare const addHook: {
|
|
23
|
+
(entryPoint: "beforeSanitizeElements" | "afterSanitizeElements" | "uponSanitizeShadowNode", hookFunction: dompurify.NodeHook): void;
|
|
24
|
+
(entryPoint: "beforeSanitizeAttributes" | "afterSanitizeAttributes", hookFunction: dompurify.ElementHook): void;
|
|
25
|
+
(entryPoint: "beforeSanitizeShadowDOM" | "afterSanitizeShadowDOM", hookFunction: dompurify.DocumentFragmentHook): void;
|
|
26
|
+
(entryPoint: "uponSanitizeElement", hookFunction: dompurify.UponSanitizeElementHook): void;
|
|
27
|
+
(entryPoint: "uponSanitizeAttribute", hookFunction: dompurify.UponSanitizeAttributeHook): void;
|
|
28
|
+
};
|
|
29
|
+
declare const removeHook: {
|
|
30
|
+
(entryPoint: "beforeSanitizeElements" | "afterSanitizeElements" | "uponSanitizeShadowNode", hookFunction?: dompurify.NodeHook): dompurify.NodeHook | undefined;
|
|
31
|
+
(entryPoint: "beforeSanitizeAttributes" | "afterSanitizeAttributes", hookFunction?: dompurify.ElementHook): dompurify.ElementHook | undefined;
|
|
32
|
+
(entryPoint: "beforeSanitizeShadowDOM" | "afterSanitizeShadowDOM", hookFunction?: dompurify.DocumentFragmentHook): dompurify.DocumentFragmentHook | undefined;
|
|
33
|
+
(entryPoint: "uponSanitizeElement", hookFunction?: dompurify.UponSanitizeElementHook): dompurify.UponSanitizeElementHook | undefined;
|
|
34
|
+
(entryPoint: "uponSanitizeAttribute", hookFunction?: dompurify.UponSanitizeAttributeHook): dompurify.UponSanitizeAttributeHook | undefined;
|
|
35
|
+
};
|
|
36
|
+
declare const removeHooks: (entryPoint: dompurify.HookName) => void;
|
|
37
|
+
declare const removeAllHooks: () => void;
|
|
38
|
+
declare const setConfig: (cfg?: dompurify.Config) => void;
|
|
39
|
+
declare const clearConfig: () => void;
|
|
40
|
+
declare const isValidAttribute: (tag: string, attr: string, value: string) => boolean;
|
|
41
|
+
declare const version: string;
|
|
42
|
+
declare const removed: (dompurify.RemovedElement | dompurify.RemovedAttribute)[];
|
|
43
|
+
declare function clearWindow(): void;
|
|
44
|
+
|
|
45
|
+
export { addHook, clearConfig, clearWindow, isSupported, isValidAttribute, removeAllHooks, removeHook, removeHooks, removed, sanitize, setConfig, version };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as trusted_types_lib from 'trusted-types/lib';
|
|
2
|
+
import * as dompurify from 'dompurify';
|
|
3
|
+
import dompurify__default from 'dompurify';
|
|
4
|
+
export { default } from 'dompurify';
|
|
5
|
+
|
|
6
|
+
declare const sanitize: {
|
|
7
|
+
(dirty: string | Node, cfg: dompurify.Config & {
|
|
8
|
+
RETURN_TRUSTED_TYPE: true;
|
|
9
|
+
}): trusted_types_lib.TrustedHTML;
|
|
10
|
+
(dirty: Node, cfg: dompurify.Config & {
|
|
11
|
+
IN_PLACE: true;
|
|
12
|
+
}): Node;
|
|
13
|
+
(dirty: string | Node, cfg: dompurify.Config & {
|
|
14
|
+
RETURN_DOM: true;
|
|
15
|
+
}): Node;
|
|
16
|
+
(dirty: string | Node, cfg: dompurify.Config & {
|
|
17
|
+
RETURN_DOM_FRAGMENT: true;
|
|
18
|
+
}): DocumentFragment;
|
|
19
|
+
(dirty: string | Node, cfg?: dompurify.Config): string;
|
|
20
|
+
};
|
|
21
|
+
declare const isSupported: boolean;
|
|
22
|
+
declare const addHook: {
|
|
23
|
+
(entryPoint: "beforeSanitizeElements" | "afterSanitizeElements" | "uponSanitizeShadowNode", hookFunction: dompurify.NodeHook): void;
|
|
24
|
+
(entryPoint: "beforeSanitizeAttributes" | "afterSanitizeAttributes", hookFunction: dompurify.ElementHook): void;
|
|
25
|
+
(entryPoint: "beforeSanitizeShadowDOM" | "afterSanitizeShadowDOM", hookFunction: dompurify.DocumentFragmentHook): void;
|
|
26
|
+
(entryPoint: "uponSanitizeElement", hookFunction: dompurify.UponSanitizeElementHook): void;
|
|
27
|
+
(entryPoint: "uponSanitizeAttribute", hookFunction: dompurify.UponSanitizeAttributeHook): void;
|
|
28
|
+
};
|
|
29
|
+
declare const removeHook: {
|
|
30
|
+
(entryPoint: "beforeSanitizeElements" | "afterSanitizeElements" | "uponSanitizeShadowNode", hookFunction?: dompurify.NodeHook): dompurify.NodeHook | undefined;
|
|
31
|
+
(entryPoint: "beforeSanitizeAttributes" | "afterSanitizeAttributes", hookFunction?: dompurify.ElementHook): dompurify.ElementHook | undefined;
|
|
32
|
+
(entryPoint: "beforeSanitizeShadowDOM" | "afterSanitizeShadowDOM", hookFunction?: dompurify.DocumentFragmentHook): dompurify.DocumentFragmentHook | undefined;
|
|
33
|
+
(entryPoint: "uponSanitizeElement", hookFunction?: dompurify.UponSanitizeElementHook): dompurify.UponSanitizeElementHook | undefined;
|
|
34
|
+
(entryPoint: "uponSanitizeAttribute", hookFunction?: dompurify.UponSanitizeAttributeHook): dompurify.UponSanitizeAttributeHook | undefined;
|
|
35
|
+
};
|
|
36
|
+
declare const removeHooks: (entryPoint: dompurify.HookName) => void;
|
|
37
|
+
declare const removeAllHooks: () => void;
|
|
38
|
+
declare const setConfig: (cfg?: dompurify.Config) => void;
|
|
39
|
+
declare const clearConfig: () => void;
|
|
40
|
+
declare const isValidAttribute: (tag: string, attr: string, value: string) => boolean;
|
|
41
|
+
declare const version: string;
|
|
42
|
+
declare const removed: (dompurify.RemovedElement | dompurify.RemovedAttribute)[];
|
|
43
|
+
declare function clearWindow(): void;
|
|
44
|
+
|
|
45
|
+
export { addHook, clearConfig, clearWindow, isSupported, isValidAttribute, removeAllHooks, removeHook, removeHooks, removed, sanitize, setConfig, version };
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/browser.ts
|
|
31
|
+
var browser_exports = {};
|
|
32
|
+
__export(browser_exports, {
|
|
33
|
+
addHook: () => addHook,
|
|
34
|
+
clearConfig: () => clearConfig,
|
|
35
|
+
clearWindow: () => clearWindow,
|
|
36
|
+
default: () => browser_default,
|
|
37
|
+
isSupported: () => isSupported,
|
|
38
|
+
isValidAttribute: () => isValidAttribute,
|
|
39
|
+
removeAllHooks: () => removeAllHooks,
|
|
40
|
+
removeHook: () => removeHook,
|
|
41
|
+
removeHooks: () => removeHooks,
|
|
42
|
+
removed: () => removed,
|
|
43
|
+
sanitize: () => sanitize,
|
|
44
|
+
setConfig: () => setConfig,
|
|
45
|
+
version: () => version
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(browser_exports);
|
|
48
|
+
var import_dompurify = __toESM(require("dompurify"));
|
|
49
|
+
var browser_default = import_dompurify.default;
|
|
50
|
+
var sanitize = import_dompurify.default.sanitize.bind(import_dompurify.default);
|
|
51
|
+
var isSupported = import_dompurify.default.isSupported;
|
|
52
|
+
var addHook = import_dompurify.default.addHook.bind(import_dompurify.default);
|
|
53
|
+
var removeHook = import_dompurify.default.removeHook.bind(import_dompurify.default);
|
|
54
|
+
var removeHooks = import_dompurify.default.removeHooks.bind(import_dompurify.default);
|
|
55
|
+
var removeAllHooks = import_dompurify.default.removeAllHooks.bind(import_dompurify.default);
|
|
56
|
+
var setConfig = import_dompurify.default.setConfig.bind(import_dompurify.default);
|
|
57
|
+
var clearConfig = import_dompurify.default.clearConfig.bind(import_dompurify.default);
|
|
58
|
+
var isValidAttribute = import_dompurify.default.isValidAttribute.bind(import_dompurify.default);
|
|
59
|
+
var version = import_dompurify.default.version;
|
|
60
|
+
var removed = import_dompurify.default.removed;
|
|
61
|
+
function clearWindow() {
|
|
62
|
+
}
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
addHook,
|
|
66
|
+
clearConfig,
|
|
67
|
+
clearWindow,
|
|
68
|
+
isSupported,
|
|
69
|
+
isValidAttribute,
|
|
70
|
+
removeAllHooks,
|
|
71
|
+
removeHook,
|
|
72
|
+
removeHooks,
|
|
73
|
+
removed,
|
|
74
|
+
sanitize,
|
|
75
|
+
setConfig,
|
|
76
|
+
version
|
|
77
|
+
});
|
package/dist/browser.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/browser.ts
|
|
2
|
+
import DOMPurify from "dompurify";
|
|
3
|
+
var browser_default = DOMPurify;
|
|
4
|
+
var sanitize = DOMPurify.sanitize.bind(DOMPurify);
|
|
5
|
+
var isSupported = DOMPurify.isSupported;
|
|
6
|
+
var addHook = DOMPurify.addHook.bind(DOMPurify);
|
|
7
|
+
var removeHook = DOMPurify.removeHook.bind(DOMPurify);
|
|
8
|
+
var removeHooks = DOMPurify.removeHooks.bind(DOMPurify);
|
|
9
|
+
var removeAllHooks = DOMPurify.removeAllHooks.bind(DOMPurify);
|
|
10
|
+
var setConfig = DOMPurify.setConfig.bind(DOMPurify);
|
|
11
|
+
var clearConfig = DOMPurify.clearConfig.bind(DOMPurify);
|
|
12
|
+
var isValidAttribute = DOMPurify.isValidAttribute.bind(DOMPurify);
|
|
13
|
+
var version = DOMPurify.version;
|
|
14
|
+
var removed = DOMPurify.removed;
|
|
15
|
+
function clearWindow() {
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
addHook,
|
|
19
|
+
clearConfig,
|
|
20
|
+
clearWindow,
|
|
21
|
+
browser_default as default,
|
|
22
|
+
isSupported,
|
|
23
|
+
isValidAttribute,
|
|
24
|
+
removeAllHooks,
|
|
25
|
+
removeHook,
|
|
26
|
+
removeHooks,
|
|
27
|
+
removed,
|
|
28
|
+
sanitize,
|
|
29
|
+
setConfig,
|
|
30
|
+
version
|
|
31
|
+
};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as dompurify from 'dompurify';
|
|
2
|
+
import { DOMPurify as DOMPurify$1 } from 'dompurify';
|
|
3
|
+
|
|
4
|
+
declare const DOMPurify: DOMPurify$1;
|
|
5
|
+
|
|
6
|
+
declare const sanitize: DOMPurify$1["sanitize"];
|
|
7
|
+
declare const isSupported: boolean;
|
|
8
|
+
declare const addHook: DOMPurify$1["addHook"];
|
|
9
|
+
declare const removeHook: DOMPurify$1["removeHook"];
|
|
10
|
+
declare const removeHooks: DOMPurify$1["removeHooks"];
|
|
11
|
+
declare const removeAllHooks: DOMPurify$1["removeAllHooks"];
|
|
12
|
+
declare const setConfig: DOMPurify$1["setConfig"];
|
|
13
|
+
declare const clearConfig: DOMPurify$1["clearConfig"];
|
|
14
|
+
declare const isValidAttribute: DOMPurify$1["isValidAttribute"];
|
|
15
|
+
declare const version: string;
|
|
16
|
+
declare const removed: (dompurify.RemovedElement | dompurify.RemovedAttribute)[];
|
|
17
|
+
declare function clearWindow(): void;
|
|
18
|
+
|
|
19
|
+
export { addHook, clearConfig, clearWindow, DOMPurify as default, isSupported, isValidAttribute, removeAllHooks, removeHook, removeHooks, removed, sanitize, setConfig, version };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as dompurify from 'dompurify';
|
|
2
|
+
import { DOMPurify as DOMPurify$1 } from 'dompurify';
|
|
3
|
+
|
|
4
|
+
declare const DOMPurify: DOMPurify$1;
|
|
5
|
+
|
|
6
|
+
declare const sanitize: DOMPurify$1["sanitize"];
|
|
7
|
+
declare const isSupported: boolean;
|
|
8
|
+
declare const addHook: DOMPurify$1["addHook"];
|
|
9
|
+
declare const removeHook: DOMPurify$1["removeHook"];
|
|
10
|
+
declare const removeHooks: DOMPurify$1["removeHooks"];
|
|
11
|
+
declare const removeAllHooks: DOMPurify$1["removeAllHooks"];
|
|
12
|
+
declare const setConfig: DOMPurify$1["setConfig"];
|
|
13
|
+
declare const clearConfig: DOMPurify$1["clearConfig"];
|
|
14
|
+
declare const isValidAttribute: DOMPurify$1["isValidAttribute"];
|
|
15
|
+
declare const version: string;
|
|
16
|
+
declare const removed: (dompurify.RemovedElement | dompurify.RemovedAttribute)[];
|
|
17
|
+
declare function clearWindow(): void;
|
|
18
|
+
|
|
19
|
+
export { addHook, clearConfig, clearWindow, DOMPurify as default, isSupported, isValidAttribute, removeAllHooks, removeHook, removeHooks, removed, sanitize, setConfig, version };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
addHook: () => addHook,
|
|
34
|
+
clearConfig: () => clearConfig,
|
|
35
|
+
clearWindow: () => clearWindow,
|
|
36
|
+
default: () => src_default,
|
|
37
|
+
isSupported: () => isSupported,
|
|
38
|
+
isValidAttribute: () => isValidAttribute,
|
|
39
|
+
removeAllHooks: () => removeAllHooks,
|
|
40
|
+
removeHook: () => removeHook,
|
|
41
|
+
removeHooks: () => removeHooks,
|
|
42
|
+
removed: () => removed,
|
|
43
|
+
sanitize: () => sanitize,
|
|
44
|
+
setConfig: () => setConfig,
|
|
45
|
+
version: () => version
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(src_exports);
|
|
48
|
+
var import_dompurify = __toESM(require("dompurify"));
|
|
49
|
+
var import_jsdom = require("jsdom");
|
|
50
|
+
var window = new import_jsdom.JSDOM("<!DOCTYPE html>").window;
|
|
51
|
+
var purify = (0, import_dompurify.default)(window);
|
|
52
|
+
var DOMPurify = new Proxy({}, {
|
|
53
|
+
get(_, prop) {
|
|
54
|
+
const value = purify[prop];
|
|
55
|
+
return typeof value === "function" ? value.bind(purify) : value;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
var src_default = DOMPurify;
|
|
59
|
+
var sanitize = ((dirty, config) => purify.sanitize(dirty, config));
|
|
60
|
+
var isSupported = DOMPurify.isSupported;
|
|
61
|
+
var addHook = ((entryPoint, hookFunction) => purify.addHook(entryPoint, hookFunction));
|
|
62
|
+
var removeHook = ((entryPoint) => purify.removeHook(entryPoint));
|
|
63
|
+
var removeHooks = ((entryPoint) => purify.removeHooks(entryPoint));
|
|
64
|
+
var removeAllHooks = (() => purify.removeAllHooks());
|
|
65
|
+
var setConfig = ((config) => purify.setConfig(config));
|
|
66
|
+
var clearConfig = (() => purify.clearConfig());
|
|
67
|
+
var isValidAttribute = ((tag, attr, value) => purify.isValidAttribute(tag, attr, value));
|
|
68
|
+
var version = DOMPurify.version;
|
|
69
|
+
var removed = DOMPurify.removed;
|
|
70
|
+
function clearWindow() {
|
|
71
|
+
window.close();
|
|
72
|
+
window = new import_jsdom.JSDOM("<!DOCTYPE html>").window;
|
|
73
|
+
purify = (0, import_dompurify.default)(window);
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
addHook,
|
|
78
|
+
clearConfig,
|
|
79
|
+
clearWindow,
|
|
80
|
+
isSupported,
|
|
81
|
+
isValidAttribute,
|
|
82
|
+
removeAllHooks,
|
|
83
|
+
removeHook,
|
|
84
|
+
removeHooks,
|
|
85
|
+
removed,
|
|
86
|
+
sanitize,
|
|
87
|
+
setConfig,
|
|
88
|
+
version
|
|
89
|
+
});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import DOMPurifyFactory from "dompurify";
|
|
3
|
+
import { JSDOM } from "jsdom";
|
|
4
|
+
var window = new JSDOM("<!DOCTYPE html>").window;
|
|
5
|
+
var purify = DOMPurifyFactory(window);
|
|
6
|
+
var DOMPurify = new Proxy({}, {
|
|
7
|
+
get(_, prop) {
|
|
8
|
+
const value = purify[prop];
|
|
9
|
+
return typeof value === "function" ? value.bind(purify) : value;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var src_default = DOMPurify;
|
|
13
|
+
var sanitize = ((dirty, config) => purify.sanitize(dirty, config));
|
|
14
|
+
var isSupported = DOMPurify.isSupported;
|
|
15
|
+
var addHook = ((entryPoint, hookFunction) => purify.addHook(entryPoint, hookFunction));
|
|
16
|
+
var removeHook = ((entryPoint) => purify.removeHook(entryPoint));
|
|
17
|
+
var removeHooks = ((entryPoint) => purify.removeHooks(entryPoint));
|
|
18
|
+
var removeAllHooks = (() => purify.removeAllHooks());
|
|
19
|
+
var setConfig = ((config) => purify.setConfig(config));
|
|
20
|
+
var clearConfig = (() => purify.clearConfig());
|
|
21
|
+
var isValidAttribute = ((tag, attr, value) => purify.isValidAttribute(tag, attr, value));
|
|
22
|
+
var version = DOMPurify.version;
|
|
23
|
+
var removed = DOMPurify.removed;
|
|
24
|
+
function clearWindow() {
|
|
25
|
+
window.close();
|
|
26
|
+
window = new JSDOM("<!DOCTYPE html>").window;
|
|
27
|
+
purify = DOMPurifyFactory(window);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
addHook,
|
|
31
|
+
clearConfig,
|
|
32
|
+
clearWindow,
|
|
33
|
+
src_default as default,
|
|
34
|
+
isSupported,
|
|
35
|
+
isValidAttribute,
|
|
36
|
+
removeAllHooks,
|
|
37
|
+
removeHook,
|
|
38
|
+
removeHooks,
|
|
39
|
+
removed,
|
|
40
|
+
sanitize,
|
|
41
|
+
setConfig,
|
|
42
|
+
version
|
|
43
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isomorphic-dompurify",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-rc.2",
|
|
4
4
|
"description": "Makes it possible to use DOMPurify on server and client in the same way.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"security",
|
|
@@ -20,25 +20,39 @@
|
|
|
20
20
|
"url": "https://github.com/kkomelin/isomorphic-dompurify/issues"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
|
-
"
|
|
24
|
-
"index.d.ts",
|
|
25
|
-
"browser.js"
|
|
23
|
+
"dist"
|
|
26
24
|
],
|
|
27
25
|
"license": "MIT",
|
|
28
26
|
"repository": "kkomelin/isomorphic-dompurify",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"types": "index.d.ts",
|
|
27
|
+
"main": "./dist/index.js",
|
|
28
|
+
"module": "./dist/index.mjs",
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"browser": {
|
|
31
|
+
"./dist/index.js": "./dist/browser.js",
|
|
32
|
+
"./dist/index.mjs": "./dist/browser.mjs"
|
|
33
|
+
},
|
|
32
34
|
"exports": {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
".": {
|
|
36
|
+
"node": {
|
|
37
|
+
"import": {
|
|
38
|
+
"types": "./dist/index.d.mts",
|
|
39
|
+
"default": "./dist/index.mjs"
|
|
40
|
+
},
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"default": "./dist/index.js"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"default": {
|
|
47
|
+
"import": {
|
|
48
|
+
"types": "./dist/browser.d.mts",
|
|
49
|
+
"default": "./dist/browser.mjs"
|
|
50
|
+
},
|
|
51
|
+
"require": {
|
|
52
|
+
"types": "./dist/browser.d.ts",
|
|
53
|
+
"default": "./dist/browser.js"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
42
56
|
}
|
|
43
57
|
},
|
|
44
58
|
"dependencies": {
|
|
@@ -46,14 +60,17 @@
|
|
|
46
60
|
"jsdom": "^28.0.0"
|
|
47
61
|
},
|
|
48
62
|
"devDependencies": {
|
|
49
|
-
"
|
|
63
|
+
"@types/jsdom": "^27.0.0",
|
|
64
|
+
"@types/trusted-types": "^2.0.7",
|
|
65
|
+
"tsup": "^8.5.1",
|
|
66
|
+
"typescript": "^5.9.3",
|
|
50
67
|
"vitest": "^4.0.16"
|
|
51
68
|
},
|
|
52
69
|
"engines": {
|
|
53
|
-
"node": "
|
|
70
|
+
"node": "^20.19.0 || ^22.12.0 || >=24.0.0"
|
|
54
71
|
},
|
|
55
72
|
"scripts": {
|
|
56
|
-
"
|
|
57
|
-
"
|
|
73
|
+
"build": "tsup",
|
|
74
|
+
"test": "NODE_OPTIONS='--expose-gc' vitest run"
|
|
58
75
|
}
|
|
59
76
|
}
|
package/browser.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = self.DOMPurify || (self.DOMPurify = require('dompurify').default || require('dompurify'));
|
package/index.d.ts
DELETED
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(e){return e&&e.default||e}module.exports=global.DOMPurify=global.DOMPurify||("undefined"!=typeof window?e(require("dompurify")):function(){const r=e(require("dompurify")),{JSDOM:u}=e(require("jsdom")),{window:o}=new u("<!DOCTYPE html>");return r(o)}());
|