@zintrust/core 0.1.39 → 0.1.41
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/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +22 -1
- package/package.json +8 -4
- package/public/error-pages/404.html +2 -2
- package/src/auth/Auth.js +1 -1
- package/src/boot/Application.d.ts +1 -16
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +2 -262
- package/src/boot/Server.d.ts +1 -1
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/bootstrap.js +23 -9
- package/src/boot/registry/registerRoute.d.ts +6 -0
- package/src/boot/registry/registerRoute.d.ts.map +1 -0
- package/src/boot/registry/registerRoute.js +96 -0
- package/src/boot/registry/runtime.d.ts +15 -0
- package/src/boot/registry/runtime.d.ts.map +1 -0
- package/src/boot/registry/runtime.js +353 -0
- package/src/boot/registry/type.d.ts +25 -0
- package/src/boot/registry/type.d.ts.map +1 -0
- package/src/boot/registry/type.js +1 -0
- package/src/boot/registry/worker.d.ts +6 -0
- package/src/boot/registry/worker.d.ts.map +1 -0
- package/src/boot/registry/worker.js +35 -0
- package/src/cache/drivers/KVRemoteDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVRemoteDriver.js +14 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +82 -34
- package/src/cli/ErrorHandler.js +1 -1
- package/src/cli/commands/ContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/ContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerProxiesCommand.js +77 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/ContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/ContainerWorkersCommand.js +57 -0
- package/src/cli/commands/DeployCommand.d.ts +16 -0
- package/src/cli/commands/DeployCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployCommand.js +110 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerProxiesCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerProxiesCommand.js +27 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts +5 -0
- package/src/cli/commands/DeployContainerWorkersCommand.d.ts.map +1 -0
- package/src/cli/commands/DeployContainerWorkersCommand.js +27 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts +3 -0
- package/src/cli/commands/DockerComposeCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/DockerComposeCommandUtils.js +34 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts +5 -0
- package/src/cli/commands/DoctorArchitectureCommand.d.ts.map +1 -0
- package/src/cli/commands/DoctorArchitectureCommand.js +54 -0
- package/src/cli/commands/InitContainerCommand.d.ts +5 -0
- package/src/cli/commands/InitContainerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitContainerCommand.js +216 -0
- package/src/cli/commands/InitProducerCommand.d.ts +5 -0
- package/src/cli/commands/InitProducerCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProducerCommand.js +47 -0
- package/src/cli/commands/InitProxyCommand.d.ts +5 -0
- package/src/cli/commands/InitProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/InitProxyCommand.js +442 -0
- package/src/cli/commands/MongoDBProxyCommand.d.ts +5 -0
- package/src/cli/commands/MongoDBProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MongoDBProxyCommand.js +98 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts +6 -0
- package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/MySqlProxyCommand.js +32 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts +6 -0
- package/src/cli/commands/PostgresProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/PostgresProxyCommand.js +32 -0
- package/src/cli/commands/ProxyCommand.d.ts +12 -0
- package/src/cli/commands/ProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommand.js +80 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts +6 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/ProxyCommandUtils.js +38 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts +6 -0
- package/src/cli/commands/QueueRecoveryCommand.d.ts.map +1 -0
- package/src/cli/commands/QueueRecoveryCommand.js +513 -0
- package/src/cli/commands/RedisProxyCommand.d.ts +6 -0
- package/src/cli/commands/RedisProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/RedisProxyCommand.js +53 -0
- package/src/cli/commands/SmtpProxyCommand.d.ts +6 -0
- package/src/cli/commands/SmtpProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SmtpProxyCommand.js +56 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts +46 -0
- package/src/cli/commands/SqlProxyCommandUtils.d.ts.map +1 -0
- package/src/cli/commands/SqlProxyCommandUtils.js +48 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts +5 -0
- package/src/cli/commands/SqlServerProxyCommand.d.ts.map +1 -0
- package/src/cli/commands/SqlServerProxyCommand.js +85 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +145 -18
- package/src/cli/commands/WorkerCommands.d.ts +1 -0
- package/src/cli/commands/WorkerCommands.d.ts.map +1 -1
- package/src/cli/commands/WorkerCommands.js +140 -6
- package/src/cli/commands/index.d.ts +2 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +2 -0
- package/src/cli/commands/runner/index.d.ts +2 -2
- package/src/cli/commands/runner/index.d.ts.map +1 -1
- package/src/cli/commands/runner/index.js +15 -4
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +3 -0
- package/src/cli/index.d.ts +4 -0
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +4 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +2 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +1 -0
- package/src/cli/utils/EnvFileLoader.d.ts +2 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/cli/utils/EnvFileLoader.js +22 -21
- package/src/cli/utils/spawn.d.ts.map +1 -1
- package/src/cli/utils/spawn.js +17 -10
- package/src/cli/workers/QueueWorkRunner.js +1 -1
- package/src/common/ExternalServiceUtils.d.ts.map +1 -1
- package/src/common/ExternalServiceUtils.js +7 -2
- package/src/common/HealthRoutes.d.ts.map +1 -1
- package/src/common/HealthRoutes.js +50 -2
- package/src/common/RemoteSignedJson.d.ts +1 -0
- package/src/common/RemoteSignedJson.d.ts.map +1 -1
- package/src/common/RemoteSignedJson.js +39 -13
- package/src/common/index.d.ts +1 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +12 -1
- package/src/config/FileLogWriter.d.ts.map +1 -1
- package/src/config/FileLogWriter.js +21 -6
- package/src/config/app.d.ts +4 -0
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +4 -0
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +22 -2
- package/src/config/cloudflare.d.ts +5 -1
- package/src/config/cloudflare.d.ts.map +1 -1
- package/src/config/cloudflare.js +48 -0
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +48 -13
- package/src/config/env.d.ts +90 -2
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +160 -18
- package/src/config/index.d.ts +1 -0
- package/src/config/index.d.ts.map +1 -1
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +60 -16
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +16 -10
- package/src/config/middleware.d.ts +5 -0
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +19 -1
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +70 -9
- package/src/config/redis.d.ts.map +1 -1
- package/src/config/redis.js +48 -13
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +1 -0
- package/src/config/type.d.ts +19 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/workers.d.ts.map +1 -1
- package/src/config/workers.js +122 -16
- package/src/functions/cloudflare.d.ts.map +1 -1
- package/src/functions/cloudflare.js +55 -1
- package/src/health/StartupHealthChecks.js +1 -1
- package/src/http/FileUpload.d.ts +3 -2
- package/src/http/FileUpload.d.ts.map +1 -1
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +2 -1
- package/src/http/error-pages/ErrorPageRenderer.d.ts +4 -0
- package/src/http/error-pages/ErrorPageRenderer.d.ts.map +1 -1
- package/src/http/error-pages/ErrorPageRenderer.js +141 -1
- package/src/http/middleware/BodyParsingMiddleware.d.ts.map +1 -1
- package/src/http/middleware/BodyParsingMiddleware.js +33 -6
- package/src/index.d.ts +25 -53
- package/src/index.d.ts.map +1 -1
- package/src/index.js +30 -14
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -1
- package/src/microservices/ServiceAuthMiddleware.js +12 -4
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +39 -10
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -1
- package/src/middleware/ErrorHandlerMiddleware.js +2 -1
- package/src/migrations/MigrationLoader.js +1 -1
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
- package/src/migrations/schema/SchemaCompiler.js +6 -3
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/fs.d.ts +1 -1
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/path.d.ts +1 -1
- package/src/node-singletons/path.d.ts.map +1 -1
- package/src/node-singletons/path.js +1 -1
- package/src/node-singletons/stream.d.ts +11 -0
- package/src/node-singletons/stream.d.ts.map +1 -0
- package/src/node-singletons/stream.js +8 -0
- package/src/observability/OpenTelemetry.d.ts +7 -0
- package/src/observability/OpenTelemetry.d.ts.map +1 -1
- package/src/observability/OpenTelemetry.js +49 -2
- package/src/orm/Database.d.ts +4 -0
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/Database.js +80 -9
- package/src/orm/DatabaseRuntimeRegistration.d.ts.map +1 -1
- package/src/orm/DatabaseRuntimeRegistration.js +2 -0
- package/src/orm/QueryBuilder.d.ts +1 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +33 -3
- package/src/orm/SchemaCompiler.d.ts.map +1 -1
- package/src/orm/SchemaCompiler.js +6 -3
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +14 -1
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts +3 -0
- package/src/orm/adapters/MongoDBProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MongoDBProxyAdapter.js +128 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/MySQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MySQLProxyAdapter.js +143 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts +11 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/PostgreSQLProxyAdapter.js +147 -0
- package/src/orm/adapters/ProxyCache.d.ts +9 -0
- package/src/orm/adapters/ProxyCache.d.ts.map +1 -0
- package/src/orm/adapters/ProxyCache.js +24 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts +11 -0
- package/src/orm/adapters/ProxySignedRequest.d.ts.map +1 -0
- package/src/orm/adapters/ProxySignedRequest.js +30 -0
- package/src/orm/adapters/ProxySigningPath.d.ts +3 -0
- package/src/orm/adapters/ProxySigningPath.d.ts.map +1 -0
- package/src/orm/adapters/ProxySigningPath.js +25 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts +19 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyAdapterUtils.js +35 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts +3 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SqlServerProxyAdapter.js +146 -0
- package/src/performance/Optimizer.d.ts +1 -0
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +21 -8
- package/src/proxy/ErrorHandler.d.ts +11 -0
- package/src/proxy/ErrorHandler.d.ts.map +1 -0
- package/src/proxy/ErrorHandler.js +7 -0
- package/src/proxy/PoolManager.d.ts +8 -0
- package/src/proxy/PoolManager.d.ts.map +1 -0
- package/src/proxy/PoolManager.js +18 -0
- package/src/proxy/ProxyBackend.d.ts +18 -0
- package/src/proxy/ProxyBackend.d.ts.map +1 -0
- package/src/proxy/ProxyBackend.js +1 -0
- package/src/proxy/ProxyConfig.d.ts +12 -0
- package/src/proxy/ProxyConfig.d.ts.map +1 -0
- package/src/proxy/ProxyConfig.js +1 -0
- package/src/proxy/ProxyRegistry.d.ts +10 -0
- package/src/proxy/ProxyRegistry.d.ts.map +1 -0
- package/src/proxy/ProxyRegistry.js +11 -0
- package/src/proxy/ProxyServer.d.ts +21 -0
- package/src/proxy/ProxyServer.d.ts.map +1 -0
- package/src/proxy/ProxyServer.js +84 -0
- package/src/proxy/ProxyServerUtils.d.ts +37 -0
- package/src/proxy/ProxyServerUtils.d.ts.map +1 -0
- package/src/proxy/ProxyServerUtils.js +42 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts +22 -0
- package/src/proxy/ProxySigningConfigResolver.d.ts.map +1 -0
- package/src/proxy/ProxySigningConfigResolver.js +24 -0
- package/src/proxy/ProxySigningRequest.d.ts +12 -0
- package/src/proxy/ProxySigningRequest.d.ts.map +1 -0
- package/src/proxy/ProxySigningRequest.js +31 -0
- package/src/proxy/RequestValidator.d.ts +15 -0
- package/src/proxy/RequestValidator.d.ts.map +1 -0
- package/src/proxy/RequestValidator.js +25 -0
- package/src/proxy/SigningService.d.ts +39 -0
- package/src/proxy/SigningService.d.ts.map +1 -0
- package/src/proxy/SigningService.js +107 -0
- package/src/proxy/SqlPayloadValidator.d.ts +13 -0
- package/src/proxy/SqlPayloadValidator.d.ts.map +1 -0
- package/src/proxy/SqlPayloadValidator.js +14 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts +2 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -0
- package/src/proxy/d1/ZintrustD1Proxy.js +1 -0
- package/src/proxy/d1/register.d.ts +2 -0
- package/src/proxy/d1/register.d.ts.map +1 -0
- package/src/proxy/d1/register.js +5 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts +2 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -0
- package/src/proxy/kv/ZintrustKvProxy.js +1 -0
- package/src/proxy/kv/register.d.ts +2 -0
- package/src/proxy/kv/register.d.ts.map +1 -0
- package/src/proxy/kv/register.js +5 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts +33 -0
- package/src/proxy/mongodb/MongoDBProxyServer.d.ts.map +1 -0
- package/src/proxy/mongodb/MongoDBProxyServer.js +202 -0
- package/src/proxy/mongodb/register.d.ts +2 -0
- package/src/proxy/mongodb/register.d.ts.map +1 -0
- package/src/proxy/mongodb/register.js +5 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts +14 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -0
- package/src/proxy/mysql/MySqlProxyServer.js +169 -0
- package/src/proxy/mysql/register.d.ts +2 -0
- package/src/proxy/mysql/register.d.ts.map +1 -0
- package/src/proxy/mysql/register.js +5 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts +14 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -0
- package/src/proxy/postgres/PostgresProxyServer.js +140 -0
- package/src/proxy/postgres/register.d.ts +2 -0
- package/src/proxy/postgres/register.d.ts.map +1 -0
- package/src/proxy/postgres/register.js +5 -0
- package/src/proxy/redis/RedisProxyServer.d.ts +12 -0
- package/src/proxy/redis/RedisProxyServer.d.ts.map +1 -0
- package/src/proxy/redis/RedisProxyServer.js +192 -0
- package/src/proxy/redis/register.d.ts +2 -0
- package/src/proxy/redis/register.d.ts.map +1 -0
- package/src/proxy/redis/register.js +5 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts +19 -0
- package/src/proxy/smtp/SmtpProxyServer.d.ts.map +1 -0
- package/src/proxy/smtp/SmtpProxyServer.js +289 -0
- package/src/proxy/smtp/register.d.ts +2 -0
- package/src/proxy/smtp/register.d.ts.map +1 -0
- package/src/proxy/smtp/register.js +5 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts +14 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.js +168 -0
- package/src/proxy/sqlserver/register.d.ts +2 -0
- package/src/proxy/sqlserver/register.d.ts.map +1 -0
- package/src/proxy/sqlserver/register.js +5 -0
- package/src/routes/doc.d.ts.map +1 -1
- package/src/routes/doc.js +16 -2
- package/src/routes/error.d.ts +5 -4
- package/src/routes/error.d.ts.map +1 -1
- package/src/routes/error.js +15 -13
- package/src/routes/errorPages.d.ts +2 -0
- package/src/routes/errorPages.d.ts.map +1 -1
- package/src/routes/errorPages.js +144 -4
- package/src/runtime/PluginAutoImports.d.ts +1 -0
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +94 -9
- package/src/runtime/RuntimeAdapter.d.ts +8 -9
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/RuntimeAdapter.js +120 -34
- package/src/runtime/RuntimeServices.d.ts +47 -0
- package/src/runtime/RuntimeServices.d.ts.map +1 -0
- package/src/runtime/RuntimeServices.js +164 -0
- package/src/runtime/StartupConfigFileRegistry.d.ts +4 -4
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +12 -0
- package/src/runtime/WorkerAdapterImports.d.ts +5 -0
- package/src/runtime/WorkerAdapterImports.d.ts.map +1 -0
- package/src/runtime/WorkerAdapterImports.js +17 -0
- package/src/runtime/WorkersModule.d.ts +6 -0
- package/src/runtime/WorkersModule.d.ts.map +1 -0
- package/src/runtime/WorkersModule.js +278 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +19 -2
- package/src/runtime/adapters/DenoAdapter.js +1 -0
- package/src/runtime/adapters/FargateAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +1 -1
- package/src/runtime/adapters/NodeServerAdapter.js +1 -1
- package/src/runtime/detectRuntime.d.ts +10 -0
- package/src/runtime/detectRuntime.d.ts.map +1 -0
- package/src/runtime/detectRuntime.js +57 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -1
- package/src/runtime/useFileLoader.js +16 -0
- package/src/scripts/TemplateImportsCheck.js +2 -2
- package/src/scripts/TemplateSync.js +3 -4
- package/src/security/CsrfTokenManager.d.ts +18 -9
- package/src/security/CsrfTokenManager.d.ts.map +1 -1
- package/src/security/CsrfTokenManager.js +204 -11
- package/src/security/Hash.d.ts +1 -1
- package/src/security/Hash.d.ts.map +1 -1
- package/src/security/Hash.js +31 -36
- package/src/seeders/SeederLoader.js +1 -1
- package/src/session/SessionManager.d.ts +3 -0
- package/src/session/SessionManager.d.ts.map +1 -1
- package/src/session/SessionManager.js +49 -10
- package/src/sockets/CloudflareSocket.d.ts +24 -0
- package/src/sockets/CloudflareSocket.d.ts.map +1 -0
- package/src/sockets/CloudflareSocket.js +259 -0
- package/src/start.d.ts.map +1 -1
- package/src/start.js +1 -8
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +4 -2
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
- package/src/tools/mail/drivers/Smtp.js +223 -18
- package/src/tools/mail/index.d.ts.map +1 -1
- package/src/tools/mail/index.js +5 -4
- package/src/tools/mail/template-loader.d.ts.map +1 -1
- package/src/tools/mail/template-loader.js +197 -29
- package/src/tools/mail/templates/auth-password-reset.d.ts +3 -0
- package/src/tools/mail/templates/auth-password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-password-reset.js +231 -0
- package/src/tools/mail/templates/auth-welcome.d.ts +3 -0
- package/src/tools/mail/templates/auth-welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/auth-welcome.js +236 -0
- package/src/tools/mail/templates/general.d.ts +3 -0
- package/src/tools/mail/templates/general.d.ts.map +1 -0
- package/src/tools/mail/templates/general.js +109 -0
- package/src/tools/mail/templates/index.js +2 -2
- package/src/tools/mail/templates/job-completed.d.ts +3 -0
- package/src/tools/mail/templates/job-completed.d.ts.map +1 -0
- package/src/tools/mail/templates/job-completed.js +188 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts +3 -0
- package/src/tools/mail/templates/notifications-new-comment.d.ts.map +1 -0
- package/src/tools/mail/templates/notifications-new-comment.js +228 -0
- package/src/tools/mail/templates/password-reset.d.ts +3 -0
- package/src/tools/mail/templates/password-reset.d.ts.map +1 -0
- package/src/tools/mail/templates/password-reset.js +221 -0
- package/src/tools/mail/templates/performance-report.d.ts +3 -0
- package/src/tools/mail/templates/performance-report.d.ts.map +1 -0
- package/src/tools/mail/templates/performance-report.js +258 -0
- package/src/tools/mail/templates/welcome.d.ts +3 -0
- package/src/tools/mail/templates/welcome.d.ts.map +1 -0
- package/src/tools/mail/templates/welcome.js +187 -0
- package/src/tools/mail/templates/worker-alert.d.ts +3 -0
- package/src/tools/mail/templates/worker-alert.d.ts.map +1 -0
- package/src/tools/mail/templates/worker-alert.js +229 -0
- package/src/tools/notification/Notification.js +1 -1
- package/src/tools/notification/testingHelpers.js +6 -5
- package/src/tools/queue/AdvancedQueue.js +2 -6
- package/src/tools/queue/IdempotencyManager.d.ts +6 -0
- package/src/tools/queue/IdempotencyManager.d.ts.map +1 -0
- package/src/tools/queue/IdempotencyManager.js +36 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts +16 -0
- package/src/tools/queue/JobHeartbeatStore.d.ts.map +1 -0
- package/src/tools/queue/JobHeartbeatStore.js +67 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts +16 -0
- package/src/tools/queue/JobReconciliationRunner.d.ts.map +1 -0
- package/src/tools/queue/JobReconciliationRunner.js +88 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts +27 -0
- package/src/tools/queue/JobRecoveryDaemon.d.ts.map +1 -0
- package/src/tools/queue/JobRecoveryDaemon.js +205 -0
- package/src/tools/queue/JobStateTracker.d.ts +131 -0
- package/src/tools/queue/JobStateTracker.d.ts.map +1 -0
- package/src/tools/queue/JobStateTracker.js +387 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts +12 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.d.ts.map +1 -0
- package/src/tools/queue/JobStateTrackerDbPersistence.js +148 -0
- package/src/tools/queue/Queue.d.ts.map +1 -1
- package/src/tools/queue/Queue.js +160 -16
- package/src/tools/queue/QueueDataRedactor.d.ts +6 -0
- package/src/tools/queue/QueueDataRedactor.d.ts.map +1 -0
- package/src/tools/queue/QueueDataRedactor.js +45 -0
- package/src/tools/queue/QueueExtensions.d.ts.map +1 -1
- package/src/tools/queue/QueueExtensions.js +2 -1
- package/src/tools/queue/QueueReliabilityMetrics.d.ts +38 -0
- package/src/tools/queue/QueueReliabilityMetrics.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityMetrics.js +131 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts +7 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.d.ts.map +1 -0
- package/src/tools/queue/QueueReliabilityOrchestrator.js +59 -0
- package/src/tools/queue/QueueRuntimeRegistration.d.ts +1 -9
- package/src/tools/queue/QueueRuntimeRegistration.d.ts.map +1 -1
- package/src/tools/queue/QueueRuntimeRegistration.js +75 -4
- package/src/tools/queue/QueueTracing.d.ts +32 -0
- package/src/tools/queue/QueueTracing.d.ts.map +1 -0
- package/src/tools/queue/QueueTracing.js +151 -0
- package/src/tools/queue/StalledJobMonitor.d.ts +5 -0
- package/src/tools/queue/StalledJobMonitor.d.ts.map +1 -0
- package/src/tools/queue/StalledJobMonitor.js +21 -0
- package/src/tools/queue/TimeoutManager.d.ts +14 -0
- package/src/tools/queue/TimeoutManager.d.ts.map +1 -0
- package/src/tools/queue/TimeoutManager.js +77 -0
- package/src/tools/queue/drivers/Redis.d.ts +1 -0
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +1 -0
- package/src/tools/queue/index.d.ts +10 -0
- package/src/tools/queue/index.d.ts.map +1 -1
- package/src/tools/queue/index.js +10 -0
- package/src/tools/redis/RedisKeyManager.d.ts +3 -0
- package/src/tools/redis/RedisKeyManager.d.ts.map +1 -1
- package/src/tools/redis/RedisKeyManager.js +15 -0
- package/src/tools/storage/drivers/R2.d.ts +13 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -1
- package/src/tools/storage/drivers/R2.js +29 -0
- package/src/zintrust.plugins.d.ts +9 -0
- package/src/zintrust.plugins.d.ts.map +1 -0
- package/src/zintrust.plugins.js +7 -0
- package/src/zintrust.plugins.wg.d.ts +9 -0
- package/src/zintrust.plugins.wg.d.ts.map +1 -0
- package/src/zintrust.plugins.wg.js +7 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { Env } from '../../config/env.js';
|
|
2
|
+
import { Logger } from '../../config/logger.js';
|
|
3
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import { ErrorHandler } from '../ErrorHandler.js';
|
|
5
|
+
import { createProxyServer } from '../ProxyServer.js';
|
|
6
|
+
import { resolveBaseConfig, resolveBaseSigningConfig, verifyRequestSignature, } from '../ProxyServerUtils.js';
|
|
7
|
+
import { RequestValidator } from '../RequestValidator.js';
|
|
8
|
+
const resolveRedisConfig = (overrides = {}) => {
|
|
9
|
+
const host = overrides.redisHost ?? Env.get('REDIS_PROXY_TARGET_HOST', Env.get('REDIS_HOST', '127.0.0.1'));
|
|
10
|
+
const port = overrides.redisPort ?? Env.getInt('REDIS_PROXY_TARGET_PORT', Env.getInt('REDIS_PORT', 6379));
|
|
11
|
+
const password = overrides.redisPassword ??
|
|
12
|
+
Env.get('REDIS_PROXY_TARGET_PASSWORD', Env.get('REDIS_PASSWORD', ''));
|
|
13
|
+
const db = overrides.redisDb ?? Env.getInt('REDIS_PROXY_TARGET_DB', Env.getInt('REDIS_DB', 0));
|
|
14
|
+
return { host, port, password, db };
|
|
15
|
+
};
|
|
16
|
+
const resolveConfig = (overrides = {}) => {
|
|
17
|
+
const proxyConfig = resolveBaseConfig(overrides, 'REDIS');
|
|
18
|
+
const redisConfig = resolveRedisConfig(overrides);
|
|
19
|
+
const signingConfig = resolveBaseSigningConfig(overrides, 'REDIS');
|
|
20
|
+
return {
|
|
21
|
+
host: proxyConfig.host,
|
|
22
|
+
port: proxyConfig.port,
|
|
23
|
+
maxBodyBytes: proxyConfig.maxBodyBytes,
|
|
24
|
+
redis: redisConfig,
|
|
25
|
+
signing: {
|
|
26
|
+
keyId: signingConfig.keyId,
|
|
27
|
+
secret: signingConfig.secret,
|
|
28
|
+
require: signingConfig.requireSigning,
|
|
29
|
+
windowMs: signingConfig.signingWindowMs,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
const validateCommandPayload = (payload) => {
|
|
34
|
+
const command = payload['command'];
|
|
35
|
+
const args = Array.isArray(payload['args']) ? payload['args'] : [];
|
|
36
|
+
if (typeof command !== 'string' || command.trim() === '') {
|
|
37
|
+
return { valid: false, error: { code: 'VALIDATION_ERROR', message: 'command is required' } };
|
|
38
|
+
}
|
|
39
|
+
return { valid: true, command, args };
|
|
40
|
+
};
|
|
41
|
+
const getRedisModule = async () => {
|
|
42
|
+
const mod = await import('ioredis');
|
|
43
|
+
return mod;
|
|
44
|
+
};
|
|
45
|
+
const createClient = async (config) => {
|
|
46
|
+
const module = (await getRedisModule());
|
|
47
|
+
const moduleDefault = module['default'];
|
|
48
|
+
const candidates = [
|
|
49
|
+
module['Redis'],
|
|
50
|
+
module['default'],
|
|
51
|
+
moduleDefault?.['Redis'],
|
|
52
|
+
moduleDefault?.['default'],
|
|
53
|
+
module,
|
|
54
|
+
];
|
|
55
|
+
const RedisCtor = candidates.find((candidate) => typeof candidate === 'function');
|
|
56
|
+
if (typeof RedisCtor !== 'function') {
|
|
57
|
+
throw ErrorFactory.createConfigError("Redis proxy could not resolve a Redis constructor from 'ioredis'.");
|
|
58
|
+
}
|
|
59
|
+
const maxReconnectRetries = Math.max(0, Env.getInt('REDIS_PROXY_CONNECT_MAX_RETRIES', 3));
|
|
60
|
+
const reconnectBaseMs = Math.max(50, Env.getInt('REDIS_PROXY_CONNECT_RETRY_BASE_MS', 200));
|
|
61
|
+
const reconnectCapMs = Math.max(reconnectBaseMs, Env.getInt('REDIS_PROXY_CONNECT_RETRY_CAP_MS', 2000));
|
|
62
|
+
const client = new RedisCtor({
|
|
63
|
+
host: config.redis.host,
|
|
64
|
+
port: config.redis.port,
|
|
65
|
+
password: config.redis.password,
|
|
66
|
+
db: config.redis.db,
|
|
67
|
+
maxRetriesPerRequest: 1,
|
|
68
|
+
enableOfflineQueue: false,
|
|
69
|
+
lazyConnect: true,
|
|
70
|
+
reconnectOnError: () => false,
|
|
71
|
+
retryStrategy: (times) => {
|
|
72
|
+
if (times > maxReconnectRetries) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
return Math.min(times * reconnectBaseMs, reconnectCapMs);
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
let lastErrorLogAt = 0;
|
|
79
|
+
client.on('error', (error) => {
|
|
80
|
+
const now = Date.now();
|
|
81
|
+
if (now - lastErrorLogAt < 5000) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
lastErrorLogAt = now;
|
|
85
|
+
Logger.warn('[RedisProxyServer] redis client error', error);
|
|
86
|
+
});
|
|
87
|
+
if (typeof client.connect === 'function') {
|
|
88
|
+
await client.connect();
|
|
89
|
+
}
|
|
90
|
+
return client;
|
|
91
|
+
};
|
|
92
|
+
const executeCommand = async (client, command, args) => {
|
|
93
|
+
const trimmed = command.trim();
|
|
94
|
+
const lower = trimmed.toLowerCase();
|
|
95
|
+
const candidate = client[lower];
|
|
96
|
+
if (typeof candidate === 'function') {
|
|
97
|
+
return candidate.apply(client, args);
|
|
98
|
+
}
|
|
99
|
+
if (typeof client.call === 'function') {
|
|
100
|
+
return client.call(trimmed, ...args);
|
|
101
|
+
}
|
|
102
|
+
throw ErrorFactory.createValidationError(`Unsupported Redis command: ${trimmed}`);
|
|
103
|
+
};
|
|
104
|
+
const createBackend = (config) => ({
|
|
105
|
+
name: 'redis',
|
|
106
|
+
handle: async (request) => {
|
|
107
|
+
const methodError = RequestValidator.requirePost(request.method);
|
|
108
|
+
if (methodError) {
|
|
109
|
+
return {
|
|
110
|
+
status: 405,
|
|
111
|
+
body: { code: methodError.code, message: methodError.message },
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
if (request.path !== '/zin/redis/command') {
|
|
115
|
+
return { status: 404, body: { code: 'NOT_FOUND', message: 'Unknown endpoint' } };
|
|
116
|
+
}
|
|
117
|
+
const parsed = RequestValidator.parseJson(request.body);
|
|
118
|
+
if (!parsed.ok) {
|
|
119
|
+
return { status: 400, body: { code: parsed.error.code, message: parsed.error.message } };
|
|
120
|
+
}
|
|
121
|
+
const validated = validateCommandPayload(parsed.value);
|
|
122
|
+
if (!validated.valid) {
|
|
123
|
+
return {
|
|
124
|
+
status: 400,
|
|
125
|
+
body: {
|
|
126
|
+
code: validated.error?.code ?? 'VALIDATION_ERROR',
|
|
127
|
+
message: validated.error?.message ?? 'Invalid request',
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
const command = validated.command ?? '';
|
|
132
|
+
if (command.trim() === '') {
|
|
133
|
+
return {
|
|
134
|
+
status: 400,
|
|
135
|
+
body: { code: 'VALIDATION_ERROR', message: 'command is required' },
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
const client = await createClient(config);
|
|
140
|
+
try {
|
|
141
|
+
const result = await executeCommand(client, command, validated.args ?? []);
|
|
142
|
+
return { status: 200, body: { result } };
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
await client.quit();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
return ErrorHandler.toProxyError(500, 'REDIS_PROXY_ERROR', String(error));
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
health: async () => {
|
|
153
|
+
try {
|
|
154
|
+
const client = await createClient(config);
|
|
155
|
+
const pingFn = client.ping;
|
|
156
|
+
if (typeof pingFn === 'function') {
|
|
157
|
+
await pingFn.apply(client);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
await executeCommand(client, 'PING', []);
|
|
161
|
+
}
|
|
162
|
+
await client.quit();
|
|
163
|
+
return { status: 200, body: { status: 'healthy' } };
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
Logger.warn('[RedisProxyServer] health check failed', error);
|
|
167
|
+
return { status: 503, body: { status: 'unhealthy', error: String(error) } };
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
export const RedisProxyServer = Object.freeze({
|
|
172
|
+
async start(overrides = {}) {
|
|
173
|
+
const config = resolveConfig(overrides);
|
|
174
|
+
const backend = createBackend(config);
|
|
175
|
+
const server = createProxyServer({
|
|
176
|
+
host: config.host,
|
|
177
|
+
port: config.port,
|
|
178
|
+
maxBodyBytes: config.maxBodyBytes,
|
|
179
|
+
backend,
|
|
180
|
+
verify: async (req, body) => {
|
|
181
|
+
const verified = await verifyRequestSignature(req, body, config, 'RedisProxyServer');
|
|
182
|
+
if (!verified.ok && verified.error) {
|
|
183
|
+
return { ok: false, status: verified.error.status, message: verified.error.message };
|
|
184
|
+
}
|
|
185
|
+
return { ok: true };
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
await server.start();
|
|
189
|
+
Logger.info(`[redis-proxy] Listening on http://${config.host}:${config.port}`);
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
export default RedisProxyServer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/proxy/redis/register.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type ProxyOverrides = Partial<{
|
|
2
|
+
host: string;
|
|
3
|
+
port: number;
|
|
4
|
+
maxBodyBytes: number;
|
|
5
|
+
smtpHost: string;
|
|
6
|
+
smtpPort: number;
|
|
7
|
+
smtpUsername: string;
|
|
8
|
+
smtpPassword: string;
|
|
9
|
+
smtpSecure: boolean | string;
|
|
10
|
+
requireSigning: boolean;
|
|
11
|
+
keyId: string;
|
|
12
|
+
secret: string;
|
|
13
|
+
signingWindowMs: number;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const SmtpProxyServer: Readonly<{
|
|
16
|
+
start(overrides?: ProxyOverrides): Promise<void>;
|
|
17
|
+
}>;
|
|
18
|
+
export default SmtpProxyServer;
|
|
19
|
+
//# sourceMappingURL=SmtpProxyServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SmtpProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/smtp/SmtpProxyServer.ts"],"names":[],"mappings":"AA2BA,KAAK,cAAc,GAAG,OAAO,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AAqUH,eAAO,MAAM,eAAe;sBACH,cAAc,GAAQ,OAAO,CAAC,IAAI,CAAC;EA2B1D,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { Env } from '../../config/env.js';
|
|
2
|
+
import { Logger } from '../../config/logger.js';
|
|
3
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import { SmtpDriver, } from '../../tools/mail/drivers/Smtp.js';
|
|
5
|
+
import { ErrorHandler } from '../ErrorHandler.js';
|
|
6
|
+
import { createProxyServer } from '../ProxyServer.js';
|
|
7
|
+
import { resolveProxySigningConfig } from '../ProxySigningConfigResolver.js';
|
|
8
|
+
import { extractSigningHeaders, verifyProxySignatureIfNeeded } from '../ProxySigningRequest.js';
|
|
9
|
+
import { RequestValidator } from '../RequestValidator.js';
|
|
10
|
+
import { SigningService } from '../SigningService.js';
|
|
11
|
+
const normalizeSecure = (value) => {
|
|
12
|
+
if (value === true || value === false)
|
|
13
|
+
return value;
|
|
14
|
+
if (typeof value === 'string') {
|
|
15
|
+
const raw = value.trim().toLowerCase();
|
|
16
|
+
if (raw === '')
|
|
17
|
+
return undefined;
|
|
18
|
+
if (raw === 'starttls')
|
|
19
|
+
return 'starttls';
|
|
20
|
+
if (['tls', 'ssl', 'smtps', 'implicit', 'true', '1', 'yes', 'y'].includes(raw))
|
|
21
|
+
return true;
|
|
22
|
+
if (['false', '0', 'no', 'n'].includes(raw))
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
};
|
|
27
|
+
const resolveProxyConfig = (overrides = {}) => {
|
|
28
|
+
const host = overrides.host ?? Env.get('SMTP_PROXY_HOST', Env.HOST ?? '127.0.0.1');
|
|
29
|
+
const port = overrides.port ?? Env.getInt('SMTP_PROXY_PORT', Env.PORT ?? 8794);
|
|
30
|
+
const maxBodyBytes = overrides.maxBodyBytes ?? Env.getInt('SMTP_PROXY_MAX_BODY_BYTES', Env.MAX_BODY_SIZE ?? 131072);
|
|
31
|
+
return { host, port, maxBodyBytes };
|
|
32
|
+
};
|
|
33
|
+
const resolveSmtpConfig = (overrides = {}) => {
|
|
34
|
+
const host = overrides.smtpHost ?? Env.get('MAIL_HOST', '');
|
|
35
|
+
const port = overrides.smtpPort ?? Env.getInt('MAIL_PORT', 587);
|
|
36
|
+
const username = overrides.smtpUsername ?? Env.get('MAIL_USERNAME', '');
|
|
37
|
+
const password = overrides.smtpPassword ?? Env.get('MAIL_PASSWORD', '');
|
|
38
|
+
const secureRaw = overrides.smtpSecure ?? Env.get('MAIL_SECURE', '');
|
|
39
|
+
const secure = normalizeSecure(secureRaw) ?? false;
|
|
40
|
+
return { host, port, username, password, secure };
|
|
41
|
+
};
|
|
42
|
+
const resolveSigningConfig = (overrides = {}) => resolveProxySigningConfig(overrides, {
|
|
43
|
+
keyIdEnvVar: 'SMTP_PROXY_KEY_ID',
|
|
44
|
+
secretEnvVar: 'SMTP_PROXY_SECRET',
|
|
45
|
+
requireEnvVar: 'SMTP_PROXY_REQUIRE_SIGNING',
|
|
46
|
+
windowEnvVar: 'SMTP_PROXY_SIGNING_WINDOW_MS',
|
|
47
|
+
});
|
|
48
|
+
const resolveConfig = (overrides = {}) => {
|
|
49
|
+
const proxyConfig = resolveProxyConfig(overrides);
|
|
50
|
+
const smtpConfig = resolveSmtpConfig(overrides);
|
|
51
|
+
const signingConfig = resolveSigningConfig(overrides);
|
|
52
|
+
return {
|
|
53
|
+
host: proxyConfig.host,
|
|
54
|
+
port: proxyConfig.port,
|
|
55
|
+
maxBodyBytes: proxyConfig.maxBodyBytes,
|
|
56
|
+
smtp: smtpConfig,
|
|
57
|
+
signing: {
|
|
58
|
+
keyId: signingConfig.keyId,
|
|
59
|
+
secret: signingConfig.secret,
|
|
60
|
+
require: signingConfig.requireSigning,
|
|
61
|
+
windowMs: signingConfig.signingWindowMs,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const validateSmtpConfig = (config) => {
|
|
66
|
+
if (config.host.trim() === '') {
|
|
67
|
+
throw ErrorFactory.createConfigError('SMTP proxy missing MAIL_HOST');
|
|
68
|
+
}
|
|
69
|
+
if (!Number.isFinite(config.port) || config.port <= 0) {
|
|
70
|
+
throw ErrorFactory.createConfigError('SMTP proxy MAIL_PORT must be a positive integer');
|
|
71
|
+
}
|
|
72
|
+
const username = config.username ?? '';
|
|
73
|
+
const password = config.password ?? '';
|
|
74
|
+
if ((username.trim() !== '' && password.trim() === '') ||
|
|
75
|
+
(username.trim() === '' && password.trim() !== '')) {
|
|
76
|
+
throw ErrorFactory.createConfigError('SMTP proxy requires both MAIL_USERNAME and MAIL_PASSWORD');
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const verifySignatureIfNeeded = async (req, body, config) => {
|
|
80
|
+
const headers = extractSigningHeaders(req);
|
|
81
|
+
if (SigningService.shouldVerify(config.signing, headers)) {
|
|
82
|
+
const verified = await verifyProxySignatureIfNeeded(req, body, config.signing);
|
|
83
|
+
if (!verified.ok) {
|
|
84
|
+
const normalizedSigning = typeof SigningService['normalizeConfig'] === 'function'
|
|
85
|
+
? SigningService['normalizeConfig'](config.signing)
|
|
86
|
+
: config.signing;
|
|
87
|
+
Logger.warn('[SmtpProxy] Signing verification failed', {
|
|
88
|
+
code: 'INVALID_SIGNATURE',
|
|
89
|
+
message: verified.error?.message ?? 'Invalid signature',
|
|
90
|
+
keyId: headers['x-zt-key-id'],
|
|
91
|
+
expectedKeyId: normalizedSigning.keyId,
|
|
92
|
+
requireSigning: normalizedSigning.require,
|
|
93
|
+
});
|
|
94
|
+
return {
|
|
95
|
+
ok: false,
|
|
96
|
+
error: {
|
|
97
|
+
status: verified.error?.status ?? 401,
|
|
98
|
+
message: verified.error?.message ?? 'Unauthorized',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return { ok: true };
|
|
104
|
+
};
|
|
105
|
+
const isRecord = (value) => typeof value === 'object' && value !== null;
|
|
106
|
+
const parseAttachment = (value) => {
|
|
107
|
+
if (!isRecord(value)) {
|
|
108
|
+
return {
|
|
109
|
+
ok: false,
|
|
110
|
+
error: { code: 'VALIDATION_ERROR', message: 'attachments must be objects' },
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
const filename = value['filename'];
|
|
114
|
+
const contentBase64 = value['contentBase64'];
|
|
115
|
+
if (typeof filename !== 'string' || filename.trim() === '') {
|
|
116
|
+
return {
|
|
117
|
+
ok: false,
|
|
118
|
+
error: { code: 'VALIDATION_ERROR', message: 'attachment filename is required' },
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (typeof contentBase64 !== 'string' || contentBase64.trim() === '') {
|
|
122
|
+
return {
|
|
123
|
+
ok: false,
|
|
124
|
+
error: { code: 'VALIDATION_ERROR', message: 'attachment contentBase64 is required' },
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const content = Buffer.from(contentBase64, 'base64');
|
|
128
|
+
return { ok: true, value: { filename, content } };
|
|
129
|
+
};
|
|
130
|
+
const parseTo = (value) => {
|
|
131
|
+
if (typeof value === 'string' || Array.isArray(value)) {
|
|
132
|
+
return { ok: true, value: value };
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
ok: false,
|
|
136
|
+
error: { code: 'VALIDATION_ERROR', message: 'to must be a string or array' },
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
const parseFrom = (value) => {
|
|
140
|
+
if (!isRecord(value)) {
|
|
141
|
+
return { ok: false, error: { code: 'VALIDATION_ERROR', message: 'from is required' } };
|
|
142
|
+
}
|
|
143
|
+
const email = value['email'];
|
|
144
|
+
const name = value['name'];
|
|
145
|
+
if (typeof email !== 'string' || email.trim() === '') {
|
|
146
|
+
return { ok: false, error: { code: 'VALIDATION_ERROR', message: 'from.email is required' } };
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
ok: true,
|
|
150
|
+
value: {
|
|
151
|
+
email,
|
|
152
|
+
name: typeof name === 'string' && name.trim() !== '' ? name : undefined,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
const parseHtml = (value) => {
|
|
157
|
+
if (value === undefined)
|
|
158
|
+
return { ok: true, value: undefined };
|
|
159
|
+
if (typeof value === 'string')
|
|
160
|
+
return { ok: true, value };
|
|
161
|
+
return { ok: false, error: { code: 'VALIDATION_ERROR', message: 'html must be a string' } };
|
|
162
|
+
};
|
|
163
|
+
const parseAttachments = (value) => {
|
|
164
|
+
if (value === undefined)
|
|
165
|
+
return { ok: true, value: undefined };
|
|
166
|
+
if (!Array.isArray(value)) {
|
|
167
|
+
return {
|
|
168
|
+
ok: false,
|
|
169
|
+
error: { code: 'VALIDATION_ERROR', message: 'attachments must be an array' },
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const attachments = [];
|
|
173
|
+
for (const entry of value) {
|
|
174
|
+
const parsed = parseAttachment(entry);
|
|
175
|
+
if (!parsed.ok)
|
|
176
|
+
return parsed;
|
|
177
|
+
attachments.push(parsed.value);
|
|
178
|
+
}
|
|
179
|
+
return { ok: true, value: attachments };
|
|
180
|
+
};
|
|
181
|
+
const parseMessagePayload = (payload) => {
|
|
182
|
+
const messageRaw = payload['message'];
|
|
183
|
+
if (!isRecord(messageRaw)) {
|
|
184
|
+
return { ok: false, error: { code: 'VALIDATION_ERROR', message: 'message is required' } };
|
|
185
|
+
}
|
|
186
|
+
const toParsed = parseTo(messageRaw['to']);
|
|
187
|
+
if (!toParsed.ok)
|
|
188
|
+
return toParsed;
|
|
189
|
+
const fromParsed = parseFrom(messageRaw['from']);
|
|
190
|
+
if (!fromParsed.ok)
|
|
191
|
+
return fromParsed;
|
|
192
|
+
const subject = messageRaw['subject'];
|
|
193
|
+
if (typeof subject !== 'string' || subject.trim() === '') {
|
|
194
|
+
return { ok: false, error: { code: 'VALIDATION_ERROR', message: 'subject is required' } };
|
|
195
|
+
}
|
|
196
|
+
const text = messageRaw['text'];
|
|
197
|
+
if (typeof text !== 'string' || text.trim() === '') {
|
|
198
|
+
return { ok: false, error: { code: 'VALIDATION_ERROR', message: 'text is required' } };
|
|
199
|
+
}
|
|
200
|
+
const htmlParsed = parseHtml(messageRaw['html']);
|
|
201
|
+
if (!htmlParsed.ok)
|
|
202
|
+
return htmlParsed;
|
|
203
|
+
const attachmentsParsed = parseAttachments(messageRaw['attachments']);
|
|
204
|
+
if (!attachmentsParsed.ok)
|
|
205
|
+
return attachmentsParsed;
|
|
206
|
+
return {
|
|
207
|
+
ok: true,
|
|
208
|
+
value: {
|
|
209
|
+
to: toParsed.value,
|
|
210
|
+
from: fromParsed.value,
|
|
211
|
+
subject,
|
|
212
|
+
text,
|
|
213
|
+
html: htmlParsed.value,
|
|
214
|
+
attachments: attachmentsParsed.value,
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
const createBackend = (config) => ({
|
|
219
|
+
name: 'smtp',
|
|
220
|
+
handle: async (request) => {
|
|
221
|
+
const methodError = RequestValidator.requirePost(request.method);
|
|
222
|
+
Logger.info('[SmtpProxy] Received request', { path: request.path, method: request.method });
|
|
223
|
+
if (methodError) {
|
|
224
|
+
return ErrorHandler.toProxyError(405, methodError.code, methodError.message);
|
|
225
|
+
}
|
|
226
|
+
if (request.path !== '/zin/smtp/send') {
|
|
227
|
+
Logger.warn('[SmtpProxy] 404 Not Found', { path: request.path });
|
|
228
|
+
return ErrorHandler.toProxyError(404, 'NOT_FOUND', 'Unknown endpoint');
|
|
229
|
+
}
|
|
230
|
+
const parsed = RequestValidator.parseJson(request.body);
|
|
231
|
+
if (!parsed.ok) {
|
|
232
|
+
return ErrorHandler.toProxyError(400, parsed.error.code, parsed.error.message);
|
|
233
|
+
}
|
|
234
|
+
const messageValidation = parseMessagePayload(parsed.value);
|
|
235
|
+
if (!messageValidation.ok) {
|
|
236
|
+
return ErrorHandler.toProxyError(400, messageValidation.error.code, messageValidation.error.message);
|
|
237
|
+
}
|
|
238
|
+
try {
|
|
239
|
+
Logger.info('[SmtpProxy] Sending email via SmtpDriver', { to: messageValidation.value.to });
|
|
240
|
+
await SmtpDriver.send(config.smtp, messageValidation.value);
|
|
241
|
+
Logger.info('[SmtpProxy] Email sent successfully');
|
|
242
|
+
return { status: 200, body: { ok: true } };
|
|
243
|
+
}
|
|
244
|
+
catch (error) {
|
|
245
|
+
Logger.error('[SmtpProxy] Failed to send email', error);
|
|
246
|
+
return ErrorHandler.toProxyError(500, 'SMTP_PROXY_ERROR', String(error));
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
async health() {
|
|
250
|
+
try {
|
|
251
|
+
validateSmtpConfig(config.smtp);
|
|
252
|
+
await Promise.resolve();
|
|
253
|
+
return { status: 200, body: { status: 'healthy' } };
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
return ErrorHandler.toProxyError(503, 'UNHEALTHY', String(error));
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
const createVerifier = (config) => async (req, body) => {
|
|
261
|
+
const verified = await verifySignatureIfNeeded(req, body, config);
|
|
262
|
+
if (!verified.ok && verified.error) {
|
|
263
|
+
return { ok: false, status: verified.error.status, message: verified.error.message };
|
|
264
|
+
}
|
|
265
|
+
return { ok: true };
|
|
266
|
+
};
|
|
267
|
+
export const SmtpProxyServer = Object.freeze({
|
|
268
|
+
async start(overrides = {}) {
|
|
269
|
+
const config = resolveConfig(overrides);
|
|
270
|
+
validateSmtpConfig(config.smtp);
|
|
271
|
+
try {
|
|
272
|
+
Logger.info(`SMTP proxy config: proxyHost=${config.host} proxyPort=${config.port} smtpHost=${String(config.smtp.host)} smtpPort=${String(config.smtp.port)} smtpUser=${String(config.smtp.username ?? '')}`);
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
// noop
|
|
276
|
+
}
|
|
277
|
+
const backend = createBackend(config);
|
|
278
|
+
const server = createProxyServer({
|
|
279
|
+
host: config.host,
|
|
280
|
+
port: config.port,
|
|
281
|
+
maxBodyBytes: config.maxBodyBytes,
|
|
282
|
+
backend,
|
|
283
|
+
verify: createVerifier(config),
|
|
284
|
+
});
|
|
285
|
+
await server.start();
|
|
286
|
+
Logger.info(`SMTP proxy listening on http://${config.host}:${config.port}`);
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
export default SmtpProxyServer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/proxy/smtp/register.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type BaseProxyOverrides } from '../ProxyServerUtils';
|
|
2
|
+
type ProxyOverrides = BaseProxyOverrides & Partial<{
|
|
3
|
+
dbHost: string;
|
|
4
|
+
dbPort: number;
|
|
5
|
+
dbName: string;
|
|
6
|
+
dbUser: string;
|
|
7
|
+
dbPass: string;
|
|
8
|
+
connectionLimit: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const SqlServerProxyServer: Readonly<{
|
|
11
|
+
start(overrides?: ProxyOverrides): Promise<void>;
|
|
12
|
+
}>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=SqlServerProxyServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlServerProxyServer.d.ts","sourceRoot":"","sources":["../../../../src/proxy/sqlserver/SqlServerProxyServer.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,yBAAyB,CAAC;AAejC,KAAK,cAAc,GAAG,kBAAkB,GACtC,OAAO,CAAC;IACN,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC,CAAC;AA+KL,eAAO,MAAM,oBAAoB;sBACR,cAAc,GAAQ,OAAO,CAAC,IAAI,CAAC;EAmC1D,CAAC"}
|