@wgtechlabs/log-engine 2.0.0 → 2.1.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 (182) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +869 -608
  3. package/dist/cjs/__tests__/async-test-utils.cjs +276 -0
  4. package/dist/cjs/__tests__/async-test-utils.d.ts +51 -0
  5. package/dist/cjs/__tests__/async-test-utils.d.ts.map +1 -0
  6. package/dist/cjs/__tests__/async-test-utils.js.map +1 -0
  7. package/dist/cjs/__tests__/redaction/test-utils.cjs +72 -0
  8. package/dist/cjs/__tests__/redaction/test-utils.d.ts +33 -0
  9. package/dist/cjs/__tests__/redaction/test-utils.d.ts.map +1 -0
  10. package/dist/cjs/__tests__/redaction/test-utils.js.map +1 -0
  11. package/dist/cjs/__tests__/test-utils.cjs +49 -0
  12. package/dist/cjs/__tests__/test-utils.d.ts +41 -0
  13. package/dist/cjs/__tests__/test-utils.d.ts.map +1 -0
  14. package/dist/cjs/__tests__/test-utils.js.map +1 -0
  15. package/dist/{formatter/colors.js → cjs/formatter/colors.cjs} +1 -0
  16. package/dist/cjs/formatter/colors.d.ts.map +1 -0
  17. package/dist/cjs/formatter/colors.js.map +1 -0
  18. package/dist/{formatter/data-formatter.js → cjs/formatter/data-formatter.cjs} +2 -1
  19. package/dist/{formatter → cjs/formatter}/data-formatter.d.ts +2 -1
  20. package/dist/cjs/formatter/data-formatter.d.ts.map +1 -0
  21. package/dist/cjs/formatter/data-formatter.js.map +1 -0
  22. package/dist/{formatter/index.js → cjs/formatter/index.cjs} +6 -5
  23. package/dist/cjs/formatter/index.d.ts.map +1 -0
  24. package/dist/cjs/formatter/index.js.map +1 -0
  25. package/dist/{formatter/message-formatter.js → cjs/formatter/message-formatter.cjs} +28 -27
  26. package/dist/cjs/formatter/message-formatter.d.ts +41 -0
  27. package/dist/cjs/formatter/message-formatter.d.ts.map +1 -0
  28. package/dist/cjs/formatter/message-formatter.js.map +1 -0
  29. package/dist/{formatter/timestamp.js → cjs/formatter/timestamp.cjs} +1 -0
  30. package/dist/cjs/formatter/timestamp.d.ts.map +1 -0
  31. package/dist/cjs/formatter/timestamp.js.map +1 -0
  32. package/dist/cjs/index.cjs +202 -0
  33. package/dist/cjs/index.d.ts +180 -0
  34. package/dist/cjs/index.d.ts.map +1 -0
  35. package/dist/cjs/index.js.map +1 -0
  36. package/dist/cjs/logger/advanced-outputs.cjs +587 -0
  37. package/dist/cjs/logger/advanced-outputs.d.ts +159 -0
  38. package/dist/cjs/logger/advanced-outputs.d.ts.map +1 -0
  39. package/dist/cjs/logger/advanced-outputs.js.map +1 -0
  40. package/dist/{logger/config.js → cjs/logger/config.cjs} +36 -32
  41. package/dist/cjs/logger/config.d.ts +42 -0
  42. package/dist/cjs/logger/config.d.ts.map +1 -0
  43. package/dist/cjs/logger/config.js.map +1 -0
  44. package/dist/cjs/logger/core.cjs +371 -0
  45. package/dist/cjs/logger/core.d.ts +152 -0
  46. package/dist/cjs/logger/core.d.ts.map +1 -0
  47. package/dist/cjs/logger/core.js.map +1 -0
  48. package/dist/{logger/environment.js → cjs/logger/environment.cjs} +17 -16
  49. package/dist/cjs/logger/environment.d.ts +36 -0
  50. package/dist/cjs/logger/environment.d.ts.map +1 -0
  51. package/dist/cjs/logger/environment.js.map +1 -0
  52. package/dist/cjs/logger/filtering.cjs +81 -0
  53. package/dist/cjs/logger/filtering.d.ts +36 -0
  54. package/dist/cjs/logger/filtering.d.ts.map +1 -0
  55. package/dist/cjs/logger/filtering.js.map +1 -0
  56. package/dist/{logger/index.js → cjs/logger/index.cjs} +6 -5
  57. package/dist/cjs/logger/index.d.ts.map +1 -0
  58. package/dist/cjs/logger/index.js.map +1 -0
  59. package/dist/cjs/package.json +3 -0
  60. package/dist/{redaction/config.js → cjs/redaction/config.cjs} +9 -8
  61. package/dist/{redaction → cjs/redaction}/config.d.ts +8 -8
  62. package/dist/cjs/redaction/config.d.ts.map +1 -0
  63. package/dist/cjs/redaction/config.js.map +1 -0
  64. package/dist/{redaction/index.js → cjs/redaction/index.cjs} +3 -2
  65. package/dist/cjs/redaction/index.d.ts.map +1 -0
  66. package/dist/cjs/redaction/index.js.map +1 -0
  67. package/dist/cjs/redaction/redactor.cjs +263 -0
  68. package/dist/cjs/redaction/redactor.d.ts +99 -0
  69. package/dist/cjs/redaction/redactor.d.ts.map +1 -0
  70. package/dist/cjs/redaction/redactor.js.map +1 -0
  71. package/dist/{types/index.js → cjs/types/index.cjs} +1 -0
  72. package/dist/{types → cjs/types}/index.d.ts +98 -16
  73. package/dist/cjs/types/index.d.ts.map +1 -0
  74. package/dist/cjs/types/index.js.map +1 -0
  75. package/dist/esm/__tests__/async-test-utils.d.ts +51 -0
  76. package/dist/esm/__tests__/async-test-utils.d.ts.map +1 -0
  77. package/dist/esm/__tests__/async-test-utils.js +231 -0
  78. package/dist/esm/__tests__/async-test-utils.js.map +1 -0
  79. package/dist/esm/__tests__/redaction/test-utils.d.ts +33 -0
  80. package/dist/esm/__tests__/redaction/test-utils.d.ts.map +1 -0
  81. package/dist/esm/__tests__/redaction/test-utils.js +65 -0
  82. package/dist/esm/__tests__/redaction/test-utils.js.map +1 -0
  83. package/dist/esm/__tests__/test-utils.d.ts +41 -0
  84. package/dist/esm/__tests__/test-utils.d.ts.map +1 -0
  85. package/dist/esm/__tests__/test-utils.js +42 -0
  86. package/dist/esm/__tests__/test-utils.js.map +1 -0
  87. package/dist/esm/formatter/colors.d.ts +32 -0
  88. package/dist/esm/formatter/colors.d.ts.map +1 -0
  89. package/dist/esm/formatter/colors.js +32 -0
  90. package/dist/esm/formatter/colors.js.map +1 -0
  91. package/dist/esm/formatter/data-formatter.d.ts +26 -0
  92. package/dist/esm/formatter/data-formatter.d.ts.map +1 -0
  93. package/dist/esm/formatter/data-formatter.js +50 -0
  94. package/dist/esm/formatter/data-formatter.js.map +1 -0
  95. package/dist/esm/formatter/index.d.ts +10 -0
  96. package/dist/esm/formatter/index.d.ts.map +1 -0
  97. package/dist/esm/formatter/index.js +11 -0
  98. package/dist/esm/formatter/index.js.map +1 -0
  99. package/dist/esm/formatter/message-formatter.d.ts +41 -0
  100. package/dist/esm/formatter/message-formatter.d.ts.map +1 -0
  101. package/dist/esm/formatter/message-formatter.js +84 -0
  102. package/dist/esm/formatter/message-formatter.js.map +1 -0
  103. package/dist/esm/formatter/timestamp.d.ts +27 -0
  104. package/dist/esm/formatter/timestamp.d.ts.map +1 -0
  105. package/dist/esm/formatter/timestamp.js +36 -0
  106. package/dist/esm/formatter/timestamp.js.map +1 -0
  107. package/dist/esm/index.d.ts +180 -0
  108. package/dist/esm/index.d.ts.map +1 -0
  109. package/dist/esm/index.js +194 -0
  110. package/dist/esm/index.js.map +1 -0
  111. package/dist/esm/logger/advanced-outputs.d.ts +159 -0
  112. package/dist/esm/logger/advanced-outputs.d.ts.map +1 -0
  113. package/dist/esm/logger/advanced-outputs.js +542 -0
  114. package/dist/esm/logger/advanced-outputs.js.map +1 -0
  115. package/dist/esm/logger/config.d.ts +42 -0
  116. package/dist/esm/logger/config.d.ts.map +1 -0
  117. package/dist/esm/logger/config.js +101 -0
  118. package/dist/esm/logger/config.js.map +1 -0
  119. package/dist/esm/logger/core.d.ts +152 -0
  120. package/dist/esm/logger/core.d.ts.map +1 -0
  121. package/dist/esm/logger/core.js +367 -0
  122. package/dist/esm/logger/core.js.map +1 -0
  123. package/dist/esm/logger/environment.d.ts +36 -0
  124. package/dist/esm/logger/environment.d.ts.map +1 -0
  125. package/dist/esm/logger/environment.js +58 -0
  126. package/dist/esm/logger/environment.js.map +1 -0
  127. package/dist/esm/logger/filtering.d.ts +36 -0
  128. package/dist/esm/logger/filtering.d.ts.map +1 -0
  129. package/dist/esm/logger/filtering.js +77 -0
  130. package/dist/esm/logger/filtering.js.map +1 -0
  131. package/dist/esm/logger/index.d.ts +10 -0
  132. package/dist/esm/logger/index.d.ts.map +1 -0
  133. package/dist/esm/logger/index.js +11 -0
  134. package/dist/esm/logger/index.js.map +1 -0
  135. package/dist/esm/redaction/config.d.ts +29 -0
  136. package/dist/esm/redaction/config.d.ts.map +1 -0
  137. package/dist/esm/redaction/config.js +92 -0
  138. package/dist/esm/redaction/config.js.map +1 -0
  139. package/dist/esm/redaction/index.d.ts +8 -0
  140. package/dist/esm/redaction/index.d.ts.map +1 -0
  141. package/dist/esm/redaction/index.js +7 -0
  142. package/dist/esm/redaction/index.js.map +1 -0
  143. package/dist/esm/redaction/redactor.d.ts +99 -0
  144. package/dist/esm/redaction/redactor.d.ts.map +1 -0
  145. package/dist/esm/redaction/redactor.js +259 -0
  146. package/dist/esm/redaction/redactor.js.map +1 -0
  147. package/dist/esm/types/index.d.ts +310 -0
  148. package/dist/esm/types/index.d.ts.map +1 -0
  149. package/dist/esm/types/index.js +41 -0
  150. package/dist/esm/types/index.js.map +1 -0
  151. package/package.json +94 -68
  152. package/dist/formatter/colors.d.ts.map +0 -1
  153. package/dist/formatter/data-formatter.d.ts.map +0 -1
  154. package/dist/formatter/index.d.ts.map +0 -1
  155. package/dist/formatter/message-formatter.d.ts +0 -41
  156. package/dist/formatter/message-formatter.d.ts.map +0 -1
  157. package/dist/formatter/timestamp.d.ts.map +0 -1
  158. package/dist/index.d.ts +0 -186
  159. package/dist/index.d.ts.map +0 -1
  160. package/dist/index.js +0 -201
  161. package/dist/logger/config.d.ts +0 -42
  162. package/dist/logger/config.d.ts.map +0 -1
  163. package/dist/logger/core.d.ts +0 -108
  164. package/dist/logger/core.d.ts.map +0 -1
  165. package/dist/logger/core.js +0 -185
  166. package/dist/logger/environment.d.ts +0 -36
  167. package/dist/logger/environment.d.ts.map +0 -1
  168. package/dist/logger/filtering.d.ts +0 -36
  169. package/dist/logger/filtering.d.ts.map +0 -1
  170. package/dist/logger/filtering.js +0 -65
  171. package/dist/logger/index.d.ts.map +0 -1
  172. package/dist/redaction/config.d.ts.map +0 -1
  173. package/dist/redaction/index.d.ts.map +0 -1
  174. package/dist/redaction/redactor.d.ts +0 -99
  175. package/dist/redaction/redactor.d.ts.map +0 -1
  176. package/dist/redaction/redactor.js +0 -257
  177. package/dist/types/index.d.ts.map +0 -1
  178. /package/dist/{formatter → cjs/formatter}/colors.d.ts +0 -0
  179. /package/dist/{formatter → cjs/formatter}/index.d.ts +0 -0
  180. /package/dist/{formatter → cjs/formatter}/timestamp.d.ts +0 -0
  181. /package/dist/{logger → cjs/logger}/index.d.ts +0 -0
  182. /package/dist/{redaction → cjs/redaction}/index.d.ts +0 -0
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ /**
3
+ * Log level and mode filtering logic
4
+ * Handles the decision logic for whether messages should be logged
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LogFilter = void 0;
8
+ const types_1 = require("../types/index.cjs");
9
+ /**
10
+ * Filtering logic for log messages based on levels and modes
11
+ * Determines whether a message should be output based on current configuration
12
+ */
13
+ class LogFilter {
14
+ /**
15
+ * Determines if a message should be logged based on current log mode
16
+ * Messages are shown only if their level is appropriate for the configured mode
17
+ * LOG level is special - it always outputs regardless of configured mode (except when OFF is set)
18
+ * OFF mode disables all logging including LOG level messages
19
+ * @param level - The log level of the message to check
20
+ * @param currentMode - The current logging mode
21
+ * @returns true if message should be logged, false otherwise
22
+ */
23
+ static shouldLog(level, currentMode) {
24
+ // Get the severity rank for the message level using safe lookup
25
+ const messageSeverity = LogFilter.getSeverityRank(level);
26
+ // Get the minimum severity threshold for the current mode using safe lookup
27
+ const modeThreshold = LogFilter.getModeThreshold(currentMode);
28
+ // Allow the message if its severity meets or exceeds the mode threshold
29
+ return messageSeverity >= modeThreshold;
30
+ }
31
+ /**
32
+ * Get the severity rank for a log level
33
+ * @param level - The log level to get rank for
34
+ * @returns Numeric severity rank
35
+ */
36
+ static getSeverityRank(level) {
37
+ switch (level) {
38
+ case types_1.LogLevel.DEBUG: return 0;
39
+ case types_1.LogLevel.INFO: return 1;
40
+ case types_1.LogLevel.WARN: return 2;
41
+ case types_1.LogLevel.ERROR: return 3;
42
+ case types_1.LogLevel.LOG: return 99;
43
+ default: return 0;
44
+ }
45
+ }
46
+ /**
47
+ * Get the threshold for a log mode
48
+ * @param mode - The log mode to get threshold for
49
+ * @returns Numeric threshold value
50
+ */
51
+ static getModeThreshold(mode) {
52
+ switch (mode) {
53
+ case types_1.LogMode.DEBUG: return 0;
54
+ case types_1.LogMode.INFO: return 1;
55
+ case types_1.LogMode.WARN: return 2;
56
+ case types_1.LogMode.ERROR: return 3;
57
+ case types_1.LogMode.SILENT: return 99;
58
+ case types_1.LogMode.OFF: return 100;
59
+ default: return 0;
60
+ }
61
+ }
62
+ }
63
+ exports.LogFilter = LogFilter;
64
+ // Maps LogLevel values to severity ranks for consistent comparison
65
+ LogFilter.SEVERITY_RANKS = {
66
+ [types_1.LogLevel.DEBUG]: 0,
67
+ [types_1.LogLevel.INFO]: 1,
68
+ [types_1.LogLevel.WARN]: 2,
69
+ [types_1.LogLevel.ERROR]: 3,
70
+ [types_1.LogLevel.LOG]: 99 // Special case - always outputs (except when OFF)
71
+ };
72
+ // Maps LogMode values to minimum severity rank required for output
73
+ LogFilter.MODE_THRESHOLDS = {
74
+ [types_1.LogMode.DEBUG]: 0, // Shows DEBUG and above
75
+ [types_1.LogMode.INFO]: 1, // Shows INFO and above
76
+ [types_1.LogMode.WARN]: 2, // Shows WARN and above
77
+ [types_1.LogMode.ERROR]: 3, // Shows ERROR and above
78
+ [types_1.LogMode.SILENT]: 99, // Only shows LOG messages
79
+ [types_1.LogMode.OFF]: 100 // Shows nothing
80
+ };
81
+ //# sourceMappingURL=filtering.js.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Log level and mode filtering logic
3
+ * Handles the decision logic for whether messages should be logged
4
+ */
5
+ import { LogLevel, LogMode } from '../types';
6
+ /**
7
+ * Filtering logic for log messages based on levels and modes
8
+ * Determines whether a message should be output based on current configuration
9
+ */
10
+ export declare class LogFilter {
11
+ private static readonly SEVERITY_RANKS;
12
+ private static readonly MODE_THRESHOLDS;
13
+ /**
14
+ * Determines if a message should be logged based on current log mode
15
+ * Messages are shown only if their level is appropriate for the configured mode
16
+ * LOG level is special - it always outputs regardless of configured mode (except when OFF is set)
17
+ * OFF mode disables all logging including LOG level messages
18
+ * @param level - The log level of the message to check
19
+ * @param currentMode - The current logging mode
20
+ * @returns true if message should be logged, false otherwise
21
+ */
22
+ static shouldLog(level: LogLevel, currentMode: LogMode): boolean;
23
+ /**
24
+ * Get the severity rank for a log level
25
+ * @param level - The log level to get rank for
26
+ * @returns Numeric severity rank
27
+ */
28
+ static getSeverityRank(level: LogLevel): number;
29
+ /**
30
+ * Get the threshold for a log mode
31
+ * @param mode - The log mode to get threshold for
32
+ * @returns Numeric threshold value
33
+ */
34
+ static getModeThreshold(mode: LogMode): number;
35
+ }
36
+ //# sourceMappingURL=filtering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filtering.d.ts","sourceRoot":"","sources":["../../../src/logger/filtering.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAE7C;;;GAGG;AACH,qBAAa,SAAS;IAEpB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAMpC;IAGF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAOrC;IAEF;;;;;;;;SAQK;IACL,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO;IAWhE;;;;SAIK;IACL,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM;IAW/C;;;;SAIK;IACL,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM;CAW/C"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filtering.js","sourceRoot":"","sources":["../../../src/logger/filtering.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,oCAA6C;AAE7C;;;GAGG;AACH,MAAa,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O,CAAC,CAAC,OAAO,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;;AAvEH,8BAwEC;AAvEC,mEAAmE;AAC3C,wBAAc,GAA6B;IACjE,CAAC,gBAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IACnB,CAAC,gBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAClB,CAAC,gBAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IAClB,CAAC,gBAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;IACnB,CAAC,gBAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,CAAE,kDAAkD;CACvE,CAAC;AAEF,mEAAmE;AAC3C,yBAAe,GAA4B;IACjE,CAAC,eAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAI,wBAAwB;IAC9C,CAAC,eAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAK,uBAAuB;IAC7C,CAAC,eAAO,CAAC,IAAI,CAAC,EAAE,CAAC,EAAK,uBAAuB;IAC7C,CAAC,eAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAI,wBAAwB;IAC9C,CAAC,eAAO,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,0BAA0B;IAChD,CAAC,eAAO,CAAC,GAAG,CAAC,EAAE,GAAG,CAAI,gBAAgB;CACvC,CAAC"}
@@ -5,14 +5,15 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.CoreLogger = exports.EnvironmentDetector = exports.LogFilter = exports.LoggerConfigManager = exports.Logger = void 0;
8
- var core_1 = require("./core");
8
+ var core_1 = require("./core.cjs");
9
9
  Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return core_1.Logger; } });
10
- var config_1 = require("./config");
10
+ var config_1 = require("./config.cjs");
11
11
  Object.defineProperty(exports, "LoggerConfigManager", { enumerable: true, get: function () { return config_1.LoggerConfigManager; } });
12
- var filtering_1 = require("./filtering");
12
+ var filtering_1 = require("./filtering.cjs");
13
13
  Object.defineProperty(exports, "LogFilter", { enumerable: true, get: function () { return filtering_1.LogFilter; } });
14
- var environment_1 = require("./environment");
14
+ var environment_1 = require("./environment.cjs");
15
15
  Object.defineProperty(exports, "EnvironmentDetector", { enumerable: true, get: function () { return environment_1.EnvironmentDetector; } });
16
16
  // Backward compatibility - maintain the original Logger class interface
17
- var core_2 = require("./core");
17
+ var core_2 = require("./core.cjs");
18
18
  Object.defineProperty(exports, "CoreLogger", { enumerable: true, get: function () { return core_2.Logger; } });
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/logger/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/logger/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+BAAgC;AAAvB,8FAAA,MAAM,OAAA;AACf,mCAA+C;AAAtC,6GAAA,mBAAmB,OAAA;AAC5B,yCAAwC;AAA/B,sGAAA,SAAS,OAAA;AAClB,6CAAoD;AAA3C,kHAAA,mBAAmB,OAAA;AAE5B,wEAAwE;AACxE,+BAA8C;AAArC,kGAAA,MAAM,OAAc"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -52,10 +52,10 @@ exports.defaultRedactionConfig = {
52
52
  */
53
53
  class RedactionController {
54
54
  /**
55
- * Check if redaction should be disabled based on environment variables
56
- * Development mode and explicit flags can disable redaction for debugging
57
- * @returns true if redaction should be disabled, false otherwise
58
- */
55
+ * Check if redaction should be disabled based on environment variables
56
+ * Development mode and explicit flags can disable redaction for debugging
57
+ * @returns true if redaction should be disabled, false otherwise
58
+ */
59
59
  static isRedactionDisabled() {
60
60
  return (process.env.NODE_ENV === 'development' ||
61
61
  process.env.LOG_REDACTION_DISABLED === 'true' ||
@@ -64,10 +64,10 @@ class RedactionController {
64
64
  process.env.LOG_REDACTION_ENABLED === 'false');
65
65
  }
66
66
  /**
67
- * Get environment-specific configuration overrides
68
- * Allows customization through environment variables
69
- * @returns Partial redaction config with environment-based overrides
70
- */
67
+ * Get environment-specific configuration overrides
68
+ * Allows customization through environment variables
69
+ * @returns Partial redaction config with environment-based overrides
70
+ */
71
71
  static getEnvironmentConfig() {
72
72
  const envConfig = {
73
73
  enabled: !this.isRedactionDisabled()
@@ -93,3 +93,4 @@ class RedactionController {
93
93
  }
94
94
  }
95
95
  exports.RedactionController = RedactionController;
96
+ //# sourceMappingURL=config.js.map
@@ -14,16 +14,16 @@ export declare const defaultRedactionConfig: RedactionConfig;
14
14
  */
15
15
  export declare class RedactionController {
16
16
  /**
17
- * Check if redaction should be disabled based on environment variables
18
- * Development mode and explicit flags can disable redaction for debugging
19
- * @returns true if redaction should be disabled, false otherwise
20
- */
17
+ * Check if redaction should be disabled based on environment variables
18
+ * Development mode and explicit flags can disable redaction for debugging
19
+ * @returns true if redaction should be disabled, false otherwise
20
+ */
21
21
  static isRedactionDisabled(): boolean;
22
22
  /**
23
- * Get environment-specific configuration overrides
24
- * Allows customization through environment variables
25
- * @returns Partial redaction config with environment-based overrides
26
- */
23
+ * Get environment-specific configuration overrides
24
+ * Allows customization through environment variables
25
+ * @returns Partial redaction config with environment-based overrides
26
+ */
27
27
  static getEnvironmentConfig(): Partial<RedactionConfig>;
28
28
  }
29
29
  //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/redaction/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;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AAC,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAC3D,CAAC;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;YACpC,SAAS,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;QAC7D,CAAC;QAED,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC;YACrC,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACpF,SAAS,CAAC,eAAe,GAAG,CAAC,GAAG,8BAAsB,CAAC,eAAe,EAAE,GAAG,YAAY,CAAC,CAAC;QAC3F,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAjDD,kDAiDC"}
@@ -5,8 +5,9 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.RedactionController = exports.defaultRedactionConfig = exports.DataRedactor = void 0;
8
- var redactor_1 = require("./redactor");
8
+ var redactor_1 = require("./redactor.cjs");
9
9
  Object.defineProperty(exports, "DataRedactor", { enumerable: true, get: function () { return redactor_1.DataRedactor; } });
10
- var config_1 = require("./config");
10
+ var config_1 = require("./config.cjs");
11
11
  Object.defineProperty(exports, "defaultRedactionConfig", { enumerable: true, get: function () { return config_1.defaultRedactionConfig; } });
12
12
  Object.defineProperty(exports, "RedactionController", { enumerable: true, get: function () { return config_1.RedactionController; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/redaction/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACvE,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/redaction/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,uCAA0C;AAAjC,wGAAA,YAAY,OAAA;AACrB,mCAAuE;AAA9D,gHAAA,sBAAsB,OAAA;AAAE,6GAAA,mBAAmB,OAAA"}
@@ -0,0 +1,263 @@
1
+ "use strict";
2
+ /**
3
+ * Core data redaction engine
4
+ * Handles automatic detection and redaction of sensitive information in log data
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DataRedactor = void 0;
8
+ const config_1 = require("./config.cjs");
9
+ /**
10
+ * DataRedactor class - Core redaction logic for processing log data
11
+ * Automatically detects and redacts sensitive information while preserving structure
12
+ */
13
+ class DataRedactor {
14
+ /**
15
+ * Update the redaction configuration with new settings
16
+ * Merges provided config with existing settings and reloads environment variables
17
+ * @param newConfig - Partial configuration to merge with current settings
18
+ */
19
+ static updateConfig(newConfig) {
20
+ // Reload environment configuration to pick up any changes
21
+ const envConfig = config_1.RedactionController.getEnvironmentConfig();
22
+ DataRedactor.config = {
23
+ ...config_1.defaultRedactionConfig,
24
+ ...envConfig,
25
+ ...newConfig
26
+ };
27
+ }
28
+ /**
29
+ * Get the current redaction configuration
30
+ * @returns Deep copy of current redaction configuration
31
+ */
32
+ static getConfig() {
33
+ return {
34
+ ...DataRedactor.config,
35
+ sensitiveFields: [...DataRedactor.config.sensitiveFields],
36
+ contentFields: [...DataRedactor.config.contentFields],
37
+ customPatterns: DataRedactor.config.customPatterns ? [...DataRedactor.config.customPatterns] : undefined
38
+ };
39
+ }
40
+ /**
41
+ * Refresh configuration from environment variables
42
+ * Useful for picking up runtime environment changes
43
+ */
44
+ static refreshConfig() {
45
+ const envConfig = config_1.RedactionController.getEnvironmentConfig();
46
+ DataRedactor.config = {
47
+ ...config_1.defaultRedactionConfig,
48
+ ...envConfig
49
+ };
50
+ }
51
+ /**
52
+ * Add custom regex patterns for advanced field detection
53
+ * @param patterns - Array of regex patterns to add
54
+ */
55
+ static addCustomPatterns(patterns) {
56
+ const currentPatterns = DataRedactor.config.customPatterns || [];
57
+ DataRedactor.config = {
58
+ ...DataRedactor.config,
59
+ customPatterns: [...currentPatterns, ...patterns]
60
+ };
61
+ }
62
+ /**
63
+ * Clear all custom regex patterns
64
+ */
65
+ static clearCustomPatterns() {
66
+ DataRedactor.config = {
67
+ ...DataRedactor.config,
68
+ customPatterns: []
69
+ };
70
+ }
71
+ /**
72
+ * Add custom sensitive field names to the existing list
73
+ * @param fields - Array of field names to add
74
+ */
75
+ static addSensitiveFields(fields) {
76
+ DataRedactor.config = {
77
+ ...DataRedactor.config,
78
+ sensitiveFields: [...DataRedactor.config.sensitiveFields, ...fields]
79
+ };
80
+ }
81
+ /**
82
+ * Test if a field name would be redacted with current configuration
83
+ * @param fieldName - Field name to test
84
+ * @returns true if field would be redacted, false otherwise
85
+ */
86
+ static testFieldRedaction(fieldName) {
87
+ const testObj = { [fieldName]: 'test-value' };
88
+ const result = DataRedactor.redactData(testObj); // Use safe property access to prevent object injection
89
+ if (Object.prototype.hasOwnProperty.call(result, fieldName)) {
90
+ // Safe access to avoid object injection
91
+ const value = result[fieldName];
92
+ return value !== 'test-value';
93
+ }
94
+ return false;
95
+ }
96
+ /**
97
+ * Main entry point for data redaction
98
+ * Processes any type of data and returns a redacted version
99
+ * @param data - Data to be processed for redaction
100
+ * @returns Redacted version of the data
101
+ */
102
+ static redactData(data) {
103
+ // Skip processing if redaction is disabled or data is null/undefined
104
+ if (!DataRedactor.config.enabled || data === null || data === undefined) {
105
+ return data;
106
+ }
107
+ return DataRedactor.processValue(data, new WeakSet(), 0);
108
+ }
109
+ /**
110
+ * Process a value of any type (primitive, object, array)
111
+ * Recursively handles nested structures when deepRedaction is enabled
112
+ * Includes circular reference protection and recursion depth limiting
113
+ * @param value - Value to process
114
+ * @param visited - Set to track visited objects (prevents circular references)
115
+ * @param depth - Current recursion depth (prevents stack overflow)
116
+ * @returns Processed value with redaction applied
117
+ */
118
+ static processValue(value, visited = new WeakSet(), depth = 0) {
119
+ // Check recursion depth limit to prevent stack overflow
120
+ if (depth >= DataRedactor.MAX_RECURSION_DEPTH) {
121
+ return '[Max Depth Exceeded]';
122
+ }
123
+ // Handle null and undefined
124
+ if (value === null || value === undefined) {
125
+ return value;
126
+ }
127
+ // Handle arrays - process each element
128
+ if (Array.isArray(value)) {
129
+ // Check for circular reference
130
+ if (visited.has(value)) {
131
+ return '[Circular Array]';
132
+ }
133
+ visited.add(value);
134
+ const result = value.map(item => DataRedactor.processValue(item, visited, depth + 1));
135
+ // Keep value in visited set to detect circular references across branches
136
+ return result;
137
+ }
138
+ // Handle objects - process each property
139
+ if (typeof value === 'object') {
140
+ // Check for circular reference
141
+ if (visited.has(value)) {
142
+ return '[Circular Object]';
143
+ }
144
+ visited.add(value);
145
+ const result = DataRedactor.redactObject(value, visited, depth + 1);
146
+ // Keep value in visited set to detect circular references across branches
147
+ return result;
148
+ }
149
+ // Handle primitives (string, number, boolean) - return as-is
150
+ return value;
151
+ }
152
+ /**
153
+ * Process an object and redact sensitive fields
154
+ * Handles field-level redaction and content truncation
155
+ * @param obj - Object to process
156
+ * @param visited - Set to track visited objects (prevents circular references)
157
+ * @param depth - Current recursion depth (prevents stack overflow)
158
+ * @returns Object with sensitive fields redacted
159
+ */
160
+ static redactObject(obj, visited = new WeakSet(), depth = 0) {
161
+ // Check recursion depth limit to prevent stack overflow
162
+ if (depth >= DataRedactor.MAX_REDACT_OBJECT_DEPTH) {
163
+ return { '[Max Depth Exceeded]': '[Max Depth Exceeded]' };
164
+ }
165
+ const redacted = {};
166
+ for (const [key, value] of Object.entries(obj)) {
167
+ // Check if this field should be completely redacted
168
+ if (DataRedactor.isSensitiveField(key)) {
169
+ Object.defineProperty(redacted, key, { value: DataRedactor.config.redactionText, enumerable: true, writable: true, configurable: true });
170
+ }
171
+ else if (DataRedactor.isContentField(key) && typeof value === 'string') {
172
+ // Check if this field should be truncated (for large content)
173
+ Object.defineProperty(redacted, key, { value: DataRedactor.truncateContent(value), enumerable: true, writable: true, configurable: true });
174
+ }
175
+ else if (DataRedactor.config.deepRedaction && (typeof value === 'object' && value !== null)) {
176
+ // Recursively process nested objects/arrays if deep redaction is enabled
177
+ Object.defineProperty(redacted, key, { value: DataRedactor.processValue(value, visited, depth + 1), enumerable: true, writable: true, configurable: true });
178
+ }
179
+ else {
180
+ // Keep the value unchanged
181
+ Object.defineProperty(redacted, key, { value: value, enumerable: true, writable: true, configurable: true });
182
+ }
183
+ }
184
+ return redacted;
185
+ }
186
+ /**
187
+ * Check if a field name indicates sensitive information
188
+ * Uses case-insensitive matching with exact and partial matches
189
+ * Includes smart filtering to avoid false positives and custom patterns
190
+ * @param fieldName - Field name to check
191
+ * @returns true if field should be redacted, false otherwise
192
+ */
193
+ static isSensitiveField(fieldName) {
194
+ const lowerField = fieldName.toLowerCase();
195
+ // Check custom regex patterns first (highest priority)
196
+ if (DataRedactor.config.customPatterns && DataRedactor.config.customPatterns.length > 0) {
197
+ for (const pattern of DataRedactor.config.customPatterns) {
198
+ if (pattern.test(fieldName)) {
199
+ return true;
200
+ }
201
+ }
202
+ }
203
+ return DataRedactor.config.sensitiveFields.some(sensitive => {
204
+ const lowerSensitive = sensitive.toLowerCase();
205
+ // Exact match (highest confidence)
206
+ if (lowerField === lowerSensitive) {
207
+ return true;
208
+ }
209
+ // Field ends with sensitive term (e.g., "userPassword" ends with "password")
210
+ if (lowerField.endsWith(lowerSensitive)) {
211
+ return true;
212
+ }
213
+ // Field starts with sensitive term (e.g., "passwordHash" starts with "password")
214
+ if (lowerField.startsWith(lowerSensitive)) {
215
+ return true;
216
+ }
217
+ // Whitelist of short sensitive terms that should always trigger substring matching
218
+ const shortSensitiveWhitelist = ['pin', 'cvv', 'cvc', 'ssn', 'pwd', 'key', 'jwt', 'dob', 'pii', 'auth', 'csrf'];
219
+ // Field contains sensitive term - either from whitelist or length >= 5 to avoid false positives
220
+ if ((shortSensitiveWhitelist.includes(lowerSensitive) || lowerSensitive.length >= 5) &&
221
+ lowerField.includes(lowerSensitive)) {
222
+ return true;
223
+ }
224
+ // Handle compound words with underscores or camelCase
225
+ if (lowerField.includes('_' + lowerSensitive) || lowerField.includes(lowerSensitive + '_')) {
226
+ return true;
227
+ }
228
+ return false;
229
+ });
230
+ }
231
+ /**
232
+ * Check if a field name indicates content that should be truncated
233
+ * Uses exact case-insensitive matching for content fields
234
+ * @param fieldName - Field name to check
235
+ * @returns true if field is a content field, false otherwise
236
+ */
237
+ static isContentField(fieldName) {
238
+ const lowerField = fieldName.toLowerCase();
239
+ return DataRedactor.config.contentFields.some(content => content.toLowerCase() === lowerField);
240
+ }
241
+ /**
242
+ * Truncate content that exceeds the maximum length
243
+ * Preserves readability while preventing log bloat
244
+ * @param content - Content string to potentially truncate
245
+ * @returns Original content or truncated version with indicator
246
+ */
247
+ static truncateContent(content) {
248
+ if (content.length <= DataRedactor.config.maxContentLength) {
249
+ return content;
250
+ }
251
+ return content.substring(0, DataRedactor.config.maxContentLength) + DataRedactor.config.truncationText;
252
+ }
253
+ }
254
+ exports.DataRedactor = DataRedactor;
255
+ DataRedactor.config = {
256
+ ...config_1.defaultRedactionConfig,
257
+ ...config_1.RedactionController.getEnvironmentConfig()
258
+ };
259
+ // Maximum recursion depth to prevent stack overflow attacks
260
+ DataRedactor.MAX_RECURSION_DEPTH = 100;
261
+ // Slightly lower limit for redactObject to ensure it can be reached
262
+ DataRedactor.MAX_REDACT_OBJECT_DEPTH = 99;
263
+ //# sourceMappingURL=redactor.js.map
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Core data redaction engine
3
+ * Handles automatic detection and redaction of sensitive information in log data
4
+ */
5
+ import { RedactionConfig, LogData } from '../types';
6
+ /**
7
+ * DataRedactor class - Core redaction logic for processing log data
8
+ * Automatically detects and redacts sensitive information while preserving structure
9
+ */
10
+ export declare class DataRedactor {
11
+ private static config;
12
+ private static readonly MAX_RECURSION_DEPTH;
13
+ private static readonly MAX_REDACT_OBJECT_DEPTH;
14
+ /**
15
+ * Update the redaction configuration with new settings
16
+ * Merges provided config with existing settings and reloads environment variables
17
+ * @param newConfig - Partial configuration to merge with current settings
18
+ */
19
+ static updateConfig(newConfig: Partial<RedactionConfig>): void;
20
+ /**
21
+ * Get the current redaction configuration
22
+ * @returns Deep copy of current redaction configuration
23
+ */
24
+ static getConfig(): RedactionConfig;
25
+ /**
26
+ * Refresh configuration from environment variables
27
+ * Useful for picking up runtime environment changes
28
+ */
29
+ static refreshConfig(): void;
30
+ /**
31
+ * Add custom regex patterns for advanced field detection
32
+ * @param patterns - Array of regex patterns to add
33
+ */
34
+ static addCustomPatterns(patterns: RegExp[]): void;
35
+ /**
36
+ * Clear all custom regex patterns
37
+ */
38
+ static clearCustomPatterns(): void;
39
+ /**
40
+ * Add custom sensitive field names to the existing list
41
+ * @param fields - Array of field names to add
42
+ */
43
+ static addSensitiveFields(fields: string[]): void;
44
+ /**
45
+ * Test if a field name would be redacted with current configuration
46
+ * @param fieldName - Field name to test
47
+ * @returns true if field would be redacted, false otherwise
48
+ */
49
+ static testFieldRedaction(fieldName: string): boolean;
50
+ /**
51
+ * Main entry point for data redaction
52
+ * Processes any type of data and returns a redacted version
53
+ * @param data - Data to be processed for redaction
54
+ * @returns Redacted version of the data
55
+ */
56
+ static redactData(data: LogData): LogData;
57
+ /**
58
+ * Process a value of any type (primitive, object, array)
59
+ * Recursively handles nested structures when deepRedaction is enabled
60
+ * Includes circular reference protection and recursion depth limiting
61
+ * @param value - Value to process
62
+ * @param visited - Set to track visited objects (prevents circular references)
63
+ * @param depth - Current recursion depth (prevents stack overflow)
64
+ * @returns Processed value with redaction applied
65
+ */
66
+ private static processValue;
67
+ /**
68
+ * Process an object and redact sensitive fields
69
+ * Handles field-level redaction and content truncation
70
+ * @param obj - Object to process
71
+ * @param visited - Set to track visited objects (prevents circular references)
72
+ * @param depth - Current recursion depth (prevents stack overflow)
73
+ * @returns Object with sensitive fields redacted
74
+ */
75
+ private static redactObject;
76
+ /**
77
+ * Check if a field name indicates sensitive information
78
+ * Uses case-insensitive matching with exact and partial matches
79
+ * Includes smart filtering to avoid false positives and custom patterns
80
+ * @param fieldName - Field name to check
81
+ * @returns true if field should be redacted, false otherwise
82
+ */
83
+ private static isSensitiveField;
84
+ /**
85
+ * Check if a field name indicates content that should be truncated
86
+ * Uses exact case-insensitive matching for content fields
87
+ * @param fieldName - Field name to check
88
+ * @returns true if field is a content field, false otherwise
89
+ */
90
+ private static isContentField;
91
+ /**
92
+ * Truncate content that exceeds the maximum length
93
+ * Preserves readability while preventing log bloat
94
+ * @param content - Content string to potentially truncate
95
+ * @returns Original content or truncated version with indicator
96
+ */
97
+ private static truncateContent;
98
+ }
99
+ //# sourceMappingURL=redactor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redactor.d.ts","sourceRoot":"","sources":["../../../src/redaction/redactor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAGpD;;;GAGG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,MAAM,CAGnB;IAGF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAO;IAElD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,uBAAuB,CAAM;IAErD;;;;SAIK;IACL,MAAM,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAU9D;;;SAGK;IACL,MAAM,CAAC,SAAS,IAAI,eAAe;IASnC;;;SAGK;IACL,MAAM,CAAC,aAAa,IAAI,IAAI;IAQ5B;;;SAGK;IACL,MAAM,CAAC,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;IAQlD;;SAEK;IACL,MAAM,CAAC,mBAAmB,IAAI,IAAI;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C,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,UAAU,CAAC,CAAC;IACjG,CAAC;IAED;;;;;SAKK;IACG,MAAM,CAAC,eAAe,CAAC,OAAe;QAC5C,IAAI,OAAO,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC3D,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC;IACzG,CAAC;;AArRH,oCAsRC;AArRgB,mBAAM,GAAoB;IACvC,GAAG,+BAAsB;IACzB,GAAG,4BAAmB,CAAC,oBAAoB,EAAE;CAC9C,CAAC;AAEF,4DAA4D;AACpC,gCAAmB,GAAG,GAAG,CAAC;AAClD,oEAAoE;AAC5C,oCAAuB,GAAG,EAAE,CAAC"}
@@ -41,3 +41,4 @@ var LogMode;
41
41
  /** Complete silence - shows no messages at all */
42
42
  LogMode[LogMode["OFF"] = 5] = "OFF";
43
43
  })(LogMode || (exports.LogMode = LogMode = {}));
44
+ //# sourceMappingURL=index.js.map