@nest-omni/core 4.1.3-25 → 4.1.3-26

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 (30) hide show
  1. package/cache/cache.service.d.ts +3 -1
  2. package/cache/cache.service.js +8 -8
  3. package/cache/decorators/cache-put.decorator.js +5 -4
  4. package/cache/dependencies/callback.dependency.js +9 -0
  5. package/cache/dependencies/tag.dependency.d.ts +1 -9
  6. package/cache/dependencies/tag.dependency.js +5 -14
  7. package/cache/providers/lrucache.provider.d.ts +1 -0
  8. package/cache/providers/lrucache.provider.js +6 -4
  9. package/cache/providers/redis-cache.provider.d.ts +1 -0
  10. package/cache/providers/redis-cache.provider.js +8 -6
  11. package/http-client/config/http-client.config.js +3 -1
  12. package/http-client/examples/axios-config-extended.example.js +1 -3
  13. package/http-client/examples/flexible-response-example.d.ts +28 -0
  14. package/http-client/examples/flexible-response-example.js +120 -0
  15. package/http-client/examples/ssl-certificate.example.d.ts +2 -2
  16. package/http-client/examples/ssl-certificate.example.js +18 -17
  17. package/http-client/services/api-client-registry.service.d.ts +6 -6
  18. package/http-client/services/api-client-registry.service.js +8 -8
  19. package/http-client/services/circuit-breaker.service.d.ts +9 -9
  20. package/http-client/services/circuit-breaker.service.js +24 -24
  21. package/http-client/services/http-client.service.d.ts +30 -13
  22. package/http-client/services/http-client.service.js +75 -46
  23. package/http-client/services/logging.service.d.ts +16 -16
  24. package/http-client/services/logging.service.js +46 -45
  25. package/http-client/utils/proxy-environment.util.d.ts +12 -12
  26. package/http-client/utils/proxy-environment.util.js +25 -19
  27. package/http-client/utils/security-validator.util.d.ts +19 -19
  28. package/http-client/utils/security-validator.util.js +66 -64
  29. package/package.json +1 -1
  30. package/vault/vault-config.service.js +1 -1
@@ -75,6 +75,25 @@ export declare class SecurityValidator {
75
75
  valid: boolean;
76
76
  error?: string;
77
77
  };
78
+ /**
79
+ * 敏感数据检测
80
+ * 检查数据中是否包含敏感信息(如密码、token等)
81
+ * @param data 要检查的数据对象
82
+ * @param additionalPatterns 额外的敏感数据模式
83
+ * @returns 检测结果
84
+ */
85
+ static detectSensitiveData(data: any, additionalPatterns?: RegExp[]): {
86
+ hasSensitiveData: boolean;
87
+ fields: string[];
88
+ };
89
+ /**
90
+ * 获取默认SSRF防护配置
91
+ */
92
+ static getDefaultSSRFConfig(): SSRFProtectionConfig;
93
+ /**
94
+ * 获取默认URL验证配置
95
+ */
96
+ static getDefaultURLConfig(): URLValidationConfig;
78
97
  /**
79
98
  * 从主机名中提取IP地址
80
99
  */
@@ -96,23 +115,4 @@ export declare class SecurityValidator {
96
115
  * 验证主机名格式
97
116
  */
98
117
  private static isValidHostname;
99
- /**
100
- * 敏感数据检测
101
- * 检查数据中是否包含敏感信息(如密码、token等)
102
- * @param data 要检查的数据对象
103
- * @param additionalPatterns 额外的敏感数据模式
104
- * @returns 检测结果
105
- */
106
- static detectSensitiveData(data: any, additionalPatterns?: RegExp[]): {
107
- hasSensitiveData: boolean;
108
- fields: string[];
109
- };
110
- /**
111
- * 获取默认SSRF防护配置
112
- */
113
- static getDefaultSSRFConfig(): SSRFProtectionConfig;
114
- /**
115
- * 获取默认URL验证配置
116
- */
117
- static getDefaultURLConfig(): URLValidationConfig;
118
118
  }
@@ -143,6 +143,69 @@ class SecurityValidator {
143
143
  }
144
144
  return { url: sanitizedURL, valid: true };
145
145
  }
146
+ /**
147
+ * 敏感数据检测
148
+ * 检查数据中是否包含敏感信息(如密码、token等)
149
+ * @param data 要检查的数据对象
150
+ * @param additionalPatterns 额外的敏感数据模式
151
+ * @returns 检测结果
152
+ */
153
+ static detectSensitiveData(data, additionalPatterns = []) {
154
+ const sensitiveFields = [];
155
+ // 默认敏感字段名模式
156
+ const defaultPatterns = [
157
+ /password/i,
158
+ /secret/i,
159
+ /token/i,
160
+ /api[_-]?key/i,
161
+ /authorization/i,
162
+ /credential/i,
163
+ /private[_-]?key/i,
164
+ /access[_-]?token/i,
165
+ /refresh[_-]?token/i,
166
+ /session[_-]?id/i,
167
+ /csrf/i,
168
+ /ssn/i,
169
+ /credit[_-]?card/i,
170
+ ];
171
+ const allPatterns = [...defaultPatterns, ...additionalPatterns];
172
+ const checkObject = (obj, path = '') => {
173
+ if (!obj || typeof obj !== 'object') {
174
+ return;
175
+ }
176
+ for (const key in obj) {
177
+ if (!obj.hasOwnProperty(key)) {
178
+ continue;
179
+ }
180
+ const currentPath = path ? `${path}.${key}` : key;
181
+ // 检查键名是否匹配敏感模式
182
+ if (allPatterns.some((pattern) => pattern.test(key))) {
183
+ sensitiveFields.push(currentPath);
184
+ }
185
+ // 递归检查嵌套对象
186
+ if (typeof obj[key] === 'object' && obj[key] !== null) {
187
+ checkObject(obj[key], currentPath);
188
+ }
189
+ }
190
+ };
191
+ checkObject(data);
192
+ return {
193
+ hasSensitiveData: sensitiveFields.length > 0,
194
+ fields: sensitiveFields,
195
+ };
196
+ }
197
+ /**
198
+ * 获取默认SSRF防护配置
199
+ */
200
+ static getDefaultSSRFConfig() {
201
+ return Object.assign({}, this.defaultSSRFConfig);
202
+ }
203
+ /**
204
+ * 获取默认URL验证配置
205
+ */
206
+ static getDefaultURLConfig() {
207
+ return Object.assign({}, this.defaultURLConfig);
208
+ }
146
209
  /**
147
210
  * 从主机名中提取IP地址
148
211
  */
@@ -165,7 +228,9 @@ class SecurityValidator {
165
228
  static validateIPAddress(ipAddress, config) {
166
229
  // 检查是否为本地回环地址
167
230
  if (!config.allowLoopback) {
168
- if (ipAddress === '127.0.0.1' || ipAddress === '::1' || ipAddress.startsWith('127.')) {
231
+ if (ipAddress === '127.0.0.1' ||
232
+ ipAddress === '::1' ||
233
+ ipAddress.startsWith('127.')) {
169
234
  return {
170
235
  valid: false,
171
236
  error: 'Loopback addresses are not allowed',
@@ -251,69 +316,6 @@ class SecurityValidator {
251
316
  const hostnameRegex = /^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$/;
252
317
  return hostnameRegex.test(hostname);
253
318
  }
254
- /**
255
- * 敏感数据检测
256
- * 检查数据中是否包含敏感信息(如密码、token等)
257
- * @param data 要检查的数据对象
258
- * @param additionalPatterns 额外的敏感数据模式
259
- * @returns 检测结果
260
- */
261
- static detectSensitiveData(data, additionalPatterns = []) {
262
- const sensitiveFields = [];
263
- // 默认敏感字段名模式
264
- const defaultPatterns = [
265
- /password/i,
266
- /secret/i,
267
- /token/i,
268
- /api[_-]?key/i,
269
- /authorization/i,
270
- /credential/i,
271
- /private[_-]?key/i,
272
- /access[_-]?token/i,
273
- /refresh[_-]?token/i,
274
- /session[_-]?id/i,
275
- /csrf/i,
276
- /ssn/i,
277
- /credit[_-]?card/i,
278
- ];
279
- const allPatterns = [...defaultPatterns, ...additionalPatterns];
280
- const checkObject = (obj, path = '') => {
281
- if (!obj || typeof obj !== 'object') {
282
- return;
283
- }
284
- for (const key in obj) {
285
- if (!obj.hasOwnProperty(key)) {
286
- continue;
287
- }
288
- const currentPath = path ? `${path}.${key}` : key;
289
- // 检查键名是否匹配敏感模式
290
- if (allPatterns.some((pattern) => pattern.test(key))) {
291
- sensitiveFields.push(currentPath);
292
- }
293
- // 递归检查嵌套对象
294
- if (typeof obj[key] === 'object' && obj[key] !== null) {
295
- checkObject(obj[key], currentPath);
296
- }
297
- }
298
- };
299
- checkObject(data);
300
- return {
301
- hasSensitiveData: sensitiveFields.length > 0,
302
- fields: sensitiveFields,
303
- };
304
- }
305
- /**
306
- * 获取默认SSRF防护配置
307
- */
308
- static getDefaultSSRFConfig() {
309
- return Object.assign({}, this.defaultSSRFConfig);
310
- }
311
- /**
312
- * 获取默认URL验证配置
313
- */
314
- static getDefaultURLConfig() {
315
- return Object.assign({}, this.defaultURLConfig);
316
- }
317
319
  }
318
320
  exports.SecurityValidator = SecurityValidator;
319
321
  SecurityValidator.logger = new common_1.Logger(SecurityValidator.name);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-omni/core",
3
- "version": "4.1.3-25",
3
+ "version": "4.1.3-26",
4
4
  "description": "A comprehensive NestJS framework for building enterprise-grade applications with best practices",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -172,7 +172,7 @@ let VaultConfigService = VaultConfigService_1 = class VaultConfigService {
172
172
  }
173
173
  try {
174
174
  const health = yield this.vaultClient.health();
175
- return health && !health.sealed;
175
+ return !!(health && !health.sealed);
176
176
  }
177
177
  catch (error) {
178
178
  this.logger.error('Vault health check failed', error.message);