@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
|
@@ -37,14 +37,58 @@ const sanitizeHtml = (html) => {
|
|
|
37
37
|
sanitized = sanitized.replaceAll(/<(?:iframe|object|embed|base)\b[\s\S]*?>/gi, '');
|
|
38
38
|
sanitized = sanitized.replaceAll(/<\/(?:iframe|object|embed|base)>/gi, '');
|
|
39
39
|
// Remove event handlers (on*)
|
|
40
|
-
sanitized = sanitized.replaceAll(/\bon\w+\s*=\s*(?:'[^']*'|"[^"]*"
|
|
41
|
-
// Remove
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
sanitized = sanitized.replaceAll(
|
|
45
|
-
|
|
40
|
+
sanitized = sanitized.replaceAll(/\bon\w+\s*=\s*(?:'[^']*'|"[^"]*"|`[^`]*`|[^\s>]*)/gi, '');
|
|
41
|
+
// Remove dangerous protocols in URL-bearing attributes.
|
|
42
|
+
// This uses the same protocol normalization logic as encodeHref to prevent obfuscations like:
|
|
43
|
+
// href="javascript:..." or href="java\nscript:..." or href="%6a%61..."
|
|
44
|
+
sanitized = sanitized.replaceAll(/(\s)(href|src|action|formaction|xlink:href)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi, (match, _leadingWhitespace, _attributeName, doubleQuotedValue, singleQuotedValue, unquotedValue) => {
|
|
45
|
+
const rawValue = doubleQuotedValue ?? singleQuotedValue ?? unquotedValue ?? '';
|
|
46
|
+
const protocolCheck = normalizeHrefForProtocolCheck(rawValue);
|
|
47
|
+
// Allow relative URLs and fragments.
|
|
48
|
+
if (protocolCheck.startsWith('/') ||
|
|
49
|
+
protocolCheck.startsWith('#') ||
|
|
50
|
+
protocolCheck.startsWith('./') ||
|
|
51
|
+
protocolCheck.startsWith('../') ||
|
|
52
|
+
protocolCheck.startsWith('//')) {
|
|
53
|
+
return match;
|
|
54
|
+
}
|
|
55
|
+
// Allow-list a narrow set of data:image/* URLs for common raster formats.
|
|
56
|
+
if (protocolCheck.startsWith('data:')) {
|
|
57
|
+
const allowedDataImagePrefixes = [
|
|
58
|
+
'data:image/png',
|
|
59
|
+
'data:image/jpeg',
|
|
60
|
+
'data:image/jpg',
|
|
61
|
+
'data:image/gif',
|
|
62
|
+
'data:image/webp',
|
|
63
|
+
'data:image/avif',
|
|
64
|
+
];
|
|
65
|
+
if (allowedDataImagePrefixes.some((p) => protocolCheck.startsWith(p))) {
|
|
66
|
+
return match;
|
|
67
|
+
}
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
const blockedProtocols = ['javascript:', 'vbscript:']; // NOSONAR: S1523 - Explicit protocol blocking to prevent XSS
|
|
71
|
+
if (blockedProtocols.some((p) => protocolCheck.startsWith(p))) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
// If a scheme is present, allowlist it.
|
|
75
|
+
const schemeMatch = new RegExp(/^([a-z][a-z0-9+.-]*):/i).exec(protocolCheck);
|
|
76
|
+
if (schemeMatch) {
|
|
77
|
+
const scheme = schemeMatch[1].toLowerCase();
|
|
78
|
+
const allowedSchemes = new Set(['http', 'https', 'mailto', 'tel']);
|
|
79
|
+
if (!allowedSchemes.has(scheme)) {
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Otherwise, keep the attribute (e.g. relative-like values without a scheme).
|
|
84
|
+
return match;
|
|
85
|
+
});
|
|
46
86
|
// Remove style tags and style attributes with potentially dangerous content
|
|
47
|
-
|
|
87
|
+
let prevSanitized;
|
|
88
|
+
do {
|
|
89
|
+
prevSanitized = sanitized;
|
|
90
|
+
sanitized = sanitized.replaceAll(/<style\b[\s\S]*?<\/style>/gi, '');
|
|
91
|
+
} while (sanitized !== prevSanitized);
|
|
48
92
|
sanitized = sanitized.replaceAll(/\bstyle\s*=\s*(?:'[^']*'|"[^"]*"|[^\s>]*)/gi, '');
|
|
49
93
|
// Remove form elements
|
|
50
94
|
sanitized = sanitized.replaceAll(/<form\b[\s\S]*?<\/form>/gi, '');
|
|
@@ -70,23 +114,109 @@ const encodeUri = (uri) => {
|
|
|
70
114
|
/**
|
|
71
115
|
* Encode URI for use in href attribute
|
|
72
116
|
*/
|
|
117
|
+
function decodeHtmlEntitiesForProtocolCheck(input) {
|
|
118
|
+
// Decode numeric HTML entities so obfuscations like "javascript:" are caught.
|
|
119
|
+
// This is intentionally minimal and only used for protocol detection (not output rendering).
|
|
120
|
+
const decodeCodePoint = (codePoint) => {
|
|
121
|
+
if (!Number.isFinite(codePoint) || codePoint < 0 || codePoint > 0x10ffff) {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
return String.fromCodePoint(codePoint);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return '';
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
// Decode a small set of named entities commonly used for obfuscation.
|
|
132
|
+
const namedDecoded = input.replaceAll(/&([a-z]+);?/gi, (m, name) => {
|
|
133
|
+
const key = String(name).toLowerCase();
|
|
134
|
+
if (key === 'colon')
|
|
135
|
+
return ':';
|
|
136
|
+
if (key === 'tab')
|
|
137
|
+
return '\t';
|
|
138
|
+
if (key === 'newline')
|
|
139
|
+
return '\n';
|
|
140
|
+
if (key === 'nbsp')
|
|
141
|
+
return ' ';
|
|
142
|
+
return m;
|
|
143
|
+
});
|
|
144
|
+
return namedDecoded
|
|
145
|
+
.replaceAll(/&#(\d+);?/g, (_m, dec) => {
|
|
146
|
+
const decStr = typeof dec === 'string' ? dec : String(dec);
|
|
147
|
+
return decodeCodePoint(Number.parseInt(decStr, 10)) || _m;
|
|
148
|
+
})
|
|
149
|
+
.replaceAll(/&#x([0-9a-f]+);?/gi, (_m, hex) => {
|
|
150
|
+
const hexStr = typeof hex === 'string' ? hex : String(hex);
|
|
151
|
+
return decodeCodePoint(Number.parseInt(hexStr, 16)) || _m;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function tryDecodePercentEncoding(input, rounds = 2) {
|
|
155
|
+
let out = input;
|
|
156
|
+
for (let i = 0; i < rounds; i += 1) {
|
|
157
|
+
try {
|
|
158
|
+
const decoded = decodeURIComponent(out);
|
|
159
|
+
if (decoded === out) {
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
out = decoded;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
function normalizeHrefForProtocolCheck(href) {
|
|
171
|
+
// Decode common obfuscations before protocol checks.
|
|
172
|
+
const entityDecoded = decodeHtmlEntitiesForProtocolCheck(href);
|
|
173
|
+
const percentDecoded = tryDecodePercentEncoding(entityDecoded, 2);
|
|
174
|
+
// Remove control characters and whitespace to prevent "java\nscript:" bypasses.
|
|
175
|
+
// eslint-disable-next-line no-control-regex
|
|
176
|
+
return percentDecoded.replaceAll(/[\x00-\x20\x7f\u00a0]/g, '').toLowerCase();
|
|
177
|
+
}
|
|
73
178
|
const encodeHref = (href) => {
|
|
74
179
|
if (typeof href !== 'string') {
|
|
75
180
|
return '';
|
|
76
181
|
}
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
182
|
+
const protocolCheck = normalizeHrefForProtocolCheck(href);
|
|
183
|
+
// Allow relative URLs and fragments.
|
|
184
|
+
if (protocolCheck.startsWith('/') ||
|
|
185
|
+
protocolCheck.startsWith('#') ||
|
|
186
|
+
protocolCheck.startsWith('./') ||
|
|
187
|
+
protocolCheck.startsWith('../') ||
|
|
188
|
+
protocolCheck.startsWith('//')) {
|
|
189
|
+
return escapeHtml(href);
|
|
190
|
+
}
|
|
191
|
+
// Explicitly block common dangerous protocols (including obfuscated versions).
|
|
192
|
+
// Allow-list a narrow set of data:image/* URLs for common raster formats.
|
|
193
|
+
if (protocolCheck.startsWith('data:')) {
|
|
194
|
+
const allowedDataImagePrefixes = [
|
|
195
|
+
'data:image/png',
|
|
196
|
+
'data:image/jpeg',
|
|
197
|
+
'data:image/jpg',
|
|
198
|
+
'data:image/gif',
|
|
199
|
+
'data:image/webp',
|
|
200
|
+
'data:image/avif',
|
|
201
|
+
];
|
|
202
|
+
if (allowedDataImagePrefixes.some((p) => protocolCheck.startsWith(p))) {
|
|
203
|
+
return escapeHtml(href);
|
|
204
|
+
}
|
|
83
205
|
return '';
|
|
84
206
|
}
|
|
85
|
-
|
|
86
|
-
if (protocolCheck.startsWith(
|
|
87
|
-
// NOSONAR: S1523 - We are explicitly blocking data: protocol to prevent XSS
|
|
207
|
+
const blockedProtocols = ['javascript:', 'vbscript:']; // NOSONAR: S1523 - Explicit protocol blocking to prevent XSS
|
|
208
|
+
if (blockedProtocols.some((p) => protocolCheck.startsWith(p))) {
|
|
88
209
|
return '';
|
|
89
210
|
}
|
|
211
|
+
// If a scheme is present, allowlist it.
|
|
212
|
+
const schemeMatch = new RegExp(/^([a-z][a-z0-9+.-]*):/i).exec(protocolCheck);
|
|
213
|
+
if (schemeMatch) {
|
|
214
|
+
const scheme = schemeMatch[1].toLowerCase();
|
|
215
|
+
const allowedSchemes = new Set(['http', 'https', 'mailto', 'tel']);
|
|
216
|
+
if (!allowedSchemes.has(scheme)) {
|
|
217
|
+
return '';
|
|
218
|
+
}
|
|
219
|
+
}
|
|
90
220
|
return escapeHtml(href);
|
|
91
221
|
};
|
|
92
222
|
/**
|
|
@@ -105,6 +235,10 @@ const isSafeUrl = (url) => {
|
|
|
105
235
|
if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
|
|
106
236
|
return true;
|
|
107
237
|
}
|
|
238
|
+
// Allow common safe schemes
|
|
239
|
+
if (trimmed.startsWith('mailto:') || trimmed.startsWith('tel:')) {
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
108
242
|
// Block dangerous protocols
|
|
109
243
|
if (/^\w+:/.test(trimmed)) {
|
|
110
244
|
return false;
|
|
@@ -8,6 +8,7 @@ import { FeatureFlags } from '@config/features';
|
|
|
8
8
|
import { Logger } from '@config/logger';
|
|
9
9
|
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
10
10
|
import { DatabaseConfig, IDatabaseAdapter, QueryResult } from '@orm/DatabaseAdapter';
|
|
11
|
+
import { QueryBuilder } from '@orm/QueryBuilder';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* MySQL adapter implementation
|
|
@@ -47,6 +48,10 @@ export const MySQLAdapter = Object.freeze({
|
|
|
47
48
|
return result.rows[0] ?? null;
|
|
48
49
|
},
|
|
49
50
|
|
|
51
|
+
async ping(): Promise<void> {
|
|
52
|
+
await this.query(QueryBuilder.create('').select('1').toSQL(), []);
|
|
53
|
+
},
|
|
54
|
+
|
|
50
55
|
async transaction<T>(callback: (adapter: IDatabaseAdapter) => Promise<T>): Promise<T> {
|
|
51
56
|
if (!connected) throw ErrorFactory.createConnectionError('Database not connected');
|
|
52
57
|
try {
|
|
@@ -8,6 +8,7 @@ import { FeatureFlags } from '@config/features';
|
|
|
8
8
|
import { Logger } from '@config/logger';
|
|
9
9
|
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
10
10
|
import { DatabaseConfig, IDatabaseAdapter, QueryResult } from '@orm/DatabaseAdapter';
|
|
11
|
+
import { QueryBuilder } from '@orm/QueryBuilder';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* PostgreSQL adapter implementation
|
|
@@ -47,6 +48,10 @@ export const PostgreSQLAdapter = Object.freeze({
|
|
|
47
48
|
return result.rows[0] ?? null;
|
|
48
49
|
},
|
|
49
50
|
|
|
51
|
+
async ping(): Promise<void> {
|
|
52
|
+
await this.query(QueryBuilder.create('').select('1').toSQL(), []);
|
|
53
|
+
},
|
|
54
|
+
|
|
50
55
|
async transaction<T>(callback: (adapter: IDatabaseAdapter) => Promise<T>): Promise<T> {
|
|
51
56
|
if (!connected) throw ErrorFactory.createConnectionError('Database not connected');
|
|
52
57
|
try {
|
|
@@ -8,6 +8,7 @@ import { FeatureFlags } from '@config/features';
|
|
|
8
8
|
import { Logger } from '@config/logger';
|
|
9
9
|
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
10
10
|
import { DatabaseConfig, IDatabaseAdapter, QueryResult } from '@orm/DatabaseAdapter';
|
|
11
|
+
import { QueryBuilder } from '@orm/QueryBuilder';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* SQL Server adapter implementation
|
|
@@ -47,6 +48,10 @@ export const SQLServerAdapter = Object.freeze({
|
|
|
47
48
|
return result.rows[0] ?? null;
|
|
48
49
|
},
|
|
49
50
|
|
|
51
|
+
async ping(): Promise<void> {
|
|
52
|
+
await this.query(QueryBuilder.create('').select('1').toSQL(), []);
|
|
53
|
+
},
|
|
54
|
+
|
|
50
55
|
async transaction<T>(callback: (adapter: IDatabaseAdapter) => Promise<T>): Promise<T> {
|
|
51
56
|
try {
|
|
52
57
|
return await callback(this);
|
|
@@ -10,6 +10,7 @@ import { Logger } from '@config/logger';
|
|
|
10
10
|
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
11
11
|
import { performance } from '@node-singletons/perf-hooks';
|
|
12
12
|
import { DatabaseConfig, IDatabaseAdapter, QueryResult } from '@orm/DatabaseAdapter';
|
|
13
|
+
import { QueryBuilder } from '@orm/QueryBuilder';
|
|
13
14
|
import Database from 'better-sqlite3';
|
|
14
15
|
|
|
15
16
|
function normalizeFilename(database: string | null | undefined): string {
|
|
@@ -157,6 +158,10 @@ function createSQLiteAdapter(config: DatabaseConfig): IDatabaseAdapter {
|
|
|
157
158
|
return result.rows[0] ?? null;
|
|
158
159
|
},
|
|
159
160
|
|
|
161
|
+
async ping(): Promise<void> {
|
|
162
|
+
await adapter.query(QueryBuilder.create('').select('1').toSQL(), []);
|
|
163
|
+
},
|
|
164
|
+
|
|
160
165
|
async transaction<T>(
|
|
161
166
|
callback: (adapter: IDatabaseAdapter, db: Database.Database) => Promise<T>
|
|
162
167
|
): Promise<T> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// TEMPLATE_START
|
|
2
2
|
|
|
3
|
+
import { generateSecureJobId } from '@common/uuid';
|
|
3
4
|
import { Logger } from '@config/logger';
|
|
4
|
-
import { ErrorFactory } from '@exceptions/ZintrustError';
|
|
5
5
|
|
|
6
6
|
export interface QueueJob {
|
|
7
7
|
id: string;
|
|
@@ -44,32 +44,4 @@ export const Queue = Object.freeze({
|
|
|
44
44
|
},
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
async function generateSecureJobId(): Promise<string> {
|
|
48
|
-
if (typeof globalThis.crypto?.randomUUID === 'function') {
|
|
49
|
-
return globalThis.crypto.randomUUID();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (typeof globalThis.crypto?.getRandomValues === 'function') {
|
|
53
|
-
const bytes = new Uint8Array(16);
|
|
54
|
-
globalThis.crypto.getRandomValues(bytes);
|
|
55
|
-
return bytesToHex(bytes);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Node fallback for environments without Web Crypto
|
|
59
|
-
try {
|
|
60
|
-
const nodeCrypto = await import('node:crypto');
|
|
61
|
-
return nodeCrypto.randomBytes(16).toString('hex');
|
|
62
|
-
} catch (error) {
|
|
63
|
-
throw ErrorFactory.createTryCatchError(
|
|
64
|
-
'Secure crypto API not available to generate a job id.',
|
|
65
|
-
error
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function bytesToHex(bytes: Uint8Array): string {
|
|
71
|
-
let out = '';
|
|
72
|
-
for (const b of bytes) out += b.toString(16).padStart(2, '0');
|
|
73
|
-
return out;
|
|
74
|
-
}
|
|
75
47
|
// TEMPLATE_END
|
|
@@ -9,6 +9,25 @@ DB_DATABASE=./database.sqlite
|
|
|
9
9
|
|
|
10
10
|
LOG_LEVEL=debug
|
|
11
11
|
LOG_CHANNEL=file
|
|
12
|
+
LOG_FORMAT=text
|
|
13
|
+
|
|
14
|
+
# Cloud logging backends (optional)
|
|
15
|
+
# KV logger (Cloudflare Workers KV)
|
|
16
|
+
KV_LOG_ENABLED=false
|
|
17
|
+
KV_NAMESPACE=CACHE
|
|
18
|
+
KV_LOG_RETENTION_DAYS=30
|
|
19
|
+
|
|
20
|
+
# Slack logger (Slack incoming webhook)
|
|
21
|
+
SLACK_LOG_ENABLED=false
|
|
22
|
+
SLACK_LOG_WEBHOOK_URL=
|
|
23
|
+
SLACK_LOG_LEVELS=warn,error,fatal
|
|
24
|
+
SLACK_LOG_BATCH_WINDOW_MS=5000
|
|
25
|
+
|
|
26
|
+
# HTTP endpoint logger
|
|
27
|
+
HTTP_LOG_ENABLED=false
|
|
28
|
+
HTTP_LOG_ENDPOINT_URL=
|
|
29
|
+
HTTP_LOG_BATCH_SIZE=50
|
|
30
|
+
HTTP_LOG_AUTH_TOKEN=
|
|
12
31
|
|
|
13
32
|
JWT_SECRET=
|
|
14
33
|
JWT_EXPIRES_IN=1h
|
|
@@ -24,3 +43,32 @@ MAIL_USERNAME=
|
|
|
24
43
|
MAIL_PASSWORD=
|
|
25
44
|
MAIL_FROM_ADDRESS=
|
|
26
45
|
MAIL_FROM_NAME=
|
|
46
|
+
|
|
47
|
+
# Storage
|
|
48
|
+
STORAGE_DRIVER=local
|
|
49
|
+
STORAGE_PATH=storage
|
|
50
|
+
STORAGE_URL=/storage
|
|
51
|
+
STORAGE_VISIBILITY=private
|
|
52
|
+
|
|
53
|
+
# AWS S3
|
|
54
|
+
AWS_ACCESS_KEY_ID=
|
|
55
|
+
AWS_SECRET_ACCESS_KEY=
|
|
56
|
+
AWS_REGION=us-east-1
|
|
57
|
+
AWS_S3_BUCKET=
|
|
58
|
+
AWS_S3_URL=
|
|
59
|
+
AWS_S3_ENDPOINT=
|
|
60
|
+
AWS_S3_USE_PATH_STYLE_URL=false
|
|
61
|
+
|
|
62
|
+
# Cloudflare R2
|
|
63
|
+
R2_ACCESS_KEY_ID=
|
|
64
|
+
R2_SECRET_ACCESS_KEY=
|
|
65
|
+
R2_REGION=
|
|
66
|
+
R2_BUCKET=
|
|
67
|
+
R2_ENDPOINT=
|
|
68
|
+
R2_URL=
|
|
69
|
+
|
|
70
|
+
# Google Cloud Storage (requires optional dependency @google-cloud/storage)
|
|
71
|
+
GCS_PROJECT_ID=
|
|
72
|
+
GCS_KEY_FILE=
|
|
73
|
+
GCS_BUCKET=
|
|
74
|
+
GCS_URL=
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
# ============================================================================
|
|
2
1
|
# Zintrust Framework - Environment Configuration
|
|
3
|
-
#
|
|
4
|
-
# ============================================================================
|
|
2
|
+
# Copy this file to .env and configure for your environment
|
|
5
3
|
|
|
6
4
|
# ============================================================================
|
|
7
5
|
# APPLICATION
|
|
@@ -11,21 +9,8 @@
|
|
|
11
9
|
NODE_ENV=development
|
|
12
10
|
|
|
13
11
|
# Server Configuration
|
|
14
|
-
HOST=
|
|
15
|
-
|
|
16
|
-
APP_NAME={{projectName}}
|
|
17
|
-
APP_KEY=
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
# ============================================================================
|
|
21
|
-
# LOGGING
|
|
22
|
-
# ============================================================================
|
|
23
|
-
|
|
24
|
-
# Log Level: debug | info | warn | error
|
|
25
|
-
LOG_LEVEL=debug
|
|
26
|
-
DISABLE_LOGGING=true
|
|
27
|
-
LOG_CHANNEL=file
|
|
28
|
-
|
|
12
|
+
HOST=
|
|
13
|
+
PORT=
|
|
29
14
|
|
|
30
15
|
# ============================================================================
|
|
31
16
|
# DATABASE
|
|
@@ -33,132 +18,142 @@ LOG_CHANNEL=file
|
|
|
33
18
|
|
|
34
19
|
# Database Connection Driver
|
|
35
20
|
# Options: sqlite | postgresql | mysql | sqlserver | d1
|
|
36
|
-
DB_CONNECTION=
|
|
21
|
+
DB_CONNECTION=
|
|
22
|
+
|
|
23
|
+
# SQLite (default for development)
|
|
24
|
+
DB_PATH=
|
|
25
|
+
|
|
26
|
+
# PostgreSQL
|
|
27
|
+
# DB_HOST=localhost
|
|
28
|
+
# DB_PORT=5432
|
|
29
|
+
# DB_DATABASE=zintrust
|
|
30
|
+
# DB_USERNAME=postgres
|
|
31
|
+
# DB_PASSWORD=postgres
|
|
37
32
|
|
|
38
|
-
#
|
|
39
|
-
|
|
33
|
+
# MySQL
|
|
34
|
+
# DB_HOST=localhost
|
|
35
|
+
# DB_PORT=3306
|
|
36
|
+
# DB_DATABASE=zintrust
|
|
37
|
+
# DB_USERNAME=root
|
|
38
|
+
# DB_PASSWORD=password
|
|
40
39
|
|
|
41
|
-
#
|
|
42
|
-
DB_HOST=localhost
|
|
43
|
-
DB_PORT=
|
|
44
|
-
DB_DATABASE=zintrust
|
|
45
|
-
DB_USERNAME=
|
|
46
|
-
DB_PASSWORD=
|
|
47
|
-
DB_READ_HOSTS=
|
|
40
|
+
# SQL Server
|
|
41
|
+
# DB_HOST=localhost
|
|
42
|
+
# DB_PORT=1433
|
|
43
|
+
# DB_DATABASE=zintrust
|
|
44
|
+
# DB_USERNAME=sa
|
|
45
|
+
# DB_PASSWORD=Password123
|
|
48
46
|
|
|
49
47
|
# ============================================================================
|
|
50
|
-
#
|
|
48
|
+
# ADVANCED DATABASE FEATURES
|
|
51
49
|
# ============================================================================
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
# Raw SQL Query Support
|
|
52
|
+
# WARNING: Only enable in development. Bypasses QueryBuilder safety.
|
|
53
|
+
# This is checked once at application bootstrap, cached in memory.
|
|
54
|
+
# Feature flag is initialized at startup - no runtime changes possible.
|
|
55
|
+
USE_RAW_QRY=
|
|
55
56
|
|
|
56
57
|
# ============================================================================
|
|
57
58
|
# CACHE
|
|
58
59
|
# ============================================================================
|
|
59
60
|
|
|
60
|
-
# Cache Driver: memory | redis |
|
|
61
|
-
|
|
61
|
+
# Cache Driver: memory | redis | mongodb | kv
|
|
62
|
+
# - kv: Cloudflare Workers only (requires a KV binding named "CACHE")
|
|
63
|
+
CACHE_DRIVER=
|
|
62
64
|
|
|
63
|
-
# Redis Configuration
|
|
64
|
-
REDIS_HOST=localhost
|
|
65
|
-
REDIS_PORT=6379
|
|
66
|
-
REDIS_PASSWORD=
|
|
65
|
+
# Redis Configuration (if using Redis)
|
|
66
|
+
# REDIS_HOST=localhost
|
|
67
|
+
# REDIS_PORT=6379
|
|
67
68
|
|
|
68
|
-
# MongoDB Cache
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
# MongoDB Cache (if using mongodb)
|
|
70
|
+
# Uses MongoDB Atlas Data API (HTTPS)
|
|
71
|
+
# MONGO_URI=https://data.mongodb-api.com/app/<app-id>/endpoint/data/v1
|
|
72
|
+
# MONGO_DB=zintrust_cache
|
|
71
73
|
|
|
72
74
|
# ============================================================================
|
|
73
|
-
#
|
|
75
|
+
# LOGGING
|
|
74
76
|
# ============================================================================
|
|
75
77
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
AWS_LAMBDA_FUNCTION_VERSION=
|
|
79
|
-
AWS_EXECUTION_ENV=
|
|
80
|
-
LAMBDA_TASK_ROOT=
|
|
81
|
-
|
|
82
|
-
# ============================================================================
|
|
83
|
-
# MICROSERVICES
|
|
84
|
-
# ============================================================================
|
|
78
|
+
# Log Level: debug | info | warn | error
|
|
79
|
+
LOG_LEVEL=
|
|
85
80
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
MICROSERVICES_TRACING=false
|
|
89
|
-
MICROSERVICES_TRACING_RATE=1.0
|
|
90
|
-
DATABASE_ISOLATION=shared
|
|
91
|
-
SERVICE_API_KEY=
|
|
92
|
-
SERVICE_JWT_SECRET=
|
|
81
|
+
# Log Channel: console | file | all
|
|
82
|
+
LOG_CHANNEL=
|
|
93
83
|
|
|
94
84
|
# ============================================================================
|
|
95
85
|
# SECURITY
|
|
96
86
|
# ============================================================================
|
|
97
87
|
|
|
98
|
-
DEBUG=false
|
|
99
|
-
ENABLE_MICROSERVICES=false
|
|
100
|
-
TOKEN_TTL=3600000
|
|
101
|
-
TOKEN_LENGTH=32
|
|
102
|
-
|
|
103
88
|
# JWT Secret for authentication
|
|
104
89
|
JWT_SECRET=
|
|
105
90
|
|
|
106
91
|
# Session Configuration
|
|
107
|
-
SESSION_DRIVER=
|
|
108
|
-
SESSION_LIFETIME=
|
|
92
|
+
SESSION_DRIVER=
|
|
93
|
+
SESSION_LIFETIME=
|
|
109
94
|
|
|
110
95
|
# CORS Configuration
|
|
111
|
-
CORS_ORIGINS=
|
|
96
|
+
CORS_ORIGINS=
|
|
112
97
|
|
|
113
98
|
# ============================================================================
|
|
114
|
-
#
|
|
99
|
+
# MICROSERVICES
|
|
115
100
|
# ============================================================================
|
|
116
101
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
MAX_BODY_SIZE=10485760
|
|
102
|
+
# Enable Microservices
|
|
103
|
+
MICROSERVICES=
|
|
120
104
|
|
|
105
|
+
# Comma-separated list of services to load
|
|
106
|
+
SERVICES=
|
|
107
|
+
|
|
108
|
+
# Service Discovery
|
|
109
|
+
SERVICE_DISCOVERY=
|
|
110
|
+
|
|
111
|
+
# Request Tracing
|
|
112
|
+
MICROSERVICES_TRACING=
|
|
113
|
+
MICROSERVICES_TRACING_RATE=
|
|
121
114
|
|
|
122
115
|
# ============================================================================
|
|
123
|
-
#
|
|
116
|
+
# SONARQUBE / SONARCLOUD
|
|
124
117
|
# ============================================================================
|
|
125
118
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
SONAR_HOST_URL="https://sonarcloud.io"
|
|
129
|
-
SONAR_TOKEN=
|
|
119
|
+
# SonarQube Server
|
|
120
|
+
SONAR_HOST_URL=
|
|
130
121
|
|
|
131
|
-
#
|
|
132
|
-
|
|
133
|
-
|
|
122
|
+
# SonarCloud
|
|
123
|
+
# SONAR_HOST_URL=https://sonarcloud.io
|
|
124
|
+
# SONAR_TOKEN=your_token
|
|
125
|
+
# SONAR_ORGANIZATION=your-organization
|
|
134
126
|
|
|
135
|
-
|
|
127
|
+
# ============================================================================
|
|
128
|
+
# EXTERNAL SERVICES
|
|
129
|
+
# ============================================================================
|
|
136
130
|
|
|
137
|
-
# Security
|
|
138
|
-
SNYK_TOKEN=
|
|
131
|
+
# Snyk Security Token
|
|
132
|
+
# SNYK_TOKEN=your_token
|
|
139
133
|
|
|
140
|
-
#
|
|
141
|
-
SENDGRID_API_KEY=
|
|
134
|
+
# SendGrid (Email)
|
|
135
|
+
# SENDGRID_API_KEY=your_api_key
|
|
142
136
|
|
|
143
|
-
#
|
|
144
|
-
STRIPE_SECRET_KEY=
|
|
145
|
-
STRIPE_PUBLIC_KEY=
|
|
137
|
+
# Stripe (Payments)
|
|
138
|
+
# STRIPE_SECRET_KEY=your_secret_key
|
|
139
|
+
# STRIPE_PUBLIC_KEY=your_public_key
|
|
146
140
|
|
|
147
|
-
#
|
|
148
|
-
AWS_ACCESS_KEY_ID=
|
|
149
|
-
AWS_SECRET_ACCESS_KEY=
|
|
150
|
-
|
|
141
|
+
# AWS S3 (File Storage)
|
|
142
|
+
# AWS_ACCESS_KEY_ID=your_access_key
|
|
143
|
+
# AWS_SECRET_ACCESS_KEY=your_secret_key
|
|
144
|
+
# AWS_REGION=us-east-1
|
|
145
|
+
# AWS_BUCKET=your_bucket_name
|
|
151
146
|
|
|
152
147
|
# ============================================================================
|
|
153
148
|
# DEVELOPMENT
|
|
154
149
|
# ============================================================================
|
|
155
150
|
|
|
151
|
+
# Debug Mode
|
|
152
|
+
DEBUG=
|
|
153
|
+
|
|
156
154
|
# Database Synchronization (auto-migrate on startup)
|
|
157
|
-
DB_SYNCHRONIZE=
|
|
155
|
+
DB_SYNCHRONIZE=
|
|
158
156
|
|
|
159
157
|
# Database Logging
|
|
160
|
-
DB_LOGGING=
|
|
158
|
+
DB_LOGGING=
|
|
161
159
|
|
|
162
|
-
# Raw SQL Query Support (development only)
|
|
163
|
-
# WARNING: Only enable in development. Bypasses QueryBuilder safety.
|
|
164
|
-
USE_RAW_QRY=false
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Mail } from '@mail/Mail';
|
|
2
|
+
|
|
3
|
+
export async function sendWelcomeEmail(
|
|
4
|
+
to: string,
|
|
5
|
+
name: string,
|
|
6
|
+
attachmentDisk?: string,
|
|
7
|
+
attachmentPath?: string
|
|
8
|
+
): Promise<void> {
|
|
9
|
+
const subject = `Welcome, ${name}`;
|
|
10
|
+
const text = `Hello ${name}, welcome.`;
|
|
11
|
+
|
|
12
|
+
const attachments =
|
|
13
|
+
attachmentDisk !== null &&
|
|
14
|
+
attachmentDisk !== undefined &&
|
|
15
|
+
attachmentDisk.trim() !== '' &&
|
|
16
|
+
attachmentPath !== null &&
|
|
17
|
+
attachmentPath !== undefined &&
|
|
18
|
+
attachmentPath.trim() !== ''
|
|
19
|
+
? [{ disk: attachmentDisk, path: attachmentPath }]
|
|
20
|
+
: undefined;
|
|
21
|
+
|
|
22
|
+
await Mail.send({
|
|
23
|
+
to,
|
|
24
|
+
subject,
|
|
25
|
+
text,
|
|
26
|
+
attachments,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default Object.freeze({ sendWelcomeEmail });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { sendSlackWebhook } from '@notification/drivers/Slack';
|
|
2
|
+
|
|
3
|
+
export async function sendSlackNotification(
|
|
4
|
+
webhookUrl: string,
|
|
5
|
+
message: { text: string }
|
|
6
|
+
): Promise<void> {
|
|
7
|
+
await sendSlackWebhook({ webhookUrl }, message);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default Object.freeze({ sendSlackNotification });
|