@noony-serverless/core 0.1.0 → 0.1.5

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 (56) hide show
  1. package/build/middlewares/authenticationMiddleware.d.ts +379 -0
  2. package/build/middlewares/authenticationMiddleware.js +216 -0
  3. package/build/middlewares/bodyParserMiddleware.d.ts +99 -0
  4. package/build/middlewares/bodyParserMiddleware.js +99 -0
  5. package/build/middlewares/bodyValidationMiddleware.d.ts +68 -4
  6. package/build/middlewares/bodyValidationMiddleware.js +64 -0
  7. package/build/middlewares/dependencyInjectionMiddleware.d.ts +238 -0
  8. package/build/middlewares/dependencyInjectionMiddleware.js +238 -0
  9. package/build/middlewares/errorHandlerMiddleware.d.ts +94 -0
  10. package/build/middlewares/errorHandlerMiddleware.js +105 -0
  11. package/build/middlewares/guards/RouteGuards.d.ts +475 -0
  12. package/build/middlewares/guards/RouteGuards.js +604 -0
  13. package/build/middlewares/guards/cache/CacheAdapter.d.ts +473 -0
  14. package/build/middlewares/guards/cache/CacheAdapter.js +205 -0
  15. package/build/middlewares/guards/cache/ConservativeCacheInvalidation.d.ts +191 -0
  16. package/build/middlewares/guards/cache/ConservativeCacheInvalidation.js +510 -0
  17. package/build/middlewares/guards/cache/MemoryCacheAdapter.d.ts +228 -0
  18. package/build/middlewares/guards/cache/MemoryCacheAdapter.js +403 -0
  19. package/build/middlewares/guards/cache/NoopCacheAdapter.d.ts +95 -0
  20. package/build/middlewares/guards/cache/NoopCacheAdapter.js +131 -0
  21. package/build/middlewares/guards/config/GuardConfiguration.d.ts +612 -0
  22. package/build/middlewares/guards/config/GuardConfiguration.js +334 -0
  23. package/build/middlewares/guards/guards/FastAuthGuard.d.ts +201 -0
  24. package/build/middlewares/guards/guards/FastAuthGuard.js +460 -0
  25. package/build/middlewares/guards/guards/PermissionGuardFactory.d.ts +202 -0
  26. package/build/middlewares/guards/guards/PermissionGuardFactory.js +563 -0
  27. package/build/middlewares/guards/index.d.ts +67 -0
  28. package/build/middlewares/guards/index.js +192 -0
  29. package/build/middlewares/guards/registry/PermissionRegistry.d.ts +188 -0
  30. package/build/middlewares/guards/registry/PermissionRegistry.js +425 -0
  31. package/build/middlewares/guards/resolvers/ExpressionPermissionResolver.d.ts +129 -0
  32. package/build/middlewares/guards/resolvers/ExpressionPermissionResolver.js +451 -0
  33. package/build/middlewares/guards/resolvers/PermissionResolver.d.ts +155 -0
  34. package/build/middlewares/guards/resolvers/PermissionResolver.js +176 -0
  35. package/build/middlewares/guards/resolvers/PlainPermissionResolver.d.ts +101 -0
  36. package/build/middlewares/guards/resolvers/PlainPermissionResolver.js +248 -0
  37. package/build/middlewares/guards/resolvers/WildcardPermissionResolver.d.ts +146 -0
  38. package/build/middlewares/guards/resolvers/WildcardPermissionResolver.js +377 -0
  39. package/build/middlewares/guards/services/FastUserContextService.d.ts +216 -0
  40. package/build/middlewares/guards/services/FastUserContextService.js +435 -0
  41. package/build/middlewares/headerVariablesMiddleware.d.ts +118 -0
  42. package/build/middlewares/headerVariablesMiddleware.js +118 -0
  43. package/build/middlewares/httpAttributesMiddleware.d.ts +235 -0
  44. package/build/middlewares/httpAttributesMiddleware.js +235 -0
  45. package/build/middlewares/index.d.ts +1 -0
  46. package/build/middlewares/index.js +1 -0
  47. package/build/middlewares/queryParametersMiddleware.d.ts +105 -0
  48. package/build/middlewares/queryParametersMiddleware.js +105 -0
  49. package/build/middlewares/rateLimitingMiddleware.d.ts +109 -5
  50. package/build/middlewares/rateLimitingMiddleware.js +109 -5
  51. package/build/middlewares/responseWrapperMiddleware.d.ts +170 -1
  52. package/build/middlewares/responseWrapperMiddleware.js +170 -1
  53. package/build/middlewares/securityAuditMiddleware.js +5 -5
  54. package/build/middlewares/validationMiddleware.d.ts +145 -0
  55. package/build/middlewares/validationMiddleware.js +145 -0
  56. package/package.json +2 -2
@@ -0,0 +1,612 @@
1
+ /**
2
+ * Guard System Configuration
3
+ *
4
+ * Comprehensive configuration system for the high-performance guard system.
5
+ * Provides type-safe configuration for different deployment environments with
6
+ * configurable performance strategies and security policies.
7
+ *
8
+ * Key Features:
9
+ * - Permission resolution strategy configuration (pre-expansion vs on-demand)
10
+ * - Cache adapter injection for different environments
11
+ * - Performance profiles for development, staging, and production
12
+ * - Security policies with conservative cache invalidation
13
+ * - Bounded complexity limits for patterns and expressions
14
+ *
15
+ * @author Noony Framework Team
16
+ * @version 1.0.0
17
+ */
18
+ /**
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
+ * ```
124
+ *
125
+ * PRE_EXPANSION: Expand wildcards at user context load time
126
+ * - Pros: Faster runtime permission checks (O(1) set lookups)
127
+ * - Cons: Higher memory usage, requires permission registry
128
+ *
129
+ * ON_DEMAND: Match wildcards at permission check time
130
+ * - Pros: Lower memory usage, supports dynamic permissions
131
+ * - Cons: Pattern matching overhead per request
132
+ */
133
+ export declare enum PermissionResolutionStrategy {
134
+ PRE_EXPANSION = "pre-expansion",
135
+ ON_DEMAND = "on-demand"
136
+ }
137
+ /**
138
+ * Cache invalidation strategies for security
139
+ */
140
+ export declare enum CacheInvalidationStrategy {
141
+ FLUSH_ALL = "flush-all",
142
+ USER_SPECIFIC = "user-specific"
143
+ }
144
+ /**
145
+ * Performance monitoring levels
146
+ */
147
+ export declare enum MonitoringLevel {
148
+ NONE = "none",
149
+ BASIC = "basic",
150
+ DETAILED = "detailed",
151
+ VERBOSE = "verbose"
152
+ }
153
+ /**
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
178
+ /**
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
+ * ```
203
+ */
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
+ */
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
+ */
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
+ */
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
+ */
244
+ authTokenTtlMs: number;
245
+ }
246
+ /**
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
+ * ```
271
+ */
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
+ */
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
+ */
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
+ */
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
+ */
312
+ metricsCollectionInterval: number;
313
+ }
314
+ /**
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
+ * ```
373
+ */
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
+ */
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
+ */
396
+ cacheType: 'memory' | 'redis' | 'none';
397
+ /**
398
+ * Security configuration for this environment.
399
+ * Contains permission resolution strategies and security limits.
400
+ */
401
+ security: GuardSecurityConfig;
402
+ /**
403
+ * Cache configuration for this environment.
404
+ * Contains cache size limits and TTL settings.
405
+ */
406
+ cache: GuardCacheConfig;
407
+ /**
408
+ * Monitoring configuration for this environment.
409
+ * Contains logging and metrics collection settings.
410
+ */
411
+ monitoring: GuardMonitoringConfig;
412
+ }
413
+ /**
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
+ * ```
454
+ */
455
+ export declare class GuardConfiguration {
456
+ /**
457
+ * Security configuration settings.
458
+ * Contains permission resolution strategies and security limits.
459
+ */
460
+ readonly security: GuardSecurityConfig;
461
+ /**
462
+ * Cache configuration settings.
463
+ * Contains cache size limits and TTL values.
464
+ */
465
+ readonly cache: GuardCacheConfig;
466
+ /**
467
+ * Monitoring configuration settings.
468
+ * Contains logging and metrics collection settings.
469
+ */
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
+ */
501
+ constructor(security: GuardSecurityConfig, cache: GuardCacheConfig, monitoring: GuardMonitoringConfig);
502
+ /**
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
+ * ```
536
+ */
537
+ static fromEnvironmentProfile(profile: GuardEnvironmentProfile): GuardConfiguration;
538
+ /**
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
+ * ```
557
+ */
558
+ static development(): GuardConfiguration;
559
+ /**
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
+ * ```
578
+ */
579
+ static production(): GuardConfiguration;
580
+ /**
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
+ validate(): void;
611
+ }
612
+ //# sourceMappingURL=GuardConfiguration.d.ts.map