@zintrust/core 0.1.49 → 0.1.50
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/package.json +1 -9
- package/src/config/index.d.ts +1 -1
- package/src/config/index.d.ts.map +1 -1
- package/src/config/index.js +30 -10
- package/src/index.d.ts +0 -2
- package/src/index.d.ts.map +1 -1
- package/src/index.js +3 -5
- package/src/proxy/d1/ZintrustD1Proxy.d.ts +2 -2
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -1
- package/src/proxy/d1/ZintrustD1Proxy.js +39 -2
- package/src/proxy/kv/ZintrustKvProxy.d.ts +2 -2
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -1
- package/src/proxy/kv/ZintrustKvProxy.js +38 -2
- package/src/security/JwtManager.js +1 -1
- package/src/zintrust.comon.d.ts +9 -0
- package/src/zintrust.comon.d.ts.map +1 -0
- package/src/zintrust.comon.js +15 -0
- package/src/zintrust.plugins.d.ts +9 -3
- package/src/zintrust.plugins.d.ts.map +1 -1
- package/src/zintrust.plugins.js +10 -3
- package/src/zintrust.plugins.wg.d.ts +1 -0
- package/src/zintrust.plugins.wg.d.ts.map +1 -1
- package/src/zintrust.plugins.wg.js +1 -0
- package/app/Controllers/AuthController.d.ts +0 -10
- package/app/Controllers/AuthController.d.ts.map +0 -1
- package/app/Controllers/AuthController.js +0 -223
- package/app/Controllers/UserController.d.ts +0 -9
- package/app/Controllers/UserController.d.ts.map +0 -1
- package/app/Controllers/UserController.js +0 -8
- package/app/Controllers/UserQueryBuilderController.d.ts +0 -16
- package/app/Controllers/UserQueryBuilderController.d.ts.map +0 -1
- package/app/Controllers/UserQueryBuilderController.js +0 -404
- package/app/Middleware/ProfilerMiddleware.d.ts +0 -12
- package/app/Middleware/ProfilerMiddleware.d.ts.map +0 -1
- package/app/Middleware/ProfilerMiddleware.js +0 -47
- package/app/Middleware/index.d.ts +0 -59
- package/app/Middleware/index.d.ts.map +0 -1
- package/app/Middleware/index.js +0 -215
- package/app/Models/Post.d.ts +0 -14
- package/app/Models/Post.d.ts.map +0 -1
- package/app/Models/Post.js +0 -27
- package/app/Models/User.d.ts +0 -14
- package/app/Models/User.d.ts.map +0 -1
- package/app/Models/User.js +0 -44
- package/app/Schedules/JobTracking.d.ts +0 -3
- package/app/Schedules/JobTracking.d.ts.map +0 -1
- package/app/Schedules/JobTracking.js +0 -13
- package/app/Schedules/index.d.ts +0 -2
- package/app/Schedules/index.d.ts.map +0 -1
- package/app/Schedules/index.js +0 -1
- package/app/Toolkit/Broadcast/sendBroadcast.d.ts +0 -6
- package/app/Toolkit/Broadcast/sendBroadcast.d.ts.map +0 -1
- package/app/Toolkit/Broadcast/sendBroadcast.js +0 -5
- package/app/Toolkit/Mail/sendWelcomeEmail.d.ts +0 -6
- package/app/Toolkit/Mail/sendWelcomeEmail.d.ts.map +0 -1
- package/app/Toolkit/Mail/sendWelcomeEmail.js +0 -20
- package/app/Toolkit/Notification/sendSlackNotification.d.ts +0 -8
- package/app/Toolkit/Notification/sendSlackNotification.d.ts.map +0 -1
- package/app/Toolkit/Notification/sendSlackNotification.js +0 -5
- package/app/Toolkit/Notification/sendSms.d.ts +0 -6
- package/app/Toolkit/Notification/sendSms.d.ts.map +0 -1
- package/app/Toolkit/Notification/sendSms.js +0 -5
- package/app/Types/controller.d.ts +0 -44
- package/app/Types/controller.d.ts.map +0 -1
- package/app/Types/controller.js +0 -1
- package/config/broadcast.d.ts +0 -38
- package/config/broadcast.d.ts.map +0 -1
- package/config/broadcast.js +0 -37
- package/config/cache.d.ts +0 -40
- package/config/cache.d.ts.map +0 -1
- package/config/cache.js +0 -39
- package/config/database.d.ts +0 -58
- package/config/database.d.ts.map +0 -1
- package/config/database.js +0 -65
- package/config/mail.d.ts +0 -51
- package/config/mail.d.ts.map +0 -1
- package/config/mail.js +0 -69
- package/config/middleware.d.ts +0 -11
- package/config/middleware.d.ts.map +0 -1
- package/config/middleware.js +0 -30
- package/config/notification.d.ts +0 -33
- package/config/notification.d.ts.map +0 -1
- package/config/notification.js +0 -33
- package/config/queue.d.ts +0 -55
- package/config/queue.d.ts.map +0 -1
- package/config/queue.js +0 -87
- package/config/storage.d.ts +0 -59
- package/config/storage.d.ts.map +0 -1
- package/config/storage.js +0 -59
- package/config/workers.d.ts +0 -54
- package/config/workers.d.ts.map +0 -1
- package/config/workers.js +0 -83
- package/packages/cloudflare-d1-proxy/src/index.d.ts +0 -48
- package/packages/cloudflare-d1-proxy/src/index.d.ts.map +0 -1
- package/packages/cloudflare-d1-proxy/src/index.js +0 -387
- package/packages/cloudflare-kv-proxy/src/index.d.ts +0 -44
- package/packages/cloudflare-kv-proxy/src/index.d.ts.map +0 -1
- package/packages/cloudflare-kv-proxy/src/index.js +0 -325
- package/packages/queue-monitor/src/QueueMonitoringService.d.ts +0 -35
- package/packages/queue-monitor/src/QueueMonitoringService.d.ts.map +0 -1
- package/packages/queue-monitor/src/QueueMonitoringService.js +0 -194
- package/packages/queue-monitor/src/connection.d.ts +0 -3
- package/packages/queue-monitor/src/connection.d.ts.map +0 -1
- package/packages/queue-monitor/src/connection.js +0 -1
- package/packages/queue-monitor/src/dashboard-ui.d.ts +0 -7
- package/packages/queue-monitor/src/dashboard-ui.d.ts.map +0 -1
- package/packages/queue-monitor/src/dashboard-ui.js +0 -997
- package/packages/queue-monitor/src/driver.d.ts +0 -15
- package/packages/queue-monitor/src/driver.d.ts.map +0 -1
- package/packages/queue-monitor/src/driver.js +0 -115
- package/packages/queue-monitor/src/index.d.ts +0 -71
- package/packages/queue-monitor/src/index.d.ts.map +0 -1
- package/packages/queue-monitor/src/index.js +0 -296
- package/packages/queue-monitor/src/metrics.d.ts +0 -27
- package/packages/queue-monitor/src/metrics.d.ts.map +0 -1
- package/packages/queue-monitor/src/metrics.js +0 -92
- package/packages/queue-monitor/src/worker.d.ts +0 -8
- package/packages/queue-monitor/src/worker.d.ts.map +0 -1
- package/packages/queue-monitor/src/worker.js +0 -35
- package/packages/queue-redis/src/BullMQRedisQueue.d.ts +0 -26
- package/packages/queue-redis/src/BullMQRedisQueue.d.ts.map +0 -1
- package/packages/queue-redis/src/BullMQRedisQueue.js +0 -463
- package/packages/queue-redis/src/HttpQueueDriver.d.ts +0 -18
- package/packages/queue-redis/src/HttpQueueDriver.d.ts.map +0 -1
- package/packages/queue-redis/src/HttpQueueDriver.js +0 -249
- package/packages/queue-redis/src/QueueHttpGateway.d.ts +0 -16
- package/packages/queue-redis/src/QueueHttpGateway.d.ts.map +0 -1
- package/packages/queue-redis/src/QueueHttpGateway.js +0 -217
- package/packages/queue-redis/src/RedisPublishClient.d.ts +0 -14
- package/packages/queue-redis/src/RedisPublishClient.d.ts.map +0 -1
- package/packages/queue-redis/src/RedisPublishClient.js +0 -251
- package/packages/queue-redis/src/index.d.ts +0 -12
- package/packages/queue-redis/src/index.d.ts.map +0 -1
- package/packages/queue-redis/src/index.js +0 -10
- package/packages/queue-redis/src/register.d.ts +0 -6
- package/packages/queue-redis/src/register.d.ts.map +0 -1
- package/packages/queue-redis/src/register.js +0 -21
- package/packages/workers/migrations/20260119100000_create_zintrust_workers_table.d.ts +0 -11
- package/packages/workers/migrations/20260119100000_create_zintrust_workers_table.d.ts.map +0 -1
- package/packages/workers/migrations/20260119100000_create_zintrust_workers_table.js +0 -32
- package/packages/workers/migrations/20260123180000_create_queue_jobs_table.d.ts +0 -11
- package/packages/workers/migrations/20260123180000_create_queue_jobs_table.d.ts.map +0 -1
- package/packages/workers/migrations/20260123180000_create_queue_jobs_table.js +0 -46
- package/packages/workers/migrations/20260213142000_create_zintrust_job_tracking_tables.d.ts +0 -7
- package/packages/workers/migrations/20260213142000_create_zintrust_job_tracking_tables.d.ts.map +0 -1
- package/packages/workers/migrations/20260213142000_create_zintrust_job_tracking_tables.js +0 -44
- package/packages/workers/migrations/20260213183000_expand_zintrust_job_tracking_reliability_tables.d.ts +0 -7
- package/packages/workers/migrations/20260213183000_expand_zintrust_job_tracking_reliability_tables.d.ts.map +0 -1
- package/packages/workers/migrations/20260213183000_expand_zintrust_job_tracking_reliability_tables.js +0 -104
- package/packages/workers/src/AnomalyDetection.d.ts +0 -107
- package/packages/workers/src/AnomalyDetection.d.ts.map +0 -1
- package/packages/workers/src/AnomalyDetection.js +0 -329
- package/packages/workers/src/AutoScaler.d.ts +0 -128
- package/packages/workers/src/AutoScaler.d.ts.map +0 -1
- package/packages/workers/src/AutoScaler.js +0 -425
- package/packages/workers/src/BroadcastWorker.d.ts +0 -24
- package/packages/workers/src/BroadcastWorker.d.ts.map +0 -1
- package/packages/workers/src/BroadcastWorker.js +0 -24
- package/packages/workers/src/CanaryController.d.ts +0 -104
- package/packages/workers/src/CanaryController.d.ts.map +0 -1
- package/packages/workers/src/CanaryController.js +0 -424
- package/packages/workers/src/ChaosEngineering.d.ts +0 -80
- package/packages/workers/src/ChaosEngineering.d.ts.map +0 -1
- package/packages/workers/src/ChaosEngineering.js +0 -229
- package/packages/workers/src/CircuitBreaker.d.ts +0 -107
- package/packages/workers/src/CircuitBreaker.d.ts.map +0 -1
- package/packages/workers/src/CircuitBreaker.js +0 -374
- package/packages/workers/src/ClusterLock.d.ts +0 -91
- package/packages/workers/src/ClusterLock.d.ts.map +0 -1
- package/packages/workers/src/ClusterLock.js +0 -397
- package/packages/workers/src/ComplianceManager.d.ts +0 -178
- package/packages/workers/src/ComplianceManager.d.ts.map +0 -1
- package/packages/workers/src/ComplianceManager.js +0 -556
- package/packages/workers/src/DatacenterOrchestrator.d.ts +0 -134
- package/packages/workers/src/DatacenterOrchestrator.d.ts.map +0 -1
- package/packages/workers/src/DatacenterOrchestrator.js +0 -404
- package/packages/workers/src/DeadLetterQueue.d.ts +0 -123
- package/packages/workers/src/DeadLetterQueue.d.ts.map +0 -1
- package/packages/workers/src/DeadLetterQueue.js +0 -544
- package/packages/workers/src/HealthMonitor.d.ts +0 -43
- package/packages/workers/src/HealthMonitor.d.ts.map +0 -1
- package/packages/workers/src/HealthMonitor.js +0 -312
- package/packages/workers/src/MultiQueueWorker.d.ts +0 -90
- package/packages/workers/src/MultiQueueWorker.d.ts.map +0 -1
- package/packages/workers/src/MultiQueueWorker.js +0 -282
- package/packages/workers/src/NotificationWorker.d.ts +0 -24
- package/packages/workers/src/NotificationWorker.d.ts.map +0 -1
- package/packages/workers/src/NotificationWorker.js +0 -23
- package/packages/workers/src/Observability.d.ts +0 -154
- package/packages/workers/src/Observability.d.ts.map +0 -1
- package/packages/workers/src/Observability.js +0 -538
- package/packages/workers/src/PluginManager.d.ts +0 -124
- package/packages/workers/src/PluginManager.d.ts.map +0 -1
- package/packages/workers/src/PluginManager.js +0 -392
- package/packages/workers/src/PriorityQueue.d.ts +0 -118
- package/packages/workers/src/PriorityQueue.d.ts.map +0 -1
- package/packages/workers/src/PriorityQueue.js +0 -276
- package/packages/workers/src/ResourceMonitor.d.ts +0 -165
- package/packages/workers/src/ResourceMonitor.d.ts.map +0 -1
- package/packages/workers/src/ResourceMonitor.js +0 -632
- package/packages/workers/src/SLAMonitor.d.ts +0 -111
- package/packages/workers/src/SLAMonitor.d.ts.map +0 -1
- package/packages/workers/src/SLAMonitor.js +0 -274
- package/packages/workers/src/WorkerFactory.d.ts +0 -218
- package/packages/workers/src/WorkerFactory.d.ts.map +0 -1
- package/packages/workers/src/WorkerFactory.js +0 -2253
- package/packages/workers/src/WorkerInit.d.ts +0 -86
- package/packages/workers/src/WorkerInit.d.ts.map +0 -1
- package/packages/workers/src/WorkerInit.js +0 -307
- package/packages/workers/src/WorkerMetrics.d.ts +0 -116
- package/packages/workers/src/WorkerMetrics.d.ts.map +0 -1
- package/packages/workers/src/WorkerMetrics.js +0 -570
- package/packages/workers/src/WorkerRegistry.d.ts +0 -152
- package/packages/workers/src/WorkerRegistry.d.ts.map +0 -1
- package/packages/workers/src/WorkerRegistry.js +0 -396
- package/packages/workers/src/WorkerShutdown.d.ts +0 -70
- package/packages/workers/src/WorkerShutdown.d.ts.map +0 -1
- package/packages/workers/src/WorkerShutdown.js +0 -185
- package/packages/workers/src/WorkerVersioning.d.ts +0 -108
- package/packages/workers/src/WorkerVersioning.d.ts.map +0 -1
- package/packages/workers/src/WorkerVersioning.js +0 -300
- package/packages/workers/src/config/workerConfig.d.ts +0 -5
- package/packages/workers/src/config/workerConfig.d.ts.map +0 -1
- package/packages/workers/src/config/workerConfig.js +0 -25
- package/packages/workers/src/createQueueWorker.d.ts +0 -26
- package/packages/workers/src/createQueueWorker.d.ts.map +0 -1
- package/packages/workers/src/createQueueWorker.js +0 -367
- package/packages/workers/src/dashboard/index.d.ts +0 -2
- package/packages/workers/src/dashboard/index.d.ts.map +0 -1
- package/packages/workers/src/dashboard/index.js +0 -1
- package/packages/workers/src/dashboard/types.d.ts +0 -123
- package/packages/workers/src/dashboard/types.d.ts.map +0 -1
- package/packages/workers/src/dashboard/types.js +0 -1
- package/packages/workers/src/dashboard/workers-api.d.ts +0 -5
- package/packages/workers/src/dashboard/workers-api.d.ts.map +0 -1
- package/packages/workers/src/dashboard/workers-api.js +0 -738
- package/packages/workers/src/helper/index.d.ts +0 -6
- package/packages/workers/src/helper/index.d.ts.map +0 -1
- package/packages/workers/src/helper/index.js +0 -10
- package/packages/workers/src/http/WorkerApiController.d.ts +0 -39
- package/packages/workers/src/http/WorkerApiController.d.ts.map +0 -1
- package/packages/workers/src/http/WorkerApiController.js +0 -313
- package/packages/workers/src/http/WorkerController.d.ts +0 -375
- package/packages/workers/src/http/WorkerController.d.ts.map +0 -1
- package/packages/workers/src/http/WorkerController.js +0 -1454
- package/packages/workers/src/http/WorkerMonitoringService.d.ts +0 -12
- package/packages/workers/src/http/WorkerMonitoringService.d.ts.map +0 -1
- package/packages/workers/src/http/WorkerMonitoringService.js +0 -89
- package/packages/workers/src/http/middleware/CustomValidation.d.ts +0 -93
- package/packages/workers/src/http/middleware/CustomValidation.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/CustomValidation.js +0 -270
- package/packages/workers/src/http/middleware/DatacenterValidator.d.ts +0 -4
- package/packages/workers/src/http/middleware/DatacenterValidator.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/DatacenterValidator.js +0 -94
- package/packages/workers/src/http/middleware/EditWorkerValidation.d.ts +0 -8
- package/packages/workers/src/http/middleware/EditWorkerValidation.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/EditWorkerValidation.js +0 -56
- package/packages/workers/src/http/middleware/FeaturesValidator.d.ts +0 -4
- package/packages/workers/src/http/middleware/FeaturesValidator.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/FeaturesValidator.js +0 -61
- package/packages/workers/src/http/middleware/InfrastructureValidator.d.ts +0 -32
- package/packages/workers/src/http/middleware/InfrastructureValidator.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/InfrastructureValidator.js +0 -226
- package/packages/workers/src/http/middleware/OptionsValidator.d.ts +0 -4
- package/packages/workers/src/http/middleware/OptionsValidator.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/OptionsValidator.js +0 -112
- package/packages/workers/src/http/middleware/PayloadSanitizer.d.ts +0 -8
- package/packages/workers/src/http/middleware/PayloadSanitizer.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/PayloadSanitizer.js +0 -42
- package/packages/workers/src/http/middleware/ProcessorPathSanitizer.d.ts +0 -4
- package/packages/workers/src/http/middleware/ProcessorPathSanitizer.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/ProcessorPathSanitizer.js +0 -140
- package/packages/workers/src/http/middleware/QueueNameSanitizer.d.ts +0 -4
- package/packages/workers/src/http/middleware/QueueNameSanitizer.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/QueueNameSanitizer.js +0 -45
- package/packages/workers/src/http/middleware/ValidateDriver.d.ts +0 -8
- package/packages/workers/src/http/middleware/ValidateDriver.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/ValidateDriver.js +0 -20
- package/packages/workers/src/http/middleware/VersionSanitizer.d.ts +0 -4
- package/packages/workers/src/http/middleware/VersionSanitizer.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/VersionSanitizer.js +0 -25
- package/packages/workers/src/http/middleware/WorkerNameSanitizer.d.ts +0 -4
- package/packages/workers/src/http/middleware/WorkerNameSanitizer.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/WorkerNameSanitizer.js +0 -46
- package/packages/workers/src/http/middleware/WorkerValidationChain.d.ts +0 -28
- package/packages/workers/src/http/middleware/WorkerValidationChain.d.ts.map +0 -1
- package/packages/workers/src/http/middleware/WorkerValidationChain.js +0 -186
- package/packages/workers/src/index.d.ts +0 -47
- package/packages/workers/src/index.d.ts.map +0 -1
- package/packages/workers/src/index.js +0 -48
- package/packages/workers/src/routes/workers.d.ts +0 -13
- package/packages/workers/src/routes/workers.d.ts.map +0 -1
- package/packages/workers/src/routes/workers.js +0 -126
- package/packages/workers/src/storage/WorkerStore.d.ts +0 -52
- package/packages/workers/src/storage/WorkerStore.d.ts.map +0 -1
- package/packages/workers/src/storage/WorkerStore.js +0 -259
- package/packages/workers/src/telemetry/api/TelemetryAPI.d.ts +0 -47
- package/packages/workers/src/telemetry/api/TelemetryAPI.d.ts.map +0 -1
- package/packages/workers/src/telemetry/api/TelemetryAPI.js +0 -219
- package/packages/workers/src/telemetry/api/TelemetryMonitoringService.d.ts +0 -18
- package/packages/workers/src/telemetry/api/TelemetryMonitoringService.d.ts.map +0 -1
- package/packages/workers/src/telemetry/api/TelemetryMonitoringService.js +0 -140
- package/packages/workers/src/telemetry/components/AlertPanel.d.ts +0 -2
- package/packages/workers/src/telemetry/components/AlertPanel.d.ts.map +0 -1
- package/packages/workers/src/telemetry/components/AlertPanel.js +0 -13
- package/packages/workers/src/telemetry/components/CostTracking.d.ts +0 -2
- package/packages/workers/src/telemetry/components/CostTracking.d.ts.map +0 -1
- package/packages/workers/src/telemetry/components/CostTracking.js +0 -14
- package/packages/workers/src/telemetry/components/ResourceUsageChart.d.ts +0 -2
- package/packages/workers/src/telemetry/components/ResourceUsageChart.d.ts.map +0 -1
- package/packages/workers/src/telemetry/components/ResourceUsageChart.js +0 -11
- package/packages/workers/src/telemetry/components/WorkerHealthChart.d.ts +0 -2
- package/packages/workers/src/telemetry/components/WorkerHealthChart.d.ts.map +0 -1
- package/packages/workers/src/telemetry/components/WorkerHealthChart.js +0 -11
- package/packages/workers/src/telemetry/index.d.ts +0 -16
- package/packages/workers/src/telemetry/index.d.ts.map +0 -1
- package/packages/workers/src/telemetry/index.js +0 -60
- package/packages/workers/src/telemetry/routes/dashboard.d.ts +0 -7
- package/packages/workers/src/telemetry/routes/dashboard.d.ts.map +0 -1
- package/packages/workers/src/telemetry/routes/dashboard.js +0 -608
- package/packages/workers/src/type.d.ts +0 -77
- package/packages/workers/src/type.d.ts.map +0 -1
- package/packages/workers/src/type.js +0 -1
- package/packages/workers/src/ui/router/EmbeddedAssets.d.ts +0 -5
- package/packages/workers/src/ui/router/EmbeddedAssets.d.ts.map +0 -1
- package/packages/workers/src/ui/router/EmbeddedAssets.js +0 -13
- package/packages/workers/src/ui/router/ui.d.ts +0 -4
- package/packages/workers/src/ui/router/ui.d.ts.map +0 -1
- package/packages/workers/src/ui/router/ui.js +0 -208
- package/packages/workers/src/ui/types/worker-ui.d.ts +0 -230
- package/packages/workers/src/ui/types/worker-ui.d.ts.map +0 -1
- package/packages/workers/src/ui/types/worker-ui.js +0 -5
- package/routes/api.d.ts +0 -7
- package/routes/api.d.ts.map +0 -1
- package/routes/api.js +0 -136
- package/routes/broadcast.d.ts +0 -9
- package/routes/broadcast.d.ts.map +0 -1
- package/routes/broadcast.js +0 -27
- package/routes/storage.d.ts +0 -4
- package/routes/storage.d.ts.map +0 -1
- package/routes/storage.js +0 -35
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../../../../../src/index.js';
|
|
2
|
-
const VALID_FEATURES = new Set([
|
|
3
|
-
'clustering',
|
|
4
|
-
'metrics',
|
|
5
|
-
'autoScaling',
|
|
6
|
-
'circuitBreaker',
|
|
7
|
-
'deadLetterQueue',
|
|
8
|
-
'resourceMonitoring',
|
|
9
|
-
'compliance',
|
|
10
|
-
'observability',
|
|
11
|
-
'plugins',
|
|
12
|
-
'versioning',
|
|
13
|
-
'datacenterOrchestration',
|
|
14
|
-
]);
|
|
15
|
-
export const withFeaturesValidation = (handler) => {
|
|
16
|
-
return async (req, res) => {
|
|
17
|
-
try {
|
|
18
|
-
const data = req.data();
|
|
19
|
-
const features = data['features'];
|
|
20
|
-
if (!features) {
|
|
21
|
-
return handler(req, res); // Skip validation if features is not provided
|
|
22
|
-
}
|
|
23
|
-
const isPlainObject = Object.prototype.toString.call(features) === '[object Object]' && !Array.isArray(features);
|
|
24
|
-
if (!isPlainObject) {
|
|
25
|
-
return res.setStatus(400).json({
|
|
26
|
-
error: 'Invalid features configuration',
|
|
27
|
-
message: 'Features must be an object',
|
|
28
|
-
code: 'INVALID_FEATURES_TYPE',
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
// Validate each feature key and value
|
|
32
|
-
const featuresObj = features;
|
|
33
|
-
const featureKeys = Object.keys(featuresObj);
|
|
34
|
-
for (const key of featureKeys) {
|
|
35
|
-
if (!VALID_FEATURES.has(key)) {
|
|
36
|
-
return res.setStatus(400).json({
|
|
37
|
-
error: 'Invalid feature',
|
|
38
|
-
message: `Unknown feature: ${key}. Valid features are: ${Array.from(VALID_FEATURES).join(', ')}`,
|
|
39
|
-
code: 'INVALID_FEATURE',
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
const value = featuresObj[key];
|
|
43
|
-
if (typeof value !== 'boolean') {
|
|
44
|
-
return res.setStatus(400).json({
|
|
45
|
-
error: 'Invalid feature value',
|
|
46
|
-
message: `Feature ${key} must be a boolean (true or false)`,
|
|
47
|
-
code: 'INVALID_FEATURE_VALUE',
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return handler(req, res);
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
Logger.error('Features validation failed', error);
|
|
55
|
-
return res.setStatus(500).json({
|
|
56
|
-
error: 'Internal validation error',
|
|
57
|
-
code: 'VALIDATION_ERROR',
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { type IRequest, type IResponse } from '../../../../../src/index.js';
|
|
2
|
-
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
|
-
export interface InfrastructureConfig {
|
|
4
|
-
persistence: {
|
|
5
|
-
driver: string;
|
|
6
|
-
};
|
|
7
|
-
redis: {
|
|
8
|
-
env: boolean;
|
|
9
|
-
host: string;
|
|
10
|
-
port: string;
|
|
11
|
-
db: string;
|
|
12
|
-
password: string;
|
|
13
|
-
};
|
|
14
|
-
deadLetterQueue: {
|
|
15
|
-
policy: string;
|
|
16
|
-
};
|
|
17
|
-
compliance: {
|
|
18
|
-
config: {
|
|
19
|
-
retentionDays: number;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
observability: {
|
|
23
|
-
enabled: boolean;
|
|
24
|
-
};
|
|
25
|
-
autoScaler: {
|
|
26
|
-
enabled: boolean;
|
|
27
|
-
minWorkers: number;
|
|
28
|
-
maxWorkers: number;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export declare const withInfrastructureValidation: (handler: RouteHandler) => RouteHandler;
|
|
32
|
-
//# sourceMappingURL=InfrastructureValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InfrastructureValidator.d.ts","sourceRoot":"","sources":["../../../../../../packages/workers/src/http/middleware/InfrastructureValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAKnF,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,EAAE;QACL,GAAG,EAAE,OAAO,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,eAAe,EAAE;QACf,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,UAAU,EAAE;QACV,MAAM,EAAE;YACN,aAAa,EAAE,MAAM,CAAC;SACvB,CAAC;KACH,CAAC;IACF,aAAa,EAAE;QACb,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,UAAU,EAAE;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAuKD,eAAO,MAAM,4BAA4B,GAAI,SAAS,YAAY,KAAG,YA6FpE,CAAC"}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../../../../../src/index.js';
|
|
2
|
-
const VALID_DRIVERS = new Set(['database', 'redis', 'memory']);
|
|
3
|
-
const VALID_DEAD_LETTER_POLICIES = new Set(['expire', 'retry', 'dead-letter']);
|
|
4
|
-
const validatePersistence = (persistence) => {
|
|
5
|
-
if (!persistence)
|
|
6
|
-
return 'Persistence configuration is required';
|
|
7
|
-
// Validate persistence driver
|
|
8
|
-
if (!persistence.driver) {
|
|
9
|
-
return 'Persistence driver is required';
|
|
10
|
-
}
|
|
11
|
-
if (!VALID_DRIVERS.has(persistence.driver)) {
|
|
12
|
-
return 'Persistence driver must be one of: database, redis, memory';
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
};
|
|
16
|
-
const validateRedis = (redis) => {
|
|
17
|
-
if (!redis)
|
|
18
|
-
return 'Redis configuration is required';
|
|
19
|
-
// Validate env flag
|
|
20
|
-
if (typeof redis.env !== 'boolean') {
|
|
21
|
-
return 'Redis env flag must be a boolean';
|
|
22
|
-
}
|
|
23
|
-
// Validate required fields when not using env
|
|
24
|
-
if (!redis.env) {
|
|
25
|
-
const requiredFieldsError = validateRequiredRedisFields(redis);
|
|
26
|
-
if (requiredFieldsError)
|
|
27
|
-
return requiredFieldsError;
|
|
28
|
-
}
|
|
29
|
-
// Validate string fields
|
|
30
|
-
return validateRedisStringFields(redis);
|
|
31
|
-
};
|
|
32
|
-
const validateRequiredRedisFields = (redis) => {
|
|
33
|
-
if (!redis.host || typeof redis.host !== 'string') {
|
|
34
|
-
return 'Redis host is required when env is false';
|
|
35
|
-
}
|
|
36
|
-
if (redis.port === undefined || redis.port === null) {
|
|
37
|
-
return 'Redis port is required when env is false';
|
|
38
|
-
}
|
|
39
|
-
if (typeof redis.port !== 'string' && typeof redis.port !== 'number') {
|
|
40
|
-
return 'Redis port must be a string or number';
|
|
41
|
-
}
|
|
42
|
-
if (!redis.db || typeof redis.db !== 'string') {
|
|
43
|
-
return 'Redis db is required when env is false';
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
};
|
|
47
|
-
const validateRedisStringFields = (redis) => {
|
|
48
|
-
if (redis.host && typeof redis.host !== 'string') {
|
|
49
|
-
return 'Redis host must be a string';
|
|
50
|
-
}
|
|
51
|
-
if (redis.port && typeof redis.port !== 'string' && typeof redis.port !== 'number') {
|
|
52
|
-
return 'Redis port must be a string or number';
|
|
53
|
-
}
|
|
54
|
-
if (redis.db && typeof redis.db !== 'string') {
|
|
55
|
-
return 'Redis db must be a string';
|
|
56
|
-
}
|
|
57
|
-
if (redis.password && typeof redis.password !== 'string') {
|
|
58
|
-
return 'Redis password must be a string';
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
};
|
|
62
|
-
const validateDeadLetterQueue = (deadLetterQueue) => {
|
|
63
|
-
if (!deadLetterQueue)
|
|
64
|
-
return 'DeadLetterQueue configuration is required';
|
|
65
|
-
// Validate policy
|
|
66
|
-
if (!deadLetterQueue.policy) {
|
|
67
|
-
return 'DeadLetterQueue policy is required';
|
|
68
|
-
}
|
|
69
|
-
if (!VALID_DEAD_LETTER_POLICIES.has(deadLetterQueue.policy)) {
|
|
70
|
-
return 'Policy must be one of: expire, retry, dead-letter';
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
};
|
|
74
|
-
const validateCompliance = (compliance) => {
|
|
75
|
-
if (!compliance)
|
|
76
|
-
return 'Compliance configuration is required';
|
|
77
|
-
if (!compliance.config) {
|
|
78
|
-
return 'Compliance config is required';
|
|
79
|
-
}
|
|
80
|
-
if (typeof compliance.config.retentionDays !== 'number' || compliance.config.retentionDays < 0) {
|
|
81
|
-
return 'Retention days must be a non-negative number';
|
|
82
|
-
}
|
|
83
|
-
const MAX_RETENTION_DAYS = 3650; // ~10 years
|
|
84
|
-
if (compliance.config.retentionDays > MAX_RETENTION_DAYS) {
|
|
85
|
-
return `Retention days cannot exceed ${MAX_RETENTION_DAYS}`;
|
|
86
|
-
}
|
|
87
|
-
return null;
|
|
88
|
-
};
|
|
89
|
-
const validateObservability = (observability) => {
|
|
90
|
-
if (!observability)
|
|
91
|
-
return 'Observability configuration is required';
|
|
92
|
-
if (typeof observability.enabled !== 'boolean') {
|
|
93
|
-
return 'Observability enabled flag must be a boolean';
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
};
|
|
97
|
-
const validateAutoScaler = (autoScaler) => {
|
|
98
|
-
if (!autoScaler)
|
|
99
|
-
return 'AutoScaler configuration is required';
|
|
100
|
-
if (typeof autoScaler.enabled !== 'boolean') {
|
|
101
|
-
return 'AutoScaler enabled flag must be a boolean';
|
|
102
|
-
}
|
|
103
|
-
if (autoScaler.enabled) {
|
|
104
|
-
const minWorkersError = validateWorkerCount(autoScaler.minWorkers, 'minWorkers');
|
|
105
|
-
if (minWorkersError)
|
|
106
|
-
return minWorkersError;
|
|
107
|
-
const maxWorkersError = validateWorkerCount(autoScaler.maxWorkers, 'maxWorkers');
|
|
108
|
-
if (maxWorkersError)
|
|
109
|
-
return maxWorkersError;
|
|
110
|
-
if (autoScaler.minWorkers > autoScaler.maxWorkers) {
|
|
111
|
-
return 'AutoScaler minWorkers cannot be greater than maxWorkers';
|
|
112
|
-
}
|
|
113
|
-
const MAX_AUTOSCALER_WORKERS = 1000;
|
|
114
|
-
if (autoScaler.maxWorkers > MAX_AUTOSCALER_WORKERS) {
|
|
115
|
-
return `AutoScaler maxWorkers cannot exceed ${MAX_AUTOSCALER_WORKERS}`;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return null;
|
|
119
|
-
};
|
|
120
|
-
const validateWorkerCount = (value, fieldName) => {
|
|
121
|
-
if (typeof value !== 'number') {
|
|
122
|
-
return `AutoScaler ${fieldName} must be a number`;
|
|
123
|
-
}
|
|
124
|
-
if (!Number.isInteger(value)) {
|
|
125
|
-
return `AutoScaler ${fieldName} must be a whole number (integer)`;
|
|
126
|
-
}
|
|
127
|
-
if (value < 0) {
|
|
128
|
-
return `AutoScaler ${fieldName} must be a non-negative number`;
|
|
129
|
-
}
|
|
130
|
-
return null;
|
|
131
|
-
};
|
|
132
|
-
const sanitizeInfrastructure = (infrastructure) => {
|
|
133
|
-
return {
|
|
134
|
-
...infrastructure,
|
|
135
|
-
autoScaler: {
|
|
136
|
-
...infrastructure.autoScaler,
|
|
137
|
-
minWorkers: Math.floor(infrastructure.autoScaler.minWorkers),
|
|
138
|
-
maxWorkers: Math.floor(infrastructure.autoScaler.maxWorkers),
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
};
|
|
142
|
-
export const withInfrastructureValidation = (handler) => {
|
|
143
|
-
return async (req, res) => {
|
|
144
|
-
try {
|
|
145
|
-
const data = req.data();
|
|
146
|
-
const infrastructure = data['infrastructure'];
|
|
147
|
-
if (!infrastructure) {
|
|
148
|
-
return res.setStatus(400).json({
|
|
149
|
-
error: 'Infrastructure configuration is required',
|
|
150
|
-
code: 'MISSING_INFRASTRUCTURE',
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
// Validate persistence
|
|
154
|
-
const persistenceError = validatePersistence(infrastructure.persistence);
|
|
155
|
-
if (persistenceError) {
|
|
156
|
-
return res.setStatus(400).json({
|
|
157
|
-
error: 'Invalid persistence configuration',
|
|
158
|
-
message: persistenceError,
|
|
159
|
-
code: 'INVALID_PERSISTENCE_CONFIG',
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
// Validate redis
|
|
163
|
-
const redisError = validateRedis(infrastructure.redis);
|
|
164
|
-
if (redisError) {
|
|
165
|
-
return res.setStatus(400).json({
|
|
166
|
-
error: 'Invalid redis configuration',
|
|
167
|
-
message: redisError,
|
|
168
|
-
code: 'INVALID_REDIS_CONFIG',
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
// Validate deadLetterQueue
|
|
172
|
-
const deadLetterQueueError = validateDeadLetterQueue(infrastructure.deadLetterQueue);
|
|
173
|
-
if (deadLetterQueueError) {
|
|
174
|
-
return res.setStatus(400).json({
|
|
175
|
-
error: 'Invalid deadLetterQueue configuration',
|
|
176
|
-
message: deadLetterQueueError,
|
|
177
|
-
code: 'INVALID_DEAD_LETTER_QUEUE_CONFIG',
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
// Validate compliance
|
|
181
|
-
const complianceError = validateCompliance(infrastructure.compliance);
|
|
182
|
-
if (complianceError) {
|
|
183
|
-
return res.setStatus(400).json({
|
|
184
|
-
error: 'Invalid compliance configuration',
|
|
185
|
-
message: complianceError,
|
|
186
|
-
code: 'INVALID_COMPLIANCE_CONFIG',
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
// Validate observability
|
|
190
|
-
const observabilityError = validateObservability(infrastructure.observability);
|
|
191
|
-
if (observabilityError) {
|
|
192
|
-
return res.setStatus(400).json({
|
|
193
|
-
error: 'Invalid observability configuration',
|
|
194
|
-
message: observabilityError,
|
|
195
|
-
code: 'INVALID_OBSERVABILITY_CONFIG',
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
// Validate autoScaler
|
|
199
|
-
const autoScalerError = validateAutoScaler(infrastructure.autoScaler);
|
|
200
|
-
if (autoScalerError) {
|
|
201
|
-
return res.setStatus(400).json({
|
|
202
|
-
error: 'Invalid autoScaler configuration',
|
|
203
|
-
message: autoScalerError,
|
|
204
|
-
code: 'INVALID_AUTO_SCALER_CONFIG',
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
// Sanitize infrastructure values
|
|
208
|
-
const currentBody = req.getBody();
|
|
209
|
-
const sanitizedInfrastructure = sanitizeInfrastructure(infrastructure);
|
|
210
|
-
// Update the infrastructure in the request body
|
|
211
|
-
const updatedBody = {
|
|
212
|
-
...currentBody,
|
|
213
|
-
infrastructure: sanitizedInfrastructure,
|
|
214
|
-
};
|
|
215
|
-
req.setBody(updatedBody);
|
|
216
|
-
return handler(req, res);
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
Logger.error('Infrastructure validation failed', error);
|
|
220
|
-
return res.setStatus(500).json({
|
|
221
|
-
error: 'Internal validation error',
|
|
222
|
-
code: 'VALIDATION_ERROR',
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type IRequest, type IResponse } from '../../../../../src/index.js';
|
|
2
|
-
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
|
-
export declare const withOptionsValidation: (handler: RouteHandler) => RouteHandler;
|
|
4
|
-
//# sourceMappingURL=OptionsValidator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OptionsValidator.d.ts","sourceRoot":"","sources":["../../../../../../packages/workers/src/http/middleware/OptionsValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAqFnF,eAAO,MAAM,qBAAqB,GAAI,SAAS,YAAY,KAAG,YAwD7D,CAAC"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../../../../../src/index.js';
|
|
2
|
-
const validateConcurrency = (concurrency) => {
|
|
3
|
-
if (concurrency === undefined || concurrency === null) {
|
|
4
|
-
return 'Concurrency is required';
|
|
5
|
-
}
|
|
6
|
-
if (typeof concurrency !== 'number') {
|
|
7
|
-
return 'Concurrency must be a number';
|
|
8
|
-
}
|
|
9
|
-
if (!Number.isInteger(concurrency)) {
|
|
10
|
-
return 'Concurrency must be a whole number (integer)';
|
|
11
|
-
}
|
|
12
|
-
if (concurrency < 1) {
|
|
13
|
-
return 'Concurrency must be at least 1';
|
|
14
|
-
}
|
|
15
|
-
const MAX_CONCURRENCY = 200;
|
|
16
|
-
if (concurrency > MAX_CONCURRENCY) {
|
|
17
|
-
return `Concurrency cannot exceed ${MAX_CONCURRENCY}`;
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
};
|
|
21
|
-
const validateLimiter = (limiter) => {
|
|
22
|
-
if (!limiter) {
|
|
23
|
-
return 'Limiter configuration is required';
|
|
24
|
-
}
|
|
25
|
-
// Validate max
|
|
26
|
-
if (limiter.max === undefined || limiter.max === null) {
|
|
27
|
-
return 'Limiter max is required';
|
|
28
|
-
}
|
|
29
|
-
if (typeof limiter.max !== 'number') {
|
|
30
|
-
return 'Limiter max must be a number';
|
|
31
|
-
}
|
|
32
|
-
if (!Number.isInteger(limiter.max)) {
|
|
33
|
-
return 'Limiter max must be a whole number (integer)';
|
|
34
|
-
}
|
|
35
|
-
if (limiter.max < 1) {
|
|
36
|
-
return 'Limiter max must be at least 1';
|
|
37
|
-
}
|
|
38
|
-
const MAX_LIMITER_MAX = 100000;
|
|
39
|
-
if (limiter.max > MAX_LIMITER_MAX) {
|
|
40
|
-
return `Limiter max cannot exceed ${MAX_LIMITER_MAX}`;
|
|
41
|
-
}
|
|
42
|
-
// Validate duration
|
|
43
|
-
if (limiter.duration === undefined || limiter.duration === null) {
|
|
44
|
-
return 'Limiter duration is required';
|
|
45
|
-
}
|
|
46
|
-
if (typeof limiter.duration !== 'number') {
|
|
47
|
-
return 'Limiter duration must be a number';
|
|
48
|
-
}
|
|
49
|
-
if (!Number.isInteger(limiter.duration)) {
|
|
50
|
-
return 'Limiter duration must be a whole number (integer)';
|
|
51
|
-
}
|
|
52
|
-
if (limiter.duration < 1000) {
|
|
53
|
-
return 'Limiter duration must be at least 1000ms';
|
|
54
|
-
}
|
|
55
|
-
const MAX_LIMITER_DURATION = 24 * 60 * 60 * 1000; // 1 day
|
|
56
|
-
if (limiter.duration > MAX_LIMITER_DURATION) {
|
|
57
|
-
return `Limiter duration cannot exceed ${MAX_LIMITER_DURATION} ms`;
|
|
58
|
-
}
|
|
59
|
-
return null;
|
|
60
|
-
};
|
|
61
|
-
export const withOptionsValidation = (handler) => {
|
|
62
|
-
return async (req, res) => {
|
|
63
|
-
try {
|
|
64
|
-
const data = req.data();
|
|
65
|
-
const options = data['options'];
|
|
66
|
-
if (!options) {
|
|
67
|
-
return res.setStatus(400).json({
|
|
68
|
-
error: 'Options configuration is required',
|
|
69
|
-
code: 'MISSING_OPTIONS',
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
// Validate concurrency
|
|
73
|
-
const concurrencyError = validateConcurrency(options.concurrency);
|
|
74
|
-
if (concurrencyError) {
|
|
75
|
-
return res.setStatus(400).json({
|
|
76
|
-
error: 'Invalid concurrency',
|
|
77
|
-
message: concurrencyError,
|
|
78
|
-
code: 'INVALID_CONCURRENCY',
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
// Validate limiter
|
|
82
|
-
const limiterError = validateLimiter(options.limiter);
|
|
83
|
-
if (limiterError) {
|
|
84
|
-
return res.setStatus(400).json({
|
|
85
|
-
error: 'Invalid limiter configuration',
|
|
86
|
-
message: limiterError,
|
|
87
|
-
code: 'INVALID_LIMITER_CONFIG',
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
// Sanitize concurrency to ensure it's an integer
|
|
91
|
-
const currentBody = req.getBody();
|
|
92
|
-
const sanitizedOptions = {
|
|
93
|
-
...options,
|
|
94
|
-
concurrency: Math.floor(options.concurrency),
|
|
95
|
-
limiter: {
|
|
96
|
-
...options.limiter,
|
|
97
|
-
max: Math.floor(options.limiter.max),
|
|
98
|
-
duration: Math.floor(options.limiter.duration),
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
req.setBody({ ...currentBody, options: sanitizedOptions });
|
|
102
|
-
return handler(req, res);
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
Logger.error('Options validation failed', error);
|
|
106
|
-
return res.setStatus(500).json({
|
|
107
|
-
error: 'Internal validation error',
|
|
108
|
-
code: 'VALIDATION_ERROR',
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { type IRequest, type IResponse } from '../../../../../src/index.js';
|
|
2
|
-
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
|
-
/**
|
|
4
|
-
* Middleware to strip unknown properties from the request body.
|
|
5
|
-
* Only properties included in the allowedKeys list are preserved.
|
|
6
|
-
*/
|
|
7
|
-
export declare const withStrictPayloadKeys: (allowedKeys: string[], handler: RouteHandler) => RouteHandler;
|
|
8
|
-
//# sourceMappingURL=PayloadSanitizer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PayloadSanitizer.d.ts","sourceRoot":"","sources":["../../../../../../packages/workers/src/http/middleware/PayloadSanitizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAEnF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAChC,aAAa,MAAM,EAAE,EACrB,SAAS,YAAY,KACpB,YAwCF,CAAC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Logger } from '../../../../../src/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Middleware to strip unknown properties from the request body.
|
|
4
|
-
* Only properties included in the allowedKeys list are preserved.
|
|
5
|
-
*/
|
|
6
|
-
export const withStrictPayloadKeys = (allowedKeys, handler) => {
|
|
7
|
-
const allowedSet = new Set(allowedKeys);
|
|
8
|
-
return async (req, res) => {
|
|
9
|
-
try {
|
|
10
|
-
const data = req.data();
|
|
11
|
-
if (!data || typeof data !== 'object' || Array.isArray(data)) {
|
|
12
|
-
// If body is not an object, skip stripping or strictly enforce object?
|
|
13
|
-
// For worker creation, it must be an object.
|
|
14
|
-
// Let's rely on downstream validators to complain if data is missing/wrong type.
|
|
15
|
-
return handler(req, res);
|
|
16
|
-
}
|
|
17
|
-
const body = data;
|
|
18
|
-
const strippedBody = {};
|
|
19
|
-
let hasUnknowns = false;
|
|
20
|
-
for (const key of Object.keys(body)) {
|
|
21
|
-
if (allowedSet.has(key)) {
|
|
22
|
-
strippedBody[key] = body[key];
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
hasUnknowns = true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (hasUnknowns) {
|
|
29
|
-
// Update the body with sanitized version
|
|
30
|
-
req.setBody(strippedBody);
|
|
31
|
-
}
|
|
32
|
-
return handler(req, res);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
Logger.error('Strict payload validation failed', error);
|
|
36
|
-
return res.setStatus(500).json({
|
|
37
|
-
error: 'Internal validation error',
|
|
38
|
-
code: 'VALIDATION_ERROR',
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type IRequest, type IResponse } from '../../../../../src/index.js';
|
|
2
|
-
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
|
-
export declare const withProcessorPathValidation: (handler: RouteHandler) => RouteHandler;
|
|
4
|
-
//# sourceMappingURL=ProcessorPathSanitizer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProcessorPathSanitizer.d.ts","sourceRoot":"","sources":["../../../../../../packages/workers/src/http/middleware/ProcessorPathSanitizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,SAAS,EACf,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AA4GnF,eAAO,MAAM,2BAA2B,GAAI,SAAS,YAAY,KAAG,YAwDnE,CAAC"}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { Logger, NodeSingletons, workersConfig, } from '../../../../../src/index.js';
|
|
2
|
-
const PROCESSOR_PATH_PATTERN = /^[a-zA-Z0-9/_.-]+\.(ts|js|mjs|cjs)$/;
|
|
3
|
-
const isUrlSpec = (value) => {
|
|
4
|
-
if (value.startsWith('url:'))
|
|
5
|
-
return true;
|
|
6
|
-
return value.includes('://');
|
|
7
|
-
};
|
|
8
|
-
const normalizeUrlSpec = (value) => {
|
|
9
|
-
return value.startsWith('url:') ? value.slice(4) : value;
|
|
10
|
-
};
|
|
11
|
-
const isAllowedRemoteHost = (host) => {
|
|
12
|
-
const allowlist = workersConfig.processorSpec.remoteAllowlist;
|
|
13
|
-
return allowlist.map((value) => value.toLowerCase()).includes(host.toLowerCase());
|
|
14
|
-
};
|
|
15
|
-
const decodeProcessorPath = (processor) => {
|
|
16
|
-
return processor
|
|
17
|
-
.replaceAll('/', '/') // HTML hex entity for /
|
|
18
|
-
.replaceAll('%2F', '/') // URL encoding for /
|
|
19
|
-
.replaceAll('.', '.') // HTML hex entity for .
|
|
20
|
-
.replaceAll('%2E', '.') // URL encoding for .
|
|
21
|
-
.replaceAll('_', '_') // HTML hex entity for _
|
|
22
|
-
.replaceAll('%5F', '_') // URL encoding for _
|
|
23
|
-
.replaceAll('-', '-') // HTML hex entity for -
|
|
24
|
-
.replaceAll('%2D', '-'); // URL encoding for -
|
|
25
|
-
};
|
|
26
|
-
const validateUrlSpec = (processor) => {
|
|
27
|
-
const normalized = normalizeUrlSpec(processor);
|
|
28
|
-
let parsed;
|
|
29
|
-
try {
|
|
30
|
-
parsed = new URL(normalized);
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return {
|
|
34
|
-
isValid: false,
|
|
35
|
-
error: { error: 'Invalid processor url', code: 'INVALID_PROCESSOR_URL' },
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
if (parsed.protocol === 'file:') {
|
|
39
|
-
const path = NodeSingletons.path;
|
|
40
|
-
const baseDir = path.resolve(process.cwd());
|
|
41
|
-
const resolved = path.resolve(baseDir, decodeURIComponent(parsed.pathname));
|
|
42
|
-
if (!resolved.startsWith(baseDir)) {
|
|
43
|
-
return {
|
|
44
|
-
isValid: false,
|
|
45
|
-
error: { error: 'Invalid processor path', code: 'INVALID_PROCESSOR_PATH_TRAVERSAL' },
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
if (parsed.protocol !== 'https:') {
|
|
51
|
-
return {
|
|
52
|
-
isValid: false,
|
|
53
|
-
error: { error: 'Invalid processor url', code: 'INVALID_PROCESSOR_URL' },
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (!isAllowedRemoteHost(parsed.host)) {
|
|
57
|
-
return {
|
|
58
|
-
isValid: false,
|
|
59
|
-
error: { error: 'Invalid processor url host', code: 'INVALID_PROCESSOR_URL_HOST' },
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return { isValid: true };
|
|
64
|
-
};
|
|
65
|
-
const validateRelativePath = (processor) => {
|
|
66
|
-
if (processor.includes('..') || processor.startsWith('/')) {
|
|
67
|
-
return {
|
|
68
|
-
isValid: false,
|
|
69
|
-
error: { error: 'Invalid processor path', code: 'INVALID_PROCESSOR_PATH' },
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
if (!PROCESSOR_PATH_PATTERN.test(processor)) {
|
|
73
|
-
return {
|
|
74
|
-
isValid: false,
|
|
75
|
-
error: { error: 'Invalid processor path', code: 'INVALID_PROCESSOR_EXTENSION' },
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
return { isValid: true };
|
|
79
|
-
};
|
|
80
|
-
const sanitizeAndResolvePath = (processor) => {
|
|
81
|
-
const sanitizedProcessor = processor.replaceAll(/[^a-zA-Z0-9/_.-]/g, '');
|
|
82
|
-
const path = NodeSingletons.path;
|
|
83
|
-
const baseDir = path.resolve(process.cwd());
|
|
84
|
-
const resolved = path.resolve(baseDir, sanitizedProcessor);
|
|
85
|
-
if (!resolved.startsWith(baseDir)) {
|
|
86
|
-
return { isValid: false, sanitized: processor };
|
|
87
|
-
}
|
|
88
|
-
return { isValid: true, sanitized: sanitizedProcessor };
|
|
89
|
-
};
|
|
90
|
-
export const withProcessorPathValidation = (handler) => {
|
|
91
|
-
return async (req, res) => {
|
|
92
|
-
try {
|
|
93
|
-
const data = req.data();
|
|
94
|
-
let processor = data['processor'];
|
|
95
|
-
if (!processor) {
|
|
96
|
-
return res.setStatus(400).json({
|
|
97
|
-
error: 'Processor spec is required',
|
|
98
|
-
code: 'MISSING_PROCESSOR_SPEC',
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
// Decode URL-encoded characters
|
|
102
|
-
processor = decodeProcessorPath(processor);
|
|
103
|
-
// Trim whitespace
|
|
104
|
-
processor = processor.trim();
|
|
105
|
-
const isUrl = isUrlSpec(processor);
|
|
106
|
-
let validation;
|
|
107
|
-
if (isUrl) {
|
|
108
|
-
validation = validateUrlSpec(processor);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
validation = validateRelativePath(processor);
|
|
112
|
-
if (validation.isValid) {
|
|
113
|
-
const pathValidation = sanitizeAndResolvePath(processor);
|
|
114
|
-
if (pathValidation.isValid) {
|
|
115
|
-
processor = pathValidation.sanitized;
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
validation = {
|
|
119
|
-
isValid: false,
|
|
120
|
-
error: { error: 'Invalid processor path', code: 'INVALID_PROCESSOR_PATH_TRAVERSAL' },
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (!validation.isValid) {
|
|
126
|
-
return res.setStatus(400).json(validation.error);
|
|
127
|
-
}
|
|
128
|
-
const currentBody = req.getBody();
|
|
129
|
-
req.setBody({ ...currentBody, processor });
|
|
130
|
-
return handler(req, res);
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
Logger.error('Processor path validation failed', error);
|
|
134
|
-
return res.setStatus(500).json({
|
|
135
|
-
error: 'Internal validation error',
|
|
136
|
-
code: 'VALIDATION_ERROR',
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type IRequest, type IResponse } from '../../../../../src/index.js';
|
|
2
|
-
export type RouteHandler = (req: IRequest, res: IResponse) => Promise<void> | void;
|
|
3
|
-
export declare const withQueueNameValidation: (handler: RouteHandler) => RouteHandler;
|
|
4
|
-
//# sourceMappingURL=QueueNameSanitizer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueueNameSanitizer.d.ts","sourceRoot":"","sources":["../../../../../../packages/workers/src/http/middleware/QueueNameSanitizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEvE,MAAM,MAAM,YAAY,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAInF,eAAO,MAAM,uBAAuB,GAAI,SAAS,YAAY,KAAG,YAgD/D,CAAC"}
|