@wgtechlabs/log-engine 2.1.0 → 2.2.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.
Files changed (171) hide show
  1. package/README.md +67 -1
  2. package/dist/cjs/__tests__/async-test-utils.cjs +276 -0
  3. package/dist/cjs/__tests__/async-test-utils.d.ts +51 -0
  4. package/dist/cjs/__tests__/async-test-utils.d.ts.map +1 -0
  5. package/dist/cjs/__tests__/async-test-utils.js.map +1 -0
  6. package/dist/cjs/__tests__/redaction/test-utils.cjs +72 -0
  7. package/dist/cjs/__tests__/redaction/test-utils.d.ts +33 -0
  8. package/dist/cjs/__tests__/redaction/test-utils.d.ts.map +1 -0
  9. package/dist/cjs/__tests__/redaction/test-utils.js.map +1 -0
  10. package/dist/cjs/__tests__/test-utils.cjs +49 -0
  11. package/dist/cjs/__tests__/test-utils.d.ts +41 -0
  12. package/dist/cjs/__tests__/test-utils.d.ts.map +1 -0
  13. package/dist/cjs/__tests__/test-utils.js.map +1 -0
  14. package/dist/{formatter/colors.js → cjs/formatter/colors.cjs} +1 -0
  15. package/dist/cjs/formatter/colors.d.ts.map +1 -0
  16. package/dist/cjs/formatter/colors.js.map +1 -0
  17. package/dist/{formatter/data-formatter.js → cjs/formatter/data-formatter.cjs} +1 -0
  18. package/dist/cjs/formatter/data-formatter.d.ts.map +1 -0
  19. package/dist/cjs/formatter/data-formatter.js.map +1 -0
  20. package/dist/{formatter/index.js → cjs/formatter/index.cjs} +6 -5
  21. package/dist/cjs/formatter/index.d.ts.map +1 -0
  22. package/dist/cjs/formatter/index.js.map +1 -0
  23. package/dist/{formatter/message-formatter.js → cjs/formatter/message-formatter.cjs} +61 -11
  24. package/dist/{formatter → cjs/formatter}/message-formatter.d.ts +9 -3
  25. package/dist/cjs/formatter/message-formatter.d.ts.map +1 -0
  26. package/dist/cjs/formatter/message-formatter.js.map +1 -0
  27. package/dist/{formatter/timestamp.js → cjs/formatter/timestamp.cjs} +1 -0
  28. package/dist/cjs/formatter/timestamp.d.ts.map +1 -0
  29. package/dist/cjs/formatter/timestamp.js.map +1 -0
  30. package/dist/{index.js → cjs/index.cjs} +5 -4
  31. package/dist/{index.d.ts → cjs/index.d.ts} +1 -1
  32. package/dist/cjs/index.d.ts.map +1 -0
  33. package/dist/cjs/index.js.map +1 -0
  34. package/dist/{logger/advanced-outputs.js → cjs/logger/advanced-outputs.cjs} +1 -0
  35. package/dist/cjs/logger/advanced-outputs.d.ts.map +1 -0
  36. package/dist/cjs/logger/advanced-outputs.js.map +1 -0
  37. package/dist/{logger/config.js → cjs/logger/config.cjs} +4 -3
  38. package/dist/cjs/logger/config.d.ts.map +1 -0
  39. package/dist/cjs/logger/config.js.map +1 -0
  40. package/dist/{logger/core.js → cjs/logger/core.cjs} +48 -16
  41. package/dist/{logger → cjs/logger}/core.d.ts +19 -0
  42. package/dist/cjs/logger/core.d.ts.map +1 -0
  43. package/dist/cjs/logger/core.js.map +1 -0
  44. package/dist/{logger/environment.js → cjs/logger/environment.cjs} +2 -1
  45. package/dist/cjs/logger/environment.d.ts.map +1 -0
  46. package/dist/cjs/logger/environment.js.map +1 -0
  47. package/dist/{logger/filtering.js → cjs/logger/filtering.cjs} +2 -1
  48. package/dist/cjs/logger/filtering.d.ts.map +1 -0
  49. package/dist/cjs/logger/filtering.js.map +1 -0
  50. package/dist/{logger/index.js → cjs/logger/index.cjs} +6 -5
  51. package/dist/cjs/logger/index.d.ts.map +1 -0
  52. package/dist/cjs/logger/index.js.map +1 -0
  53. package/dist/cjs/package.json +3 -0
  54. package/dist/{redaction/config.js → cjs/redaction/config.cjs} +1 -0
  55. package/dist/cjs/redaction/config.d.ts.map +1 -0
  56. package/dist/cjs/redaction/config.js.map +1 -0
  57. package/dist/{redaction/index.js → cjs/redaction/index.cjs} +3 -2
  58. package/dist/cjs/redaction/index.d.ts.map +1 -0
  59. package/dist/cjs/redaction/index.js.map +1 -0
  60. package/dist/{redaction/redactor.js → cjs/redaction/redactor.cjs} +2 -1
  61. package/dist/cjs/redaction/redactor.d.ts.map +1 -0
  62. package/dist/cjs/redaction/redactor.js.map +1 -0
  63. package/dist/{types/index.js → cjs/types/index.cjs} +1 -0
  64. package/dist/{types → cjs/types}/index.d.ts +12 -0
  65. package/dist/cjs/types/index.d.ts.map +1 -0
  66. package/dist/cjs/types/index.js.map +1 -0
  67. package/dist/esm/__tests__/async-test-utils.d.ts +51 -0
  68. package/dist/esm/__tests__/async-test-utils.d.ts.map +1 -0
  69. package/dist/esm/__tests__/async-test-utils.js +231 -0
  70. package/dist/esm/__tests__/async-test-utils.js.map +1 -0
  71. package/dist/esm/__tests__/redaction/test-utils.d.ts +33 -0
  72. package/dist/esm/__tests__/redaction/test-utils.d.ts.map +1 -0
  73. package/dist/esm/__tests__/redaction/test-utils.js +65 -0
  74. package/dist/esm/__tests__/redaction/test-utils.js.map +1 -0
  75. package/dist/esm/__tests__/test-utils.d.ts +41 -0
  76. package/dist/esm/__tests__/test-utils.d.ts.map +1 -0
  77. package/dist/esm/__tests__/test-utils.js +42 -0
  78. package/dist/esm/__tests__/test-utils.js.map +1 -0
  79. package/dist/esm/formatter/colors.d.ts +32 -0
  80. package/dist/esm/formatter/colors.d.ts.map +1 -0
  81. package/dist/esm/formatter/colors.js +32 -0
  82. package/dist/esm/formatter/colors.js.map +1 -0
  83. package/dist/esm/formatter/data-formatter.d.ts +26 -0
  84. package/dist/esm/formatter/data-formatter.d.ts.map +1 -0
  85. package/dist/esm/formatter/data-formatter.js +50 -0
  86. package/dist/esm/formatter/data-formatter.js.map +1 -0
  87. package/dist/esm/formatter/index.d.ts +10 -0
  88. package/dist/esm/formatter/index.d.ts.map +1 -0
  89. package/dist/esm/formatter/index.js +11 -0
  90. package/dist/esm/formatter/index.js.map +1 -0
  91. package/dist/esm/formatter/message-formatter.d.ts +47 -0
  92. package/dist/esm/formatter/message-formatter.d.ts.map +1 -0
  93. package/dist/esm/formatter/message-formatter.js +133 -0
  94. package/dist/esm/formatter/message-formatter.js.map +1 -0
  95. package/dist/esm/formatter/timestamp.d.ts +27 -0
  96. package/dist/esm/formatter/timestamp.d.ts.map +1 -0
  97. package/dist/esm/formatter/timestamp.js +36 -0
  98. package/dist/esm/formatter/timestamp.js.map +1 -0
  99. package/dist/esm/index.d.ts +180 -0
  100. package/dist/esm/index.d.ts.map +1 -0
  101. package/dist/esm/index.js +194 -0
  102. package/dist/esm/index.js.map +1 -0
  103. package/dist/esm/logger/advanced-outputs.d.ts +159 -0
  104. package/dist/esm/logger/advanced-outputs.d.ts.map +1 -0
  105. package/dist/esm/logger/advanced-outputs.js +542 -0
  106. package/dist/esm/logger/advanced-outputs.js.map +1 -0
  107. package/dist/esm/logger/config.d.ts +42 -0
  108. package/dist/esm/logger/config.d.ts.map +1 -0
  109. package/dist/esm/logger/config.js +101 -0
  110. package/dist/esm/logger/config.js.map +1 -0
  111. package/dist/esm/logger/core.d.ts +171 -0
  112. package/dist/esm/logger/core.d.ts.map +1 -0
  113. package/dist/esm/logger/core.js +398 -0
  114. package/dist/esm/logger/core.js.map +1 -0
  115. package/dist/esm/logger/environment.d.ts +36 -0
  116. package/dist/esm/logger/environment.d.ts.map +1 -0
  117. package/dist/esm/logger/environment.js +58 -0
  118. package/dist/esm/logger/environment.js.map +1 -0
  119. package/dist/esm/logger/filtering.d.ts +36 -0
  120. package/dist/esm/logger/filtering.d.ts.map +1 -0
  121. package/dist/esm/logger/filtering.js +77 -0
  122. package/dist/esm/logger/filtering.js.map +1 -0
  123. package/dist/esm/logger/index.d.ts +10 -0
  124. package/dist/esm/logger/index.d.ts.map +1 -0
  125. package/dist/esm/logger/index.js +11 -0
  126. package/dist/esm/logger/index.js.map +1 -0
  127. package/dist/esm/redaction/config.d.ts +29 -0
  128. package/dist/esm/redaction/config.d.ts.map +1 -0
  129. package/dist/esm/redaction/config.js +92 -0
  130. package/dist/esm/redaction/config.js.map +1 -0
  131. package/dist/esm/redaction/index.d.ts +8 -0
  132. package/dist/esm/redaction/index.d.ts.map +1 -0
  133. package/dist/esm/redaction/index.js +7 -0
  134. package/dist/esm/redaction/index.js.map +1 -0
  135. package/dist/esm/redaction/redactor.d.ts +99 -0
  136. package/dist/esm/redaction/redactor.d.ts.map +1 -0
  137. package/dist/esm/redaction/redactor.js +259 -0
  138. package/dist/esm/redaction/redactor.js.map +1 -0
  139. package/dist/esm/types/index.d.ts +322 -0
  140. package/dist/esm/types/index.d.ts.map +1 -0
  141. package/dist/esm/types/index.js +41 -0
  142. package/dist/esm/types/index.js.map +1 -0
  143. package/package.json +59 -10
  144. package/dist/formatter/colors.d.ts.map +0 -1
  145. package/dist/formatter/data-formatter.d.ts.map +0 -1
  146. package/dist/formatter/index.d.ts.map +0 -1
  147. package/dist/formatter/message-formatter.d.ts.map +0 -1
  148. package/dist/formatter/timestamp.d.ts.map +0 -1
  149. package/dist/index.d.ts.map +0 -1
  150. package/dist/logger/advanced-outputs.d.ts.map +0 -1
  151. package/dist/logger/config.d.ts.map +0 -1
  152. package/dist/logger/core.d.ts.map +0 -1
  153. package/dist/logger/environment.d.ts.map +0 -1
  154. package/dist/logger/filtering.d.ts.map +0 -1
  155. package/dist/logger/index.d.ts.map +0 -1
  156. package/dist/redaction/config.d.ts.map +0 -1
  157. package/dist/redaction/index.d.ts.map +0 -1
  158. package/dist/redaction/redactor.d.ts.map +0 -1
  159. package/dist/types/index.d.ts.map +0 -1
  160. /package/dist/{formatter → cjs/formatter}/colors.d.ts +0 -0
  161. /package/dist/{formatter → cjs/formatter}/data-formatter.d.ts +0 -0
  162. /package/dist/{formatter → cjs/formatter}/index.d.ts +0 -0
  163. /package/dist/{formatter → cjs/formatter}/timestamp.d.ts +0 -0
  164. /package/dist/{logger → cjs/logger}/advanced-outputs.d.ts +0 -0
  165. /package/dist/{logger → cjs/logger}/config.d.ts +0 -0
  166. /package/dist/{logger → cjs/logger}/environment.d.ts +0 -0
  167. /package/dist/{logger → cjs/logger}/filtering.d.ts +0 -0
  168. /package/dist/{logger → cjs/logger}/index.d.ts +0 -0
  169. /package/dist/{redaction → cjs/redaction}/config.d.ts +0 -0
  170. /package/dist/{redaction → cjs/redaction}/index.d.ts +0 -0
  171. /package/dist/{redaction → cjs/redaction}/redactor.d.ts +0 -0
@@ -0,0 +1,259 @@
1
+ /**
2
+ * Core data redaction engine
3
+ * Handles automatic detection and redaction of sensitive information in log data
4
+ */
5
+ import { defaultRedactionConfig, RedactionController } from './config.js';
6
+ /**
7
+ * DataRedactor class - Core redaction logic for processing log data
8
+ * Automatically detects and redacts sensitive information while preserving structure
9
+ */
10
+ export class DataRedactor {
11
+ /**
12
+ * Update the redaction configuration with new settings
13
+ * Merges provided config with existing settings and reloads environment variables
14
+ * @param newConfig - Partial configuration to merge with current settings
15
+ */
16
+ static updateConfig(newConfig) {
17
+ // Reload environment configuration to pick up any changes
18
+ const envConfig = RedactionController.getEnvironmentConfig();
19
+ DataRedactor.config = {
20
+ ...defaultRedactionConfig,
21
+ ...envConfig,
22
+ ...newConfig
23
+ };
24
+ }
25
+ /**
26
+ * Get the current redaction configuration
27
+ * @returns Deep copy of current redaction configuration
28
+ */
29
+ static getConfig() {
30
+ return {
31
+ ...DataRedactor.config,
32
+ sensitiveFields: [...DataRedactor.config.sensitiveFields],
33
+ contentFields: [...DataRedactor.config.contentFields],
34
+ customPatterns: DataRedactor.config.customPatterns ? [...DataRedactor.config.customPatterns] : undefined
35
+ };
36
+ }
37
+ /**
38
+ * Refresh configuration from environment variables
39
+ * Useful for picking up runtime environment changes
40
+ */
41
+ static refreshConfig() {
42
+ const envConfig = RedactionController.getEnvironmentConfig();
43
+ DataRedactor.config = {
44
+ ...defaultRedactionConfig,
45
+ ...envConfig
46
+ };
47
+ }
48
+ /**
49
+ * Add custom regex patterns for advanced field detection
50
+ * @param patterns - Array of regex patterns to add
51
+ */
52
+ static addCustomPatterns(patterns) {
53
+ const currentPatterns = DataRedactor.config.customPatterns || [];
54
+ DataRedactor.config = {
55
+ ...DataRedactor.config,
56
+ customPatterns: [...currentPatterns, ...patterns]
57
+ };
58
+ }
59
+ /**
60
+ * Clear all custom regex patterns
61
+ */
62
+ static clearCustomPatterns() {
63
+ DataRedactor.config = {
64
+ ...DataRedactor.config,
65
+ customPatterns: []
66
+ };
67
+ }
68
+ /**
69
+ * Add custom sensitive field names to the existing list
70
+ * @param fields - Array of field names to add
71
+ */
72
+ static addSensitiveFields(fields) {
73
+ DataRedactor.config = {
74
+ ...DataRedactor.config,
75
+ sensitiveFields: [...DataRedactor.config.sensitiveFields, ...fields]
76
+ };
77
+ }
78
+ /**
79
+ * Test if a field name would be redacted with current configuration
80
+ * @param fieldName - Field name to test
81
+ * @returns true if field would be redacted, false otherwise
82
+ */
83
+ static testFieldRedaction(fieldName) {
84
+ const testObj = { [fieldName]: 'test-value' };
85
+ const result = DataRedactor.redactData(testObj); // Use safe property access to prevent object injection
86
+ if (Object.prototype.hasOwnProperty.call(result, fieldName)) {
87
+ // Safe access to avoid object injection
88
+ const value = result[fieldName];
89
+ return value !== 'test-value';
90
+ }
91
+ return false;
92
+ }
93
+ /**
94
+ * Main entry point for data redaction
95
+ * Processes any type of data and returns a redacted version
96
+ * @param data - Data to be processed for redaction
97
+ * @returns Redacted version of the data
98
+ */
99
+ static redactData(data) {
100
+ // Skip processing if redaction is disabled or data is null/undefined
101
+ if (!DataRedactor.config.enabled || data === null || data === undefined) {
102
+ return data;
103
+ }
104
+ return DataRedactor.processValue(data, new WeakSet(), 0);
105
+ }
106
+ /**
107
+ * Process a value of any type (primitive, object, array)
108
+ * Recursively handles nested structures when deepRedaction is enabled
109
+ * Includes circular reference protection and recursion depth limiting
110
+ * @param value - Value to process
111
+ * @param visited - Set to track visited objects (prevents circular references)
112
+ * @param depth - Current recursion depth (prevents stack overflow)
113
+ * @returns Processed value with redaction applied
114
+ */
115
+ static processValue(value, visited = new WeakSet(), depth = 0) {
116
+ // Check recursion depth limit to prevent stack overflow
117
+ if (depth >= DataRedactor.MAX_RECURSION_DEPTH) {
118
+ return '[Max Depth Exceeded]';
119
+ }
120
+ // Handle null and undefined
121
+ if (value === null || value === undefined) {
122
+ return value;
123
+ }
124
+ // Handle arrays - process each element
125
+ if (Array.isArray(value)) {
126
+ // Check for circular reference
127
+ if (visited.has(value)) {
128
+ return '[Circular Array]';
129
+ }
130
+ visited.add(value);
131
+ const result = value.map(item => DataRedactor.processValue(item, visited, depth + 1));
132
+ // Keep value in visited set to detect circular references across branches
133
+ return result;
134
+ }
135
+ // Handle objects - process each property
136
+ if (typeof value === 'object') {
137
+ // Check for circular reference
138
+ if (visited.has(value)) {
139
+ return '[Circular Object]';
140
+ }
141
+ visited.add(value);
142
+ const result = DataRedactor.redactObject(value, visited, depth + 1);
143
+ // Keep value in visited set to detect circular references across branches
144
+ return result;
145
+ }
146
+ // Handle primitives (string, number, boolean) - return as-is
147
+ return value;
148
+ }
149
+ /**
150
+ * Process an object and redact sensitive fields
151
+ * Handles field-level redaction and content truncation
152
+ * @param obj - Object to process
153
+ * @param visited - Set to track visited objects (prevents circular references)
154
+ * @param depth - Current recursion depth (prevents stack overflow)
155
+ * @returns Object with sensitive fields redacted
156
+ */
157
+ static redactObject(obj, visited = new WeakSet(), depth = 0) {
158
+ // Check recursion depth limit to prevent stack overflow
159
+ if (depth >= DataRedactor.MAX_REDACT_OBJECT_DEPTH) {
160
+ return { '[Max Depth Exceeded]': '[Max Depth Exceeded]' };
161
+ }
162
+ const redacted = {};
163
+ for (const [key, value] of Object.entries(obj)) {
164
+ // Check if this field should be completely redacted
165
+ if (DataRedactor.isSensitiveField(key)) {
166
+ Object.defineProperty(redacted, key, { value: DataRedactor.config.redactionText, enumerable: true, writable: true, configurable: true });
167
+ }
168
+ else if (DataRedactor.isContentField(key) && typeof value === 'string') {
169
+ // Check if this field should be truncated (for large content)
170
+ Object.defineProperty(redacted, key, { value: DataRedactor.truncateContent(value), enumerable: true, writable: true, configurable: true });
171
+ }
172
+ else if (DataRedactor.config.deepRedaction && (typeof value === 'object' && value !== null)) {
173
+ // Recursively process nested objects/arrays if deep redaction is enabled
174
+ Object.defineProperty(redacted, key, { value: DataRedactor.processValue(value, visited, depth + 1), enumerable: true, writable: true, configurable: true });
175
+ }
176
+ else {
177
+ // Keep the value unchanged
178
+ Object.defineProperty(redacted, key, { value: value, enumerable: true, writable: true, configurable: true });
179
+ }
180
+ }
181
+ return redacted;
182
+ }
183
+ /**
184
+ * Check if a field name indicates sensitive information
185
+ * Uses case-insensitive matching with exact and partial matches
186
+ * Includes smart filtering to avoid false positives and custom patterns
187
+ * @param fieldName - Field name to check
188
+ * @returns true if field should be redacted, false otherwise
189
+ */
190
+ static isSensitiveField(fieldName) {
191
+ const lowerField = fieldName.toLowerCase();
192
+ // Check custom regex patterns first (highest priority)
193
+ if (DataRedactor.config.customPatterns && DataRedactor.config.customPatterns.length > 0) {
194
+ for (const pattern of DataRedactor.config.customPatterns) {
195
+ if (pattern.test(fieldName)) {
196
+ return true;
197
+ }
198
+ }
199
+ }
200
+ return DataRedactor.config.sensitiveFields.some(sensitive => {
201
+ const lowerSensitive = sensitive.toLowerCase();
202
+ // Exact match (highest confidence)
203
+ if (lowerField === lowerSensitive) {
204
+ return true;
205
+ }
206
+ // Field ends with sensitive term (e.g., "userPassword" ends with "password")
207
+ if (lowerField.endsWith(lowerSensitive)) {
208
+ return true;
209
+ }
210
+ // Field starts with sensitive term (e.g., "passwordHash" starts with "password")
211
+ if (lowerField.startsWith(lowerSensitive)) {
212
+ return true;
213
+ }
214
+ // Whitelist of short sensitive terms that should always trigger substring matching
215
+ const shortSensitiveWhitelist = ['pin', 'cvv', 'cvc', 'ssn', 'pwd', 'key', 'jwt', 'dob', 'pii', 'auth', 'csrf'];
216
+ // Field contains sensitive term - either from whitelist or length >= 5 to avoid false positives
217
+ if ((shortSensitiveWhitelist.includes(lowerSensitive) || lowerSensitive.length >= 5) &&
218
+ lowerField.includes(lowerSensitive)) {
219
+ return true;
220
+ }
221
+ // Handle compound words with underscores or camelCase
222
+ if (lowerField.includes('_' + lowerSensitive) || lowerField.includes(lowerSensitive + '_')) {
223
+ return true;
224
+ }
225
+ return false;
226
+ });
227
+ }
228
+ /**
229
+ * Check if a field name indicates content that should be truncated
230
+ * Uses exact case-insensitive matching for content fields
231
+ * @param fieldName - Field name to check
232
+ * @returns true if field is a content field, false otherwise
233
+ */
234
+ static isContentField(fieldName) {
235
+ const lowerField = fieldName.toLowerCase();
236
+ return DataRedactor.config.contentFields.some(content => content.toLowerCase() === lowerField);
237
+ }
238
+ /**
239
+ * Truncate content that exceeds the maximum length
240
+ * Preserves readability while preventing log bloat
241
+ * @param content - Content string to potentially truncate
242
+ * @returns Original content or truncated version with indicator
243
+ */
244
+ static truncateContent(content) {
245
+ if (content.length <= DataRedactor.config.maxContentLength) {
246
+ return content;
247
+ }
248
+ return content.substring(0, DataRedactor.config.maxContentLength) + DataRedactor.config.truncationText;
249
+ }
250
+ }
251
+ DataRedactor.config = {
252
+ ...defaultRedactionConfig,
253
+ ...RedactionController.getEnvironmentConfig()
254
+ };
255
+ // Maximum recursion depth to prevent stack overflow attacks
256
+ DataRedactor.MAX_RECURSION_DEPTH = 100;
257
+ // Slightly lower limit for redactObject to ensure it can be reached
258
+ DataRedactor.MAX_REDACT_OBJECT_DEPTH = 99;
259
+ //# sourceMappingURL=redactor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redactor.js","sourceRoot":"","sources":["../../../src/redaction/redactor.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEvE;;;GAGG;AACH,MAAM,OAAO,YAAY;IAWvB;;;;SAIK;IACL,MAAM,CAAC,YAAY,CAAC,SAAmC;QACrD,0DAA0D;QAC1D,MAAM,SAAS,GAAG,mBAAmB,CAAC,oBAAoB,EAAE,CAAC;QAC7D,YAAY,CAAC,MAAM,GAAG;YACpB,GAAG,sBAAsB;YACzB,GAAG,SAAS;YACZ,GAAG,SAAS;SACb,CAAC;IACJ,CAAC;IAED;;;SAGK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IAAI,UAAU,CAAC,QAAQ,CAAC,cAAc,GAAG,GAAG,CAAC,EAAE,CAAC;gBAC3F,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;SAKK;IACG,MAAM,CAAC,cAAc,CAAC,SAAiB;QAC7C,MAAM,UAAU,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;QAC3C,OAAO,YAAY,CAAC,MAAM,CAAC,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;;AApRc,mBAAM,GAAoB;IACvC,GAAG,sBAAsB;IACzB,GAAG,mBAAmB,CAAC,oBAAoB,EAAE;CAC9C,CAAC;AAEF,4DAA4D;AACpC,gCAAmB,GAAG,GAAG,CAAC;AAClD,oEAAoE;AAC5C,oCAAuB,GAAG,EAAE,CAAC"}
@@ -0,0 +1,322 @@
1
+ /**
2
+ * Type definitions for the Log Engine library
3
+ * Provides strongly-typed interfaces for configuration and log levels
4
+ */
5
+ /**
6
+ * Type for log data - accepts any value since logs can contain literally anything
7
+ * This is intentionally `any` rather than `unknown` for maximum usability in a logging context
8
+ */
9
+ export type LogData = any;
10
+ /**
11
+ * Log levels representing message severity (lowest to highest)
12
+ * Used for filtering messages based on importance
13
+ */
14
+ export declare enum LogLevel {
15
+ /** Detailed diagnostic information, typically only of interest during development */
16
+ DEBUG = 0,
17
+ /** General information about application flow and state */
18
+ INFO = 1,
19
+ /** Potentially harmful situations that don't prevent operation */
20
+ WARN = 2,
21
+ /** Error events that might still allow the application to continue */
22
+ ERROR = 3,
23
+ /** Critical messages that always output regardless of configured mode (except when OFF is set) */
24
+ LOG = 99
25
+ }
26
+ /**
27
+ * Log modes controlling output behavior and filtering
28
+ * Determines what messages are displayed based on verbosity requirements
29
+ */
30
+ export declare enum LogMode {
31
+ /** Most verbose - shows DEBUG, INFO, WARN, ERROR, LOG messages */
32
+ DEBUG = 0,
33
+ /** Balanced - shows INFO, WARN, ERROR, LOG messages */
34
+ INFO = 1,
35
+ /** Focused - shows WARN, ERROR, LOG messages */
36
+ WARN = 2,
37
+ /** Minimal - shows ERROR, LOG messages */
38
+ ERROR = 3,
39
+ /** Critical only - shows LOG messages only */
40
+ SILENT = 4,
41
+ /** Complete silence - shows no messages at all */
42
+ OFF = 5
43
+ }
44
+ /**
45
+ * Represents a single log entry with timestamp, level, and message
46
+ * Used internally for structured logging operations
47
+ */
48
+ export interface LogEntry {
49
+ /** When the log entry was created */
50
+ timestamp: Date;
51
+ /** The severity level of this log entry */
52
+ level: LogLevel;
53
+ /** The actual log message content */
54
+ message: string;
55
+ }
56
+ /**
57
+ * Output handler function type for custom log output
58
+ * Receives the log level, formatted message, and optional data
59
+ */
60
+ export type LogOutputHandler = (level: string, message: string, data?: LogData) => void;
61
+ /**
62
+ * Built-in output handler types
63
+ */
64
+ export type BuiltInOutputHandler = 'console' | 'silent' | 'file' | 'http';
65
+ /**
66
+ * Configuration for file output handler
67
+ */
68
+ export interface FileOutputConfig {
69
+ /** File path to write logs to */
70
+ filePath: string;
71
+ /** Whether to append to existing file (default: true) */
72
+ append?: boolean;
73
+ /** Maximum file size before rotation in bytes (optional) */
74
+ maxFileSize?: number;
75
+ /** Number of backup files to keep during rotation (default: 3) */
76
+ maxBackupFiles?: number;
77
+ /** Custom format function for file output */
78
+ formatter?: (level: string, message: string, data?: LogData) => string;
79
+ }
80
+ /**
81
+ * Configuration for HTTP output handler
82
+ */
83
+ export interface HttpOutputConfig {
84
+ /** HTTP endpoint URL to send logs to */
85
+ url: string;
86
+ /** HTTP method (default: 'POST') */
87
+ method?: 'POST' | 'PUT' | 'PATCH';
88
+ /** Custom headers to include with requests */
89
+ headers?: Record<string, string>;
90
+ /** Batch size for sending multiple logs (default: 1) */
91
+ batchSize?: number;
92
+ /** Timeout for HTTP requests in ms (default: 5000) */
93
+ timeout?: number;
94
+ /** Custom format function for HTTP payload */
95
+ formatter?: (logs: Array<{
96
+ level: string;
97
+ message: string;
98
+ data?: LogData;
99
+ timestamp: string;
100
+ }>) => LogData;
101
+ }
102
+ /**
103
+ * Configuration object for advanced built-in handlers
104
+ */
105
+ export interface AdvancedOutputConfig {
106
+ file?: FileOutputConfig;
107
+ http?: HttpOutputConfig;
108
+ }
109
+ /**
110
+ * Enhanced output target - can be built-in handler, custom function, or configured handler object
111
+ */
112
+ export type EnhancedOutputTarget = BuiltInOutputHandler | LogOutputHandler | {
113
+ type: 'file';
114
+ config: FileOutputConfig;
115
+ } | {
116
+ type: 'http';
117
+ config: HttpOutputConfig;
118
+ };
119
+ /**
120
+ * Output target - can be a built-in handler string or custom function
121
+ */
122
+ export type OutputTarget = BuiltInOutputHandler | LogOutputHandler;
123
+ /**
124
+ * Configuration for log message formatting
125
+ * Controls which elements are included in the log output
126
+ */
127
+ export interface LogFormatConfig {
128
+ /** Whether to include ISO timestamp (e.g., [2025-05-29T16:57:45.678Z]) */
129
+ includeIsoTimestamp?: boolean;
130
+ /** Whether to include local time (e.g., [4:57PM]) */
131
+ includeLocalTime?: boolean;
132
+ }
133
+ /**
134
+ * Configuration options for the logger
135
+ * Supports both legacy level-based and new mode-based configuration
136
+ */
137
+ export interface LoggerConfig {
138
+ /** Log mode controlling output behavior (new API) */
139
+ mode?: LogMode;
140
+ /** Legacy: Minimum log level to display (backwards compatibility)
141
+ * Note: If both mode and level are provided, mode takes precedence */
142
+ level?: LogLevel;
143
+ /** Optional environment identifier for context (e.g., 'production', 'staging') */
144
+ environment?: string;
145
+ /** Custom output handler function to replace console output (backward compatibility) */
146
+ outputHandler?: LogOutputHandler;
147
+ /** Array of output targets for multiple simultaneous outputs */
148
+ outputs?: OutputTarget[];
149
+ /** Enhanced outputs with advanced configuration support */
150
+ enhancedOutputs?: EnhancedOutputTarget[];
151
+ /** Whether to suppress default console output (useful with custom outputHandler) */
152
+ suppressConsoleOutput?: boolean;
153
+ /** Advanced configuration for built-in handlers */
154
+ advancedOutputConfig?: AdvancedOutputConfig;
155
+ /** Format configuration for customizing log element inclusion */
156
+ format?: LogFormatConfig;
157
+ }
158
+ /**
159
+ * Configuration options for automatic data redaction
160
+ * Controls how sensitive information is processed in log messages
161
+ */
162
+ export interface RedactionConfig {
163
+ /** Whether redaction is enabled globally */
164
+ enabled: boolean;
165
+ /** List of field names that should be redacted (case-insensitive partial matching) */
166
+ sensitiveFields: string[];
167
+ /** List of field names that should be truncated if they exceed maxContentLength */
168
+ contentFields: string[];
169
+ /** Maximum length for content fields before truncation occurs */
170
+ maxContentLength: number;
171
+ /** Text to replace sensitive field values with */
172
+ redactionText: string;
173
+ /** Text to append when content is truncated */
174
+ truncationText: string;
175
+ /** Whether to recursively scan nested objects and arrays */
176
+ deepRedaction: boolean;
177
+ /** Optional custom regex patterns for advanced field detection */
178
+ customPatterns?: RegExp[];
179
+ }
180
+ /**
181
+ * Interface for the LogEngine singleton object
182
+ * Provides all logging methods with comprehensive TypeScript support
183
+ */
184
+ export interface ILogEngine {
185
+ /** Configure the logger with new settings */
186
+ configure(config: Partial<LoggerConfig>): void;
187
+ /** Log a debug message with automatic data redaction */
188
+ debug(message: string, data?: LogData): void;
189
+ /** Log an info message with automatic data redaction */
190
+ info(message: string, data?: LogData): void;
191
+ /** Log a warn message with automatic data redaction */
192
+ warn(message: string, data?: LogData): void;
193
+ /** Log an error message with automatic data redaction */
194
+ error(message: string, data?: LogData): void;
195
+ /** Log a message with automatic data redaction */
196
+ log(message: string, data?: LogData): void;
197
+ /** Log a debug message without redaction */
198
+ debugRaw(message: string, data?: LogData): void;
199
+ /** Log an info message without redaction */
200
+ infoRaw(message: string, data?: LogData): void;
201
+ /** Log a warn message without redaction */
202
+ warnRaw(message: string, data?: LogData): void;
203
+ /** Log an error message without redaction */
204
+ errorRaw(message: string, data?: LogData): void;
205
+ /** Log a message without redaction */
206
+ logRaw(message: string, data?: LogData): void;
207
+ /** Configure redaction settings */
208
+ configureRedaction(config: Partial<RedactionConfig>): void;
209
+ /** Reset redaction configuration to defaults */
210
+ resetRedactionConfig(): void;
211
+ /** Refresh redaction configuration from environment variables */
212
+ refreshRedactionConfig(): void;
213
+ /** Get current redaction configuration */
214
+ getRedactionConfig(): RedactionConfig;
215
+ /** Add custom regex patterns for advanced field detection */
216
+ addCustomRedactionPatterns(patterns: RegExp[]): void;
217
+ /** Clear all custom redaction patterns */
218
+ clearCustomRedactionPatterns(): void;
219
+ /** Add custom sensitive field names to the existing list */
220
+ addSensitiveFields(fields: string[]): void;
221
+ /** Test if a field name would be redacted with current configuration */
222
+ testFieldRedaction(fieldName: string): boolean;
223
+ /** Temporarily disable redaction for a specific logging call */
224
+ withoutRedaction(): ILogEngineWithoutRedaction;
225
+ }
226
+ /**
227
+ * Interface for LogEngine methods without redaction
228
+ * Returned by withoutRedaction() method
229
+ */
230
+ export interface ILogEngineWithoutRedaction {
231
+ /** Log a debug message without redaction */
232
+ debug(message: string, data?: LogData): void;
233
+ /** Log an info message without redaction */
234
+ info(message: string, data?: LogData): void;
235
+ /** Log a warn message without redaction */
236
+ warn(message: string, data?: LogData): void;
237
+ /** Log an error message without redaction */
238
+ error(message: string, data?: LogData): void;
239
+ /** Log a message without redaction */
240
+ log(message: string, data?: LogData): void;
241
+ }
242
+ /**
243
+ * Interface for the DataRedactor static class methods
244
+ * Provides type safety for all redaction operations
245
+ */
246
+ export interface IDataRedactor {
247
+ /** Update redaction configuration */
248
+ updateConfig(newConfig: Partial<RedactionConfig>): void;
249
+ /** Get current redaction configuration */
250
+ getConfig(): RedactionConfig;
251
+ /** Refresh configuration from environment variables */
252
+ refreshConfig(): void;
253
+ /** Add custom regex patterns for field detection */
254
+ addCustomPatterns(patterns: RegExp[]): void;
255
+ /** Clear all custom regex patterns */
256
+ clearCustomPatterns(): void;
257
+ /** Add sensitive field names to the existing list */
258
+ addSensitiveFields(fields: string[]): void;
259
+ /** Test if a field name would be redacted */
260
+ testFieldRedaction(fieldName: string): boolean;
261
+ /** Redact sensitive data from any value */
262
+ redactData(data: LogData): LogData;
263
+ }
264
+ /**
265
+ * Interface for the RedactionController methods
266
+ * Provides environment-based configuration management
267
+ */
268
+ export interface IRedactionController {
269
+ /** Load configuration from environment variables */
270
+ loadFromEnvironment(): RedactionConfig;
271
+ /** Reset configuration to default values */
272
+ resetToDefaults(): RedactionConfig;
273
+ /** Get currently active configuration */
274
+ getCurrentConfig(): RedactionConfig;
275
+ }
276
+ /**
277
+ * Options for configuring redaction behavior
278
+ * Used for advanced redaction scenarios
279
+ */
280
+ export interface RedactionOptions {
281
+ /** Whether to enable deep scanning of nested objects */
282
+ deep?: boolean;
283
+ /** Custom patterns to use for this operation */
284
+ customPatterns?: RegExp[];
285
+ /** Additional sensitive fields for this operation */
286
+ additionalSensitiveFields?: string[];
287
+ /** Override default redaction text */
288
+ redactionText?: string;
289
+ }
290
+ /**
291
+ * Result type for field redaction testing
292
+ * Provides detailed information about redaction decisions
293
+ */
294
+ export interface FieldRedactionResult {
295
+ /** Whether the field would be redacted */
296
+ wouldRedact: boolean;
297
+ /** Reason for the redaction decision */
298
+ reason: 'sensitive_field' | 'custom_pattern' | 'not_sensitive';
299
+ /** Pattern that matched (if applicable) */
300
+ matchedPattern?: RegExp;
301
+ }
302
+ /**
303
+ * Environment variable configuration mapping
304
+ * Documents all supported environment variables
305
+ */
306
+ export interface EnvironmentConfig {
307
+ /** LOG_REDACTION_DISABLED - Disable all redaction */
308
+ LOG_REDACTION_DISABLED?: string;
309
+ /** LOG_REDACTION_TEXT - Custom redaction text */
310
+ LOG_REDACTION_TEXT?: string;
311
+ /** LOG_REDACTION_SENSITIVE_FIELDS - Comma-separated sensitive field names */
312
+ LOG_REDACTION_SENSITIVE_FIELDS?: string;
313
+ /** LOG_REDACTION_CONTENT_FIELDS - Comma-separated content field names */
314
+ LOG_REDACTION_CONTENT_FIELDS?: string;
315
+ /** LOG_REDACTION_MAX_CONTENT_LENGTH - Maximum length for content fields */
316
+ LOG_REDACTION_MAX_CONTENT_LENGTH?: string;
317
+ /** LOG_REDACTION_TRUNCATION_TEXT - Text for truncated content */
318
+ LOG_REDACTION_TRUNCATION_TEXT?: string;
319
+ /** LOG_REDACTION_DEEP - Enable deep redaction */
320
+ LOG_REDACTION_DEEP?: string;
321
+ }
322
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AAEH,MAAM,MAAM,OAAO,GAAG,GAAG,CAAC;AAE1B;;;GAGG;AACH,oBAAY,QAAQ;IAChB,qFAAqF;IACrF,KAAK,IAAI;IACT,2DAA2D;IAC3D,IAAI,IAAI;IACR,kEAAkE;IAClE,IAAI,IAAI;IACR,sEAAsE;IACtE,KAAK,IAAI;IACT,kGAAkG;IAClG,GAAG,KAAK;CACX;AAED;;;GAGG;AACH,oBAAY,OAAO;IACf,kEAAkE;IAClE,KAAK,IAAI;IACT,uDAAuD;IACvD,IAAI,IAAI;IACR,gDAAgD;IAChD,IAAI,IAAI;IACR,0CAA0C;IAC1C,KAAK,IAAI;IACT,8CAA8C;IAC9C,MAAM,IAAI;IACV,kDAAkD;IAClD,GAAG,IAAI;CACV;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB,qCAAqC;IACrC,SAAS,EAAE,IAAI,CAAC;IAChB,2CAA2C;IAC3C,KAAK,EAAE,QAAQ,CAAC;IAChB,qCA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,GAAG,eAAe,CAAC;IAC/D,2CAA2C;IAC3C,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,qDAAqD;IACrD,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iDAAiD;IACjD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,6EAA6E;IAC7E,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,yEAAyE;IACzE,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,2EAA2E;IAC3E,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAC1C,iEAAiE;IACjE,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,iDAAiD;IACjD,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Type definitions for the Log Engine library
3
+ * Provides strongly-typed interfaces for configuration and log levels
4
+ */
5
+ /**
6
+ * Log levels representing message severity (lowest to highest)
7
+ * Used for filtering messages based on importance
8
+ */
9
+ export var LogLevel;
10
+ (function (LogLevel) {
11
+ /** Detailed diagnostic information, typically only of interest during development */
12
+ LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
13
+ /** General information about application flow and state */
14
+ LogLevel[LogLevel["INFO"] = 1] = "INFO";
15
+ /** Potentially harmful situations that don't prevent operation */
16
+ LogLevel[LogLevel["WARN"] = 2] = "WARN";
17
+ /** Error events that might still allow the application to continue */
18
+ LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
19
+ /** Critical messages that always output regardless of configured mode (except when OFF is set) */
20
+ LogLevel[LogLevel["LOG"] = 99] = "LOG";
21
+ })(LogLevel || (LogLevel = {}));
22
+ /**
23
+ * Log modes controlling output behavior and filtering
24
+ * Determines what messages are displayed based on verbosity requirements
25
+ */
26
+ export var LogMode;
27
+ (function (LogMode) {
28
+ /** Most verbose - shows DEBUG, INFO, WARN, ERROR, LOG messages */
29
+ LogMode[LogMode["DEBUG"] = 0] = "DEBUG";
30
+ /** Balanced - shows INFO, WARN, ERROR, LOG messages */
31
+ LogMode[LogMode["INFO"] = 1] = "INFO";
32
+ /** Focused - shows WARN, ERROR, LOG messages */
33
+ LogMode[LogMode["WARN"] = 2] = "WARN";
34
+ /** Minimal - shows ERROR, LOG messages */
35
+ LogMode[LogMode["ERROR"] = 3] = "ERROR";
36
+ /** Critical only - shows LOG messages only */
37
+ LogMode[LogMode["SILENT"] = 4] = "SILENT";
38
+ /** Complete silence - shows no messages at all */
39
+ LogMode[LogMode["OFF"] = 5] = "OFF";
40
+ })(LogMode || (LogMode = {}));
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH;;;GAGG;AACH,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAChB,qFAAqF;IACrF,yCAAS,CAAA;IACT,2DAA2D;IAC3D,uCAAQ,CAAA;IACR,kEAAkE;IAClE,uCAAQ,CAAA;IACR,sEAAsE;IACtE,yCAAS,CAAA;IACT,kGAAkG;IAClG,sCAAQ,CAAA;AACZ,CAAC,EAXW,QAAQ,KAAR,QAAQ,QAWnB;AAED;;;GAGG;AACH,MAAM,CAAN,IAAY,OAaX;AAbD,WAAY,OAAO;IACf,kEAAkE;IAClE,uCAAS,CAAA;IACT,uDAAuD;IACvD,qCAAQ,CAAA;IACR,gDAAgD;IAChD,qCAAQ,CAAA;IACR,0CAA0C;IAC1C,uCAAS,CAAA;IACT,8CAA8C;IAC9C,yCAAU,CAAA;IACV,kDAAkD;IAClD,mCAAO,CAAA;AACX,CAAC,EAbW,OAAO,KAAP,OAAO,QAalB"}