@zintrust/core 0.1.42 → 0.1.44

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/README.md +1 -0
  2. package/app/Controllers/AuthController.d.ts +10 -0
  3. package/app/Controllers/AuthController.d.ts.map +1 -0
  4. package/app/Controllers/AuthController.js +201 -0
  5. package/app/Controllers/UserController.d.ts +9 -0
  6. package/app/Controllers/UserController.d.ts.map +1 -0
  7. package/app/Controllers/UserController.js +8 -0
  8. package/app/Controllers/UserQueryBuilderController.d.ts +16 -0
  9. package/app/Controllers/UserQueryBuilderController.d.ts.map +1 -0
  10. package/app/Controllers/UserQueryBuilderController.js +404 -0
  11. package/app/Middleware/ProfilerMiddleware.d.ts +12 -0
  12. package/app/Middleware/ProfilerMiddleware.d.ts.map +1 -0
  13. package/app/Middleware/ProfilerMiddleware.js +47 -0
  14. package/app/Middleware/index.d.ts +59 -0
  15. package/app/Middleware/index.d.ts.map +1 -0
  16. package/app/Middleware/index.js +215 -0
  17. package/app/Models/Post.d.ts +14 -0
  18. package/app/Models/Post.d.ts.map +1 -0
  19. package/app/Models/Post.js +27 -0
  20. package/app/Models/User.d.ts +14 -0
  21. package/app/Models/User.d.ts.map +1 -0
  22. package/app/Models/User.js +44 -0
  23. package/app/Schedules/JobTracking.d.ts +3 -0
  24. package/app/Schedules/JobTracking.d.ts.map +1 -0
  25. package/app/Schedules/JobTracking.js +13 -0
  26. package/app/Schedules/index.d.ts +2 -0
  27. package/app/Schedules/index.d.ts.map +1 -0
  28. package/app/Schedules/index.js +1 -0
  29. package/app/Toolkit/Broadcast/sendBroadcast.d.ts +6 -0
  30. package/app/Toolkit/Broadcast/sendBroadcast.d.ts.map +1 -0
  31. package/app/Toolkit/Broadcast/sendBroadcast.js +5 -0
  32. package/app/Toolkit/Mail/sendWelcomeEmail.d.ts +6 -0
  33. package/app/Toolkit/Mail/sendWelcomeEmail.d.ts.map +1 -0
  34. package/app/Toolkit/Mail/sendWelcomeEmail.js +20 -0
  35. package/app/Toolkit/Notification/sendSlackNotification.d.ts +8 -0
  36. package/app/Toolkit/Notification/sendSlackNotification.d.ts.map +1 -0
  37. package/app/Toolkit/Notification/sendSlackNotification.js +5 -0
  38. package/app/Toolkit/Notification/sendSms.d.ts +6 -0
  39. package/app/Toolkit/Notification/sendSms.d.ts.map +1 -0
  40. package/app/Toolkit/Notification/sendSms.js +5 -0
  41. package/app/Types/controller.d.ts +42 -0
  42. package/app/Types/controller.d.ts.map +1 -0
  43. package/app/Types/controller.js +1 -0
  44. package/config/broadcast.d.ts +38 -0
  45. package/config/broadcast.d.ts.map +1 -0
  46. package/config/broadcast.js +37 -0
  47. package/config/cache.d.ts +40 -0
  48. package/config/cache.d.ts.map +1 -0
  49. package/config/cache.js +39 -0
  50. package/config/database.d.ts +58 -0
  51. package/config/database.d.ts.map +1 -0
  52. package/config/database.js +65 -0
  53. package/config/mail.d.ts +51 -0
  54. package/config/mail.d.ts.map +1 -0
  55. package/config/mail.js +69 -0
  56. package/config/middleware.d.ts +11 -0
  57. package/config/middleware.d.ts.map +1 -0
  58. package/config/middleware.js +30 -0
  59. package/config/notification.d.ts +33 -0
  60. package/config/notification.d.ts.map +1 -0
  61. package/config/notification.js +33 -0
  62. package/config/queue.d.ts +55 -0
  63. package/config/queue.d.ts.map +1 -0
  64. package/config/queue.js +87 -0
  65. package/config/storage.d.ts +59 -0
  66. package/config/storage.d.ts.map +1 -0
  67. package/config/storage.js +59 -0
  68. package/config/workers.d.ts +54 -0
  69. package/config/workers.d.ts.map +1 -0
  70. package/config/workers.js +83 -0
  71. package/package.json +12 -5
  72. package/packages/cloudflare-d1-proxy/src/index.d.ts +48 -0
  73. package/packages/cloudflare-d1-proxy/src/index.d.ts.map +1 -0
  74. package/packages/cloudflare-d1-proxy/src/index.js +387 -0
  75. package/packages/cloudflare-kv-proxy/src/index.d.ts +44 -0
  76. package/packages/cloudflare-kv-proxy/src/index.d.ts.map +1 -0
  77. package/packages/cloudflare-kv-proxy/src/index.js +325 -0
  78. package/packages/queue-monitor/src/QueueMonitoringService.d.ts +35 -0
  79. package/packages/queue-monitor/src/QueueMonitoringService.d.ts.map +1 -0
  80. package/packages/queue-monitor/src/QueueMonitoringService.js +194 -0
  81. package/packages/queue-monitor/src/connection.d.ts +3 -0
  82. package/packages/queue-monitor/src/connection.d.ts.map +1 -0
  83. package/packages/queue-monitor/src/connection.js +1 -0
  84. package/packages/queue-monitor/src/dashboard-ui.d.ts +7 -0
  85. package/packages/queue-monitor/src/dashboard-ui.d.ts.map +1 -0
  86. package/packages/queue-monitor/src/dashboard-ui.js +997 -0
  87. package/packages/queue-monitor/src/driver.d.ts +15 -0
  88. package/packages/queue-monitor/src/driver.d.ts.map +1 -0
  89. package/packages/queue-monitor/src/driver.js +115 -0
  90. package/packages/queue-monitor/src/index.d.ts +71 -0
  91. package/packages/queue-monitor/src/index.d.ts.map +1 -0
  92. package/packages/queue-monitor/src/index.js +296 -0
  93. package/packages/queue-monitor/src/metrics.d.ts +27 -0
  94. package/packages/queue-monitor/src/metrics.d.ts.map +1 -0
  95. package/packages/queue-monitor/src/metrics.js +92 -0
  96. package/packages/queue-monitor/src/worker.d.ts +8 -0
  97. package/packages/queue-monitor/src/worker.d.ts.map +1 -0
  98. package/packages/queue-monitor/src/worker.js +35 -0
  99. package/packages/queue-redis/src/BullMQRedisQueue.d.ts +26 -0
  100. package/packages/queue-redis/src/BullMQRedisQueue.d.ts.map +1 -0
  101. package/packages/queue-redis/src/BullMQRedisQueue.js +463 -0
  102. package/packages/queue-redis/src/HttpQueueDriver.d.ts +18 -0
  103. package/packages/queue-redis/src/HttpQueueDriver.d.ts.map +1 -0
  104. package/packages/queue-redis/src/HttpQueueDriver.js +249 -0
  105. package/packages/queue-redis/src/QueueHttpGateway.d.ts +16 -0
  106. package/packages/queue-redis/src/QueueHttpGateway.d.ts.map +1 -0
  107. package/packages/queue-redis/src/QueueHttpGateway.js +217 -0
  108. package/packages/queue-redis/src/RedisPublishClient.d.ts +14 -0
  109. package/packages/queue-redis/src/RedisPublishClient.d.ts.map +1 -0
  110. package/packages/queue-redis/src/RedisPublishClient.js +251 -0
  111. package/packages/queue-redis/src/index.d.ts +12 -0
  112. package/packages/queue-redis/src/index.d.ts.map +1 -0
  113. package/packages/queue-redis/src/index.js +10 -0
  114. package/packages/queue-redis/src/register.d.ts +6 -0
  115. package/packages/queue-redis/src/register.d.ts.map +1 -0
  116. package/packages/queue-redis/src/register.js +21 -0
  117. package/packages/workers/migrations/20260119100000_create_zintrust_workers_table.d.ts +11 -0
  118. package/packages/workers/migrations/20260119100000_create_zintrust_workers_table.d.ts.map +1 -0
  119. package/packages/workers/migrations/20260119100000_create_zintrust_workers_table.js +32 -0
  120. package/packages/workers/migrations/20260123180000_create_queue_jobs_table.d.ts +11 -0
  121. package/packages/workers/migrations/20260123180000_create_queue_jobs_table.d.ts.map +1 -0
  122. package/packages/workers/migrations/20260123180000_create_queue_jobs_table.js +46 -0
  123. package/packages/workers/migrations/20260213142000_create_zintrust_job_tracking_tables.d.ts +7 -0
  124. package/packages/workers/migrations/20260213142000_create_zintrust_job_tracking_tables.d.ts.map +1 -0
  125. package/packages/workers/migrations/20260213142000_create_zintrust_job_tracking_tables.js +44 -0
  126. package/packages/workers/migrations/20260213183000_expand_zintrust_job_tracking_reliability_tables.d.ts +7 -0
  127. package/packages/workers/migrations/20260213183000_expand_zintrust_job_tracking_reliability_tables.d.ts.map +1 -0
  128. package/packages/workers/migrations/20260213183000_expand_zintrust_job_tracking_reliability_tables.js +104 -0
  129. package/packages/workers/src/AnomalyDetection.d.ts +107 -0
  130. package/packages/workers/src/AnomalyDetection.d.ts.map +1 -0
  131. package/packages/workers/src/AnomalyDetection.js +329 -0
  132. package/packages/workers/src/AutoScaler.d.ts +128 -0
  133. package/packages/workers/src/AutoScaler.d.ts.map +1 -0
  134. package/packages/workers/src/AutoScaler.js +425 -0
  135. package/packages/workers/src/BroadcastWorker.d.ts +24 -0
  136. package/packages/workers/src/BroadcastWorker.d.ts.map +1 -0
  137. package/packages/workers/src/BroadcastWorker.js +24 -0
  138. package/packages/workers/src/CanaryController.d.ts +104 -0
  139. package/packages/workers/src/CanaryController.d.ts.map +1 -0
  140. package/packages/workers/src/CanaryController.js +424 -0
  141. package/packages/workers/src/ChaosEngineering.d.ts +80 -0
  142. package/packages/workers/src/ChaosEngineering.d.ts.map +1 -0
  143. package/packages/workers/src/ChaosEngineering.js +229 -0
  144. package/packages/workers/src/CircuitBreaker.d.ts +107 -0
  145. package/packages/workers/src/CircuitBreaker.d.ts.map +1 -0
  146. package/packages/workers/src/CircuitBreaker.js +374 -0
  147. package/packages/workers/src/ClusterLock.d.ts +91 -0
  148. package/packages/workers/src/ClusterLock.d.ts.map +1 -0
  149. package/packages/workers/src/ClusterLock.js +397 -0
  150. package/packages/workers/src/ComplianceManager.d.ts +178 -0
  151. package/packages/workers/src/ComplianceManager.d.ts.map +1 -0
  152. package/packages/workers/src/ComplianceManager.js +556 -0
  153. package/packages/workers/src/DatacenterOrchestrator.d.ts +134 -0
  154. package/packages/workers/src/DatacenterOrchestrator.d.ts.map +1 -0
  155. package/packages/workers/src/DatacenterOrchestrator.js +404 -0
  156. package/packages/workers/src/DeadLetterQueue.d.ts +123 -0
  157. package/packages/workers/src/DeadLetterQueue.d.ts.map +1 -0
  158. package/packages/workers/src/DeadLetterQueue.js +544 -0
  159. package/packages/workers/src/HealthMonitor.d.ts +43 -0
  160. package/packages/workers/src/HealthMonitor.d.ts.map +1 -0
  161. package/packages/workers/src/HealthMonitor.js +312 -0
  162. package/packages/workers/src/MultiQueueWorker.d.ts +90 -0
  163. package/packages/workers/src/MultiQueueWorker.d.ts.map +1 -0
  164. package/packages/workers/src/MultiQueueWorker.js +282 -0
  165. package/packages/workers/src/NotificationWorker.d.ts +24 -0
  166. package/packages/workers/src/NotificationWorker.d.ts.map +1 -0
  167. package/packages/workers/src/NotificationWorker.js +23 -0
  168. package/packages/workers/src/Observability.d.ts +154 -0
  169. package/packages/workers/src/Observability.d.ts.map +1 -0
  170. package/packages/workers/src/Observability.js +538 -0
  171. package/packages/workers/src/PluginManager.d.ts +124 -0
  172. package/packages/workers/src/PluginManager.d.ts.map +1 -0
  173. package/packages/workers/src/PluginManager.js +392 -0
  174. package/packages/workers/src/PriorityQueue.d.ts +118 -0
  175. package/packages/workers/src/PriorityQueue.d.ts.map +1 -0
  176. package/packages/workers/src/PriorityQueue.js +276 -0
  177. package/packages/workers/src/ResourceMonitor.d.ts +165 -0
  178. package/packages/workers/src/ResourceMonitor.d.ts.map +1 -0
  179. package/packages/workers/src/ResourceMonitor.js +632 -0
  180. package/packages/workers/src/SLAMonitor.d.ts +111 -0
  181. package/packages/workers/src/SLAMonitor.d.ts.map +1 -0
  182. package/packages/workers/src/SLAMonitor.js +274 -0
  183. package/packages/workers/src/WorkerFactory.d.ts +218 -0
  184. package/packages/workers/src/WorkerFactory.d.ts.map +1 -0
  185. package/packages/workers/src/WorkerFactory.js +2253 -0
  186. package/packages/workers/src/WorkerInit.d.ts +86 -0
  187. package/packages/workers/src/WorkerInit.d.ts.map +1 -0
  188. package/packages/workers/src/WorkerInit.js +307 -0
  189. package/packages/workers/src/WorkerMetrics.d.ts +116 -0
  190. package/packages/workers/src/WorkerMetrics.d.ts.map +1 -0
  191. package/packages/workers/src/WorkerMetrics.js +570 -0
  192. package/packages/workers/src/WorkerRegistry.d.ts +152 -0
  193. package/packages/workers/src/WorkerRegistry.d.ts.map +1 -0
  194. package/packages/workers/src/WorkerRegistry.js +396 -0
  195. package/packages/workers/src/WorkerShutdown.d.ts +70 -0
  196. package/packages/workers/src/WorkerShutdown.d.ts.map +1 -0
  197. package/packages/workers/src/WorkerShutdown.js +185 -0
  198. package/packages/workers/src/WorkerVersioning.d.ts +108 -0
  199. package/packages/workers/src/WorkerVersioning.d.ts.map +1 -0
  200. package/packages/workers/src/WorkerVersioning.js +300 -0
  201. package/packages/workers/src/config/workerConfig.d.ts +5 -0
  202. package/packages/workers/src/config/workerConfig.d.ts.map +1 -0
  203. package/packages/workers/src/config/workerConfig.js +25 -0
  204. package/packages/workers/src/createQueueWorker.d.ts +26 -0
  205. package/packages/workers/src/createQueueWorker.d.ts.map +1 -0
  206. package/packages/workers/src/createQueueWorker.js +367 -0
  207. package/packages/workers/src/dashboard/index.d.ts +2 -0
  208. package/packages/workers/src/dashboard/index.d.ts.map +1 -0
  209. package/packages/workers/src/dashboard/index.js +1 -0
  210. package/packages/workers/src/dashboard/types.d.ts +123 -0
  211. package/packages/workers/src/dashboard/types.d.ts.map +1 -0
  212. package/packages/workers/src/dashboard/types.js +1 -0
  213. package/packages/workers/src/dashboard/workers-api.d.ts +5 -0
  214. package/packages/workers/src/dashboard/workers-api.d.ts.map +1 -0
  215. package/packages/workers/src/dashboard/workers-api.js +738 -0
  216. package/packages/workers/src/helper/index.d.ts +6 -0
  217. package/packages/workers/src/helper/index.d.ts.map +1 -0
  218. package/packages/workers/src/helper/index.js +10 -0
  219. package/packages/workers/src/http/WorkerApiController.d.ts +39 -0
  220. package/packages/workers/src/http/WorkerApiController.d.ts.map +1 -0
  221. package/packages/workers/src/http/WorkerApiController.js +313 -0
  222. package/packages/workers/src/http/WorkerController.d.ts +375 -0
  223. package/packages/workers/src/http/WorkerController.d.ts.map +1 -0
  224. package/packages/workers/src/http/WorkerController.js +1454 -0
  225. package/packages/workers/src/http/WorkerMonitoringService.d.ts +12 -0
  226. package/packages/workers/src/http/WorkerMonitoringService.d.ts.map +1 -0
  227. package/packages/workers/src/http/WorkerMonitoringService.js +89 -0
  228. package/packages/workers/src/http/middleware/CustomValidation.d.ts +93 -0
  229. package/packages/workers/src/http/middleware/CustomValidation.d.ts.map +1 -0
  230. package/packages/workers/src/http/middleware/CustomValidation.js +270 -0
  231. package/packages/workers/src/http/middleware/DatacenterValidator.d.ts +4 -0
  232. package/packages/workers/src/http/middleware/DatacenterValidator.d.ts.map +1 -0
  233. package/packages/workers/src/http/middleware/DatacenterValidator.js +94 -0
  234. package/packages/workers/src/http/middleware/EditWorkerValidation.d.ts +8 -0
  235. package/packages/workers/src/http/middleware/EditWorkerValidation.d.ts.map +1 -0
  236. package/packages/workers/src/http/middleware/EditWorkerValidation.js +56 -0
  237. package/packages/workers/src/http/middleware/FeaturesValidator.d.ts +4 -0
  238. package/packages/workers/src/http/middleware/FeaturesValidator.d.ts.map +1 -0
  239. package/packages/workers/src/http/middleware/FeaturesValidator.js +60 -0
  240. package/packages/workers/src/http/middleware/InfrastructureValidator.d.ts +32 -0
  241. package/packages/workers/src/http/middleware/InfrastructureValidator.d.ts.map +1 -0
  242. package/packages/workers/src/http/middleware/InfrastructureValidator.js +226 -0
  243. package/packages/workers/src/http/middleware/OptionsValidator.d.ts +4 -0
  244. package/packages/workers/src/http/middleware/OptionsValidator.d.ts.map +1 -0
  245. package/packages/workers/src/http/middleware/OptionsValidator.js +112 -0
  246. package/packages/workers/src/http/middleware/PayloadSanitizer.d.ts +8 -0
  247. package/packages/workers/src/http/middleware/PayloadSanitizer.d.ts.map +1 -0
  248. package/packages/workers/src/http/middleware/PayloadSanitizer.js +42 -0
  249. package/packages/workers/src/http/middleware/ProcessorPathSanitizer.d.ts +4 -0
  250. package/packages/workers/src/http/middleware/ProcessorPathSanitizer.d.ts.map +1 -0
  251. package/packages/workers/src/http/middleware/ProcessorPathSanitizer.js +140 -0
  252. package/packages/workers/src/http/middleware/QueueNameSanitizer.d.ts +4 -0
  253. package/packages/workers/src/http/middleware/QueueNameSanitizer.d.ts.map +1 -0
  254. package/packages/workers/src/http/middleware/QueueNameSanitizer.js +45 -0
  255. package/packages/workers/src/http/middleware/ValidateDriver.d.ts +8 -0
  256. package/packages/workers/src/http/middleware/ValidateDriver.d.ts.map +1 -0
  257. package/packages/workers/src/http/middleware/ValidateDriver.js +20 -0
  258. package/packages/workers/src/http/middleware/VersionSanitizer.d.ts +4 -0
  259. package/packages/workers/src/http/middleware/VersionSanitizer.d.ts.map +1 -0
  260. package/packages/workers/src/http/middleware/VersionSanitizer.js +25 -0
  261. package/packages/workers/src/http/middleware/WorkerNameSanitizer.d.ts +4 -0
  262. package/packages/workers/src/http/middleware/WorkerNameSanitizer.d.ts.map +1 -0
  263. package/packages/workers/src/http/middleware/WorkerNameSanitizer.js +46 -0
  264. package/packages/workers/src/http/middleware/WorkerValidationChain.d.ts +28 -0
  265. package/packages/workers/src/http/middleware/WorkerValidationChain.d.ts.map +1 -0
  266. package/packages/workers/src/http/middleware/WorkerValidationChain.js +186 -0
  267. package/packages/workers/src/index.d.ts +47 -0
  268. package/packages/workers/src/index.d.ts.map +1 -0
  269. package/packages/workers/src/index.js +48 -0
  270. package/packages/workers/src/routes/workers.d.ts +13 -0
  271. package/packages/workers/src/routes/workers.d.ts.map +1 -0
  272. package/packages/workers/src/routes/workers.js +126 -0
  273. package/packages/workers/src/storage/WorkerStore.d.ts +52 -0
  274. package/packages/workers/src/storage/WorkerStore.d.ts.map +1 -0
  275. package/packages/workers/src/storage/WorkerStore.js +259 -0
  276. package/packages/workers/src/telemetry/api/TelemetryAPI.d.ts +47 -0
  277. package/packages/workers/src/telemetry/api/TelemetryAPI.d.ts.map +1 -0
  278. package/packages/workers/src/telemetry/api/TelemetryAPI.js +219 -0
  279. package/packages/workers/src/telemetry/api/TelemetryMonitoringService.d.ts +18 -0
  280. package/packages/workers/src/telemetry/api/TelemetryMonitoringService.d.ts.map +1 -0
  281. package/packages/workers/src/telemetry/api/TelemetryMonitoringService.js +140 -0
  282. package/packages/workers/src/telemetry/components/AlertPanel.d.ts +2 -0
  283. package/packages/workers/src/telemetry/components/AlertPanel.d.ts.map +1 -0
  284. package/packages/workers/src/telemetry/components/AlertPanel.js +13 -0
  285. package/packages/workers/src/telemetry/components/CostTracking.d.ts +2 -0
  286. package/packages/workers/src/telemetry/components/CostTracking.d.ts.map +1 -0
  287. package/packages/workers/src/telemetry/components/CostTracking.js +14 -0
  288. package/packages/workers/src/telemetry/components/ResourceUsageChart.d.ts +2 -0
  289. package/packages/workers/src/telemetry/components/ResourceUsageChart.d.ts.map +1 -0
  290. package/packages/workers/src/telemetry/components/ResourceUsageChart.js +11 -0
  291. package/packages/workers/src/telemetry/components/WorkerHealthChart.d.ts +2 -0
  292. package/packages/workers/src/telemetry/components/WorkerHealthChart.d.ts.map +1 -0
  293. package/packages/workers/src/telemetry/components/WorkerHealthChart.js +11 -0
  294. package/packages/workers/src/telemetry/index.d.ts +16 -0
  295. package/packages/workers/src/telemetry/index.d.ts.map +1 -0
  296. package/packages/workers/src/telemetry/index.js +60 -0
  297. package/packages/workers/src/telemetry/routes/dashboard.d.ts +7 -0
  298. package/packages/workers/src/telemetry/routes/dashboard.d.ts.map +1 -0
  299. package/packages/workers/src/telemetry/routes/dashboard.js +608 -0
  300. package/packages/workers/src/type.d.ts +77 -0
  301. package/packages/workers/src/type.d.ts.map +1 -0
  302. package/packages/workers/src/type.js +1 -0
  303. package/packages/workers/src/ui/router/EmbeddedAssets.d.ts +5 -0
  304. package/packages/workers/src/ui/router/EmbeddedAssets.d.ts.map +1 -0
  305. package/packages/workers/src/ui/router/EmbeddedAssets.js +13 -0
  306. package/packages/workers/src/ui/router/ui.d.ts +4 -0
  307. package/packages/workers/src/ui/router/ui.d.ts.map +1 -0
  308. package/packages/workers/src/ui/router/ui.js +208 -0
  309. package/packages/workers/src/ui/types/worker-ui.d.ts +230 -0
  310. package/packages/workers/src/ui/types/worker-ui.d.ts.map +1 -0
  311. package/packages/workers/src/ui/types/worker-ui.js +5 -0
  312. package/routes/api.d.ts +7 -0
  313. package/routes/api.d.ts.map +1 -0
  314. package/routes/api.js +129 -0
  315. package/routes/broadcast.d.ts +9 -0
  316. package/routes/broadcast.d.ts.map +1 -0
  317. package/routes/broadcast.js +27 -0
  318. package/routes/storage.d.ts +4 -0
  319. package/routes/storage.d.ts.map +1 -0
  320. package/routes/storage.js +35 -0
  321. package/src/cache/Cache.d.ts.map +1 -1
  322. package/src/cache/Cache.js +40 -8
  323. package/src/cache/drivers/KVRemoteDriver.d.ts +1 -1
  324. package/src/cache/drivers/KVRemoteDriver.d.ts.map +1 -1
  325. package/src/cache/drivers/KVRemoteDriver.js +259 -44
  326. package/src/cache/drivers/MemoryDriver.d.ts.map +1 -1
  327. package/src/cache/drivers/MemoryDriver.js +10 -2
  328. package/src/cache/drivers/RedisDriver.d.ts.map +1 -1
  329. package/src/cache/drivers/RedisDriver.js +256 -33
  330. package/src/cli/CLI.d.ts.map +1 -1
  331. package/src/cli/CLI.js +6 -0
  332. package/src/cli/commands/DeployCommand.d.ts.map +1 -1
  333. package/src/cli/commands/DeployCommand.js +12 -1
  334. package/src/cli/commands/DeployContainersProxyCommand.d.ts +5 -0
  335. package/src/cli/commands/DeployContainersProxyCommand.d.ts.map +1 -0
  336. package/src/cli/commands/DeployContainersProxyCommand.js +45 -0
  337. package/src/cli/commands/DockerCommand.d.ts +5 -0
  338. package/src/cli/commands/DockerCommand.d.ts.map +1 -0
  339. package/src/cli/commands/DockerCommand.js +74 -0
  340. package/src/cli/commands/InitContainerCommand.js +10 -10
  341. package/src/cli/commands/InitContainersProxyCommand.d.ts +5 -0
  342. package/src/cli/commands/InitContainersProxyCommand.d.ts.map +1 -0
  343. package/src/cli/commands/InitContainersProxyCommand.js +159 -0
  344. package/src/cli/commands/NewCommand.d.ts.map +1 -1
  345. package/src/cli/commands/NewCommand.js +33 -0
  346. package/src/cli/commands/PutCommand.d.ts.map +1 -1
  347. package/src/cli/commands/PutCommand.js +15 -5
  348. package/src/cli/commands/StartCommand.d.ts.map +1 -1
  349. package/src/cli/commands/StartCommand.js +43 -4
  350. package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
  351. package/src/cli/scaffolding/ProjectScaffolder.js +65 -73
  352. package/src/cli/utils/DistPackager.d.ts.map +1 -1
  353. package/src/cli/utils/DistPackager.js +25 -0
  354. package/src/cli/utils/EnvFileLoader.d.ts +1 -0
  355. package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
  356. package/src/cli/utils/EnvFileLoader.js +14 -0
  357. package/src/common/RemoteSignedJson.d.ts.map +1 -1
  358. package/src/common/RemoteSignedJson.js +9 -2
  359. package/src/config/cache.js +1 -1
  360. package/src/config/env.d.ts +7 -0
  361. package/src/config/env.d.ts.map +1 -1
  362. package/src/config/env.js +8 -0
  363. package/src/config/queue.js +1 -1
  364. package/src/functions/cloudflare.d.ts.map +1 -1
  365. package/src/functions/cloudflare.js +4 -2
  366. package/src/index.js +3 -3
  367. package/src/middleware/JwtAuthMiddleware.d.ts.map +1 -1
  368. package/src/middleware/JwtAuthMiddleware.js +11 -5
  369. package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
  370. package/src/runtime/RuntimeAdapter.js +30 -12
  371. package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
  372. package/src/runtime/adapters/CloudflareAdapter.js +15 -4
  373. package/src/scheduler/Schedule.js +1 -1
  374. package/src/scheduler/leader/SchedulerLeader.js +1 -1
  375. package/src/schedules/job-tracking-cleanup.js +1 -1
  376. package/src/security/TokenRevocation.d.ts +19 -2
  377. package/src/security/TokenRevocation.d.ts.map +1 -1
  378. package/src/security/TokenRevocation.js +558 -30
  379. package/src/templates/project/basic/app/Controllers/AuthController.ts.tpl +11 -3
  380. package/src/templates/project/basic/config/middleware.ts.tpl +23 -22
  381. package/src/templates/project/basic/wrangler.jsonc.tpl +28 -0
@@ -0,0 +1,60 @@
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
+ // Check if features is an object
24
+ if (typeof features !== 'object' || features === null || Array.isArray(features)) {
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 featureKeys = Object.keys(features);
33
+ for (const key of featureKeys) {
34
+ if (!VALID_FEATURES.has(key)) {
35
+ return res.setStatus(400).json({
36
+ error: 'Invalid feature',
37
+ message: `Unknown feature: ${key}. Valid features are: ${Array.from(VALID_FEATURES).join(', ')}`,
38
+ code: 'INVALID_FEATURE',
39
+ });
40
+ }
41
+ const value = features[key];
42
+ if (typeof value !== 'boolean') {
43
+ return res.setStatus(400).json({
44
+ error: 'Invalid feature value',
45
+ message: `Feature ${key} must be a boolean (true or false)`,
46
+ code: 'INVALID_FEATURE_VALUE',
47
+ });
48
+ }
49
+ }
50
+ return handler(req, res);
51
+ }
52
+ catch (error) {
53
+ Logger.error('Features validation failed', error);
54
+ return res.setStatus(500).json({
55
+ error: 'Internal validation error',
56
+ code: 'VALIDATION_ERROR',
57
+ });
58
+ }
59
+ };
60
+ };
@@ -0,0 +1,32 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,226 @@
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
+ };
@@ -0,0 +1,4 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,112 @@
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
+ };
@@ -0,0 +1,8 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,42 @@
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
+ };
@@ -0,0 +1,4 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,140 @@
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('&#x2F;', '/') // HTML hex entity for /
18
+ .replaceAll('%2F', '/') // URL encoding for /
19
+ .replaceAll('&#x2E;', '.') // HTML hex entity for .
20
+ .replaceAll('%2E', '.') // URL encoding for .
21
+ .replaceAll('&#x5F;', '_') // HTML hex entity for _
22
+ .replaceAll('%5F', '_') // URL encoding for _
23
+ .replaceAll('&#x2D;', '-') // 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
+ };
@@ -0,0 +1,4 @@
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
@@ -0,0 +1 @@
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"}