xypriss 2.0.0 → 2.1.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.
- package/README.md +170 -380
- package/dist/cjs/mods/security/src/algorithms/hash-algorithms.js +10 -0
- package/dist/cjs/mods/security/src/algorithms/hash-algorithms.js.map +1 -1
- package/dist/cjs/mods/security/src/components/cache/cacheSys.utils.js +10 -0
- package/dist/cjs/mods/security/src/components/cache/cacheSys.utils.js.map +1 -1
- package/dist/cjs/mods/security/src/components/cache/index.js +10 -2
- package/dist/cjs/mods/security/src/components/cache/index.js.map +1 -1
- package/dist/cjs/mods/security/src/components/fortified-function/index.js +9 -0
- package/dist/cjs/mods/security/src/components/fortified-function/index.js.map +1 -1
- package/dist/cjs/mods/security/src/components/fortified-function/security/security-handler.js +10 -0
- package/dist/cjs/mods/security/src/components/fortified-function/security/security-handler.js.map +1 -1
- package/dist/cjs/mods/security/src/core/crypto.js +14 -0
- package/dist/cjs/mods/security/src/core/crypto.js.map +1 -1
- package/dist/cjs/mods/security/src/index.js +10 -1
- package/dist/cjs/mods/security/src/index.js.map +1 -1
- package/dist/cjs/shared/logger/Logger.js +372 -29
- package/dist/cjs/shared/logger/Logger.js.map +1 -1
- package/dist/cjs/src/cluster/bun-cluster-manager.js +91 -1
- package/dist/cjs/src/cluster/bun-cluster-manager.js.map +1 -1
- package/dist/cjs/src/cluster/cluster-manager.js +15 -3
- package/dist/cjs/src/cluster/cluster-manager.js.map +1 -1
- package/dist/cjs/src/cluster/modules/AutoScaler.js +4 -4
- package/dist/cjs/src/cluster/modules/AutoScaler.js.map +1 -1
- package/dist/cjs/src/cluster/modules/CrossPlatformMemory.js +2 -2
- package/dist/cjs/src/cluster/modules/CrossPlatformMemory.js.map +1 -1
- package/dist/cjs/src/cluster/modules/EventLoopMonitor.js +270 -0
- package/dist/cjs/src/cluster/modules/EventLoopMonitor.js.map +1 -0
- package/dist/cjs/src/cluster/modules/GCStatsTracker.js +200 -0
- package/dist/cjs/src/cluster/modules/GCStatsTracker.js.map +1 -0
- package/dist/cjs/src/cluster/modules/HeapStatsCollector.js +111 -0
- package/dist/cjs/src/cluster/modules/HeapStatsCollector.js.map +1 -0
- package/dist/cjs/src/cluster/modules/NetworkTracker.js +162 -0
- package/dist/cjs/src/cluster/modules/NetworkTracker.js.map +1 -0
- package/dist/cjs/src/cluster/modules/ThroughputCalculator.js +186 -0
- package/dist/cjs/src/cluster/modules/ThroughputCalculator.js.map +1 -0
- package/dist/cjs/src/cluster/modules/WorkerManager.js +14 -15
- package/dist/cjs/src/cluster/modules/WorkerManager.js.map +1 -1
- package/dist/cjs/src/cluster/modules/{LoadBalancer.js → strategy/LoadBalancer.js} +1 -1
- package/dist/cjs/src/cluster/modules/strategy/LoadBalancer.js.map +1 -0
- package/dist/cjs/src/middleware/built-in/sqlInjection.js +335 -0
- package/dist/cjs/src/middleware/built-in/sqlInjection.js.map +1 -0
- package/dist/cjs/src/middleware/safe-json-middleware.js +1 -1
- package/dist/cjs/src/middleware/safe-json-middleware.js.map +1 -1
- package/dist/cjs/src/middleware/security-middleware.js +447 -332
- package/dist/cjs/src/middleware/security-middleware.js.map +1 -1
- package/dist/cjs/src/plugins/modules/index.js +9 -3
- package/dist/cjs/src/plugins/modules/index.js.map +1 -1
- package/dist/cjs/src/server/FastServer.js +41 -1
- package/dist/cjs/src/server/FastServer.js.map +1 -1
- package/dist/cjs/src/server/ServerFactory.js +62 -2
- package/dist/cjs/src/server/ServerFactory.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/ClusterManagerComponent.js +32 -6
- package/dist/cjs/src/server/components/fastapi/ClusterManagerComponent.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/WorkerPoolComponent.js +206 -0
- package/dist/cjs/src/server/components/fastapi/WorkerPoolComponent.js.map +1 -0
- package/dist/cjs/src/server/components/fastapi/console/ConsoleInterceptor.js +3 -28
- package/dist/cjs/src/server/components/fastapi/console/ConsoleInterceptor.js.map +1 -1
- package/dist/cjs/src/server/components/fastapi/modules/UFRP/WorkerPoolManager.js +265 -0
- package/dist/cjs/src/server/components/fastapi/modules/UFRP/WorkerPoolManager.js.map +1 -0
- package/dist/cjs/src/server/components/fastapi/modules/UFRP/workers/Logger.js +236 -0
- package/dist/cjs/src/server/components/fastapi/modules/UFRP/workers/cpu-tasks.js +294 -0
- package/dist/cjs/src/server/components/fastapi/modules/UFRP/workers/enhanced-cpu-worker.js +433 -0
- package/dist/cjs/src/server/components/fastapi/modules/UFRP/workers/io-worker.js +1615 -0
- package/dist/cjs/src/server/components/lifecycle/ServerLifecycleManager.js +143 -24
- package/dist/cjs/src/server/components/lifecycle/ServerLifecycleManager.js.map +1 -1
- package/dist/cjs/src/server/const/default.js +23 -9
- package/dist/cjs/src/server/const/default.js.map +1 -1
- package/dist/cjs/src/server/core/HttpServer.js +8 -8
- package/dist/cjs/src/server/core/HttpServer.js.map +1 -1
- package/dist/cjs/src/server/core/XyprissApp.js +284 -17
- package/dist/cjs/src/server/core/XyprissApp.js.map +1 -1
- package/dist/cjs/src/server/handlers/NotFoundHandler.js +1 -1
- package/dist/cjs/src/server/handlers/NotFoundHandler.js.map +1 -1
- package/dist/cjs/src/server/middleware/MiddlewareManager.js +57 -12
- package/dist/cjs/src/server/middleware/MiddlewareManager.js.map +1 -1
- package/dist/cjs/src/server/utils/forceClosePort.js +1 -1
- package/dist/cjs/src/server/utils/forceClosePort.js.map +1 -1
- package/dist/esm/mods/security/src/algorithms/hash-algorithms.js +10 -0
- package/dist/esm/mods/security/src/algorithms/hash-algorithms.js.map +1 -1
- package/dist/esm/mods/security/src/components/cache/cacheSys.utils.js +10 -0
- package/dist/esm/mods/security/src/components/cache/cacheSys.utils.js.map +1 -1
- package/dist/esm/mods/security/src/components/cache/index.js +10 -2
- package/dist/esm/mods/security/src/components/cache/index.js.map +1 -1
- package/dist/esm/mods/security/src/components/fortified-function/index.js +9 -0
- package/dist/esm/mods/security/src/components/fortified-function/index.js.map +1 -1
- package/dist/esm/mods/security/src/components/fortified-function/security/security-handler.js +10 -0
- package/dist/esm/mods/security/src/components/fortified-function/security/security-handler.js.map +1 -1
- package/dist/esm/mods/security/src/core/crypto.js +14 -0
- package/dist/esm/mods/security/src/core/crypto.js.map +1 -1
- package/dist/esm/mods/security/src/index.js +10 -1
- package/dist/esm/mods/security/src/index.js.map +1 -1
- package/dist/esm/shared/logger/Logger.js +372 -29
- package/dist/esm/shared/logger/Logger.js.map +1 -1
- package/dist/esm/src/cluster/bun-cluster-manager.js +91 -1
- package/dist/esm/src/cluster/bun-cluster-manager.js.map +1 -1
- package/dist/esm/src/cluster/cluster-manager.js +15 -3
- package/dist/esm/src/cluster/cluster-manager.js.map +1 -1
- package/dist/esm/src/cluster/modules/AutoScaler.js +4 -4
- package/dist/esm/src/cluster/modules/AutoScaler.js.map +1 -1
- package/dist/esm/src/cluster/modules/CrossPlatformMemory.js +2 -2
- package/dist/esm/src/cluster/modules/CrossPlatformMemory.js.map +1 -1
- package/dist/esm/src/cluster/modules/EventLoopMonitor.js +268 -0
- package/dist/esm/src/cluster/modules/EventLoopMonitor.js.map +1 -0
- package/dist/esm/src/cluster/modules/GCStatsTracker.js +198 -0
- package/dist/esm/src/cluster/modules/GCStatsTracker.js.map +1 -0
- package/dist/esm/src/cluster/modules/HeapStatsCollector.js +109 -0
- package/dist/esm/src/cluster/modules/HeapStatsCollector.js.map +1 -0
- package/dist/esm/src/cluster/modules/NetworkTracker.js +160 -0
- package/dist/esm/src/cluster/modules/NetworkTracker.js.map +1 -0
- package/dist/esm/src/cluster/modules/ThroughputCalculator.js +184 -0
- package/dist/esm/src/cluster/modules/ThroughputCalculator.js.map +1 -0
- package/dist/esm/src/cluster/modules/WorkerManager.js +14 -14
- package/dist/esm/src/cluster/modules/WorkerManager.js.map +1 -1
- package/dist/esm/src/cluster/modules/{LoadBalancer.js → strategy/LoadBalancer.js} +1 -1
- package/dist/esm/src/cluster/modules/strategy/LoadBalancer.js.map +1 -0
- package/dist/esm/src/middleware/built-in/sqlInjection.js +333 -0
- package/dist/esm/src/middleware/built-in/sqlInjection.js.map +1 -0
- package/dist/esm/src/middleware/safe-json-middleware.js +1 -1
- package/dist/esm/src/middleware/safe-json-middleware.js.map +1 -1
- package/dist/esm/src/middleware/security-middleware.js +447 -332
- package/dist/esm/src/middleware/security-middleware.js.map +1 -1
- package/dist/esm/src/plugins/modules/index.js +9 -3
- package/dist/esm/src/plugins/modules/index.js.map +1 -1
- package/dist/esm/src/server/FastServer.js +41 -1
- package/dist/esm/src/server/FastServer.js.map +1 -1
- package/dist/esm/src/server/ServerFactory.js +62 -2
- package/dist/esm/src/server/ServerFactory.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/ClusterManagerComponent.js +32 -6
- package/dist/esm/src/server/components/fastapi/ClusterManagerComponent.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/WorkerPoolComponent.js +204 -0
- package/dist/esm/src/server/components/fastapi/WorkerPoolComponent.js.map +1 -0
- package/dist/esm/src/server/components/fastapi/console/ConsoleInterceptor.js +2 -27
- package/dist/esm/src/server/components/fastapi/console/ConsoleInterceptor.js.map +1 -1
- package/dist/esm/src/server/components/fastapi/modules/UFRP/WorkerPoolManager.js +263 -0
- package/dist/esm/src/server/components/fastapi/modules/UFRP/WorkerPoolManager.js.map +1 -0
- package/dist/esm/src/server/components/fastapi/modules/UFRP/workers/Logger.js +236 -0
- package/dist/esm/src/server/components/fastapi/modules/UFRP/workers/cpu-tasks.js +294 -0
- package/dist/esm/src/server/components/fastapi/modules/UFRP/workers/enhanced-cpu-worker.js +433 -0
- package/dist/esm/src/server/components/fastapi/modules/UFRP/workers/io-worker.js +1615 -0
- package/dist/esm/src/server/components/lifecycle/ServerLifecycleManager.js +143 -24
- package/dist/esm/src/server/components/lifecycle/ServerLifecycleManager.js.map +1 -1
- package/dist/esm/src/server/const/default.js +23 -9
- package/dist/esm/src/server/const/default.js.map +1 -1
- package/dist/esm/src/server/core/HttpServer.js +8 -8
- package/dist/esm/src/server/core/HttpServer.js.map +1 -1
- package/dist/esm/src/server/core/XyprissApp.js +284 -17
- package/dist/esm/src/server/core/XyprissApp.js.map +1 -1
- package/dist/esm/src/server/handlers/NotFoundHandler.js +1 -1
- package/dist/esm/src/server/handlers/NotFoundHandler.js.map +1 -1
- package/dist/esm/src/server/middleware/MiddlewareManager.js +57 -12
- package/dist/esm/src/server/middleware/MiddlewareManager.js.map +1 -1
- package/dist/esm/src/server/utils/forceClosePort.js +1 -1
- package/dist/esm/src/server/utils/forceClosePort.js.map +1 -1
- package/dist/index.d.ts +675 -516
- package/package.json +10 -11
- package/dist/cjs/src/cluster/index.js +0 -361
- package/dist/cjs/src/cluster/index.js.map +0 -1
- package/dist/cjs/src/cluster/modules/ClusterFactory.js +0 -539
- package/dist/cjs/src/cluster/modules/ClusterFactory.js.map +0 -1
- package/dist/cjs/src/cluster/modules/LoadBalancer.js.map +0 -1
- package/dist/cjs/src/server/components/fastapi/UltraFastRequestProcessor.js +0 -668
- package/dist/cjs/src/server/components/fastapi/UltraFastRequestProcessor.js.map +0 -1
- package/dist/cjs/src/server/components/fastapi/middlewares/MiddlewareAPI.js +0 -347
- package/dist/cjs/src/server/components/fastapi/middlewares/MiddlewareAPI.js.map +0 -1
- package/dist/cjs/src/server/components/fastapi/middlewares/MiddlewareMethodsManager.js +0 -204
- package/dist/cjs/src/server/components/fastapi/middlewares/MiddlewareMethodsManager.js.map +0 -1
- package/dist/cjs/src/server/components/fastapi/middlewares/middlewareManager.js +0 -953
- package/dist/cjs/src/server/components/fastapi/middlewares/middlewareManager.js.map +0 -1
- package/dist/cjs/src/server/components/fastapi/modules/UFRP/WorkerPool.js +0 -56
- package/dist/cjs/src/server/components/fastapi/modules/UFRP/WorkerPool.js.map +0 -1
- package/dist/esm/src/cluster/index.js +0 -339
- package/dist/esm/src/cluster/index.js.map +0 -1
- package/dist/esm/src/cluster/modules/ClusterFactory.js +0 -511
- package/dist/esm/src/cluster/modules/ClusterFactory.js.map +0 -1
- package/dist/esm/src/cluster/modules/LoadBalancer.js.map +0 -1
- package/dist/esm/src/server/components/fastapi/UltraFastRequestProcessor.js +0 -647
- package/dist/esm/src/server/components/fastapi/UltraFastRequestProcessor.js.map +0 -1
- package/dist/esm/src/server/components/fastapi/middlewares/MiddlewareAPI.js +0 -345
- package/dist/esm/src/server/components/fastapi/middlewares/MiddlewareAPI.js.map +0 -1
- package/dist/esm/src/server/components/fastapi/middlewares/MiddlewareMethodsManager.js +0 -202
- package/dist/esm/src/server/components/fastapi/middlewares/MiddlewareMethodsManager.js.map +0 -1
- package/dist/esm/src/server/components/fastapi/middlewares/middlewareManager.js +0 -951
- package/dist/esm/src/server/components/fastapi/middlewares/middlewareManager.js.map +0 -1
- package/dist/esm/src/server/components/fastapi/modules/UFRP/WorkerPool.js +0 -54
- package/dist/esm/src/server/components/fastapi/modules/UFRP/WorkerPool.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1215,6 +1215,28 @@ declare const LOG_COMPONENTS: readonly ["middleware", "server", "cache", "cluste
|
|
|
1215
1215
|
type LogComponent = (typeof LOG_COMPONENTS)[number];
|
|
1216
1216
|
declare const LOG_TYPES: readonly ["startup", "warnings", "errors", "performance", "debug", "hotReload", "portSwitching", "lifecycle"];
|
|
1217
1217
|
type LogType = (typeof LOG_TYPES)[number];
|
|
1218
|
+
/**
|
|
1219
|
+
* Component-specific logging configuration
|
|
1220
|
+
*/
|
|
1221
|
+
interface ComponentLogConfig {
|
|
1222
|
+
/** Enable/disable logging for this component */
|
|
1223
|
+
enabled?: boolean;
|
|
1224
|
+
/** Override log level for this component */
|
|
1225
|
+
level?: LogLevel;
|
|
1226
|
+
/** Component-specific type filtering */
|
|
1227
|
+
types?: Partial<Record<LogType, boolean>>;
|
|
1228
|
+
/** Custom formatter for this component */
|
|
1229
|
+
formatter?: (level: LogLevel, message: string, ...args: any[]) => string;
|
|
1230
|
+
/** Rate limiting for this component */
|
|
1231
|
+
rateLimit?: {
|
|
1232
|
+
/** Maximum logs per time window */
|
|
1233
|
+
maxLogs?: number;
|
|
1234
|
+
/** Time window in milliseconds */
|
|
1235
|
+
window?: number;
|
|
1236
|
+
};
|
|
1237
|
+
/** Pattern-based message filtering */
|
|
1238
|
+
suppressPatterns?: (string | RegExp)[];
|
|
1239
|
+
}
|
|
1218
1240
|
|
|
1219
1241
|
/**
|
|
1220
1242
|
* Type definitions for Console Interception System
|
|
@@ -1294,175 +1316,430 @@ interface ConsoleInterceptionStats {
|
|
|
1294
1316
|
}
|
|
1295
1317
|
|
|
1296
1318
|
/**
|
|
1297
|
-
* @fileoverview
|
|
1319
|
+
* @fileoverview Security-related type definitions for XyPrissJS Express integration
|
|
1298
1320
|
*
|
|
1299
|
-
* This module contains
|
|
1300
|
-
*
|
|
1321
|
+
* This module contains all security-related types including authentication,
|
|
1322
|
+
* authorization, encryption, and security policies.
|
|
1301
1323
|
*
|
|
1302
1324
|
* @version 4.5.11
|
|
1303
1325
|
* @author XyPrissJS Team
|
|
1304
1326
|
* @since 2025-01-06
|
|
1305
1327
|
*/
|
|
1306
|
-
|
|
1307
1328
|
/**
|
|
1308
|
-
*
|
|
1329
|
+
* Security configuration levels.
|
|
1309
1330
|
*
|
|
1310
|
-
*
|
|
1311
|
-
*
|
|
1331
|
+
* Predefined security levels that automatically configure
|
|
1332
|
+
* appropriate security measures:
|
|
1333
|
+
* - basic: Essential security features
|
|
1334
|
+
* - enhanced: Additional security layers
|
|
1335
|
+
* - maximum: All security features enabled
|
|
1336
|
+
*/
|
|
1337
|
+
type SecurityLevel = "basic" | "enhanced" | "maximum";
|
|
1338
|
+
/**
|
|
1339
|
+
* Main security configuration interface.
|
|
1312
1340
|
*
|
|
1313
|
-
*
|
|
1341
|
+
* Comprehensive security configuration including authentication,
|
|
1342
|
+
* encryption, and various security features.
|
|
1343
|
+
*
|
|
1344
|
+
* @interface SecurityConfig
|
|
1314
1345
|
*
|
|
1315
1346
|
* @example
|
|
1316
1347
|
* ```typescript
|
|
1317
|
-
*
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
1320
|
-
*
|
|
1321
|
-
*
|
|
1322
|
-
*
|
|
1323
|
-
*
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1348
|
+
* const securityConfig: SecurityConfig = {
|
|
1349
|
+
* level: 'enhanced',
|
|
1350
|
+
* csrf: true,
|
|
1351
|
+
* helmet: true,
|
|
1352
|
+
* xss: true,
|
|
1353
|
+
* sqlInjection: true,
|
|
1354
|
+
* bruteForce: true,
|
|
1355
|
+
* encryption: {
|
|
1356
|
+
* algorithm: 'aes-256-gcm',
|
|
1357
|
+
* keySize: 256
|
|
1358
|
+
* },
|
|
1359
|
+
* authentication: {
|
|
1360
|
+
* jwt: {
|
|
1361
|
+
* secret: 'your-secret-key',
|
|
1362
|
+
* expiresIn: '24h',
|
|
1363
|
+
* algorithm: 'HS256'
|
|
1364
|
+
* }
|
|
1365
|
+
* }
|
|
1366
|
+
* };
|
|
1326
1367
|
* ```
|
|
1327
1368
|
*/
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1369
|
+
interface SecurityConfig {
|
|
1370
|
+
/** Security level preset */
|
|
1371
|
+
level?: SecurityLevel;
|
|
1372
|
+
/** Enable CSRF protection */
|
|
1373
|
+
csrf?: boolean;
|
|
1374
|
+
/** Enable Helmet.js security headers */
|
|
1375
|
+
helmet?: boolean;
|
|
1376
|
+
/** Enable XSS protection */
|
|
1377
|
+
xss?: boolean;
|
|
1378
|
+
/** Enable SQL injection protection */
|
|
1379
|
+
sqlInjection?: boolean;
|
|
1380
|
+
/** Enable brute force protection */
|
|
1381
|
+
bruteForce?: boolean;
|
|
1382
|
+
/** Encryption configuration */
|
|
1383
|
+
encryption?: EncryptionConfig;
|
|
1384
|
+
/** Authentication configuration */
|
|
1385
|
+
authentication?: AuthenticationConfig;
|
|
1386
|
+
}
|
|
1331
1387
|
/**
|
|
1332
|
-
*
|
|
1388
|
+
* Encryption configuration interface.
|
|
1333
1389
|
*
|
|
1334
|
-
*
|
|
1335
|
-
*
|
|
1390
|
+
* Settings for data encryption including algorithm
|
|
1391
|
+
* selection and key management.
|
|
1336
1392
|
*
|
|
1337
|
-
* @interface
|
|
1393
|
+
* @interface EncryptionConfig
|
|
1338
1394
|
*
|
|
1339
1395
|
* @example
|
|
1340
1396
|
* ```typescript
|
|
1341
|
-
* const
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
* data: { email: '', password: '123' }
|
|
1397
|
+
* const encryptionConfig: EncryptionConfig = {
|
|
1398
|
+
* algorithm: 'aes-256-gcm',
|
|
1399
|
+
* keySize: 256
|
|
1345
1400
|
* };
|
|
1346
1401
|
* ```
|
|
1347
1402
|
*/
|
|
1348
|
-
interface
|
|
1349
|
-
/**
|
|
1350
|
-
|
|
1351
|
-
/**
|
|
1352
|
-
|
|
1353
|
-
/** The validated/sanitized data */
|
|
1354
|
-
data: any;
|
|
1403
|
+
interface EncryptionConfig {
|
|
1404
|
+
/** Encryption algorithm to use */
|
|
1405
|
+
algorithm?: string;
|
|
1406
|
+
/** Key size in bits */
|
|
1407
|
+
keySize?: number;
|
|
1355
1408
|
}
|
|
1356
1409
|
/**
|
|
1357
|
-
*
|
|
1410
|
+
* Authentication configuration interface.
|
|
1358
1411
|
*
|
|
1359
|
-
*
|
|
1360
|
-
*
|
|
1412
|
+
* Configuration for various authentication methods
|
|
1413
|
+
* including JWT and session-based authentication.
|
|
1361
1414
|
*
|
|
1362
|
-
* @interface
|
|
1415
|
+
* @interface AuthenticationConfig
|
|
1363
1416
|
*
|
|
1364
1417
|
* @example
|
|
1365
1418
|
* ```typescript
|
|
1366
|
-
* const
|
|
1367
|
-
*
|
|
1368
|
-
*
|
|
1369
|
-
*
|
|
1370
|
-
*
|
|
1419
|
+
* const authConfig: AuthenticationConfig = {
|
|
1420
|
+
* jwt: {
|
|
1421
|
+
* secret: 'your-jwt-secret',
|
|
1422
|
+
* expiresIn: '24h',
|
|
1423
|
+
* algorithm: 'HS256',
|
|
1424
|
+
* issuer: 'your-app',
|
|
1425
|
+
* audience: 'your-users'
|
|
1426
|
+
* },
|
|
1427
|
+
* session: {
|
|
1428
|
+
* secret: 'your-session-secret',
|
|
1429
|
+
* name: 'sessionId',
|
|
1430
|
+
* cookie: {
|
|
1431
|
+
* maxAge: 86400000, // 24 hours
|
|
1432
|
+
* secure: true,
|
|
1433
|
+
* httpOnly: true,
|
|
1434
|
+
* sameSite: 'strict'
|
|
1435
|
+
* }
|
|
1436
|
+
* }
|
|
1371
1437
|
* };
|
|
1372
1438
|
* ```
|
|
1373
1439
|
*/
|
|
1374
|
-
interface
|
|
1375
|
-
/**
|
|
1376
|
-
|
|
1377
|
-
/**
|
|
1378
|
-
|
|
1379
|
-
/** Array of specific permissions */
|
|
1380
|
-
permissions: string[];
|
|
1381
|
-
/** Additional user metadata */
|
|
1382
|
-
metadata: Record<string, any>;
|
|
1440
|
+
interface AuthenticationConfig {
|
|
1441
|
+
/** JWT authentication configuration */
|
|
1442
|
+
jwt?: JWTConfig;
|
|
1443
|
+
/** Session authentication configuration */
|
|
1444
|
+
session?: SessionConfig;
|
|
1383
1445
|
}
|
|
1384
1446
|
/**
|
|
1385
|
-
*
|
|
1447
|
+
* JWT (JSON Web Token) configuration interface.
|
|
1386
1448
|
*
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1449
|
+
* Configuration for JWT-based authentication including
|
|
1450
|
+
* signing algorithms and token validation.
|
|
1389
1451
|
*
|
|
1390
|
-
* @interface
|
|
1452
|
+
* @interface JWTConfig
|
|
1391
1453
|
*
|
|
1392
1454
|
* @example
|
|
1393
1455
|
* ```typescript
|
|
1394
|
-
* const
|
|
1395
|
-
*
|
|
1396
|
-
*
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
1456
|
+
* const jwtConfig: JWTConfig = {
|
|
1457
|
+
* secret: 'your-256-bit-secret',
|
|
1458
|
+
* expiresIn: '24h',
|
|
1459
|
+
* algorithm: 'HS256',
|
|
1460
|
+
* issuer: 'your-application',
|
|
1461
|
+
* audience: 'your-users'
|
|
1399
1462
|
* };
|
|
1400
1463
|
* ```
|
|
1401
1464
|
*/
|
|
1402
|
-
interface
|
|
1403
|
-
/**
|
|
1404
|
-
|
|
1405
|
-
/**
|
|
1406
|
-
|
|
1407
|
-
/**
|
|
1408
|
-
|
|
1409
|
-
/**
|
|
1410
|
-
|
|
1465
|
+
interface JWTConfig {
|
|
1466
|
+
/** Secret key for signing tokens */
|
|
1467
|
+
secret: string;
|
|
1468
|
+
/** Token expiration time (e.g., '24h', '7d', '30m') */
|
|
1469
|
+
expiresIn?: string;
|
|
1470
|
+
/** Signing algorithm */
|
|
1471
|
+
algorithm?: string;
|
|
1472
|
+
/** Token issuer */
|
|
1473
|
+
issuer?: string;
|
|
1474
|
+
/** Token audience */
|
|
1475
|
+
audience?: string;
|
|
1411
1476
|
}
|
|
1412
1477
|
/**
|
|
1413
|
-
*
|
|
1478
|
+
* Session configuration interface.
|
|
1414
1479
|
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1480
|
+
* Configuration for session-based authentication including
|
|
1481
|
+
* cookie settings and storage options.
|
|
1417
1482
|
*
|
|
1418
|
-
* @interface
|
|
1483
|
+
* @interface SessionConfig
|
|
1419
1484
|
*
|
|
1420
1485
|
* @example
|
|
1421
1486
|
* ```typescript
|
|
1422
|
-
* const
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1425
|
-
*
|
|
1426
|
-
*
|
|
1487
|
+
* const sessionConfig: SessionConfig = {
|
|
1488
|
+
* secret: 'your-session-secret',
|
|
1489
|
+
* name: 'connect.sid',
|
|
1490
|
+
* cookie: {
|
|
1491
|
+
* maxAge: 86400000, // 24 hours
|
|
1492
|
+
* secure: true,
|
|
1493
|
+
* httpOnly: true,
|
|
1494
|
+
* sameSite: 'strict'
|
|
1495
|
+
* },
|
|
1496
|
+
* store: 'redis'
|
|
1427
1497
|
* };
|
|
1428
1498
|
* ```
|
|
1429
1499
|
*/
|
|
1430
|
-
interface
|
|
1431
|
-
/**
|
|
1432
|
-
|
|
1433
|
-
/**
|
|
1434
|
-
|
|
1435
|
-
/**
|
|
1436
|
-
|
|
1437
|
-
/**
|
|
1438
|
-
|
|
1500
|
+
interface SessionConfig {
|
|
1501
|
+
/** Secret for signing session cookies */
|
|
1502
|
+
secret: string;
|
|
1503
|
+
/** Session cookie name */
|
|
1504
|
+
name?: string;
|
|
1505
|
+
/** Cookie configuration */
|
|
1506
|
+
cookie?: SessionCookieConfig;
|
|
1507
|
+
/** Session store type */
|
|
1508
|
+
store?: "memory" | "redis" | "custom";
|
|
1439
1509
|
}
|
|
1440
1510
|
/**
|
|
1441
|
-
*
|
|
1511
|
+
* Session cookie configuration interface.
|
|
1442
1512
|
*
|
|
1443
|
-
*
|
|
1444
|
-
*
|
|
1513
|
+
* Detailed configuration for session cookies including
|
|
1514
|
+
* security and expiration settings.
|
|
1445
1515
|
*
|
|
1446
|
-
* @interface
|
|
1447
|
-
* @extends Request
|
|
1516
|
+
* @interface SessionCookieConfig
|
|
1448
1517
|
*
|
|
1449
1518
|
* @example
|
|
1450
1519
|
* ```typescript
|
|
1451
|
-
*
|
|
1452
|
-
* //
|
|
1453
|
-
*
|
|
1454
|
-
*
|
|
1455
|
-
*
|
|
1456
|
-
*
|
|
1457
|
-
*
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
*/
|
|
1465
|
-
|
|
1520
|
+
* const cookieConfig: SessionCookieConfig = {
|
|
1521
|
+
* maxAge: 86400000, // 24 hours
|
|
1522
|
+
* secure: true,
|
|
1523
|
+
* httpOnly: true,
|
|
1524
|
+
* sameSite: 'strict'
|
|
1525
|
+
* };
|
|
1526
|
+
* ```
|
|
1527
|
+
*/
|
|
1528
|
+
interface SessionCookieConfig {
|
|
1529
|
+
/** Cookie expiration time in milliseconds */
|
|
1530
|
+
maxAge?: number;
|
|
1531
|
+
/** Require HTTPS for cookie transmission */
|
|
1532
|
+
secure?: boolean;
|
|
1533
|
+
/** Prevent client-side JavaScript access */
|
|
1534
|
+
httpOnly?: boolean;
|
|
1535
|
+
/** SameSite cookie attribute */
|
|
1536
|
+
sameSite?: boolean | "lax" | "strict" | "none";
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Route-specific security configuration interface.
|
|
1540
|
+
*
|
|
1541
|
+
* Security settings that can be applied to individual
|
|
1542
|
+
* routes or route groups.
|
|
1543
|
+
*
|
|
1544
|
+
* @interface RouteSecurityConfig
|
|
1545
|
+
*
|
|
1546
|
+
* @example
|
|
1547
|
+
* ```typescript
|
|
1548
|
+
* const routeSecurityConfig: RouteSecurityConfig = {
|
|
1549
|
+
* auth: true,
|
|
1550
|
+
* roles: ['admin', 'moderator'],
|
|
1551
|
+
* permissions: ['read:users', 'write:posts'],
|
|
1552
|
+
* encryption: true,
|
|
1553
|
+
* sanitization: true,
|
|
1554
|
+
* validation: true
|
|
1555
|
+
* };
|
|
1556
|
+
* ```
|
|
1557
|
+
*/
|
|
1558
|
+
interface RouteSecurityConfig {
|
|
1559
|
+
/** Require authentication */
|
|
1560
|
+
auth?: boolean;
|
|
1561
|
+
/** Required user roles */
|
|
1562
|
+
roles?: string[];
|
|
1563
|
+
/** Required permissions */
|
|
1564
|
+
permissions?: string[];
|
|
1565
|
+
/** Enable response encryption */
|
|
1566
|
+
encryption?: boolean;
|
|
1567
|
+
/** Enable input sanitization */
|
|
1568
|
+
sanitization?: boolean;
|
|
1569
|
+
/** Enable input validation */
|
|
1570
|
+
validation?: boolean;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
/**
|
|
1574
|
+
* @fileoverview Core type definitions for XyPrissJS Express integration
|
|
1575
|
+
*
|
|
1576
|
+
* This module contains fundamental types and utilities used throughout
|
|
1577
|
+
* the Express integration system.
|
|
1578
|
+
*
|
|
1579
|
+
* @version 4.5.11
|
|
1580
|
+
* @author XyPrissJS Team
|
|
1581
|
+
* @since 2025-01-06
|
|
1582
|
+
*/
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* Deep partial utility type that makes all properties optional recursively.
|
|
1586
|
+
*
|
|
1587
|
+
* This utility type is used throughout the configuration system to allow
|
|
1588
|
+
* partial configuration objects while maintaining type safety.
|
|
1589
|
+
*
|
|
1590
|
+
* @template T - The type to make deeply partial
|
|
1591
|
+
*
|
|
1592
|
+
* @example
|
|
1593
|
+
* ```typescript
|
|
1594
|
+
* interface Config {
|
|
1595
|
+
* server: {
|
|
1596
|
+
* port: number;
|
|
1597
|
+
* host: string;
|
|
1598
|
+
* };
|
|
1599
|
+
* }
|
|
1600
|
+
*
|
|
1601
|
+
* type PartialConfig = DeepPartial<Config>;
|
|
1602
|
+
* // Result: { server?: { port?: number; host?: string; } }
|
|
1603
|
+
* ```
|
|
1604
|
+
*/
|
|
1605
|
+
type DeepPartial<T> = {
|
|
1606
|
+
[K in keyof T]?: T[K] extends infer U ? U extends object ? U extends readonly any[] ? U extends readonly (infer V)[] ? readonly DeepPartial<V>[] : U : U extends Function ? U : DeepPartial<U> : U : never;
|
|
1607
|
+
};
|
|
1608
|
+
/**
|
|
1609
|
+
* Validation result interface for request validation operations.
|
|
1610
|
+
*
|
|
1611
|
+
* Used by validation middleware and request handlers to provide
|
|
1612
|
+
* structured validation feedback.
|
|
1613
|
+
*
|
|
1614
|
+
* @interface ValidationResult
|
|
1615
|
+
*
|
|
1616
|
+
* @example
|
|
1617
|
+
* ```typescript
|
|
1618
|
+
* const result: ValidationResult = {
|
|
1619
|
+
* valid: false,
|
|
1620
|
+
* errors: ['Email is required', 'Password too short'],
|
|
1621
|
+
* data: { email: '', password: '123' }
|
|
1622
|
+
* };
|
|
1623
|
+
* ```
|
|
1624
|
+
*/
|
|
1625
|
+
interface ValidationResult$1 {
|
|
1626
|
+
/** Whether the validation passed */
|
|
1627
|
+
valid: boolean;
|
|
1628
|
+
/** Array of validation error messages */
|
|
1629
|
+
errors: string[];
|
|
1630
|
+
/** The validated/sanitized data */
|
|
1631
|
+
data: any;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* User context information for authenticated requests.
|
|
1635
|
+
*
|
|
1636
|
+
* Contains user identity, permissions, and metadata for
|
|
1637
|
+
* authorization and audit purposes.
|
|
1638
|
+
*
|
|
1639
|
+
* @interface UserContext
|
|
1640
|
+
*
|
|
1641
|
+
* @example
|
|
1642
|
+
* ```typescript
|
|
1643
|
+
* const user: UserContext = {
|
|
1644
|
+
* id: 'user-123',
|
|
1645
|
+
* roles: ['admin', 'user'],
|
|
1646
|
+
* permissions: ['read:users', 'write:posts'],
|
|
1647
|
+
* metadata: { department: 'engineering', level: 'senior' }
|
|
1648
|
+
* };
|
|
1649
|
+
* ```
|
|
1650
|
+
*/
|
|
1651
|
+
interface UserContext {
|
|
1652
|
+
/** Unique user identifier */
|
|
1653
|
+
id: string;
|
|
1654
|
+
/** Array of user roles */
|
|
1655
|
+
roles: string[];
|
|
1656
|
+
/** Array of specific permissions */
|
|
1657
|
+
permissions: string[];
|
|
1658
|
+
/** Additional user metadata */
|
|
1659
|
+
metadata: Record<string, any>;
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Session data structure for user sessions.
|
|
1663
|
+
*
|
|
1664
|
+
* Contains session information including expiration and
|
|
1665
|
+
* custom session data.
|
|
1666
|
+
*
|
|
1667
|
+
* @interface SessionData
|
|
1668
|
+
*
|
|
1669
|
+
* @example
|
|
1670
|
+
* ```typescript
|
|
1671
|
+
* const session: SessionData = {
|
|
1672
|
+
* id: 'session-abc123',
|
|
1673
|
+
* userId: 'user-123',
|
|
1674
|
+
* data: { theme: 'dark', language: 'en' },
|
|
1675
|
+
* expires: new Date(Date.now() + 3600000) // 1 hour
|
|
1676
|
+
* };
|
|
1677
|
+
* ```
|
|
1678
|
+
*/
|
|
1679
|
+
interface SessionData {
|
|
1680
|
+
/** Unique session identifier */
|
|
1681
|
+
id: string;
|
|
1682
|
+
/** Associated user ID (optional) */
|
|
1683
|
+
userId?: string;
|
|
1684
|
+
/** Custom session data */
|
|
1685
|
+
data: Record<string, any>;
|
|
1686
|
+
/** Session expiration date */
|
|
1687
|
+
expires: Date;
|
|
1688
|
+
}
|
|
1689
|
+
/**
|
|
1690
|
+
* Pagination information for paginated responses.
|
|
1691
|
+
*
|
|
1692
|
+
* Used by API endpoints that return paginated data to provide
|
|
1693
|
+
* navigation information to clients.
|
|
1694
|
+
*
|
|
1695
|
+
* @interface PaginationInfo
|
|
1696
|
+
*
|
|
1697
|
+
* @example
|
|
1698
|
+
* ```typescript
|
|
1699
|
+
* const pagination: PaginationInfo = {
|
|
1700
|
+
* page: 2,
|
|
1701
|
+
* limit: 20,
|
|
1702
|
+
* total: 150,
|
|
1703
|
+
* pages: 8
|
|
1704
|
+
* };
|
|
1705
|
+
* ```
|
|
1706
|
+
*/
|
|
1707
|
+
interface PaginationInfo {
|
|
1708
|
+
/** Current page number (1-based) */
|
|
1709
|
+
page: number;
|
|
1710
|
+
/** Number of items per page */
|
|
1711
|
+
limit: number;
|
|
1712
|
+
/** Total number of items */
|
|
1713
|
+
total: number;
|
|
1714
|
+
/** Total number of pages */
|
|
1715
|
+
pages: number;
|
|
1716
|
+
}
|
|
1717
|
+
/**
|
|
1718
|
+
* Enhanced Express request interface with additional utilities.
|
|
1719
|
+
*
|
|
1720
|
+
* Extends the standard Express Request with caching, security,
|
|
1721
|
+
* performance, and validation utilities.
|
|
1722
|
+
*
|
|
1723
|
+
* @interface EnhancedRequest
|
|
1724
|
+
* @extends Request
|
|
1725
|
+
*
|
|
1726
|
+
* @example
|
|
1727
|
+
* ```typescript
|
|
1728
|
+
* app.get('/api/users', async (req: EnhancedRequest, res: EnhancedResponse) => {
|
|
1729
|
+
* // Use enhanced features
|
|
1730
|
+
* const cached = await req.cache.get('users');
|
|
1731
|
+
* const encrypted = await req.security.encrypt(sensitiveData);
|
|
1732
|
+
* req.performance.start();
|
|
1733
|
+
*
|
|
1734
|
+
* // Validation
|
|
1735
|
+
* const validation = req.validation.query(userQuerySchema);
|
|
1736
|
+
* if (!validation.valid) {
|
|
1737
|
+
* return res.error('Invalid query parameters');
|
|
1738
|
+
* }
|
|
1739
|
+
* });
|
|
1740
|
+
* ```
|
|
1741
|
+
*/
|
|
1742
|
+
interface EnhancedRequest extends Request {
|
|
1466
1743
|
/** Cache utilities for request-level caching */
|
|
1467
1744
|
cache: {
|
|
1468
1745
|
/** Get cached value by key */
|
|
@@ -1883,351 +2160,96 @@ interface CacheSecurityConfig {
|
|
|
1883
2160
|
*
|
|
1884
2161
|
* @example
|
|
1885
2162
|
* ```typescript
|
|
1886
|
-
* const monitoringConfig: CacheMonitoringConfig = {
|
|
1887
|
-
* enabled: true,
|
|
1888
|
-
* metricsInterval: 30000, // 30 seconds
|
|
1889
|
-
* alertThresholds: {
|
|
1890
|
-
* memoryUsage: 0.85,
|
|
1891
|
-
* hitRate: 0.7,
|
|
1892
|
-
* errorRate: 0.05,
|
|
1893
|
-
* latency: 100
|
|
1894
|
-
* },
|
|
1895
|
-
* detailed: true
|
|
1896
|
-
* };
|
|
1897
|
-
* ```
|
|
1898
|
-
*/
|
|
1899
|
-
interface CacheMonitoringConfig {
|
|
1900
|
-
/** Enable monitoring */
|
|
1901
|
-
enabled?: boolean;
|
|
1902
|
-
/** Metrics collection interval in milliseconds */
|
|
1903
|
-
metricsInterval?: number;
|
|
1904
|
-
/** Alert thresholds for various metrics */
|
|
1905
|
-
alertThresholds?: {
|
|
1906
|
-
/** Memory usage threshold (0-1) */
|
|
1907
|
-
memoryUsage?: number;
|
|
1908
|
-
/** Cache hit rate threshold (0-1) */
|
|
1909
|
-
hitRate?: number;
|
|
1910
|
-
/** Error rate threshold (0-1) */
|
|
1911
|
-
errorRate?: number;
|
|
1912
|
-
/** Latency threshold in milliseconds */
|
|
1913
|
-
latency?: number;
|
|
1914
|
-
};
|
|
1915
|
-
/** Enable detailed metrics collection */
|
|
1916
|
-
detailed?: boolean;
|
|
1917
|
-
}
|
|
1918
|
-
/**
|
|
1919
|
-
* Cache resilience configuration.
|
|
1920
|
-
*
|
|
1921
|
-
* Settings for fault tolerance including retry logic,
|
|
1922
|
-
* circuit breakers, and fallback mechanisms.
|
|
1923
|
-
*
|
|
1924
|
-
* @interface CacheResilienceConfig
|
|
1925
|
-
*
|
|
1926
|
-
* @example
|
|
1927
|
-
* ```typescript
|
|
1928
|
-
* const resilienceConfig: CacheResilienceConfig = {
|
|
1929
|
-
* retryAttempts: 3,
|
|
1930
|
-
* retryDelay: 1000,
|
|
1931
|
-
* circuitBreaker: true,
|
|
1932
|
-
* fallback: true,
|
|
1933
|
-
* healthCheck: true
|
|
1934
|
-
* };
|
|
1935
|
-
* ```
|
|
1936
|
-
*/
|
|
1937
|
-
interface CacheResilienceConfig {
|
|
1938
|
-
/** Number of retry attempts for failed operations */
|
|
1939
|
-
retryAttempts?: number;
|
|
1940
|
-
/** Delay between retry attempts in milliseconds */
|
|
1941
|
-
retryDelay?: number;
|
|
1942
|
-
/** Enable circuit breaker pattern */
|
|
1943
|
-
circuitBreaker?: boolean;
|
|
1944
|
-
/** Enable fallback to alternative cache */
|
|
1945
|
-
fallback?: boolean;
|
|
1946
|
-
/** Enable health check monitoring */
|
|
1947
|
-
healthCheck?: boolean;
|
|
1948
|
-
}
|
|
1949
|
-
/**
|
|
1950
|
-
* Cache strategy configuration.
|
|
1951
|
-
*
|
|
1952
|
-
* Defines conditional caching strategies based on
|
|
1953
|
-
* request characteristics and business logic.
|
|
1954
|
-
*
|
|
1955
|
-
* @interface CacheStrategy
|
|
1956
|
-
*
|
|
1957
|
-
* @example
|
|
1958
|
-
* ```typescript
|
|
1959
|
-
* const apiStrategy: CacheStrategy = {
|
|
1960
|
-
* name: 'api-endpoints',
|
|
1961
|
-
* condition: (req) => req.path.startsWith('/api/') && req.method === 'GET',
|
|
1962
|
-
* ttl: 300, // 5 minutes
|
|
1963
|
-
* tags: ['api', 'public']
|
|
1964
|
-
* };
|
|
1965
|
-
* ```
|
|
1966
|
-
*/
|
|
1967
|
-
interface CacheStrategy {
|
|
1968
|
-
/** Strategy name for identification */
|
|
1969
|
-
name: string;
|
|
1970
|
-
/** Condition function to determine if strategy applies */
|
|
1971
|
-
condition: (req: Request) => boolean;
|
|
1972
|
-
/** TTL for this strategy in seconds */
|
|
1973
|
-
ttl: number;
|
|
1974
|
-
/** Tags for cache invalidation */
|
|
1975
|
-
tags?: string[];
|
|
1976
|
-
}
|
|
1977
|
-
|
|
1978
|
-
/**
|
|
1979
|
-
* @fileoverview Security-related type definitions for XyPrissJS Express integration
|
|
1980
|
-
*
|
|
1981
|
-
* This module contains all security-related types including authentication,
|
|
1982
|
-
* authorization, encryption, and security policies.
|
|
1983
|
-
*
|
|
1984
|
-
* @version 4.5.11
|
|
1985
|
-
* @author XyPrissJS Team
|
|
1986
|
-
* @since 2025-01-06
|
|
1987
|
-
*/
|
|
1988
|
-
/**
|
|
1989
|
-
* Security configuration levels.
|
|
1990
|
-
*
|
|
1991
|
-
* Predefined security levels that automatically configure
|
|
1992
|
-
* appropriate security measures:
|
|
1993
|
-
* - basic: Essential security features
|
|
1994
|
-
* - enhanced: Additional security layers
|
|
1995
|
-
* - maximum: All security features enabled
|
|
1996
|
-
*/
|
|
1997
|
-
type SecurityLevel = "basic" | "enhanced" | "maximum";
|
|
1998
|
-
/**
|
|
1999
|
-
* Main security configuration interface.
|
|
2000
|
-
*
|
|
2001
|
-
* Comprehensive security configuration including authentication,
|
|
2002
|
-
* encryption, and various security features.
|
|
2003
|
-
*
|
|
2004
|
-
* @interface SecurityConfig
|
|
2005
|
-
*
|
|
2006
|
-
* @example
|
|
2007
|
-
* ```typescript
|
|
2008
|
-
* const securityConfig: SecurityConfig = {
|
|
2009
|
-
* level: 'enhanced',
|
|
2010
|
-
* csrf: true,
|
|
2011
|
-
* helmet: true,
|
|
2012
|
-
* xss: true,
|
|
2013
|
-
* sqlInjection: true,
|
|
2014
|
-
* bruteForce: true,
|
|
2015
|
-
* encryption: {
|
|
2016
|
-
* algorithm: 'aes-256-gcm',
|
|
2017
|
-
* keySize: 256
|
|
2018
|
-
* },
|
|
2019
|
-
* authentication: {
|
|
2020
|
-
* jwt: {
|
|
2021
|
-
* secret: 'your-secret-key',
|
|
2022
|
-
* expiresIn: '24h',
|
|
2023
|
-
* algorithm: 'HS256'
|
|
2024
|
-
* }
|
|
2025
|
-
* }
|
|
2026
|
-
* };
|
|
2027
|
-
* ```
|
|
2028
|
-
*/
|
|
2029
|
-
interface SecurityConfig {
|
|
2030
|
-
/** Security level preset */
|
|
2031
|
-
level?: SecurityLevel;
|
|
2032
|
-
/** Enable CSRF protection */
|
|
2033
|
-
csrf?: boolean;
|
|
2034
|
-
/** Enable Helmet.js security headers */
|
|
2035
|
-
helmet?: boolean;
|
|
2036
|
-
/** Enable XSS protection */
|
|
2037
|
-
xss?: boolean;
|
|
2038
|
-
/** Enable SQL injection protection */
|
|
2039
|
-
sqlInjection?: boolean;
|
|
2040
|
-
/** Enable brute force protection */
|
|
2041
|
-
bruteForce?: boolean;
|
|
2042
|
-
/** Encryption configuration */
|
|
2043
|
-
encryption?: EncryptionConfig;
|
|
2044
|
-
/** Authentication configuration */
|
|
2045
|
-
authentication?: AuthenticationConfig;
|
|
2046
|
-
}
|
|
2047
|
-
/**
|
|
2048
|
-
* Encryption configuration interface.
|
|
2049
|
-
*
|
|
2050
|
-
* Settings for data encryption including algorithm
|
|
2051
|
-
* selection and key management.
|
|
2052
|
-
*
|
|
2053
|
-
* @interface EncryptionConfig
|
|
2054
|
-
*
|
|
2055
|
-
* @example
|
|
2056
|
-
* ```typescript
|
|
2057
|
-
* const encryptionConfig: EncryptionConfig = {
|
|
2058
|
-
* algorithm: 'aes-256-gcm',
|
|
2059
|
-
* keySize: 256
|
|
2060
|
-
* };
|
|
2061
|
-
* ```
|
|
2062
|
-
*/
|
|
2063
|
-
interface EncryptionConfig {
|
|
2064
|
-
/** Encryption algorithm to use */
|
|
2065
|
-
algorithm?: string;
|
|
2066
|
-
/** Key size in bits */
|
|
2067
|
-
keySize?: number;
|
|
2068
|
-
}
|
|
2069
|
-
/**
|
|
2070
|
-
* Authentication configuration interface.
|
|
2071
|
-
*
|
|
2072
|
-
* Configuration for various authentication methods
|
|
2073
|
-
* including JWT and session-based authentication.
|
|
2074
|
-
*
|
|
2075
|
-
* @interface AuthenticationConfig
|
|
2076
|
-
*
|
|
2077
|
-
* @example
|
|
2078
|
-
* ```typescript
|
|
2079
|
-
* const authConfig: AuthenticationConfig = {
|
|
2080
|
-
* jwt: {
|
|
2081
|
-
* secret: 'your-jwt-secret',
|
|
2082
|
-
* expiresIn: '24h',
|
|
2083
|
-
* algorithm: 'HS256',
|
|
2084
|
-
* issuer: 'your-app',
|
|
2085
|
-
* audience: 'your-users'
|
|
2086
|
-
* },
|
|
2087
|
-
* session: {
|
|
2088
|
-
* secret: 'your-session-secret',
|
|
2089
|
-
* name: 'sessionId',
|
|
2090
|
-
* cookie: {
|
|
2091
|
-
* maxAge: 86400000, // 24 hours
|
|
2092
|
-
* secure: true,
|
|
2093
|
-
* httpOnly: true,
|
|
2094
|
-
* sameSite: 'strict'
|
|
2095
|
-
* }
|
|
2096
|
-
* }
|
|
2097
|
-
* };
|
|
2098
|
-
* ```
|
|
2099
|
-
*/
|
|
2100
|
-
interface AuthenticationConfig {
|
|
2101
|
-
/** JWT authentication configuration */
|
|
2102
|
-
jwt?: JWTConfig;
|
|
2103
|
-
/** Session authentication configuration */
|
|
2104
|
-
session?: SessionConfig;
|
|
2105
|
-
}
|
|
2106
|
-
/**
|
|
2107
|
-
* JWT (JSON Web Token) configuration interface.
|
|
2108
|
-
*
|
|
2109
|
-
* Configuration for JWT-based authentication including
|
|
2110
|
-
* signing algorithms and token validation.
|
|
2111
|
-
*
|
|
2112
|
-
* @interface JWTConfig
|
|
2113
|
-
*
|
|
2114
|
-
* @example
|
|
2115
|
-
* ```typescript
|
|
2116
|
-
* const jwtConfig: JWTConfig = {
|
|
2117
|
-
* secret: 'your-256-bit-secret',
|
|
2118
|
-
* expiresIn: '24h',
|
|
2119
|
-
* algorithm: 'HS256',
|
|
2120
|
-
* issuer: 'your-application',
|
|
2121
|
-
* audience: 'your-users'
|
|
2122
|
-
* };
|
|
2123
|
-
* ```
|
|
2124
|
-
*/
|
|
2125
|
-
interface JWTConfig {
|
|
2126
|
-
/** Secret key for signing tokens */
|
|
2127
|
-
secret: string;
|
|
2128
|
-
/** Token expiration time (e.g., '24h', '7d', '30m') */
|
|
2129
|
-
expiresIn?: string;
|
|
2130
|
-
/** Signing algorithm */
|
|
2131
|
-
algorithm?: string;
|
|
2132
|
-
/** Token issuer */
|
|
2133
|
-
issuer?: string;
|
|
2134
|
-
/** Token audience */
|
|
2135
|
-
audience?: string;
|
|
2136
|
-
}
|
|
2137
|
-
/**
|
|
2138
|
-
* Session configuration interface.
|
|
2139
|
-
*
|
|
2140
|
-
* Configuration for session-based authentication including
|
|
2141
|
-
* cookie settings and storage options.
|
|
2142
|
-
*
|
|
2143
|
-
* @interface SessionConfig
|
|
2144
|
-
*
|
|
2145
|
-
* @example
|
|
2146
|
-
* ```typescript
|
|
2147
|
-
* const sessionConfig: SessionConfig = {
|
|
2148
|
-
* secret: 'your-session-secret',
|
|
2149
|
-
* name: 'connect.sid',
|
|
2150
|
-
* cookie: {
|
|
2151
|
-
* maxAge: 86400000, // 24 hours
|
|
2152
|
-
* secure: true,
|
|
2153
|
-
* httpOnly: true,
|
|
2154
|
-
* sameSite: 'strict'
|
|
2163
|
+
* const monitoringConfig: CacheMonitoringConfig = {
|
|
2164
|
+
* enabled: true,
|
|
2165
|
+
* metricsInterval: 30000, // 30 seconds
|
|
2166
|
+
* alertThresholds: {
|
|
2167
|
+
* memoryUsage: 0.85,
|
|
2168
|
+
* hitRate: 0.7,
|
|
2169
|
+
* errorRate: 0.05,
|
|
2170
|
+
* latency: 100
|
|
2155
2171
|
* },
|
|
2156
|
-
*
|
|
2172
|
+
* detailed: true
|
|
2157
2173
|
* };
|
|
2158
2174
|
* ```
|
|
2159
2175
|
*/
|
|
2160
|
-
interface
|
|
2161
|
-
/**
|
|
2162
|
-
|
|
2163
|
-
/**
|
|
2164
|
-
|
|
2165
|
-
/**
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2176
|
+
interface CacheMonitoringConfig {
|
|
2177
|
+
/** Enable monitoring */
|
|
2178
|
+
enabled?: boolean;
|
|
2179
|
+
/** Metrics collection interval in milliseconds */
|
|
2180
|
+
metricsInterval?: number;
|
|
2181
|
+
/** Alert thresholds for various metrics */
|
|
2182
|
+
alertThresholds?: {
|
|
2183
|
+
/** Memory usage threshold (0-1) */
|
|
2184
|
+
memoryUsage?: number;
|
|
2185
|
+
/** Cache hit rate threshold (0-1) */
|
|
2186
|
+
hitRate?: number;
|
|
2187
|
+
/** Error rate threshold (0-1) */
|
|
2188
|
+
errorRate?: number;
|
|
2189
|
+
/** Latency threshold in milliseconds */
|
|
2190
|
+
latency?: number;
|
|
2191
|
+
};
|
|
2192
|
+
/** Enable detailed metrics collection */
|
|
2193
|
+
detailed?: boolean;
|
|
2169
2194
|
}
|
|
2170
2195
|
/**
|
|
2171
|
-
*
|
|
2196
|
+
* Cache resilience configuration.
|
|
2172
2197
|
*
|
|
2173
|
-
*
|
|
2174
|
-
*
|
|
2198
|
+
* Settings for fault tolerance including retry logic,
|
|
2199
|
+
* circuit breakers, and fallback mechanisms.
|
|
2175
2200
|
*
|
|
2176
|
-
* @interface
|
|
2201
|
+
* @interface CacheResilienceConfig
|
|
2177
2202
|
*
|
|
2178
2203
|
* @example
|
|
2179
2204
|
* ```typescript
|
|
2180
|
-
* const
|
|
2181
|
-
*
|
|
2182
|
-
*
|
|
2183
|
-
*
|
|
2184
|
-
*
|
|
2205
|
+
* const resilienceConfig: CacheResilienceConfig = {
|
|
2206
|
+
* retryAttempts: 3,
|
|
2207
|
+
* retryDelay: 1000,
|
|
2208
|
+
* circuitBreaker: true,
|
|
2209
|
+
* fallback: true,
|
|
2210
|
+
* healthCheck: true
|
|
2185
2211
|
* };
|
|
2186
2212
|
* ```
|
|
2187
2213
|
*/
|
|
2188
|
-
interface
|
|
2189
|
-
/**
|
|
2190
|
-
|
|
2191
|
-
/**
|
|
2192
|
-
|
|
2193
|
-
/**
|
|
2194
|
-
|
|
2195
|
-
/**
|
|
2196
|
-
|
|
2214
|
+
interface CacheResilienceConfig {
|
|
2215
|
+
/** Number of retry attempts for failed operations */
|
|
2216
|
+
retryAttempts?: number;
|
|
2217
|
+
/** Delay between retry attempts in milliseconds */
|
|
2218
|
+
retryDelay?: number;
|
|
2219
|
+
/** Enable circuit breaker pattern */
|
|
2220
|
+
circuitBreaker?: boolean;
|
|
2221
|
+
/** Enable fallback to alternative cache */
|
|
2222
|
+
fallback?: boolean;
|
|
2223
|
+
/** Enable health check monitoring */
|
|
2224
|
+
healthCheck?: boolean;
|
|
2197
2225
|
}
|
|
2198
2226
|
/**
|
|
2199
|
-
*
|
|
2227
|
+
* Cache strategy configuration.
|
|
2200
2228
|
*
|
|
2201
|
-
*
|
|
2202
|
-
*
|
|
2229
|
+
* Defines conditional caching strategies based on
|
|
2230
|
+
* request characteristics and business logic.
|
|
2203
2231
|
*
|
|
2204
|
-
* @interface
|
|
2232
|
+
* @interface CacheStrategy
|
|
2205
2233
|
*
|
|
2206
2234
|
* @example
|
|
2207
2235
|
* ```typescript
|
|
2208
|
-
* const
|
|
2209
|
-
*
|
|
2210
|
-
*
|
|
2211
|
-
*
|
|
2212
|
-
*
|
|
2213
|
-
* sanitization: true,
|
|
2214
|
-
* validation: true
|
|
2236
|
+
* const apiStrategy: CacheStrategy = {
|
|
2237
|
+
* name: 'api-endpoints',
|
|
2238
|
+
* condition: (req) => req.path.startsWith('/api/') && req.method === 'GET',
|
|
2239
|
+
* ttl: 300, // 5 minutes
|
|
2240
|
+
* tags: ['api', 'public']
|
|
2215
2241
|
* };
|
|
2216
2242
|
* ```
|
|
2217
2243
|
*/
|
|
2218
|
-
interface
|
|
2219
|
-
/**
|
|
2220
|
-
|
|
2221
|
-
/**
|
|
2222
|
-
|
|
2223
|
-
/**
|
|
2224
|
-
|
|
2225
|
-
/**
|
|
2226
|
-
|
|
2227
|
-
/** Enable input sanitization */
|
|
2228
|
-
sanitization?: boolean;
|
|
2229
|
-
/** Enable input validation */
|
|
2230
|
-
validation?: boolean;
|
|
2244
|
+
interface CacheStrategy {
|
|
2245
|
+
/** Strategy name for identification */
|
|
2246
|
+
name: string;
|
|
2247
|
+
/** Condition function to determine if strategy applies */
|
|
2248
|
+
condition: (req: Request) => boolean;
|
|
2249
|
+
/** TTL for this strategy in seconds */
|
|
2250
|
+
ttl: number;
|
|
2251
|
+
/** Tags for cache invalidation */
|
|
2252
|
+
tags?: string[];
|
|
2231
2253
|
}
|
|
2232
2254
|
|
|
2233
2255
|
/**
|
|
@@ -3097,25 +3119,49 @@ interface ServerOptions {
|
|
|
3097
3119
|
/**
|
|
3098
3120
|
* Security configuration for the server.
|
|
3099
3121
|
*
|
|
3100
|
-
* Comprehensive security settings including
|
|
3101
|
-
* and various security features.
|
|
3122
|
+
* Comprehensive security settings including authentication, encryption,
|
|
3123
|
+
* CSRF protection, security headers, and various security features.
|
|
3102
3124
|
*
|
|
3103
3125
|
* @example
|
|
3104
3126
|
* ```typescript
|
|
3105
3127
|
* security: {
|
|
3106
|
-
*
|
|
3107
|
-
*
|
|
3128
|
+
* enabled: true,
|
|
3129
|
+
* level: 'enhanced',
|
|
3130
|
+
* csrf: true,
|
|
3108
3131
|
* helmet: true,
|
|
3109
|
-
*
|
|
3110
|
-
*
|
|
3111
|
-
*
|
|
3132
|
+
* xss: true,
|
|
3133
|
+
* bruteForce: true,
|
|
3134
|
+
* authentication: {
|
|
3135
|
+
* jwt: {
|
|
3136
|
+
* secret: 'your-secret-key',
|
|
3137
|
+
* expiresIn: '24h'
|
|
3138
|
+
* }
|
|
3139
|
+
* }
|
|
3112
3140
|
* }
|
|
3113
3141
|
* ```
|
|
3114
3142
|
*/
|
|
3143
|
+
security?: SecurityConfig & {
|
|
3144
|
+
/** Enable security middleware */
|
|
3145
|
+
enabled?: boolean;
|
|
3146
|
+
};
|
|
3115
3147
|
cluster?: {
|
|
3116
3148
|
enabled?: boolean;
|
|
3117
3149
|
config?: Omit<ClusterConfig, "enabled">;
|
|
3118
3150
|
};
|
|
3151
|
+
workerPool?: {
|
|
3152
|
+
enabled?: boolean;
|
|
3153
|
+
config?: {
|
|
3154
|
+
cpu?: {
|
|
3155
|
+
min: number;
|
|
3156
|
+
max: number;
|
|
3157
|
+
};
|
|
3158
|
+
io?: {
|
|
3159
|
+
min: number;
|
|
3160
|
+
max: number;
|
|
3161
|
+
};
|
|
3162
|
+
maxConcurrentTasks?: number;
|
|
3163
|
+
};
|
|
3164
|
+
};
|
|
3119
3165
|
fileWatcher?: {
|
|
3120
3166
|
enabled?: boolean;
|
|
3121
3167
|
watchPaths?: string[];
|
|
@@ -3238,7 +3284,7 @@ interface ServerOptions {
|
|
|
3238
3284
|
};
|
|
3239
3285
|
logging?: {
|
|
3240
3286
|
enabled?: boolean;
|
|
3241
|
-
level?:
|
|
3287
|
+
level?: LogLevel;
|
|
3242
3288
|
components?: {
|
|
3243
3289
|
server?: boolean;
|
|
3244
3290
|
cache?: boolean;
|
|
@@ -3261,6 +3307,7 @@ interface ServerOptions {
|
|
|
3261
3307
|
lifecycle?: boolean;
|
|
3262
3308
|
routing?: boolean;
|
|
3263
3309
|
};
|
|
3310
|
+
componentLevels?: Partial<Record<LogComponent, ComponentLogConfig | LogLevel>>;
|
|
3264
3311
|
types?: {
|
|
3265
3312
|
startup?: boolean;
|
|
3266
3313
|
warnings?: boolean;
|
|
@@ -3271,14 +3318,43 @@ interface ServerOptions {
|
|
|
3271
3318
|
portSwitching?: boolean;
|
|
3272
3319
|
lifecycle?: boolean;
|
|
3273
3320
|
};
|
|
3321
|
+
consoleInterception?: DeepPartial<ConsoleInterceptionConfig>;
|
|
3322
|
+
customLogger?: (level: LogLevel, component: LogComponent, message: string, ...args: any[]) => void;
|
|
3274
3323
|
format?: {
|
|
3275
3324
|
timestamps?: boolean;
|
|
3276
3325
|
colors?: boolean;
|
|
3277
3326
|
prefix?: boolean;
|
|
3278
3327
|
compact?: boolean;
|
|
3328
|
+
includeMemory?: boolean;
|
|
3329
|
+
includeProcessId?: boolean;
|
|
3330
|
+
maxLineLength?: number;
|
|
3331
|
+
};
|
|
3332
|
+
buffer?: {
|
|
3333
|
+
enabled?: boolean;
|
|
3334
|
+
maxSize?: number;
|
|
3335
|
+
flushInterval?: number;
|
|
3336
|
+
autoFlush?: boolean;
|
|
3337
|
+
};
|
|
3338
|
+
errorHandling?: {
|
|
3339
|
+
maxErrorsPerMinute?: number;
|
|
3340
|
+
suppressRepeatedErrors?: boolean;
|
|
3341
|
+
suppressAfterCount?: number;
|
|
3342
|
+
resetSuppressionAfter?: number;
|
|
3343
|
+
};
|
|
3344
|
+
file?: {
|
|
3345
|
+
enabled?: boolean;
|
|
3346
|
+
path?: string;
|
|
3347
|
+
maxSize?: number;
|
|
3348
|
+
maxFiles?: number;
|
|
3349
|
+
rotateDaily?: boolean;
|
|
3350
|
+
};
|
|
3351
|
+
remote?: {
|
|
3352
|
+
enabled?: boolean;
|
|
3353
|
+
endpoint?: string;
|
|
3354
|
+
apiKey?: string;
|
|
3355
|
+
batchSize?: number;
|
|
3356
|
+
flushInterval?: number;
|
|
3279
3357
|
};
|
|
3280
|
-
consoleInterception?: DeepPartial<ConsoleInterceptionConfig>;
|
|
3281
|
-
customLogger?: (level: LogLevel, component: LogComponent, message: string, ...args: any[]) => void;
|
|
3282
3358
|
};
|
|
3283
3359
|
/**
|
|
3284
3360
|
* Custom 404 error page configuration.
|
|
@@ -4304,6 +4380,10 @@ declare class ClusterManager extends EventEmitter implements RobustClusterManage
|
|
|
4304
4380
|
* Send message to least loaded worker
|
|
4305
4381
|
*/
|
|
4306
4382
|
sendToLeastLoadedWorker(message: any): Promise<void>;
|
|
4383
|
+
/**
|
|
4384
|
+
* Select worker for request using load balancing strategy
|
|
4385
|
+
*/
|
|
4386
|
+
selectWorkerForRequest(workers: WorkerMetrics[], request?: any): string;
|
|
4307
4387
|
/**
|
|
4308
4388
|
* Register event handler
|
|
4309
4389
|
*/
|
|
@@ -4424,13 +4504,41 @@ declare class ClusterManager extends EventEmitter implements RobustClusterManage
|
|
|
4424
4504
|
|
|
4425
4505
|
/**
|
|
4426
4506
|
* Centralized Logger for FastApi.ts Server
|
|
4427
|
-
* Provides granular control over logging output
|
|
4507
|
+
* Provides granular control over logging output with enhanced robustness
|
|
4428
4508
|
*/
|
|
4429
4509
|
|
|
4430
4510
|
declare class Logger {
|
|
4431
4511
|
private config;
|
|
4432
4512
|
private static instance;
|
|
4513
|
+
private buffer;
|
|
4514
|
+
private flushTimer?;
|
|
4515
|
+
private isDisposed;
|
|
4516
|
+
private logQueue;
|
|
4517
|
+
private isProcessingQueue;
|
|
4518
|
+
private errorCount;
|
|
4519
|
+
private lastErrorTime;
|
|
4520
|
+
private suppressedComponents;
|
|
4433
4521
|
constructor(config?: ServerOptions["logging"]);
|
|
4522
|
+
/**
|
|
4523
|
+
* Initialize log buffer system
|
|
4524
|
+
*/
|
|
4525
|
+
private initializeBuffer;
|
|
4526
|
+
/**
|
|
4527
|
+
* Setup error handling and recovery mechanisms
|
|
4528
|
+
*/
|
|
4529
|
+
private setupErrorHandling;
|
|
4530
|
+
/**
|
|
4531
|
+
* Emergency logging that bypasses normal filtering
|
|
4532
|
+
*/
|
|
4533
|
+
private emergencyLog;
|
|
4534
|
+
/**
|
|
4535
|
+
* Start auto-flush timer for buffered logging
|
|
4536
|
+
*/
|
|
4537
|
+
private startAutoFlush;
|
|
4538
|
+
/**
|
|
4539
|
+
* Flush buffered log entries
|
|
4540
|
+
*/
|
|
4541
|
+
flush(): void;
|
|
4434
4542
|
/**
|
|
4435
4543
|
* Get or create singleton instance
|
|
4436
4544
|
*/
|
|
@@ -4447,14 +4555,38 @@ declare class Logger {
|
|
|
4447
4555
|
* Get current logger configuration (for debugging)
|
|
4448
4556
|
*/
|
|
4449
4557
|
getConfig(): ServerOptions["logging"];
|
|
4558
|
+
/**
|
|
4559
|
+
* Check if we should suppress this log due to error rate limiting
|
|
4560
|
+
*/
|
|
4561
|
+
private shouldSuppressError;
|
|
4450
4562
|
/**
|
|
4451
4563
|
* Check if logging is enabled for a specific component and type
|
|
4452
4564
|
*/
|
|
4453
4565
|
private shouldLog;
|
|
4566
|
+
/**
|
|
4567
|
+
* Get memory usage information
|
|
4568
|
+
*/
|
|
4569
|
+
private getMemoryInfo;
|
|
4570
|
+
/**
|
|
4571
|
+
* Get process ID
|
|
4572
|
+
*/
|
|
4573
|
+
private getProcessId;
|
|
4574
|
+
/**
|
|
4575
|
+
* Truncate message if it exceeds max line length
|
|
4576
|
+
*/
|
|
4577
|
+
private truncateMessage;
|
|
4454
4578
|
/**
|
|
4455
4579
|
* Format log message
|
|
4456
4580
|
*/
|
|
4457
4581
|
private formatMessage;
|
|
4582
|
+
/**
|
|
4583
|
+
* Write log entry to output
|
|
4584
|
+
*/
|
|
4585
|
+
private writeLog;
|
|
4586
|
+
/**
|
|
4587
|
+
* Process log queue
|
|
4588
|
+
*/
|
|
4589
|
+
private processLogQueue;
|
|
4458
4590
|
/**
|
|
4459
4591
|
* Log a message
|
|
4460
4592
|
*/
|
|
@@ -4463,6 +4595,7 @@ declare class Logger {
|
|
|
4463
4595
|
warn(component: LogComponent, message: string, ...args: any[]): void;
|
|
4464
4596
|
info(component: LogComponent, message: string, ...args: any[]): void;
|
|
4465
4597
|
debug(component: LogComponent, message: string, ...args: any[]): void;
|
|
4598
|
+
verbose(component: LogComponent, message: string, ...args: any[]): void;
|
|
4466
4599
|
startup(component: LogComponent, message: string, ...args: any[]): void;
|
|
4467
4600
|
performance(component: LogComponent, message: string, ...args: any[]): void;
|
|
4468
4601
|
hotReload(component: LogComponent, message: string, ...args: any[]): void;
|
|
@@ -4472,6 +4605,28 @@ declare class Logger {
|
|
|
4472
4605
|
getLevel(): LogLevel;
|
|
4473
4606
|
isComponentEnabled(component: LogComponent): boolean;
|
|
4474
4607
|
isTypeEnabled(type: LogType): boolean;
|
|
4608
|
+
/**
|
|
4609
|
+
* Get logging statistics
|
|
4610
|
+
*/
|
|
4611
|
+
getStats(): {
|
|
4612
|
+
errorCount: number;
|
|
4613
|
+
lastErrorTime: number;
|
|
4614
|
+
suppressedComponents: string[];
|
|
4615
|
+
bufferSize: number;
|
|
4616
|
+
queueSize: number;
|
|
4617
|
+
};
|
|
4618
|
+
/**
|
|
4619
|
+
* Clear suppressed components
|
|
4620
|
+
*/
|
|
4621
|
+
clearSuppression(): void;
|
|
4622
|
+
/**
|
|
4623
|
+
* Dispose logger and cleanup resources
|
|
4624
|
+
*/
|
|
4625
|
+
dispose(): void;
|
|
4626
|
+
/**
|
|
4627
|
+
* Create a child logger with component-specific configuration
|
|
4628
|
+
*/
|
|
4629
|
+
child(component: LogComponent, config?: Partial<ServerOptions["logging"]>): Logger;
|
|
4475
4630
|
}
|
|
4476
4631
|
|
|
4477
4632
|
/**
|
|
@@ -5239,6 +5394,77 @@ declare class ConsoleInterceptor {
|
|
|
5239
5394
|
};
|
|
5240
5395
|
}
|
|
5241
5396
|
|
|
5397
|
+
/**
|
|
5398
|
+
* XyPriss Security Middleware
|
|
5399
|
+
* Comprehensive security middleware using proven external libraries
|
|
5400
|
+
*/
|
|
5401
|
+
|
|
5402
|
+
/**
|
|
5403
|
+
* Security middleware class implementing comprehensive protection
|
|
5404
|
+
* Implements SecurityConfig interface to ensure type safety
|
|
5405
|
+
*/
|
|
5406
|
+
declare class SecurityMiddleware implements Required<SecurityConfig> {
|
|
5407
|
+
level: SecurityLevel;
|
|
5408
|
+
csrf: boolean;
|
|
5409
|
+
helmet: boolean;
|
|
5410
|
+
xss: boolean;
|
|
5411
|
+
sqlInjection: boolean;
|
|
5412
|
+
bruteForce: boolean;
|
|
5413
|
+
encryption: Required<SecurityConfig>["encryption"];
|
|
5414
|
+
authentication: Required<SecurityConfig>["authentication"];
|
|
5415
|
+
private helmetMiddleware;
|
|
5416
|
+
private corsMiddleware;
|
|
5417
|
+
private rateLimitMiddleware;
|
|
5418
|
+
private csrfMiddleware;
|
|
5419
|
+
private mongoSanitizeMiddleware;
|
|
5420
|
+
private hppMiddleware;
|
|
5421
|
+
private compressionMiddleware;
|
|
5422
|
+
private sqlInjectionDetector;
|
|
5423
|
+
private logger;
|
|
5424
|
+
constructor(config?: SecurityConfig, logger?: Logger);
|
|
5425
|
+
/**
|
|
5426
|
+
* Initialize all security middleware instances using external libraries
|
|
5427
|
+
*/
|
|
5428
|
+
private initializeMiddleware;
|
|
5429
|
+
/**
|
|
5430
|
+
* Get the main security middleware stack
|
|
5431
|
+
* Returns a single middleware function that applies all security measures
|
|
5432
|
+
*/
|
|
5433
|
+
getMiddleware(): (req: XyPrisRequest, res: XyPrisResponse, next: NextFunction) => void;
|
|
5434
|
+
/**
|
|
5435
|
+
* Apply all security middleware in the correct order
|
|
5436
|
+
*/
|
|
5437
|
+
private applySecurityStack;
|
|
5438
|
+
/**
|
|
5439
|
+
* Execute middleware stack sequentially with proper async handling
|
|
5440
|
+
*/
|
|
5441
|
+
private executeMiddlewareStack;
|
|
5442
|
+
/**
|
|
5443
|
+
* Custom XSS protection middleware
|
|
5444
|
+
*/
|
|
5445
|
+
private xssProtection;
|
|
5446
|
+
/**
|
|
5447
|
+
* Make request properties writable to avoid readonly property errors
|
|
5448
|
+
*/
|
|
5449
|
+
private makeRequestPropertiesWritable;
|
|
5450
|
+
/**
|
|
5451
|
+
* Recursively sanitize object properties
|
|
5452
|
+
*/
|
|
5453
|
+
private sanitizeObject;
|
|
5454
|
+
/**
|
|
5455
|
+
* Sanitize object and detect threats
|
|
5456
|
+
*/
|
|
5457
|
+
private sanitizeObjectWithDetection;
|
|
5458
|
+
/**
|
|
5459
|
+
* Get CSRF token for client-side usage
|
|
5460
|
+
*/
|
|
5461
|
+
generateCsrfToken(req: XyPrisRequest): string | null;
|
|
5462
|
+
/**
|
|
5463
|
+
* Get security configuration
|
|
5464
|
+
*/
|
|
5465
|
+
getConfig(): Required<SecurityConfig>;
|
|
5466
|
+
}
|
|
5467
|
+
|
|
5242
5468
|
/**
|
|
5243
5469
|
* Ultra-Fast Express Server with Advanced Performance Optimization
|
|
5244
5470
|
*/
|
|
@@ -5257,8 +5483,10 @@ declare class XyPrissServer {
|
|
|
5257
5483
|
private clusterManager;
|
|
5258
5484
|
private fileWatcherManager;
|
|
5259
5485
|
private consoleInterceptor;
|
|
5486
|
+
private workerPoolComponent;
|
|
5260
5487
|
private notFoundHandler;
|
|
5261
5488
|
private serverPluginManager;
|
|
5489
|
+
private securityMiddleware?;
|
|
5262
5490
|
private lifecycleManager;
|
|
5263
5491
|
constructor(userOptions?: ServerOptions);
|
|
5264
5492
|
/**
|
|
@@ -5271,11 +5499,17 @@ declare class XyPrissServer {
|
|
|
5271
5499
|
private initializePlugins;
|
|
5272
5500
|
private initializeCluster;
|
|
5273
5501
|
private initializeFileWatcher;
|
|
5502
|
+
private initializeWorkerPool;
|
|
5503
|
+
private initializeSecurity;
|
|
5274
5504
|
private initializeDependentComponents;
|
|
5275
5505
|
/**
|
|
5276
5506
|
* Get the Express app instance (ready to use immediately)
|
|
5277
5507
|
*/
|
|
5278
5508
|
getApp(): UltraFastApp;
|
|
5509
|
+
/**
|
|
5510
|
+
* Get the security middleware instance
|
|
5511
|
+
*/
|
|
5512
|
+
getSecurityMiddleware(): SecurityMiddleware | undefined;
|
|
5279
5513
|
/**
|
|
5280
5514
|
* Get the server plugin manager
|
|
5281
5515
|
*/
|
|
@@ -5553,81 +5787,6 @@ declare function Route(config: Omit<RouteConfig, "security"> & {
|
|
|
5553
5787
|
*/
|
|
5554
5788
|
declare function createOptimalCache(config?: CacheConfig): SecureCacheAdapter;
|
|
5555
5789
|
|
|
5556
|
-
/**
|
|
5557
|
-
* XyPrissJS Security Middleware
|
|
5558
|
-
* Military-grade security middleware for Express applications
|
|
5559
|
-
*/
|
|
5560
|
-
|
|
5561
|
-
declare class SecurityMiddleware {
|
|
5562
|
-
private config;
|
|
5563
|
-
private bruteForceMap;
|
|
5564
|
-
constructor(config?: SecurityConfig);
|
|
5565
|
-
/**
|
|
5566
|
-
* Get the main security middleware
|
|
5567
|
-
*/
|
|
5568
|
-
getMiddleware(): (req: any, res: any, next: any) => void;
|
|
5569
|
-
/**
|
|
5570
|
-
* Apply security headers
|
|
5571
|
-
*/
|
|
5572
|
-
private applySecurityHeaders;
|
|
5573
|
-
/**
|
|
5574
|
-
* Get Content Security Policy header
|
|
5575
|
-
*/
|
|
5576
|
-
private getCSPHeader;
|
|
5577
|
-
/**
|
|
5578
|
-
* Check for brute force attacks
|
|
5579
|
-
*/
|
|
5580
|
-
private checkBruteForce;
|
|
5581
|
-
/**
|
|
5582
|
-
* Detect obfuscated SQL injection attempts using entropy analysis
|
|
5583
|
-
*/
|
|
5584
|
-
private detectObfuscatedSQLInjection;
|
|
5585
|
-
/**
|
|
5586
|
-
* Get client IP address
|
|
5587
|
-
*/
|
|
5588
|
-
private getClientIP;
|
|
5589
|
-
/**
|
|
5590
|
-
* XSS Protection middleware
|
|
5591
|
-
*/
|
|
5592
|
-
xssProtection(): (req: any, res: any, next: any) => any;
|
|
5593
|
-
/**
|
|
5594
|
-
* SQL Injection protection middleware
|
|
5595
|
-
*/
|
|
5596
|
-
sqlInjectionProtection(): (req: any, res: any, next: any) => any;
|
|
5597
|
-
/**
|
|
5598
|
-
* CSRF Protection middleware
|
|
5599
|
-
*/
|
|
5600
|
-
csrfProtection(): (req: any, res: any, next: any) => any;
|
|
5601
|
-
/**
|
|
5602
|
-
* Request encryption middleware
|
|
5603
|
-
*/
|
|
5604
|
-
requestEncryption(): (req: any, res: any, next: any) => any;
|
|
5605
|
-
/**
|
|
5606
|
-
* Sanitize object recursively
|
|
5607
|
-
*/
|
|
5608
|
-
private sanitizeObject;
|
|
5609
|
-
/**
|
|
5610
|
-
* Sanitize string for XSS
|
|
5611
|
-
*/
|
|
5612
|
-
private sanitizeString;
|
|
5613
|
-
/**
|
|
5614
|
-
* Get security configuration
|
|
5615
|
-
*/
|
|
5616
|
-
getConfig(): Required<SecurityConfig>;
|
|
5617
|
-
/**
|
|
5618
|
-
* Get brute force statistics
|
|
5619
|
-
*/
|
|
5620
|
-
getBruteForceStats(): any;
|
|
5621
|
-
/**
|
|
5622
|
-
* Unblock IP address
|
|
5623
|
-
*/
|
|
5624
|
-
unblockIP(ip: string): boolean;
|
|
5625
|
-
/**
|
|
5626
|
-
* Clear all brute force records
|
|
5627
|
-
*/
|
|
5628
|
-
clearBruteForceRecords(): void;
|
|
5629
|
-
}
|
|
5630
|
-
|
|
5631
5790
|
/**
|
|
5632
5791
|
* XyPrissJS Performance Monitor
|
|
5633
5792
|
* Real-time performance monitoring and optimization
|