@zintrust/core 0.1.40 → 0.1.42
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 +24 -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 -290
- package/src/boot/Server.d.ts +1 -1
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/bootstrap.js +50 -16
- 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 +364 -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 +94 -34
- package/src/cli/ErrorHandler.js +1 -1
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/ConfigCommand.js +3 -5
- 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/D1LearnCommand.d.ts +9 -0
- package/src/cli/commands/D1LearnCommand.d.ts.map +1 -0
- package/src/cli/commands/D1LearnCommand.js +143 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +55 -16
- 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 +231 -0
- package/src/cli/commands/InitEcosystemCommand.d.ts +6 -0
- package/src/cli/commands/InitEcosystemCommand.d.ts.map +1 -0
- package/src/cli/commands/InitEcosystemCommand.js +51 -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/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +78 -36
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateWorkerCommand.js +36 -2
- 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/PutCommand.d.ts +6 -0
- package/src/cli/commands/PutCommand.d.ts.map +1 -0
- package/src/cli/commands/PutCommand.js +173 -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 +612 -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/ScheduleListCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleListCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleListCommand.js +62 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleRunCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleRunCommand.js +32 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts +6 -0
- package/src/cli/commands/ScheduleStartCommand.d.ts.map +1 -0
- package/src/cli/commands/ScheduleStartCommand.js +40 -0
- package/src/cli/commands/SecretsCommand.d.ts.map +1 -1
- package/src/cli/commands/SecretsCommand.js +2 -2
- 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 +132 -17
- 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/commands/schedule/ScheduleCliSupport.d.ts +6 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts.map +1 -0
- package/src/cli/commands/schedule/ScheduleCliSupport.js +55 -0
- package/src/cli/config/ConfigManager.d.ts.map +1 -1
- package/src/cli/config/ConfigManager.js +8 -1
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +14 -1
- package/src/cli/d1/WranglerConfig.d.ts.map +1 -1
- package/src/cli/d1/WranglerConfig.js +34 -2
- 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/services/VersionChecker.d.ts.map +1 -1
- package/src/cli/services/VersionChecker.js +5 -1
- package/src/cli/utils/DatabaseCliUtils.d.ts.map +1 -1
- package/src/cli/utils/DatabaseCliUtils.js +6 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/cli/utils/EnvFileLoader.js +35 -15
- package/src/cli/workers/QueueWorkRunner.js +1 -1
- package/src/cli.d.ts +5 -0
- package/src/cli.d.ts.map +1 -0
- package/src/cli.js +4 -0
- package/src/collections/index.d.ts +2 -2
- package/src/collections/index.d.ts.map +1 -1
- package/src/collections/index.js +1 -1
- 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 +81 -29
- 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/common/utility.d.ts.map +1 -1
- package/src/common/utility.js +2 -6
- 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 +67 -8
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +48 -13
- package/src/config/env.d.ts +87 -2
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +158 -19
- package/src/config/index.d.ts +1 -0
- package/src/config/index.d.ts.map +1 -1
- 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 +18 -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/helper/index.d.ts +225 -0
- package/src/helper/index.d.ts.map +1 -0
- package/src/helper/index.js +347 -0
- 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 +26 -57
- package/src/index.d.ts.map +1 -1
- package/src/index.js +32 -18
- 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 +30 -16
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -1
- package/src/middleware/ErrorHandlerMiddleware.js +2 -1
- package/src/migrations/MigrationDiscovery.d.ts.map +1 -1
- package/src/migrations/MigrationDiscovery.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/DatabaseAdapter.d.ts +1 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- 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/SchemaStatemenWriter.d.ts +15 -0
- package/src/orm/SchemaStatemenWriter.d.ts.map +1 -0
- package/src/orm/SchemaStatemenWriter.js +78 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +52 -2
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +150 -89
- 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 +162 -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 +163 -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 +36 -0
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts +12 -0
- package/src/orm/adapters/SqlProxyRegistryMode.d.ts.map +1 -0
- package/src/orm/adapters/SqlProxyRegistryMode.js +24 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts +6 -0
- package/src/orm/adapters/SqlServerProxyAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SqlServerProxyAdapter.js +154 -0
- package/src/orm/migrations/MigrationStore.js +1 -1
- 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/ProxyRequestParsing.d.ts +9 -0
- package/src/proxy/ProxyRequestParsing.d.ts.map +1 -0
- package/src/proxy/ProxyRequestParsing.js +16 -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 +26 -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/SqlProxyDbOverrides.d.ts +17 -0
- package/src/proxy/SqlProxyDbOverrides.d.ts.map +1 -0
- package/src/proxy/SqlProxyDbOverrides.js +1 -0
- package/src/proxy/SqlProxyServerDeps.d.ts +12 -0
- package/src/proxy/SqlProxyServerDeps.d.ts.map +1 -0
- package/src/proxy/SqlProxyServerDeps.js +9 -0
- package/src/proxy/StatementPayloadValidator.d.ts +13 -0
- package/src/proxy/StatementPayloadValidator.d.ts.map +1 -0
- package/src/proxy/StatementPayloadValidator.js +18 -0
- package/src/proxy/StatementRegistryLoader.d.ts +2 -0
- package/src/proxy/StatementRegistryLoader.d.ts.map +1 -0
- package/src/proxy/StatementRegistryLoader.js +36 -0
- package/src/proxy/StatementRegistryResolver.d.ts +15 -0
- package/src/proxy/StatementRegistryResolver.d.ts.map +1 -0
- package/src/proxy/StatementRegistryResolver.js +34 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts +3 -0
- package/src/proxy/d1/ZintrustD1Proxy.d.ts.map +1 -0
- package/src/proxy/d1/ZintrustD1Proxy.js +2 -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/isMutatingSql.d.ts +2 -0
- package/src/proxy/isMutatingSql.d.ts.map +1 -0
- package/src/proxy/isMutatingSql.js +12 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts +3 -0
- package/src/proxy/kv/ZintrustKvProxy.d.ts.map +1 -0
- package/src/proxy/kv/ZintrustKvProxy.js +2 -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 +8 -0
- package/src/proxy/mysql/MySqlProxyServer.d.ts.map +1 -0
- package/src/proxy/mysql/MySqlProxyServer.js +202 -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 +8 -0
- package/src/proxy/postgres/PostgresProxyServer.d.ts.map +1 -0
- package/src/proxy/postgres/PostgresProxyServer.js +178 -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 +290 -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 +8 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.d.ts.map +1 -0
- package/src/proxy/sqlserver/SqlServerProxyServer.js +203 -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/proxy.d.ts +4 -0
- package/src/proxy.d.ts.map +1 -0
- package/src/proxy.js +3 -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/scheduler/Schedule.d.ts +36 -0
- package/src/scheduler/Schedule.d.ts.map +1 -0
- package/src/scheduler/Schedule.js +197 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts +8 -0
- package/src/scheduler/ScheduleHttpGateway.d.ts.map +1 -0
- package/src/scheduler/ScheduleHttpGateway.js +196 -0
- package/src/scheduler/ScheduleRunner.d.ts +6 -0
- package/src/scheduler/ScheduleRunner.d.ts.map +1 -1
- package/src/scheduler/ScheduleRunner.js +166 -29
- package/src/scheduler/SchedulerRuntime.d.ts +15 -0
- package/src/scheduler/SchedulerRuntime.d.ts.map +1 -0
- package/src/scheduler/SchedulerRuntime.js +79 -0
- package/src/scheduler/cron/Cron.d.ts +19 -0
- package/src/scheduler/cron/Cron.d.ts.map +1 -0
- package/src/scheduler/cron/Cron.js +200 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts +14 -0
- package/src/scheduler/leader/SchedulerLeader.d.ts.map +1 -0
- package/src/scheduler/leader/SchedulerLeader.js +187 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts +27 -0
- package/src/scheduler/state/ScheduleStateStore.d.ts.map +1 -0
- package/src/scheduler/state/ScheduleStateStore.js +27 -0
- package/src/scheduler/types.d.ts +10 -0
- package/src/scheduler/types.d.ts.map +1 -1
- package/src/schedules/index.d.ts +1 -0
- package/src/schedules/index.d.ts.map +1 -1
- package/src/schedules/index.js +1 -0
- package/src/schedules/job-tracking-cleanup.d.ts +4 -0
- package/src/schedules/job-tracking-cleanup.d.ts.map +1 -0
- package/src/schedules/job-tracking-cleanup.js +116 -0
- package/src/schedules/log-cleanup.d.ts +1 -2
- package/src/schedules/log-cleanup.d.ts.map +1 -1
- package/src/schedules/log-cleanup.js +12 -15
- package/src/scripts/TemplateImportsCheck.js +2 -2
- package/src/scripts/TemplateSync.js +3 -4
- package/src/security/CsrfTokenManager.d.ts.map +1 -1
- package/src/security/CsrfTokenManager.js +12 -0
- 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/security/Sanitizer.d.ts.map +1 -1
- package/src/security/Sanitizer.js +1 -9
- package/src/security/SignedRequest.d.ts.map +1 -1
- package/src/security/SignedRequest.js +2 -2
- 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/docker/docker-compose.ecosystem.yml.tpl +301 -0
- package/src/templates/docker/docker-compose.schedules.yml.tpl +84 -0
- package/src/templates/project/basic/app/Schedules/index.ts.tpl +0 -0
- package/src/templates/project/basic/config/database.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.wg.ts.tpl +8 -0
- package/src/toolkit/Secrets/Manifest.d.ts.map +1 -1
- package/src/toolkit/Secrets/Manifest.js +5 -7
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -1
- package/src/tools/mail/drivers/Smtp.js +229 -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 +56 -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 +303 -0
- package/src/tools/queue/JobStateTracker.d.ts +140 -0
- package/src/tools/queue/JobStateTracker.d.ts.map +1 -0
- package/src/tools/queue/JobStateTracker.js +409 -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 +239 -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/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,128 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
2
|
+
import { Env } from '../../config/env.js';
|
|
3
|
+
import { Logger } from '../../config/logger.js';
|
|
4
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
5
|
+
import { ProxyCache } from '../adapters/ProxyCache.js';
|
|
6
|
+
import { ensureSignedSettings, isRecord, requestSignedProxy, } from '../adapters/SqlProxyAdapterUtils.js';
|
|
7
|
+
const normalizeRows = (value) => {
|
|
8
|
+
if (value === null)
|
|
9
|
+
return [];
|
|
10
|
+
if (Array.isArray(value))
|
|
11
|
+
return value;
|
|
12
|
+
return [value];
|
|
13
|
+
};
|
|
14
|
+
const extractResultPayload = (response) => {
|
|
15
|
+
if (!isRecord(response))
|
|
16
|
+
return response;
|
|
17
|
+
if ('result' in response)
|
|
18
|
+
return response['result'];
|
|
19
|
+
if ('rows' in response)
|
|
20
|
+
return response['rows'];
|
|
21
|
+
return response;
|
|
22
|
+
};
|
|
23
|
+
const getCacheKey = (collection, operation, args) => {
|
|
24
|
+
return `${collection}:${operation}:${JSON.stringify(args)}`;
|
|
25
|
+
};
|
|
26
|
+
const resolveProxyUrl = () => {
|
|
27
|
+
const url = Env.get('MONGODB_PROXY_URL', '');
|
|
28
|
+
if (typeof url === 'string' && url.trim() !== '')
|
|
29
|
+
return url;
|
|
30
|
+
const host = Env.get('MONGODB_PROXY_HOST', '127.0.0.1');
|
|
31
|
+
const port = Env.getInt('MONGODB_PROXY_PORT', 8792);
|
|
32
|
+
return `http://${host}:${port}`;
|
|
33
|
+
};
|
|
34
|
+
const buildProxySettings = () => {
|
|
35
|
+
const baseUrl = resolveProxyUrl();
|
|
36
|
+
const keyId = Env.get('MONGODB_PROXY_KEY_ID', '');
|
|
37
|
+
const secret = Env.get('MONGODB_PROXY_SECRET', '');
|
|
38
|
+
const timeoutMs = Env.getInt('MONGODB_PROXY_TIMEOUT_MS', 30000);
|
|
39
|
+
return { baseUrl, keyId, secret, timeoutMs };
|
|
40
|
+
};
|
|
41
|
+
const buildSignedProxyConfig = (settings) => ({
|
|
42
|
+
settings,
|
|
43
|
+
missingUrlMessage: 'MongoDB proxy URL is missing',
|
|
44
|
+
missingCredentialsMessage: 'MongoDB proxy signing credentials are missing',
|
|
45
|
+
messages: {
|
|
46
|
+
unauthorized: 'MongoDB proxy unauthorized',
|
|
47
|
+
forbidden: 'MongoDB proxy forbidden',
|
|
48
|
+
rateLimited: 'MongoDB proxy rate limited',
|
|
49
|
+
rejected: 'MongoDB proxy rejected',
|
|
50
|
+
error: 'MongoDB proxy error',
|
|
51
|
+
timedOut: 'MongoDB proxy timed out',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
const MONGODB_OPERATION_PATH = '/zin/mongodb/operation';
|
|
55
|
+
export function createMongoDBProxyAdapter() {
|
|
56
|
+
let connected = false;
|
|
57
|
+
const cache = ProxyCache.create();
|
|
58
|
+
const settings = buildProxySettings();
|
|
59
|
+
return {
|
|
60
|
+
async connect() {
|
|
61
|
+
ensureSignedSettings(buildSignedProxyConfig(settings));
|
|
62
|
+
Logger.info(`Connecting to MongoDB via proxy: ${settings.baseUrl}`);
|
|
63
|
+
connected = true;
|
|
64
|
+
},
|
|
65
|
+
async disconnect() {
|
|
66
|
+
connected = false;
|
|
67
|
+
cache.clear();
|
|
68
|
+
Logger.info('Disconnected from MongoDB proxy');
|
|
69
|
+
},
|
|
70
|
+
async query(_sql, _parameters) {
|
|
71
|
+
if (!connected) {
|
|
72
|
+
throw ErrorFactory.createConnectionError('Not connected to MongoDB proxy');
|
|
73
|
+
}
|
|
74
|
+
// Parse MongoDB-like query (simple implementation)
|
|
75
|
+
// Expected format: collection.operation({...})
|
|
76
|
+
const pattern = /^(\w+)\.(\w+)\((.+)\$/;
|
|
77
|
+
const match = pattern.exec(_sql);
|
|
78
|
+
if (!match) {
|
|
79
|
+
throw ErrorFactory.createGeneralError('Invalid MongoDB query format');
|
|
80
|
+
}
|
|
81
|
+
const [, collection, operation, argsStr] = match;
|
|
82
|
+
const args = JSON.parse(argsStr);
|
|
83
|
+
const cacheKey = getCacheKey(collection, operation, args);
|
|
84
|
+
const cached = cache.get(cacheKey);
|
|
85
|
+
if (cached)
|
|
86
|
+
return cached;
|
|
87
|
+
const response = await requestSignedProxy(buildSignedProxyConfig({
|
|
88
|
+
...settings,
|
|
89
|
+
signaturePathPrefixToStrip: MONGODB_OPERATION_PATH,
|
|
90
|
+
}), MONGODB_OPERATION_PATH, { collection, operation, args });
|
|
91
|
+
const result = extractResultPayload(response);
|
|
92
|
+
const rows = normalizeRows(result);
|
|
93
|
+
const queryResult = {
|
|
94
|
+
rows,
|
|
95
|
+
rowCount: rows.length,
|
|
96
|
+
};
|
|
97
|
+
cache.set(cacheKey, queryResult);
|
|
98
|
+
return queryResult;
|
|
99
|
+
},
|
|
100
|
+
async queryOne(sql, parameters) {
|
|
101
|
+
const result = await this.query(sql, parameters);
|
|
102
|
+
return result.rows[0] ?? null;
|
|
103
|
+
},
|
|
104
|
+
async ping() {
|
|
105
|
+
if (!connected) {
|
|
106
|
+
throw ErrorFactory.createConnectionError('Not connected to MongoDB proxy');
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
async transaction(callback) {
|
|
110
|
+
// MongoDB proxy doesn't support traditional transactions via HTTP
|
|
111
|
+
Logger.warn('MongoDB proxy adapter does not support transactions');
|
|
112
|
+
return callback(this);
|
|
113
|
+
},
|
|
114
|
+
async rawQuery(sql, parameters) {
|
|
115
|
+
const result = await this.query(sql, parameters ?? []);
|
|
116
|
+
return result.rows;
|
|
117
|
+
},
|
|
118
|
+
getType() {
|
|
119
|
+
return 'mongodb-proxy';
|
|
120
|
+
},
|
|
121
|
+
isConnected() {
|
|
122
|
+
return connected;
|
|
123
|
+
},
|
|
124
|
+
getPlaceholder(index) {
|
|
125
|
+
return `$${index}`;
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MySQL Proxy Adapter (HTTP)
|
|
3
|
+
*
|
|
4
|
+
* Used in Cloudflare Workers when MYSQL_PROXY_URL is configured.
|
|
5
|
+
*/
|
|
6
|
+
import type { DatabaseConfig, IDatabaseAdapter } from '../DatabaseAdapter';
|
|
7
|
+
export declare const MySQLProxyAdapter: Readonly<{
|
|
8
|
+
create(_config: DatabaseConfig): IDatabaseAdapter;
|
|
9
|
+
}>;
|
|
10
|
+
export default MySQLProxyAdapter;
|
|
11
|
+
//# sourceMappingURL=MySQLProxyAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MySQLProxyAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/MySQLProxyAdapter.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAkBH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAiN1F,eAAO,MAAM,iBAAiB;oBACZ,cAAc,GAAG,gBAAgB;EAajD,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
2
|
+
/**
|
|
3
|
+
* MySQL Proxy Adapter (HTTP)
|
|
4
|
+
*
|
|
5
|
+
* Used in Cloudflare Workers when MYSQL_PROXY_URL is configured.
|
|
6
|
+
*/
|
|
7
|
+
import { Env } from '../../config/env.js';
|
|
8
|
+
import { Logger } from '../../config/logger.js';
|
|
9
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
10
|
+
import { AdaptersEnum } from '../../migrations/enum/index.js';
|
|
11
|
+
import { ensureSignedSettings, isRecord, requestSignedProxy, } from '../adapters/SqlProxyAdapterUtils.js';
|
|
12
|
+
import { createStatementPayload, getExecMetaWithLastRowId, resolveSqlProxyMode, } from '../adapters/SqlProxyRegistryMode.js';
|
|
13
|
+
import { QueryBuilder } from '../QueryBuilder.js';
|
|
14
|
+
const buildProxySettings = () => {
|
|
15
|
+
const baseUrl = Env.MYSQL_PROXY_URL;
|
|
16
|
+
const keyId = Env.MYSQL_PROXY_KEY_ID ?? '';
|
|
17
|
+
const secret = Env.MYSQL_PROXY_SECRET ?? '';
|
|
18
|
+
const timeoutMs = Env.MYSQL_PROXY_TIMEOUT_MS;
|
|
19
|
+
return { baseUrl, keyId, secret, timeoutMs };
|
|
20
|
+
};
|
|
21
|
+
const buildSignedProxyConfig = (settings) => ({
|
|
22
|
+
settings,
|
|
23
|
+
missingUrlMessage: 'MySQL proxy URL is missing (MYSQL_PROXY_URL)',
|
|
24
|
+
missingCredentialsMessage: 'MySQL proxy signing credentials are missing (MYSQL_PROXY_KEY_ID / MYSQL_PROXY_SECRET)',
|
|
25
|
+
messages: {
|
|
26
|
+
unauthorized: 'MySQL proxy unauthorized',
|
|
27
|
+
forbidden: 'MySQL proxy forbidden',
|
|
28
|
+
rateLimited: 'MySQL proxy rate limited',
|
|
29
|
+
rejected: 'MySQL proxy rejected request',
|
|
30
|
+
error: 'MySQL proxy error',
|
|
31
|
+
timedOut: 'MySQL proxy request timed out',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const isQueryResponse = (value) => isRecord(value) && Array.isArray(value['rows']) && typeof value['rowCount'] === 'number';
|
|
35
|
+
const isQueryOneResponse = (value) => isRecord(value) && 'row' in value;
|
|
36
|
+
const requestProxy = async (settings, path, payload) => {
|
|
37
|
+
const signedProxyConfig = buildSignedProxyConfig(settings);
|
|
38
|
+
try {
|
|
39
|
+
return await requestSignedProxy(signedProxyConfig, path, payload);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
Logger.error('[MySQLProxyAdapter] Proxy request failed', {
|
|
43
|
+
path,
|
|
44
|
+
baseUrl: settings.baseUrl,
|
|
45
|
+
timeoutMs: settings.timeoutMs,
|
|
46
|
+
hasKeyId: (settings.keyId ?? '').trim() !== '',
|
|
47
|
+
hasSecret: (settings.secret ?? '').trim() !== '',
|
|
48
|
+
error: error instanceof Error ? error.message : String(error),
|
|
49
|
+
});
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const resolveProxyMode = () => {
|
|
54
|
+
return resolveSqlProxyMode('MYSQL_PROXY_MODE');
|
|
55
|
+
};
|
|
56
|
+
const requireConnected = (state) => {
|
|
57
|
+
if (!state.connected)
|
|
58
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
59
|
+
};
|
|
60
|
+
const toQueryResult = (out) => {
|
|
61
|
+
if (isQueryResponse(out)) {
|
|
62
|
+
return {
|
|
63
|
+
rows: out.rows,
|
|
64
|
+
rowCount: out.rowCount,
|
|
65
|
+
lastInsertId: out.lastInsertId,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (isQueryOneResponse(out)) {
|
|
69
|
+
const row = out.row;
|
|
70
|
+
return { rows: row ? [row] : [], rowCount: row ? 1 : 0 };
|
|
71
|
+
}
|
|
72
|
+
const meta = getExecMetaWithLastRowId(out);
|
|
73
|
+
return { rows: [], rowCount: meta.changes, lastInsertId: meta.lastRowId };
|
|
74
|
+
};
|
|
75
|
+
const createQuery = (state) => async (sql, parameters) => {
|
|
76
|
+
requireConnected(state);
|
|
77
|
+
const mode = resolveProxyMode();
|
|
78
|
+
const out = mode === 'registry'
|
|
79
|
+
? await requestProxy(state.settings, '/zin/mysql/statement', await createStatementPayload(sql, parameters))
|
|
80
|
+
: await requestProxy(state.settings, '/zin/mysql/query', {
|
|
81
|
+
sql,
|
|
82
|
+
params: parameters,
|
|
83
|
+
});
|
|
84
|
+
return toQueryResult(out);
|
|
85
|
+
};
|
|
86
|
+
const createQueryOne = (state) => async (sql, parameters) => {
|
|
87
|
+
requireConnected(state);
|
|
88
|
+
const mode = resolveProxyMode();
|
|
89
|
+
if (mode !== 'registry') {
|
|
90
|
+
const out = await requestProxy(state.settings, '/zin/mysql/queryOne', {
|
|
91
|
+
sql,
|
|
92
|
+
params: parameters,
|
|
93
|
+
});
|
|
94
|
+
return out.row ?? null;
|
|
95
|
+
}
|
|
96
|
+
const out = await requestProxy(state.settings, '/zin/mysql/statement', await createStatementPayload(sql, parameters));
|
|
97
|
+
if (isQueryOneResponse(out))
|
|
98
|
+
return out.row ?? null;
|
|
99
|
+
if (isQueryResponse(out))
|
|
100
|
+
return out.rows[0] ?? null;
|
|
101
|
+
return null;
|
|
102
|
+
};
|
|
103
|
+
const createPing = (queryOne) => async () => {
|
|
104
|
+
await queryOne(QueryBuilder.create('').select('1').toSQL(), []);
|
|
105
|
+
};
|
|
106
|
+
const createTransaction = (state, getAdapter) => async (callback) => {
|
|
107
|
+
requireConnected(state);
|
|
108
|
+
try {
|
|
109
|
+
return await callback(getAdapter());
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
throw ErrorFactory.createTryCatchError('MySQL proxy transaction failed', error);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const createRawQuery = (state, query) => async (sql, parameters = []) => {
|
|
116
|
+
requireConnected(state);
|
|
117
|
+
const out = await query(sql, parameters);
|
|
118
|
+
return out.rows;
|
|
119
|
+
};
|
|
120
|
+
const createAdapter = (state) => {
|
|
121
|
+
const query = createQuery(state);
|
|
122
|
+
const queryOne = createQueryOne(state);
|
|
123
|
+
const ping = createPing(queryOne);
|
|
124
|
+
const adapter = {
|
|
125
|
+
async connect() {
|
|
126
|
+
ensureSignedSettings(buildSignedProxyConfig(state.settings));
|
|
127
|
+
state.connected = true;
|
|
128
|
+
},
|
|
129
|
+
async disconnect() {
|
|
130
|
+
state.connected = false;
|
|
131
|
+
},
|
|
132
|
+
query,
|
|
133
|
+
queryOne,
|
|
134
|
+
ping,
|
|
135
|
+
transaction: createTransaction(state, () => adapter),
|
|
136
|
+
rawQuery: createRawQuery(state, query),
|
|
137
|
+
getType() {
|
|
138
|
+
return AdaptersEnum.mysql;
|
|
139
|
+
},
|
|
140
|
+
isConnected() {
|
|
141
|
+
return state.connected;
|
|
142
|
+
},
|
|
143
|
+
getPlaceholder(_index) {
|
|
144
|
+
return '?';
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
return adapter;
|
|
148
|
+
};
|
|
149
|
+
export const MySQLProxyAdapter = Object.freeze({
|
|
150
|
+
create(_config) {
|
|
151
|
+
const settings = buildProxySettings();
|
|
152
|
+
const state = { connected: false, settings };
|
|
153
|
+
Logger.info('[MySQLProxyAdapter] Created with runtime settings', {
|
|
154
|
+
baseUrl: settings.baseUrl,
|
|
155
|
+
timeoutMs: settings.timeoutMs,
|
|
156
|
+
hasKeyId: (settings.keyId ?? '').trim() !== '',
|
|
157
|
+
hasSecret: (settings.secret ?? '').trim() !== '',
|
|
158
|
+
});
|
|
159
|
+
return createAdapter(state);
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
export default MySQLProxyAdapter;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL Proxy Adapter (HTTP)
|
|
3
|
+
*
|
|
4
|
+
* Used in Cloudflare Workers when POSTGRES_PROXY_URL is configured.
|
|
5
|
+
*/
|
|
6
|
+
import type { DatabaseConfig, IDatabaseAdapter } from '../DatabaseAdapter';
|
|
7
|
+
export declare const PostgreSQLProxyAdapter: Readonly<{
|
|
8
|
+
create(_config: DatabaseConfig): IDatabaseAdapter;
|
|
9
|
+
}>;
|
|
10
|
+
export default PostgreSQLProxyAdapter;
|
|
11
|
+
//# sourceMappingURL=PostgreSQLProxyAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgreSQLProxyAdapter.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/PostgreSQLProxyAdapter.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAaH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAiH1F,eAAO,MAAM,sBAAsB;oBACjB,cAAc,GAAG,gBAAgB;EAwFjD,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/require-await */
|
|
2
|
+
/**
|
|
3
|
+
* PostgreSQL Proxy Adapter (HTTP)
|
|
4
|
+
*
|
|
5
|
+
* Used in Cloudflare Workers when POSTGRES_PROXY_URL is configured.
|
|
6
|
+
*/
|
|
7
|
+
import { Env } from '../../config/env.js';
|
|
8
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
9
|
+
import { AdaptersEnum } from '../../migrations/enum/index.js';
|
|
10
|
+
import { ensureSignedSettings, isRecord, requestSignedProxy, } from '../adapters/SqlProxyAdapterUtils.js';
|
|
11
|
+
import { createStatementPayload, resolveSqlProxyMode } from '../adapters/SqlProxyRegistryMode.js';
|
|
12
|
+
import { QueryBuilder } from '../QueryBuilder.js';
|
|
13
|
+
const resolveBaseUrl = () => {
|
|
14
|
+
const explicit = Env.POSTGRES_PROXY_URL.trim();
|
|
15
|
+
if (explicit !== '')
|
|
16
|
+
return explicit;
|
|
17
|
+
const host = Env.POSTGRES_PROXY_HOST || '127.0.0.1';
|
|
18
|
+
const port = Env.POSTGRES_PROXY_PORT;
|
|
19
|
+
return `http://${host}:${port}`;
|
|
20
|
+
};
|
|
21
|
+
const buildProxySettings = () => {
|
|
22
|
+
const baseUrl = resolveBaseUrl();
|
|
23
|
+
const keyId = Env.POSTGRES_PROXY_KEY_ID ?? '';
|
|
24
|
+
const secret = Env.POSTGRES_PROXY_SECRET ?? '';
|
|
25
|
+
const timeoutMs = Env.POSTGRES_PROXY_TIMEOUT_MS;
|
|
26
|
+
return { baseUrl, keyId, secret, timeoutMs };
|
|
27
|
+
};
|
|
28
|
+
const buildSignedProxyConfig = (settings) => ({
|
|
29
|
+
settings,
|
|
30
|
+
missingUrlMessage: 'PostgreSQL proxy URL is missing (POSTGRES_PROXY_URL)',
|
|
31
|
+
missingCredentialsMessage: 'PostgreSQL proxy signing credentials are missing (POSTGRES_PROXY_KEY_ID / POSTGRES_PROXY_SECRET)',
|
|
32
|
+
messages: {
|
|
33
|
+
unauthorized: 'PostgreSQL proxy unauthorized',
|
|
34
|
+
forbidden: 'PostgreSQL proxy forbidden',
|
|
35
|
+
rateLimited: 'PostgreSQL proxy rate limited',
|
|
36
|
+
rejected: 'PostgreSQL proxy rejected request',
|
|
37
|
+
error: 'PostgreSQL proxy error',
|
|
38
|
+
timedOut: 'PostgreSQL proxy request timed out',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
const isQueryResponse = (value) => isRecord(value) && Array.isArray(value['rows']) && typeof value['rowCount'] === 'number';
|
|
42
|
+
const isQueryOneResponse = (value) => isRecord(value) && 'row' in value;
|
|
43
|
+
const normalizeLastInsertId = (value) => {
|
|
44
|
+
if (typeof value === 'number' || typeof value === 'string' || typeof value === 'bigint') {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
};
|
|
49
|
+
const extractRowId = (row) => {
|
|
50
|
+
if (!isRecord(row))
|
|
51
|
+
return undefined;
|
|
52
|
+
return normalizeLastInsertId(row['id']);
|
|
53
|
+
};
|
|
54
|
+
const getExecMeta = (value) => {
|
|
55
|
+
if (!isRecord(value) || typeof value['ok'] !== 'boolean')
|
|
56
|
+
return { changes: 0 };
|
|
57
|
+
const meta = value['meta'];
|
|
58
|
+
if (!isRecord(meta))
|
|
59
|
+
return { changes: 0 };
|
|
60
|
+
const changes = typeof meta['changes'] === 'number' ? meta['changes'] : 0;
|
|
61
|
+
return { changes };
|
|
62
|
+
};
|
|
63
|
+
const toQueryResult = (out) => {
|
|
64
|
+
if (isQueryResponse(out)) {
|
|
65
|
+
return {
|
|
66
|
+
rows: out.rows,
|
|
67
|
+
rowCount: out.rowCount,
|
|
68
|
+
lastInsertId: extractRowId(out.rows[0]),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (isQueryOneResponse(out)) {
|
|
72
|
+
const row = out.row ?? null;
|
|
73
|
+
return {
|
|
74
|
+
rows: row ? [row] : [],
|
|
75
|
+
rowCount: row ? 1 : 0,
|
|
76
|
+
lastInsertId: extractRowId(row),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const meta = getExecMeta(out);
|
|
80
|
+
return { rows: [], rowCount: meta.changes };
|
|
81
|
+
};
|
|
82
|
+
const requestProxy = async (settings, path, payload) => {
|
|
83
|
+
return requestSignedProxy(buildSignedProxyConfig(settings), path, payload);
|
|
84
|
+
};
|
|
85
|
+
const resolveProxyMode = () => {
|
|
86
|
+
return resolveSqlProxyMode('POSTGRES_PROXY_MODE');
|
|
87
|
+
};
|
|
88
|
+
export const PostgreSQLProxyAdapter = Object.freeze({
|
|
89
|
+
create(_config) {
|
|
90
|
+
let connected = true;
|
|
91
|
+
const settings = buildProxySettings();
|
|
92
|
+
return {
|
|
93
|
+
async connect() {
|
|
94
|
+
ensureSignedSettings(buildSignedProxyConfig(settings));
|
|
95
|
+
connected = true;
|
|
96
|
+
},
|
|
97
|
+
async disconnect() {
|
|
98
|
+
connected = true;
|
|
99
|
+
},
|
|
100
|
+
async query(sql, parameters) {
|
|
101
|
+
if (!connected)
|
|
102
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
103
|
+
const mode = resolveProxyMode();
|
|
104
|
+
const out = mode === 'registry'
|
|
105
|
+
? await requestProxy(settings, '/zin/postgres/statement', await createStatementPayload(sql, parameters))
|
|
106
|
+
: await requestProxy(settings, '/zin/postgres/query', {
|
|
107
|
+
sql,
|
|
108
|
+
params: parameters,
|
|
109
|
+
});
|
|
110
|
+
return toQueryResult(out);
|
|
111
|
+
},
|
|
112
|
+
async queryOne(sql, parameters) {
|
|
113
|
+
if (!connected)
|
|
114
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
115
|
+
const mode = resolveProxyMode();
|
|
116
|
+
if (mode !== 'registry') {
|
|
117
|
+
const out = await requestProxy(settings, '/zin/postgres/queryOne', {
|
|
118
|
+
sql,
|
|
119
|
+
params: parameters,
|
|
120
|
+
});
|
|
121
|
+
return out.row ?? null;
|
|
122
|
+
}
|
|
123
|
+
const out = await requestProxy(settings, '/zin/postgres/statement', await createStatementPayload(sql, parameters));
|
|
124
|
+
if (isQueryOneResponse(out))
|
|
125
|
+
return out.row ?? null;
|
|
126
|
+
if (isQueryResponse(out))
|
|
127
|
+
return out.rows[0] ?? null;
|
|
128
|
+
return null;
|
|
129
|
+
},
|
|
130
|
+
async ping() {
|
|
131
|
+
if (!connected)
|
|
132
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
133
|
+
await this.queryOne(QueryBuilder.create('').select('1').toSQL(), []);
|
|
134
|
+
},
|
|
135
|
+
async transaction(callback) {
|
|
136
|
+
if (!connected)
|
|
137
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
138
|
+
try {
|
|
139
|
+
return await callback(this);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
throw ErrorFactory.createTryCatchError('PostgreSQL proxy transaction failed', error);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
async rawQuery(sql, parameters = []) {
|
|
146
|
+
if (!connected)
|
|
147
|
+
throw ErrorFactory.createConnectionError('Database not connected');
|
|
148
|
+
const out = await this.query(sql, parameters);
|
|
149
|
+
return out.rows;
|
|
150
|
+
},
|
|
151
|
+
getType() {
|
|
152
|
+
return AdaptersEnum.postgresql;
|
|
153
|
+
},
|
|
154
|
+
isConnected() {
|
|
155
|
+
return connected;
|
|
156
|
+
},
|
|
157
|
+
getPlaceholder(index) {
|
|
158
|
+
return `$${index}`;
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
export default PostgreSQLProxyAdapter;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { QueryResult } from '../DatabaseAdapter';
|
|
2
|
+
export declare const ProxyCache: Readonly<{
|
|
3
|
+
create(): Readonly<{
|
|
4
|
+
get(key: string): QueryResult | null;
|
|
5
|
+
set(key: string, data: QueryResult): void;
|
|
6
|
+
clear(): void;
|
|
7
|
+
}>;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=ProxyCache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxyCache.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/ProxyCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AASxD,eAAO,MAAM,UAAU;;iBAKR,MAAM,GAAG,WAAW,GAAG,IAAI;iBAU3B,MAAM,QAAQ,WAAW,GAAG,IAAI;iBAIhC,IAAI;;EAKjB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const CACHE_TTL_MS = 5000;
|
|
2
|
+
export const ProxyCache = Object.freeze({
|
|
3
|
+
create() {
|
|
4
|
+
const cache = new Map();
|
|
5
|
+
return Object.freeze({
|
|
6
|
+
get(key) {
|
|
7
|
+
const entry = cache.get(key);
|
|
8
|
+
if (!entry)
|
|
9
|
+
return null;
|
|
10
|
+
if (Date.now() - entry.timestamp > CACHE_TTL_MS) {
|
|
11
|
+
cache.delete(key);
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return entry.data;
|
|
15
|
+
},
|
|
16
|
+
set(key, data) {
|
|
17
|
+
cache.set(key, { data, timestamp: Date.now() });
|
|
18
|
+
},
|
|
19
|
+
clear() {
|
|
20
|
+
cache.clear();
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
},
|
|
24
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const createSignedProxyRequest: (input: {
|
|
2
|
+
url: string;
|
|
3
|
+
body: string;
|
|
4
|
+
keyId: string;
|
|
5
|
+
secret: string;
|
|
6
|
+
missingCredentialsMessage: string;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
headers: Record<string, string>;
|
|
9
|
+
body: string;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=ProxySignedRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxySignedRequest.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/ProxySignedRequest.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,wBAAwB,GAAU,OAAO;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB,EAAE,MAAM,CAAC;CACnC,KAAG,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA4B5D,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
2
|
+
import { normalizeSigningCredentials } from '../../proxy/SigningService.js';
|
|
3
|
+
import { SignedRequest } from '../../security/SignedRequest.js';
|
|
4
|
+
import { buildSigningUrl } from '../adapters/ProxySigningPath.js';
|
|
5
|
+
export const createSignedProxyRequest = async (input) => {
|
|
6
|
+
const creds = normalizeSigningCredentials({ keyId: input.keyId, secret: input.secret });
|
|
7
|
+
if (creds.keyId.trim() === '' || creds.secret.trim() === '') {
|
|
8
|
+
throw ErrorFactory.createConfigError(input.missingCredentialsMessage);
|
|
9
|
+
}
|
|
10
|
+
const urlObj = new URL(input.url);
|
|
11
|
+
const signingUrl = buildSigningUrl(urlObj, input.url);
|
|
12
|
+
const signResult = await SignedRequest.createHeaders({
|
|
13
|
+
method: 'POST',
|
|
14
|
+
url: signingUrl,
|
|
15
|
+
body: input.body,
|
|
16
|
+
keyId: creds.keyId,
|
|
17
|
+
secret: creds.secret,
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
headers: {
|
|
21
|
+
'content-type': 'application/json',
|
|
22
|
+
'x-zt-key-id': signResult['x-zt-key-id'],
|
|
23
|
+
'x-zt-timestamp': signResult['x-zt-timestamp'],
|
|
24
|
+
'x-zt-nonce': signResult['x-zt-nonce'],
|
|
25
|
+
'x-zt-body-sha256': signResult['x-zt-body-sha256'],
|
|
26
|
+
'x-zt-signature': signResult['x-zt-signature'],
|
|
27
|
+
},
|
|
28
|
+
body: input.body,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProxySigningPath.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/ProxySigningPath.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,KAAG,MAAM,GAAG,SAU/D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,YAAY,GAAG,EAAE,SAAS,MAAM,KAAG,GAYlE,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const resolveSigningPrefix = (baseUrl) => {
|
|
2
|
+
try {
|
|
3
|
+
const parsed = new URL(baseUrl);
|
|
4
|
+
const pathname = parsed.pathname;
|
|
5
|
+
const path = pathname.endsWith('/') ? pathname.slice(0, -1) : pathname;
|
|
6
|
+
if (path === '' || path === '/')
|
|
7
|
+
return undefined;
|
|
8
|
+
return path;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const buildSigningUrl = (requestUrl, baseUrl) => {
|
|
15
|
+
const prefix = resolveSigningPrefix(baseUrl);
|
|
16
|
+
if (typeof prefix !== 'string' || prefix.trim() === '')
|
|
17
|
+
return requestUrl;
|
|
18
|
+
if (requestUrl.pathname === prefix || requestUrl.pathname.startsWith(`${prefix}/`)) {
|
|
19
|
+
const signingUrl = new URL(requestUrl.toString());
|
|
20
|
+
const stripped = requestUrl.pathname.slice(prefix.length);
|
|
21
|
+
signingUrl.pathname = stripped.startsWith('/') ? stripped : `/${stripped}`;
|
|
22
|
+
return signingUrl;
|
|
23
|
+
}
|
|
24
|
+
return requestUrl;
|
|
25
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type RemoteSignedJsonSettings } from '../../common/RemoteSignedJson';
|
|
2
|
+
export type ProxySettings = {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
keyId?: string;
|
|
5
|
+
secret?: string;
|
|
6
|
+
timeoutMs: number;
|
|
7
|
+
signaturePathPrefixToStrip?: string;
|
|
8
|
+
};
|
|
9
|
+
export type SignedProxyConfig = {
|
|
10
|
+
settings: ProxySettings;
|
|
11
|
+
missingUrlMessage: string;
|
|
12
|
+
missingCredentialsMessage: string;
|
|
13
|
+
messages: RemoteSignedJsonSettings['messages'];
|
|
14
|
+
};
|
|
15
|
+
export declare const buildSignedSettings: (config: SignedProxyConfig) => RemoteSignedJsonSettings;
|
|
16
|
+
export declare const ensureSignedSettings: (config: SignedProxyConfig) => RemoteSignedJsonSettings;
|
|
17
|
+
export declare const requestSignedProxy: <T>(config: SignedProxyConfig, path: string, payload: Record<string, unknown>) => Promise<T>;
|
|
18
|
+
export declare const isRecord: (value: unknown) => value is Record<string, unknown>;
|
|
19
|
+
//# sourceMappingURL=SqlProxyAdapterUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqlProxyAdapterUtils.d.ts","sourceRoot":"","sources":["../../../../src/orm/adapters/SqlProxyAdapterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAM3F,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,aAAa,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,yBAAyB,EAAE,MAAM,CAAC;IAClC,QAAQ,EAAE,wBAAwB,CAAC,UAAU,CAAC,CAAC;CAChD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,QAAQ,iBAAiB,KAAG,wBAiB/D,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,QAAQ,iBAAiB,KAAG,wBAYhE,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAU,CAAC,EACxC,QAAQ,iBAAiB,EACzB,MAAM,MAAM,EACZ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/B,OAAO,CAAC,CAAC,CAGX,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAoB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RemoteSignedJson } from '../../common/RemoteSignedJson.js';
|
|
2
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
3
|
+
import { isObject } from '../../helper/index.js';
|
|
4
|
+
import { resolveSigningPrefix } from '../adapters/ProxySigningPath.js';
|
|
5
|
+
import { normalizeSigningCredentials } from '../../proxy/SigningService.js';
|
|
6
|
+
export const buildSignedSettings = (config) => {
|
|
7
|
+
const creds = normalizeSigningCredentials({
|
|
8
|
+
keyId: config.settings.keyId ?? '',
|
|
9
|
+
secret: config.settings.secret ?? '',
|
|
10
|
+
});
|
|
11
|
+
return {
|
|
12
|
+
baseUrl: config.settings.baseUrl,
|
|
13
|
+
keyId: creds.keyId,
|
|
14
|
+
secret: creds.secret,
|
|
15
|
+
timeoutMs: config.settings.timeoutMs,
|
|
16
|
+
signaturePathPrefixToStrip: config.settings.signaturePathPrefixToStrip ?? resolveSigningPrefix(config.settings.baseUrl),
|
|
17
|
+
missingUrlMessage: config.missingUrlMessage,
|
|
18
|
+
missingCredentialsMessage: config.missingCredentialsMessage,
|
|
19
|
+
messages: config.messages,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export const ensureSignedSettings = (config) => {
|
|
23
|
+
const signedSettings = buildSignedSettings(config);
|
|
24
|
+
if (signedSettings.baseUrl.trim() === '') {
|
|
25
|
+
throw ErrorFactory.createConfigError(config.missingUrlMessage);
|
|
26
|
+
}
|
|
27
|
+
if (signedSettings.keyId.trim() === '' || signedSettings.secret.trim() === '') {
|
|
28
|
+
throw ErrorFactory.createConfigError(config.missingCredentialsMessage);
|
|
29
|
+
}
|
|
30
|
+
return signedSettings;
|
|
31
|
+
};
|
|
32
|
+
export const requestSignedProxy = async (config, path, payload) => {
|
|
33
|
+
const signedSettings = ensureSignedSettings(config);
|
|
34
|
+
return RemoteSignedJson.request(signedSettings, path, payload);
|
|
35
|
+
};
|
|
36
|
+
export const isRecord = (value) => isObject(value);
|