purifai 2.0.0 โ 2.0.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 +35 -16
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +11 -2
package/README.md
CHANGED
|
@@ -21,22 +21,36 @@ such as `<b>` and `<a href>`. That is a harder problem and they solve it well.
|
|
|
21
21
|
|
|
22
22
|
## ๐ Benchmark Results
|
|
23
23
|
|
|
24
|
-
Produced by `pnpm
|
|
24
|
+
Produced by `pnpm benchmark`. Each tool's output is inserted into a real DOM
|
|
25
25
|
(jsdom), then serialized and re-parsed โ the round trip where mutation XSS lives.
|
|
26
26
|
A vector counts as blocked only if *neither* parse yields a script node, an `on*`
|
|
27
|
-
handler, or a dangerous-protocol URL.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
27
|
+
handler, or a dangerous-protocol URL. The suite covers the major Node-compatible
|
|
28
|
+
sanitizers, tag strippers, and HTML encoders with materially different APIs.
|
|
29
|
+
|
|
30
|
+
| Library | Category | Security | Text kept | Markup kept | Ops/sec* |
|
|
31
|
+
|---------|----------|----------|-----------|-------------|----------|
|
|
32
|
+
| **Purifai** | strip-text | **100%** | **100%** | 0% *(by design)* | **341,705** |
|
|
33
|
+
| striptags | strip-text | 100% | 100% | 0% | 674,214 |
|
|
34
|
+
| DOMPurify | preserve-html | 100% | 100% | 100% | 1,809 |
|
|
35
|
+
| sanitize-html | preserve-html | 100% | 100% | 100% | 85,340 |
|
|
36
|
+
| xss | preserve-html | 100% | 100% | 100% | 240,911 |
|
|
37
|
+
| rehype-sanitize | preserve-html | 100% | 100% | 100% | 23,738 |
|
|
38
|
+
| escape-html | escape-html | 100% | 60% | 0% | 2,374,124 |
|
|
39
|
+
| validator.escape | escape-html | 100% | 60% | 0% | 713,563 |
|
|
40
|
+
| entities.escapeUTF8 | escape-html | 100% | 60% | 0% | 1,148,270 |
|
|
41
|
+
| html-entities | escape-html | 100% | 60% | 0% | 890,538 |
|
|
42
|
+
| he.escape | escape-html | 100% | 60% | 0% | 1,054,481 |
|
|
43
|
+
| `() => ''` *(calibration)* | โ | 100% | 0% | 0% | โ |
|
|
44
|
+
| `v => v` *(calibration)* | โ | 38.1% | 100% | 100% | โ |
|
|
37
45
|
|
|
38
46
|
84 attack vectors (OWASP, PortSwigger, cure53 corpora) ยท 15 benign documents.
|
|
39
47
|
|
|
48
|
+
\* Throughput is a single-process development snapshot captured on 2026-08-02
|
|
49
|
+
with Node 26.3.0 on Apple Silicon. It varies by hardware and runtime and should
|
|
50
|
+
only be compared within the same category. The command above is the source of
|
|
51
|
+
truth. HTML encoders safely display the original markup as text; unlike Purifai
|
|
52
|
+
and striptags, they do not turn markup-bearing input into clean reader text.
|
|
53
|
+
|
|
40
54
|
> ๐ **Read this honestly.** On security there is no headroom left โ every
|
|
41
55
|
> maintained sanitizer above blocks everything thrown at it. The calibration rows
|
|
42
56
|
> are the whole point: a function returning `''` also scores 100% security, which
|
|
@@ -348,7 +362,7 @@ const clean = sanitize(dirty);
|
|
|
348
362
|
- **Multi-layer sanitization** with fallback mechanisms
|
|
349
363
|
- **Context-aware parsing** to prevent bypass attempts
|
|
350
364
|
- **Aggressive mode** for maximum security applications
|
|
351
|
-
- **
|
|
365
|
+
- **No executable output** across the current 84-vector benchmark corpus
|
|
352
366
|
|
|
353
367
|
### Encoded Attack Detection
|
|
354
368
|
```typescript
|
|
@@ -374,7 +388,7 @@ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) f
|
|
|
374
388
|
|
|
375
389
|
### Development Setup
|
|
376
390
|
```bash
|
|
377
|
-
git clone https://github.com/
|
|
391
|
+
git clone https://github.com/moji2002/purifai.git
|
|
378
392
|
cd purifai
|
|
379
393
|
pnpm install
|
|
380
394
|
pnpm build
|
|
@@ -383,9 +397,14 @@ pnpm test
|
|
|
383
397
|
|
|
384
398
|
### Running Benchmarks
|
|
385
399
|
```bash
|
|
386
|
-
pnpm benchmark
|
|
400
|
+
pnpm benchmark
|
|
387
401
|
```
|
|
388
402
|
|
|
403
|
+
This builds the published artifact, runs the two-axis competitor benchmark, and
|
|
404
|
+
then measures Purifai's throughput, critical-attack checks, and bundle size. The
|
|
405
|
+
competitor set and exact versions are pinned in `package.json` and
|
|
406
|
+
`pnpm-lock.yaml` so results are reproducible.
|
|
407
|
+
|
|
389
408
|
## ๐ License
|
|
390
409
|
|
|
391
410
|
MIT License - see [LICENSE](LICENSE) file for details.
|
|
@@ -404,10 +423,10 @@ MIT License - see [LICENSE](LICENSE) file for details.
|
|
|
404
423
|
|
|
405
424
|
---
|
|
406
425
|
|
|
407
|
-
**โก
|
|
426
|
+
**โก Need untrusted markup reduced to plain text? Install Purifai.**
|
|
408
427
|
|
|
409
428
|
```bash
|
|
410
429
|
npm install purifai
|
|
411
430
|
```
|
|
412
431
|
|
|
413
|
-
*Purifai
|
|
432
|
+
*Purifai โ strip untrusted markup, keep the text.*
|
package/dist/index.cjs
CHANGED
|
@@ -64,7 +64,7 @@ var DEFAULT_OPTIONS = {
|
|
|
64
64
|
allowedProtocols: ["http", "https", "mailto"],
|
|
65
65
|
aggressiveMode: true
|
|
66
66
|
};
|
|
67
|
-
var VERSION = "2.0.
|
|
67
|
+
var VERSION = "2.0.2";
|
|
68
68
|
var MAX_FILTER_PASSES = 5;
|
|
69
69
|
function decodeEncodingBypasses(str) {
|
|
70
70
|
let result = str;
|
|
@@ -401,6 +401,6 @@ var index_default = Purifai;
|
|
|
401
401
|
* Advanced XSS protection with polyglot attack resistance.
|
|
402
402
|
* Blocks sophisticated obfuscation techniques that bypass other sanitizers.
|
|
403
403
|
*
|
|
404
|
-
* @version 2.0.
|
|
404
|
+
* @version 2.0.2
|
|
405
405
|
* @license MIT
|
|
406
406
|
*/
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var DEFAULT_OPTIONS = {
|
|
|
32
32
|
allowedProtocols: ["http", "https", "mailto"],
|
|
33
33
|
aggressiveMode: true
|
|
34
34
|
};
|
|
35
|
-
var VERSION = "2.0.
|
|
35
|
+
var VERSION = "2.0.2";
|
|
36
36
|
var MAX_FILTER_PASSES = 5;
|
|
37
37
|
function decodeEncodingBypasses(str) {
|
|
38
38
|
let result = str;
|
|
@@ -369,6 +369,6 @@ export {
|
|
|
369
369
|
* Advanced XSS protection with polyglot attack resistance.
|
|
370
370
|
* Blocks sophisticated obfuscation techniques that bypass other sanitizers.
|
|
371
371
|
*
|
|
372
|
-
* @version 2.0.
|
|
372
|
+
* @version 2.0.2
|
|
373
373
|
* @license MIT
|
|
374
374
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "purifai",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Zero-dependency strip-to-text HTML sanitizer with contextual output encoding (HTML, attribute, URL). ~4.1KB gzipped, no DOM required - runs in Node, browsers and edge runtimes.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"test:bench": "node test/comprehensive-test.js",
|
|
29
29
|
"test:fair": "node test/fair-benchmark.js",
|
|
30
30
|
"test:perf": "node test/verify-performance.js",
|
|
31
|
+
"benchmark": "pnpm run build && node test/fair-benchmark.js && node test/verify-performance.js",
|
|
31
32
|
"prepublishOnly": "pnpm run test",
|
|
32
33
|
"dev": "tsup index.ts --format cjs,esm --watch",
|
|
33
34
|
"typecheck": "tsc --noEmit",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
"nodejs",
|
|
55
56
|
"browser"
|
|
56
57
|
],
|
|
57
|
-
"author": "Purifai Team <
|
|
58
|
+
"author": "Purifai Team <it@worksonmy.dev>",
|
|
58
59
|
"license": "MIT",
|
|
59
60
|
"homepage": "https://github.com/moji2002/purifai#readme",
|
|
60
61
|
"repository": {
|
|
@@ -71,12 +72,20 @@
|
|
|
71
72
|
"@types/node": "^26.0.0",
|
|
72
73
|
"chalk": "^6.0.0",
|
|
73
74
|
"cli-table3": "^0.6.5",
|
|
75
|
+
"entities": "^8.0.0",
|
|
76
|
+
"escape-html": "^1.0.3",
|
|
77
|
+
"he": "^1.2.0",
|
|
78
|
+
"html-entities": "^2.6.0",
|
|
74
79
|
"isomorphic-dompurify": "^3.19.0",
|
|
75
80
|
"jsdom": "^29.1.1",
|
|
76
81
|
"playwright-core": "^1.62.0",
|
|
82
|
+
"rehype": "^13.0.2",
|
|
83
|
+
"rehype-sanitize": "^6.0.0",
|
|
77
84
|
"sanitize-html": "^2.17.6",
|
|
85
|
+
"striptags": "^3.2.0",
|
|
78
86
|
"tsup": "^8.5.1",
|
|
79
87
|
"typescript": "^7.0.2",
|
|
88
|
+
"validator": "^13.15.35",
|
|
80
89
|
"xss": "^1.0.15"
|
|
81
90
|
}
|
|
82
91
|
}
|