@hackylabs/deep-redact 2.0.1 → 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
+ [![npm version](https://badge.fury.io/js/@hackylabs%2Fdeep-redact.svg)](https://badge.fury.io/js/@hackylabs%2Fdeep-redact)
4
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](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
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](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 and Fast Redact as well as different configurations of Deep Redact, using
86
- [this test object](./test/setup/dummyUser.ts). Fast Redact was configured to redact the same keys on the same object as
87
- Deep Redact without using wildcards.
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
- The benchmark is run on a 2021 iMac with an M1 chip with 16GB memory running Sonoma 14.5.
105
+ Fast-redact is included as a benchmark because it's the next fastest library available specifically for redaction.
90
106
 
91
- JSON.stringify is included as a benchmark because it is the fastest way to deeply iterate over an object although it
92
- doesn't redact any sensitive information. Fast-redact is included as a benchmark because it's the next fastest redaction
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
  ![Benchmark](./benchmark.png)
96
111
 
97
112
  | scenario | ops / sec | op duration (ms) | margin of error | sample count |
98
113
  | --- | --- | --- | --- | --- |
99
- | JSON.stringify, large object | 295500.62 | 0.0033840876 | 0.00002 | 147751 |
100
- | DeepRedact, remove item, single object | 36272.4 | 0.0275691709 | 0.00016 | 18137 |
101
- | DeepRedact, custom replacer function, single object | 30314.59 | 0.0329874115 | 0.00028 | 15158 |
102
- | DeepRedact, default config, large object | 30028.19 | 0.0333020395 | 0.0002 | 15015 |
103
- | DeepRedact, replace string by length, single object | 28756.9 | 0.0347742688 | 0.00028 | 14379 |
104
- | DeepRedact, retain structure, single object | 24803.01 | 0.0403176903 | 0.00032 | 12402 |
105
- | DeepRedact, fuzzy matching, single object | 22243.3 | 0.0449573621 | 0.00038 | 11122 |
106
- | DeepRedact, config per key, single object | 21603.85 | 0.0462880355 | 0.0013 | 10802 |
107
- | fast redact, large object | 9529.2 | 0.1049406557 | 0.00064 | 4765 |
108
- | DeepRedact, case insensitive matching, single object | 6503.72 | 0.1537581959 | 0.00105 | 3252 |
109
- | DeepRedact, default config, 1000 large objects | 5915.05 | 0.1690602382 | 0.00296 | 2958 |
110
- | DeepRedact, fuzzy and case insensitive matching, single object | 5591.96 | 0.1788283015 | 0.00184 | 2796 |
111
- | JSON.stringify, 1000 large objects | 394.41 | 2.5354059248 | 0.01001 | 198 |
112
- | fast redact, 1000 large objects | 172.23 | 5.8060829174 | 0.06886 | 87 |
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hackylabs/deep-redact",
3
- "version": "2.0.1",
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",
@@ -9,6 +9,21 @@
9
9
  "types": "./dist/types/index.d.ts",
10
10
  "main": "./dist/cjs/index.js",
11
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
+ ],
12
27
  "keywords": [
13
28
  "redact",
14
29
  "redaction",
@@ -26,19 +41,9 @@
26
41
  "GDPR",
27
42
  "PII"
28
43
  ],
29
- "exports": {
30
- ".": {
31
- "import": "./dist/esm/index.js",
32
- "require": "./dist/cjs/index.js",
33
- "types": "./dist/types/index.d.ts"
34
- }
35
- },
36
- "files": [
37
- "dist"
38
- ],
39
44
  "repository": {
40
45
  "type": "git",
41
- "url": "https://github.com/hackylabs/deep-redact"
46
+ "url": "git+https://github.com/hackylabs/deep-redact"
42
47
  },
43
48
  "scripts": {
44
49
  "lint": "eslint",
@@ -53,10 +58,11 @@
53
58
  "update-license": "npx ts-node ./scripts/update-license.ts"
54
59
  },
55
60
  "//": [
56
- "fast-redact installed only as a benchmark comparison and is not used in the library",
61
+ "fast-redact and obglob are installed only as benchmark comparisons and are not used in the library",
57
62
  "all dependencies are for development purposes only"
58
63
  ],
59
64
  "devDependencies": {
65
+ "@hackylabs/obglob": "1.1.2",
60
66
  "@memlab/core": "1.1.34",
61
67
  "@types/fast-redact": "3.0.4",
62
68
  "@types/node": "20.14.12",
@@ -71,7 +77,8 @@
71
77
  "eslint-plugin-promise": "7.0.0",
72
78
  "fast-redact": "3.5.0",
73
79
  "image-charts": "6.1.19",
74
- "typescript": "5.5.4",
80
+ "superjson": "2.2.1",
81
+ "typescript": "5.6.2",
75
82
  "vitest": "2.0.4"
76
83
  }
77
84
  }