@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
|
@@ -4,14 +4,13 @@
|
|
|
4
4
|
* Runs during npm run build
|
|
5
5
|
*/
|
|
6
6
|
import { TemplateRegistry } from '../templates/TemplateRegistry.js';
|
|
7
|
+
import { ensureDir, esmDirname } from '../common/index';
|
|
7
8
|
import { Logger } from '../config/logger';
|
|
8
9
|
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
9
10
|
import * as crypto from '../node-singletons/crypto';
|
|
10
11
|
import fs from '../node-singletons/fs';
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
-
const __dirname = path.dirname(__filename);
|
|
12
|
+
import * as path from '../node-singletons/path';
|
|
13
|
+
const __dirname = esmDirname(import.meta.url);
|
|
15
14
|
const ROOT_DIR = path.resolve(__dirname, '../../');
|
|
16
15
|
/**
|
|
17
16
|
* Calculate SHA1 hash of file content
|
|
@@ -48,14 +47,6 @@ function extractTemplateContent(filePath) {
|
|
|
48
47
|
throw ErrorFactory.createTryCatchError(`Failed to extract template from: ${filePath}`, error);
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Ensure directory exists, create if needed
|
|
53
|
-
*/
|
|
54
|
-
function ensureDir(dirPath) {
|
|
55
|
-
if (!fs.existsSync(dirPath)) {
|
|
56
|
-
fs.mkdirSync(dirPath, { recursive: true });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
50
|
const shouldSkipEntry = (name) => {
|
|
60
51
|
return (name === 'node_modules' ||
|
|
61
52
|
name === 'dist' ||
|
|
@@ -117,64 +108,28 @@ const syncProjectTemplateDir = (params) => {
|
|
|
117
108
|
}
|
|
118
109
|
return { updated, skipped, total: files.length };
|
|
119
110
|
};
|
|
120
|
-
|
|
121
|
-
* Load existing checksums from JSON file
|
|
122
|
-
*/
|
|
123
|
-
function loadChecksums() {
|
|
124
|
-
const checksumPath = path.join(ROOT_DIR, '.template-checksums.json');
|
|
125
|
-
if (fs.existsSync(checksumPath)) {
|
|
126
|
-
try {
|
|
127
|
-
const content = fs.readFileSync(checksumPath, 'utf8');
|
|
128
|
-
return JSON.parse(content);
|
|
129
|
-
}
|
|
130
|
-
catch (error) {
|
|
131
|
-
Logger.error('Could not parse .template-checksums.json, starting fresh', error);
|
|
132
|
-
return {};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return {};
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Save checksums to JSON file
|
|
139
|
-
*/
|
|
140
|
-
function saveChecksums(checksums) {
|
|
141
|
-
const checksumPath = path.join(ROOT_DIR, '.template-checksums.json');
|
|
142
|
-
fs.writeFileSync(checksumPath, JSON.stringify(checksums, null, 2));
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Main sync function
|
|
146
|
-
*/
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
148
|
-
async function syncTemplates() {
|
|
149
|
-
Logger.info('🔄 Syncing templates...\n');
|
|
150
|
-
const checksums = loadChecksums();
|
|
151
|
-
const mappings = TemplateRegistry.getMappings();
|
|
111
|
+
const syncRegistryMappings = (params) => {
|
|
152
112
|
let updated = 0;
|
|
153
113
|
let skipped = 0;
|
|
154
|
-
for (const mapping of mappings) {
|
|
114
|
+
for (const mapping of params.mappings) {
|
|
155
115
|
const basePath = path.join(ROOT_DIR, mapping.basePath);
|
|
156
116
|
const templatePath = path.join(ROOT_DIR, mapping.templatePath);
|
|
157
|
-
// Check if base file exists
|
|
158
117
|
if (!fs.existsSync(basePath)) {
|
|
159
118
|
Logger.warn(`⚠️ Base file not found: ${mapping.basePath}`);
|
|
160
119
|
continue;
|
|
161
120
|
}
|
|
162
|
-
// Calculate current hash
|
|
163
121
|
const currentHash = hashFile(basePath);
|
|
164
|
-
const storedHash = checksums[mapping.basePath];
|
|
165
|
-
// Check if update is needed
|
|
122
|
+
const storedHash = params.checksums[mapping.basePath];
|
|
166
123
|
if (currentHash === storedHash && fs.existsSync(templatePath)) {
|
|
167
124
|
Logger.info(`✓ ${mapping.description} (in sync)`);
|
|
168
125
|
skipped++;
|
|
169
126
|
continue;
|
|
170
127
|
}
|
|
171
|
-
// Extract and write template
|
|
172
128
|
try {
|
|
173
129
|
const templateContent = extractTemplateContent(basePath);
|
|
174
130
|
ensureDir(path.dirname(templatePath));
|
|
175
131
|
fs.writeFileSync(templatePath, templateContent, 'utf8');
|
|
176
|
-
|
|
177
|
-
checksums[mapping.basePath] = currentHash;
|
|
132
|
+
params.checksums[mapping.basePath] = currentHash;
|
|
178
133
|
Logger.info(`✓ Updated: ${mapping.description}`);
|
|
179
134
|
updated++;
|
|
180
135
|
}
|
|
@@ -183,46 +138,130 @@ async function syncTemplates() {
|
|
|
183
138
|
process.exit(1);
|
|
184
139
|
}
|
|
185
140
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
141
|
+
return { updated, skipped };
|
|
142
|
+
};
|
|
143
|
+
const syncStarterEnvTemplate = (params) => {
|
|
144
|
+
const envExampleAbs = fs.existsSync(path.join(ROOT_DIR, '.env.example'))
|
|
145
|
+
? path.join(ROOT_DIR, '.env.example')
|
|
146
|
+
: path.join(ROOT_DIR, '.env.example.generated');
|
|
147
|
+
const envTemplateAbs = path.join(ROOT_DIR, params.projectRoot, '.env.tpl');
|
|
148
|
+
const envChecksumKey = 'starter/.env';
|
|
149
|
+
if (!fs.existsSync(envExampleAbs)) {
|
|
150
|
+
Logger.warn('⚠️ .env.example not found; skipping starter .env template generation');
|
|
151
|
+
return { updated: 0, skipped: 0, total: 1 };
|
|
152
|
+
}
|
|
153
|
+
const currentHash = hashFile(envExampleAbs);
|
|
154
|
+
const storedHash = params.checksums[envChecksumKey];
|
|
155
|
+
if (currentHash === storedHash && fs.existsSync(envTemplateAbs)) {
|
|
156
|
+
return { updated: 0, skipped: 1, total: 1 };
|
|
157
|
+
}
|
|
158
|
+
const raw = fs.readFileSync(envExampleAbs, 'utf8');
|
|
159
|
+
const lines = raw.split(/\r?\n/);
|
|
160
|
+
const rendered = lines
|
|
161
|
+
.map((line) => {
|
|
162
|
+
if (line.trim() === '' || line.startsWith('#'))
|
|
163
|
+
return line;
|
|
164
|
+
const eq = line.indexOf('=');
|
|
165
|
+
if (eq === -1)
|
|
166
|
+
return line;
|
|
167
|
+
const key = line.slice(0, eq).trim();
|
|
168
|
+
if (key === '')
|
|
169
|
+
return line;
|
|
170
|
+
if (key === 'NODE_ENV')
|
|
171
|
+
return 'NODE_ENV=development';
|
|
172
|
+
return `${key}=`;
|
|
173
|
+
})
|
|
174
|
+
.join('\n') + '\n';
|
|
175
|
+
ensureDir(path.dirname(envTemplateAbs));
|
|
176
|
+
fs.writeFileSync(envTemplateAbs, rendered, 'utf8');
|
|
177
|
+
params.checksums[envChecksumKey] = currentHash;
|
|
178
|
+
Logger.info('✓ Starter project .env (generated)');
|
|
179
|
+
return { updated: 1, skipped: 0, total: 1 };
|
|
180
|
+
};
|
|
181
|
+
const syncStarterProjectTemplates = (params) => {
|
|
192
182
|
const s1 = syncProjectTemplateDir({
|
|
193
|
-
checksums,
|
|
183
|
+
checksums: params.checksums,
|
|
194
184
|
baseDirRel: 'app',
|
|
195
|
-
templateDirRel: `${projectRoot}/app`,
|
|
185
|
+
templateDirRel: `${params.projectRoot}/app`,
|
|
196
186
|
description: 'Starter project app/*',
|
|
197
187
|
});
|
|
198
188
|
const s2 = syncProjectTemplateDir({
|
|
199
|
-
checksums,
|
|
189
|
+
checksums: params.checksums,
|
|
200
190
|
baseDirRel: 'src/config',
|
|
201
|
-
templateDirRel: `${projectRoot}/config`,
|
|
191
|
+
templateDirRel: `${params.projectRoot}/config`,
|
|
202
192
|
description: 'Starter project config/* (from src/config/*)',
|
|
203
193
|
});
|
|
204
194
|
const s3 = syncProjectTemplateDir({
|
|
205
|
-
checksums,
|
|
195
|
+
checksums: params.checksums,
|
|
206
196
|
baseDirRel: 'src/database',
|
|
207
|
-
templateDirRel: `${projectRoot}/database`,
|
|
197
|
+
templateDirRel: `${params.projectRoot}/database`,
|
|
208
198
|
description: 'Starter project database/* (from src/database/*)',
|
|
209
199
|
});
|
|
210
200
|
const s4 = syncProjectTemplateDir({
|
|
211
|
-
checksums,
|
|
201
|
+
checksums: params.checksums,
|
|
212
202
|
baseDirRel: 'routes',
|
|
213
|
-
templateDirRel: `${projectRoot}/routes`,
|
|
203
|
+
templateDirRel: `${params.projectRoot}/routes`,
|
|
214
204
|
description: 'Starter project routes/*',
|
|
215
205
|
});
|
|
216
|
-
const s5 = {
|
|
217
|
-
|
|
218
|
-
|
|
206
|
+
const s5 = syncStarterEnvTemplate({
|
|
207
|
+
checksums: params.checksums,
|
|
208
|
+
projectRoot: params.projectRoot,
|
|
209
|
+
});
|
|
210
|
+
return {
|
|
211
|
+
updated: s1.updated + s2.updated + s3.updated + s4.updated + s5.updated,
|
|
212
|
+
skipped: s1.skipped + s2.skipped + s3.skipped + s4.skipped + s5.skipped,
|
|
213
|
+
total: s1.total + s2.total + s3.total + s4.total + s5.total,
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* Load existing checksums from JSON file
|
|
218
|
+
*/
|
|
219
|
+
function loadChecksums() {
|
|
220
|
+
const checksumPath = path.join(ROOT_DIR, '.template-checksums.json');
|
|
221
|
+
if (fs.existsSync(checksumPath)) {
|
|
222
|
+
try {
|
|
223
|
+
const content = fs.readFileSync(checksumPath, 'utf8');
|
|
224
|
+
return JSON.parse(content);
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
Logger.error('Could not parse .template-checksums.json, starting fresh', error);
|
|
228
|
+
return {};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return {};
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Save checksums to JSON file
|
|
235
|
+
*/
|
|
236
|
+
function saveChecksums(checksums) {
|
|
237
|
+
const checksumPath = path.join(ROOT_DIR, '.template-checksums.json');
|
|
238
|
+
fs.writeFileSync(checksumPath, JSON.stringify(checksums, null, 2));
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Main sync function
|
|
242
|
+
*/
|
|
243
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
244
|
+
async function syncTemplates() {
|
|
245
|
+
Logger.info('🔄 Syncing templates...\n');
|
|
246
|
+
const checksums = loadChecksums();
|
|
247
|
+
const mappings = TemplateRegistry.getMappings();
|
|
248
|
+
const registry = syncRegistryMappings({ checksums, mappings });
|
|
249
|
+
// Sync starter project templates (basic) from base framework folders.
|
|
250
|
+
// Spec: app/* -> app/*, src/config/* -> config/*, src/database/* -> database/*, routes/* -> routes/*
|
|
251
|
+
// plus .env (generated from .env.example with sensitive values blanked).
|
|
252
|
+
Logger.info('');
|
|
253
|
+
Logger.info('🔄 Syncing starter project templates (basic)...');
|
|
254
|
+
const projectRoot = 'src/templates/project/basic';
|
|
255
|
+
const starter = syncStarterProjectTemplates({ checksums, projectRoot });
|
|
219
256
|
// Save updated checksums
|
|
220
257
|
saveChecksums(checksums);
|
|
221
258
|
// Summary
|
|
259
|
+
const updated = registry.updated + starter.updated;
|
|
260
|
+
const skipped = registry.skipped + starter.skipped;
|
|
222
261
|
Logger.info(`\n📦 Template sync complete`);
|
|
223
262
|
Logger.info(` Updated: ${updated}`);
|
|
224
263
|
Logger.info(` Skipped: ${skipped}`);
|
|
225
|
-
Logger.info(` Total: ${mappings.length +
|
|
264
|
+
Logger.info(` Total: ${mappings.length + starter.total}\n`);
|
|
226
265
|
}
|
|
227
266
|
// Run sync
|
|
228
267
|
try {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { Logger } from '../config/logger';
|
|
6
6
|
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
7
|
-
import { pbkdf2Sync, randomBytes } from 'node
|
|
7
|
+
import { pbkdf2Sync, randomBytes } from '../node-singletons/crypto';
|
|
8
8
|
function isBcryptModule(value) {
|
|
9
9
|
if (typeof value !== 'object' || value === null)
|
|
10
10
|
return false;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash
|
|
3
|
+
* bcrypt-based password hashing utility.
|
|
4
|
+
*
|
|
5
|
+
* Runtime-aware: uses dynamic import for bcrypt.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Hash: Readonly<{
|
|
8
|
+
isValidHash(hash: string): boolean;
|
|
9
|
+
hash(plaintext: string): Promise<string>;
|
|
10
|
+
hashWithRounds(plaintext: string, rounds: number): Promise<string>;
|
|
11
|
+
verify(plaintext: string, hashed: string): Promise<boolean>;
|
|
12
|
+
}>;
|
|
13
|
+
export default Hash;
|
|
14
|
+
//# sourceMappingURL=Hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Hash.d.ts","sourceRoot":"","sources":["../../../src/security/Hash.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA+CH,eAAO,MAAM,IAAI;sBACG,MAAM,GAAG,OAAO;oBAIZ,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;8BAUd,MAAM,UAAU,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;sBAgBhD,MAAM,UAAU,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;EAWjE,CAAC;AAEH,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hash
|
|
3
|
+
* bcrypt-based password hashing utility.
|
|
4
|
+
*
|
|
5
|
+
* Runtime-aware: uses dynamic import for bcrypt.
|
|
6
|
+
*/
|
|
7
|
+
import { Logger } from '../config/logger';
|
|
8
|
+
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
9
|
+
function isBcryptModule(value) {
|
|
10
|
+
if (typeof value !== 'object' || value === null)
|
|
11
|
+
return false;
|
|
12
|
+
const record = value;
|
|
13
|
+
return typeof record['hash'] === 'function' && typeof record['compare'] === 'function';
|
|
14
|
+
}
|
|
15
|
+
let bcrypt;
|
|
16
|
+
let loadingPromise;
|
|
17
|
+
async function loadBcrypt() {
|
|
18
|
+
const imported = await import('bcrypt');
|
|
19
|
+
const module = imported;
|
|
20
|
+
const candidate = module.default ?? module;
|
|
21
|
+
if (!isBcryptModule(candidate)) {
|
|
22
|
+
throw ErrorFactory.createConfigError('Invalid bcrypt module shape');
|
|
23
|
+
}
|
|
24
|
+
bcrypt = candidate;
|
|
25
|
+
}
|
|
26
|
+
async function ensureBcrypt() {
|
|
27
|
+
if (bcrypt !== undefined)
|
|
28
|
+
return bcrypt;
|
|
29
|
+
loadingPromise ??= loadBcrypt().catch((error) => {
|
|
30
|
+
Logger.error('bcrypt unavailable', error);
|
|
31
|
+
throw ErrorFactory.createConfigError('bcrypt unavailable', error);
|
|
32
|
+
});
|
|
33
|
+
await loadingPromise;
|
|
34
|
+
if (bcrypt === undefined) {
|
|
35
|
+
throw ErrorFactory.createConfigError('bcrypt unavailable');
|
|
36
|
+
}
|
|
37
|
+
return bcrypt;
|
|
38
|
+
}
|
|
39
|
+
const BCRYPT_HASH_RE = /^\$2[aby]\$\d{2}\$[./A-Za-z0-9]{53}$/;
|
|
40
|
+
export const Hash = Object.freeze({
|
|
41
|
+
isValidHash(hash) {
|
|
42
|
+
return BCRYPT_HASH_RE.test(hash);
|
|
43
|
+
},
|
|
44
|
+
async hash(plaintext) {
|
|
45
|
+
const bcryptModule = await ensureBcrypt();
|
|
46
|
+
try {
|
|
47
|
+
return await bcryptModule.hash(plaintext, 12);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
Logger.error('Password hashing failed', error);
|
|
51
|
+
throw ErrorFactory.createSecurityError('Password hashing failed', error);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
async hashWithRounds(plaintext, rounds) {
|
|
55
|
+
const bcryptModule = await ensureBcrypt();
|
|
56
|
+
const normalizedRounds = Number.isFinite(rounds) ? Math.trunc(rounds) : 0;
|
|
57
|
+
if (normalizedRounds <= 0) {
|
|
58
|
+
throw ErrorFactory.createConfigError('Invalid bcrypt rounds', { rounds });
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return await bcryptModule.hash(plaintext, normalizedRounds);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
Logger.error('Password hashing failed', error);
|
|
65
|
+
throw ErrorFactory.createSecurityError('Password hashing failed', error);
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
async verify(plaintext, hashed) {
|
|
69
|
+
if (!Hash.isValidHash(hashed))
|
|
70
|
+
return false;
|
|
71
|
+
try {
|
|
72
|
+
const bcryptModule = await ensureBcrypt();
|
|
73
|
+
return await bcryptModule.compare(plaintext, hashed);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
Logger.error('Password verify failed', error);
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
export default Hash;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Startup Secret Validation
|
|
3
|
+
*
|
|
4
|
+
* Validates critical secrets early at boot time so production misconfiguration
|
|
5
|
+
* fails fast and predictably.
|
|
6
|
+
*/
|
|
7
|
+
export type StartupSecretValidationError = {
|
|
8
|
+
key: string;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
export type StartupSecretValidationResult = {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
errors: StartupSecretValidationError[];
|
|
14
|
+
};
|
|
15
|
+
export declare const StartupSecretValidation: Readonly<{
|
|
16
|
+
validate(): StartupSecretValidationResult;
|
|
17
|
+
assertValid(): void;
|
|
18
|
+
}>;
|
|
19
|
+
export default StartupSecretValidation;
|
|
20
|
+
//# sourceMappingURL=StartupSecretValidation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartupSecretValidation.d.ts","sourceRoot":"","sources":["../../../src/security/StartupSecretValidation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,MAAM,4BAA4B,GAAG;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,4BAA4B,EAAE,CAAC;CACxC,CAAC;AA6BF,eAAO,MAAM,uBAAuB;gBACtB,6BAA6B;mBAe1B,IAAI;EAQnB,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Startup Secret Validation
|
|
3
|
+
*
|
|
4
|
+
* Validates critical secrets early at boot time so production misconfiguration
|
|
5
|
+
* fails fast and predictably.
|
|
6
|
+
*/
|
|
7
|
+
import { appConfig } from '../config/app';
|
|
8
|
+
import { securityConfig } from '../config/security';
|
|
9
|
+
import { startupConfig } from '../config/startup';
|
|
10
|
+
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
11
|
+
const validateApiKeySecret = () => {
|
|
12
|
+
if (!securityConfig.apiKey.enabled)
|
|
13
|
+
return null;
|
|
14
|
+
const secret = (securityConfig.apiKey.secret ?? '').trim();
|
|
15
|
+
if (secret.length > 0)
|
|
16
|
+
return null;
|
|
17
|
+
return {
|
|
18
|
+
key: 'API_KEY_SECRET',
|
|
19
|
+
message: 'API_KEY_SECRET must be set when API key auth is enabled',
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const validateJwtSecret = () => {
|
|
23
|
+
if (!securityConfig.jwt.enabled)
|
|
24
|
+
return null;
|
|
25
|
+
try {
|
|
26
|
+
const secret = securityConfig.jwt.secret.trim();
|
|
27
|
+
if (secret.length === 0) {
|
|
28
|
+
return { key: 'JWT_SECRET', message: 'JWT_SECRET must be set when JWT is enabled' };
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
34
|
+
return { key: 'JWT_SECRET', message };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export const StartupSecretValidation = Object.freeze({
|
|
38
|
+
validate() {
|
|
39
|
+
if (!startupConfig.validateSecrets)
|
|
40
|
+
return { valid: true, errors: [] };
|
|
41
|
+
if (!appConfig.isProduction())
|
|
42
|
+
return { valid: true, errors: [] };
|
|
43
|
+
const errors = [];
|
|
44
|
+
const jwtError = validateJwtSecret();
|
|
45
|
+
if (jwtError !== null)
|
|
46
|
+
errors.push(jwtError);
|
|
47
|
+
const apiKeyError = validateApiKeySecret();
|
|
48
|
+
if (apiKeyError !== null)
|
|
49
|
+
errors.push(apiKeyError);
|
|
50
|
+
return { valid: errors.length === 0, errors };
|
|
51
|
+
},
|
|
52
|
+
assertValid() {
|
|
53
|
+
const result = StartupSecretValidation.validate();
|
|
54
|
+
if (result.valid)
|
|
55
|
+
return;
|
|
56
|
+
throw ErrorFactory.createConfigError('Invalid startup secret configuration', {
|
|
57
|
+
errors: result.errors,
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
export default StartupSecretValidation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlValidator.d.ts","sourceRoot":"","sources":["../../../src/security/UrlValidator.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"UrlValidator.d.ts","sourceRoot":"","sources":["../../../src/security/UrlValidator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAC3D;AAED;;;GAGG;AACH,QAAA,MAAM,QAAQ,GAAI,KAAK,MAAM,EAAE,iBAAgB,MAAM,EAA+B,KAAG,IAyBtF,CAAC;AAEF,QAAA,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,iBAAiB,MAAM,EAAE,KAAG,IAE7D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,aAGzB,CAAC;AAGH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Security Utilities
|
|
3
3
|
* Mitigates SSRF (SonarQube S5144)
|
|
4
4
|
*/
|
|
5
|
-
import { Env } from '../config/env';
|
|
6
5
|
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
7
6
|
/**
|
|
8
7
|
* Validate URL for SSRF protection
|
|
@@ -15,7 +14,7 @@ const validate = (url, allowedDomains = ['localhost', '127.0.0.1']) => {
|
|
|
15
14
|
// In a real microservices environment, we would check against a service registry
|
|
16
15
|
// For now, we allow localhost and any domain in the allowed list
|
|
17
16
|
const isAllowed = allowedDomains.some((domain) => hostname === domain || hostname.endsWith(`.${domain}`));
|
|
18
|
-
if (!isAllowed
|
|
17
|
+
if (!isAllowed) {
|
|
19
18
|
throw ErrorFactory.createValidationError(`URL hostname '${hostname}' is not allowed (SSRF Protection)`, { hostname });
|
|
20
19
|
}
|
|
21
20
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XSS Sanitizer
|
|
3
|
+
* Recursive, zero-dependency input sanitization utility.
|
|
4
|
+
*
|
|
5
|
+
* This is intentionally conservative:
|
|
6
|
+
* - Strings: strip tags, then escape HTML entities.
|
|
7
|
+
* - Arrays/Objects: sanitize recursively.
|
|
8
|
+
*/
|
|
9
|
+
export interface IXss {
|
|
10
|
+
sanitize(input: unknown): unknown;
|
|
11
|
+
}
|
|
12
|
+
export declare const Xss: IXss;
|
|
13
|
+
export default Xss;
|
|
14
|
+
//# sourceMappingURL=Xss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Xss.d.ts","sourceRoot":"","sources":["../../../src/security/Xss.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwDH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC;CACnC;AAED,eAAO,MAAM,GAAG,EAAE,IAIhB,CAAC;AAEH,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XSS Sanitizer
|
|
3
|
+
* Recursive, zero-dependency input sanitization utility.
|
|
4
|
+
*
|
|
5
|
+
* This is intentionally conservative:
|
|
6
|
+
* - Strings: strip tags, then escape HTML entities.
|
|
7
|
+
* - Arrays/Objects: sanitize recursively.
|
|
8
|
+
*/
|
|
9
|
+
import { XssProtection } from './XssProtection';
|
|
10
|
+
const stripTags = (value) => {
|
|
11
|
+
// Remove all HTML tags in linear time (no regex backtracking / ReDoS risk).
|
|
12
|
+
let out = '';
|
|
13
|
+
let inTag = false;
|
|
14
|
+
for (const element of value) {
|
|
15
|
+
const ch = element;
|
|
16
|
+
if (ch === '<') {
|
|
17
|
+
inTag = true;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (inTag) {
|
|
21
|
+
if (ch === '>')
|
|
22
|
+
inTag = false;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
out += ch;
|
|
26
|
+
}
|
|
27
|
+
return out;
|
|
28
|
+
};
|
|
29
|
+
const sanitizeRecursive = (input, seen) => {
|
|
30
|
+
if (typeof input === 'string') {
|
|
31
|
+
return XssProtection.escape(stripTags(input));
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(input)) {
|
|
34
|
+
if (seen.has(input))
|
|
35
|
+
return input;
|
|
36
|
+
seen.add(input);
|
|
37
|
+
return input.map((item) => sanitizeRecursive(item, seen));
|
|
38
|
+
}
|
|
39
|
+
if (typeof input === 'object' && input !== null) {
|
|
40
|
+
const obj = input;
|
|
41
|
+
if (seen.has(obj))
|
|
42
|
+
return input;
|
|
43
|
+
seen.add(obj);
|
|
44
|
+
const out = {};
|
|
45
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
46
|
+
out[key] = sanitizeRecursive(value, seen);
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
return input;
|
|
51
|
+
};
|
|
52
|
+
export const Xss = Object.freeze({
|
|
53
|
+
sanitize(input) {
|
|
54
|
+
return sanitizeRecursive(input, new WeakSet());
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
export default Xss;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XssProtection.d.ts","sourceRoot":"","sources":["../../../src/security/XssProtection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"XssProtection.d.ts","sourceRoot":"","sources":["../../../src/security/XssProtection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAoSH;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,KAAK,OAAO,KAAG,MAGzC,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC;CAClC;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,cAO1B,CAAC"}
|