@hackylabs/deep-redact 3.0.4 → 4.0.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/LICENSE +1 -1
- package/README.md +221 -106
- package/dist/adapters/console/index.cjs +74 -0
- package/dist/adapters/console/index.d.cts +22 -0
- package/dist/adapters/console/index.d.ts +22 -0
- package/dist/adapters/console/index.js +73 -0
- package/dist/index.cjs +2743 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2741 -55
- package/dist/node-console-sink-BnRUkAAr.cjs +19 -0
- package/dist/node-console-sink-DaQleNZ8.js +14 -0
- package/dist/public-Da0aARA9.d.cts +127 -0
- package/dist/public-Dw4ycNzO.d.ts +127 -0
- package/package.json +67 -102
- package/dist/index.mjs +0 -40
- package/dist/types/index.d.ts +0 -29
- package/dist/types/types.d.ts +0 -224
- package/dist/types/utils/TransformerRegistry.d.ts +0 -52
- package/dist/types/utils/index.d.ts +0 -131
- package/dist/types/utils/standardTransformers/bigint.d.ts +0 -2
- package/dist/types/utils/standardTransformers/date.d.ts +0 -2
- package/dist/types/utils/standardTransformers/error.d.ts +0 -2
- package/dist/types/utils/standardTransformers/index.d.ts +0 -9
- package/dist/types/utils/standardTransformers/map.d.ts +0 -2
- package/dist/types/utils/standardTransformers/regex.d.ts +0 -2
- package/dist/types/utils/standardTransformers/set.d.ts +0 -2
- package/dist/types/utils/standardTransformers/url.d.ts +0 -2
- package/dist/types.js +0 -2
- package/dist/types.mjs +0 -1
- package/dist/utils/TransformerRegistry.js +0 -100
- package/dist/utils/TransformerRegistry.mjs +0 -94
- package/dist/utils/index.js +0 -471
- package/dist/utils/index.mjs +0 -467
- package/dist/utils/standardTransformers/bigint.js +0 -10
- package/dist/utils/standardTransformers/bigint.mjs +0 -6
- package/dist/utils/standardTransformers/date.js +0 -9
- package/dist/utils/standardTransformers/date.mjs +0 -5
- package/dist/utils/standardTransformers/error.js +0 -16
- package/dist/utils/standardTransformers/error.mjs +0 -12
- package/dist/utils/standardTransformers/index.js +0 -38
- package/dist/utils/standardTransformers/index.mjs +0 -35
- package/dist/utils/standardTransformers/map.js +0 -9
- package/dist/utils/standardTransformers/map.mjs +0 -5
- package/dist/utils/standardTransformers/regex.js +0 -15
- package/dist/utils/standardTransformers/regex.mjs +0 -11
- package/dist/utils/standardTransformers/set.js +0 -9
- package/dist/utils/standardTransformers/set.mjs +0 -5
- package/dist/utils/standardTransformers/url.js +0 -9
- 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,75 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackylabs/deep-redact",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.0.0",
|
|
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
|
-
"
|
|
10
|
-
"
|
|
11
|
-
|
|
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
|
-
"
|
|
14
|
-
"import": "./dist/index.
|
|
15
|
-
"require": "./dist/index.
|
|
16
|
-
"types": "./dist/
|
|
17
|
-
},
|
|
18
|
-
"./types.ts": {
|
|
19
|
-
"import": "./dist/types.mjs",
|
|
20
|
-
"require": "./dist/types.js",
|
|
21
|
-
"types": "./dist/types/types.d.ts"
|
|
22
|
-
},
|
|
23
|
-
"./utils/TransformerRegistry.ts": {
|
|
24
|
-
"import": "./dist/utils/TransformerRegistry.mjs",
|
|
25
|
-
"require": "./dist/utils/TransformerRegistry.js",
|
|
26
|
-
"types": "./dist/types/utils/TransformerRegistry.d.ts"
|
|
27
|
-
},
|
|
28
|
-
"./utils/index.ts": {
|
|
29
|
-
"import": "./dist/utils/index.mjs",
|
|
30
|
-
"require": "./dist/utils/index.js",
|
|
31
|
-
"types": "./dist/types/utils/index.d.ts"
|
|
32
|
-
},
|
|
33
|
-
"./utils/standardTransformers/bigint.ts": {
|
|
34
|
-
"import": "./dist/utils/standardTransformers/bigint.mjs",
|
|
35
|
-
"require": "./dist/utils/standardTransformers/bigint.js",
|
|
36
|
-
"types": "./dist/types/utils/standardTransformers/bigint.d.ts"
|
|
37
|
-
},
|
|
38
|
-
"./utils/standardTransformers/date.ts": {
|
|
39
|
-
"import": "./dist/utils/standardTransformers/date.mjs",
|
|
40
|
-
"require": "./dist/utils/standardTransformers/date.js",
|
|
41
|
-
"types": "./dist/types/utils/standardTransformers/date.d.ts"
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
|
+
"types": "./dist/index.d.ts"
|
|
42
26
|
},
|
|
43
|
-
"./
|
|
44
|
-
"import": "./dist/
|
|
45
|
-
"require": "./dist/
|
|
46
|
-
"types": "./dist/
|
|
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"
|
|
47
31
|
},
|
|
48
|
-
"./
|
|
49
|
-
"import": "./dist/utils/standardTransformers/index.mjs",
|
|
50
|
-
"require": "./dist/utils/standardTransformers/index.js",
|
|
51
|
-
"types": "./dist/types/utils/standardTransformers/index.d.ts"
|
|
52
|
-
},
|
|
53
|
-
"./utils/standardTransformers/map.ts": {
|
|
54
|
-
"import": "./dist/utils/standardTransformers/map.mjs",
|
|
55
|
-
"require": "./dist/utils/standardTransformers/map.js",
|
|
56
|
-
"types": "./dist/types/utils/standardTransformers/map.d.ts"
|
|
57
|
-
},
|
|
58
|
-
"./utils/standardTransformers/regex.ts": {
|
|
59
|
-
"import": "./dist/utils/standardTransformers/regex.mjs",
|
|
60
|
-
"require": "./dist/utils/standardTransformers/regex.js",
|
|
61
|
-
"types": "./dist/types/utils/standardTransformers/regex.d.ts"
|
|
62
|
-
},
|
|
63
|
-
"./utils/standardTransformers/set.ts": {
|
|
64
|
-
"import": "./dist/utils/standardTransformers/set.mjs",
|
|
65
|
-
"require": "./dist/utils/standardTransformers/set.js",
|
|
66
|
-
"types": "./dist/types/utils/standardTransformers/set.d.ts"
|
|
67
|
-
},
|
|
68
|
-
"./utils/standardTransformers/url.ts": {
|
|
69
|
-
"import": "./dist/utils/standardTransformers/url.mjs",
|
|
70
|
-
"require": "./dist/utils/standardTransformers/url.js",
|
|
71
|
-
"types": "./dist/types/utils/standardTransformers/url.d.ts"
|
|
72
|
-
}
|
|
32
|
+
"./package.json": "./package.json"
|
|
73
33
|
},
|
|
74
34
|
"files": [
|
|
75
35
|
"dist"
|
|
@@ -99,51 +59,56 @@
|
|
|
99
59
|
"type": "git",
|
|
100
60
|
"url": "git+https://github.com/hackylabs/deep-redact"
|
|
101
61
|
},
|
|
102
|
-
"scripts": {
|
|
103
|
-
"lint": "eslint",
|
|
104
|
-
"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",
|
|
105
|
-
"build:dev": "rm -rf dist && npm run build:esm && npm run build:cjs && npm run update-exports",
|
|
106
|
-
"build:esm": "tsc --project tsconfig.esm.json && ./scripts/js-to-mjs.sh",
|
|
107
|
-
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
108
|
-
"bench": "npx vitest bench --watch=false",
|
|
109
|
-
"bench:dev": "npx vitest bench",
|
|
110
|
-
"test:dev": "npx vitest",
|
|
111
|
-
"test": "npx vitest run",
|
|
112
|
-
"test:build": "npx vitest run test/build.test.ts --reporter=basic --coverage=false",
|
|
113
|
-
"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",
|
|
114
|
-
"test:load": "npx vitest run test/load/redact.test.ts --reporter=basic --coverage=false",
|
|
115
|
-
"test:load:dev": "npx vitest test/load/redact.test.ts --coverage=false --reporter=basic",
|
|
116
|
-
"test:unit": "npx vitest run test/unit --reporter=verbose",
|
|
117
|
-
"test:unit:dev": "npx vitest test/unit --coverage=false --reporter=verbose",
|
|
118
|
-
"update-readme": "npx ts-node ./scripts/update-readme.ts",
|
|
119
|
-
"update-license": "npx ts-node ./scripts/update-license.ts",
|
|
120
|
-
"update-exports": "npx ts-node ./scripts/update-exports.ts"
|
|
121
|
-
},
|
|
122
62
|
"//": [
|
|
123
|
-
"
|
|
63
|
+
"deep-redact-v3 and fast-redact are installed only as internal benchmark comparisons and are not used in the library",
|
|
124
64
|
"all dependencies are for development purposes only"
|
|
125
65
|
],
|
|
126
66
|
"devDependencies": {
|
|
127
|
-
"@
|
|
128
|
-
"@
|
|
129
|
-
"@types/autocannon": "7.12.6",
|
|
67
|
+
"@eslint/js": "9.39.4",
|
|
68
|
+
"@stylistic/eslint-plugin": "4.4.1",
|
|
130
69
|
"@types/fast-redact": "3.0.4",
|
|
131
|
-
"@types/node": "
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
135
|
-
"autocannon": "8.0.0",
|
|
136
|
-
"eslint": "8.57.0",
|
|
137
|
-
"eslint-config-airbnb-base": "15.0.0",
|
|
138
|
-
"eslint-config-airbnb-typescript": "18.0.0",
|
|
139
|
-
"eslint-plugin-import": "2.29.1",
|
|
140
|
-
"eslint-plugin-n": "17.9.0",
|
|
141
|
-
"eslint-plugin-promise": "7.0.0",
|
|
70
|
+
"@types/node": "24.1.0",
|
|
71
|
+
"deep-redact-v3": "npm:@hackylabs/deep-redact@^3.0.0",
|
|
72
|
+
"eslint": "9.39.4",
|
|
73
|
+
"eslint-plugin-unicorn": "59.0.1",
|
|
142
74
|
"fast-redact": "3.5.0",
|
|
143
|
-
"
|
|
144
|
-
"
|
|
75
|
+
"globals": "16.5.0",
|
|
76
|
+
"tsdown": "0.21.7",
|
|
77
|
+
"typescript": "6.0.2",
|
|
78
|
+
"typescript-eslint": "8.59.0",
|
|
79
|
+
"vega": "6.2.0",
|
|
80
|
+
"vega-lite": "6.4.3",
|
|
81
|
+
"vitest": "4.1.4"
|
|
145
82
|
},
|
|
146
83
|
"editor.formatOnSave": true,
|
|
147
84
|
"editor.formatOnPaste": true,
|
|
148
|
-
"editor.defaultFormatter": "EditorConfig.editorconfig"
|
|
149
|
-
|
|
85
|
+
"editor.defaultFormatter": "EditorConfig.editorconfig",
|
|
86
|
+
"scripts": {
|
|
87
|
+
"bench": "pnpm run bench:speed",
|
|
88
|
+
"build": "pnpm run verify-generated-files && pnpm exec tsdown",
|
|
89
|
+
"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",
|
|
90
|
+
"generate-exports": "node --experimental-strip-types ./scripts/generate-exports.ts",
|
|
91
|
+
"generate-fast-redact-migration-doc": "node --experimental-strip-types ./scripts/generate-fast-redact-migration-doc.ts",
|
|
92
|
+
"generate-v3-migration-doc": "node --experimental-strip-types ./scripts/generate-v3-migration-doc.ts",
|
|
93
|
+
"generate-one-way-redaction-doc": "node --experimental-strip-types ./scripts/generate-one-way-redaction-doc.ts",
|
|
94
|
+
"generate-precedence-doc": "node --experimental-strip-types ./scripts/generate-precedence-doc.ts",
|
|
95
|
+
"generate-readme": "node --experimental-strip-types ./scripts/generate-readme.ts",
|
|
96
|
+
"generate:standardisation-guide": "node --experimental-strip-types ./scripts/generate-standardisation-guide.ts",
|
|
97
|
+
"lint": "pnpm exec eslint . && pnpm exec tsc --noEmit",
|
|
98
|
+
"test": "pnpm run build && pnpm run test:contract",
|
|
99
|
+
"test:contract": "pnpm exec vitest run test/build.test.ts test/contract/**/*.test.ts test/security/*.test.ts --reporter=verbose",
|
|
100
|
+
"verify:install-matrix": "pnpm run build && node --experimental-strip-types ./scripts/verify-install-matrix.ts",
|
|
101
|
+
"verify:migration:fast-redact": "pnpm run build && node --experimental-strip-types ./scripts/verify-fast-redact-migration.ts",
|
|
102
|
+
"verify:migration:v3": "pnpm run build && node --experimental-strip-types ./scripts/verify-v3-migration.ts",
|
|
103
|
+
"verify:examples": "pnpm run build && node --experimental-strip-types ./scripts/verify-examples.ts",
|
|
104
|
+
"verify-generated-files": "node --experimental-strip-types ./scripts/verify-generated-files.ts",
|
|
105
|
+
"generate-example-docs": "node --experimental-strip-types ./scripts/generate-example-docs.ts",
|
|
106
|
+
"bench:resource": "pnpm run build && node --expose-gc --experimental-strip-types ./scripts/run-resource-benchmarks.ts",
|
|
107
|
+
"bench:resource:generate-doc": "node --experimental-strip-types ./scripts/generate-resource-benchmark-doc.ts",
|
|
108
|
+
"bench:speed": "pnpm run build && node --experimental-strip-types ./scripts/run-benchmarks.ts",
|
|
109
|
+
"bench:speed:generate-doc": "node --experimental-strip-types ./scripts/generate-benchmark-doc.ts",
|
|
110
|
+
"bench:generate-charts": "node --experimental-strip-types ./scripts/generate-benchmark-charts.ts",
|
|
111
|
+
"verify:resource-benchmarks": "pnpm run build && node --experimental-strip-types ./scripts/verify-resource-benchmarks.ts",
|
|
112
|
+
"verify:speed-benchmarks": "pnpm run build && node --experimental-strip-types ./scripts/verify-speed-benchmarks.ts"
|
|
113
|
+
}
|
|
114
|
+
}
|
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, };
|
package/dist/types/index.d.ts
DELETED
|
@@ -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, };
|