@noony-serverless/core 0.1.1 → 0.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 (62) hide show
  1. package/build/core/core.d.ts +16 -48
  2. package/build/core/core.js +2 -61
  3. package/build/core/handler.d.ts +37 -16
  4. package/build/core/handler.js +131 -42
  5. package/build/core/index.d.ts +0 -1
  6. package/build/core/index.js +0 -1
  7. package/build/middlewares/ConsolidatedValidationMiddleware.d.ts +126 -0
  8. package/build/middlewares/ConsolidatedValidationMiddleware.js +330 -0
  9. package/build/middlewares/ProcessingMiddleware.d.ts +138 -0
  10. package/build/middlewares/ProcessingMiddleware.js +425 -0
  11. package/build/middlewares/SecurityMiddleware.d.ts +157 -0
  12. package/build/middlewares/SecurityMiddleware.js +307 -0
  13. package/build/middlewares/authenticationMiddleware.d.ts +379 -0
  14. package/build/middlewares/authenticationMiddleware.js +216 -0
  15. package/build/middlewares/bodyParserMiddleware.d.ts +99 -0
  16. package/build/middlewares/bodyParserMiddleware.js +99 -0
  17. package/build/middlewares/bodyValidationMiddleware.d.ts +69 -3
  18. package/build/middlewares/bodyValidationMiddleware.js +68 -2
  19. package/build/middlewares/dependencyInjectionMiddleware.d.ts +238 -0
  20. package/build/middlewares/dependencyInjectionMiddleware.js +238 -0
  21. package/build/middlewares/errorHandlerMiddleware.d.ts +94 -0
  22. package/build/middlewares/errorHandlerMiddleware.js +105 -0
  23. package/build/middlewares/guards/RouteGuards.d.ts +476 -21
  24. package/build/middlewares/guards/RouteGuards.js +418 -21
  25. package/build/middlewares/guards/adapters/CustomTokenVerificationPortAdapter.d.ts +271 -0
  26. package/build/middlewares/guards/adapters/CustomTokenVerificationPortAdapter.js +301 -0
  27. package/build/middlewares/guards/cache/CacheAdapter.d.ts +369 -28
  28. package/build/middlewares/guards/cache/CacheAdapter.js +124 -5
  29. package/build/middlewares/guards/cache/MemoryCacheAdapter.d.ts +113 -4
  30. package/build/middlewares/guards/cache/MemoryCacheAdapter.js +113 -4
  31. package/build/middlewares/guards/config/GuardConfiguration.d.ts +568 -18
  32. package/build/middlewares/guards/config/GuardConfiguration.js +266 -10
  33. package/build/middlewares/guards/guards/FastAuthGuard.d.ts +5 -5
  34. package/build/middlewares/guards/guards/PermissionGuardFactory.d.ts +5 -13
  35. package/build/middlewares/guards/guards/PermissionGuardFactory.js +4 -4
  36. package/build/middlewares/guards/index.d.ts +43 -1
  37. package/build/middlewares/guards/index.js +46 -1
  38. package/build/middlewares/guards/resolvers/ExpressionPermissionResolver.d.ts +1 -1
  39. package/build/middlewares/guards/resolvers/ExpressionPermissionResolver.js +1 -1
  40. package/build/middlewares/guards/resolvers/PermissionResolver.d.ts +1 -1
  41. package/build/middlewares/guards/resolvers/PlainPermissionResolver.d.ts +1 -1
  42. package/build/middlewares/guards/resolvers/WildcardPermissionResolver.d.ts +1 -1
  43. package/build/middlewares/guards/services/FastUserContextService.d.ts +20 -33
  44. package/build/middlewares/guards/services/FastUserContextService.js +19 -5
  45. package/build/middlewares/headerVariablesMiddleware.d.ts +118 -0
  46. package/build/middlewares/headerVariablesMiddleware.js +118 -0
  47. package/build/middlewares/httpAttributesMiddleware.d.ts +235 -0
  48. package/build/middlewares/httpAttributesMiddleware.js +236 -1
  49. package/build/middlewares/index.d.ts +3 -1
  50. package/build/middlewares/index.js +6 -1
  51. package/build/middlewares/queryParametersMiddleware.d.ts +105 -0
  52. package/build/middlewares/queryParametersMiddleware.js +105 -0
  53. package/build/middlewares/rateLimitingMiddleware.d.ts +601 -9
  54. package/build/middlewares/rateLimitingMiddleware.js +623 -11
  55. package/build/middlewares/responseWrapperMiddleware.d.ts +170 -1
  56. package/build/middlewares/responseWrapperMiddleware.js +170 -1
  57. package/build/middlewares/securityAuditMiddleware.js +5 -5
  58. package/package.json +11 -9
  59. package/build/core/containerPool.d.ts +0 -44
  60. package/build/core/containerPool.js +0 -103
  61. package/build/middlewares/validationMiddleware.d.ts +0 -9
  62. package/build/middlewares/validationMiddleware.js +0 -40
@@ -16,7 +16,111 @@
16
16
  * @version 1.0.0
17
17
  */
18
18
  /**
19
- * Permission resolution strategies for wildcard permissions
19
+ * Security configuration for the guard system.
20
+ * Controls security policies and performance limits to prevent attacks.
21
+ *
22
+ * @example
23
+ * High-security production configuration:
24
+ * ```typescript
25
+ * const securityConfig: GuardSecurityConfig = {
26
+ * permissionResolutionStrategy: PermissionResolutionStrategy.PRE_EXPANSION,
27
+ * conservativeCacheInvalidation: true, // Clear related caches on any change
28
+ * maxExpressionComplexity: 100, // Limit complex permission expressions
29
+ * maxPatternDepth: 3, // Limit wildcard nesting (admin.users.*)
30
+ * maxNestingDepth: 2 // Limit boolean expression nesting
31
+ * };
32
+ * ```
33
+ *
34
+ * @example
35
+ * Development configuration (more permissive):
36
+ * ```typescript
37
+ * const devSecurityConfig: GuardSecurityConfig = {
38
+ * permissionResolutionStrategy: PermissionResolutionStrategy.ON_DEMAND,
39
+ * conservativeCacheInvalidation: false, // Less aggressive caching for dev
40
+ * maxExpressionComplexity: 50, // Lower limits for faster feedback
41
+ * maxPatternDepth: 3,
42
+ * maxNestingDepth: 2
43
+ * };
44
+ * ```
45
+ */
46
+ export interface GuardSecurityConfig {
47
+ /**
48
+ * Strategy for resolving permissions (default: PRE_EXPANSION).
49
+ * Controls when wildcards and expressions are processed for optimal performance.
50
+ *
51
+ * @example
52
+ * Production setup with pre-expansion for performance:
53
+ * ```typescript
54
+ * permissionResolutionStrategy: PermissionResolutionStrategy.PRE_EXPANSION
55
+ * ```
56
+ */
57
+ permissionResolutionStrategy?: PermissionResolutionStrategy;
58
+ /**
59
+ * Whether to use conservative cache invalidation (default: true).
60
+ * When true, related cache entries are cleared on any permission change.
61
+ * When false, only specific entries are invalidated (better performance).
62
+ *
63
+ * @example
64
+ * High-security setup:
65
+ * ```typescript
66
+ * conservativeCacheInvalidation: true // Clear all related caches on changes
67
+ * ```
68
+ */
69
+ conservativeCacheInvalidation?: boolean;
70
+ /**
71
+ * Maximum complexity for permission expressions (default: 100).
72
+ * Prevents DoS attacks through complex boolean expressions.
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * maxExpressionComplexity: 50 // Limit to moderate complexity
77
+ * ```
78
+ */
79
+ maxExpressionComplexity?: number;
80
+ /**
81
+ * Maximum depth for wildcard patterns (default: 5).
82
+ * Limits patterns like 'admin.users.groups.permissions.*' to prevent deep recursion.
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * maxPatternDepth: 3 // Allow up to 'admin.users.*' depth
87
+ * ```
88
+ */
89
+ maxPatternDepth?: number;
90
+ /**
91
+ * Maximum nesting depth for boolean expressions (default: 3).
92
+ * Prevents deeply nested expressions like '((((A AND B) OR C) AND D) OR E)'.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * maxNestingDepth: 2 // Allow up to '(A AND B) OR (C AND D)' complexity
97
+ * ```
98
+ */
99
+ maxNestingDepth?: number;
100
+ }
101
+ /**
102
+ * Permission resolution strategies for wildcard permissions.
103
+ * Determines how wildcard patterns are processed for optimal performance.
104
+ *
105
+ * @example
106
+ * Pre-expansion strategy (production recommended):
107
+ * ```typescript
108
+ * const productionConfig = {
109
+ * permissionResolutionStrategy: PermissionResolutionStrategy.PRE_EXPANSION,
110
+ * // Expands "admin.*" to ["admin.users", "admin.reports", "admin.settings"]
111
+ * // at user context load time for O(1) runtime checks
112
+ * };
113
+ * ```
114
+ *
115
+ * @example
116
+ * On-demand strategy (memory efficient):
117
+ * ```typescript
118
+ * const memoryEfficientConfig = {
119
+ * permissionResolutionStrategy: PermissionResolutionStrategy.ON_DEMAND,
120
+ * // Matches "admin.*" pattern against user permissions at runtime
121
+ * // Lower memory usage but requires pattern matching overhead
122
+ * };
123
+ * ```
20
124
  *
21
125
  * PRE_EXPANSION: Expand wildcards at user context load time
22
126
  * - Pros: Faster runtime permission checks (O(1) set lookups)
@@ -47,66 +151,512 @@ export declare enum MonitoringLevel {
47
151
  VERBOSE = "verbose"
48
152
  }
49
153
  /**
50
- * Security configuration for the guard system
51
- */
52
- export interface GuardSecurityConfig {
53
- permissionResolutionStrategy: PermissionResolutionStrategy;
54
- conservativeCacheInvalidation: boolean;
55
- maxExpressionComplexity: number;
56
- maxPatternDepth: number;
57
- maxNestingDepth: number;
58
- }
154
+ * Security configuration for the guard system.
155
+ * Controls security policies and performance limits to prevent attacks.
156
+ *
157
+ * @example
158
+ * High-security production configuration:
159
+ * ```typescript
160
+ * const securityConfig: GuardSecurityConfig = {
161
+ * permissionResolutionStrategy: PermissionResolutionStrategy.PRE_EXPANSION,
162
+ * conservativeCacheInvalidation: true, // Clear related caches on any change
163
+ * maxExpressionComplexity: 100, // Limit complex permission expressions
164
+ * maxPatternDepth: 3, // Limit wildcard nesting (admin.users.*)
165
+ * maxNestingDepth: 2 // Limit boolean expression nesting
166
+ * };
167
+ * ```
168
+ *
169
+ * @example
170
+ * Development configuration (more permissive):
171
+ * ```typescript
172
+ * const devSecurityConfig: GuardSecurityConfig = {
173
+ * permissionResolutionStrategy: PermissionResolutionStrategy.ON_DEMAND,
174
+ * conservativeCacheInvalidation: false, // Less aggressive caching for dev
175
+ * maxExpressionComplexity: 50, // Lower limits for faster feedback
176
+ * maxPatternDepth: 3,
177
+ * maxNestingDepth: 2
59
178
  /**
60
- * Cache configuration for the guard system
179
+ * Cache configuration for the guard system.
180
+ * Controls caching behavior for optimal performance with configurable TTL values.
181
+ *
182
+ * @example
183
+ * Production cache configuration:
184
+ * ```typescript
185
+ * const cacheConfig: GuardCacheConfig = {
186
+ * maxEntries: 10000, // Support up to 10k cached entries
187
+ * defaultTtlMs: 300000, // 5 minutes default TTL
188
+ * userContextTtlMs: 600000, // 10 minutes for user context
189
+ * authTokenTtlMs: 900000 // 15 minutes for auth tokens
190
+ * };
191
+ * ```
192
+ *
193
+ * @example
194
+ * Development cache configuration (faster refresh):
195
+ * ```typescript
196
+ * const devCacheConfig: GuardCacheConfig = {
197
+ * maxEntries: 1000, // Smaller cache for development
198
+ * defaultTtlMs: 60000, // 1 minute default TTL
199
+ * userContextTtlMs: 120000, // 2 minutes for user context
200
+ * authTokenTtlMs: 180000 // 3 minutes for auth tokens
201
+ * };
202
+ * ```
61
203
  */
62
204
  export interface GuardCacheConfig {
205
+ /**
206
+ * Maximum number of entries to cache (default: 5000).
207
+ * When limit is reached, LRU eviction is used.
208
+ *
209
+ * @example
210
+ * ```typescript
211
+ * maxEntries: 10000 // High-traffic production environment
212
+ * ```
213
+ */
63
214
  maxEntries: number;
215
+ /**
216
+ * Default TTL in milliseconds for cached entries (default: 300000 = 5 minutes).
217
+ * Applied to general permission checks and guard evaluations.
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * defaultTtlMs: 600000 // 10 minutes for stable permissions
222
+ * ```
223
+ */
64
224
  defaultTtlMs: number;
225
+ /**
226
+ * TTL in milliseconds for user context cache (default: 600000 = 10 minutes).
227
+ * User context includes roles, permissions, and session data.
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * userContextTtlMs: 900000 // 15 minutes for user sessions
232
+ * ```
233
+ */
65
234
  userContextTtlMs: number;
235
+ /**
236
+ * TTL in milliseconds for authentication token cache (default: 900000 = 15 minutes).
237
+ * Controls how long validated tokens are cached before re-verification.
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * authTokenTtlMs: 1800000 // 30 minutes for production tokens
242
+ * ```
243
+ */
66
244
  authTokenTtlMs: number;
67
245
  }
68
246
  /**
69
- * Monitoring configuration for the guard system
247
+ * Monitoring configuration for the guard system.
248
+ * Controls performance tracking, logging, and metrics collection.
249
+ *
250
+ * @example
251
+ * Production monitoring configuration:
252
+ * ```typescript
253
+ * const monitoringConfig: GuardMonitoringConfig = {
254
+ * enablePerformanceTracking: true, // Track guard performance metrics
255
+ * enableDetailedLogging: false, // Minimize log overhead in production
256
+ * logLevel: 'error', // Only log errors and warnings
257
+ * metricsCollectionInterval: 60000 // Collect metrics every minute
258
+ * };
259
+ * ```
260
+ *
261
+ * @example
262
+ * Development monitoring configuration:
263
+ * ```typescript
264
+ * const devMonitoringConfig: GuardMonitoringConfig = {
265
+ * enablePerformanceTracking: true, // Track performance for optimization
266
+ * enableDetailedLogging: true, // Detailed logs for debugging
267
+ * logLevel: 'debug', // All log levels for development
268
+ * metricsCollectionInterval: 10000 // More frequent metrics collection
269
+ * };
270
+ * ```
70
271
  */
71
272
  export interface GuardMonitoringConfig {
273
+ /**
274
+ * Enable performance tracking for guard operations (default: true).
275
+ * Tracks timing data for permission resolution, cache hits/misses, etc.
276
+ *
277
+ * @example
278
+ * ```typescript
279
+ * enablePerformanceTracking: true // Monitor guard performance
280
+ * ```
281
+ */
72
282
  enablePerformanceTracking: boolean;
283
+ /**
284
+ * Enable detailed logging for debugging (default: false in production).
285
+ * Logs detailed information about guard evaluations and cache operations.
286
+ *
287
+ * @example
288
+ * ```typescript
289
+ * enableDetailedLogging: true // Detailed logs for troubleshooting
290
+ * ```
291
+ */
73
292
  enableDetailedLogging: boolean;
293
+ /**
294
+ * Log level for guard system messages (default: 'info').
295
+ * Controls verbosity of guard system logging.
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * logLevel: 'error' // Only log errors in production
300
+ * ```
301
+ */
74
302
  logLevel: string;
303
+ /**
304
+ * Interval in milliseconds for metrics collection (default: 60000 = 1 minute).
305
+ * Controls how often performance metrics are aggregated and reported.
306
+ *
307
+ * @example
308
+ * ```typescript
309
+ * metricsCollectionInterval: 30000 // Collect metrics every 30 seconds
310
+ * ```
311
+ */
75
312
  metricsCollectionInterval: number;
76
313
  }
77
314
  /**
78
- * Environment profile for guard system configuration
315
+ * Environment profile for guard system configuration.
316
+ * Provides pre-configured profiles for different deployment environments.
317
+ *
318
+ * @example
319
+ * Production environment profile:
320
+ * ```typescript
321
+ * const productionProfile: GuardEnvironmentProfile = {
322
+ * environment: 'production',
323
+ * cacheType: 'redis', // Redis for distributed caching
324
+ * security: {
325
+ * permissionResolutionStrategy: PermissionResolutionStrategy.PRE_EXPANSION,
326
+ * conservativeCacheInvalidation: true,
327
+ * maxExpressionComplexity: 100,
328
+ * maxPatternDepth: 5,
329
+ * maxNestingDepth: 3
330
+ * },
331
+ * cache: {
332
+ * maxEntries: 50000,
333
+ * defaultTtlMs: 600000, // 10 minutes
334
+ * userContextTtlMs: 1800000, // 30 minutes
335
+ * authTokenTtlMs: 3600000 // 1 hour
336
+ * },
337
+ * monitoring: {
338
+ * enablePerformanceTracking: true,
339
+ * enableDetailedLogging: false,
340
+ * logLevel: 'error',
341
+ * metricsCollectionInterval: 60000
342
+ * }
343
+ * };
344
+ * ```
345
+ *
346
+ * @example
347
+ * Development environment profile:
348
+ * ```typescript
349
+ * const developmentProfile: GuardEnvironmentProfile = {
350
+ * environment: 'development',
351
+ * cacheType: 'memory', // In-memory cache for dev
352
+ * security: {
353
+ * permissionResolutionStrategy: PermissionResolutionStrategy.ON_DEMAND,
354
+ * conservativeCacheInvalidation: false,
355
+ * maxExpressionComplexity: 50,
356
+ * maxPatternDepth: 3,
357
+ * maxNestingDepth: 2
358
+ * },
359
+ * cache: {
360
+ * maxEntries: 1000,
361
+ * defaultTtlMs: 60000, // 1 minute
362
+ * userContextTtlMs: 120000, // 2 minutes
363
+ * authTokenTtlMs: 300000 // 5 minutes
364
+ * },
365
+ * monitoring: {
366
+ * enablePerformanceTracking: true,
367
+ * enableDetailedLogging: true,
368
+ * logLevel: 'debug',
369
+ * metricsCollectionInterval: 10000
370
+ * }
371
+ * };
372
+ * ```
79
373
  */
80
374
  export interface GuardEnvironmentProfile {
375
+ /**
376
+ * Environment name identifier (e.g., 'development', 'staging', 'production').
377
+ * Used for environment-specific logging and configuration selection.
378
+ *
379
+ * @example
380
+ * ```typescript
381
+ * environment: 'production' // Identifies production environment
382
+ * ```
383
+ */
81
384
  environment: string;
385
+ /**
386
+ * Cache implementation type to use.
387
+ * - 'memory': In-memory cache (single instance)
388
+ * - 'redis': Redis distributed cache (multi-instance)
389
+ * - 'none': No caching (testing/debug)
390
+ *
391
+ * @example
392
+ * ```typescript
393
+ * cacheType: 'redis' // Use Redis for production distributed cache
394
+ * ```
395
+ */
82
396
  cacheType: 'memory' | 'redis' | 'none';
397
+ /**
398
+ * Security configuration for this environment.
399
+ * Contains permission resolution strategies and security limits.
400
+ */
83
401
  security: GuardSecurityConfig;
402
+ /**
403
+ * Cache configuration for this environment.
404
+ * Contains cache size limits and TTL settings.
405
+ */
84
406
  cache: GuardCacheConfig;
407
+ /**
408
+ * Monitoring configuration for this environment.
409
+ * Contains logging and metrics collection settings.
410
+ */
85
411
  monitoring: GuardMonitoringConfig;
86
412
  }
87
413
  /**
88
- * GuardConfiguration class implementation
414
+ * GuardConfiguration class implementation.
415
+ * Immutable configuration object for the Noony guard system with factory methods
416
+ * for creating configurations from environment profiles or predefined templates.
417
+ *
418
+ * @example
419
+ * Create from environment profile:
420
+ * ```typescript
421
+ * import { GuardConfiguration } from '@noony/core';
422
+ *
423
+ * const config = GuardConfiguration.fromEnvironmentProfile({
424
+ * environment: 'production',
425
+ * cacheType: 'redis',
426
+ * security: { ... },
427
+ * cache: { ... },
428
+ * monitoring: { ... }
429
+ * });
430
+ * ```
431
+ *
432
+ * @example
433
+ * Use predefined configurations:
434
+ * ```typescript
435
+ * // Development configuration
436
+ * const devConfig = GuardConfiguration.development();
437
+ *
438
+ * // Production configuration
439
+ * const prodConfig = GuardConfiguration.production();
440
+ *
441
+ * // Testing configuration
442
+ * const testConfig = GuardConfiguration.testing();
443
+ * ```
444
+ *
445
+ * @example
446
+ * Manual configuration:
447
+ * ```typescript
448
+ * const customConfig = new GuardConfiguration(
449
+ * { permissionResolutionStrategy: PermissionResolutionStrategy.PRE_EXPANSION },
450
+ * { maxEntries: 10000, defaultTtlMs: 300000 },
451
+ * { enablePerformanceTracking: true, logLevel: 'info' }
452
+ * );
453
+ * ```
89
454
  */
90
455
  export declare class GuardConfiguration {
456
+ /**
457
+ * Security configuration settings.
458
+ * Contains permission resolution strategies and security limits.
459
+ */
91
460
  readonly security: GuardSecurityConfig;
461
+ /**
462
+ * Cache configuration settings.
463
+ * Contains cache size limits and TTL values.
464
+ */
92
465
  readonly cache: GuardCacheConfig;
466
+ /**
467
+ * Monitoring configuration settings.
468
+ * Contains logging and metrics collection settings.
469
+ */
93
470
  readonly monitoring: GuardMonitoringConfig;
471
+ /**
472
+ * Creates a new GuardConfiguration instance.
473
+ *
474
+ * @param security - Security configuration settings
475
+ * @param cache - Cache configuration settings
476
+ * @param monitoring - Monitoring configuration settings
477
+ *
478
+ * @example
479
+ * ```typescript
480
+ * const config = new GuardConfiguration(
481
+ * {
482
+ * permissionResolutionStrategy: PermissionResolutionStrategy.PRE_EXPANSION,
483
+ * conservativeCacheInvalidation: true,
484
+ * maxExpressionComplexity: 100
485
+ * },
486
+ * {
487
+ * maxEntries: 10000,
488
+ * defaultTtlMs: 300000,
489
+ * userContextTtlMs: 600000,
490
+ * authTokenTtlMs: 900000
491
+ * },
492
+ * {
493
+ * enablePerformanceTracking: true,
494
+ * enableDetailedLogging: false,
495
+ * logLevel: 'info',
496
+ * metricsCollectionInterval: 60000
497
+ * }
498
+ * );
499
+ * ```
500
+ */
94
501
  constructor(security: GuardSecurityConfig, cache: GuardCacheConfig, monitoring: GuardMonitoringConfig);
95
502
  /**
96
- * Create GuardConfiguration from environment profile
503
+ * Create GuardConfiguration from environment profile.
504
+ * Factory method that constructs a configuration from a complete environment profile.
505
+ *
506
+ * @param profile - Complete environment profile with all configuration sections
507
+ * @returns New GuardConfiguration instance
508
+ *
509
+ * @example
510
+ * Create from production profile:
511
+ * ```typescript
512
+ * const productionProfile: GuardEnvironmentProfile = {
513
+ * environment: 'production',
514
+ * cacheType: 'redis',
515
+ * security: {
516
+ * permissionResolutionStrategy: PermissionResolutionStrategy.PRE_EXPANSION,
517
+ * conservativeCacheInvalidation: true,
518
+ * maxExpressionComplexity: 100
519
+ * },
520
+ * cache: {
521
+ * maxEntries: 50000,
522
+ * defaultTtlMs: 600000,
523
+ * userContextTtlMs: 1800000,
524
+ * authTokenTtlMs: 3600000
525
+ * },
526
+ * monitoring: {
527
+ * enablePerformanceTracking: true,
528
+ * enableDetailedLogging: false,
529
+ * logLevel: 'error',
530
+ * metricsCollectionInterval: 60000
531
+ * }
532
+ * };
533
+ *
534
+ * const config = GuardConfiguration.fromEnvironmentProfile(productionProfile);
535
+ * ```
97
536
  */
98
537
  static fromEnvironmentProfile(profile: GuardEnvironmentProfile): GuardConfiguration;
99
538
  /**
100
- * Create default development configuration
539
+ * Create default development configuration.
540
+ * Pre-configured settings optimized for development environments with fast refresh
541
+ * and detailed logging for debugging.
542
+ *
543
+ * @returns GuardConfiguration optimized for development
544
+ *
545
+ * @example
546
+ * ```typescript
547
+ * const devConfig = GuardConfiguration.development();
548
+ *
549
+ * // Configuration includes:
550
+ * // - On-demand permission resolution (lower memory, dynamic)
551
+ * // - Conservative cache invalidation disabled (faster refresh)
552
+ * // - Lower complexity limits for faster feedback
553
+ * // - Shorter TTL values for rapid development cycles
554
+ * // - Detailed logging and debug level
555
+ * // - Frequent metrics collection (30 seconds)
556
+ * ```
101
557
  */
102
558
  static development(): GuardConfiguration;
103
559
  /**
104
- * Create default production configuration
560
+ * Create default production configuration.
561
+ * Pre-configured settings optimized for production environments with high performance,
562
+ * security, and stability.
563
+ *
564
+ * @returns GuardConfiguration optimized for production
565
+ *
566
+ * @example
567
+ * ```typescript
568
+ * const prodConfig = GuardConfiguration.production();
569
+ *
570
+ * // Configuration includes:
571
+ * // - Pre-expansion permission resolution (high performance)
572
+ * // - Conservative cache invalidation enabled (high security)
573
+ * // - Higher complexity limits for production workloads
574
+ * // - Longer TTL values for better performance
575
+ * // - Performance tracking enabled, detailed logging disabled
576
+ * // - Standard metrics collection (1 minute intervals)
577
+ * ```
105
578
  */
106
579
  static production(): GuardConfiguration;
107
580
  /**
108
- * Validate configuration
581
+ * Validate configuration settings.
582
+ * Ensures all configuration values are within acceptable bounds and constraints
583
+ * to prevent security vulnerabilities and performance issues.
584
+ *
585
+ * @throws Error if any configuration value is invalid
586
+ *
587
+ * @example
588
+ * ```typescript
589
+ * const config = new GuardConfiguration(securityConfig, cacheConfig, monitoringConfig);
590
+ *
591
+ * try {
592
+ * config.validate();
593
+ * console.log('Configuration is valid');
594
+ * } catch (error) {
595
+ * console.error('Invalid configuration:', error.message);
596
+ * // Handle configuration error
597
+ * }
598
+ * ```
599
+ *
600
+ * @example
601
+ * Validation constraints:
602
+ * ```typescript
603
+ * // These will throw validation errors:
604
+ * // maxPatternDepth must be 2 or 3 (prevents deep recursion)
605
+ * // maxNestingDepth must be 2 (prevents complex expressions)
606
+ * // maxExpressionComplexity must be positive
607
+ * // defaultTtlMs must be at least 1000ms (1 second)
608
+ * ```
609
+ */
610
+ /**
611
+ * Check if caching is enabled via environment variable.
612
+ *
613
+ * Caching is disabled by default for security-first approach.
614
+ * Only enabled when NOONY_GUARD_CACHE_ENABLE is explicitly set to 'true'.
615
+ *
616
+ * @returns true if caching should be enabled, false otherwise
617
+ *
618
+ * @example
619
+ * ```typescript
620
+ * // Caching disabled (default)
621
+ * process.env.NOONY_GUARD_CACHE_ENABLE = undefined;
622
+ * console.log(GuardConfiguration.isCachingEnabled()); // false
623
+ *
624
+ * // Caching enabled
625
+ * process.env.NOONY_GUARD_CACHE_ENABLE = 'true';
626
+ * console.log(GuardConfiguration.isCachingEnabled()); // true
627
+ *
628
+ * // Caching disabled (any other value)
629
+ * process.env.NOONY_GUARD_CACHE_ENABLE = 'false';
630
+ * console.log(GuardConfiguration.isCachingEnabled()); // false
631
+ * ```
632
+ */
633
+ static isCachingEnabled(): boolean;
634
+ /**
635
+ * Get effective cache type considering environment variable override.
636
+ *
637
+ * Environment variable takes precedence for security:
638
+ * - If NOONY_GUARD_CACHE_ENABLE is not 'true', returns 'none'
639
+ * - Otherwise returns the specified cacheType
640
+ *
641
+ * @param cacheType - Configured cache type
642
+ * @returns Effective cache type after environment variable consideration
643
+ *
644
+ * @example
645
+ * ```typescript
646
+ * // Environment variable not set - caching disabled
647
+ * process.env.NOONY_GUARD_CACHE_ENABLE = undefined;
648
+ * console.log(GuardConfiguration.getEffectiveCacheType('memory')); // 'none'
649
+ * console.log(GuardConfiguration.getEffectiveCacheType('redis')); // 'none'
650
+ * console.log(GuardConfiguration.getEffectiveCacheType('none')); // 'none'
651
+ *
652
+ * // Environment variable enabled - respect cacheType
653
+ * process.env.NOONY_GUARD_CACHE_ENABLE = 'true';
654
+ * console.log(GuardConfiguration.getEffectiveCacheType('memory')); // 'memory'
655
+ * console.log(GuardConfiguration.getEffectiveCacheType('redis')); // 'redis'
656
+ * console.log(GuardConfiguration.getEffectiveCacheType('none')); // 'none'
657
+ * ```
109
658
  */
659
+ static getEffectiveCacheType(cacheType: 'memory' | 'redis' | 'none'): 'memory' | 'redis' | 'none';
110
660
  validate(): void;
111
661
  }
112
662
  //# sourceMappingURL=GuardConfiguration.d.ts.map