isomorphic-dompurify 3.10.0 → 3.12.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 CHANGED
@@ -1,5 +1,6 @@
1
1
  # Isomorphic DOMPurify
2
2
  [![npm version](https://img.shields.io/npm/v/isomorphic-dompurify.svg)](https://www.npmjs.com/package/isomorphic-dompurify)
3
+ [![npm downloads](https://img.shields.io/npm/dw/isomorphic-dompurify)](https://www.npmjs.com/package/isomorphic-dompurify)
3
4
  [![Test Status](https://github.com/kkomelin/isomorphic-dompurify/actions/workflows/build_test.yml/badge.svg)](https://github.com/kkomelin/isomorphic-dompurify/actions/workflows/build_test.yml)
4
5
 
5
6
  The library makes it possible to seamlessly use [DOMPurify](https://github.com/cure53/DOMPurify) on both server and client in the same way.
@@ -69,6 +70,22 @@ const purify = DOMPurify(new JSDOM().window);
69
70
  const clean = purify.sanitize(dirtyString);
70
71
  ```
71
72
 
73
+ ## TypeScript
74
+
75
+ The hook-related types from `dompurify` are re-exported, so you can type your `addHook` callbacks without redeclaring the signatures:
76
+
77
+ ```typescript
78
+ import { addHook, type NodeHook } from "isomorphic-dompurify";
79
+
80
+ const stripTargetBlank: NodeHook = function (node) {
81
+ if ("target" in node) (node as Element).removeAttribute("target");
82
+ };
83
+
84
+ addHook("afterSanitizeAttributes", stripTargetBlank);
85
+ ```
86
+
87
+ Available type re-exports: `Config`, `DOMPurify`, `DocumentFragmentHook`, `ElementHook`, `HookName`, `NodeHook`, `RemovedAttribute`, `RemovedElement`, `UponSanitizeAttributeHook`, `UponSanitizeAttributeHookEvent`, `UponSanitizeElementHook`, `UponSanitizeElementHookEvent`, `WindowLike`.
88
+
72
89
  ## Memory Management (Server)
73
90
 
74
91
  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:
@@ -1,6 +1,6 @@
1
1
  import * as dompurify from 'dompurify';
2
2
  import dompurify__default from 'dompurify';
3
- export { default } from 'dompurify';
3
+ export { Config, DOMPurify, DocumentFragmentHook, ElementHook, HookName, NodeHook, RemovedAttribute, RemovedElement, UponSanitizeAttributeHook, UponSanitizeAttributeHookEvent, UponSanitizeElementHook, UponSanitizeElementHookEvent, WindowLike, default } from 'dompurify';
4
4
 
5
5
  declare const sanitize: typeof dompurify__default.sanitize;
6
6
  declare const isSupported: boolean;
package/dist/browser.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as dompurify from 'dompurify';
2
2
  import dompurify__default from 'dompurify';
3
- export { default } from 'dompurify';
3
+ export { Config, DOMPurify, DocumentFragmentHook, ElementHook, HookName, NodeHook, RemovedAttribute, RemovedElement, UponSanitizeAttributeHook, UponSanitizeAttributeHookEvent, UponSanitizeElementHook, UponSanitizeElementHookEvent, WindowLike, default } from 'dompurify';
4
4
 
5
5
  declare const sanitize: typeof dompurify__default.sanitize;
6
6
  declare const isSupported: boolean;
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { DOMPurify as DOMPurify$1 } from 'dompurify';
2
+ export { Config, DOMPurify, DocumentFragmentHook, ElementHook, HookName, NodeHook, RemovedAttribute, RemovedElement, UponSanitizeAttributeHook, UponSanitizeAttributeHookEvent, UponSanitizeElementHook, UponSanitizeElementHookEvent, WindowLike } from 'dompurify';
2
3
 
3
4
  declare const DOMPurify: DOMPurify$1;
4
5
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { DOMPurify as DOMPurify$1 } from 'dompurify';
2
+ export { Config, DOMPurify, DocumentFragmentHook, ElementHook, HookName, NodeHook, RemovedAttribute, RemovedElement, UponSanitizeAttributeHook, UponSanitizeAttributeHookEvent, UponSanitizeElementHook, UponSanitizeElementHookEvent, WindowLike } from 'dompurify';
2
3
 
3
4
  declare const DOMPurify: DOMPurify$1;
4
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isomorphic-dompurify",
3
- "version": "3.10.0",
3
+ "version": "3.12.0",
4
4
  "description": "Makes it possible to use DOMPurify on server and client in the same way.",
5
5
  "keywords": [
6
6
  "security",
@@ -56,11 +56,11 @@
56
56
  }
57
57
  },
58
58
  "dependencies": {
59
- "dompurify": "^3.4.1",
60
- "jsdom": "^29.0.2"
59
+ "dompurify": "^3.4.2",
60
+ "jsdom": "^29.1.1"
61
61
  },
62
62
  "devDependencies": {
63
- "@biomejs/biome": "^2.4.12",
63
+ "@biomejs/biome": "^2.4.14",
64
64
  "@types/jsdom": "^28.0.1",
65
65
  "@types/trusted-types": "^2.0.7",
66
66
  "lefthook": "^2.1.6",