isomorphic-dompurify 3.5.0 → 3.6.0
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 +9 -0
- package/dist/index.js +11 -5
- package/dist/index.mjs +11 -5
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -60,6 +60,15 @@ import { sanitize } from "isomorphic-dompurify";
|
|
|
60
60
|
const clean = sanitize(dirtyString);
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
The default export is also callable as a factory, matching the `dompurify` API. This is useful when you need a DOMPurify instance bound to a specific window (e.g. in tests or sandboxed environments):
|
|
64
|
+
```javascript
|
|
65
|
+
import DOMPurify from "isomorphic-dompurify";
|
|
66
|
+
import { JSDOM } from "jsdom";
|
|
67
|
+
|
|
68
|
+
const purify = DOMPurify(new JSDOM().window);
|
|
69
|
+
const clean = purify.sanitize(dirtyString);
|
|
70
|
+
```
|
|
71
|
+
|
|
63
72
|
## Memory Management (Server)
|
|
64
73
|
|
|
65
74
|
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:
|
package/dist/index.js
CHANGED
|
@@ -49,12 +49,18 @@ var import_dompurify = __toESM(require("dompurify"));
|
|
|
49
49
|
var import_jsdom = require("jsdom");
|
|
50
50
|
var window = new import_jsdom.JSDOM("<!DOCTYPE html>").window;
|
|
51
51
|
var purify = (0, import_dompurify.default)(window);
|
|
52
|
-
var DOMPurify = new Proxy(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
var DOMPurify = new Proxy(
|
|
53
|
+
((root) => (0, import_dompurify.default)(root)),
|
|
54
|
+
{
|
|
55
|
+
get(_, prop) {
|
|
56
|
+
const value = purify[prop];
|
|
57
|
+
return typeof value === "function" ? value.bind(purify) : value;
|
|
58
|
+
},
|
|
59
|
+
apply(_, __, [root]) {
|
|
60
|
+
return (0, import_dompurify.default)(root);
|
|
61
|
+
}
|
|
56
62
|
}
|
|
57
|
-
|
|
63
|
+
);
|
|
58
64
|
var src_default = DOMPurify;
|
|
59
65
|
var sanitize = ((dirty, config) => purify.sanitize(dirty, config));
|
|
60
66
|
var isSupported = DOMPurify.isSupported;
|
package/dist/index.mjs
CHANGED
|
@@ -3,12 +3,18 @@ import DOMPurifyFactory from "dompurify";
|
|
|
3
3
|
import { JSDOM } from "jsdom";
|
|
4
4
|
var window = new JSDOM("<!DOCTYPE html>").window;
|
|
5
5
|
var purify = DOMPurifyFactory(window);
|
|
6
|
-
var DOMPurify = new Proxy(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
var DOMPurify = new Proxy(
|
|
7
|
+
((root) => DOMPurifyFactory(root)),
|
|
8
|
+
{
|
|
9
|
+
get(_, prop) {
|
|
10
|
+
const value = purify[prop];
|
|
11
|
+
return typeof value === "function" ? value.bind(purify) : value;
|
|
12
|
+
},
|
|
13
|
+
apply(_, __, [root]) {
|
|
14
|
+
return DOMPurifyFactory(root);
|
|
15
|
+
}
|
|
10
16
|
}
|
|
11
|
-
|
|
17
|
+
);
|
|
12
18
|
var src_default = DOMPurify;
|
|
13
19
|
var sanitize = ((dirty, config) => purify.sanitize(dirty, config));
|
|
14
20
|
var isSupported = DOMPurify.isSupported;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "isomorphic-dompurify",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Makes it possible to use DOMPurify on server and client in the same way.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"security",
|
|
@@ -57,16 +57,16 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"dompurify": "^3.3.3",
|
|
60
|
-
"jsdom": "^29.0.
|
|
60
|
+
"jsdom": "^29.0.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@biomejs/biome": "^2.4.
|
|
64
|
-
"@types/jsdom": "^28.0.
|
|
63
|
+
"@biomejs/biome": "^2.4.8",
|
|
64
|
+
"@types/jsdom": "^28.0.1",
|
|
65
65
|
"@types/trusted-types": "^2.0.7",
|
|
66
66
|
"lefthook": "^2.1.4",
|
|
67
67
|
"tsup": "^8.5.1",
|
|
68
68
|
"typescript": "^5.9.3",
|
|
69
|
-
"vitest": "^4.0
|
|
69
|
+
"vitest": "^4.1.0"
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
72
|
"node": "^20.19.0 || ^22.13.0 || >=24.0.0"
|