@zintrust/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/z.d.ts +7 -0
- package/bin/z.d.ts.map +1 -0
- package/bin/z.js +6 -0
- package/bin/zin.d.ts +7 -0
- package/bin/zin.d.ts.map +1 -0
- package/bin/zin.js +6 -0
- package/bin/zintrust-microservices.d.ts +7 -0
- package/bin/zintrust-microservices.d.ts.map +1 -0
- package/bin/zintrust-microservices.js +165 -0
- package/bin/zintrust.d.ts +9 -0
- package/bin/zintrust.d.ts.map +1 -0
- package/bin/zintrust.js +51 -0
- package/bin/zt.d.ts +7 -0
- package/bin/zt.d.ts.map +1 -0
- package/bin/zt.js +6 -0
- package/package.json +80 -0
- package/src/boot/Application.d.ts +31 -0
- package/src/boot/Application.d.ts.map +1 -0
- package/src/boot/Application.js +159 -0
- package/src/boot/Server.d.ts +23 -0
- package/src/boot/Server.d.ts.map +1 -0
- package/src/boot/Server.js +236 -0
- package/src/boot/bootstrap.d.ts +7 -0
- package/src/boot/bootstrap.d.ts.map +1 -0
- package/src/boot/bootstrap.js +64 -0
- package/src/builder/BundleOptimizer.d.ts +42 -0
- package/src/builder/BundleOptimizer.d.ts.map +1 -0
- package/src/builder/BundleOptimizer.js +356 -0
- package/src/cache/Cache.d.ts +26 -0
- package/src/cache/Cache.d.ts.map +1 -0
- package/src/cache/Cache.js +89 -0
- package/src/cache/CacheDriver.d.ts +28 -0
- package/src/cache/CacheDriver.d.ts.map +1 -0
- package/src/cache/CacheDriver.js +6 -0
- package/src/cache/drivers/KVDriver.d.ts +12 -0
- package/src/cache/drivers/KVDriver.d.ts.map +1 -0
- package/src/cache/drivers/KVDriver.js +54 -0
- package/src/cache/drivers/MemoryDriver.d.ts +12 -0
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -0
- package/src/cache/drivers/MemoryDriver.js +50 -0
- package/src/cache/drivers/MongoDriver.d.ts +17 -0
- package/src/cache/drivers/MongoDriver.d.ts.map +1 -0
- package/src/cache/drivers/MongoDriver.js +80 -0
- package/src/cache/drivers/RedisDriver.d.ts +12 -0
- package/src/cache/drivers/RedisDriver.d.ts.map +1 -0
- package/src/cache/drivers/RedisDriver.js +79 -0
- package/src/cli/BaseCommand.d.ts +39 -0
- package/src/cli/BaseCommand.d.ts.map +1 -0
- package/src/cli/BaseCommand.js +58 -0
- package/src/cli/CLI.d.ts +21 -0
- package/src/cli/CLI.d.ts.map +1 -0
- package/src/cli/CLI.js +203 -0
- package/src/cli/ErrorHandler.d.ts +23 -0
- package/src/cli/ErrorHandler.d.ts.map +1 -0
- package/src/cli/ErrorHandler.js +95 -0
- package/src/cli/PromptHelper.d.ts +47 -0
- package/src/cli/PromptHelper.d.ts.map +1 -0
- package/src/cli/PromptHelper.js +155 -0
- package/src/cli/commands/AddCommand.d.ts +15 -0
- package/src/cli/commands/AddCommand.d.ts.map +1 -0
- package/src/cli/commands/AddCommand.js +817 -0
- package/src/cli/commands/ConfigCommand.d.ts +15 -0
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/src/cli/commands/ConfigCommand.js +273 -0
- package/src/cli/commands/D1MigrateCommand.d.ts +15 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -0
- package/src/cli/commands/D1MigrateCommand.js +73 -0
- package/src/cli/commands/DebugCommand.d.ts +15 -0
- package/src/cli/commands/DebugCommand.d.ts.map +1 -0
- package/src/cli/commands/DebugCommand.js +52 -0
- package/src/cli/commands/FixCommand.d.ts +15 -0
- package/src/cli/commands/FixCommand.d.ts.map +1 -0
- package/src/cli/commands/FixCommand.js +80 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts +9 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -0
- package/src/cli/commands/KeyGenerateCommand.js +76 -0
- package/src/cli/commands/LogsCommand.d.ts +19 -0
- package/src/cli/commands/LogsCommand.d.ts.map +1 -0
- package/src/cli/commands/LogsCommand.js +185 -0
- package/src/cli/commands/MigrateCommand.d.ts +15 -0
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -0
- package/src/cli/commands/MigrateCommand.js +56 -0
- package/src/cli/commands/NewCommand.d.ts +32 -0
- package/src/cli/commands/NewCommand.d.ts.map +1 -0
- package/src/cli/commands/NewCommand.js +280 -0
- package/src/cli/commands/PluginCommand.d.ts +9 -0
- package/src/cli/commands/PluginCommand.d.ts.map +1 -0
- package/src/cli/commands/PluginCommand.js +94 -0
- package/src/cli/commands/PrepareCommand.d.ts +8 -0
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -0
- package/src/cli/commands/PrepareCommand.js +51 -0
- package/src/cli/commands/QACommand.d.ts +33 -0
- package/src/cli/commands/QACommand.d.ts.map +1 -0
- package/src/cli/commands/QACommand.js +490 -0
- package/src/cli/commands/SimulateCommand.d.ts +12 -0
- package/src/cli/commands/SimulateCommand.d.ts.map +1 -0
- package/src/cli/commands/SimulateCommand.js +79 -0
- package/src/cli/commands/StartCommand.d.ts +5 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -0
- package/src/cli/commands/StartCommand.js +227 -0
- package/src/cli/commands/index.d.ts +11 -0
- package/src/cli/commands/index.d.ts.map +1 -0
- package/src/cli/commands/index.js +10 -0
- package/src/cli/config/ConfigManager.d.ts +42 -0
- package/src/cli/config/ConfigManager.d.ts.map +1 -0
- package/src/cli/config/ConfigManager.js +175 -0
- package/src/cli/config/ConfigSchema.d.ts +195 -0
- package/src/cli/config/ConfigSchema.d.ts.map +1 -0
- package/src/cli/config/ConfigSchema.js +171 -0
- package/src/cli/config/ConfigValidator.d.ts +41 -0
- package/src/cli/config/ConfigValidator.d.ts.map +1 -0
- package/src/cli/config/ConfigValidator.js +200 -0
- package/src/cli/config/index.d.ts +8 -0
- package/src/cli/config/index.d.ts.map +1 -0
- package/src/cli/config/index.js +7 -0
- package/src/cli/debug/Dashboard.d.ts +34 -0
- package/src/cli/debug/Dashboard.d.ts.map +1 -0
- package/src/cli/debug/Dashboard.js +152 -0
- package/src/cli/index.d.ts +14 -0
- package/src/cli/index.d.ts.map +1 -0
- package/src/cli/index.js +14 -0
- package/src/cli/logger/Logger.d.ts +43 -0
- package/src/cli/logger/Logger.d.ts.map +1 -0
- package/src/cli/logger/Logger.js +137 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts +44 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ControllerGenerator.js +540 -0
- package/src/cli/scaffolding/FactoryGenerator.d.ts +47 -0
- package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/FactoryGenerator.js +356 -0
- package/src/cli/scaffolding/FeatureScaffolder.d.ts +40 -0
- package/src/cli/scaffolding/FeatureScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/FeatureScaffolder.js +747 -0
- package/src/cli/scaffolding/FileGenerator.d.ts +31 -0
- package/src/cli/scaffolding/FileGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/FileGenerator.js +222 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts +35 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/MigrationGenerator.js +257 -0
- package/src/cli/scaffolding/ModelGenerator.d.ts +81 -0
- package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ModelGenerator.js +249 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts +66 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/ProjectScaffolder.js +439 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.d.ts +50 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.js +465 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts +43 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.js +321 -0
- package/src/cli/scaffolding/RouteGenerator.d.ts +66 -0
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/RouteGenerator.js +306 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts +47 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/SeederGenerator.js +286 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts +40 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +267 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts +45 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.js +397 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts +45 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceScaffolder.js +367 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts +35 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts.map +1 -0
- package/src/cli/scaffolding/TemplateEngine.js +379 -0
- package/src/cli/scaffolding/WorkflowGenerator.d.ts +31 -0
- package/src/cli/scaffolding/WorkflowGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/WorkflowGenerator.js +193 -0
- package/src/cli/scaffolding/index.d.ts +34 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -0
- package/src/cli/scaffolding/index.js +18 -0
- package/src/cli/utils/DistPackager.d.ts +8 -0
- package/src/cli/utils/DistPackager.d.ts.map +1 -0
- package/src/cli/utils/DistPackager.js +94 -0
- package/src/cli/utils/EnvFileLoader.d.ts +21 -0
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -0
- package/src/cli/utils/EnvFileLoader.js +166 -0
- package/src/cli/utils/spawn.d.ts +11 -0
- package/src/cli/utils/spawn.d.ts.map +1 -0
- package/src/cli/utils/spawn.js +81 -0
- package/src/common/index.d.ts +87 -0
- package/src/common/index.d.ts.map +1 -0
- package/src/common/index.js +207 -0
- package/src/config/SecretsManager.d.ts +122 -0
- package/src/config/SecretsManager.d.ts.map +1 -0
- package/src/config/SecretsManager.js +328 -0
- package/src/config/app.d.ts +56 -0
- package/src/config/app.d.ts.map +1 -0
- package/src/config/app.js +77 -0
- package/src/config/cache.d.ts +76 -0
- package/src/config/cache.d.ts.map +1 -0
- package/src/config/cache.js +62 -0
- package/src/config/constants.d.ts +108 -0
- package/src/config/constants.d.ts.map +1 -0
- package/src/config/constants.js +64 -0
- package/src/config/database.d.ts +122 -0
- package/src/config/database.d.ts.map +1 -0
- package/src/config/database.js +89 -0
- package/src/config/env.d.ts +56 -0
- package/src/config/env.d.ts.map +1 -0
- package/src/config/env.js +133 -0
- package/src/config/features.d.ts +27 -0
- package/src/config/features.d.ts.map +1 -0
- package/src/config/features.js +49 -0
- package/src/config/index.d.ts +554 -0
- package/src/config/index.d.ts.map +1 -0
- package/src/config/index.js +31 -0
- package/src/config/logger.d.ts +17 -0
- package/src/config/logger.d.ts.map +1 -0
- package/src/config/logger.js +77 -0
- package/src/config/microservices.d.ts +88 -0
- package/src/config/microservices.d.ts.map +1 -0
- package/src/config/microservices.js +90 -0
- package/src/config/queue.d.ts +107 -0
- package/src/config/queue.d.ts.map +1 -0
- package/src/config/queue.js +74 -0
- package/src/config/security.d.ts +108 -0
- package/src/config/security.d.ts.map +1 -0
- package/src/config/security.js +134 -0
- package/src/config/storage.d.ts +105 -0
- package/src/config/storage.d.ts.map +1 -0
- package/src/config/storage.js +79 -0
- package/src/container/ServiceContainer.d.ts +25 -0
- package/src/container/ServiceContainer.d.ts.map +1 -0
- package/src/container/ServiceContainer.js +75 -0
- package/src/database/migrations/index.d.ts +2 -0
- package/src/database/migrations/index.d.ts.map +1 -0
- package/src/database/migrations/index.js +1 -0
- package/src/exceptions/ZintrustError.d.ts +88 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -0
- package/src/exceptions/ZintrustError.js +110 -0
- package/src/features/Auth.d.ts +20 -0
- package/src/features/Auth.d.ts.map +1 -0
- package/src/features/Auth.js +32 -0
- package/src/features/Queue.d.ts +21 -0
- package/src/features/Queue.d.ts.map +1 -0
- package/src/features/Queue.js +59 -0
- package/src/functions/cloudflare.d.ts +5 -0
- package/src/functions/cloudflare.d.ts.map +1 -0
- package/src/functions/cloudflare.js +34 -0
- package/src/functions/deno.d.ts +3 -0
- package/src/functions/deno.d.ts.map +1 -0
- package/src/functions/deno.js +31 -0
- package/src/functions/lambda.d.ts +2 -0
- package/src/functions/lambda.d.ts.map +1 -0
- package/src/functions/lambda.js +32 -0
- package/src/http/Controller.d.ts +20 -0
- package/src/http/Controller.d.ts.map +1 -0
- package/src/http/Controller.js +46 -0
- package/src/http/Kernel.d.ts +24 -0
- package/src/http/Kernel.d.ts.map +1 -0
- package/src/http/Kernel.js +72 -0
- package/src/http/Request.d.ts +36 -0
- package/src/http/Request.d.ts.map +1 -0
- package/src/http/Request.js +142 -0
- package/src/http/Response.d.ts +32 -0
- package/src/http/Response.d.ts.map +1 -0
- package/src/http/Response.js +70 -0
- package/src/index.d.ts +43 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +37 -0
- package/src/microservices/MicroserviceBootstrap.d.ts +75 -0
- package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -0
- package/src/microservices/MicroserviceBootstrap.js +285 -0
- package/src/microservices/MicroserviceGenerator.d.ts +27 -0
- package/src/microservices/MicroserviceGenerator.d.ts.map +1 -0
- package/src/microservices/MicroserviceGenerator.js +436 -0
- package/src/microservices/MicroserviceManager.d.ts +68 -0
- package/src/microservices/MicroserviceManager.d.ts.map +1 -0
- package/src/microservices/MicroserviceManager.js +266 -0
- package/src/microservices/PostgresAdapter.d.ts +90 -0
- package/src/microservices/PostgresAdapter.d.ts.map +1 -0
- package/src/microservices/PostgresAdapter.js +286 -0
- package/src/microservices/RequestTracingMiddleware.d.ts +41 -0
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -0
- package/src/microservices/RequestTracingMiddleware.js +122 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts +58 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -0
- package/src/microservices/ServiceAuthMiddleware.js +240 -0
- package/src/microservices/ServiceBundler.d.ts +45 -0
- package/src/microservices/ServiceBundler.d.ts.map +1 -0
- package/src/microservices/ServiceBundler.js +297 -0
- package/src/microservices/ServiceHealthMonitor.d.ts +96 -0
- package/src/microservices/ServiceHealthMonitor.d.ts.map +1 -0
- package/src/microservices/ServiceHealthMonitor.js +379 -0
- package/src/middleware/CsrfMiddleware.d.ts +19 -0
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -0
- package/src/middleware/CsrfMiddleware.js +121 -0
- package/src/middleware/MiddlewareStack.d.ts +27 -0
- package/src/middleware/MiddlewareStack.d.ts.map +1 -0
- package/src/middleware/MiddlewareStack.js +43 -0
- package/src/middleware/RateLimiter.d.ts +22 -0
- package/src/middleware/RateLimiter.d.ts.map +1 -0
- package/src/middleware/RateLimiter.js +72 -0
- package/src/middleware/SecurityMiddleware.d.ts +33 -0
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -0
- package/src/middleware/SecurityMiddleware.js +106 -0
- package/src/middleware/index.d.ts +9 -0
- package/src/middleware/index.d.ts.map +1 -0
- package/src/middleware/index.js +8 -0
- package/src/node-singletons/child-process.d.ts +7 -0
- package/src/node-singletons/child-process.d.ts.map +1 -0
- package/src/node-singletons/child-process.js +6 -0
- package/src/node-singletons/crypto.d.ts +7 -0
- package/src/node-singletons/crypto.d.ts.map +1 -0
- package/src/node-singletons/crypto.js +6 -0
- package/src/node-singletons/events.d.ts +7 -0
- package/src/node-singletons/events.d.ts.map +1 -0
- package/src/node-singletons/events.js +6 -0
- package/src/node-singletons/fs.d.ts +12 -0
- package/src/node-singletons/fs.d.ts.map +1 -0
- package/src/node-singletons/fs.js +14 -0
- package/src/node-singletons/http.d.ts +8 -0
- package/src/node-singletons/http.d.ts.map +1 -0
- package/src/node-singletons/http.js +6 -0
- package/src/node-singletons/index.d.ts +30 -0
- package/src/node-singletons/index.d.ts.map +1 -0
- package/src/node-singletons/index.js +31 -0
- package/src/node-singletons/os.d.ts +9 -0
- package/src/node-singletons/os.d.ts.map +1 -0
- package/src/node-singletons/os.js +9 -0
- package/src/node-singletons/path.d.ts +7 -0
- package/src/node-singletons/path.d.ts.map +1 -0
- package/src/node-singletons/path.js +6 -0
- package/src/node-singletons/perf-hooks.d.ts +7 -0
- package/src/node-singletons/perf-hooks.d.ts.map +1 -0
- package/src/node-singletons/perf-hooks.js +6 -0
- package/src/node-singletons/readline.d.ts +10 -0
- package/src/node-singletons/readline.d.ts.map +1 -0
- package/src/node-singletons/readline.js +9 -0
- package/src/node-singletons/url.d.ts +7 -0
- package/src/node-singletons/url.d.ts.map +1 -0
- package/src/node-singletons/url.js +6 -0
- package/src/orm/ConnectionManager.d.ts +118 -0
- package/src/orm/ConnectionManager.d.ts.map +1 -0
- package/src/orm/ConnectionManager.js +401 -0
- package/src/orm/Database.d.ts +31 -0
- package/src/orm/Database.d.ts.map +1 -0
- package/src/orm/Database.js +163 -0
- package/src/orm/DatabaseAdapter.d.ts +96 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -0
- package/src/orm/DatabaseAdapter.js +40 -0
- package/src/orm/Model.d.ts +91 -0
- package/src/orm/Model.d.ts.map +1 -0
- package/src/orm/Model.js +206 -0
- package/src/orm/QueryBuilder.d.ts +52 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -0
- package/src/orm/QueryBuilder.js +134 -0
- package/src/orm/Relationships.d.ts +53 -0
- package/src/orm/Relationships.d.ts.map +1 -0
- package/src/orm/Relationships.js +98 -0
- package/src/orm/Schema.d.ts +123 -0
- package/src/orm/Schema.d.ts.map +1 -0
- package/src/orm/Schema.js +169 -0
- package/src/orm/adapters/D1Adapter.d.ts +15 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -0
- package/src/orm/adapters/D1Adapter.js +125 -0
- package/src/orm/adapters/MySQLAdapter.d.ts +16 -0
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MySQLAdapter.js +87 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts +16 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -0
- package/src/orm/adapters/PostgreSQLAdapter.js +87 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts +16 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SQLServerAdapter.js +81 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts +11 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SQLiteAdapter.js +131 -0
- package/src/performance/Benchmark.d.ts +87 -0
- package/src/performance/Benchmark.d.ts.map +1 -0
- package/src/performance/Benchmark.js +304 -0
- package/src/performance/CodeGenerationBenchmark.d.ts +23 -0
- package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -0
- package/src/performance/CodeGenerationBenchmark.js +249 -0
- package/src/performance/Optimizer.d.ts +99 -0
- package/src/performance/Optimizer.d.ts.map +1 -0
- package/src/performance/Optimizer.js +396 -0
- package/src/performance/establish-baseline.d.ts +9 -0
- package/src/performance/establish-baseline.d.ts.map +1 -0
- package/src/performance/establish-baseline.js +55 -0
- package/src/profiling/MemoryProfiler.d.ts +32 -0
- package/src/profiling/MemoryProfiler.d.ts.map +1 -0
- package/src/profiling/MemoryProfiler.js +84 -0
- package/src/profiling/N1Detector.d.ts +16 -0
- package/src/profiling/N1Detector.d.ts.map +1 -0
- package/src/profiling/N1Detector.js +120 -0
- package/src/profiling/QueryLogger.d.ts +107 -0
- package/src/profiling/QueryLogger.d.ts.map +1 -0
- package/src/profiling/QueryLogger.js +148 -0
- package/src/profiling/RequestProfiler.d.ts +30 -0
- package/src/profiling/RequestProfiler.d.ts.map +1 -0
- package/src/profiling/RequestProfiler.js +94 -0
- package/src/profiling/types.d.ts +77 -0
- package/src/profiling/types.d.ts.map +1 -0
- package/src/profiling/types.js +5 -0
- package/src/routing/Router.d.ts +52 -0
- package/src/routing/Router.d.ts.map +1 -0
- package/src/routing/Router.js +191 -0
- package/src/runtime/PluginManager.d.ts +30 -0
- package/src/runtime/PluginManager.d.ts.map +1 -0
- package/src/runtime/PluginManager.js +197 -0
- package/src/runtime/PluginRegistry.d.ts +22 -0
- package/src/runtime/PluginRegistry.d.ts.map +1 -0
- package/src/runtime/PluginRegistry.js +93 -0
- package/src/runtime/RuntimeAdapter.d.ts +126 -0
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -0
- package/src/runtime/RuntimeAdapter.js +127 -0
- package/src/runtime/RuntimeDetector.d.ts +15 -0
- package/src/runtime/RuntimeDetector.d.ts.map +1 -0
- package/src/runtime/RuntimeDetector.js +219 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts +43 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/CloudflareAdapter.js +175 -0
- package/src/runtime/adapters/DenoAdapter.d.ts +30 -0
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/DenoAdapter.js +191 -0
- package/src/runtime/adapters/FargateAdapter.d.ts +40 -0
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/FargateAdapter.js +156 -0
- package/src/runtime/adapters/LambdaAdapter.d.ts +13 -0
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/LambdaAdapter.js +302 -0
- package/src/runtime/adapters/NodeServerAdapter.d.ts +16 -0
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/NodeServerAdapter.js +199 -0
- package/src/scripts/TemplateSync.d.ts +7 -0
- package/src/scripts/TemplateSync.d.ts.map +1 -0
- package/src/scripts/TemplateSync.js +234 -0
- package/src/security/CsrfTokenManager.d.ts +28 -0
- package/src/security/CsrfTokenManager.d.ts.map +1 -0
- package/src/security/CsrfTokenManager.js +78 -0
- package/src/security/Encryptor.d.ts +15 -0
- package/src/security/Encryptor.d.ts.map +1 -0
- package/src/security/Encryptor.js +142 -0
- package/src/security/JwtManager.d.ts +41 -0
- package/src/security/JwtManager.d.ts.map +1 -0
- package/src/security/JwtManager.js +229 -0
- package/src/security/UrlValidator.d.ts +21 -0
- package/src/security/UrlValidator.d.ts.map +1 -0
- package/src/security/UrlValidator.js +42 -0
- package/src/security/XssProtection.d.ts +24 -0
- package/src/security/XssProtection.d.ts.map +1 -0
- package/src/security/XssProtection.js +133 -0
- package/src/templates/TemplateRegistry.d.ts +40 -0
- package/src/templates/TemplateRegistry.d.ts.map +1 -0
- package/src/templates/TemplateRegistry.js +78 -0
- package/src/templates/TemplateRegistry.ts +91 -0
- package/src/templates/adapters/MySQLAdapter.ts.tpl +97 -0
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +101 -0
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +95 -0
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +189 -0
- package/src/templates/features/Auth.ts.tpl +40 -0
- package/src/templates/features/Queue.ts.tpl +75 -0
- package/src/templates/project/basic/.env.example.tpl +26 -0
- package/src/templates/project/basic/.env.tpl +164 -0
- package/src/templates/project/basic/README.md.tpl +13 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +155 -0
- package/src/templates/project/basic/app/Middleware/ProfilerMiddleware.ts.tpl +55 -0
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +304 -0
- package/src/templates/project/basic/app/Models/Post.ts.tpl +30 -0
- package/src/templates/project/basic/app/Models/User.ts.tpl +53 -0
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +453 -0
- package/src/templates/project/basic/config/app.ts.tpl +97 -0
- package/src/templates/project/basic/config/cache.ts.tpl +117 -0
- package/src/templates/project/basic/config/constants.ts.tpl +70 -0
- package/src/templates/project/basic/config/database.ts.tpl +152 -0
- package/src/templates/project/basic/config/env.ts.tpl +148 -0
- package/src/templates/project/basic/config/features.ts.tpl +57 -0
- package/src/templates/project/basic/config/index.ts.tpl +36 -0
- package/src/templates/project/basic/config/logger.ts.tpl +95 -0
- package/src/templates/project/basic/config/microservices.ts.tpl +104 -0
- package/src/templates/project/basic/config/queue.ts.tpl +134 -0
- package/src/templates/project/basic/config/security.ts.tpl +149 -0
- package/src/templates/project/basic/config/storage.ts.tpl +136 -0
- package/src/templates/project/basic/database/factories/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/database/migrations/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/database/migrations/index.ts.tpl +2 -0
- package/src/templates/project/basic/database/seeders/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/package.json.tpl +22 -0
- package/src/templates/project/basic/routes/api.ts.tpl +135 -0
- package/src/templates/project/basic/src/index.ts.tpl +49 -0
- package/src/templates/project/basic/template.json +17 -0
- package/src/templates/project/basic/tsconfig.json.tpl +20 -0
- package/src/validation/ValidationError.d.ts +42 -0
- package/src/validation/ValidationError.d.ts.map +1 -0
- package/src/validation/ValidationError.js +53 -0
- package/src/validation/Validator.d.ts +60 -0
- package/src/validation/Validator.d.ts.map +1 -0
- package/src/validation/Validator.js +190 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JWT Manager
|
|
3
|
+
* JSON Web Token generation, verification, and claims management
|
|
4
|
+
* Uses native Node.js crypto module (zero external dependencies)
|
|
5
|
+
*/
|
|
6
|
+
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
7
|
+
import { createHmac, createSign, createVerify, randomBytes } from '../node-singletons/crypto';
|
|
8
|
+
/**
|
|
9
|
+
* Create a new JWT manager instance
|
|
10
|
+
*/
|
|
11
|
+
const create = () => {
|
|
12
|
+
const state = {
|
|
13
|
+
hmacSecret: null,
|
|
14
|
+
rsaPrivateKey: null,
|
|
15
|
+
rsaPublicKey: null,
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
setHmacSecret(secret) {
|
|
19
|
+
state.hmacSecret = secret;
|
|
20
|
+
},
|
|
21
|
+
setRsaKeys(privateKey, publicKey) {
|
|
22
|
+
state.rsaPrivateKey = privateKey;
|
|
23
|
+
state.rsaPublicKey = publicKey;
|
|
24
|
+
},
|
|
25
|
+
sign(payload, options = {}) {
|
|
26
|
+
return signToken(state, payload, options);
|
|
27
|
+
},
|
|
28
|
+
verify(token, algorithm = 'HS256') {
|
|
29
|
+
return verifyToken(state, token, algorithm);
|
|
30
|
+
},
|
|
31
|
+
decode(token) {
|
|
32
|
+
return decodeToken(token);
|
|
33
|
+
},
|
|
34
|
+
signRsa(message) {
|
|
35
|
+
return signRsa(message, state.rsaPrivateKey);
|
|
36
|
+
},
|
|
37
|
+
generateJwtId() {
|
|
38
|
+
return randomBytes(16).toString('hex');
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* JwtManager namespace - sealed for immutability
|
|
44
|
+
*/
|
|
45
|
+
export const JwtManager = Object.freeze({
|
|
46
|
+
create,
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Sign JWT token
|
|
50
|
+
*/
|
|
51
|
+
function signToken(state, payload, options) {
|
|
52
|
+
const algorithm = options.algorithm ?? 'HS256';
|
|
53
|
+
const now = Math.floor(Date.now() / 1000);
|
|
54
|
+
const claims = buildClaims(payload, options, now);
|
|
55
|
+
const header = { alg: algorithm, typ: 'JWT' };
|
|
56
|
+
const encodedHeader = base64Encode(JSON.stringify(header));
|
|
57
|
+
const encodedPayload = base64Encode(JSON.stringify(claims));
|
|
58
|
+
const message = `${encodedHeader}.${encodedPayload}`;
|
|
59
|
+
const signature = generateSignature(message, algorithm, state.hmacSecret, state.rsaPrivateKey);
|
|
60
|
+
return `${message}.${signature}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Verify JWT token
|
|
64
|
+
*/
|
|
65
|
+
function verifyToken(state, token, algorithm) {
|
|
66
|
+
const parts = token.split('.');
|
|
67
|
+
if (parts.length !== 3) {
|
|
68
|
+
throw ErrorFactory.createSecurityError('Invalid token format');
|
|
69
|
+
}
|
|
70
|
+
const [encodedHeader, encodedPayload, encodedSignature] = parts;
|
|
71
|
+
try {
|
|
72
|
+
const header = JSON.parse(base64Decode(encodedHeader));
|
|
73
|
+
if (header['alg'] !== algorithm) {
|
|
74
|
+
throw ErrorFactory.createSecurityError(`Algorithm mismatch: expected ${algorithm}, got ${header['alg']}`);
|
|
75
|
+
}
|
|
76
|
+
const message = `${encodedHeader}.${encodedPayload}`;
|
|
77
|
+
const isValid = verifySignature(message, encodedSignature, algorithm, state.hmacSecret, state.rsaPublicKey);
|
|
78
|
+
if (!isValid) {
|
|
79
|
+
throw ErrorFactory.createSecurityError('Invalid signature');
|
|
80
|
+
}
|
|
81
|
+
const payload = JSON.parse(base64Decode(encodedPayload));
|
|
82
|
+
verifyClaims(payload);
|
|
83
|
+
return payload;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw ErrorFactory.createSecurityError(`Token verification failed: ${error.message}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Decode JWT token without verification
|
|
91
|
+
*/
|
|
92
|
+
function decodeToken(token) {
|
|
93
|
+
const parts = token.split('.');
|
|
94
|
+
if (parts.length !== 3) {
|
|
95
|
+
throw ErrorFactory.createSecurityError('Invalid token format');
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
const payload = JSON.parse(base64Decode(parts[1]));
|
|
99
|
+
return payload;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
throw ErrorFactory.createSecurityError(`Invalid token payload: ${error.message}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Base64 URL encoding
|
|
107
|
+
*/
|
|
108
|
+
function base64Encode(data) {
|
|
109
|
+
const buffer = typeof data === 'string' ? Buffer.from(data, 'utf8') : data;
|
|
110
|
+
return buffer.toString('base64').replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '');
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Base64 URL decoding to Buffer
|
|
114
|
+
*/
|
|
115
|
+
function base64DecodeBuffer(data) {
|
|
116
|
+
const padded = data + '==='.slice((data.length + 3) % 4);
|
|
117
|
+
const base64 = padded.replaceAll('-', '+').replaceAll('_', '/');
|
|
118
|
+
return Buffer.from(base64, 'base64');
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Base64 URL decoding to string
|
|
122
|
+
*/
|
|
123
|
+
function base64Decode(data) {
|
|
124
|
+
return base64DecodeBuffer(data).toString('utf8');
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Timing safe string comparison
|
|
128
|
+
*/
|
|
129
|
+
function timingSafeEquals(a, b) {
|
|
130
|
+
if (a.length !== b.length) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
let result = 0;
|
|
134
|
+
for (let i = 0; i < a.length; i++) {
|
|
135
|
+
result |= (a.codePointAt(i) ?? 0) ^ (b.codePointAt(i) ?? 0);
|
|
136
|
+
}
|
|
137
|
+
return result === 0;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Sign message using HMAC
|
|
141
|
+
*/
|
|
142
|
+
function signHmac(message, algorithm, secret) {
|
|
143
|
+
if (secret === null) {
|
|
144
|
+
throw ErrorFactory.createSecurityError('HMAC secret not configured');
|
|
145
|
+
}
|
|
146
|
+
const digestAlgorithm = algorithm === 'HS256' ? 'sha256' : 'sha512';
|
|
147
|
+
const signature = createHmac(digestAlgorithm, secret).update(message).digest();
|
|
148
|
+
return base64Encode(signature);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Sign message using RSA
|
|
152
|
+
*/
|
|
153
|
+
function signRsa(message, privateKey) {
|
|
154
|
+
if (privateKey === null) {
|
|
155
|
+
throw ErrorFactory.createSecurityError('RSA private key not configured');
|
|
156
|
+
}
|
|
157
|
+
const sign = createSign('RSA-SHA256');
|
|
158
|
+
sign.update(message);
|
|
159
|
+
const signature = sign.sign(privateKey);
|
|
160
|
+
return base64Encode(signature);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Generate signature based on algorithm
|
|
164
|
+
*/
|
|
165
|
+
function generateSignature(message, algorithm, hmacSecret, rsaPrivateKey) {
|
|
166
|
+
if (algorithm.startsWith('HS')) {
|
|
167
|
+
return signHmac(message, algorithm, hmacSecret);
|
|
168
|
+
}
|
|
169
|
+
if (algorithm === 'RS256') {
|
|
170
|
+
return signRsa(message, rsaPrivateKey);
|
|
171
|
+
}
|
|
172
|
+
throw ErrorFactory.createSecurityError(`Unsupported algorithm: ${algorithm}`);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Verify signature based on algorithm
|
|
176
|
+
*/
|
|
177
|
+
function verifySignature(message, encodedSignature, algorithm, hmacSecret, rsaPublicKey) {
|
|
178
|
+
if (algorithm.startsWith('HS')) {
|
|
179
|
+
const expectedSignature = signHmac(message, algorithm, hmacSecret);
|
|
180
|
+
return timingSafeEquals(encodedSignature, expectedSignature);
|
|
181
|
+
}
|
|
182
|
+
else if (algorithm === 'RS256') {
|
|
183
|
+
if (rsaPublicKey === null) {
|
|
184
|
+
throw ErrorFactory.createSecurityError('RSA public key not configured');
|
|
185
|
+
}
|
|
186
|
+
const verify = createVerify('RSA-SHA256'); // NOSONAR LCHECK
|
|
187
|
+
verify.update(message);
|
|
188
|
+
const signature = base64DecodeBuffer(encodedSignature);
|
|
189
|
+
return verify.verify(rsaPublicKey, signature);
|
|
190
|
+
}
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Build JWT claims
|
|
195
|
+
*/
|
|
196
|
+
function buildClaims(payload, options, now) {
|
|
197
|
+
const claims = {
|
|
198
|
+
...payload,
|
|
199
|
+
iat: now,
|
|
200
|
+
};
|
|
201
|
+
if (options.expiresIn !== undefined && options.expiresIn !== null) {
|
|
202
|
+
claims.exp = now + options.expiresIn;
|
|
203
|
+
}
|
|
204
|
+
if (options.issuer !== undefined && options.issuer !== null) {
|
|
205
|
+
claims.iss = options.issuer;
|
|
206
|
+
}
|
|
207
|
+
if (options.audience !== undefined && options.audience !== null) {
|
|
208
|
+
claims.aud = options.audience;
|
|
209
|
+
}
|
|
210
|
+
if (options.subject !== undefined && options.subject !== null) {
|
|
211
|
+
claims.sub = options.subject;
|
|
212
|
+
}
|
|
213
|
+
if (options.jwtId !== undefined && options.jwtId !== null) {
|
|
214
|
+
claims.jti = options.jwtId;
|
|
215
|
+
}
|
|
216
|
+
return claims;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Verify JWT claims (expiration, not before)
|
|
220
|
+
*/
|
|
221
|
+
function verifyClaims(payload) {
|
|
222
|
+
const now = Math.floor(Date.now() / 1000);
|
|
223
|
+
if (payload.exp !== undefined && payload.exp !== null && payload.exp <= now) {
|
|
224
|
+
throw ErrorFactory.createSecurityError('Token expired');
|
|
225
|
+
}
|
|
226
|
+
if (payload.nbf !== undefined && payload.nbf !== null && payload.nbf > now) {
|
|
227
|
+
throw ErrorFactory.createSecurityError('Token not yet valid');
|
|
228
|
+
}
|
|
229
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Utilities
|
|
3
|
+
* Mitigates SSRF (SonarQube S5144)
|
|
4
|
+
*/
|
|
5
|
+
export interface IUrlValidator {
|
|
6
|
+
validate(url: string, allowedDomains?: string[]): void;
|
|
7
|
+
validateUrl(url: string, allowedDomains?: string[]): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Validate URL for SSRF protection
|
|
11
|
+
* Ensures URL is either internal or matches allowed domains
|
|
12
|
+
*/
|
|
13
|
+
declare const validate: (url: string, allowedDomains?: string[]) => void;
|
|
14
|
+
declare const validateUrl: (url: string, allowedDomains?: string[]) => void;
|
|
15
|
+
/**
|
|
16
|
+
* UrlValidator handles URL validation for SSRF protection
|
|
17
|
+
* Sealed namespace for immutability
|
|
18
|
+
*/
|
|
19
|
+
export declare const UrlValidator: IUrlValidator;
|
|
20
|
+
export { validate, validateUrl };
|
|
21
|
+
//# sourceMappingURL=UrlValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UrlValidator.d.ts","sourceRoot":"","sources":["../../../src/security/UrlValidator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACvD,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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security Utilities
|
|
3
|
+
* Mitigates SSRF (SonarQube S5144)
|
|
4
|
+
*/
|
|
5
|
+
import { Env } from '../config/env';
|
|
6
|
+
import { ErrorFactory } from '../exceptions/ZintrustError';
|
|
7
|
+
/**
|
|
8
|
+
* Validate URL for SSRF protection
|
|
9
|
+
* Ensures URL is either internal or matches allowed domains
|
|
10
|
+
*/
|
|
11
|
+
const validate = (url, allowedDomains = ['localhost', '127.0.0.1']) => {
|
|
12
|
+
try {
|
|
13
|
+
const parsedUrl = new URL(url);
|
|
14
|
+
const hostname = parsedUrl.hostname;
|
|
15
|
+
// In a real microservices environment, we would check against a service registry
|
|
16
|
+
// For now, we allow localhost and any domain in the allowed list
|
|
17
|
+
const isAllowed = allowedDomains.some((domain) => hostname === domain || hostname.endsWith(`.${domain}`));
|
|
18
|
+
if (!isAllowed && Env.NODE_ENV === 'production') {
|
|
19
|
+
throw ErrorFactory.createValidationError(`URL hostname '${hostname}' is not allowed (SSRF Protection)`, { hostname });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const maybeZinError = error;
|
|
24
|
+
if (maybeZinError.code === 'VALIDATION_ERROR') {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
throw ErrorFactory.createValidationError(`Invalid URL: ${url}`, { cause: error });
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const validateUrl = (url, allowedDomains) => {
|
|
31
|
+
return validate(url, allowedDomains);
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* UrlValidator handles URL validation for SSRF protection
|
|
35
|
+
* Sealed namespace for immutability
|
|
36
|
+
*/
|
|
37
|
+
export const UrlValidator = Object.freeze({
|
|
38
|
+
validate,
|
|
39
|
+
validateUrl,
|
|
40
|
+
});
|
|
41
|
+
// Re-export for backward compatibility
|
|
42
|
+
export { validate, validateUrl };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XSS Protection Utilities
|
|
3
|
+
* HTML escaping and sanitization (pure TypeScript, zero dependencies)
|
|
4
|
+
* Sealed namespace pattern - all exports through XssProtection namespace
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Escape JSON for safe embedding in HTML
|
|
8
|
+
*/
|
|
9
|
+
export declare const escapeJson: (obj: unknown) => string;
|
|
10
|
+
export interface IXssProtection {
|
|
11
|
+
escape(text: string): string;
|
|
12
|
+
sanitize(html: string): string;
|
|
13
|
+
encodeUri(uri: string): string;
|
|
14
|
+
encodeHref(href: string): string;
|
|
15
|
+
isSafeUrl(url: string): boolean;
|
|
16
|
+
escapeJson(obj: unknown): string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* XSS Protection Utilities
|
|
20
|
+
* HTML escaping and sanitization (pure TypeScript, zero dependencies)
|
|
21
|
+
* Sealed namespace with protection methods
|
|
22
|
+
*/
|
|
23
|
+
export declare const XssProtection: IXssProtection;
|
|
24
|
+
//# sourceMappingURL=XssProtection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"XssProtection.d.ts","sourceRoot":"","sources":["../../../src/security/XssProtection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAyIH;;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"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XSS Protection Utilities
|
|
3
|
+
* HTML escaping and sanitization (pure TypeScript, zero dependencies)
|
|
4
|
+
* Sealed namespace pattern - all exports through XssProtection namespace
|
|
5
|
+
*/
|
|
6
|
+
import { Logger } from '../config/logger';
|
|
7
|
+
const HTML_ESCAPE_MAP = {
|
|
8
|
+
'&': '&',
|
|
9
|
+
'<': '<',
|
|
10
|
+
'>': '>',
|
|
11
|
+
'"': '"',
|
|
12
|
+
"'": ''',
|
|
13
|
+
'/': '/',
|
|
14
|
+
// Additional characters commonly escaped in attribute / template contexts
|
|
15
|
+
'`': '`',
|
|
16
|
+
'=': '=',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Escape HTML special characters
|
|
20
|
+
*/
|
|
21
|
+
const escapeHtml = (text) => {
|
|
22
|
+
if (typeof text !== 'string') {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
return text.replaceAll(/[&<>"'/`=]/g, (char) => HTML_ESCAPE_MAP[char] || char);
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Sanitize HTML by removing dangerous tags and attributes
|
|
29
|
+
*/
|
|
30
|
+
const sanitizeHtml = (html) => {
|
|
31
|
+
if (typeof html !== 'string') {
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
// Remove script tags and content
|
|
35
|
+
let sanitized = html.replaceAll(/<script\b[\s\S]*?<\/script>/gi, '');
|
|
36
|
+
// Remove iframe, object, embed, and base tags
|
|
37
|
+
sanitized = sanitized.replaceAll(/<(?:iframe|object|embed|base)\b[\s\S]*?>/gi, '');
|
|
38
|
+
sanitized = sanitized.replaceAll(/<\/(?:iframe|object|embed|base)>/gi, '');
|
|
39
|
+
// Remove event handlers (on*)
|
|
40
|
+
sanitized = sanitized.replaceAll(/\bon\w+\s*=\s*(?:'[^']*'|"[^"]*"|[^\s>]*)/gi, '');
|
|
41
|
+
// Remove javascript: and data: URIs in attributes
|
|
42
|
+
sanitized = sanitized.replaceAll(/\b(?:href|src|action|formaction|xlink:href)\s*=\s*['"]\s*(?:javascript|data):[\s\S]*?['"]/gi, // NOSONAR: S1523 - We are removing javascript: and data: protocols to prevent XSS
|
|
43
|
+
'');
|
|
44
|
+
sanitized = sanitized.replaceAll(/\b(?:href|src|action|formaction|xlink:href)\s*=\s*(?:javascript|data):[^\s>]*?(\s|>|$)/gi, // NOSONAR: S1523 - We are removing javascript: and data: protocols to prevent XSS
|
|
45
|
+
'');
|
|
46
|
+
// Remove style tags and style attributes with potentially dangerous content
|
|
47
|
+
sanitized = sanitized.replaceAll(/<style\b[\s\S]*?<\/style>/gi, '');
|
|
48
|
+
sanitized = sanitized.replaceAll(/\bstyle\s*=\s*(?:'[^']*'|"[^"]*"|[^\s>]*)/gi, '');
|
|
49
|
+
// Remove form elements
|
|
50
|
+
sanitized = sanitized.replaceAll(/<form\b[\s\S]*?<\/form>/gi, '');
|
|
51
|
+
// Remove object and embed tags
|
|
52
|
+
sanitized = sanitized.replaceAll(/<(?:object|embed|applet|meta|link|base)\b[\s\S]*?>/gi, '');
|
|
53
|
+
return sanitized.trim();
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Encode URI component to prevent injection in URLs
|
|
57
|
+
*/
|
|
58
|
+
const encodeUri = (uri) => {
|
|
59
|
+
if (typeof uri !== 'string') {
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
return encodeURIComponent(uri);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
Logger.error('URI encoding failed', error);
|
|
67
|
+
return '';
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Encode URI for use in href attribute
|
|
72
|
+
*/
|
|
73
|
+
const encodeHref = (href) => {
|
|
74
|
+
if (typeof href !== 'string') {
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
77
|
+
// Prevent javascript: protocol (including obfuscated versions)
|
|
78
|
+
// We remove control characters and whitespace for the check
|
|
79
|
+
// eslint-disable-next-line no-control-regex
|
|
80
|
+
const protocolCheck = href.replaceAll(/[\x00-\x20]/g, '').toLowerCase();
|
|
81
|
+
const jsProtocol = 'javascript:'; // NOSONAR: S1523 - We are explicitly blocking javascript: protocol to prevent XSS
|
|
82
|
+
if (protocolCheck.startsWith(jsProtocol)) {
|
|
83
|
+
return '';
|
|
84
|
+
}
|
|
85
|
+
// Prevent data: protocol (unless explicitly allowed)
|
|
86
|
+
if (protocolCheck.startsWith('data:text/html')) {
|
|
87
|
+
// NOSONAR: S1523 - We are explicitly blocking data: protocol to prevent XSS
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
return escapeHtml(href);
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Check if string is safe URL (http, https, or relative)
|
|
94
|
+
*/
|
|
95
|
+
const isSafeUrl = (url) => {
|
|
96
|
+
if (typeof url !== 'string') {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
const trimmed = url.trim().toLowerCase();
|
|
100
|
+
// Allow relative URLs
|
|
101
|
+
if (trimmed.startsWith('/') || trimmed.startsWith('#')) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
// Allow http and https
|
|
105
|
+
if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
// Block dangerous protocols
|
|
109
|
+
if (/^\w+:/.test(trimmed)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Escape JSON for safe embedding in HTML
|
|
116
|
+
*/
|
|
117
|
+
export const escapeJson = (obj) => {
|
|
118
|
+
const json = JSON.stringify(obj);
|
|
119
|
+
return escapeHtml(json);
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* XSS Protection Utilities
|
|
123
|
+
* HTML escaping and sanitization (pure TypeScript, zero dependencies)
|
|
124
|
+
* Sealed namespace with protection methods
|
|
125
|
+
*/
|
|
126
|
+
export const XssProtection = Object.freeze({
|
|
127
|
+
escape: escapeHtml,
|
|
128
|
+
sanitize: sanitizeHtml,
|
|
129
|
+
encodeUri,
|
|
130
|
+
encodeHref,
|
|
131
|
+
isSafeUrl,
|
|
132
|
+
escapeJson,
|
|
133
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Registry
|
|
3
|
+
* Maps base framework files to their .tpl template equivalents
|
|
4
|
+
* Sealed namespace pattern for immutability
|
|
5
|
+
*/
|
|
6
|
+
export interface TemplateMapping {
|
|
7
|
+
basePath: string;
|
|
8
|
+
templatePath: string;
|
|
9
|
+
description: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Sealed namespace providing template registry access
|
|
13
|
+
*/
|
|
14
|
+
export declare const TemplateRegistry: Readonly<{
|
|
15
|
+
/**
|
|
16
|
+
* Get all template mappings
|
|
17
|
+
*/
|
|
18
|
+
getMappings(): TemplateMapping[];
|
|
19
|
+
/**
|
|
20
|
+
* Get a specific mapping by base path
|
|
21
|
+
*/
|
|
22
|
+
getMapping(basePath: string): TemplateMapping | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Get all base file paths
|
|
25
|
+
*/
|
|
26
|
+
getBasePaths(): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Get all template paths
|
|
29
|
+
*/
|
|
30
|
+
getTemplatePaths(): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Validate if a base path is in the registry
|
|
33
|
+
*/
|
|
34
|
+
isRegistered(basePath: string): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get count of registered templates
|
|
37
|
+
*/
|
|
38
|
+
count(): number;
|
|
39
|
+
}>;
|
|
40
|
+
//# sourceMappingURL=TemplateRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TemplateRegistry.d.ts","sourceRoot":"","sources":["../../../src/templates/TemplateRegistry.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAmCD;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAC3B;;OAEG;mBACY,eAAe,EAAE;IAIhC;;OAEG;yBACkB,MAAM,GAAG,eAAe,GAAG,SAAS;IAIzD;;OAEG;oBACa,MAAM,EAAE;IAIxB;;OAEG;wBACiB,MAAM,EAAE;IAI5B;;OAEG;2BACoB,MAAM,GAAG,OAAO;IAIvC;;OAEG;aACM,MAAM;EAGf,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Registry
|
|
3
|
+
* Maps base framework files to their .tpl template equivalents
|
|
4
|
+
* Sealed namespace pattern for immutability
|
|
5
|
+
*/
|
|
6
|
+
const MAPPINGS = [
|
|
7
|
+
{
|
|
8
|
+
basePath: 'src/orm/adapters/SQLiteAdapter.ts',
|
|
9
|
+
templatePath: 'src/templates/adapters/SQLiteAdapter.ts.tpl',
|
|
10
|
+
description: 'SQLite database adapter',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
basePath: 'src/orm/adapters/PostgreSQLAdapter.ts',
|
|
14
|
+
templatePath: 'src/templates/adapters/PostgreSQLAdapter.ts.tpl',
|
|
15
|
+
description: 'PostgreSQL database adapter',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
basePath: 'src/orm/adapters/MySQLAdapter.ts',
|
|
19
|
+
templatePath: 'src/templates/adapters/MySQLAdapter.ts.tpl',
|
|
20
|
+
description: 'MySQL database adapter',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
basePath: 'src/orm/adapters/SQLServerAdapter.ts',
|
|
24
|
+
templatePath: 'src/templates/adapters/SQLServerAdapter.ts.tpl',
|
|
25
|
+
description: 'SQL Server database adapter',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
basePath: 'src/features/Auth.ts',
|
|
29
|
+
templatePath: 'src/templates/features/Auth.ts.tpl',
|
|
30
|
+
description: 'Authentication feature with JWT & bcrypt',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
basePath: 'src/features/Queue.ts',
|
|
34
|
+
templatePath: 'src/templates/features/Queue.ts.tpl',
|
|
35
|
+
description: 'Job queue feature',
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
/**
|
|
39
|
+
* Sealed namespace providing template registry access
|
|
40
|
+
*/
|
|
41
|
+
export const TemplateRegistry = Object.freeze({
|
|
42
|
+
/**
|
|
43
|
+
* Get all template mappings
|
|
44
|
+
*/
|
|
45
|
+
getMappings() {
|
|
46
|
+
return [...MAPPINGS];
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* Get a specific mapping by base path
|
|
50
|
+
*/
|
|
51
|
+
getMapping(basePath) {
|
|
52
|
+
return MAPPINGS.find((m) => m.basePath === basePath);
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* Get all base file paths
|
|
56
|
+
*/
|
|
57
|
+
getBasePaths() {
|
|
58
|
+
return MAPPINGS.map((m) => m.basePath);
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* Get all template paths
|
|
62
|
+
*/
|
|
63
|
+
getTemplatePaths() {
|
|
64
|
+
return MAPPINGS.map((m) => m.templatePath);
|
|
65
|
+
},
|
|
66
|
+
/**
|
|
67
|
+
* Validate if a base path is in the registry
|
|
68
|
+
*/
|
|
69
|
+
isRegistered(basePath) {
|
|
70
|
+
return MAPPINGS.some((m) => m.basePath === basePath);
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* Get count of registered templates
|
|
74
|
+
*/
|
|
75
|
+
count() {
|
|
76
|
+
return MAPPINGS.length;
|
|
77
|
+
},
|
|
78
|
+
});
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Registry
|
|
3
|
+
* Maps base framework files to their .tpl template equivalents
|
|
4
|
+
* Sealed namespace pattern for immutability
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface TemplateMapping {
|
|
8
|
+
basePath: string;
|
|
9
|
+
templatePath: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const MAPPINGS: TemplateMapping[] = [
|
|
14
|
+
{
|
|
15
|
+
basePath: 'src/orm/adapters/SQLiteAdapter.ts',
|
|
16
|
+
templatePath: 'src/templates/adapters/SQLiteAdapter.ts.tpl',
|
|
17
|
+
description: 'SQLite database adapter',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
basePath: 'src/orm/adapters/PostgreSQLAdapter.ts',
|
|
21
|
+
templatePath: 'src/templates/adapters/PostgreSQLAdapter.ts.tpl',
|
|
22
|
+
description: 'PostgreSQL database adapter',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
basePath: 'src/orm/adapters/MySQLAdapter.ts',
|
|
26
|
+
templatePath: 'src/templates/adapters/MySQLAdapter.ts.tpl',
|
|
27
|
+
description: 'MySQL database adapter',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
basePath: 'src/orm/adapters/SQLServerAdapter.ts',
|
|
31
|
+
templatePath: 'src/templates/adapters/SQLServerAdapter.ts.tpl',
|
|
32
|
+
description: 'SQL Server database adapter',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
basePath: 'src/features/Auth.ts',
|
|
36
|
+
templatePath: 'src/templates/features/Auth.ts.tpl',
|
|
37
|
+
description: 'Authentication feature with JWT & bcrypt',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
basePath: 'src/features/Queue.ts',
|
|
41
|
+
templatePath: 'src/templates/features/Queue.ts.tpl',
|
|
42
|
+
description: 'Job queue feature',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Sealed namespace providing template registry access
|
|
48
|
+
*/
|
|
49
|
+
export const TemplateRegistry = Object.freeze({
|
|
50
|
+
/**
|
|
51
|
+
* Get all template mappings
|
|
52
|
+
*/
|
|
53
|
+
getMappings(): TemplateMapping[] {
|
|
54
|
+
return [...MAPPINGS];
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get a specific mapping by base path
|
|
59
|
+
*/
|
|
60
|
+
getMapping(basePath: string): TemplateMapping | undefined {
|
|
61
|
+
return MAPPINGS.find((m) => m.basePath === basePath);
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get all base file paths
|
|
66
|
+
*/
|
|
67
|
+
getBasePaths(): string[] {
|
|
68
|
+
return MAPPINGS.map((m) => m.basePath);
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get all template paths
|
|
73
|
+
*/
|
|
74
|
+
getTemplatePaths(): string[] {
|
|
75
|
+
return MAPPINGS.map((m) => m.templatePath);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Validate if a base path is in the registry
|
|
80
|
+
*/
|
|
81
|
+
isRegistered(basePath: string): boolean {
|
|
82
|
+
return MAPPINGS.some((m) => m.basePath === basePath);
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get count of registered templates
|
|
87
|
+
*/
|
|
88
|
+
count(): number {
|
|
89
|
+
return MAPPINGS.length;
|
|
90
|
+
},
|
|
91
|
+
});
|