@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,168 @@
|
|
|
1
|
+
import { Env } from '../../config/env.js';
|
|
2
|
+
import { Logger } from '../../config/logger.js';
|
|
3
|
+
import { ErrorHandler } from '../ErrorHandler.js';
|
|
4
|
+
import { createProxyServer } from '../ProxyServer.js';
|
|
5
|
+
import { resolveBaseConfig, resolveBaseSigningConfig, verifyRequestSignature, } from '../ProxyServerUtils.js';
|
|
6
|
+
import { RequestValidator } from '../RequestValidator.js';
|
|
7
|
+
import { validateSqlPayload } from '../SqlPayloadValidator.js';
|
|
8
|
+
const resolveDatabaseConfig = (overrides = {}) => {
|
|
9
|
+
const dbHost = overrides.dbHost ?? Env.get('DB_HOST_MSSQL', Env.get('DB_HOST', '127.0.0.1'));
|
|
10
|
+
const dbPort = overrides.dbPort ?? Env.getInt('DB_PORT_MSSQL', 1433);
|
|
11
|
+
const dbName = overrides.dbName ?? Env.get('DB_DATABASE_MSSQL', 'zintrust');
|
|
12
|
+
const dbUser = overrides.dbUser ?? Env.get('DB_USERNAME_MSSQL', 'sa');
|
|
13
|
+
const dbPass = overrides.dbPass ?? Env.get('DB_PASSWORD_MSSQL', '');
|
|
14
|
+
const connectionLimit = overrides.connectionLimit ?? Env.getInt('SQLSERVER_PROXY_POOL_LIMIT', 10);
|
|
15
|
+
return { dbHost, dbPort, dbName, dbUser, dbPass, connectionLimit };
|
|
16
|
+
};
|
|
17
|
+
const resolveConfig = (overrides = {}) => {
|
|
18
|
+
const proxyConfig = resolveBaseConfig(overrides, 'SQLSERVER');
|
|
19
|
+
const dbConfig = resolveDatabaseConfig(overrides);
|
|
20
|
+
const signingConfig = resolveBaseSigningConfig(overrides, 'SQLSERVER');
|
|
21
|
+
const poolConfig = {
|
|
22
|
+
server: dbConfig.dbHost,
|
|
23
|
+
port: dbConfig.dbPort,
|
|
24
|
+
database: dbConfig.dbName,
|
|
25
|
+
user: dbConfig.dbUser,
|
|
26
|
+
password: dbConfig.dbPass,
|
|
27
|
+
pool: {
|
|
28
|
+
max: dbConfig.connectionLimit,
|
|
29
|
+
min: 0,
|
|
30
|
+
idleTimeoutMillis: 30000,
|
|
31
|
+
},
|
|
32
|
+
options: {
|
|
33
|
+
encrypt: false,
|
|
34
|
+
trustServerCertificate: true,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
host: proxyConfig.host,
|
|
39
|
+
port: proxyConfig.port,
|
|
40
|
+
maxBodyBytes: proxyConfig.maxBodyBytes,
|
|
41
|
+
poolConfig,
|
|
42
|
+
signing: {
|
|
43
|
+
keyId: signingConfig.keyId,
|
|
44
|
+
secret: signingConfig.secret,
|
|
45
|
+
require: signingConfig.requireSigning,
|
|
46
|
+
windowMs: signingConfig.signingWindowMs,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const validateQueryPayload = (payload) => {
|
|
51
|
+
const base = validateSqlPayload(payload);
|
|
52
|
+
if (!base.valid) {
|
|
53
|
+
return { valid: false, error: base.error };
|
|
54
|
+
}
|
|
55
|
+
if (base.sql.trim() === '') {
|
|
56
|
+
return { valid: false, error: { code: 'VALIDATION_ERROR', message: 'sql is required' } };
|
|
57
|
+
}
|
|
58
|
+
return { valid: true, sql: base.sql, params: base.params };
|
|
59
|
+
};
|
|
60
|
+
const getSqlModule = async () => {
|
|
61
|
+
const mod = await import('mssql');
|
|
62
|
+
return mod;
|
|
63
|
+
};
|
|
64
|
+
const createPool = async (config) => {
|
|
65
|
+
const mod = await getSqlModule();
|
|
66
|
+
const connect = mod['connect'];
|
|
67
|
+
return connect(config);
|
|
68
|
+
};
|
|
69
|
+
const executeQuery = async (pool, sqlQuery, params) => {
|
|
70
|
+
const requestFunc = pool['request'];
|
|
71
|
+
const request = requestFunc();
|
|
72
|
+
params.forEach((param, index) => {
|
|
73
|
+
const inputFunc = request['input'];
|
|
74
|
+
inputFunc(`param${index}`, param);
|
|
75
|
+
});
|
|
76
|
+
const queryFunc = request['query'];
|
|
77
|
+
return queryFunc(sqlQuery);
|
|
78
|
+
};
|
|
79
|
+
const handleEndpoint = (path, result) => {
|
|
80
|
+
const rows = result['recordset'];
|
|
81
|
+
const rowsAffected = result['rowsAffected'];
|
|
82
|
+
if (path === '/zin/sqlserver/query') {
|
|
83
|
+
return { status: 200, body: { rows, rowCount: rowsAffected[0] ?? 0 } };
|
|
84
|
+
}
|
|
85
|
+
if (path === '/zin/sqlserver/queryOne') {
|
|
86
|
+
const firstRow = Array.isArray(rows) ? rows[0] : null;
|
|
87
|
+
return { status: 200, body: { row: firstRow ?? null } };
|
|
88
|
+
}
|
|
89
|
+
if (path === '/zin/sqlserver/exec') {
|
|
90
|
+
return {
|
|
91
|
+
status: 200,
|
|
92
|
+
body: {
|
|
93
|
+
ok: true,
|
|
94
|
+
meta: { changes: rowsAffected[0] ?? 0 },
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return ErrorHandler.toProxyError(404, 'NOT_FOUND', 'Unknown endpoint');
|
|
99
|
+
};
|
|
100
|
+
const createBackend = (pool) => ({
|
|
101
|
+
name: 'sqlserver',
|
|
102
|
+
handle: async (request) => {
|
|
103
|
+
const methodError = RequestValidator.requirePost(request.method);
|
|
104
|
+
if (methodError) {
|
|
105
|
+
return ErrorHandler.toProxyError(405, methodError.code, methodError.message);
|
|
106
|
+
}
|
|
107
|
+
const parsed = RequestValidator.parseJson(request.body);
|
|
108
|
+
if (!parsed.ok) {
|
|
109
|
+
return ErrorHandler.toProxyError(400, parsed.error.code, parsed.error.message);
|
|
110
|
+
}
|
|
111
|
+
const sqlValidation = validateQueryPayload(parsed.value);
|
|
112
|
+
if (!sqlValidation.valid) {
|
|
113
|
+
const error = sqlValidation.error ?? {
|
|
114
|
+
code: 'VALIDATION_ERROR',
|
|
115
|
+
message: 'Invalid SQL payload',
|
|
116
|
+
};
|
|
117
|
+
return ErrorHandler.toProxyError(400, error.code, error.message);
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const result = await executeQuery(pool, sqlValidation.sql ?? '', sqlValidation.params ?? []);
|
|
121
|
+
return handleEndpoint(request.path, result);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return ErrorHandler.toProxyError(500, 'SQLSERVER_ERROR', String(error));
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
health: async () => {
|
|
128
|
+
try {
|
|
129
|
+
await executeQuery(pool, 'SELECT 1', []);
|
|
130
|
+
return { status: 200, body: { status: 'healthy' } };
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
return ErrorHandler.toProxyError(503, 'UNHEALTHY', String(error));
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
shutdown: async () => {
|
|
137
|
+
const closeFunc = pool['close'];
|
|
138
|
+
await closeFunc();
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
export const SqlServerProxyServer = Object.freeze({
|
|
142
|
+
async start(overrides = {}) {
|
|
143
|
+
const config = resolveConfig(overrides);
|
|
144
|
+
try {
|
|
145
|
+
Logger.info(`SQL Server proxy config: proxyHost=${config.host} proxyPort=${config.port} dbHost=${String(config.poolConfig['server'])} dbPort=${String(config.poolConfig['port'])} dbName=${String(config.poolConfig['database'])} dbUser=${String(config.poolConfig['user'])}`);
|
|
146
|
+
}
|
|
147
|
+
catch {
|
|
148
|
+
// noop - logging must not block startup
|
|
149
|
+
}
|
|
150
|
+
const pool = await createPool(config.poolConfig);
|
|
151
|
+
const backend = createBackend(pool);
|
|
152
|
+
const proxy = createProxyServer({
|
|
153
|
+
host: config.host,
|
|
154
|
+
port: config.port,
|
|
155
|
+
maxBodyBytes: config.maxBodyBytes,
|
|
156
|
+
backend,
|
|
157
|
+
verify: async (req, body) => {
|
|
158
|
+
const verified = await verifyRequestSignature(req, body, config, 'SqlServerProxyServer');
|
|
159
|
+
if (!verified.ok && verified.error) {
|
|
160
|
+
return { ok: false, status: verified.error.status, message: verified.error.message };
|
|
161
|
+
}
|
|
162
|
+
return { ok: true };
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
await proxy.start();
|
|
166
|
+
Logger.info(`✓ SQL Server proxy listening on ${config.host}:${config.port}`);
|
|
167
|
+
},
|
|
168
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../../src/proxy/sqlserver/register.ts"],"names":[],"mappings":""}
|
package/src/routes/doc.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../../src/routes/doc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AAEH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,4BAA4B,EAC5B,aAAa,EACb,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"doc.d.ts","sourceRoot":"","sources":["../../../src/routes/doc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AAEH,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,uBAAuB,EACvB,4BAA4B,EAC5B,aAAa,EACb,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AAkCjC;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,UAAU,SAAS,KAAG,IAWhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAS,MAAM,EACf,UAAU,SAAS,KAClB,OAAO,CAAC,OAAO,CAgDjB,CAAC;AASF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,OAAO,KAAG,IAMnD,CAAC;;gCANwC,OAAO,KAAG,IAAI;2CA5EH,SAAS,KAAG,IAAI;2CAiB1D,MAAM,YACL,SAAS,KAClB,OAAO,CAAC,OAAO,CAAC;;AAiEnB,wBAIE"}
|
package/src/routes/doc.js
CHANGED
|
@@ -16,8 +16,22 @@ export { MIME_TYPES_MAP } from './common.js';
|
|
|
16
16
|
*/
|
|
17
17
|
// Backward-compatible re-exports
|
|
18
18
|
export { findPackageRoot, findPackageRootAsync, getFrameworkPublicRoots, getFrameworkPublicRootsAsync, getPublicRoot, getPublicRootAsync, } from './publicRoot.js';
|
|
19
|
+
const PUBLIC_ROOT_CACHE_TTL_MS = 3000000000; //50 minutes, effectively caching for the duration of typical dev sessions
|
|
20
|
+
let cachedPublicRoot = null;
|
|
21
|
+
const getCachedPublicRootAsync = async () => {
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
if (cachedPublicRoot !== null && cachedPublicRoot.expiresAt > now) {
|
|
24
|
+
return cachedPublicRoot.value;
|
|
25
|
+
}
|
|
26
|
+
const resolved = await getPublicRootAsync();
|
|
27
|
+
cachedPublicRoot = {
|
|
28
|
+
value: resolved,
|
|
29
|
+
expiresAt: now + PUBLIC_ROOT_CACHE_TTL_MS,
|
|
30
|
+
};
|
|
31
|
+
return resolved;
|
|
32
|
+
};
|
|
19
33
|
const mapStaticPathAsync = async (urlPath) => {
|
|
20
|
-
const publicRoot = await
|
|
34
|
+
const publicRoot = await getCachedPublicRootAsync();
|
|
21
35
|
const normalize = (p) => (p.startsWith('/') ? p.slice(1) : p);
|
|
22
36
|
if (urlPath === '/doc' || urlPath === '/doc/')
|
|
23
37
|
return publicRoot;
|
|
@@ -94,7 +108,7 @@ const handleDocRequest = async (req, res) => {
|
|
|
94
108
|
const urlPath = req.getPath();
|
|
95
109
|
if (await serveDocumentationFileAsync(urlPath, res))
|
|
96
110
|
return;
|
|
97
|
-
ErrorRouting.handleNotFound(req, res);
|
|
111
|
+
await ErrorRouting.handleNotFound(req, res);
|
|
98
112
|
};
|
|
99
113
|
export const registerDocRoutes = (router) => {
|
|
100
114
|
// Root docs entrypoints.
|
package/src/routes/error.d.ts
CHANGED
|
@@ -10,12 +10,13 @@ import type * as http from '../node-singletons/http';
|
|
|
10
10
|
* Debug routes to always render 404/500 responses.
|
|
11
11
|
*/
|
|
12
12
|
export declare const registerErrorRoutes: (router: IRouter) => void;
|
|
13
|
-
|
|
13
|
+
type ErrorRoutingApi = {
|
|
14
14
|
getPublicRoot: () => string;
|
|
15
15
|
registerErrorRoutes: (router: IRouter) => void;
|
|
16
|
-
handleNotFound: (request: IRequest, response: IResponse, requestId?: string) => void
|
|
17
|
-
handleInternalServerErrorWithWrappers: (request: IRequest, response: IResponse, error: unknown, requestId?: string) => void
|
|
16
|
+
handleNotFound: (request: IRequest, response: IResponse, requestId?: string) => Promise<void>;
|
|
17
|
+
handleInternalServerErrorWithWrappers: (request: IRequest, response: IResponse, error: unknown, requestId?: string) => Promise<void>;
|
|
18
18
|
handleInternalServerErrorRaw: (res: http.ServerResponse) => void;
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
|
+
export declare const ErrorRouting: ErrorRoutingApi;
|
|
20
21
|
export default ErrorRouting;
|
|
21
22
|
//# sourceMappingURL=error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/routes/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/routes/error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAKnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,KAAK,IAAI,MAAM,uBAAuB,CAAC;AA0KnD;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,OAAO,KAAG,IAGrD,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,aAAa,EAAE,MAAM,MAAM,CAAC;IAC5B,mBAAmB,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/C,cAAc,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9F,qCAAqC,EAAE,CACrC,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,SAAS,EACnB,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,MAAM,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,4BAA4B,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC;CAClE,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,eAMzB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
package/src/routes/error.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { appConfig } from '../config/app.js';
|
|
6
6
|
import { HTTP_HEADERS, MIME_TYPES } from '../config/constants.js';
|
|
7
|
-
import {
|
|
7
|
+
import { serveErrorPagesFileAsync, serveZintrustSvgFile, serveZintrustSvgFileAsync, } from './errorPages.js';
|
|
8
8
|
import { getPublicRoot } from './publicRoot.js';
|
|
9
9
|
import { Router } from './Router.js';
|
|
10
10
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
@@ -31,11 +31,11 @@ const safeJsonStringify = (value) => {
|
|
|
31
31
|
return '';
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
const trySendHtmlErrorPage = (request, response, input) => {
|
|
34
|
+
const trySendHtmlErrorPage = async (request, response, input) => {
|
|
35
35
|
if (!ErrorPageRenderer.shouldSendHtml(request))
|
|
36
36
|
return false;
|
|
37
37
|
const publicRoot = getPublicRoot();
|
|
38
|
-
const html = ErrorPageRenderer.
|
|
38
|
+
const html = await ErrorPageRenderer.renderHtmlAsync(publicRoot, {
|
|
39
39
|
statusCode: input.statusCode,
|
|
40
40
|
errorName: input.errorName,
|
|
41
41
|
errorMessage: input.errorMessage,
|
|
@@ -50,18 +50,20 @@ const trySendHtmlErrorPage = (request, response, input) => {
|
|
|
50
50
|
response.html(html);
|
|
51
51
|
return true;
|
|
52
52
|
};
|
|
53
|
-
const handleNotFound = (request, response, requestId) => {
|
|
53
|
+
const handleNotFound = async (request, response, requestId) => {
|
|
54
54
|
const path = request.getPath();
|
|
55
55
|
if (path.startsWith('/error-pages/')) {
|
|
56
|
-
|
|
56
|
+
await serveErrorPagesFileAsync(path, response);
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
if (path === '/zintrust.svg') {
|
|
60
|
-
|
|
60
|
+
if (!(await serveZintrustSvgFileAsync(response))) {
|
|
61
|
+
serveZintrustSvgFile(response);
|
|
62
|
+
}
|
|
61
63
|
return;
|
|
62
64
|
}
|
|
63
65
|
response.setStatus(404);
|
|
64
|
-
if (trySendHtmlErrorPage(request, response, {
|
|
66
|
+
if (await trySendHtmlErrorPage(request, response, {
|
|
65
67
|
statusCode: 404,
|
|
66
68
|
errorName: 'Not Found',
|
|
67
69
|
errorMessage: 'The page you requested could not be found.',
|
|
@@ -70,7 +72,7 @@ const handleNotFound = (request, response, requestId) => {
|
|
|
70
72
|
}
|
|
71
73
|
response.json(ErrorResponse.notFound('Route', requestId));
|
|
72
74
|
};
|
|
73
|
-
const handleInternalServerErrorWithWrappers = (request, response, error, requestId) => {
|
|
75
|
+
const handleInternalServerErrorWithWrappers = async (request, response, error, requestId) => {
|
|
74
76
|
response.setStatus(500);
|
|
75
77
|
const isDev = appConfig.isDevelopment();
|
|
76
78
|
const err = error instanceof Error ? error : ErrorFactory.createGeneralError('Unknown error', error);
|
|
@@ -94,7 +96,7 @@ const handleInternalServerErrorWithWrappers = (request, response, error, request
|
|
|
94
96
|
const stackRaw = isDev
|
|
95
97
|
? safeJsonStringify({ name: err.name, message: err.message, stack: err.stack })
|
|
96
98
|
: undefined;
|
|
97
|
-
if (trySendHtmlErrorPage(request, response, {
|
|
99
|
+
if (await trySendHtmlErrorPage(request, response, {
|
|
98
100
|
statusCode: 500,
|
|
99
101
|
errorName,
|
|
100
102
|
errorMessage,
|
|
@@ -111,14 +113,14 @@ const handleInternalServerErrorRaw = (res) => {
|
|
|
111
113
|
res.writeHead(500, { [HTTP_HEADERS.CONTENT_TYPE]: MIME_TYPES.JSON });
|
|
112
114
|
res.end(JSON.stringify(ErrorResponse.internalServerError('Internal server error')));
|
|
113
115
|
};
|
|
114
|
-
const handleForced404 = (req, res) => {
|
|
115
|
-
handleNotFound(req, res);
|
|
116
|
+
const handleForced404 = async (req, res) => {
|
|
117
|
+
await handleNotFound(req, res);
|
|
116
118
|
};
|
|
117
|
-
const handleForced500 = (req, res) => {
|
|
119
|
+
const handleForced500 = async (req, res) => {
|
|
118
120
|
const forced = ErrorFactory.createGeneralError('Forced 500 route', {
|
|
119
121
|
route: '/500',
|
|
120
122
|
});
|
|
121
|
-
handleInternalServerErrorWithWrappers(req, res, forced);
|
|
123
|
+
await handleInternalServerErrorWithWrappers(req, res, forced);
|
|
122
124
|
};
|
|
123
125
|
/**
|
|
124
126
|
* Debug routes to always render 404/500 responses.
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
import type { IRouter } from './Router';
|
|
6
6
|
import type { IResponse } from '../http/Response';
|
|
7
7
|
export declare const serveErrorPagesFile: (urlPath: string, response: IResponse) => boolean;
|
|
8
|
+
export declare const serveErrorPagesFileAsync: (urlPath: string, response: IResponse) => Promise<boolean>;
|
|
8
9
|
export declare const serveZintrustSvgFile: (response: IResponse) => boolean;
|
|
10
|
+
export declare const serveZintrustSvgFileAsync: (response: IResponse) => Promise<boolean>;
|
|
9
11
|
export declare const registerErrorPagesRoutes: (router: IRouter) => void;
|
|
10
12
|
declare const _default: {
|
|
11
13
|
registerErrorPagesRoutes: (router: IRouter) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorPages.d.ts","sourceRoot":"","sources":["../../../src/routes/errorPages.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"errorPages.d.ts","sourceRoot":"","sources":["../../../src/routes/errorPages.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAInD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA8JhD,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,EAAE,UAAU,SAAS,KAAG,OAkD1E,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,SAAS,MAAM,EACf,UAAU,SAAS,KAClB,OAAO,CAAC,OAAO,CA4CjB,CAAC;AAmBF,eAAO,MAAM,oBAAoB,GAAI,UAAU,SAAS,KAAG,OAE1D,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAU,UAAU,SAAS,KAAG,OAAO,CAAC,OAAO,CAKpF,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,OAAO,KAAG,IAO1D,CAAC;;uCAP+C,OAAO,KAAG,IAAI;mCAjIlB,MAAM,YAAY,SAAS,KAAG,OAAO;;AA0IlF,wBAAiE"}
|
package/src/routes/errorPages.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Error Pages Static Assets
|
|
3
3
|
* Serves /error-pages/* assets (CSS/JS/SVG/etc) used by HTML error templates.
|
|
4
4
|
*/
|
|
5
|
+
import { Cloudflare } from '../config/cloudflare.js';
|
|
5
6
|
import { HTTP_HEADERS, MIME_TYPES } from '../config/constants.js';
|
|
6
7
|
import { MIME_TYPES_MAP, resolveSafePath, tryDecodeURIComponent } from './common.js';
|
|
7
8
|
import { getFrameworkPublicRoots } from './publicRoot.js';
|
|
@@ -14,6 +15,74 @@ const getCandidatePublicRoots = () => {
|
|
|
14
15
|
const unique = new Set(roots.map((root) => root.trim()).filter((root) => root !== ''));
|
|
15
16
|
return [...unique];
|
|
16
17
|
};
|
|
18
|
+
const pathExistsAsync = async (candidate) => {
|
|
19
|
+
try {
|
|
20
|
+
await fs.fsPromises.access(candidate);
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const isFileAsync = async (candidate) => {
|
|
28
|
+
try {
|
|
29
|
+
const stats = await fs.fsPromises.stat(candidate);
|
|
30
|
+
return stats.isFile();
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const findFirstExistingFileAsync = async (candidates) => {
|
|
37
|
+
const results = await Promise.all(candidates.map(async (candidate) => ({
|
|
38
|
+
candidate,
|
|
39
|
+
isFile: await isFileAsync(candidate),
|
|
40
|
+
})));
|
|
41
|
+
return results.find((result) => result.isFile)?.candidate;
|
|
42
|
+
};
|
|
43
|
+
const resolveErrorPageFilePathAsync = async (candidateRoots, normalizedRelative) => {
|
|
44
|
+
const checks = await Promise.all(candidateRoots.map(async (root) => {
|
|
45
|
+
const baseDir = path.join(root, 'error-pages');
|
|
46
|
+
const filePath = resolveSafePath(baseDir, normalizedRelative);
|
|
47
|
+
if (filePath === undefined)
|
|
48
|
+
return undefined;
|
|
49
|
+
try {
|
|
50
|
+
const stats = await fs.fsPromises.stat(filePath);
|
|
51
|
+
if (stats.isDirectory())
|
|
52
|
+
return undefined;
|
|
53
|
+
return filePath;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
return checks.find((filePath) => typeof filePath === 'string');
|
|
60
|
+
};
|
|
61
|
+
const servePublicRootFileAsync = async (relativePath, response, contentType) => {
|
|
62
|
+
const candidateRoots = getCandidatePublicRoots();
|
|
63
|
+
const candidates = candidateRoots.map((root) => path.join(root, relativePath));
|
|
64
|
+
const filePath = await findFirstExistingFileAsync(candidates);
|
|
65
|
+
try {
|
|
66
|
+
if (filePath === undefined || filePath === null) {
|
|
67
|
+
response.setStatus(404);
|
|
68
|
+
response.setHeader(HTTP_HEADERS.CONTENT_TYPE, MIME_TYPES.TEXT);
|
|
69
|
+
response.send('Not Found');
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const content = await fs.fsPromises.readFile(filePath);
|
|
73
|
+
response.setStatus(200);
|
|
74
|
+
response.setHeader(HTTP_HEADERS.CONTENT_TYPE, contentType);
|
|
75
|
+
response.send(content);
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
ErrorFactory.createTryCatchError(`Error serving public file ${filePath}`, error);
|
|
80
|
+
response.setStatus(500);
|
|
81
|
+
response.setHeader(HTTP_HEADERS.CONTENT_TYPE, MIME_TYPES.TEXT);
|
|
82
|
+
response.send('Internal Server Error');
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
17
86
|
const findFirstExistingFile = (candidates) => {
|
|
18
87
|
for (const candidate of candidates) {
|
|
19
88
|
try {
|
|
@@ -51,6 +120,28 @@ const servePublicRootFile = (relativePath, response, contentType) => {
|
|
|
51
120
|
return false;
|
|
52
121
|
}
|
|
53
122
|
};
|
|
123
|
+
const serveAssetsFileAsync = async (urlPath, response) => {
|
|
124
|
+
const assets = Cloudflare.getAssetsBinding();
|
|
125
|
+
if (!assets)
|
|
126
|
+
return false;
|
|
127
|
+
try {
|
|
128
|
+
const url = new URL(urlPath, 'https://assets.local');
|
|
129
|
+
const res = await assets.fetch(url.toString());
|
|
130
|
+
const contentType = res.headers.get(HTTP_HEADERS.CONTENT_TYPE) ?? MIME_TYPES.TEXT;
|
|
131
|
+
const body = Buffer.from(await res.arrayBuffer());
|
|
132
|
+
response.setStatus(res.status);
|
|
133
|
+
response.setHeader(HTTP_HEADERS.CONTENT_TYPE, contentType);
|
|
134
|
+
response.send(body);
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
ErrorFactory.createTryCatchError(`Error serving asset ${urlPath}`, error);
|
|
139
|
+
response.setStatus(500);
|
|
140
|
+
response.setHeader(HTTP_HEADERS.CONTENT_TYPE, MIME_TYPES.TEXT);
|
|
141
|
+
response.send('Internal Server Error');
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
54
145
|
export const serveErrorPagesFile = (urlPath, response) => {
|
|
55
146
|
if (urlPath === '/error-pages' || urlPath === '/error-pages/') {
|
|
56
147
|
response.setStatus(404);
|
|
@@ -96,20 +187,69 @@ export const serveErrorPagesFile = (urlPath, response) => {
|
|
|
96
187
|
response.send('Not Found');
|
|
97
188
|
return true;
|
|
98
189
|
};
|
|
99
|
-
const
|
|
190
|
+
export const serveErrorPagesFileAsync = async (urlPath, response) => {
|
|
191
|
+
if (urlPath === '/error-pages' || urlPath === '/error-pages/') {
|
|
192
|
+
response.setStatus(404);
|
|
193
|
+
response.setHeader(HTTP_HEADERS.CONTENT_TYPE, MIME_TYPES.TEXT);
|
|
194
|
+
response.send('Not Found');
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
if (!urlPath.startsWith('/error-pages/'))
|
|
198
|
+
return false;
|
|
199
|
+
if (Cloudflare.getWorkersEnv() !== null) {
|
|
200
|
+
return serveAssetsFileAsync(urlPath, response);
|
|
201
|
+
}
|
|
202
|
+
const candidateRoots = getCandidatePublicRoots();
|
|
203
|
+
const rawRelative = urlPath.slice('/error-pages/'.length);
|
|
204
|
+
const normalizedRelative = tryDecodeURIComponent(rawRelative).replaceAll('\\', '/');
|
|
205
|
+
const filePath = await resolveErrorPageFilePathAsync(candidateRoots, normalizedRelative);
|
|
206
|
+
try {
|
|
207
|
+
if (filePath !== undefined && (await pathExistsAsync(filePath))) {
|
|
208
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
209
|
+
const contentType = MIME_TYPES_MAP[ext] || 'application/octet-stream';
|
|
210
|
+
const content = await fs.fsPromises.readFile(filePath);
|
|
211
|
+
response.setStatus(200);
|
|
212
|
+
response.setHeader(HTTP_HEADERS.CONTENT_TYPE, contentType);
|
|
213
|
+
response.send(content);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
ErrorFactory.createTryCatchError(`Error serving error-pages file ${filePath}`, error);
|
|
219
|
+
response.setStatus(500);
|
|
220
|
+
response.setHeader(HTTP_HEADERS.CONTENT_TYPE, MIME_TYPES.TEXT);
|
|
221
|
+
response.send('Internal Server Error');
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
response.setStatus(404);
|
|
225
|
+
response.setHeader(HTTP_HEADERS.CONTENT_TYPE, MIME_TYPES.TEXT);
|
|
226
|
+
response.send('Not Found');
|
|
227
|
+
return true;
|
|
228
|
+
};
|
|
229
|
+
const handleErrorPagesRequest = async (req, res) => {
|
|
100
230
|
const urlPath = req.getPath();
|
|
101
|
-
if (
|
|
231
|
+
if (await serveErrorPagesFileAsync(urlPath, res))
|
|
102
232
|
return;
|
|
103
233
|
res.setStatus(404);
|
|
104
234
|
res.setHeader(HTTP_HEADERS.CONTENT_TYPE, MIME_TYPES.TEXT);
|
|
105
235
|
res.send('Not Found');
|
|
106
236
|
};
|
|
107
|
-
const handleZintrustSvgRequest = (_req, res) => {
|
|
108
|
-
|
|
237
|
+
const handleZintrustSvgRequest = async (_req, res) => {
|
|
238
|
+
if (Cloudflare.getWorkersEnv() !== null) {
|
|
239
|
+
await serveAssetsFileAsync('/zintrust.svg', res);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
await servePublicRootFileAsync('zintrust.svg', res, MIME_TYPES.SVG);
|
|
109
243
|
};
|
|
110
244
|
export const serveZintrustSvgFile = (response) => {
|
|
111
245
|
return servePublicRootFile('zintrust.svg', response, MIME_TYPES.SVG);
|
|
112
246
|
};
|
|
247
|
+
export const serveZintrustSvgFileAsync = async (response) => {
|
|
248
|
+
if (Cloudflare.getWorkersEnv() !== null) {
|
|
249
|
+
return serveAssetsFileAsync('/zintrust.svg', response);
|
|
250
|
+
}
|
|
251
|
+
return servePublicRootFileAsync('zintrust.svg', response, MIME_TYPES.SVG);
|
|
252
|
+
};
|
|
113
253
|
export const registerErrorPagesRoutes = (router) => {
|
|
114
254
|
Router.get(router, '/error-pages', handleErrorPagesRequest);
|
|
115
255
|
Router.get(router, '/error-pages/', handleErrorPagesRequest);
|
|
@@ -16,6 +16,7 @@ export declare const PluginAutoImports: Readonly<{
|
|
|
16
16
|
* adapters/drivers into core registries.
|
|
17
17
|
*/
|
|
18
18
|
tryImportProjectAutoImports(): Promise<ImportResult>;
|
|
19
|
+
tryImportFromFileContents(files: string[]): Promise<ImportResult>;
|
|
19
20
|
}>;
|
|
20
21
|
export {};
|
|
21
22
|
//# sourceMappingURL=PluginAutoImports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginAutoImports.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginAutoImports.ts"],"names":[],"mappings":"AAMA,KAAK,YAAY,GACb;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAChC;IACE,EAAE,EAAE,KAAK,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,eAAe,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"PluginAutoImports.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginAutoImports.ts"],"names":[],"mappings":"AAMA,KAAK,YAAY,GACb;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAChC;IACE,EAAE,EAAE,KAAK,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,eAAe,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AA0GN,eAAO,MAAM,iBAAiB;IAC5B;;;;;;OAMG;mCACkC,OAAO,CAAC,YAAY,CAAC;qCAmEnB,MAAM,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC;EAavE,CAAC"}
|