@zintrust/core 0.1.21 → 0.1.23
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 +1 -1
- package/bin/z.js +1 -1
- package/bin/zin.d.ts +1 -1
- package/bin/zin.js +1 -1
- package/bin/zintrust-main.d.ts +1 -1
- package/bin/zintrust-main.js +2 -2
- package/bin/zintrust-microservices.d.ts +1 -1
- package/bin/zintrust-microservices.js +1 -1
- package/bin/zintrust.d.ts +1 -1
- package/bin/zintrust.js +1 -1
- package/bin/zt.d.ts +1 -1
- package/bin/zt.js +1 -1
- package/package.json +2 -3
- package/public/index.html +3 -3
- package/routes/api.js +1 -1
- package/routes/health.d.ts +3 -4
- package/routes/health.d.ts.map +1 -1
- package/routes/health.js +3 -125
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +11 -22
- package/src/boot/bootstrap.d.ts +1 -1
- package/src/boot/bootstrap.js +48 -7
- package/src/builder/BundleOptimizer.d.ts +1 -1
- package/src/builder/BundleOptimizer.js +1 -1
- package/src/cache/drivers/KVRemoteDriver.d.ts +1 -1
- package/src/cache/drivers/KVRemoteDriver.js +1 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +15 -1
- package/src/cli/ErrorHandler.js +3 -3
- package/src/cli/commands/AddCommand.d.ts +1 -1
- package/src/cli/commands/AddCommand.d.ts.map +1 -1
- package/src/cli/commands/AddCommand.js +1 -1
- package/src/cli/commands/DbSeedCommand.js +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.js +2 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.js +2 -1
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +1 -1
- package/src/cli/commands/MigrateWorkerCommand.d.ts +9 -0
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -0
- package/src/cli/commands/MigrateWorkerCommand.js +182 -0
- package/src/cli/commands/NewCommand.d.ts +1 -1
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +21 -7
- package/src/cli/commands/PublishCommand.d.ts +5 -0
- package/src/cli/commands/PublishCommand.d.ts.map +1 -0
- package/src/cli/commands/PublishCommand.js +54 -0
- package/src/cli/commands/QACommand.js +4 -4
- package/src/cli/commands/ResourceControlCommand.d.ts +6 -0
- package/src/cli/commands/ResourceControlCommand.d.ts.map +1 -0
- package/src/cli/commands/ResourceControlCommand.js +43 -0
- package/src/cli/commands/SimulateCommand.d.ts +1 -1
- package/src/cli/commands/SimulateCommand.js +4 -4
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +19 -7
- package/src/cli/commands/UpgradeCommand.d.ts +1 -1
- package/src/cli/commands/UpgradeCommand.js +2 -2
- package/src/cli/commands/WorkerCommands.d.ts +17 -0
- package/src/cli/commands/WorkerCommands.d.ts.map +1 -0
- package/src/cli/commands/WorkerCommands.js +264 -0
- package/src/cli/commands/index.d.ts +2 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +2 -0
- package/src/cli/config/ConfigSchema.d.ts +1 -1
- package/src/cli/config/ConfigSchema.d.ts.map +1 -1
- package/src/cli/config/ConfigSchema.js +4 -3
- package/src/cli/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +4 -3
- package/src/cli/scaffolding/ModelGenerator.d.ts +1 -1
- package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ModelGenerator.js +10 -2
- package/src/cli/scaffolding/ProjectScaffolder.js +5 -5
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/RouteGenerator.js +21 -2
- package/src/cli/scaffolding/TemplateEngine.js +1 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/common/ExternalServiceUtils.d.ts +63 -0
- package/src/common/ExternalServiceUtils.d.ts.map +1 -0
- package/src/common/ExternalServiceUtils.js +116 -0
- package/src/common/HealthRoutes.d.ts +10 -0
- package/src/common/HealthRoutes.d.ts.map +1 -0
- package/src/common/HealthRoutes.js +114 -0
- package/src/config/SecretsManager.d.ts.map +1 -1
- package/src/config/SecretsManager.js +2 -1
- package/src/config/app.d.ts +2 -1
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +98 -52
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/broadcast.js +2 -2
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +2 -2
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +24 -5
- package/src/config/env.d.ts +43 -1
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +68 -21
- package/src/config/index.d.ts +10 -1
- package/src/config/index.d.ts.map +1 -1
- package/src/config/index.js +1 -0
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +3 -3
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +1 -1
- package/src/config/notification.d.ts.map +1 -1
- package/src/config/notification.js +2 -2
- package/src/config/queue.d.ts +14 -0
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +61 -36
- package/src/config/security.js +2 -2
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +5 -5
- package/src/config/type.d.ts +122 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/type.js +10 -1
- package/src/config/workers.d.ts +13 -0
- package/src/config/workers.d.ts.map +1 -0
- package/src/config/workers.js +173 -0
- package/src/database/Paginator.d.ts +37 -0
- package/src/database/Paginator.d.ts.map +1 -0
- package/src/database/Paginator.js +81 -0
- package/src/exceptions/ZintrustError.d.ts +5 -2
- package/src/exceptions/ZintrustError.d.ts.map +1 -1
- package/src/exceptions/ZintrustError.js +6 -2
- package/src/features/Auth.d.ts +1 -1
- package/src/features/Auth.d.ts.map +1 -1
- package/src/features/Auth.js +3 -2
- package/src/features/Queue.d.ts.map +1 -1
- package/src/features/Queue.js +0 -2
- package/src/index.d.ts +15 -5
- package/src/index.d.ts.map +1 -1
- package/src/index.js +24 -3
- package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -1
- package/src/microservices/MicroserviceBootstrap.js +3 -1
- package/src/microservices/MicroserviceGenerator.js +4 -4
- package/src/microservices/MicroserviceManager.d.ts +1 -1
- package/src/microservices/MicroserviceManager.js +1 -1
- package/src/middleware/RateLimiter.d.ts.map +1 -1
- package/src/middleware/RateLimiter.js +4 -3
- package/src/migrations/MigrationLoader.d.ts +1 -1
- package/src/migrations/MigrationLoader.d.ts.map +1 -1
- package/src/migrations/Migrator.d.ts +3 -3
- package/src/migrations/Migrator.d.ts.map +1 -1
- package/src/migrations/Migrator.js +1 -1
- package/src/migrations/MigratorFactory.d.ts +1 -1
- package/src/migrations/MigratorFactory.d.ts.map +1 -1
- package/src/migrations/MigratorFactory.js +3 -3
- package/src/migrations/enum/index.d.ts +93 -0
- package/src/migrations/enum/index.d.ts.map +1 -0
- package/src/migrations/enum/index.js +92 -0
- package/src/migrations/schema/Blueprint.d.ts +1 -1
- package/src/migrations/schema/Blueprint.d.ts.map +1 -1
- package/src/migrations/schema/Blueprint.js +27 -25
- package/src/migrations/schema/Schema.d.ts +1 -1
- package/src/migrations/schema/Schema.d.ts.map +1 -1
- package/src/migrations/schema/Schema.js +4 -3
- package/src/migrations/schema/SchemaCompiler.d.ts +1 -1
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
- package/src/migrations/schema/SchemaCompiler.js +99 -91
- package/src/migrations/schema/index.d.ts +4 -4
- package/src/migrations/schema/index.d.ts.map +1 -1
- package/src/migrations/schema/index.js +3 -3
- package/src/migrations/schema/types.d.ts +2 -1
- package/src/migrations/schema/types.d.ts.map +1 -1
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/os.d.ts +10 -1
- package/src/node-singletons/os.d.ts.map +1 -1
- package/src/node-singletons/os.js +10 -1
- package/src/openapi/OpenApiGenerator.js +2 -2
- package/src/orm/ConnectionManager.d.ts +7 -5
- package/src/orm/ConnectionManager.d.ts.map +1 -1
- package/src/orm/ConnectionManager.js +249 -93
- package/src/orm/Database.d.ts +2 -1
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/DatabaseAdapter.d.ts +3 -2
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseAdapter.js +17 -0
- package/src/orm/Model.d.ts +8 -1
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +109 -26
- package/src/orm/QueryBuilder.d.ts +12 -2
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +438 -38
- package/src/orm/Relationships.d.ts +61 -1
- package/src/orm/Relationships.d.ts.map +1 -1
- package/src/orm/Relationships.js +190 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +2 -1
- package/src/orm/adapters/D1RemoteAdapter.d.ts +1 -1
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +3 -2
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +2 -1
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLServerAdapter.js +2 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +2 -1
- package/src/orm/migrations/MigrationStore.d.ts.map +1 -1
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +57 -18
- package/src/profiling/RequestProfiler.d.ts.map +1 -1
- package/src/profiling/RequestProfiler.js +3 -1
- package/src/routing/CoreRoutes.d.ts +1 -1
- package/src/routing/CoreRoutes.d.ts.map +1 -1
- package/src/routing/CoreRoutes.js +2 -116
- package/src/routing/error.d.ts.map +1 -1
- package/src/routing/error.js +3 -2
- package/src/routing/publicRoot.d.ts.map +1 -1
- package/src/routing/publicRoot.js +4 -2
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +20 -4
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +23 -6
- package/src/runtime/RuntimeAdapter.d.ts +3 -3
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.d.ts +15 -13
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +12 -12
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/DenoAdapter.js +1 -1
- package/src/runtime/adapters/FargateAdapter.d.ts +2 -2
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/FargateAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +6 -4
- package/src/runtime/adapters/NodeServerAdapter.js +1 -1
- package/src/scripts/GenerateEnvArtifacts.js +1 -1
- package/src/security/SignedRequest.js +1 -1
- package/src/security/StartupSecretValidation.d.ts.map +1 -1
- package/src/security/StartupSecretValidation.js +7 -1
- package/src/start.d.ts.map +1 -1
- package/src/start.js +0 -2
- package/src/templates/features/Auth.ts.tpl +4 -4
- package/src/templates/project/basic/README.md.tpl +1 -1
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +1 -1
- package/src/templates/project/basic/config/notification.ts.tpl +1 -1
- package/src/templates/project/basic/routes/api.ts.tpl +1 -3
- package/src/templates/project/basic/src/index.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.ts.tpl +1 -1
- package/src/templates/project/basic/template.json +1 -1
- package/src/toolkit/Secrets/index.d.ts.map +1 -1
- package/src/toolkit/Secrets/index.js +13 -9
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +20 -7
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/CloudflareKv.js +19 -6
- package/src/tools/http/Http.js +1 -1
- package/src/tools/mail/drivers/Ses.d.ts.map +1 -1
- package/src/tools/mail/drivers/Ses.js +5 -4
- package/src/tools/mail/templates/index.js +2 -2
- package/src/tools/notification/drivers/Termii.d.ts.map +1 -1
- package/src/tools/notification/drivers/Termii.js +6 -17
- package/src/tools/notification/testingHelpers.d.ts.map +1 -1
- package/src/tools/queue/Queue.d.ts.map +1 -1
- package/src/tools/queue/Queue.js +3 -5
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +7 -1
- package/src/tools/storage/drivers/S3.d.ts.map +1 -1
- package/src/tools/storage/drivers/S3.js +16 -3
- package/src/routes/health.d.ts +0 -2
- package/src/routes/health.d.ts.map +0 -1
- package/src/routes/health.js +0 -1
- package/src/runtime/RuntimeDetector.d.ts +0 -15
- package/src/runtime/RuntimeDetector.d.ts.map +0 -1
- package/src/runtime/RuntimeDetector.js +0 -271
- package/src/templates/project/basic/routes/health.ts.tpl +0 -143
- package/src/templates/project/basic/routes/metrics.ts.tpl +0 -22
- package/src/workers/BroadcastWorker.d.ts +0 -22
- package/src/workers/BroadcastWorker.d.ts.map +0 -1
- package/src/workers/BroadcastWorker.js +0 -24
- package/src/workers/NotificationWorker.d.ts +0 -22
- package/src/workers/NotificationWorker.d.ts.map +0 -1
- package/src/workers/NotificationWorker.js +0 -23
- package/src/workers/createQueueWorker.d.ts +0 -24
- package/src/workers/createQueueWorker.d.ts.map +0 -1
- package/src/workers/createQueueWorker.js +0 -114
package/src/routing/error.js
CHANGED
|
@@ -9,11 +9,12 @@ import { ErrorPageRenderer } from '../http/error-pages/ErrorPageRenderer.js';
|
|
|
9
9
|
import { ErrorResponse } from '../http/ErrorResponse.js';
|
|
10
10
|
import { getPublicRoot } from './publicRoot.js';
|
|
11
11
|
import { Router } from './Router.js';
|
|
12
|
+
// Cache Set at module level to avoid repeated creation
|
|
13
|
+
const REDACTED_HEADERS = new Set(['authorization', 'cookie', 'set-cookie', 'x-api-key']);
|
|
12
14
|
const redactHeaders = (headers) => {
|
|
13
|
-
const redacted = new Set(['authorization', 'cookie', 'set-cookie', 'x-api-key']);
|
|
14
15
|
const out = {};
|
|
15
16
|
for (const [key, value] of Object.entries(headers)) {
|
|
16
|
-
if (
|
|
17
|
+
if (REDACTED_HEADERS.has(key.toLowerCase())) {
|
|
17
18
|
out[key] = '[redacted]';
|
|
18
19
|
continue;
|
|
19
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicRoot.d.ts","sourceRoot":"","sources":["../../../src/routing/publicRoot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,KAAG,MAalD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAkB3E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAO,MAAM,EAIhD,CAAC;AAEF,eAAO,MAAM,4BAA4B,QAAa,OAAO,CAAC,MAAM,EAAE,CAIrE,CAAC;
|
|
1
|
+
{"version":3,"file":"publicRoot.d.ts","sourceRoot":"","sources":["../../../src/routing/publicRoot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,KAAG,MAalD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,CAkB3E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAO,MAAM,EAIhD,CAAC;AAEF,eAAO,MAAM,4BAA4B,QAAa,OAAO,CAAC,MAAM,EAAE,CAIrE,CAAC;AAKF;;;GAGG;AACH,eAAO,MAAM,aAAa,QAAO,MAgBhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAAa,OAAO,CAAC,MAAM,CA+BzD,CAAC"}
|
|
@@ -59,12 +59,14 @@ export const getFrameworkPublicRootsAsync = async () => {
|
|
|
59
59
|
const packageRoot = await findPackageRootAsync(thisDir);
|
|
60
60
|
return [path.join(packageRoot, 'dist/public'), path.join(packageRoot, 'public')];
|
|
61
61
|
};
|
|
62
|
+
// Cache process.cwd() at module load time
|
|
63
|
+
const projectCwd = process.cwd();
|
|
62
64
|
/**
|
|
63
65
|
* Resolve the effective public root.
|
|
64
66
|
* Prefers app-local `public/` when present; otherwise falls back to framework public roots.
|
|
65
67
|
*/
|
|
66
68
|
export const getPublicRoot = () => {
|
|
67
|
-
const appRoots = [path.join(
|
|
69
|
+
const appRoots = [path.join(projectCwd, 'public')];
|
|
68
70
|
const candidates = [...appRoots, ...getFrameworkPublicRoots()];
|
|
69
71
|
// Prefer a root that contains an index.html (common for docs + dev portal).
|
|
70
72
|
const hasIndex = (root) => fs.existsSync(path.join(root, 'index.html'));
|
|
@@ -82,7 +84,7 @@ export const getPublicRoot = () => {
|
|
|
82
84
|
* Resolve the effective public root (async).
|
|
83
85
|
*/
|
|
84
86
|
export const getPublicRootAsync = async () => {
|
|
85
|
-
const appRoots = [path.join(
|
|
87
|
+
const appRoots = [path.join(projectCwd, 'public')];
|
|
86
88
|
const fwRoots = await getFrameworkPublicRootsAsync();
|
|
87
89
|
const candidates = [...appRoots, ...fwRoots];
|
|
88
90
|
const exists = async (p) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginAutoImports.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginAutoImports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PluginAutoImports.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginAutoImports.ts"],"names":[],"mappings":"AAOA,KAAK,YAAY,GACb;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAChC;IACE,EAAE,EAAE,KAAK,CAAC;IACV,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,eAAe,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAmCN,eAAO,MAAM,iBAAiB;IAC5B;;;;;;OAMG;mCACkC,OAAO,CAAC,YAAY,CAAC;EAgC1D,CAAC"}
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import { pathToFileURL } from '../node-singletons/url.js';
|
|
2
|
+
import { Env } from '../config/env.js';
|
|
2
3
|
import { Logger } from '../config/logger.js';
|
|
3
4
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
4
5
|
import { existsSync } from '../node-singletons/fs.js';
|
|
5
6
|
import * as path from '../node-singletons/path.js';
|
|
7
|
+
const readEnvString = (key) => {
|
|
8
|
+
const anyEnv = Env;
|
|
9
|
+
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
10
|
+
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
11
|
+
return fromEnv;
|
|
12
|
+
if (typeof process !== 'undefined') {
|
|
13
|
+
const raw = process.env?.[key];
|
|
14
|
+
if (typeof raw === 'string')
|
|
15
|
+
return raw;
|
|
16
|
+
}
|
|
17
|
+
return fromEnv ?? '';
|
|
18
|
+
};
|
|
19
|
+
const getProjectCwd = () => process.cwd();
|
|
20
|
+
const getProjectRootEnv = () => readEnvString('ZINTRUST_PROJECT_ROOT');
|
|
6
21
|
const resolveProjectRoot = () => {
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
return
|
|
10
|
-
|
|
22
|
+
const projectRootEnv = getProjectRootEnv();
|
|
23
|
+
if (projectRootEnv.trim().length > 0) {
|
|
24
|
+
return projectRootEnv.trim();
|
|
25
|
+
}
|
|
26
|
+
return getProjectCwd();
|
|
11
27
|
};
|
|
12
28
|
const getCandidates = (projectRoot) => {
|
|
13
29
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PluginManager.d.ts","sourceRoot":"","sources":["../../../src/runtime/PluginManager.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AA2ShE,eAAO,MAAM,aAAa;IACxB;;OAEG;YACK,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAIxC;;OAEG;yBACkB,MAAM,GAAG,MAAM,GAAG,IAAI;IAW3C;;OAEG;0BACyB,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA0DrD;;OAEG;sBACqB,MAAM,YAAY;QAAE,cAAc,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BrF;;;;OAIG;wBACuB,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;EA2ChD,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { execSync } from '../node-singletons/child-process.js';
|
|
7
7
|
import { SpawnUtil } from '../cli/utils/spawn.js';
|
|
8
8
|
import { esmDirname, resolvePackageManager } from '../common/index.js';
|
|
9
|
+
import { Env } from '../config/env.js';
|
|
9
10
|
import { Logger } from '../config/logger.js';
|
|
10
11
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
11
12
|
import { existsSync, fsPromises as fs } from '../node-singletons/fs.js';
|
|
@@ -26,11 +27,27 @@ function findPackageRoot(startDir) {
|
|
|
26
27
|
// Fallback to a reasonable default if package.json isn't found.
|
|
27
28
|
return path.resolve(startDir, '../..');
|
|
28
29
|
}
|
|
30
|
+
const readEnvString = (key) => {
|
|
31
|
+
const anyEnv = Env;
|
|
32
|
+
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
33
|
+
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
34
|
+
return fromEnv;
|
|
35
|
+
if (typeof process !== 'undefined') {
|
|
36
|
+
const raw = process.env?.[key];
|
|
37
|
+
if (typeof raw === 'string')
|
|
38
|
+
return raw;
|
|
39
|
+
}
|
|
40
|
+
return fromEnv ?? '';
|
|
41
|
+
};
|
|
42
|
+
const getProjectCwd = () => process.cwd();
|
|
43
|
+
const getProjectRootEnv = () => readEnvString('ZINTRUST_PROJECT_ROOT');
|
|
44
|
+
const getAllowPostInstallEnv = () => readEnvString('ZINTRUST_ALLOW_POSTINSTALL').trim();
|
|
29
45
|
function resolveProjectRoot() {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
return
|
|
33
|
-
|
|
46
|
+
const projectRootEnv = getProjectRootEnv();
|
|
47
|
+
if (projectRootEnv.trim().length > 0) {
|
|
48
|
+
return projectRootEnv.trim();
|
|
49
|
+
}
|
|
50
|
+
return getProjectCwd();
|
|
34
51
|
}
|
|
35
52
|
function resolveTemplateRootOrThrow() {
|
|
36
53
|
const packageRoot = findPackageRoot(__dirname);
|
|
@@ -172,7 +189,7 @@ async function ensurePluginAutoImports(plugin) {
|
|
|
172
189
|
const pluginFile = path.join(projectRoot, 'src', 'zintrust.plugins.ts');
|
|
173
190
|
await fs.mkdir(path.dirname(pluginFile), { recursive: true });
|
|
174
191
|
const header = '/**\n' +
|
|
175
|
-
' *
|
|
192
|
+
' * ZinTrust plugin auto-imports\n' +
|
|
176
193
|
' *\n' +
|
|
177
194
|
' * This file is managed by `zin plugin install` and contains side-effect\n' +
|
|
178
195
|
' * imports that register optional adapters/drivers into core registries.\n' +
|
|
@@ -219,7 +236,7 @@ function runPostInstall(plugin) {
|
|
|
219
236
|
if (plugin.postInstall.command !== undefined) {
|
|
220
237
|
// Post-install command execution is opt-in. To avoid arbitrary command execution
|
|
221
238
|
// and reduce supply-chain risk, we only execute when ZINTRUST_ALLOW_POSTINSTALL=1
|
|
222
|
-
const allow =
|
|
239
|
+
const allow = getAllowPostInstallEnv() === '1';
|
|
223
240
|
if (allow) {
|
|
224
241
|
Logger.info(`Running post-install command: ${plugin.postInstall.command}...`);
|
|
225
242
|
try {
|
|
@@ -40,7 +40,7 @@ export interface RuntimeAdapter {
|
|
|
40
40
|
*/
|
|
41
41
|
parseRequest(event: unknown): PlatformRequest;
|
|
42
42
|
/**
|
|
43
|
-
* Convert
|
|
43
|
+
* Convert ZinTrust response to platform-specific format
|
|
44
44
|
*/
|
|
45
45
|
formatResponse(response: PlatformResponse): unknown;
|
|
46
46
|
/**
|
|
@@ -60,7 +60,7 @@ export interface RuntimeAdapter {
|
|
|
60
60
|
* Get environment configuration object
|
|
61
61
|
*/
|
|
62
62
|
getEnvironment(): {
|
|
63
|
-
nodeEnv:
|
|
63
|
+
nodeEnv: NodeJS.ProcessEnv['NODE_ENV'];
|
|
64
64
|
runtime: string;
|
|
65
65
|
dbConnection: string;
|
|
66
66
|
dbHost?: string;
|
|
@@ -69,7 +69,7 @@ export interface RuntimeAdapter {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
|
-
* Request handler that processes HTTP requests through
|
|
72
|
+
* Request handler that processes HTTP requests through ZinTrust framework
|
|
73
73
|
*/
|
|
74
74
|
export type ZintrustHandler = (req: IncomingMessage, res: ServerResponse, body: Tbody) => Promise<void>;
|
|
75
75
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/RuntimeAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE7E,KA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H,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,eAAe,GAAG;IAC/D,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC7B,YAAY,EAAE;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;QAC3C,IAAI,EAAE,KAAK,CAAC;KACb,CAAC;CACH,CA+DA"}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
Broadcast
|
|
3
|
-
Cache
|
|
4
|
-
Database
|
|
5
|
-
Mail
|
|
6
|
-
Middleware
|
|
7
|
-
Notification
|
|
8
|
-
Queue
|
|
9
|
-
Storage
|
|
10
|
-
|
|
1
|
+
export declare const StartupConfigFile: {
|
|
2
|
+
readonly Broadcast: "config/broadcast.ts";
|
|
3
|
+
readonly Cache: "config/cache.ts";
|
|
4
|
+
readonly Database: "config/database.ts";
|
|
5
|
+
readonly Mail: "config/mail.ts";
|
|
6
|
+
readonly Middleware: "config/middleware.ts";
|
|
7
|
+
readonly Notification: "config/notification.ts";
|
|
8
|
+
readonly Queue: "config/queue.ts";
|
|
9
|
+
readonly Storage: "config/storage.ts";
|
|
10
|
+
readonly Workers: "config/workers.ts";
|
|
11
|
+
};
|
|
12
|
+
export type StartupConfigFileTyps = typeof StartupConfigFile.Broadcast | typeof StartupConfigFile.Cache | typeof StartupConfigFile.Database | typeof StartupConfigFile.Mail | typeof StartupConfigFile.Middleware | typeof StartupConfigFile.Notification | typeof StartupConfigFile.Queue | typeof StartupConfigFile.Storage | typeof StartupConfigFile.Workers;
|
|
11
13
|
export declare const StartupConfigFileRegistry: Readonly<{
|
|
12
|
-
preload(files: readonly
|
|
14
|
+
preload(files: readonly StartupConfigFileTyps[]): Promise<void>;
|
|
13
15
|
isPreloaded(): boolean;
|
|
14
|
-
get<T>(file:
|
|
15
|
-
has(file:
|
|
16
|
+
get<T>(file: StartupConfigFileTyps): T | undefined;
|
|
17
|
+
has(file: StartupConfigFileTyps): boolean;
|
|
16
18
|
/** Intended for tests only. */
|
|
17
19
|
clear(): void;
|
|
18
20
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartupConfigFileRegistry.d.ts","sourceRoot":"","sources":["../../../src/runtime/StartupConfigFileRegistry.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"StartupConfigFileRegistry.d.ts","sourceRoot":"","sources":["../../../src/runtime/StartupConfigFileRegistry.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;;;;;;;;;CAUpB,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAC7B,OAAO,iBAAiB,CAAC,SAAS,GAClC,OAAO,iBAAiB,CAAC,KAAK,GAC9B,OAAO,iBAAiB,CAAC,QAAQ,GACjC,OAAO,iBAAiB,CAAC,IAAI,GAC7B,OAAO,iBAAiB,CAAC,UAAU,GACnC,OAAO,iBAAiB,CAAC,YAAY,GACrC,OAAO,iBAAiB,CAAC,KAAK,GAC9B,OAAO,iBAAiB,CAAC,OAAO,GAChC,OAAO,iBAAiB,CAAC,OAAO,CAAC;AAKrC,eAAO,MAAM,yBAAyB;mBACf,SAAS,qBAAqB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;mBAetD,OAAO;QAIlB,CAAC,QAAQ,qBAAqB,GAAG,CAAC,GAAG,SAAS;cAIxC,qBAAqB,GAAG,OAAO;IAIzC,+BAA+B;aACtB,IAAI;EAIb,CAAC;AAEH,eAAe,yBAAyB,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import useFileLoader from '
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
import useFileLoader from './useFileLoader.js';
|
|
2
|
+
export const StartupConfigFile = {
|
|
3
|
+
Broadcast: 'config/broadcast.ts',
|
|
4
|
+
Cache: 'config/cache.ts',
|
|
5
|
+
Database: 'config/database.ts',
|
|
6
|
+
Mail: 'config/mail.ts',
|
|
7
|
+
Middleware: 'config/middleware.ts',
|
|
8
|
+
Notification: 'config/notification.ts',
|
|
9
|
+
Queue: 'config/queue.ts',
|
|
10
|
+
Storage: 'config/storage.ts',
|
|
11
|
+
Workers: 'config/workers.ts',
|
|
12
|
+
};
|
|
13
13
|
const cache = new Map();
|
|
14
14
|
let preloaded = false;
|
|
15
15
|
export const StartupConfigFileRegistry = Object.freeze({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudflareAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/CloudflareAdapter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,
|
|
1
|
+
{"version":3,"file":"CloudflareAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/CloudflareAdapter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC;;;;GAIG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;mBACY,aAAa,GAAG,cAAc;IAoD7C;;;OAGG;qBACc,OAAO;IAKxB;;;OAGG;qBACc,MAAM,GAAG,OAAO;EAIjC,CAAC;AA4IH;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,OAAO;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;IACjC,EAAE,CAAC,EAAE;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DenoAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/DenoAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,
|
|
1
|
+
{"version":3,"file":"DenoAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/DenoAdapter.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC;;;GAGG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;mBACY,aAAa,GAAG,cAAc,GAAG;QAC9C,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC1D;IAwDD;;OAEG;yBAEQ,cAAc,SACjB,MAAM,SACN,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;IAQhB;;OAEG;aACY,OAAO,CAAC,OAAO,CAAC;IAK/B;;OAEG;mBACY,MAAM,iBAAiB,MAAM,GAAG,MAAM;IAKrD;;OAEG;2BACoB,OAAO;EAI9B,CAAC"}
|
|
@@ -176,7 +176,7 @@ function getDenoEnvironment() {
|
|
|
176
176
|
// @ts-ignore - Deno.env is available in Deno runtime
|
|
177
177
|
const env = (typeof Deno === 'undefined' ? {} : (Deno.env.toObject?.() ?? {}));
|
|
178
178
|
return {
|
|
179
|
-
nodeEnv: env['DENO_ENV'] ?? 'production',
|
|
179
|
+
nodeEnv: (env['DENO_ENV'] ?? 'production'),
|
|
180
180
|
runtime: 'deno',
|
|
181
181
|
dbConnection: env['DB_CONNECTION'] ?? 'postgresql',
|
|
182
182
|
dbHost: env['DB_HOST'],
|
|
@@ -2,7 +2,7 @@ import { type IncomingMessage, type Server, type ServerResponse } from '../../no
|
|
|
2
2
|
import type { AdapterConfig, RuntimeAdapter } from '../RuntimeAdapter';
|
|
3
3
|
export interface FargateEnvironment {
|
|
4
4
|
[key: string]: unknown;
|
|
5
|
-
nodeEnv:
|
|
5
|
+
nodeEnv: NodeJS.ProcessEnv['NODE_ENV'];
|
|
6
6
|
runtime: string;
|
|
7
7
|
dbConnection: string;
|
|
8
8
|
dbHost: string | undefined;
|
|
@@ -17,7 +17,7 @@ export declare function createFargateAdapter(config: AdapterConfig): RuntimeAdap
|
|
|
17
17
|
stop(): Promise<void>;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* Fargate/Container adapter for running
|
|
20
|
+
* Fargate/Container adapter for running ZinTrust in AWS Fargate, Cloud Run, or Docker
|
|
21
21
|
* Wraps existing Node.js HTTP server for container orchestration
|
|
22
22
|
* Sealed namespace for immutability
|
|
23
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FargateAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/FargateAdapter.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,kBAAkB;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"FargateAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/FargateAdapter.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,cAAc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AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgB1F;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,EAC/B,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAIpD;AAED,wBAAgB,0BAA0B,IAAI,aAAa,CAAC,QAAQ,CAAC,CAUpE"}
|
|
@@ -56,7 +56,7 @@ export function createFargateAdapter(config) {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
* Fargate/Container adapter for running
|
|
59
|
+
* Fargate/Container adapter for running ZinTrust in AWS Fargate, Cloud Run, or Docker
|
|
60
60
|
* Wraps existing Node.js HTTP server for container orchestration
|
|
61
61
|
* Sealed namespace for immutability
|
|
62
62
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AdapterConfig, RuntimeAdapter } from '../RuntimeAdapter';
|
|
2
2
|
/**
|
|
3
3
|
* AWS Lambda adapter for API Gateway and ALB events
|
|
4
|
-
* Converts Lambda events to standard HTTP format for
|
|
4
|
+
* Converts Lambda events to standard HTTP format for ZinTrust framework
|
|
5
5
|
* Sealed namespace for immutability
|
|
6
6
|
*/
|
|
7
7
|
export declare const LambdaAdapter: Readonly<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LambdaAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/LambdaAdapter.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,
|
|
1
|
+
{"version":3,"file":"LambdaAdapter.d.ts","sourceRoot":"","sources":["../../../../src/runtime/adapters/LambdaAdapter.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACV,aAAa,EAGb,cAAc,EACf,MAAM,yBAAyB,CAAC;AAGjC;;;;GAIG;AACH,eAAO,MAAM,aAAa;IACxB;;OAEG;mBACY,aAAa,GAAG,cAAc;EA8D7C,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { IncomingMessage, ServerResponse, } from '../../node-singletons/http.js'
|
|
|
7
7
|
import { ErrorResponse, HttpResponse } from '../RuntimeAdapter.js';
|
|
8
8
|
/**
|
|
9
9
|
* AWS Lambda adapter for API Gateway and ALB events
|
|
10
|
-
* Converts Lambda events to standard HTTP format for
|
|
10
|
+
* Converts Lambda events to standard HTTP format for ZinTrust framework
|
|
11
11
|
* Sealed namespace for immutability
|
|
12
12
|
*/
|
|
13
13
|
export const LambdaAdapter = Object.freeze({
|
|
@@ -75,7 +75,7 @@ async function handleLambdaRequest(adapter, config, event, _context) {
|
|
|
75
75
|
}));
|
|
76
76
|
}, timeout);
|
|
77
77
|
try {
|
|
78
|
-
// Process request through
|
|
78
|
+
// Process request through ZinTrust handler
|
|
79
79
|
await config.handler(req, res, body);
|
|
80
80
|
}
|
|
81
81
|
finally {
|
|
@@ -95,8 +95,10 @@ async function handleLambdaRequest(adapter, config, event, _context) {
|
|
|
95
95
|
}
|
|
96
96
|
catch (error) {
|
|
97
97
|
Logger.error('Lambda handler error', error);
|
|
98
|
-
const nodeEnv = typeof Env.NODE_ENV === 'string' && Env.NODE_ENV !== ''
|
|
99
|
-
|
|
98
|
+
const nodeEnv = typeof Env.NODE_ENV === 'string' && String(Env.NODE_ENV) !== ''
|
|
99
|
+
? Env.NODE_ENV
|
|
100
|
+
: 'development';
|
|
101
|
+
const includeDetails = nodeEnv === 'development' || String(nodeEnv) === 'dev';
|
|
100
102
|
const errorResponse = ErrorResponse.create(500, 'Internal Server Error', includeDetails ? { message: error.message } : undefined);
|
|
101
103
|
return errorResponse.toResponse();
|
|
102
104
|
}
|
|
@@ -112,7 +112,7 @@ const renderEnvDts = (keys) => {
|
|
|
112
112
|
return `declare namespace NodeJS {\n interface ProcessEnv {\n NODE_ENV: 'development' | 'production' | 'testing' | undefined;\n\n${lines}\n }\n}\n`;
|
|
113
113
|
};
|
|
114
114
|
const renderEnvExample = (keys) => {
|
|
115
|
-
const header = `#
|
|
115
|
+
const header = `# ZinTrust Framework - Environment Configuration\n# Generated by src/scripts/GenerateEnvArtifacts.ts\n# Copy this file to .env and configure for your environment\n\n`;
|
|
116
116
|
const sortedKeys = keys.toSorted((a, b) => a.localeCompare(b));
|
|
117
117
|
const body = sortedKeys
|
|
118
118
|
.filter((k) => k !== 'NODE_ENV')
|
|
@@ -18,7 +18,7 @@ const timingSafeEquals = (a, b) => {
|
|
|
18
18
|
const getCrypto = () => {
|
|
19
19
|
if (typeof crypto === 'undefined' || crypto.subtle === undefined) {
|
|
20
20
|
// Some runtimes (or test environments) may not expose WebCrypto.
|
|
21
|
-
// Keep this as a typed
|
|
21
|
+
// Keep this as a typed ZinTrust error to satisfy lint rules.
|
|
22
22
|
throw ErrorFactory.createSecurityError('WebCrypto is not available in this runtime');
|
|
23
23
|
}
|
|
24
24
|
return crypto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartupSecretValidation.d.ts","sourceRoot":"","sources":["../../../src/security/StartupSecretValidation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,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;
|
|
1
|
+
{"version":3,"file":"StartupSecretValidation.d.ts","sourceRoot":"","sources":["../../../src/security/StartupSecretValidation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,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;AAgHF,eAAO,MAAM,uBAAuB;gBACtB,6BAA6B;mBAiB1B,IAAI;EAQnB,CAAC;AAEH,eAAe,uBAAuB,CAAC"}
|
|
@@ -25,8 +25,14 @@ const validateJwtSecret = () => {
|
|
|
25
25
|
return null;
|
|
26
26
|
try {
|
|
27
27
|
const secret = securityConfig.jwt.secret.trim();
|
|
28
|
+
const appKey = (Env.APP_KEY ?? '').trim();
|
|
28
29
|
if (secret.length === 0) {
|
|
29
|
-
|
|
30
|
+
if (appKey.length > 0)
|
|
31
|
+
return null;
|
|
32
|
+
return {
|
|
33
|
+
key: 'JWT_SECRET',
|
|
34
|
+
message: 'JWT_SECRET must be set when JWT is enabled (or provide APP_KEY)',
|
|
35
|
+
};
|
|
30
36
|
}
|
|
31
37
|
return null;
|
|
32
38
|
}
|
package/src/start.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"AAsBA,eAAO,MAAM,UAAU,GAAI,eAAe,MAAM,KAAG,OAYlD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAAa,OAAO,CAAC,IAAI,CAO1C,CAAC;AAEF;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
|
package/src/start.js
CHANGED
|
@@ -36,14 +36,12 @@ export const isNodeMain = (importMetaUrl) => {
|
|
|
36
36
|
* This uses a non-literal dynamic import so Worker bundlers don't pull Node-only modules.
|
|
37
37
|
*/
|
|
38
38
|
export const start = async () => {
|
|
39
|
-
/* c8 ignore start */
|
|
40
39
|
if (!isNodeRuntime())
|
|
41
40
|
return;
|
|
42
41
|
// Compiled output places bootstrap at `dist/src/boot/bootstrap.js`.
|
|
43
42
|
// This file compiles to `dist/src/start.js`, so relative import is stable.
|
|
44
43
|
// In unit tests, importing bootstrap has heavy side effects (starts server + exits).
|
|
45
44
|
await import('./boot/' + 'bootstrap.js');
|
|
46
|
-
/* c8 ignore stop */
|
|
47
45
|
};
|
|
48
46
|
/**
|
|
49
47
|
* Cloudflare Workers entry (module worker style).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// TEMPLATE_START
|
|
2
2
|
import * as bcrypt from 'bcrypt';
|
|
3
|
-
import
|
|
3
|
+
import jwt, { type Secret, type SignOptions } from 'jsonwebtoken';
|
|
4
4
|
|
|
5
5
|
export const Auth = Object.freeze({
|
|
6
6
|
/**
|
|
@@ -27,14 +27,14 @@ export const Auth = Object.freeze({
|
|
|
27
27
|
expiresIn: NonNullable<SignOptions['expiresIn']> = '1h'
|
|
28
28
|
): string {
|
|
29
29
|
const options: SignOptions = { expiresIn };
|
|
30
|
-
return sign(payload, secret, options);
|
|
30
|
+
return jwt.sign(payload, secret, options);
|
|
31
31
|
},
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* Verify a JWT token
|
|
35
35
|
*/
|
|
36
36
|
verifyToken<T>(token: string, secret: Secret): T {
|
|
37
|
-
return verify(token, secret) as T;
|
|
37
|
+
return jwt.verify(token, secret) as T;
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
|
-
// TEMPLATE_END
|
|
40
|
+
// TEMPLATE_END
|
|
@@ -17,7 +17,7 @@ export default {
|
|
|
17
17
|
termii: {
|
|
18
18
|
driver: 'termii' as const,
|
|
19
19
|
apiKey: Env.get('TERMII_API_KEY', ''),
|
|
20
|
-
sender: Env.get('TERMII_SENDER', '
|
|
20
|
+
sender: Env.get('TERMII_SENDER', 'ZinTrust'),
|
|
21
21
|
endpoint: Env.get('TERMII_ENDPOINT', 'https://api.termii.com/sms/send'),
|
|
22
22
|
},
|
|
23
23
|
twilio: {
|
|
@@ -8,7 +8,6 @@ import { UserQueryBuilderController } from '@app/Controllers/UserQueryBuilderCon
|
|
|
8
8
|
import { Env , Router } from '@zintrust/core';
|
|
9
9
|
import type { MiddlewareKey , IRouter , IResponse, IRequest} from '@zintrust/core';
|
|
10
10
|
import { registerBroadcastRoutes } from '@routes/broadcast';
|
|
11
|
-
import { registerHealthRoutes } from '@routes/health';
|
|
12
11
|
import { registerStorageRoutes } from '@routes/storage';
|
|
13
12
|
|
|
14
13
|
export function registerRoutes(router: IRouter): void {
|
|
@@ -24,7 +23,6 @@ export function registerRoutes(router: IRouter): void {
|
|
|
24
23
|
*/
|
|
25
24
|
function registerPublicRoutes(router: IRouter): void {
|
|
26
25
|
registerRootRoute(router);
|
|
27
|
-
registerHealthRoutes(router);
|
|
28
26
|
registerBroadcastRoutes(router);
|
|
29
27
|
registerStorageRoutes(router);
|
|
30
28
|
}
|
|
@@ -32,7 +30,7 @@ function registerPublicRoutes(router: IRouter): void {
|
|
|
32
30
|
function registerRootRoute(router: IRouter): void {
|
|
33
31
|
Router.get(router, '/', async (_req: IRequest, res:IResponse) => {
|
|
34
32
|
res.json({
|
|
35
|
-
framework: '
|
|
33
|
+
framework: 'ZinTrust Framework',
|
|
36
34
|
app_name: Env.APP_NAME,
|
|
37
35
|
version: '0.1.0',
|
|
38
36
|
env: Env.NODE_ENV ?? 'development',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/toolkit/Secrets/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/toolkit/Secrets/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAI/E,YAAY,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,mBAAmB,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,EAAE,mBAAmB,CAAC;CAChC,CAAC;AA+GF,eAAO,MAAM,cAAc;kBACL,WAAW,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;kBAe1D,WAAW,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;oBAiB7D,aAAa,GAAG;QAC9B,QAAQ,EAAE,mBAAmB,CAAC;QAC9B,EAAE,EAAE,OAAO,CAAC;QACZ,OAAO,EAAE,MAAM,EAAE,CAAC;KACnB;EAMD,CAAC;AAEH,eAAe,cAAc,CAAC"}
|