@zintrust/core 0.1.0 → 0.1.2
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/README.md +214 -0
- package/bin/zintrust.d.ts.map +1 -1
- package/bin/zintrust.js +18 -1
- package/package.json +4 -34
- package/public/index.html +535 -0
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +46 -3
- package/src/boot/Server.d.ts.map +1 -1
- package/src/boot/Server.js +3 -4
- package/src/boot/bootstrap.js +77 -6
- package/src/builder/BundleOptimizer.d.ts.map +1 -1
- package/src/builder/BundleOptimizer.js +25 -29
- package/src/cache/Cache.d.ts.map +1 -1
- package/src/cache/Cache.js +4 -2
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.js +8 -7
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -1
- package/src/cache/drivers/MemoryDriver.js +5 -0
- package/src/cache/drivers/RedisDriver.js +1 -1
- package/src/cli/BaseCommand.d.ts +2 -2
- package/src/cli/BaseCommand.d.ts.map +1 -1
- package/src/cli/BaseCommand.js +2 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +22 -18
- package/src/cli/ErrorHandler.d.ts.map +1 -1
- package/src/cli/ErrorHandler.js +2 -4
- package/src/cli/commands/AddCommand.d.ts +81 -0
- package/src/cli/commands/AddCommand.d.ts.map +1 -1
- package/src/cli/commands/AddCommand.js +24 -5
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -1
- package/src/cli/commands/ConfigCommand.js +59 -25
- package/src/cli/commands/D1MigrateCommand.d.ts +4 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/D1MigrateCommand.js +6 -4
- package/src/cli/commands/FixCommand.d.ts.map +1 -1
- package/src/cli/commands/FixCommand.js +3 -15
- package/src/cli/commands/LogsCleanupCommand.d.ts +6 -0
- package/src/cli/commands/LogsCleanupCommand.d.ts.map +1 -0
- package/src/cli/commands/LogsCleanupCommand.js +20 -0
- package/src/cli/commands/LogsCommand.d.ts.map +1 -1
- package/src/cli/commands/LogsCommand.js +4 -6
- package/src/cli/commands/MakeMailTemplateCommand.d.ts +10 -0
- package/src/cli/commands/MakeMailTemplateCommand.d.ts.map +1 -0
- package/src/cli/commands/MakeMailTemplateCommand.js +74 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts +10 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.d.ts.map +1 -0
- package/src/cli/commands/MakeNotificationTemplateCommand.js +113 -0
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +3 -3
- package/src/cli/commands/NewCommand.d.ts +4 -0
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +34 -19
- package/src/cli/commands/PluginCommand.d.ts.map +1 -1
- package/src/cli/commands/PluginCommand.js +8 -4
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -1
- package/src/cli/commands/PrepareCommand.js +1 -1
- package/src/cli/commands/QACommand.d.ts.map +1 -1
- package/src/cli/commands/QACommand.js +16 -26
- package/src/cli/commands/SecretsCommand.d.ts +16 -0
- package/src/cli/commands/SecretsCommand.d.ts.map +1 -0
- package/src/cli/commands/SecretsCommand.js +91 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +2 -2
- package/src/cli/commands/TemplatesCommand.d.ts +3 -0
- package/src/cli/commands/TemplatesCommand.d.ts.map +1 -0
- package/src/cli/commands/TemplatesCommand.js +65 -0
- package/src/cli/commands/index.d.ts +5 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +5 -0
- package/src/cli/config/ConfigManager.js +1 -1
- package/src/cli/index.d.ts +2 -1
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +2 -1
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ControllerGenerator.js +11 -10
- package/src/cli/scaffolding/FeatureScaffolder.js +4 -4
- package/src/cli/scaffolding/FileGenerator.js +1 -1
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/MigrationGenerator.js +10 -9
- package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ModelGenerator.js +11 -10
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ProjectScaffolder.js +61 -11
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ResponseFactoryGenerator.js +2 -1
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/RouteGenerator.js +15 -14
- package/src/cli/scaffolding/SeederGenerator.js +1 -1
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +7 -6
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts +1 -1
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.js +2 -2
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -1
- package/src/cli/scaffolding/ServiceScaffolder.js +13 -12
- package/src/cli/scaffolding/TemplateEngine.d.ts +10 -3
- package/src/cli/scaffolding/TemplateEngine.d.ts.map +1 -1
- package/src/cli/scaffolding/TemplateEngine.js +15 -285
- package/src/cli/scaffolding/TemplateGenerator.d.ts +40 -0
- package/src/cli/scaffolding/TemplateGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/TemplateGenerator.js +172 -0
- package/src/cli/scaffolding/index.d.ts +1 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -1
- package/src/cli/scaffolding/index.js +1 -0
- package/src/cli/utils/spawn.js +1 -1
- package/src/common/AwsSigV4.d.ts +41 -0
- package/src/common/AwsSigV4.d.ts.map +1 -0
- package/src/common/AwsSigV4.js +69 -0
- package/src/common/index.d.ts +39 -0
- package/src/common/index.d.ts.map +1 -1
- package/src/common/index.js +101 -8
- package/src/common/uuid.d.ts +3 -0
- package/src/common/uuid.d.ts.map +1 -0
- package/src/common/uuid.js +30 -0
- package/src/config/FileLogWriter.d.ts +22 -0
- package/src/config/FileLogWriter.d.ts.map +1 -0
- package/src/config/FileLogWriter.js +192 -0
- package/src/config/SecretsManager.d.ts.map +1 -1
- package/src/config/SecretsManager.js +26 -0
- package/src/config/StartupConfigValidator.d.ts +15 -0
- package/src/config/StartupConfigValidator.d.ts.map +1 -0
- package/src/config/StartupConfigValidator.js +86 -0
- package/src/config/app.d.ts +2 -1
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +65 -15
- package/src/config/broadcast.d.ts +47 -0
- package/src/config/broadcast.d.ts.map +1 -0
- package/src/config/broadcast.js +54 -0
- package/src/config/cache.d.ts +13 -17
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +9 -11
- package/src/config/cloudflare.d.ts +26 -0
- package/src/config/cloudflare.d.ts.map +1 -0
- package/src/config/cloudflare.js +38 -0
- package/src/config/env.d.ts +6 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +6 -0
- package/src/config/index.d.ts +52 -28
- package/src/config/index.d.ts.map +1 -1
- package/src/config/index.js +3 -0
- package/src/config/logger.d.ts +2 -0
- package/src/config/logger.d.ts.map +1 -1
- package/src/config/logger.js +270 -11
- package/src/config/logging/HttpLogger.d.ts +23 -0
- package/src/config/logging/HttpLogger.d.ts.map +1 -0
- package/src/config/logging/HttpLogger.js +93 -0
- package/src/config/logging/KvLogger.d.ts +22 -0
- package/src/config/logging/KvLogger.d.ts.map +1 -0
- package/src/config/logging/KvLogger.js +143 -0
- package/src/config/logging/SlackLogger.d.ts +23 -0
- package/src/config/logging/SlackLogger.d.ts.map +1 -0
- package/src/config/logging/SlackLogger.js +119 -0
- package/src/config/mail.d.ts +81 -0
- package/src/config/mail.d.ts.map +1 -0
- package/src/config/mail.js +73 -0
- package/src/config/middleware.d.ts +8 -0
- package/src/config/middleware.d.ts.map +1 -0
- package/src/config/middleware.js +18 -0
- package/src/config/notification.d.ts +62 -0
- package/src/config/notification.d.ts.map +1 -0
- package/src/config/notification.js +43 -0
- package/src/config/security.d.ts.map +1 -1
- package/src/config/security.js +2 -2
- package/src/config/startup.d.ts +23 -0
- package/src/config/startup.d.ts.map +1 -0
- package/src/config/startup.js +15 -0
- package/src/config/storage.d.ts +21 -35
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +57 -37
- package/src/database/migrations/index.d.ts +1 -1
- package/src/database/migrations/index.d.ts.map +1 -1
- package/src/database/migrations/index.js +2 -1
- package/src/features/Queue.js +1 -25
- package/src/functions/lambda.d.ts.map +1 -1
- package/src/functions/lambda.js +6 -1
- package/src/health/RuntimeHealthProbes.d.ts +13 -0
- package/src/health/RuntimeHealthProbes.d.ts.map +1 -0
- package/src/health/RuntimeHealthProbes.js +62 -0
- package/src/health/StartupHealthChecks.d.ts +26 -0
- package/src/health/StartupHealthChecks.d.ts.map +1 -0
- package/src/health/StartupHealthChecks.js +124 -0
- package/src/http/ErrorResponse.d.ts +28 -0
- package/src/http/ErrorResponse.d.ts.map +1 -0
- package/src/http/ErrorResponse.js +42 -0
- package/src/http/Kernel.d.ts +5 -0
- package/src/http/Kernel.d.ts.map +1 -1
- package/src/http/Kernel.js +96 -30
- package/src/http/Request.d.ts +1 -1
- package/src/http/Request.d.ts.map +1 -1
- package/src/http/RequestContext.d.ts +20 -0
- package/src/http/RequestContext.d.ts.map +1 -0
- package/src/http/RequestContext.js +77 -0
- package/src/index.d.ts +9 -1
- package/src/index.d.ts.map +1 -1
- package/src/index.js +8 -2
- package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -1
- package/src/microservices/MicroserviceBootstrap.js +6 -5
- package/src/microservices/MicroserviceManager.d.ts.map +1 -1
- package/src/microservices/MicroserviceManager.js +7 -5
- package/src/microservices/PostgresAdapter.d.ts.map +1 -1
- package/src/microservices/PostgresAdapter.js +7 -4
- package/src/microservices/ServiceBundler.d.ts.map +1 -1
- package/src/microservices/ServiceBundler.js +3 -1
- package/src/microservices/ServiceHealthMonitor.d.ts.map +1 -1
- package/src/microservices/ServiceHealthMonitor.js +7 -3
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -1
- package/src/middleware/CsrfMiddleware.js +2 -19
- package/src/middleware/ErrorHandlerMiddleware.d.ts +6 -0
- package/src/middleware/ErrorHandlerMiddleware.d.ts.map +1 -0
- package/src/middleware/ErrorHandlerMiddleware.js +33 -0
- package/src/middleware/LoggingMiddleware.d.ts +9 -0
- package/src/middleware/LoggingMiddleware.d.ts.map +1 -0
- package/src/middleware/LoggingMiddleware.js +36 -0
- package/src/middleware/index.d.ts +2 -0
- package/src/middleware/index.d.ts.map +1 -1
- package/src/middleware/index.js +2 -0
- package/src/node-singletons/async_hooks.d.ts +9 -0
- package/src/node-singletons/async_hooks.d.ts.map +1 -0
- package/src/node-singletons/async_hooks.js +8 -0
- package/src/node-singletons/fs.d.ts +2 -2
- package/src/node-singletons/fs.d.ts.map +1 -1
- package/src/node-singletons/fs.js +2 -2
- package/src/node-singletons/http.d.ts +1 -1
- package/src/node-singletons/http.d.ts.map +1 -1
- package/src/node-singletons/http.js +1 -1
- package/src/node-singletons/index.d.ts +4 -0
- package/src/node-singletons/index.d.ts.map +1 -1
- package/src/node-singletons/index.js +4 -0
- package/src/node-singletons/net.d.ts +9 -0
- package/src/node-singletons/net.d.ts.map +1 -0
- package/src/node-singletons/net.js +8 -0
- package/src/node-singletons/os.d.ts +3 -3
- package/src/node-singletons/os.d.ts.map +1 -1
- package/src/node-singletons/os.js +3 -4
- package/src/node-singletons/path.d.ts +3 -1
- package/src/node-singletons/path.d.ts.map +1 -1
- package/src/node-singletons/path.js +3 -1
- package/src/node-singletons/perf-hooks.d.ts +3 -1
- package/src/node-singletons/perf-hooks.d.ts.map +1 -1
- package/src/node-singletons/perf-hooks.js +3 -1
- package/src/node-singletons/process.d.ts +23 -0
- package/src/node-singletons/process.d.ts.map +1 -0
- package/src/node-singletons/process.js +8 -0
- package/src/node-singletons/readline.d.ts +3 -3
- package/src/node-singletons/readline.d.ts.map +1 -1
- package/src/node-singletons/readline.js +3 -4
- package/src/node-singletons/tls.d.ts +9 -0
- package/src/node-singletons/tls.d.ts.map +1 -0
- package/src/node-singletons/tls.js +8 -0
- package/src/node-singletons/url.d.ts +3 -1
- package/src/node-singletons/url.d.ts.map +1 -1
- package/src/node-singletons/url.js +3 -1
- package/src/orm/ConnectionManager.d.ts +6 -1
- package/src/orm/ConnectionManager.d.ts.map +1 -1
- package/src/orm/ConnectionManager.js +14 -0
- package/src/orm/DatabaseAdapter.d.ts +6 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/QueryBuilder.d.ts +8 -1
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +188 -28
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +18 -12
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +4 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/PostgreSQLAdapter.js +4 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLServerAdapter.js +4 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +4 -0
- package/src/performance/Benchmark.d.ts.map +1 -1
- package/src/performance/Benchmark.js +3 -0
- package/src/performance/CodeGenerationBenchmark.js +3 -3
- package/src/performance/Optimizer.d.ts +1 -1
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +157 -80
- package/src/performance/establish-baseline.js +3 -3
- package/src/runtime/PluginManager.d.ts +3 -1
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +124 -28
- package/src/runtime/RuntimeDetector.d.ts.map +1 -1
- package/src/runtime/RuntimeDetector.js +47 -5
- package/src/runtime/adapters/CloudflareAdapter.js +2 -2
- package/src/runtime/adapters/DenoAdapter.js +9 -7
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/FargateAdapter.js +4 -3
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +4 -2
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/NodeServerAdapter.js +7 -6
- package/src/scheduler/ScheduleRunner.d.ts +18 -0
- package/src/scheduler/ScheduleRunner.d.ts.map +1 -0
- package/src/scheduler/ScheduleRunner.js +155 -0
- package/src/scheduler/index.d.ts +3 -0
- package/src/scheduler/index.d.ts.map +1 -0
- package/src/scheduler/index.js +1 -0
- package/src/scheduler/types.d.ts +16 -0
- package/src/scheduler/types.d.ts.map +1 -0
- package/src/scheduler/types.js +4 -0
- package/src/schedules/index.d.ts +2 -0
- package/src/schedules/index.d.ts.map +1 -0
- package/src/schedules/index.js +1 -0
- package/src/schedules/log-cleanup.d.ts +4 -0
- package/src/schedules/log-cleanup.d.ts.map +1 -0
- package/src/schedules/log-cleanup.js +18 -0
- package/src/scripts/GenerateEnvArtifacts.d.ts +13 -0
- package/src/scripts/GenerateEnvArtifacts.d.ts.map +1 -0
- package/src/scripts/GenerateEnvArtifacts.js +171 -0
- package/src/scripts/TemplateSync.js +109 -70
- package/src/security/CsrfTokenManager.js +1 -1
- package/src/security/Encryptor.js +1 -1
- package/src/security/Hash.d.ts +14 -0
- package/src/security/Hash.d.ts.map +1 -0
- package/src/security/Hash.js +81 -0
- package/src/security/StartupSecretValidation.d.ts +20 -0
- package/src/security/StartupSecretValidation.d.ts.map +1 -0
- package/src/security/StartupSecretValidation.js +61 -0
- package/src/security/UrlValidator.d.ts +0 -1
- package/src/security/UrlValidator.d.ts.map +1 -1
- package/src/security/UrlValidator.js +1 -2
- package/src/security/Xss.d.ts +14 -0
- package/src/security/Xss.d.ts.map +1 -0
- package/src/security/Xss.js +57 -0
- package/src/security/XssProtection.d.ts.map +1 -1
- package/src/security/XssProtection.js +150 -16
- package/src/templates/adapters/MySQLAdapter.ts.tpl +5 -0
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +5 -0
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +5 -0
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +5 -0
- package/src/templates/features/Queue.ts.tpl +1 -29
- package/src/templates/project/basic/.env.example.tpl +48 -0
- package/src/templates/project/basic/.env.tpl +89 -94
- package/src/templates/project/basic/app/Toolkit/Broadcast/sendBroadcast.ts.tpl +7 -0
- package/src/templates/project/basic/app/Toolkit/Mail/sendWelcomeEmail.ts.tpl +30 -0
- package/src/templates/project/basic/app/Toolkit/Notification/sendSlackNotification.ts.tpl +10 -0
- package/src/templates/project/basic/app/Toolkit/Notification/sendSms.ts.tpl +13 -0
- package/src/templates/project/basic/config/FileLogWriter.ts.tpl +240 -0
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +32 -1
- package/src/templates/project/basic/config/StartupConfigValidator.ts.tpl +151 -0
- package/src/templates/project/basic/config/app.ts.tpl +84 -15
- package/src/templates/project/basic/config/broadcast.ts.tpl +97 -0
- package/src/templates/project/basic/config/cache.ts.tpl +19 -23
- package/src/templates/project/basic/config/cloudflare.ts.tpl +57 -0
- package/src/templates/project/basic/config/env.ts.tpl +7 -1
- package/src/templates/project/basic/config/index.ts.tpl +3 -0
- package/src/templates/project/basic/config/logger.ts.tpl +301 -11
- package/src/templates/project/basic/config/logging/HttpLogger.ts.tpl +121 -0
- package/src/templates/project/basic/config/logging/KvLogger.ts.tpl +181 -0
- package/src/templates/project/basic/config/logging/SlackLogger.ts.tpl +156 -0
- package/src/templates/project/basic/config/mail.ts.tpl +141 -0
- package/src/templates/project/basic/config/middleware.ts.tpl +27 -0
- package/src/templates/project/basic/config/notification.ts.tpl +86 -0
- package/src/templates/project/basic/config/security.ts.tpl +4 -5
- package/src/templates/project/basic/config/startup.ts.tpl +27 -0
- package/src/templates/project/basic/config/storage.ts.tpl +77 -42
- package/src/templates/project/basic/database/migrations/index.ts.tpl +1 -1
- package/src/templates/project/basic/package.json.tpl +1 -1
- package/src/templates/project/basic/routes/api.ts.tpl +9 -37
- package/src/templates/project/basic/routes/broadcast.ts.tpl +32 -0
- package/src/templates/project/basic/routes/health.ts.tpl +134 -0
- package/src/templates/project/basic/src/index.ts.tpl +38 -11
- package/src/templates/project/basic/template.json +3 -0
- package/src/toolkit/Secrets/EnvFile.d.ts +15 -0
- package/src/toolkit/Secrets/EnvFile.d.ts.map +1 -0
- package/src/toolkit/Secrets/EnvFile.js +63 -0
- package/src/toolkit/Secrets/Manifest.d.ts +24 -0
- package/src/toolkit/Secrets/Manifest.d.ts.map +1 -0
- package/src/toolkit/Secrets/Manifest.js +71 -0
- package/src/toolkit/Secrets/index.d.ts +42 -0
- package/src/toolkit/Secrets/index.d.ts.map +1 -0
- package/src/toolkit/Secrets/index.js +119 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts +14 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -0
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +131 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts +9 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -0
- package/src/toolkit/Secrets/providers/CloudflareKv.js +73 -0
- package/src/tools/broadcast/Broadcast.d.ts +7 -0
- package/src/tools/broadcast/Broadcast.d.ts.map +1 -0
- package/src/tools/broadcast/Broadcast.js +37 -0
- package/src/tools/broadcast/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/broadcast/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/BaseDriver.js +8 -0
- package/src/tools/broadcast/drivers/InMemory.d.ts +18 -0
- package/src/tools/broadcast/drivers/InMemory.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/InMemory.js +16 -0
- package/src/tools/broadcast/drivers/Pusher.d.ts +8 -0
- package/src/tools/broadcast/drivers/Pusher.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/Pusher.js +75 -0
- package/src/tools/broadcast/drivers/Redis.d.ts +19 -0
- package/src/tools/broadcast/drivers/Redis.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/Redis.js +73 -0
- package/src/tools/broadcast/drivers/RedisHttps.d.ts +14 -0
- package/src/tools/broadcast/drivers/RedisHttps.d.ts.map +1 -0
- package/src/tools/broadcast/drivers/RedisHttps.js +50 -0
- package/src/tools/broadcast/index.d.ts +7 -0
- package/src/tools/broadcast/index.d.ts.map +1 -0
- package/src/tools/broadcast/index.js +6 -0
- package/src/tools/http/Http.d.ts +51 -0
- package/src/tools/http/Http.d.ts.map +1 -0
- package/src/tools/http/Http.js +171 -0
- package/src/tools/http/HttpResponse.d.ts +32 -0
- package/src/tools/http/HttpResponse.d.ts.map +1 -0
- package/src/tools/http/HttpResponse.js +80 -0
- package/src/tools/http/index.d.ts +15 -0
- package/src/tools/http/index.d.ts.map +1 -0
- package/src/tools/http/index.js +9 -0
- package/src/tools/mail/Mail.d.ts +22 -0
- package/src/tools/mail/Mail.d.ts.map +1 -0
- package/src/tools/mail/Mail.js +105 -0
- package/src/tools/mail/attachments.d.ts +23 -0
- package/src/tools/mail/attachments.d.ts.map +1 -0
- package/src/tools/mail/attachments.js +26 -0
- package/src/tools/mail/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/mail/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/mail/drivers/BaseDriver.js +8 -0
- package/src/tools/mail/drivers/Mailgun.d.ts +31 -0
- package/src/tools/mail/drivers/Mailgun.d.ts.map +1 -0
- package/src/tools/mail/drivers/Mailgun.js +81 -0
- package/src/tools/mail/drivers/SendGrid.d.ts +29 -0
- package/src/tools/mail/drivers/SendGrid.d.ts.map +1 -0
- package/src/tools/mail/drivers/SendGrid.js +57 -0
- package/src/tools/mail/drivers/Ses.d.ts +24 -0
- package/src/tools/mail/drivers/Ses.d.ts.map +1 -0
- package/src/tools/mail/drivers/Ses.js +116 -0
- package/src/tools/mail/drivers/Smtp.d.ts +38 -0
- package/src/tools/mail/drivers/Smtp.d.ts.map +1 -0
- package/src/tools/mail/drivers/Smtp.js +327 -0
- package/src/tools/mail/templates/index.d.ts +27 -0
- package/src/tools/mail/templates/index.d.ts.map +1 -0
- package/src/tools/mail/templates/index.js +35 -0
- package/src/tools/mail/templates/markdown/index.d.ts +17 -0
- package/src/tools/mail/templates/markdown/index.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/index.js +49 -0
- package/src/tools/mail/templates/markdown/registry.d.ts +15 -0
- package/src/tools/mail/templates/markdown/registry.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/registry.js +34 -0
- package/src/tools/mail/templates/markdown/validator.d.ts +16 -0
- package/src/tools/mail/templates/markdown/validator.d.ts.map +1 -0
- package/src/tools/mail/templates/markdown/validator.js +24 -0
- package/src/tools/mail/testing.d.ts +41 -0
- package/src/tools/mail/testing.d.ts.map +1 -0
- package/src/tools/mail/testing.js +34 -0
- package/src/tools/notification/Driver.d.ts +11 -0
- package/src/tools/notification/Driver.d.ts.map +1 -0
- package/src/tools/notification/Driver.js +1 -0
- package/src/tools/notification/Notification.d.ts +11 -0
- package/src/tools/notification/Notification.d.ts.map +1 -0
- package/src/tools/notification/Notification.js +11 -0
- package/src/tools/notification/Registry.d.ts +10 -0
- package/src/tools/notification/Registry.d.ts.map +1 -0
- package/src/tools/notification/Registry.js +22 -0
- package/src/tools/notification/Service.d.ts +6 -0
- package/src/tools/notification/Service.d.ts.map +1 -0
- package/src/tools/notification/Service.js +18 -0
- package/src/tools/notification/config.d.ts +5 -0
- package/src/tools/notification/config.d.ts.map +1 -0
- package/src/tools/notification/config.js +5 -0
- package/src/tools/notification/drivers/BaseDriver.d.ts +5 -0
- package/src/tools/notification/drivers/BaseDriver.d.ts.map +1 -0
- package/src/tools/notification/drivers/BaseDriver.js +8 -0
- package/src/tools/notification/drivers/Console.d.ts +7 -0
- package/src/tools/notification/drivers/Console.d.ts.map +1 -0
- package/src/tools/notification/drivers/Console.js +13 -0
- package/src/tools/notification/drivers/Slack.d.ts +16 -0
- package/src/tools/notification/drivers/Slack.d.ts.map +1 -0
- package/src/tools/notification/drivers/Slack.js +24 -0
- package/src/tools/notification/drivers/Termii.d.ts +10 -0
- package/src/tools/notification/drivers/Termii.d.ts.map +1 -0
- package/src/tools/notification/drivers/Termii.js +47 -0
- package/src/tools/notification/drivers/Twilio.d.ts +21 -0
- package/src/tools/notification/drivers/Twilio.d.ts.map +1 -0
- package/src/tools/notification/drivers/Twilio.js +48 -0
- package/src/tools/notification/templates/markdown/index.d.ts +15 -0
- package/src/tools/notification/templates/markdown/index.d.ts.map +1 -0
- package/src/tools/notification/templates/markdown/index.js +38 -0
- package/src/tools/notification/templates/markdown/registry.d.ts +15 -0
- package/src/tools/notification/templates/markdown/registry.d.ts.map +1 -0
- package/src/tools/notification/templates/markdown/registry.js +36 -0
- package/src/tools/notification/testing.d.ts +19 -0
- package/src/tools/notification/testing.d.ts.map +1 -0
- package/src/tools/notification/testing.js +35 -0
- package/src/tools/notification/testingHelpers.d.ts +12 -0
- package/src/tools/notification/testingHelpers.d.ts.map +1 -0
- package/src/tools/notification/testingHelpers.js +32 -0
- package/src/tools/queue/Queue.d.ts +23 -0
- package/src/tools/queue/Queue.d.ts.map +1 -0
- package/src/tools/queue/Queue.js +38 -0
- package/src/tools/queue/drivers/InMemory.d.ts +10 -0
- package/src/tools/queue/drivers/InMemory.d.ts.map +1 -0
- package/src/tools/queue/drivers/InMemory.js +55 -0
- package/src/tools/queue/drivers/Redis.d.ts +10 -0
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -0
- package/src/tools/queue/drivers/Redis.js +91 -0
- package/src/tools/storage/drivers/Gcs.d.ts +20 -0
- package/src/tools/storage/drivers/Gcs.d.ts.map +1 -0
- package/src/tools/storage/drivers/Gcs.js +152 -0
- package/src/tools/storage/drivers/Local.d.ts +17 -0
- package/src/tools/storage/drivers/Local.d.ts.map +1 -0
- package/src/tools/storage/drivers/Local.js +63 -0
- package/src/tools/storage/drivers/R2.d.ts +20 -0
- package/src/tools/storage/drivers/R2.d.ts.map +1 -0
- package/src/tools/storage/drivers/R2.js +73 -0
- package/src/tools/storage/drivers/S3.d.ts +26 -0
- package/src/tools/storage/drivers/S3.d.ts.map +1 -0
- package/src/tools/storage/drivers/S3.js +258 -0
- package/src/tools/storage/index.d.ts +24 -0
- package/src/tools/storage/index.d.ts.map +1 -0
- package/src/tools/storage/index.js +112 -0
- package/src/tools/storage/testing.d.ts +23 -0
- package/src/tools/storage/testing.d.ts.map +1 -0
- package/src/tools/storage/testing.js +52 -0
- package/src/tools/templates/MarkdownRenderer.d.ts +14 -0
- package/src/tools/templates/MarkdownRenderer.d.ts.map +1 -0
- package/src/tools/templates/MarkdownRenderer.js +300 -0
- package/src/tools/templates/index.d.ts +5 -0
- package/src/tools/templates/index.d.ts.map +1 -0
- package/src/tools/templates/index.js +4 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
2
|
+
import { fsPromises as fs } from '../../node-singletons/fs';
|
|
3
|
+
import * as path from '../../node-singletons/path';
|
|
4
|
+
const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
5
|
+
const assertString = (value, name) => {
|
|
6
|
+
if (typeof value !== 'string' || value.trim() === '') {
|
|
7
|
+
throw ErrorFactory.createCliError(`Manifest: missing/invalid ${name}`);
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
};
|
|
11
|
+
const validateKeyName = (key) => {
|
|
12
|
+
if (!/^[A-Z0-9_]+$/.test(key)) {
|
|
13
|
+
throw ErrorFactory.createCliError(`Manifest: invalid env key: ${key}`);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const parseProvider = (parsed, fallback) => {
|
|
17
|
+
const provider = 'provider' in parsed && typeof parsed['provider'] === 'string'
|
|
18
|
+
? parsed['provider']
|
|
19
|
+
: fallback;
|
|
20
|
+
if (provider !== 'aws' && provider !== 'cloudflare') {
|
|
21
|
+
throw ErrorFactory.createCliError('Manifest: provider must be aws|cloudflare');
|
|
22
|
+
}
|
|
23
|
+
return provider;
|
|
24
|
+
};
|
|
25
|
+
const parseKeySpec = (envKey, specUnknown) => {
|
|
26
|
+
const spec = {};
|
|
27
|
+
const awsUnknown = specUnknown['aws'];
|
|
28
|
+
if (isRecord(awsUnknown)) {
|
|
29
|
+
spec.aws = {
|
|
30
|
+
secretId: assertString(awsUnknown['secretId'], `keys.${envKey}.aws.secretId`),
|
|
31
|
+
jsonKey: typeof awsUnknown['jsonKey'] === 'string' && awsUnknown['jsonKey'].trim() !== ''
|
|
32
|
+
? awsUnknown['jsonKey']
|
|
33
|
+
: undefined,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const cloudflareUnknown = specUnknown['cloudflare'];
|
|
37
|
+
if (isRecord(cloudflareUnknown)) {
|
|
38
|
+
spec.cloudflare = {
|
|
39
|
+
key: assertString(cloudflareUnknown['key'], `keys.${envKey}.cloudflare.key`),
|
|
40
|
+
namespaceId: typeof cloudflareUnknown['namespaceId'] === 'string' &&
|
|
41
|
+
cloudflareUnknown['namespaceId'].trim() !== ''
|
|
42
|
+
? cloudflareUnknown['namespaceId']
|
|
43
|
+
: undefined,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return spec;
|
|
47
|
+
};
|
|
48
|
+
export const Manifest = Object.freeze({
|
|
49
|
+
async load(params) {
|
|
50
|
+
const filePath = path.resolve(params.cwd, params.path);
|
|
51
|
+
const raw = await fs.readFile(filePath, 'utf-8');
|
|
52
|
+
const parsedUnknown = JSON.parse(raw);
|
|
53
|
+
if (!isRecord(parsedUnknown)) {
|
|
54
|
+
throw ErrorFactory.createCliError('Manifest: expected JSON object');
|
|
55
|
+
}
|
|
56
|
+
const provider = parseProvider(parsedUnknown, params.provider);
|
|
57
|
+
const keysUnknown = parsedUnknown['keys'];
|
|
58
|
+
if (!isRecord(keysUnknown)) {
|
|
59
|
+
throw ErrorFactory.createCliError('Manifest: keys must be an object');
|
|
60
|
+
}
|
|
61
|
+
const keys = {};
|
|
62
|
+
for (const [envKey, specUnknown] of Object.entries(keysUnknown)) {
|
|
63
|
+
validateKeyName(envKey);
|
|
64
|
+
if (!isRecord(specUnknown))
|
|
65
|
+
throw ErrorFactory.createCliError(`Manifest: key ${envKey} must be an object`);
|
|
66
|
+
keys[envKey] = parseKeySpec(envKey, specUnknown);
|
|
67
|
+
}
|
|
68
|
+
return { provider, keys };
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
export default Manifest;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secrets Toolkit (Core)
|
|
3
|
+
*
|
|
4
|
+
* Internal framework module intended for CLI usage.
|
|
5
|
+
* It may use Node APIs (via node-singletons) and should not be used by runtime apps.
|
|
6
|
+
*/
|
|
7
|
+
import { type SecretsProviderName } from '../Secrets/Manifest';
|
|
8
|
+
export type { SecretsProviderName } from '../Secrets/Manifest';
|
|
9
|
+
export type PullOptions = {
|
|
10
|
+
cwd: string;
|
|
11
|
+
provider?: SecretsProviderName;
|
|
12
|
+
manifestPath?: string;
|
|
13
|
+
outFile?: string;
|
|
14
|
+
dryRun?: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type PushOptions = {
|
|
17
|
+
cwd: string;
|
|
18
|
+
provider?: SecretsProviderName;
|
|
19
|
+
manifestPath?: string;
|
|
20
|
+
inFile?: string;
|
|
21
|
+
dryRun?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type DoctorOptions = {
|
|
24
|
+
provider?: SecretsProviderName;
|
|
25
|
+
};
|
|
26
|
+
export declare const SecretsToolkit: Readonly<{
|
|
27
|
+
pull(options: PullOptions): Promise<{
|
|
28
|
+
outFile: string;
|
|
29
|
+
keys: string[];
|
|
30
|
+
}>;
|
|
31
|
+
push(options: PushOptions): Promise<{
|
|
32
|
+
inFile: string;
|
|
33
|
+
keys: string[];
|
|
34
|
+
}>;
|
|
35
|
+
doctor(options: DoctorOptions): {
|
|
36
|
+
provider: SecretsProviderName;
|
|
37
|
+
ok: boolean;
|
|
38
|
+
missing: string[];
|
|
39
|
+
};
|
|
40
|
+
}>;
|
|
41
|
+
export default SecretsToolkit;
|
|
42
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/toolkit/Secrets/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAI/E,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC,CAAC;AA0GF,eAAO,MAAM,cAAc;kBACL,WAAW,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;kBAkB1D,WAAW,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;oBAoB7D,aAAa,GAAG;QAC9B,QAAQ,EAAE,mBAAmB,CAAC;QAC9B,EAAE,EAAE,OAAO,CAAC;QACZ,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB;EASD,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secrets Toolkit (Core)
|
|
3
|
+
*
|
|
4
|
+
* Internal framework module intended for CLI usage.
|
|
5
|
+
* It may use Node APIs (via node-singletons) and should not be used by runtime apps.
|
|
6
|
+
*/
|
|
7
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
8
|
+
import { EnvFile } from '../Secrets/EnvFile';
|
|
9
|
+
import { Manifest } from '../Secrets/Manifest';
|
|
10
|
+
import { AwsSecretsManager } from '../Secrets/providers/AwsSecretsManager';
|
|
11
|
+
import { CloudflareKv } from '../Secrets/providers/CloudflareKv';
|
|
12
|
+
const resolveProvider = (provider) => {
|
|
13
|
+
if (provider === 'aws' || provider === 'cloudflare')
|
|
14
|
+
return provider;
|
|
15
|
+
throw ErrorFactory.createCliError('Missing/invalid provider. Use --provider aws|cloudflare or set ZINTRUST_SECRETS_PROVIDER.');
|
|
16
|
+
};
|
|
17
|
+
const resolveOutFile = (outFile) => outFile ?? process.env['ZINTRUST_ENV_FILE'] ?? '.env.pull';
|
|
18
|
+
const resolveManifestPath = (manifestPath) => manifestPath ?? process.env['ZINTRUST_SECRETS_MANIFEST'] ?? 'secrets.manifest.json';
|
|
19
|
+
const resolveInFile = (inFile) => inFile ?? process.env['ZINTRUST_ENV_IN_FILE'] ?? '.env';
|
|
20
|
+
const pullAws = async (manifest) => {
|
|
21
|
+
const client = AwsSecretsManager.createFromEnv();
|
|
22
|
+
const entries = Object.entries(manifest.keys).filter(([, spec]) => spec.aws !== undefined);
|
|
23
|
+
const pairs = await Promise.all(entries.map(async ([envKey, spec]) => {
|
|
24
|
+
const aws = spec.aws;
|
|
25
|
+
if (aws === undefined)
|
|
26
|
+
return null;
|
|
27
|
+
const value = await client.getValue(aws.secretId, aws.jsonKey);
|
|
28
|
+
return value === null ? null : [envKey, value];
|
|
29
|
+
}));
|
|
30
|
+
const resolved = {};
|
|
31
|
+
for (const pair of pairs) {
|
|
32
|
+
if (pair)
|
|
33
|
+
resolved[pair[0]] = pair[1];
|
|
34
|
+
}
|
|
35
|
+
return resolved;
|
|
36
|
+
};
|
|
37
|
+
const pullCloudflare = async (manifest) => {
|
|
38
|
+
const client = CloudflareKv.createFromEnv();
|
|
39
|
+
const entries = Object.entries(manifest.keys).filter(([, spec]) => spec.cloudflare !== undefined);
|
|
40
|
+
const pairs = await Promise.all(entries.map(async ([envKey, spec]) => {
|
|
41
|
+
const cf = spec.cloudflare;
|
|
42
|
+
if (cf === undefined)
|
|
43
|
+
return null;
|
|
44
|
+
const value = await client.getValue(cf.key, cf.namespaceId);
|
|
45
|
+
return value === null ? null : [envKey, value];
|
|
46
|
+
}));
|
|
47
|
+
const resolved = {};
|
|
48
|
+
for (const pair of pairs) {
|
|
49
|
+
if (pair)
|
|
50
|
+
resolved[pair[0]] = pair[1];
|
|
51
|
+
}
|
|
52
|
+
return resolved;
|
|
53
|
+
};
|
|
54
|
+
const pushAws = async (manifest, env, dryRun) => {
|
|
55
|
+
const client = AwsSecretsManager.createFromEnv();
|
|
56
|
+
const entries = Object.entries(manifest.keys).filter(([, spec]) => spec.aws !== undefined);
|
|
57
|
+
const pushed = await Promise.all(entries.map(async ([envKey, spec]) => {
|
|
58
|
+
const aws = spec.aws;
|
|
59
|
+
if (aws === undefined)
|
|
60
|
+
return null;
|
|
61
|
+
const value = env[envKey];
|
|
62
|
+
if (typeof value !== 'string')
|
|
63
|
+
return null;
|
|
64
|
+
if (!dryRun)
|
|
65
|
+
await client.putValue(aws.secretId, value);
|
|
66
|
+
return envKey;
|
|
67
|
+
}));
|
|
68
|
+
return pushed.filter((k) => typeof k === 'string');
|
|
69
|
+
};
|
|
70
|
+
const pushCloudflare = async (manifest, env, dryRun) => {
|
|
71
|
+
const client = CloudflareKv.createFromEnv();
|
|
72
|
+
const entries = Object.entries(manifest.keys).filter(([, spec]) => spec.cloudflare !== undefined);
|
|
73
|
+
const pushed = await Promise.all(entries.map(async ([envKey, spec]) => {
|
|
74
|
+
const cf = spec.cloudflare;
|
|
75
|
+
if (cf === undefined)
|
|
76
|
+
return null;
|
|
77
|
+
const value = env[envKey];
|
|
78
|
+
if (typeof value !== 'string')
|
|
79
|
+
return null;
|
|
80
|
+
if (!dryRun)
|
|
81
|
+
await client.putValue(cf.key, value, cf.namespaceId);
|
|
82
|
+
return envKey;
|
|
83
|
+
}));
|
|
84
|
+
return pushed.filter((k) => typeof k === 'string');
|
|
85
|
+
};
|
|
86
|
+
export const SecretsToolkit = Object.freeze({
|
|
87
|
+
async pull(options) {
|
|
88
|
+
const provider = resolveProvider(options.provider ??
|
|
89
|
+
process.env['ZINTRUST_SECRETS_PROVIDER']);
|
|
90
|
+
const outFile = resolveOutFile(options.outFile);
|
|
91
|
+
const manifestPath = resolveManifestPath(options.manifestPath);
|
|
92
|
+
const manifest = await Manifest.load({ cwd: options.cwd, path: manifestPath, provider });
|
|
93
|
+
const resolved = provider === 'aws' ? await pullAws(manifest) : await pullCloudflare(manifest);
|
|
94
|
+
if (options.dryRun === true)
|
|
95
|
+
return { outFile, keys: Object.keys(resolved) };
|
|
96
|
+
await EnvFile.write({ cwd: options.cwd, path: outFile, values: resolved, mode: 'overwrite' });
|
|
97
|
+
return { outFile, keys: Object.keys(resolved) };
|
|
98
|
+
},
|
|
99
|
+
async push(options) {
|
|
100
|
+
const provider = resolveProvider(options.provider ??
|
|
101
|
+
process.env['ZINTRUST_SECRETS_PROVIDER']);
|
|
102
|
+
const inFile = resolveInFile(options.inFile);
|
|
103
|
+
const manifestPath = resolveManifestPath(options.manifestPath);
|
|
104
|
+
const manifest = await Manifest.load({ cwd: options.cwd, path: manifestPath, provider });
|
|
105
|
+
const env = await EnvFile.read({ cwd: options.cwd, path: inFile });
|
|
106
|
+
const dryRun = options.dryRun === true;
|
|
107
|
+
const keys = provider === 'aws'
|
|
108
|
+
? await pushAws(manifest, env, dryRun)
|
|
109
|
+
: await pushCloudflare(manifest, env, dryRun);
|
|
110
|
+
return { inFile, keys };
|
|
111
|
+
},
|
|
112
|
+
doctor(options) {
|
|
113
|
+
const provider = resolveProvider(options.provider ??
|
|
114
|
+
process.env['ZINTRUST_SECRETS_PROVIDER']);
|
|
115
|
+
const missing = provider === 'aws' ? AwsSecretsManager.doctorEnv() : CloudflareKv.doctorEnv();
|
|
116
|
+
return { provider, ok: missing.length === 0, missing };
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
export default SecretsToolkit;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type AwsCredentials = {
|
|
2
|
+
accessKeyId: string;
|
|
3
|
+
secretAccessKey: string;
|
|
4
|
+
sessionToken?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const AwsSecretsManager: Readonly<{
|
|
7
|
+
createFromEnv(): {
|
|
8
|
+
getValue: (secretId: string, jsonKey?: string) => Promise<string | null>;
|
|
9
|
+
putValue: (secretId: string, value: string) => Promise<void>;
|
|
10
|
+
};
|
|
11
|
+
doctorEnv(): string[];
|
|
12
|
+
}>;
|
|
13
|
+
export default AwsSecretsManager;
|
|
14
|
+
//# sourceMappingURL=AwsSecretsManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AwsSecretsManager.d.ts","sourceRoot":"","sources":["../../../../../src/toolkit/Secrets/providers/AwsSecretsManager.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AA0GF,eAAO,MAAM,iBAAiB;qBACX;QACf,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACzE,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC9D;iBAsDY,MAAM,EAAE;EAcrB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { AwsSigV4 } from '../../../common/index';
|
|
2
|
+
import { ErrorFactory } from '../../../exceptions/ZintrustError';
|
|
3
|
+
const sha256Hex = (data) => AwsSigV4.sha256Hex(data);
|
|
4
|
+
const buildAuthorization = (params) => {
|
|
5
|
+
const canonicalUri = '/';
|
|
6
|
+
const canonicalQueryString = '';
|
|
7
|
+
const headers = {
|
|
8
|
+
'content-type': 'application/x-amz-json-1.1',
|
|
9
|
+
host: params.host,
|
|
10
|
+
'x-amz-date': params.amzDate,
|
|
11
|
+
'x-amz-target': params.target,
|
|
12
|
+
};
|
|
13
|
+
const sessionToken = params.credentials.sessionToken;
|
|
14
|
+
if (typeof sessionToken === 'string' && sessionToken.trim() !== '') {
|
|
15
|
+
headers['x-amz-security-token'] = sessionToken;
|
|
16
|
+
}
|
|
17
|
+
const payloadHash = sha256Hex(params.body);
|
|
18
|
+
return AwsSigV4.buildAuthorization({
|
|
19
|
+
method: params.method,
|
|
20
|
+
canonicalUri,
|
|
21
|
+
canonicalQueryString,
|
|
22
|
+
headers,
|
|
23
|
+
payloadHash,
|
|
24
|
+
region: params.region,
|
|
25
|
+
service: 'secretsmanager',
|
|
26
|
+
amzDate: params.amzDate,
|
|
27
|
+
dateStamp: params.dateStamp,
|
|
28
|
+
credentials: params.credentials,
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
const parseMaybeJson = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(value);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const requestAwsSecretsManager = async (region, credentials, target, body) => {
|
|
40
|
+
const host = `secretsmanager.${region}.amazonaws.com`;
|
|
41
|
+
const url = `https://${host}/`;
|
|
42
|
+
const now = new Date();
|
|
43
|
+
const { amzDate, dateStamp } = AwsSigV4.toAmzDate(now);
|
|
44
|
+
const bodyJson = JSON.stringify(body);
|
|
45
|
+
const { authorization } = buildAuthorization({
|
|
46
|
+
method: 'POST',
|
|
47
|
+
host,
|
|
48
|
+
region,
|
|
49
|
+
amzDate,
|
|
50
|
+
dateStamp,
|
|
51
|
+
credentials,
|
|
52
|
+
target,
|
|
53
|
+
body: bodyJson,
|
|
54
|
+
});
|
|
55
|
+
const headers = {
|
|
56
|
+
'content-type': 'application/x-amz-json-1.1',
|
|
57
|
+
'x-amz-date': amzDate,
|
|
58
|
+
'x-amz-target': target,
|
|
59
|
+
Authorization: authorization,
|
|
60
|
+
};
|
|
61
|
+
const sessionToken = credentials.sessionToken;
|
|
62
|
+
if (typeof sessionToken === 'string' && sessionToken.trim() !== '') {
|
|
63
|
+
headers['x-amz-security-token'] = sessionToken;
|
|
64
|
+
}
|
|
65
|
+
const res = await fetch(url, {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers,
|
|
68
|
+
body: bodyJson,
|
|
69
|
+
});
|
|
70
|
+
const text = await res.text();
|
|
71
|
+
if (!res.ok) {
|
|
72
|
+
throw ErrorFactory.createCliError(`AWS SecretsManager request failed (${res.status})`, {
|
|
73
|
+
status: res.status,
|
|
74
|
+
body: text,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return JSON.parse(text);
|
|
78
|
+
};
|
|
79
|
+
export const AwsSecretsManager = Object.freeze({
|
|
80
|
+
createFromEnv() {
|
|
81
|
+
const region = process.env['AWS_REGION'] ?? process.env['AWS_DEFAULT_REGION'] ?? '';
|
|
82
|
+
const accessKeyId = process.env['AWS_ACCESS_KEY_ID'] ?? '';
|
|
83
|
+
const secretAccessKey = process.env['AWS_SECRET_ACCESS_KEY'] ?? '';
|
|
84
|
+
const sessionToken = process.env['AWS_SESSION_TOKEN'] ?? undefined;
|
|
85
|
+
if (region.trim() === '' || accessKeyId.trim() === '' || secretAccessKey.trim() === '') {
|
|
86
|
+
throw ErrorFactory.createCliError('AWS credentials missing: set AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY');
|
|
87
|
+
}
|
|
88
|
+
const credentials = { accessKeyId, secretAccessKey, sessionToken };
|
|
89
|
+
const getValue = async (secretId, jsonKey) => {
|
|
90
|
+
const data = await requestAwsSecretsManager(region, credentials, 'secretsmanager.GetSecretValue', {
|
|
91
|
+
SecretId: secretId,
|
|
92
|
+
});
|
|
93
|
+
if (typeof data.SecretString !== 'string')
|
|
94
|
+
return null;
|
|
95
|
+
if (jsonKey === undefined)
|
|
96
|
+
return data.SecretString;
|
|
97
|
+
const parsed = parseMaybeJson(data.SecretString);
|
|
98
|
+
if (typeof parsed === 'object' && parsed !== null) {
|
|
99
|
+
const obj = parsed;
|
|
100
|
+
if (!(jsonKey in obj))
|
|
101
|
+
return null;
|
|
102
|
+
const v = obj[jsonKey];
|
|
103
|
+
if (typeof v === 'string')
|
|
104
|
+
return v;
|
|
105
|
+
return JSON.stringify(v);
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
};
|
|
109
|
+
const putValue = async (secretId, value) => {
|
|
110
|
+
await requestAwsSecretsManager(region, credentials, 'secretsmanager.PutSecretValue', {
|
|
111
|
+
SecretId: secretId,
|
|
112
|
+
SecretString: value,
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
return { getValue, putValue };
|
|
116
|
+
},
|
|
117
|
+
doctorEnv() {
|
|
118
|
+
const missing = [];
|
|
119
|
+
const region = (process.env['AWS_REGION'] ?? process.env['AWS_DEFAULT_REGION'] ?? '').trim();
|
|
120
|
+
if (region === '')
|
|
121
|
+
missing.push('AWS_REGION');
|
|
122
|
+
const accessKeyId = (process.env['AWS_ACCESS_KEY_ID'] ?? '').trim();
|
|
123
|
+
if (accessKeyId === '')
|
|
124
|
+
missing.push('AWS_ACCESS_KEY_ID');
|
|
125
|
+
const secretAccessKey = (process.env['AWS_SECRET_ACCESS_KEY'] ?? '').trim();
|
|
126
|
+
if (secretAccessKey === '')
|
|
127
|
+
missing.push('AWS_SECRET_ACCESS_KEY');
|
|
128
|
+
return missing;
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
export default AwsSecretsManager;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const CloudflareKv: Readonly<{
|
|
2
|
+
createFromEnv(): {
|
|
3
|
+
getValue: (key: string, namespaceId?: string) => Promise<string | null>;
|
|
4
|
+
putValue: (key: string, value: string, namespaceId?: string) => Promise<void>;
|
|
5
|
+
};
|
|
6
|
+
doctorEnv(): string[];
|
|
7
|
+
}>;
|
|
8
|
+
export default CloudflareKv;
|
|
9
|
+
//# sourceMappingURL=CloudflareKv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloudflareKv.d.ts","sourceRoot":"","sources":["../../../../../src/toolkit/Secrets/providers/CloudflareKv.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;qBACN;QACf,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACxE,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KAC/E;iBAsEY,MAAM,EAAE;EAcrB,CAAC;AAEH,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../../exceptions/ZintrustError';
|
|
2
|
+
export const CloudflareKv = Object.freeze({
|
|
3
|
+
createFromEnv() {
|
|
4
|
+
const accountId = process.env['CLOUDFLARE_ACCOUNT_ID'] ?? '';
|
|
5
|
+
const apiToken = process.env['CLOUDFLARE_API_TOKEN'] ?? '';
|
|
6
|
+
const defaultNamespaceId = process.env['CLOUDFLARE_KV_NAMESPACE_ID'] ?? '';
|
|
7
|
+
if (accountId.trim() === '' || apiToken.trim() === '') {
|
|
8
|
+
throw ErrorFactory.createCliError('Cloudflare credentials missing: set CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_API_TOKEN');
|
|
9
|
+
}
|
|
10
|
+
const getNs = (namespaceId) => {
|
|
11
|
+
const resolved = namespaceId ?? defaultNamespaceId;
|
|
12
|
+
if (resolved.trim() === '') {
|
|
13
|
+
throw ErrorFactory.createCliError('Cloudflare KV namespace missing: set CLOUDFLARE_KV_NAMESPACE_ID or set namespaceId in manifest');
|
|
14
|
+
}
|
|
15
|
+
return resolved;
|
|
16
|
+
};
|
|
17
|
+
const base = `https://api.cloudflare.com/client/v4/accounts/${accountId}/storage/kv/namespaces`;
|
|
18
|
+
const getValue = async (key, namespaceId) => {
|
|
19
|
+
const ns = getNs(namespaceId);
|
|
20
|
+
const url = `${base}/${encodeURIComponent(ns)}/values/${encodeURIComponent(key)}`;
|
|
21
|
+
const res = await fetch(url, {
|
|
22
|
+
method: 'GET',
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${apiToken}`,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
if (res.status === 404)
|
|
28
|
+
return null;
|
|
29
|
+
const text = await res.text();
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
throw ErrorFactory.createCliError(`Cloudflare KV GET failed (${res.status})`, {
|
|
32
|
+
status: res.status,
|
|
33
|
+
body: text,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return text;
|
|
37
|
+
};
|
|
38
|
+
const putValue = async (key, value, namespaceId) => {
|
|
39
|
+
const ns = getNs(namespaceId);
|
|
40
|
+
const url = `${base}/${encodeURIComponent(ns)}/values/${encodeURIComponent(key)}`;
|
|
41
|
+
const res = await fetch(url, {
|
|
42
|
+
method: 'PUT',
|
|
43
|
+
headers: {
|
|
44
|
+
Authorization: `Bearer ${apiToken}`,
|
|
45
|
+
'content-type': 'text/plain',
|
|
46
|
+
},
|
|
47
|
+
body: value,
|
|
48
|
+
});
|
|
49
|
+
const text = await res.text();
|
|
50
|
+
if (!res.ok) {
|
|
51
|
+
throw ErrorFactory.createCliError(`Cloudflare KV PUT failed (${res.status})`, {
|
|
52
|
+
status: res.status,
|
|
53
|
+
body: text,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
return { getValue, putValue };
|
|
58
|
+
},
|
|
59
|
+
doctorEnv() {
|
|
60
|
+
const missing = [];
|
|
61
|
+
const accountId = (process.env['CLOUDFLARE_ACCOUNT_ID'] ?? '').trim();
|
|
62
|
+
if (accountId === '')
|
|
63
|
+
missing.push('CLOUDFLARE_ACCOUNT_ID');
|
|
64
|
+
const apiToken = (process.env['CLOUDFLARE_API_TOKEN'] ?? '').trim();
|
|
65
|
+
if (apiToken === '')
|
|
66
|
+
missing.push('CLOUDFLARE_API_TOKEN');
|
|
67
|
+
const namespaceId = (process.env['CLOUDFLARE_KV_NAMESPACE_ID'] ?? '').trim();
|
|
68
|
+
if (namespaceId === '')
|
|
69
|
+
missing.push('CLOUDFLARE_KV_NAMESPACE_ID');
|
|
70
|
+
return missing;
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
export default CloudflareKv;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Broadcast.d.ts","sourceRoot":"","sources":["../../../../src/tools/broadcast/Broadcast.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,SAAS;kBACA,MAAM,SAAS,MAAM,QAAQ,OAAO;;;EAmCxD,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { InMemoryDriver } from './drivers/InMemory';
|
|
2
|
+
import { PusherDriver } from './drivers/Pusher';
|
|
3
|
+
import { RedisDriver } from './drivers/Redis';
|
|
4
|
+
import { RedisHttpsDriver } from './drivers/RedisHttps';
|
|
5
|
+
import broadcastConfig from '../../config/broadcast';
|
|
6
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
7
|
+
export const Broadcast = Object.freeze({
|
|
8
|
+
async send(channel, event, data) {
|
|
9
|
+
const driver = broadcastConfig.getDriverName();
|
|
10
|
+
const config = broadcastConfig.getDriverConfig();
|
|
11
|
+
if (driver === 'inmemory') {
|
|
12
|
+
const result = await InMemoryDriver.send(undefined, channel, event, data);
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
if (driver === 'pusher') {
|
|
16
|
+
if (config.driver !== 'pusher') {
|
|
17
|
+
throw ErrorFactory.createConfigError('Broadcast driver config mismatch: expected pusher');
|
|
18
|
+
}
|
|
19
|
+
return PusherDriver.send(config, channel, event, data);
|
|
20
|
+
}
|
|
21
|
+
if (driver === 'redis') {
|
|
22
|
+
if (config.driver !== 'redis') {
|
|
23
|
+
throw ErrorFactory.createConfigError('Broadcast driver config mismatch: expected redis');
|
|
24
|
+
}
|
|
25
|
+
return RedisDriver.send(config, channel, event, data);
|
|
26
|
+
}
|
|
27
|
+
if (driver === 'redishttps') {
|
|
28
|
+
if (config.driver !== 'redishttps') {
|
|
29
|
+
throw ErrorFactory.createConfigError('Broadcast driver config mismatch: expected redishttps');
|
|
30
|
+
}
|
|
31
|
+
return RedisHttpsDriver.send(config, channel, event, data);
|
|
32
|
+
}
|
|
33
|
+
const err = ErrorFactory.createConfigError(`Broadcast driver not implemented: ${driver}`);
|
|
34
|
+
throw err;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
export default Broadcast;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDriver.d.ts","sourceRoot":"","sources":["../../../../../src/tools/broadcast/drivers/BaseDriver.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU;YACP,OAAO,CAAC,OAAO,CAAC;EAI9B,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ErrorFactory } from '../../../exceptions/ZintrustError';
|
|
2
|
+
export const BaseDriver = Object.freeze({
|
|
3
|
+
async send() {
|
|
4
|
+
await Promise.resolve();
|
|
5
|
+
throw ErrorFactory.createConfigError('Broadcast driver must implement send()');
|
|
6
|
+
},
|
|
7
|
+
});
|
|
8
|
+
export default BaseDriver;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const InMemoryDriver: Readonly<{
|
|
2
|
+
_events: Array<{
|
|
3
|
+
channel: string;
|
|
4
|
+
event: string;
|
|
5
|
+
data: unknown;
|
|
6
|
+
}>;
|
|
7
|
+
send(_config: unknown, channel: string, event: string, data: unknown): Promise<{
|
|
8
|
+
ok: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
getEvents(): {
|
|
11
|
+
channel: string;
|
|
12
|
+
event: string;
|
|
13
|
+
data: unknown;
|
|
14
|
+
}[];
|
|
15
|
+
reset(): void;
|
|
16
|
+
}>;
|
|
17
|
+
export default InMemoryDriver;
|
|
18
|
+
//# sourceMappingURL=InMemory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InMemory.d.ts","sourceRoot":"","sources":["../../../../../src/tools/broadcast/drivers/InMemory.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;aACV,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;kBAEnD,OAAO,WAAW,MAAM,SAAS,MAAM,QAAQ,OAAO;;;;iBAF1C,MAAM;eAAS,MAAM;cAAQ,OAAO;;;EAgBpE,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const InMemoryDriver = Object.freeze({
|
|
2
|
+
_events: [],
|
|
3
|
+
async send(_config, channel, event, data) {
|
|
4
|
+
// ensure function is async and returns a resolved promise
|
|
5
|
+
await Promise.resolve();
|
|
6
|
+
this._events.push({ channel, event, data });
|
|
7
|
+
return { ok: true };
|
|
8
|
+
},
|
|
9
|
+
getEvents() {
|
|
10
|
+
return this._events.slice();
|
|
11
|
+
},
|
|
12
|
+
reset() {
|
|
13
|
+
this._events.length = 0;
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
export default InMemoryDriver;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PusherBroadcastDriverConfig } from '../../../config/broadcast';
|
|
2
|
+
export declare const PusherDriver: Readonly<{
|
|
3
|
+
send(config: PusherBroadcastDriverConfig, channel: string, event: string, data: unknown): Promise<{
|
|
4
|
+
ok: boolean;
|
|
5
|
+
}>;
|
|
6
|
+
}>;
|
|
7
|
+
export default PusherDriver;
|
|
8
|
+
//# sourceMappingURL=Pusher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Pusher.d.ts","sourceRoot":"","sources":["../../../../../src/tools/broadcast/drivers/Pusher.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAqDrE,eAAO,MAAM,YAAY;iBACJ,2BAA2B,WAAW,MAAM,SAAS,MAAM,QAAQ,OAAO;;;EAkD7F,CAAC;AAEH,eAAe,YAAY,CAAC"}
|