field-redactor 1.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customObjectChecker.d.ts","sourceRoot":"","sources":["../src/customObjectChecker.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;GAEG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,aAAa,CAAsB;IAE3C;;;OAGG;gBACS,aAAa,CAAC,EAAE,YAAY,EAAE;IAK1C;;;;OAIG;IACI,uBAAuB,CAAC,KAAK,EAAE,GAAG,GAAG,YAAY,GAAG,SAAS;IASpE,OAAO,CAAC,cAAc;IAkBtB,OAAO,CAAC,gCAAgC;IAUxC,OAAO,CAAC,qBAAqB;CAoB9B"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CustomObjectChecker = void 0;
4
+ const errors_1 = require("./errors");
5
+ /**
6
+ * Utility for determining if a given object matches a CustomObject schema.
7
+ */
8
+ class CustomObjectChecker {
9
+ /**
10
+ * Creates a CustomObjectChecker with the specified CustomObjects.
11
+ * @param customObjects The CustomObjects to check against.
12
+ */
13
+ constructor(customObjects) {
14
+ this.customObjects = [];
15
+ this.validateCustomObjects(customObjects);
16
+ this.customObjects = customObjects ? customObjects : [];
17
+ }
18
+ /**
19
+ * Determines if the input value matches any of the custom objects provided in the constructor.
20
+ * @param value The value to compare against the custom objects.
21
+ * @returns A matching custom object if one exists, otherwise undefined.
22
+ */
23
+ getMatchingCustomObject(value) {
24
+ for (const customObject of this.customObjects) {
25
+ if (this.isCustomObject(value, customObject)) {
26
+ return customObject;
27
+ }
28
+ }
29
+ return undefined;
30
+ }
31
+ isCustomObject(value, customObject) {
32
+ if (typeof value !== 'object' || !value || Array.isArray(value)) {
33
+ return false;
34
+ }
35
+ if (!this.customObjectDoesNotHaveExtraKeys(value, customObject)) {
36
+ return false;
37
+ }
38
+ for (const key of Object.keys(value)) {
39
+ if (!customObject.hasOwnProperty(key)) {
40
+ return false;
41
+ }
42
+ }
43
+ return true;
44
+ }
45
+ customObjectDoesNotHaveExtraKeys(value, customObject) {
46
+ for (const key of Object.keys(customObject)) {
47
+ if (!value.hasOwnProperty(key)) {
48
+ return false;
49
+ }
50
+ }
51
+ return true;
52
+ }
53
+ validateCustomObjects(customObjects) {
54
+ if (!customObjects || customObjects.length <= 1) {
55
+ return;
56
+ }
57
+ for (let i = 0; i < customObjects.length - 1; i++) {
58
+ const current = customObjects[i];
59
+ const keys = Object.keys(current);
60
+ for (let j = i + 1; j < customObjects.length; j++) {
61
+ const other = customObjects[j];
62
+ const otherKeys = Object.keys(other);
63
+ const commonKeys = keys.filter((key) => otherKeys.includes(key));
64
+ if (commonKeys.length === keys.length && commonKeys.length === otherKeys.length) {
65
+ throw new errors_1.FieldRedactorConfigurationError(`Custom Objects at indexes ${i} and ${j} cannot have identical keys: ${commonKeys}`);
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+ exports.CustomObjectChecker = CustomObjectChecker;
72
+ //# sourceMappingURL=customObjectChecker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customObjectChecker.js","sourceRoot":"","sources":["../src/customObjectChecker.ts"],"names":[],"mappings":";;;AAAA,qCAA2D;AAG3D;;GAEG;AACH,MAAa,mBAAmB;IAG9B;;;OAGG;IACH,YAAY,aAA8B;QANlC,kBAAa,GAAmB,EAAE,CAAC;QAOzC,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACI,uBAAuB,CAAC,KAAU;QACvC,KAAK,MAAM,YAAY,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YAC9C,IAAI,IAAI,CAAC,cAA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AG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAClC,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBAClD,MAAM,KAAK,GAAiB,aAAa,CAAC,CAAC,CAAC,CAAC;gBAC7C,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBACrC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;gBACjE,IAAI,UAAU,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;oBAChF,MAAM,IAAI,wCAA+B,CACvC,6BAA6B,CAAC,QAAQ,CAAC,gCAAgC,UAAU,EAAE,CACpF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA1ED,kDA0EC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Top-Level Field Redactor error thrown when there is an error redacting a JSON object.
3
+ */
4
+ export declare class FieldRedactorError extends Error {
5
+ constructor(message: string);
6
+ }
7
+ /**
8
+ * Error thrown when there is a Configuration issue with the FieldRedactor, such as two
9
+ * Custom Objects with identical keys.
10
+ */
11
+ export declare class FieldRedactorConfigurationError extends FieldRedactorError {
12
+ constructor(message: string);
13
+ }
14
+ /**
15
+ * Error thrown when the input value to the FieldRedactor fails validation, such as not being a JSON object.
16
+ */
17
+ export declare class FieldRedactorValidationError extends FieldRedactorError {
18
+ constructor(message: string);
19
+ }
20
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED;;;GAGG;AACH,qBAAa,+BAAgC,SAAQ,kBAAkB;gBACzD,OAAO,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,kBAAkB;gBACtD,OAAO,EAAE,MAAM;CAI5B"}
package/dist/errors.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldRedactorValidationError = exports.FieldRedactorConfigurationError = exports.FieldRedactorError = void 0;
4
+ /**
5
+ * Top-Level Field Redactor error thrown when there is an error redacting a JSON object.
6
+ */
7
+ class FieldRedactorError extends Error {
8
+ constructor(message) {
9
+ super(message);
10
+ this.name = 'FieldRedactorError';
11
+ }
12
+ }
13
+ exports.FieldRedactorError = FieldRedactorError;
14
+ /**
15
+ * Error thrown when there is a Configuration issue with the FieldRedactor, such as two
16
+ * Custom Objects with identical keys.
17
+ */
18
+ class FieldRedactorConfigurationError extends FieldRedactorError {
19
+ constructor(message) {
20
+ super(message);
21
+ this.name = 'FieldRedactorConfigurationError';
22
+ }
23
+ }
24
+ exports.FieldRedactorConfigurationError = FieldRedactorConfigurationError;
25
+ /**
26
+ * Error thrown when the input value to the FieldRedactor fails validation, such as not being a JSON object.
27
+ */
28
+ class FieldRedactorValidationError extends FieldRedactorError {
29
+ constructor(message) {
30
+ super(message);
31
+ this.name = 'FieldRedactorValidationError';
32
+ }
33
+ }
34
+ exports.FieldRedactorValidationError = FieldRedactorValidationError;
35
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AALD,gDAKC;AAED;;;GAGG;AACH,MAAa,+BAAgC,SAAQ,kBAAkB;IACrE,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iCAAiC,CAAC;IAChD,CAAC;CACF;AALD,0EAKC;AAED;;GAEG;AACH,MAAa,4BAA6B,SAAQ,kBAAkB;IAClE,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF;AALD,oEAKC"}
@@ -0,0 +1,25 @@
1
+ import { FieldRedactorConfig } from './types';
2
+ /**
3
+ * FieldRedactor is a highly customizable JSON object field redactor. It conditionally redacts fields based on
4
+ * the secrets, deepSecrets, fullSecrets, and custom objects provided in the configuration. Refer to the README.md
5
+ * for more details.
6
+ */
7
+ export declare class FieldRedactor {
8
+ private deepCopy;
9
+ private readonly objectRedactor;
10
+ constructor(config?: FieldRedactorConfig);
11
+ /**
12
+ * Conditionally redacts fields in the JSON object based on the configuration provided in the constructor and returns the
13
+ * redacted result.
14
+ * @param value The JSON value to redact.
15
+ * @returns The redacted JSON object.
16
+ */
17
+ redact(value: any): Promise<any>;
18
+ /**
19
+ * Conditionally redacts fields in the JSON object in place based on the configuration provided in the constructor.
20
+ * @param value The JSON value to redact in place.
21
+ */
22
+ redactInPlace(value: any): Promise<void>;
23
+ private validateInput;
24
+ }
25
+ //# sourceMappingURL=fieldRedactor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldRedactor.d.ts","sourceRoot":"","sources":["../src/fieldRedactor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAO9C;;;;GAIG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAwC;IACxD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;gBACpC,MAAM,CAAC,EAAE,mBAAmB;IA4BxC;;;;;OAKG;IACU,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAK7C;;;OAGG;IACU,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IASrD,OAAO,CAAC,aAAa;CAKtB"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FieldRedactor = void 0;
16
+ const rfdc_1 = __importDefault(require("rfdc"));
17
+ const objectRedactor_1 = require("./objectRedactor");
18
+ const primitiveRedactor_1 = require("./primitiveRedactor");
19
+ const secretManager_1 = require("./secretManager");
20
+ const customObjectChecker_1 = require("./customObjectChecker");
21
+ const errors_1 = require("./errors");
22
+ /**
23
+ * FieldRedactor is a highly customizable JSON object field redactor. It conditionally redacts fields based on
24
+ * the secrets, deepSecrets, fullSecrets, and custom objects provided in the configuration. Refer to the README.md
25
+ * for more details.
26
+ */
27
+ class FieldRedactor {
28
+ constructor(config) {
29
+ this.deepCopy = (0, rfdc_1.default)({ proto: true, circles: true });
30
+ const { ignoreBooleans, ignoreNullOrUndefined, redactor, secretKeys, deepSecretKeys, fullSecretKeys, customObjects } = config || {};
31
+ const primitiveRedactor = new primitiveRedactor_1.PrimitiveRedactor({
32
+ ignoreBooleans,
33
+ ignoreNullOrUndefined,
34
+ redactor
35
+ });
36
+ const secretManager = new secretManager_1.SecretManager({
37
+ secretKeys,
38
+ deepSecretKeys,
39
+ fullSecretKeys
40
+ });
41
+ const customObjectChecker = new customObjectChecker_1.CustomObjectChecker(customObjects);
42
+ this.objectRedactor = new objectRedactor_1.ObjectRedactor(primitiveRedactor, secretManager, customObjectChecker);
43
+ }
44
+ /**
45
+ * Conditionally redacts fields in the JSON object based on the configuration provided in the constructor and returns the
46
+ * redacted result.
47
+ * @param value The JSON value to redact.
48
+ * @returns The redacted JSON object.
49
+ */
50
+ redact(value) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ const copy = this.deepCopy(value);
53
+ return this.redactInPlace(copy);
54
+ });
55
+ }
56
+ /**
57
+ * Conditionally redacts fields in the JSON object in place based on the configuration provided in the constructor.
58
+ * @param value The JSON value to redact in place.
59
+ */
60
+ redactInPlace(value) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ this.validateInput(value);
63
+ try {
64
+ return this.objectRedactor.redactInPlace(value);
65
+ }
66
+ catch (e) {
67
+ throw new errors_1.FieldRedactorError(e.message);
68
+ }
69
+ });
70
+ }
71
+ validateInput(value) {
72
+ if (!value || typeof value !== 'object' || value instanceof Date) {
73
+ throw new errors_1.FieldRedactorValidationError('Input value must be a JSON object');
74
+ }
75
+ }
76
+ }
77
+ exports.FieldRedactor = FieldRedactor;
78
+ //# sourceMappingURL=fieldRedactor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fieldRedactor.js","sourceRoot":"","sources":["../src/fieldRedactor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAwB;AAExB,qDAAkD;AAClD,2DAAwD;AACxD,mDAAgD;AAChD,+DAA4D;AAC5D,qCAA4E;AAE5E;;;;GAIG;AACH,MAAa,aAAa;IAGxB,YAAY,MAA4B;QAFhC,aAAQ,GAAG,IAAA,cAAI,EAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OA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A4DC"}
@@ -0,0 +1,5 @@
1
+ import { FieldRedactor } from './fieldRedactor';
2
+ export { CustomObjectMatchType, Redactor, FieldRedactorConfig, CustomObject } from './types';
3
+ export { FieldRedactor };
4
+ export default FieldRedactor;
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,CAAC;AACzB,eAAe,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldRedactor = exports.CustomObjectMatchType = void 0;
4
+ const fieldRedactor_1 = require("./fieldRedactor");
5
+ Object.defineProperty(exports, "FieldRedactor", { enumerable: true, get: function () { return fieldRedactor_1.FieldRedactor; } });
6
+ var types_1 = require("./types");
7
+ Object.defineProperty(exports, "CustomObjectMatchType", { enumerable: true, get: function () { return types_1.CustomObjectMatchType; } });
8
+ exports.default = fieldRedactor_1.FieldRedactor;
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAEvC,8FAFA,6BAAa,OAEA;AADtB,iCAA6F;AAApF,8GAAA,qBAAqB,OAAA;AAE9B,kBAAe,6BAAa,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { SecretManager } from './secretManager';
2
+ import { CustomObjectChecker } from './customObjectChecker';
3
+ import { PrimitiveRedactor } from './primitiveRedactor';
4
+ /**
5
+ * Redacts fields in a JSON object using the secretManager, primitiveRedactor, and CustomObjectChecker provided in the
6
+ * constructor. The redaction is done in place and the redacted object is returned. CustomObjects take highest precedence,
7
+ * followed by fullSecretKeys, then deepSecretKeys, and finally secretKeys. If a field is an object or an array it is
8
+ * assessed recursively unless otherwise configured by a CustomObject or deepSecretKey.
9
+ */
10
+ export declare class ObjectRedactor {
11
+ private readonly primitiveRedactor;
12
+ private readonly secretManager;
13
+ private readonly checker;
14
+ constructor(primitiveRedactor: PrimitiveRedactor, secretManager: SecretManager, checker: CustomObjectChecker);
15
+ /**
16
+ * Conditionally redacts fields in the JSON object in place based on the configuration using the
17
+ * primitive redactor, custom object checker, and secret manager provided in the constructor.
18
+ * @param value The JSON value to redact in place.
19
+ * @returns The JSON value provided in the argument.
20
+ */
21
+ redactInPlace(value: any): Promise<any>;
22
+ private redactSecretObjectFields;
23
+ private redactArrayInObject;
24
+ private redactObjectsInArray;
25
+ private redactAllArrayValues;
26
+ private redactObjectInObject;
27
+ private redactCustomObject;
28
+ private handlecustomObjectValueIfObject;
29
+ private handleCustomObjectValueIfArray;
30
+ private handleCustomObjectArrayValueIfStringKeySpecified;
31
+ private getStringValue;
32
+ private handleCustomObjectArrayValueIfMatchTypeSpecified;
33
+ private handleCustomObjectObjectValueIfStringKeySpecified;
34
+ private handleCustomObjectOjectValueIfMatchTypeSpecified;
35
+ private handleCustomObjectValueIfPrimitive;
36
+ private handleCustomObjectPrimitiveValueIfMatchTypeSpecified;
37
+ private handleCustomObjectPrimitiveValueIfStringKeySpecified;
38
+ private getStringSpecifiedCustomObjectSecretKeyValueIfExists;
39
+ private isObject;
40
+ private redactPrimitiveValueIfSecret;
41
+ }
42
+ //# sourceMappingURL=objectRedactor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectRedactor.d.ts","sourceRoot":"","sources":["../src/objectRedactor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;;;GAKG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAClC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAFP,iBAAiB,EAAE,iBAAiB,EACpC,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,mBAAmB;IAG/C;;;;;OAKG;IACU,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;YAWtC,wBAAwB;YAkBxB,mBAAmB;YASnB,oBAAoB;YAkBpB,oBAAoB;YAqBpB,oBAAoB;YAUpB,kBAAkB;YAYlB,+BAA+B;YAa/B,8BAA8B;YAa9B,gDAAgD;IAW9D,OAAO,CAAC,cAAc;YAUR,gDAAgD;YAsBhD,iDAAiD;YAajD,gDAAgD;YAmBhD,kCAAkC;YAQlC,oDAAoD;YAgBpD,oDAAoD;IAalE,OAAO,CAAC,oDAAoD;IAS5D,OAAO,CAAC,QAAQ;YAIF,4BAA4B;CAS3C"}
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ObjectRedactor = void 0;
13
+ const types_1 = require("./types");
14
+ /**
15
+ * Redacts fields in a JSON object using the secretManager, primitiveRedactor, and CustomObjectChecker provided in the
16
+ * constructor. The redaction is done in place and the redacted object is returned. CustomObjects take highest precedence,
17
+ * followed by fullSecretKeys, then deepSecretKeys, and finally secretKeys. If a field is an object or an array it is
18
+ * assessed recursively unless otherwise configured by a CustomObject or deepSecretKey.
19
+ */
20
+ class ObjectRedactor {
21
+ constructor(primitiveRedactor, secretManager, checker) {
22
+ this.primitiveRedactor = primitiveRedactor;
23
+ this.secretManager = secretManager;
24
+ this.checker = checker;
25
+ }
26
+ /**
27
+ * Conditionally redacts fields in the JSON object in place based on the configuration using the
28
+ * primitive redactor, custom object checker, and secret manager provided in the constructor.
29
+ * @param value The JSON value to redact in place.
30
+ * @returns The JSON value provided in the argument.
31
+ */
32
+ redactInPlace(value) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ const customObject = this.checker.getMatchingCustomObject(value);
35
+ if (customObject) {
36
+ yield this.redactCustomObject(value, customObject);
37
+ }
38
+ else {
39
+ yield this.redactSecretObjectFields(value);
40
+ }
41
+ return value;
42
+ });
43
+ }
44
+ redactSecretObjectFields(object_1) {
45
+ return __awaiter(this, arguments, void 0, function* (object, forceDeepRedaction = false) {
46
+ for (const key of Object.keys(object)) {
47
+ const value = object[key];
48
+ const customObject = this.checker.getMatchingCustomObject(value);
49
+ if (customObject) {
50
+ yield this.redactCustomObject(value, customObject);
51
+ }
52
+ else if (this.secretManager.isFullSecretKey(key)) {
53
+ object[key] = yield this.primitiveRedactor.redactValue(this.getStringValue(value));
54
+ }
55
+ else if (Array.isArray(object[key])) {
56
+ object[key] = yield this.redactArrayInObject(value, key, forceDeepRedaction);
57
+ }
58
+ else if (this.isObject(object[key])) {
59
+ yield this.redactObjectInObject(object[key], key, forceDeepRedaction);
60
+ }
61
+ else {
62
+ object[key] = yield this.redactPrimitiveValueIfSecret(key, value, forceDeepRedaction);
63
+ }
64
+ }
65
+ });
66
+ }
67
+ redactArrayInObject(array, key, forceDeepRedaction) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ const deepSecretKey = this.secretManager.isDeepSecretKey(key);
70
+ if (this.secretManager.isSecretKey(key) || deepSecretKey || forceDeepRedaction) {
71
+ return this.redactAllArrayValues(array, forceDeepRedaction || deepSecretKey);
72
+ }
73
+ else {
74
+ return yield this.redactObjectsInArray(array);
75
+ }
76
+ });
77
+ }
78
+ redactObjectsInArray(array) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const promises = array.map((value) => __awaiter(this, void 0, void 0, function* () {
81
+ if (this.isObject(value)) {
82
+ const customObject = this.checker.getMatchingCustomObject(value);
83
+ if (customObject) {
84
+ yield this.redactCustomObject(value, customObject);
85
+ return value;
86
+ }
87
+ else {
88
+ yield this.redactSecretObjectFields(value, false);
89
+ }
90
+ }
91
+ return value;
92
+ }));
93
+ return Promise.all(promises);
94
+ });
95
+ }
96
+ redactAllArrayValues(array, forceDeepRedaction) {
97
+ return __awaiter(this, void 0, void 0, function* () {
98
+ const promises = array.map((value) => __awaiter(this, void 0, void 0, function* () {
99
+ if (Array.isArray(value)) {
100
+ return this.redactAllArrayValues(value, forceDeepRedaction);
101
+ }
102
+ else if (!this.isObject(value)) {
103
+ return this.primitiveRedactor.redactValue(value);
104
+ }
105
+ else {
106
+ const customObject = this.checker.getMatchingCustomObject(value);
107
+ if (customObject) {
108
+ yield this.redactCustomObject(value, customObject);
109
+ return Promise.resolve(value);
110
+ }
111
+ else {
112
+ yield this.redactSecretObjectFields(value, forceDeepRedaction);
113
+ return Promise.resolve(value);
114
+ }
115
+ }
116
+ }));
117
+ return Promise.all(promises);
118
+ });
119
+ }
120
+ redactObjectInObject(value, key, forceDeepRedaction) {
121
+ return __awaiter(this, void 0, void 0, function* () {
122
+ const customObject = this.checker.getMatchingCustomObject(value);
123
+ if (customObject) {
124
+ yield this.redactCustomObject(value, customObject);
125
+ }
126
+ else {
127
+ const secretObject = forceDeepRedaction || this.secretManager.isDeepSecretKey(key);
128
+ yield this.redactSecretObjectFields(value, secretObject);
129
+ }
130
+ });
131
+ }
132
+ redactCustomObject(value, customObject) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ for (const key of Object.keys(customObject)) {
135
+ if (Array.isArray(value[key])) {
136
+ yield this.handleCustomObjectValueIfArray(value, key, customObject);
137
+ }
138
+ else if (this.isObject(value[key])) {
139
+ yield this.handlecustomObjectValueIfObject(value, key, customObject);
140
+ }
141
+ else {
142
+ yield this.handleCustomObjectValueIfPrimitive(value, customObject, key);
143
+ }
144
+ }
145
+ });
146
+ }
147
+ handlecustomObjectValueIfObject(value, key, customObject) {
148
+ return __awaiter(this, void 0, void 0, function* () {
149
+ const stringKey = this.getStringSpecifiedCustomObjectSecretKeyValueIfExists(value, customObject, key);
150
+ if (stringKey) {
151
+ yield this.handleCustomObjectObjectValueIfStringKeySpecified(value, key, stringKey);
152
+ }
153
+ else {
154
+ yield this.handleCustomObjectOjectValueIfMatchTypeSpecified(value, key, customObject[key]);
155
+ }
156
+ });
157
+ }
158
+ handleCustomObjectValueIfArray(value, key, customObject) {
159
+ return __awaiter(this, void 0, void 0, function* () {
160
+ const stringKey = this.getStringSpecifiedCustomObjectSecretKeyValueIfExists(value, customObject, key);
161
+ if (stringKey) {
162
+ yield this.handleCustomObjectArrayValueIfStringKeySpecified(value, key, stringKey);
163
+ }
164
+ else {
165
+ yield this.handleCustomObjectArrayValueIfMatchTypeSpecified(value, key, customObject[key]);
166
+ }
167
+ });
168
+ }
169
+ handleCustomObjectArrayValueIfStringKeySpecified(value, key, stringKey) {
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ if (this.secretManager.isFullSecretKey(stringKey)) {
172
+ value[key] = yield this.primitiveRedactor.redactValue(this.getStringValue(value[key]));
173
+ }
174
+ const isDeepSecretKey = this.secretManager.isDeepSecretKey(stringKey);
175
+ if (isDeepSecretKey || this.secretManager.isSecretKey(stringKey)) {
176
+ value[key] = yield this.redactAllArrayValues(value[key], isDeepSecretKey);
177
+ }
178
+ });
179
+ }
180
+ getStringValue(val) {
181
+ if (this.isObject(val) || Array.isArray(val)) {
182
+ return JSON.stringify(val);
183
+ }
184
+ else if (val === null || val === undefined) {
185
+ return val;
186
+ }
187
+ else {
188
+ return val.toString();
189
+ }
190
+ }
191
+ handleCustomObjectArrayValueIfMatchTypeSpecified(value, key, matchType) {
192
+ return __awaiter(this, void 0, void 0, function* () {
193
+ switch (matchType) {
194
+ case types_1.CustomObjectMatchType.Full:
195
+ value[key] = yield this.primitiveRedactor.redactValue(this.getStringValue(value[key]));
196
+ return Promise.resolve();
197
+ case types_1.CustomObjectMatchType.Deep:
198
+ value[key] = yield this.redactAllArrayValues(value[key], true);
199
+ return Promise.resolve();
200
+ case types_1.CustomObjectMatchType.Shallow:
201
+ value[key] = yield this.redactAllArrayValues(value[key], false);
202
+ return Promise.resolve();
203
+ case types_1.CustomObjectMatchType.Pass:
204
+ value[key] = yield this.redactArrayInObject(value[key], key, false);
205
+ default:
206
+ return Promise.resolve();
207
+ }
208
+ });
209
+ }
210
+ handleCustomObjectObjectValueIfStringKeySpecified(value, key, stringKey) {
211
+ return __awaiter(this, void 0, void 0, function* () {
212
+ const customObject = this.checker.getMatchingCustomObject(value[key]);
213
+ if (customObject) {
214
+ yield this.redactCustomObject(value[key], customObject);
215
+ }
216
+ else if (this.secretManager.isFullSecretKey(stringKey)) {
217
+ value[key] = yield this.primitiveRedactor.redactValue(this.getStringValue(value[key]));
218
+ }
219
+ else if (this.secretManager.isDeepSecretKey(stringKey)) {
220
+ yield this.redactSecretObjectFields(value[key], true);
221
+ }
222
+ else if (this.secretManager.isSecretKey(stringKey)) {
223
+ yield this.redactSecretObjectFields(value[key], false);
224
+ }
225
+ });
226
+ }
227
+ handleCustomObjectOjectValueIfMatchTypeSpecified(value, key, matchType) {
228
+ return __awaiter(this, void 0, void 0, function* () {
229
+ switch (matchType) {
230
+ case types_1.CustomObjectMatchType.Full:
231
+ value[key] = yield this.primitiveRedactor.redactValue(this.getStringValue(value[key]));
232
+ return Promise.resolve();
233
+ case types_1.CustomObjectMatchType.Deep:
234
+ return this.redactSecretObjectFields(value[key], true);
235
+ case types_1.CustomObjectMatchType.Shallow:
236
+ case types_1.CustomObjectMatchType.Pass:
237
+ return this.redactSecretObjectFields(value[key], false);
238
+ case types_1.CustomObjectMatchType.Ignore:
239
+ return Promise.resolve();
240
+ }
241
+ });
242
+ }
243
+ handleCustomObjectValueIfPrimitive(value, customObject, key) {
244
+ return __awaiter(this, void 0, void 0, function* () {
245
+ if (typeof customObject[key] === 'number') {
246
+ value[key] = yield this.handleCustomObjectPrimitiveValueIfMatchTypeSpecified(value[key], customObject[key]);
247
+ }
248
+ else {
249
+ value[key] = yield this.handleCustomObjectPrimitiveValueIfStringKeySpecified(value, customObject, key);
250
+ }
251
+ });
252
+ }
253
+ handleCustomObjectPrimitiveValueIfMatchTypeSpecified(value, matchValue) {
254
+ return __awaiter(this, void 0, void 0, function* () {
255
+ switch (matchValue) {
256
+ case types_1.CustomObjectMatchType.Full:
257
+ return this.primitiveRedactor.redactValue(this.getStringValue(value));
258
+ case types_1.CustomObjectMatchType.Deep:
259
+ case types_1.CustomObjectMatchType.Shallow:
260
+ return this.primitiveRedactor.redactValue(value);
261
+ case types_1.CustomObjectMatchType.Pass:
262
+ default:
263
+ return Promise.resolve(value);
264
+ }
265
+ });
266
+ }
267
+ handleCustomObjectPrimitiveValueIfStringKeySpecified(value, customObject, key) {
268
+ return __awaiter(this, void 0, void 0, function* () {
269
+ const secretKey = this.getStringSpecifiedCustomObjectSecretKeyValueIfExists(value, customObject, key);
270
+ if (!secretKey) {
271
+ return value[key];
272
+ }
273
+ return this.redactPrimitiveValueIfSecret(secretKey, value[key], false);
274
+ });
275
+ }
276
+ getStringSpecifiedCustomObjectSecretKeyValueIfExists(value, customObject, key) {
277
+ const hasSecretKey = typeof customObject[key] === 'string' && !!value[customObject[key]];
278
+ return hasSecretKey ? value[customObject[key]] : null;
279
+ }
280
+ isObject(value) {
281
+ return !!value && typeof value === 'object' && !(value instanceof Date) && !Array.isArray(value);
282
+ }
283
+ redactPrimitiveValueIfSecret(key, value, forceDeepRedaction) {
284
+ return __awaiter(this, void 0, void 0, function* () {
285
+ if (this.secretManager.isFullSecretKey(key)) {
286
+ return this.primitiveRedactor.redactValue(this.getStringValue(value));
287
+ }
288
+ else if (forceDeepRedaction || this.secretManager.isSecretKey(key) || this.secretManager.isDeepSecretKey(key)) {
289
+ return this.primitiveRedactor.redactValue(value);
290
+ }
291
+ else {
292
+ return value;
293
+ }
294
+ });
295
+ }
296
+ }
297
+ exports.ObjectRedactor = ObjectRedactor;
298
+ //# sourceMappingURL=objectRedactor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectRedactor.js","sourceRoot":"","sources":["../src/objectRedactor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA8D;AAK9D;;;;;GAKG;AACH,MAAa,cAAc;IACzB,YACmB,iBAAoC,EACpC,aAA4B,EAC5B,OAA4B;QAF5B,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,kBAAa,GAAb,aAAa,CAAe;QAC5B,YAAO,GAAP,OAAO,CAAqB;IAC5C,CAAC;IAEJ;;;;;OAKG;IACU,aAAa,CAAC,KAAU;;YACnC,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;YACjE,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;YACrD,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC;YAC7C,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC;KAAA;IAEa,wBAAwB;6DAAC,MAAW,EAAE,qBAA8B,KAAK;YACrF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACtC,MAAM,KAAK,GAAQ,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC,K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