@hackylabs/deep-redact 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
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Deep Redact
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/js/@hackylabs%2Fdeep-redact)
|
|
4
|
+
[](https://github.com/hackylabs/deep-redact/blob/main/LICENSE)
|
|
5
|
+
|
|
3
6
|
Faster than Fast Redact <sup>1</sup> as well as being safer and more configurable than many other redaction libraries,
|
|
4
7
|
Deep Redact is a zero-dependency tool that redacts sensitive information from strings and objects. It is designed to be
|
|
5
8
|
used in a production environment where sensitive information needs to be redacted from logs, error messages, files,
|
|
@@ -11,6 +14,8 @@ possible while still being configurable.
|
|
|
11
14
|
Supporting both CommonJS and ESM, with named and default exports, Deep Redact is designed to be versatile and easy to
|
|
12
15
|
use in any modern JavaScript or TypeScript project in Node or the browser.
|
|
13
16
|
|
|
17
|
+
[](https://ko-fi.com/hackylabs)
|
|
18
|
+
|
|
14
19
|
## Installation
|
|
15
20
|
|
|
16
21
|
```bash
|
|
@@ -82,31 +87,45 @@ redaction.redact(obj)
|
|
|
82
87
|
| retainStructure | boolean | Main options `retainStructure` | N |
|
|
83
88
|
|
|
84
89
|
### Benchmark
|
|
85
|
-
Comparisons are made against JSON.stringify
|
|
86
|
-
|
|
87
|
-
Deep Redact
|
|
90
|
+
Comparisons are made against JSON.stringify, Regex.replace, Fast Redact &
|
|
91
|
+
(one of my other creations, [@hackylabs/obglob](https://npmjs.com/package/@hackylabs/obglob)) as well as different
|
|
92
|
+
configurations of Deep Redact, using [this test object](./test/setup/dummyUser.ts). Fast Redact was configured to redact
|
|
93
|
+
the same keys on the same object as Deep Redact without using wildcards.
|
|
94
|
+
|
|
95
|
+
The benchmark is run on a 2021 iMac with an M1 chip with 16GB memory running macOS Sequoia 15.0.0.
|
|
96
|
+
|
|
97
|
+
JSON.stringify is included as a benchmark because it is the fastest way to deeply iterate over an object, although it
|
|
98
|
+
doesn't redact any sensitive information.
|
|
99
|
+
|
|
100
|
+
Regex.replace is included as a benchmark because it is the fastest way to redact sensitive information from a string.
|
|
101
|
+
However, a regex pattern for all keys to be redacted is much harder to configure than a dedicated redaction library,
|
|
102
|
+
especially when dealing with multiple types of values. It also doesn't handle circular references or other unsupported
|
|
103
|
+
values as gracefully as deep-redact unless a third-party library is used to stringify the object beforehand.
|
|
88
104
|
|
|
89
|
-
|
|
105
|
+
Fast-redact is included as a benchmark because it's the next fastest library available specifically for redaction.
|
|
90
106
|
|
|
91
|
-
JSON.stringify
|
|
92
|
-
|
|
93
|
-
library available. Neither JSON.stringify nor Fast Redact offer the same level of configurability as deep-redact.
|
|
107
|
+
Neither JSON.stringify, Regex.replace nor Fast Redact offer the same level of configurability as deep-redact. Both Fast
|
|
108
|
+
Redact and Obglob are slower and rely on dependencies.
|
|
94
109
|
|
|
95
110
|

|
|
96
111
|
|
|
97
112
|
| scenario | ops / sec | op duration (ms) | margin of error | sample count |
|
|
98
113
|
| --- | --- | --- | --- | --- |
|
|
99
|
-
| JSON.stringify, large object |
|
|
100
|
-
| DeepRedact, remove item, single object |
|
|
101
|
-
| DeepRedact, custom replacer function, single object |
|
|
102
|
-
| DeepRedact,
|
|
103
|
-
| DeepRedact,
|
|
104
|
-
|
|
|
105
|
-
| DeepRedact,
|
|
106
|
-
| DeepRedact,
|
|
107
|
-
|
|
|
108
|
-
| DeepRedact,
|
|
109
|
-
|
|
|
110
|
-
| DeepRedact,
|
|
111
|
-
|
|
|
112
|
-
|
|
|
114
|
+
| JSON.stringify, large object | 161827.79 | 0.0061794083 | 0.00002 | 80914 |
|
|
115
|
+
| DeepRedact, remove item, single object | 26010.46 | 0.0384460656 | 0.00016 | 13006 |
|
|
116
|
+
| DeepRedact, custom replacer function, single object | 22412.54 | 0.0446178767 | 0.00031 | 11207 |
|
|
117
|
+
| DeepRedact, replace string by length, single object | 22323.79 | 0.044795253 | 0.00024 | 11162 |
|
|
118
|
+
| DeepRedact, default config, large object | 21932.77 | 0.0455938725 | 0.00025 | 10967 |
|
|
119
|
+
| Regex replace, large object | 21919.75 | 0.0456209497 | 0.00027 | 10960 |
|
|
120
|
+
| DeepRedact, retain structure, single object | 18417.65 | 0.0542957469 | 0.00024 | 9212 |
|
|
121
|
+
| DeepRedact, fuzzy matching, single object | 17428.25 | 0.0573781129 | 0.00028 | 8715 |
|
|
122
|
+
| DeepRedact, config per key, single object | 16975.98 | 0.0589067685 | 0.00033 | 8488 |
|
|
123
|
+
| DeepRedact, default config, 1000 large objects | 7787.76 | 0.1284065968 | 0.00319 | 3894 |
|
|
124
|
+
| fast redact, large object | 5847.55 | 0.1710116908 | 0.00143 | 2924 |
|
|
125
|
+
| DeepRedact, case insensitive matching, single object | 5136.64 | 0.1946798809 | 0.00152 | 2569 |
|
|
126
|
+
| ObGlob, large object | 5083.79 | 0.1967037628 | 0.01079 | 2542 |
|
|
127
|
+
| DeepRedact, fuzzy and case insensitive matching, single object | 4819.04 | 0.2075101033 | 0.00142 | 2410 |
|
|
128
|
+
| JSON.stringify, 1000 large objects | 226.71 | 4.4109355351 | 0.04147 | 114 |
|
|
129
|
+
| ObGlob, 1000 large objects | 164.41 | 6.0825151928 | 0.15338 | 83 |
|
|
130
|
+
| fast redact, 1000 large objects | 121.82 | 8.2088192787 | 0.09619 | 61 |
|
|
131
|
+
| Regex replace, 1000 large objects | 94.57 | 10.5740055833 | 0.30159 | 48 |
|
package/package.json
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackylabs/deep-redact",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "A fast, safe and configurable zero-dependency library for redacting strings or deeply redacting arrays and objects.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Benjamin Green (https://bengreen.dev)",
|
|
8
|
+
"funding": "https://ko-fi.com/hackylabs",
|
|
8
9
|
"types": "./dist/types/index.d.ts",
|
|
9
10
|
"main": "./dist/cjs/index.js",
|
|
10
11
|
"module": "./dist/esm/index.mjs",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/esm/index.mjs",
|
|
15
|
+
"require": "./dist/cjs/index.js",
|
|
16
|
+
"types": "./dist/types/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./utils/redactorUtils": {
|
|
19
|
+
"import": "./dist/esm/utils/redactorUtils.mjs",
|
|
20
|
+
"require": "./dist/cjs/utils/redactorUtils.js",
|
|
21
|
+
"types": "./dist/types/utils/redactorUtils.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
11
27
|
"keywords": [
|
|
12
28
|
"redact",
|
|
13
29
|
"redaction",
|
|
@@ -25,19 +41,9 @@
|
|
|
25
41
|
"GDPR",
|
|
26
42
|
"PII"
|
|
27
43
|
],
|
|
28
|
-
"exports": {
|
|
29
|
-
".": {
|
|
30
|
-
"import": "./dist/esm/index.js",
|
|
31
|
-
"require": "./dist/cjs/index.js",
|
|
32
|
-
"types": "./dist/types/index.d.ts"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"files": [
|
|
36
|
-
"dist"
|
|
37
|
-
],
|
|
38
44
|
"repository": {
|
|
39
45
|
"type": "git",
|
|
40
|
-
"url": "https://github.com/hackylabs/deep-redact"
|
|
46
|
+
"url": "git+https://github.com/hackylabs/deep-redact"
|
|
41
47
|
},
|
|
42
48
|
"scripts": {
|
|
43
49
|
"lint": "eslint",
|
|
@@ -52,10 +58,11 @@
|
|
|
52
58
|
"update-license": "npx ts-node ./scripts/update-license.ts"
|
|
53
59
|
},
|
|
54
60
|
"//": [
|
|
55
|
-
"fast-redact installed only as
|
|
61
|
+
"fast-redact and obglob are installed only as benchmark comparisons and are not used in the library",
|
|
56
62
|
"all dependencies are for development purposes only"
|
|
57
63
|
],
|
|
58
64
|
"devDependencies": {
|
|
65
|
+
"@hackylabs/obglob": "1.1.2",
|
|
59
66
|
"@memlab/core": "1.1.34",
|
|
60
67
|
"@types/fast-redact": "3.0.4",
|
|
61
68
|
"@types/node": "20.14.12",
|
|
@@ -70,7 +77,8 @@
|
|
|
70
77
|
"eslint-plugin-promise": "7.0.0",
|
|
71
78
|
"fast-redact": "3.5.0",
|
|
72
79
|
"image-charts": "6.1.19",
|
|
73
|
-
"
|
|
80
|
+
"superjson": "2.2.1",
|
|
81
|
+
"typescript": "5.6.2",
|
|
74
82
|
"vitest": "2.0.4"
|
|
75
83
|
}
|
|
76
84
|
}
|
|
File without changes
|