@hackylabs/deep-redact 3.0.5 → 4.0.1

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.
Files changed (49) hide show
  1. package/README.md +229 -106
  2. package/dist/adapters/console/index.cjs +74 -0
  3. package/dist/adapters/console/index.d.cts +22 -0
  4. package/dist/adapters/console/index.d.ts +22 -0
  5. package/dist/adapters/console/index.js +73 -0
  6. package/dist/index.cjs +2782 -0
  7. package/dist/index.d.cts +7 -0
  8. package/dist/index.d.ts +7 -0
  9. package/dist/index.js +2780 -55
  10. package/dist/node-console-sink-BnRUkAAr.cjs +19 -0
  11. package/dist/node-console-sink-DaQleNZ8.js +14 -0
  12. package/dist/public-Da0aARA9.d.cts +127 -0
  13. package/dist/public-Dw4ycNzO.d.ts +127 -0
  14. package/package.json +68 -106
  15. package/dist/index.mjs +0 -40
  16. package/dist/types/index.d.ts +0 -29
  17. package/dist/types/types.d.ts +0 -224
  18. package/dist/types/utils/TransformerRegistry.d.ts +0 -52
  19. package/dist/types/utils/index.d.ts +0 -131
  20. package/dist/types/utils/standardTransformers/bigint.d.ts +0 -2
  21. package/dist/types/utils/standardTransformers/date.d.ts +0 -2
  22. package/dist/types/utils/standardTransformers/error.d.ts +0 -2
  23. package/dist/types/utils/standardTransformers/index.d.ts +0 -9
  24. package/dist/types/utils/standardTransformers/map.d.ts +0 -2
  25. package/dist/types/utils/standardTransformers/regex.d.ts +0 -2
  26. package/dist/types/utils/standardTransformers/set.d.ts +0 -2
  27. package/dist/types/utils/standardTransformers/url.d.ts +0 -2
  28. package/dist/types.js +0 -2
  29. package/dist/types.mjs +0 -1
  30. package/dist/utils/TransformerRegistry.js +0 -100
  31. package/dist/utils/TransformerRegistry.mjs +0 -94
  32. package/dist/utils/index.js +0 -471
  33. package/dist/utils/index.mjs +0 -467
  34. package/dist/utils/standardTransformers/bigint.js +0 -10
  35. package/dist/utils/standardTransformers/bigint.mjs +0 -6
  36. package/dist/utils/standardTransformers/date.js +0 -9
  37. package/dist/utils/standardTransformers/date.mjs +0 -5
  38. package/dist/utils/standardTransformers/error.js +0 -16
  39. package/dist/utils/standardTransformers/error.mjs +0 -12
  40. package/dist/utils/standardTransformers/index.js +0 -38
  41. package/dist/utils/standardTransformers/index.mjs +0 -35
  42. package/dist/utils/standardTransformers/map.js +0 -9
  43. package/dist/utils/standardTransformers/map.mjs +0 -5
  44. package/dist/utils/standardTransformers/regex.js +0 -15
  45. package/dist/utils/standardTransformers/regex.mjs +0 -11
  46. package/dist/utils/standardTransformers/set.js +0 -9
  47. package/dist/utils/standardTransformers/set.mjs +0 -5
  48. package/dist/utils/standardTransformers/url.js +0 -9
  49. package/dist/utils/standardTransformers/url.mjs +0 -5
@@ -0,0 +1,19 @@
1
+ //#region src/core/diagnostics/node-console-sink.ts
2
+ const isNodeRuntime = () => {
3
+ return typeof globalThis.process?.versions?.node === "string";
4
+ };
5
+ const getNodeConsoleDiagnosticSink = () => {
6
+ if (!isNodeRuntime() || typeof globalThis.console?.error !== "function") return;
7
+ const consoleTarget = globalThis.console;
8
+ const error = consoleTarget.error;
9
+ return (event) => {
10
+ error.call(consoleTarget, event);
11
+ };
12
+ };
13
+ //#endregion
14
+ Object.defineProperty(exports, "getNodeConsoleDiagnosticSink", {
15
+ enumerable: true,
16
+ get: function() {
17
+ return getNodeConsoleDiagnosticSink;
18
+ }
19
+ });
@@ -0,0 +1,14 @@
1
+ //#region src/core/diagnostics/node-console-sink.ts
2
+ const isNodeRuntime = () => {
3
+ return typeof globalThis.process?.versions?.node === "string";
4
+ };
5
+ const getNodeConsoleDiagnosticSink = () => {
6
+ if (!isNodeRuntime() || typeof globalThis.console?.error !== "function") return;
7
+ const consoleTarget = globalThis.console;
8
+ const error = consoleTarget.error;
9
+ return (event) => {
10
+ error.call(consoleTarget, event);
11
+ };
12
+ };
13
+ //#endregion
14
+ export { getNodeConsoleDiagnosticSink as t };
@@ -0,0 +1,127 @@
1
+ //#region src/types/paths.d.ts
2
+ interface PublicWildcardSegment {
3
+ readonly any: true;
4
+ }
5
+ interface PublicRecursiveWildcardSegment {
6
+ readonly anyDepth: true;
7
+ }
8
+ type PathSegments = readonly (string | number | RegExp | IgnorePathSegment | PublicWildcardSegment | PublicRecursiveWildcardSegment)[];
9
+ interface FunctionCensorContext {
10
+ readonly matchedPath: PathSegments;
11
+ /**
12
+ * The path segments of the rule that produced this redaction.
13
+ * When an inherited policy is active (e.g. a parent key rule with `retainStructure: true`),
14
+ * this reflects the ancestor rule's key or path — not the current node's own key.
15
+ */
16
+ readonly rulePath: PathSegments;
17
+ readonly rootInput: unknown;
18
+ readonly terminalKey?: string | number;
19
+ }
20
+ type Censor = string | ((value: unknown, context: FunctionCensorContext) => unknown);
21
+ type RegexPathSegment = RegExp;
22
+ interface IgnorePathSegment {
23
+ readonly ignore: string | number | RegexPathSegment;
24
+ }
25
+ type StructuredPathSegment = string | number | RegexPathSegment | IgnorePathSegment;
26
+ type StructuredPathSelector = readonly StructuredPathSegment[];
27
+ type PathSelector = string | StructuredPathSelector;
28
+ interface PathRule {
29
+ readonly path: PathSelector;
30
+ readonly censor?: Censor;
31
+ readonly remove?: boolean;
32
+ readonly retainStructure?: boolean;
33
+ readonly replaceStringByLength?: boolean;
34
+ }
35
+ type PathEntry = PathSelector | PathRule;
36
+ //#endregion
37
+ //#region src/types/diagnostics.d.ts
38
+ interface DiagnosticEvent {
39
+ readonly details?: Record<string, unknown>;
40
+ readonly event: string;
41
+ readonly message: string;
42
+ readonly path: string;
43
+ readonly valueType: string;
44
+ }
45
+ type DiagnosticSink = (event: DiagnosticEvent) => void;
46
+ interface DiagnosticsOptions {
47
+ readonly sink?: DiagnosticSink;
48
+ }
49
+ //#endregion
50
+ //#region src/types/ignored-value-types.d.ts
51
+ interface IgnoredValueTypesOption {
52
+ readonly bigint?: boolean;
53
+ readonly Date?: boolean;
54
+ readonly Error?: boolean;
55
+ readonly Map?: boolean;
56
+ readonly RegExp?: boolean;
57
+ readonly Set?: boolean;
58
+ readonly URL?: boolean;
59
+ }
60
+ //#endregion
61
+ //#region src/types/transformers.d.ts
62
+ type Transformer = (value: unknown) => unknown;
63
+ interface CustomConstructorTransformerRegistration {
64
+ readonly constructor: abstract new (...args: never[]) => object;
65
+ readonly transformers: readonly Transformer[];
66
+ }
67
+ interface TransformersByType {
68
+ readonly bigint?: readonly Transformer[];
69
+ readonly object?: readonly Transformer[];
70
+ }
71
+ interface TransformersByConstructor {
72
+ readonly Date?: readonly Transformer[];
73
+ readonly Error?: readonly Transformer[];
74
+ readonly Map?: readonly Transformer[];
75
+ readonly RegExp?: readonly Transformer[];
76
+ readonly Set?: readonly Transformer[];
77
+ readonly URL?: readonly Transformer[];
78
+ readonly custom?: readonly CustomConstructorTransformerRegistration[];
79
+ }
80
+ interface TransformersOption {
81
+ readonly byType?: TransformersByType;
82
+ readonly byConstructor?: TransformersByConstructor;
83
+ readonly fallback?: readonly Transformer[];
84
+ }
85
+ //#endregion
86
+ //#region src/types/config.d.ts
87
+ type SerialiseOption = boolean | ((value: unknown) => string);
88
+ interface KeyRule {
89
+ readonly key: string | RegExp;
90
+ readonly fuzzyKeyMatch?: boolean;
91
+ readonly caseSensitiveKeyMatch?: boolean;
92
+ readonly censor?: Censor;
93
+ readonly remove?: boolean;
94
+ readonly retainStructure?: boolean;
95
+ readonly replaceStringByLength?: boolean;
96
+ }
97
+ type KeySelector = string | RegExp | KeyRule;
98
+ type StringTest = RegExp | SubstringRule;
99
+ type ValueTypeName = 'string' | 'number' | 'bigint' | 'boolean' | 'object' | 'function' | 'symbol' | 'undefined';
100
+ interface SubstringRule {
101
+ readonly pattern: RegExp;
102
+ readonly replacer: (value: string, pattern: RegExp) => string;
103
+ }
104
+ interface DeepRedactOptions {
105
+ readonly caseSensitiveKeyMatch?: boolean;
106
+ readonly censor?: Censor;
107
+ readonly diagnostics?: DiagnosticsOptions;
108
+ readonly fuzzyKeyMatch?: boolean;
109
+ readonly keys?: readonly KeySelector[];
110
+ readonly maxDepth?: number;
111
+ readonly maxNodes?: number;
112
+ readonly paths?: readonly PathEntry[];
113
+ readonly remove?: boolean;
114
+ readonly retainStructure?: boolean;
115
+ readonly serialise?: SerialiseOption;
116
+ readonly stringTests?: readonly StringTest[];
117
+ readonly transformers?: TransformersOption;
118
+ readonly types?: readonly ValueTypeName[];
119
+ readonly ignoredValueTypes?: IgnoredValueTypesOption;
120
+ readonly replaceStringByLength?: boolean;
121
+ }
122
+ //#endregion
123
+ //#region src/types/public.d.ts
124
+ type Redactor = (value: unknown) => unknown;
125
+ type RedactorFactory = (options?: DeepRedactOptions) => Redactor;
126
+ //#endregion
127
+ export { StructuredPathSelector as A, PathRule as C, PublicWildcardSegment as D, PublicRecursiveWildcardSegment as E, RegexPathSegment as O, PathEntry as S, PathSelector as T, DiagnosticSink as _, KeySelector as a, FunctionCensorContext as b, SubstringRule as c, Transformer as d, TransformersByConstructor as f, DiagnosticEvent as g, IgnoredValueTypesOption as h, KeyRule as i, StructuredPathSegment as k, ValueTypeName as l, TransformersOption as m, RedactorFactory as n, SerialiseOption as o, TransformersByType as p, DeepRedactOptions as r, StringTest as s, Redactor as t, CustomConstructorTransformerRegistration as u, DiagnosticsOptions as v, PathSegments as w, IgnorePathSegment as x, Censor as y };
@@ -0,0 +1,127 @@
1
+ //#region src/types/paths.d.ts
2
+ interface PublicWildcardSegment {
3
+ readonly any: true;
4
+ }
5
+ interface PublicRecursiveWildcardSegment {
6
+ readonly anyDepth: true;
7
+ }
8
+ type PathSegments = readonly (string | number | RegExp | IgnorePathSegment | PublicWildcardSegment | PublicRecursiveWildcardSegment)[];
9
+ interface FunctionCensorContext {
10
+ readonly matchedPath: PathSegments;
11
+ /**
12
+ * The path segments of the rule that produced this redaction.
13
+ * When an inherited policy is active (e.g. a parent key rule with `retainStructure: true`),
14
+ * this reflects the ancestor rule's key or path — not the current node's own key.
15
+ */
16
+ readonly rulePath: PathSegments;
17
+ readonly rootInput: unknown;
18
+ readonly terminalKey?: string | number;
19
+ }
20
+ type Censor = string | ((value: unknown, context: FunctionCensorContext) => unknown);
21
+ type RegexPathSegment = RegExp;
22
+ interface IgnorePathSegment {
23
+ readonly ignore: string | number | RegexPathSegment;
24
+ }
25
+ type StructuredPathSegment = string | number | RegexPathSegment | IgnorePathSegment;
26
+ type StructuredPathSelector = readonly StructuredPathSegment[];
27
+ type PathSelector = string | StructuredPathSelector;
28
+ interface PathRule {
29
+ readonly path: PathSelector;
30
+ readonly censor?: Censor;
31
+ readonly remove?: boolean;
32
+ readonly retainStructure?: boolean;
33
+ readonly replaceStringByLength?: boolean;
34
+ }
35
+ type PathEntry = PathSelector | PathRule;
36
+ //#endregion
37
+ //#region src/types/diagnostics.d.ts
38
+ interface DiagnosticEvent {
39
+ readonly details?: Record<string, unknown>;
40
+ readonly event: string;
41
+ readonly message: string;
42
+ readonly path: string;
43
+ readonly valueType: string;
44
+ }
45
+ type DiagnosticSink = (event: DiagnosticEvent) => void;
46
+ interface DiagnosticsOptions {
47
+ readonly sink?: DiagnosticSink;
48
+ }
49
+ //#endregion
50
+ //#region src/types/ignored-value-types.d.ts
51
+ interface IgnoredValueTypesOption {
52
+ readonly bigint?: boolean;
53
+ readonly Date?: boolean;
54
+ readonly Error?: boolean;
55
+ readonly Map?: boolean;
56
+ readonly RegExp?: boolean;
57
+ readonly Set?: boolean;
58
+ readonly URL?: boolean;
59
+ }
60
+ //#endregion
61
+ //#region src/types/transformers.d.ts
62
+ type Transformer = (value: unknown) => unknown;
63
+ interface CustomConstructorTransformerRegistration {
64
+ readonly constructor: abstract new (...args: never[]) => object;
65
+ readonly transformers: readonly Transformer[];
66
+ }
67
+ interface TransformersByType {
68
+ readonly bigint?: readonly Transformer[];
69
+ readonly object?: readonly Transformer[];
70
+ }
71
+ interface TransformersByConstructor {
72
+ readonly Date?: readonly Transformer[];
73
+ readonly Error?: readonly Transformer[];
74
+ readonly Map?: readonly Transformer[];
75
+ readonly RegExp?: readonly Transformer[];
76
+ readonly Set?: readonly Transformer[];
77
+ readonly URL?: readonly Transformer[];
78
+ readonly custom?: readonly CustomConstructorTransformerRegistration[];
79
+ }
80
+ interface TransformersOption {
81
+ readonly byType?: TransformersByType;
82
+ readonly byConstructor?: TransformersByConstructor;
83
+ readonly fallback?: readonly Transformer[];
84
+ }
85
+ //#endregion
86
+ //#region src/types/config.d.ts
87
+ type SerialiseOption = boolean | ((value: unknown) => string);
88
+ interface KeyRule {
89
+ readonly key: string | RegExp;
90
+ readonly fuzzyKeyMatch?: boolean;
91
+ readonly caseSensitiveKeyMatch?: boolean;
92
+ readonly censor?: Censor;
93
+ readonly remove?: boolean;
94
+ readonly retainStructure?: boolean;
95
+ readonly replaceStringByLength?: boolean;
96
+ }
97
+ type KeySelector = string | RegExp | KeyRule;
98
+ type StringTest = RegExp | SubstringRule;
99
+ type ValueTypeName = 'string' | 'number' | 'bigint' | 'boolean' | 'object' | 'function' | 'symbol' | 'undefined';
100
+ interface SubstringRule {
101
+ readonly pattern: RegExp;
102
+ readonly replacer: (value: string, pattern: RegExp) => string;
103
+ }
104
+ interface DeepRedactOptions {
105
+ readonly caseSensitiveKeyMatch?: boolean;
106
+ readonly censor?: Censor;
107
+ readonly diagnostics?: DiagnosticsOptions;
108
+ readonly fuzzyKeyMatch?: boolean;
109
+ readonly keys?: readonly KeySelector[];
110
+ readonly maxDepth?: number;
111
+ readonly maxNodes?: number;
112
+ readonly paths?: readonly PathEntry[];
113
+ readonly remove?: boolean;
114
+ readonly retainStructure?: boolean;
115
+ readonly serialise?: SerialiseOption;
116
+ readonly stringTests?: readonly StringTest[];
117
+ readonly transformers?: TransformersOption;
118
+ readonly types?: readonly ValueTypeName[];
119
+ readonly ignoredValueTypes?: IgnoredValueTypesOption;
120
+ readonly replaceStringByLength?: boolean;
121
+ }
122
+ //#endregion
123
+ //#region src/types/public.d.ts
124
+ type Redactor = (value: unknown) => unknown;
125
+ type RedactorFactory = (options?: DeepRedactOptions) => Redactor;
126
+ //#endregion
127
+ export { StructuredPathSelector as A, PathRule as C, PublicWildcardSegment as D, PublicRecursiveWildcardSegment as E, RegexPathSegment as O, PathEntry as S, PathSelector as T, DiagnosticSink as _, KeySelector as a, FunctionCensorContext as b, SubstringRule as c, Transformer as d, TransformersByConstructor as f, DiagnosticEvent as g, IgnoredValueTypesOption as h, KeyRule as i, StructuredPathSegment as k, ValueTypeName as l, TransformersOption as m, RedactorFactory as n, SerialiseOption as o, TransformersByType as p, DeepRedactOptions as r, StringTest as s, Redactor as t, CustomConstructorTransformerRegistration as u, DiagnosticsOptions as v, PathSegments as w, IgnorePathSegment as x, Censor as y };
package/package.json CHANGED
@@ -1,80 +1,35 @@
1
1
  {
2
2
  "name": "@hackylabs/deep-redact",
3
- "version": "3.0.5",
4
- "description": "A fast, safe and configurable zero-dependency library for redacting strings or deeply redacting arrays and objects.",
3
+ "version": "4.0.1",
4
+ "description": "Deeply redact sensitive data from objects, arrays and arbitrary strings (e.g. XML or raw cookies data) with a composable, function-first API.",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "author": "Benjamin Green (https://bengreen.dev)",
8
8
  "funding": "https://ko-fi.com/hackylabs",
9
- "types": "./dist/types/index.d.ts",
10
- "main": "./dist/index.js",
11
- "module": "./dist/index.mjs",
9
+ "type": "module",
10
+ "volta": {
11
+ "node": "24.14.1",
12
+ "pnpm": "10.33.0"
13
+ },
14
+ "engines": {
15
+ "node": ">=22.18.0"
16
+ },
17
+ "sideEffects": false,
18
+ "main": "./dist/index.cjs",
19
+ "module": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
12
21
  "exports": {
13
22
  ".": {
14
- "import": "./dist/index.mjs",
15
- "require": "./dist/index.js",
16
- "types": "./dist/types/index.d.ts"
17
- },
18
- "./index.ts": {
19
- "import": "./dist/index.mjs",
20
- "require": "./dist/index.js",
21
- "types": "./dist/types/index.d.ts"
22
- },
23
- "./types.ts": {
24
- "import": "./dist/types.mjs",
25
- "require": "./dist/types.js",
26
- "types": "./dist/types/types.d.ts"
27
- },
28
- "./utils/TransformerRegistry.ts": {
29
- "import": "./dist/utils/TransformerRegistry.mjs",
30
- "require": "./dist/utils/TransformerRegistry.js",
31
- "types": "./dist/types/utils/TransformerRegistry.d.ts"
32
- },
33
- "./utils/index.ts": {
34
- "import": "./dist/utils/index.mjs",
35
- "require": "./dist/utils/index.js",
36
- "types": "./dist/types/utils/index.d.ts"
37
- },
38
- "./utils/standardTransformers/bigint.ts": {
39
- "import": "./dist/utils/standardTransformers/bigint.mjs",
40
- "require": "./dist/utils/standardTransformers/bigint.js",
41
- "types": "./dist/types/utils/standardTransformers/bigint.d.ts"
42
- },
43
- "./utils/standardTransformers/date.ts": {
44
- "import": "./dist/utils/standardTransformers/date.mjs",
45
- "require": "./dist/utils/standardTransformers/date.js",
46
- "types": "./dist/types/utils/standardTransformers/date.d.ts"
23
+ "import": "./dist/index.js",
24
+ "require": "./dist/index.cjs",
25
+ "types": "./dist/index.d.ts"
47
26
  },
48
- "./utils/standardTransformers/error.ts": {
49
- "import": "./dist/utils/standardTransformers/error.mjs",
50
- "require": "./dist/utils/standardTransformers/error.js",
51
- "types": "./dist/types/utils/standardTransformers/error.d.ts"
27
+ "./adapters/console": {
28
+ "import": "./dist/adapters/console/index.js",
29
+ "require": "./dist/adapters/console/index.cjs",
30
+ "types": "./dist/adapters/console/index.d.ts"
52
31
  },
53
- "./utils/standardTransformers/index.ts": {
54
- "import": "./dist/utils/standardTransformers/index.mjs",
55
- "require": "./dist/utils/standardTransformers/index.js",
56
- "types": "./dist/types/utils/standardTransformers/index.d.ts"
57
- },
58
- "./utils/standardTransformers/map.ts": {
59
- "import": "./dist/utils/standardTransformers/map.mjs",
60
- "require": "./dist/utils/standardTransformers/map.js",
61
- "types": "./dist/types/utils/standardTransformers/map.d.ts"
62
- },
63
- "./utils/standardTransformers/regex.ts": {
64
- "import": "./dist/utils/standardTransformers/regex.mjs",
65
- "require": "./dist/utils/standardTransformers/regex.js",
66
- "types": "./dist/types/utils/standardTransformers/regex.d.ts"
67
- },
68
- "./utils/standardTransformers/set.ts": {
69
- "import": "./dist/utils/standardTransformers/set.mjs",
70
- "require": "./dist/utils/standardTransformers/set.js",
71
- "types": "./dist/types/utils/standardTransformers/set.d.ts"
72
- },
73
- "./utils/standardTransformers/url.ts": {
74
- "import": "./dist/utils/standardTransformers/url.mjs",
75
- "require": "./dist/utils/standardTransformers/url.js",
76
- "types": "./dist/types/utils/standardTransformers/url.d.ts"
77
- }
32
+ "./package.json": "./package.json"
78
33
  },
79
34
  "files": [
80
35
  "dist"
@@ -104,51 +59,58 @@
104
59
  "type": "git",
105
60
  "url": "git+https://github.com/hackylabs/deep-redact"
106
61
  },
107
- "scripts": {
108
- "lint": "eslint",
109
- "build": "npm run lint && npm run test && npm run bench && npm run build:esm && npm run build:cjs && npm run update-exports && npm run test:build && npm run update-readme && npm run update-license",
110
- "build:dev": "rm -rf dist && npm run build:esm && npm run build:cjs && npm run update-exports",
111
- "build:esm": "tsc --project tsconfig.esm.json && ./scripts/js-to-mjs.sh",
112
- "build:cjs": "tsc --project tsconfig.cjs.json",
113
- "bench": "npx vitest bench --watch=false",
114
- "bench:dev": "npx vitest bench",
115
- "test:dev": "npx vitest",
116
- "test": "npx vitest run",
117
- "test:build": "npx vitest run test/build.test.ts --reporter=basic --coverage=false",
118
- "test:build:dev": "npm run build:cjs && npm run build:esm && npm run update-exports && npx vitest test/build.test.ts --coverage=false --reporter=basic",
119
- "test:load": "npx vitest run test/load/redact.test.ts --reporter=basic --coverage=false",
120
- "test:load:dev": "npx vitest test/load/redact.test.ts --coverage=false --reporter=basic",
121
- "test:unit": "npx vitest run test/unit --reporter=verbose",
122
- "test:unit:dev": "npx vitest test/unit --coverage=false --reporter=verbose",
123
- "update-readme": "npx ts-node ./scripts/update-readme.ts",
124
- "update-license": "npx ts-node ./scripts/update-license.ts",
125
- "update-exports": "npx ts-node ./scripts/update-exports.ts"
126
- },
127
62
  "//": [
128
- "autocannon, fast-redact and obglob are installed only as internal benchmark comparisons and are not used in the library",
63
+ "deep-redact-v2, deep-redact-v3, deep-redact-v4-baseline (released 4.0.0) and fast-redact are installed only as internal benchmark comparisons and are not used in the library",
129
64
  "all dependencies are for development purposes only"
130
65
  ],
131
66
  "devDependencies": {
132
- "@hackylabs/obglob": "1.1.2",
133
- "@memlab/core": "1.1.34",
134
- "@types/autocannon": "7.12.6",
67
+ "@eslint/js": "9.39.4",
68
+ "@stylistic/eslint-plugin": "4.4.1",
135
69
  "@types/fast-redact": "3.0.4",
136
- "@types/node": "20.14.12",
137
- "@typescript-eslint/eslint-plugin": "7.14.1",
138
- "@typescript-eslint/parser": "7.14.1",
139
- "@vitest/coverage-v8": "2.0.4",
140
- "autocannon": "8.0.0",
141
- "eslint": "8.57.0",
142
- "eslint-config-airbnb-base": "15.0.0",
143
- "eslint-config-airbnb-typescript": "18.0.0",
144
- "eslint-plugin-import": "2.29.1",
145
- "eslint-plugin-n": "17.9.0",
146
- "eslint-plugin-promise": "7.0.0",
70
+ "@types/node": "24.1.0",
71
+ "deep-redact-v2": "npm:@hackylabs/deep-redact@2.2.1",
72
+ "deep-redact-v3": "npm:@hackylabs/deep-redact@^3.0.0",
73
+ "deep-redact-v4-baseline": "npm:@hackylabs/deep-redact@4.0.0",
74
+ "eslint": "9.39.4",
75
+ "eslint-plugin-unicorn": "59.0.1",
147
76
  "fast-redact": "3.5.0",
148
- "typescript": "5.6.2",
149
- "vitest": "2.0.4"
77
+ "globals": "16.5.0",
78
+ "tsdown": "0.21.7",
79
+ "typescript": "6.0.2",
80
+ "typescript-eslint": "8.59.0",
81
+ "vega": "6.2.0",
82
+ "vega-lite": "6.4.3",
83
+ "vitest": "4.1.4"
150
84
  },
151
85
  "editor.formatOnSave": true,
152
86
  "editor.formatOnPaste": true,
153
- "editor.defaultFormatter": "EditorConfig.editorconfig"
154
- }
87
+ "editor.defaultFormatter": "EditorConfig.editorconfig",
88
+ "scripts": {
89
+ "bench": "pnpm run bench:speed",
90
+ "build": "pnpm run verify-generated-files && pnpm exec tsdown",
91
+ "generate": "pnpm run generate-exports && pnpm run generate-readme && pnpm run generate-precedence-doc && pnpm run generate-one-way-redaction-doc && pnpm run generate-fast-redact-migration-doc && pnpm run generate-v3-migration-doc && pnpm run generate-example-docs && pnpm run generate:standardisation-guide",
92
+ "generate-exports": "node --experimental-strip-types ./scripts/generate-exports.ts",
93
+ "generate-fast-redact-migration-doc": "node --experimental-strip-types ./scripts/generate-fast-redact-migration-doc.ts",
94
+ "generate-v3-migration-doc": "node --experimental-strip-types ./scripts/generate-v3-migration-doc.ts",
95
+ "generate-one-way-redaction-doc": "node --experimental-strip-types ./scripts/generate-one-way-redaction-doc.ts",
96
+ "generate-precedence-doc": "node --experimental-strip-types ./scripts/generate-precedence-doc.ts",
97
+ "generate-readme": "node --experimental-strip-types ./scripts/generate-readme.ts",
98
+ "generate:standardisation-guide": "node --experimental-strip-types ./scripts/generate-standardisation-guide.ts",
99
+ "lint": "pnpm exec eslint . && pnpm exec tsc --noEmit",
100
+ "test": "pnpm run build && pnpm run test:contract",
101
+ "test:contract": "pnpm exec vitest run test/build.test.ts test/contract/**/*.test.ts test/security/*.test.ts --reporter=verbose",
102
+ "verify:install-matrix": "pnpm run build && node --experimental-strip-types ./scripts/verify-install-matrix.ts",
103
+ "verify:migration:fast-redact": "pnpm run build && node --experimental-strip-types ./scripts/verify-fast-redact-migration.ts",
104
+ "verify:migration:v3": "pnpm run build && node --experimental-strip-types ./scripts/verify-v3-migration.ts",
105
+ "verify:examples": "pnpm run build && node --experimental-strip-types ./scripts/verify-examples.ts",
106
+ "verify-generated-files": "node --experimental-strip-types ./scripts/verify-generated-files.ts",
107
+ "generate-example-docs": "node --experimental-strip-types ./scripts/generate-example-docs.ts",
108
+ "bench:resource": "pnpm run build && node --expose-gc --experimental-strip-types ./scripts/run-resource-benchmarks.ts",
109
+ "bench:resource:generate-doc": "node --experimental-strip-types ./scripts/generate-resource-benchmark-doc.ts",
110
+ "bench:speed": "pnpm run build && node --experimental-strip-types ./scripts/run-benchmarks.ts",
111
+ "bench:speed:generate-doc": "node --experimental-strip-types ./scripts/generate-benchmark-doc.ts",
112
+ "bench:generate-charts": "node --experimental-strip-types ./scripts/generate-benchmark-charts.ts",
113
+ "verify:resource-benchmarks": "pnpm run build && node --experimental-strip-types ./scripts/verify-resource-benchmarks.ts",
114
+ "verify:speed-benchmarks": "pnpm run build && node --experimental-strip-types ./scripts/verify-speed-benchmarks.ts"
115
+ }
116
+ }
package/dist/index.mjs DELETED
@@ -1,40 +0,0 @@
1
- import { organisedStandardTransformers, standardTransformers } from './utils/standardTransformers/index.mjs';
2
- import RedactorUtils from './utils/index.mjs';
3
- class DeepRedact {
4
- /**
5
- * The redactorUtils instance to handle the redaction.
6
- * @private
7
- */
8
- redactorUtils;
9
- /**
10
- * The configuration for the redaction.
11
- * @private
12
- */
13
- config = {
14
- serialise: false,
15
- };
16
- /**
17
- * Create a new DeepRedact instance with the provided configuration.
18
- * The configuration will be merged with the default configuration.
19
- * `blacklistedKeys` will be normalised to an array inherited from the default configuration as the default values.
20
- * @param {DeepRedactConfig} config. The configuration for the redaction.
21
- */
22
- constructor(config) {
23
- const { serialise, serialize, ...rest } = config;
24
- const englishSerialise = serialise ?? serialize;
25
- if (typeof englishSerialise === 'boolean')
26
- this.config.serialise = englishSerialise;
27
- this.redactorUtils = new RedactorUtils({ ...rest });
28
- }
29
- /**
30
- * Redact the provided value. The value will be stripped of any circular references and other unsupported data types, before being redacted according to the configuration and finally serialised if required.
31
- * @param {unknown} value The value to redact.
32
- * @returns {unknown} The redacted value.
33
- * @throws {Error} If the value cannot be serialised to JSON and serialise is true.
34
- */
35
- redact = (value) => {
36
- const redacted = this.redactorUtils.traverse(value);
37
- return this.config.serialise ? JSON.stringify(redacted) : redacted;
38
- };
39
- }
40
- export { DeepRedact, DeepRedact as default, standardTransformers, organisedStandardTransformers, };
@@ -1,29 +0,0 @@
1
- import type { DeepRedactConfig, RedactorUtilsConfig, BlacklistKeyConfig, Types, Transformer, ComplexStringTest, BaseDeepRedactConfig, OrganisedTransformers, TransformerConfig } from './types.js';
2
- import { organisedStandardTransformers, standardTransformers } from './utils/standardTransformers/index.js';
3
- declare class DeepRedact {
4
- /**
5
- * The redactorUtils instance to handle the redaction.
6
- * @private
7
- */
8
- private redactorUtils;
9
- /**
10
- * The configuration for the redaction.
11
- * @private
12
- */
13
- private readonly config;
14
- /**
15
- * Create a new DeepRedact instance with the provided configuration.
16
- * The configuration will be merged with the default configuration.
17
- * `blacklistedKeys` will be normalised to an array inherited from the default configuration as the default values.
18
- * @param {DeepRedactConfig} config. The configuration for the redaction.
19
- */
20
- constructor(config: DeepRedactConfig);
21
- /**
22
- * Redact the provided value. The value will be stripped of any circular references and other unsupported data types, before being redacted according to the configuration and finally serialised if required.
23
- * @param {unknown} value The value to redact.
24
- * @returns {unknown} The redacted value.
25
- * @throws {Error} If the value cannot be serialised to JSON and serialise is true.
26
- */
27
- redact: (value: unknown) => unknown;
28
- }
29
- export { DeepRedact, DeepRedact as default, type BaseDeepRedactConfig, type RedactorUtilsConfig, type BlacklistKeyConfig, type ComplexStringTest, type Transformer, type Types, type OrganisedTransformers, type TransformerConfig, standardTransformers, organisedStandardTransformers, };