@zintrust/core 0.4.80 → 0.4.81
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/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +19 -7
- package/package.json +1 -1
- package/src/cli/commands/D1ProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/D1ProxyCommand.js +12 -1
- package/src/cli/commands/MongoDBProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/MongoDBProxyCommand.js +3 -1
- package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/MySqlProxyCommand.js +9 -7
- package/src/cli/commands/PostgresProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/PostgresProxyCommand.js +9 -7
- package/src/cli/commands/ProxyCommandUtils.d.ts +2 -0
- package/src/cli/commands/ProxyCommandUtils.d.ts.map +1 -1
- package/src/cli/commands/ProxyCommandUtils.js +25 -0
- package/src/cli/commands/RedisProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/RedisProxyCommand.js +3 -2
- package/src/cli/commands/SmtpProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/SmtpProxyCommand.js +2 -1
- package/src/cli/commands/SqlServerProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/SqlServerProxyCommand.js +3 -1
- package/src/cli/commands/WranglerProxyCommandUtils.d.ts.map +1 -1
- package/src/cli/commands/WranglerProxyCommandUtils.js +14 -35
- package/src/index.js +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust-main.d.ts","sourceRoot":"","sources":["../../bin/zintrust-main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"zintrust-main.d.ts","sourceRoot":"","sources":["../../bin/zintrust-main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AA0WF,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAMzC;AAED,eAAO,MAAM,mBAAmB;;qCAzUQ,MAAM,KAAG,qBAAqB,GAAG,SAAS;mCA6C5C,MAAM,GAAG,IAAI,UAAU,MAAM,CAAC,OAAO,GAAG,IAAI,KAAG,MAAM;iCAnEzD,MAAM;8BAIP,MAAM,KAAG,MAAM;uCAsEtC,qBAAqB,WACpB,MAAM,EAAE,KAChB,OAAO,CAAC,KAAK,CAAC;oCAhEsB,MAAM,sBAAsB,MAAM,KAAG,OAAO;6CA2G7B,MAAM,EAAE,KAAG,OAAO,CAAC,OAAO,CAAC;yCAtE1E,MAAM,sBACS,MAAM,QACrB,MAAM,CAAC,UAAU,KACrB,qBAAqB,GAAG,SAAS;EAqTlC,CAAC;AAEH,OAAO,EAAE,CAAC"}
|
package/bin/zintrust-main.js
CHANGED
|
@@ -4,12 +4,20 @@
|
|
|
4
4
|
* This module contains the CLI implementation without a hashbang so that it can
|
|
5
5
|
* be imported by other bin shortcuts (zin/z/zt) without parse errors.
|
|
6
6
|
*/
|
|
7
|
-
import { Logger } from '../src/config/logger.js';
|
|
8
7
|
import { spawn } from 'node:child_process';
|
|
9
8
|
import fs from 'node:fs';
|
|
10
9
|
import path from 'node:path';
|
|
11
10
|
import { fileURLToPath } from 'node:url';
|
|
12
11
|
const CLI_HANDOFF_ENV_KEY = 'ZINTRUST_CLI_HANDOFF';
|
|
12
|
+
const loadLogger = async () => {
|
|
13
|
+
try {
|
|
14
|
+
const { Logger } = await import('../src/config/logger.js');
|
|
15
|
+
return Logger;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
13
21
|
const getCurrentPackageRoot = () => {
|
|
14
22
|
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
15
23
|
};
|
|
@@ -199,18 +207,22 @@ const shouldDeferPluginAutoImportWarnings = (args) => {
|
|
|
199
207
|
const command = getPrimaryCommand(args);
|
|
200
208
|
return command === 'start' || command === 's';
|
|
201
209
|
};
|
|
202
|
-
const logPluginAutoImportFailure = (args, scope, details) => {
|
|
210
|
+
const logPluginAutoImportFailure = async (args, scope, details) => {
|
|
211
|
+
const logger = await loadLogger();
|
|
212
|
+
if (logger === undefined)
|
|
213
|
+
return;
|
|
203
214
|
if (shouldDeferPluginAutoImportWarnings(args)) {
|
|
204
|
-
|
|
215
|
+
logger.debug(`${scope} plugin auto-import advisory deferred to runtime bootstrap`, {
|
|
205
216
|
details,
|
|
206
217
|
});
|
|
207
218
|
return;
|
|
208
219
|
}
|
|
209
|
-
|
|
220
|
+
logger.warn(`${scope} plugin auto-imports failed:`, details);
|
|
210
221
|
};
|
|
211
222
|
const handleCliFatal = async (error, context) => {
|
|
212
223
|
try {
|
|
213
|
-
|
|
224
|
+
const logger = await loadLogger();
|
|
225
|
+
logger?.error(context, error);
|
|
214
226
|
}
|
|
215
227
|
catch {
|
|
216
228
|
// best-effort logging
|
|
@@ -259,11 +271,11 @@ const runCliInternal = async () => {
|
|
|
259
271
|
const runtimeImportMode = process.env['DOCKER_WORKER'] === 'true' ? 'worker' : 'base';
|
|
260
272
|
const officialImports = await PluginAutoImports.tryImportRuntimeAutoImports(runtimeImportMode);
|
|
261
273
|
if (!officialImports.ok) {
|
|
262
|
-
logPluginAutoImportFailure(args0, 'Official', officialImports.errorMessage);
|
|
274
|
+
await logPluginAutoImportFailure(args0, 'Official', officialImports.errorMessage);
|
|
263
275
|
}
|
|
264
276
|
const projectImports = await PluginAutoImports.tryImportProjectAutoImports();
|
|
265
277
|
if (!projectImports.ok && projectImports.reason !== 'not-found') {
|
|
266
|
-
logPluginAutoImportFailure(args0, 'Project', projectImports.errorMessage);
|
|
278
|
+
await logPluginAutoImportFailure(args0, 'Project', projectImports.errorMessage);
|
|
267
279
|
}
|
|
268
280
|
}
|
|
269
281
|
catch {
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1ProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1ProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"D1ProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/D1ProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkIrD,eAAO,MAAM,cAAc;cACf,YAAY;EAkBtB,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -66,6 +66,17 @@ const warnOnPlaceholderDatabaseId = (values) => {
|
|
|
66
66
|
return;
|
|
67
67
|
Logger.warn('Could not resolve a D1 database id automatically. Update wrangler.jsonc or pass --database-id before relying on the generated d1-proxy environment.');
|
|
68
68
|
};
|
|
69
|
+
const warnOnMissingSigningSecret = () => {
|
|
70
|
+
const directSecret = trimNonEmptyOption(Env.get('D1_REMOTE_SECRET', ''));
|
|
71
|
+
const fallbackSecret = trimNonEmptyOption(Env.get('APP_KEY', ''));
|
|
72
|
+
if (directSecret !== undefined || fallbackSecret !== undefined)
|
|
73
|
+
return;
|
|
74
|
+
Logger.warn('D1 proxy signing will fail: the resolved project env does not expose D1_REMOTE_SECRET or APP_KEY to the Worker runtime. Signed requests will be rejected with 401 CONFIG_ERROR until one of those keys is set.');
|
|
75
|
+
};
|
|
76
|
+
const runD1ProxyDiagnostics = (values) => {
|
|
77
|
+
warnOnPlaceholderDatabaseId(values);
|
|
78
|
+
warnOnMissingSigningSecret();
|
|
79
|
+
};
|
|
69
80
|
const addOptions = (command) => {
|
|
70
81
|
addWranglerProxyBaseOptions(command, DEFAULT_CONFIG);
|
|
71
82
|
command.option('--binding <name>', 'D1 binding name', DEFAULT_BINDING);
|
|
@@ -88,7 +99,7 @@ export const D1ProxyCommand = Object.freeze({
|
|
|
88
99
|
addOptions,
|
|
89
100
|
resolveValues: resolveConfigValues,
|
|
90
101
|
renderEnvBlock: renderD1ProxyEnvBlock,
|
|
91
|
-
afterConfigResolved:
|
|
102
|
+
afterConfigResolved: runD1ProxyDiagnostics,
|
|
92
103
|
});
|
|
93
104
|
},
|
|
94
105
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MongoDBProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MongoDBProxyCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MongoDBProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MongoDBProxyCommand.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA4DpC,eAAO,MAAM,mBAAmB;cACpB,OAAO;EA0EjB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Env } from '../../config/env.js';
|
|
2
2
|
import { Logger } from '../../config/logger.js';
|
|
3
3
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import { ensureProxyEnvLoadedForCwd } from '../commands/ProxyCommandUtils.js';
|
|
4
5
|
import { Command } from 'commander';
|
|
5
6
|
const startWatchMode = async (options) => {
|
|
6
7
|
Logger.info('Starting MongoDB proxy in watch mode...');
|
|
@@ -57,13 +58,14 @@ export const MongoDBProxyCommand = Object.freeze({
|
|
|
57
58
|
const cmd = new Command('proxy:mongodb');
|
|
58
59
|
cmd.description('Start MongoDB HTTP proxy server');
|
|
59
60
|
const configureOptions = () => {
|
|
61
|
+
ensureProxyEnvLoadedForCwd();
|
|
60
62
|
cmd.option('--host <host>', 'Proxy host', Env.get('MONGODB_PROXY_HOST', '127.0.0.1'));
|
|
61
63
|
cmd.option('--port <port>', 'Proxy port', String(Env.getInt('MONGODB_PROXY_PORT', 8792)));
|
|
62
64
|
cmd.option('--mongo-uri <uri>', 'MongoDB connection URI', Env.get('MONGO_URI', ''));
|
|
63
65
|
cmd.option('--mongo-db <database>', 'MongoDB database name', Env.get('MONGO_DB', ''));
|
|
64
66
|
cmd.option('--key-id <keyId>', 'Signing key ID', Env.get('MONGODB_PROXY_KEY_ID', 'default'));
|
|
65
67
|
cmd.option('--secret <secret>', 'Signing secret', Env.get('MONGODB_PROXY_SECRET', ''));
|
|
66
|
-
cmd.option('--require-signing', 'Require request signing', Env.MONGODB_PROXY_REQUIRE_SIGNING);
|
|
68
|
+
cmd.option('--require-signing', 'Require request signing', Env.getBool('MONGODB_PROXY_REQUIRE_SIGNING', true));
|
|
67
69
|
cmd.option('--signing-window-ms <ms>', 'Signing window in milliseconds', String(Env.getInt('MONGODB_PROXY_SIGNING_WINDOW_MS', 60000)));
|
|
68
70
|
cmd.option('--watch', 'Watch mode: restart on file changes');
|
|
69
71
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MySqlProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MySqlProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"MySqlProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MySqlProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgCrE,eAAO,MAAM,iBAAiB;cAClB,YAAY;EAatB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { ensureProxyEnvLoadedForCwd } from '../commands/ProxyCommandUtils.js';
|
|
2
3
|
import { addSqlProxyOptions, runSqlProxyCommand, } from '../commands/SqlProxyCommandUtils.js';
|
|
3
4
|
import { Env } from '../../config/env.js';
|
|
4
5
|
import { MySqlProxyServer } from '../../proxy/mysql/MySqlProxyServer.js';
|
|
5
6
|
const addOptions = (command) => {
|
|
7
|
+
ensureProxyEnvLoadedForCwd();
|
|
6
8
|
addSqlProxyOptions(command, {
|
|
7
|
-
hostDefault: Env.MYSQL_PROXY_HOST,
|
|
8
|
-
portDefault: Env.MYSQL_PROXY_PORT,
|
|
9
|
-
maxBodyBytesDefault: Env.MYSQL_PROXY_MAX_BODY_BYTES,
|
|
9
|
+
hostDefault: Env.get('MYSQL_PROXY_HOST', '127.0.0.1'),
|
|
10
|
+
portDefault: Env.getInt('MYSQL_PROXY_PORT', 8789),
|
|
11
|
+
maxBodyBytesDefault: Env.getInt('MYSQL_PROXY_MAX_BODY_BYTES', 131072),
|
|
10
12
|
dbVendorLabel: 'MySQL',
|
|
11
|
-
requireSigningDefault: Env.MYSQL_PROXY_REQUIRE_SIGNING,
|
|
12
|
-
keyIdDefault: Env.MYSQL_PROXY_KEY_ID,
|
|
13
|
-
secretDefault: Env.MYSQL_PROXY_SECRET,
|
|
14
|
-
signingWindowMsDefault: Env.MYSQL_PROXY_SIGNING_WINDOW_MS,
|
|
13
|
+
requireSigningDefault: Env.getBool('MYSQL_PROXY_REQUIRE_SIGNING', true),
|
|
14
|
+
keyIdDefault: Env.get('MYSQL_PROXY_KEY_ID', Env.get('APP_NAME', 'ZinTrust')),
|
|
15
|
+
secretDefault: Env.get('MYSQL_PROXY_SECRET', Env.get('APP_KEY', '')),
|
|
16
|
+
signingWindowMsDefault: Env.getInt('MYSQL_PROXY_SIGNING_WINDOW_MS', Env.getInt('ZT_PROXY_SIGNING_WINDOW_MS', 60000)),
|
|
15
17
|
});
|
|
16
18
|
};
|
|
17
19
|
export const MySqlProxyCommand = Object.freeze({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/PostgresProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgresProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/PostgresProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAgCrE,eAAO,MAAM,oBAAoB;cACrB,YAAY;EAatB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { ensureProxyEnvLoadedForCwd } from '../commands/ProxyCommandUtils.js';
|
|
2
3
|
import { addSqlProxyOptions, runSqlProxyCommand, } from '../commands/SqlProxyCommandUtils.js';
|
|
3
4
|
import { Env } from '../../config/env.js';
|
|
4
5
|
import { PostgresProxyServer } from '../../proxy/postgres/PostgresProxyServer.js';
|
|
5
6
|
const addOptions = (command) => {
|
|
7
|
+
ensureProxyEnvLoadedForCwd();
|
|
6
8
|
addSqlProxyOptions(command, {
|
|
7
|
-
hostDefault: Env.POSTGRES_PROXY_HOST,
|
|
8
|
-
portDefault: Env.POSTGRES_PROXY_PORT,
|
|
9
|
-
maxBodyBytesDefault: Env.POSTGRES_PROXY_MAX_BODY_BYTES,
|
|
9
|
+
hostDefault: Env.get('POSTGRES_PROXY_HOST', '127.0.0.1'),
|
|
10
|
+
portDefault: Env.getInt('POSTGRES_PROXY_PORT', 8790),
|
|
11
|
+
maxBodyBytesDefault: Env.getInt('POSTGRES_PROXY_MAX_BODY_BYTES', 131072),
|
|
10
12
|
dbVendorLabel: 'PostgreSQL',
|
|
11
|
-
requireSigningDefault: Env.POSTGRES_PROXY_REQUIRE_SIGNING,
|
|
12
|
-
keyIdDefault: Env.POSTGRES_PROXY_KEY_ID,
|
|
13
|
-
secretDefault: Env.POSTGRES_PROXY_SECRET,
|
|
14
|
-
signingWindowMsDefault: Env.POSTGRES_PROXY_SIGNING_WINDOW_MS,
|
|
13
|
+
requireSigningDefault: Env.getBool('POSTGRES_PROXY_REQUIRE_SIGNING', true),
|
|
14
|
+
keyIdDefault: Env.get('POSTGRES_PROXY_KEY_ID', Env.get('APP_NAME', 'ZinTrust')),
|
|
15
|
+
secretDefault: Env.get('POSTGRES_PROXY_SECRET', Env.get('APP_KEY', '')),
|
|
16
|
+
signingWindowMsDefault: Env.getInt('POSTGRES_PROXY_SIGNING_WINDOW_MS', Env.getInt('ZT_PROXY_SIGNING_WINDOW_MS', 60000)),
|
|
15
17
|
});
|
|
16
18
|
};
|
|
17
19
|
export const PostgresProxyCommand = Object.freeze({
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
type NumberExpectation = 'positive' | 'non-negative';
|
|
2
2
|
export declare const parseIntOption: (raw: string | undefined, name: string, expectation?: NumberExpectation) => number | undefined;
|
|
3
3
|
export declare const trimOption: (value: string | undefined) => string | undefined;
|
|
4
|
+
export declare const resolveProxyProjectRoot: (cwd: string) => string;
|
|
5
|
+
export declare const ensureProxyEnvLoadedForCwd: (cwd?: string) => string;
|
|
4
6
|
export declare const maybeRunProxyWatchMode: (watch: boolean | undefined) => Promise<void>;
|
|
5
7
|
export {};
|
|
6
8
|
//# sourceMappingURL=ProxyCommandUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ProxyCommandUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ProxyCommandUtils.ts"],"names":[],"mappings":"AAMA,KAAK,iBAAiB,GAAG,UAAU,GAAG,cAAc,CAAC;AAErD,eAAO,MAAM,cAAc,GACzB,KAAK,MAAM,GAAG,SAAS,EACvB,MAAM,MAAM,EACZ,cAAa,iBAA8B,KAC1C,MAAM,GAAG,SAeX,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,OAAO,MAAM,GAAG,SAAS,KAAG,MAAM,GAAG,SAA0B,CAAC;AAc3F,eAAO,MAAM,uBAAuB,GAAI,KAAK,MAAM,KAAG,MAErD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,MAAK,MAAsB,KAAG,MAUxE,CAAC;AAUF,eAAO,MAAM,sBAAsB,GAAU,OAAO,OAAO,GAAG,SAAS,KAAG,OAAO,CAAC,IAAI,CAerF,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { EnvFileLoader } from '../utils/EnvFileLoader.js';
|
|
1
2
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
2
3
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import { existsSync } from '../../node-singletons/fs.js';
|
|
3
5
|
import * as path from '../../node-singletons/path.js';
|
|
4
6
|
export const parseIntOption = (raw, name, expectation = 'positive') => {
|
|
5
7
|
if (raw === undefined)
|
|
@@ -15,6 +17,29 @@ export const parseIntOption = (raw, name, expectation = 'positive') => {
|
|
|
15
17
|
return parsed;
|
|
16
18
|
};
|
|
17
19
|
export const trimOption = (value) => value?.trim();
|
|
20
|
+
const findNearestPackageJsonDir = (cwd) => {
|
|
21
|
+
let current = cwd;
|
|
22
|
+
while (true) {
|
|
23
|
+
if (existsSync(path.join(current, 'package.json')))
|
|
24
|
+
return current;
|
|
25
|
+
const parent = path.dirname(current);
|
|
26
|
+
if (parent === current)
|
|
27
|
+
return undefined;
|
|
28
|
+
current = parent;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export const resolveProxyProjectRoot = (cwd) => {
|
|
32
|
+
return findNearestPackageJsonDir(cwd) ?? cwd;
|
|
33
|
+
};
|
|
34
|
+
export const ensureProxyEnvLoadedForCwd = (cwd = process.cwd()) => {
|
|
35
|
+
const projectRoot = resolveProxyProjectRoot(cwd);
|
|
36
|
+
EnvFileLoader.ensureLoaded({
|
|
37
|
+
cwd: projectRoot,
|
|
38
|
+
includeCwd: true,
|
|
39
|
+
...(cwd === projectRoot ? {} : { extraCwds: [cwd] }),
|
|
40
|
+
});
|
|
41
|
+
return projectRoot;
|
|
42
|
+
};
|
|
18
43
|
const isWatchChild = () => process.env['ZINTRUST_PROXY_WATCH_CHILD'] === '1';
|
|
19
44
|
const buildWatchArgs = () => {
|
|
20
45
|
const rawArgs = process.argv.slice(2);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/RedisProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"RedisProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/RedisProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0DrE,eAAO,MAAM,iBAAiB;cAClB,YAAY;EAoCtB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
-
import { maybeRunProxyWatchMode, parseIntOption, trimOption, } from '../commands/ProxyCommandUtils.js';
|
|
2
|
+
import { ensureProxyEnvLoadedForCwd, maybeRunProxyWatchMode, parseIntOption, trimOption, } from '../commands/ProxyCommandUtils.js';
|
|
3
3
|
import { Env } from '../../config/env.js';
|
|
4
4
|
import { RedisProxyServer } from '../../proxy/redis/RedisProxyServer.js';
|
|
5
5
|
const addOptions = (command) => {
|
|
6
|
+
ensureProxyEnvLoadedForCwd();
|
|
6
7
|
command.option('--host <host>', 'Host to bind', Env.get('REDIS_PROXY_HOST', '127.0.0.1'));
|
|
7
8
|
command.option('--port <port>', 'Port to bind', String(Env.getInt('REDIS_PROXY_PORT', 8791)));
|
|
8
9
|
command.option('--max-body-bytes <bytes>', 'Max request size in bytes', String(Env.getInt('REDIS_PROXY_MAX_BODY_BYTES', 131072)));
|
|
@@ -11,7 +12,7 @@ const addOptions = (command) => {
|
|
|
11
12
|
command.option('--redis-port <port>', 'Redis port');
|
|
12
13
|
command.option('--redis-password <password>', 'Redis password');
|
|
13
14
|
command.option('--redis-db <db>', 'Redis database');
|
|
14
|
-
command.option('--require-signing', 'Require signed requests', Env.REDIS_PROXY_REQUIRE_SIGNING);
|
|
15
|
+
command.option('--require-signing', 'Require signed requests', Env.getBool('REDIS_PROXY_REQUIRE_SIGNING', true));
|
|
15
16
|
command.option('--key-id <id>', 'Signing key id', Env.get('REDIS_PROXY_KEY_ID', ''));
|
|
16
17
|
command.option('--secret <secret>', 'Signing secret', Env.get('REDIS_PROXY_SECRET', ''));
|
|
17
18
|
command.option('--signing-window-ms <ms>', 'Signing time window in ms', String(Env.getInt('REDIS_PROXY_SIGNING_WINDOW_MS', 60000)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SmtpProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/SmtpProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"SmtpProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/SmtpProxyCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA4DrE,eAAO,MAAM,gBAAgB;cACjB,YAAY;EAsCtB,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
-
import { maybeRunProxyWatchMode, parseIntOption, trimOption, } from '../commands/ProxyCommandUtils.js';
|
|
2
|
+
import { ensureProxyEnvLoadedForCwd, maybeRunProxyWatchMode, parseIntOption, trimOption, } from '../commands/ProxyCommandUtils.js';
|
|
3
3
|
import { Env } from '../../config/env.js';
|
|
4
4
|
import { SmtpProxyServer } from '../../proxy/smtp/SmtpProxyServer.js';
|
|
5
5
|
const addOptions = (command) => {
|
|
6
|
+
ensureProxyEnvLoadedForCwd();
|
|
6
7
|
command.option('--host <host>', 'Host to bind', Env.get('SMTP_PROXY_HOST', '127.0.0.1'));
|
|
7
8
|
command.option('--port <port>', 'Port to bind', String(Env.getInt('SMTP_PROXY_PORT', 8794)));
|
|
8
9
|
command.option('--max-body-bytes <bytes>', 'Max request size in bytes', String(Env.getInt('SMTP_PROXY_MAX_BODY_BYTES', 131072)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqlServerProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/SqlServerProxyCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SqlServerProxyCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/SqlServerProxyCommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2DpC,eAAO,MAAM,qBAAqB;cACtB,OAAO;EAwEjB,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Env } from '../../config/env.js';
|
|
2
|
+
import { ensureProxyEnvLoadedForCwd } from '../commands/ProxyCommandUtils.js';
|
|
2
3
|
import { Logger } from '../../config/logger.js';
|
|
3
4
|
import { Command } from 'commander';
|
|
4
5
|
const startWatchMode = async (options) => {
|
|
@@ -39,6 +40,7 @@ export const SqlServerProxyCommand = Object.freeze({
|
|
|
39
40
|
const cmd = new Command('proxy:sqlserver');
|
|
40
41
|
cmd.description('Start SQL Server HTTP proxy server');
|
|
41
42
|
const configureOptions = () => {
|
|
43
|
+
ensureProxyEnvLoadedForCwd();
|
|
42
44
|
cmd.option('--host <host>', 'Proxy host', Env.get('SQLSERVER_PROXY_HOST', '127.0.0.1'));
|
|
43
45
|
cmd.option('--port <port>', 'Proxy port', String(Env.getInt('SQLSERVER_PROXY_PORT', 8793)));
|
|
44
46
|
cmd.option('--db-host <host>', 'SQL Server host', Env.get('DB_HOST_MSSQL', '127.0.0.1'));
|
|
@@ -49,7 +51,7 @@ export const SqlServerProxyCommand = Object.freeze({
|
|
|
49
51
|
cmd.option('--connection-limit <limit>', 'Connection pool limit', String(Env.getInt('SQLSERVER_PROXY_POOL_LIMIT', 10)));
|
|
50
52
|
cmd.option('--key-id <keyId>', 'Signing key ID', Env.get('SQLSERVER_PROXY_KEY_ID', 'default'));
|
|
51
53
|
cmd.option('--secret <secret>', 'Signing secret', Env.get('SQLSERVER_PROXY_SECRET', ''));
|
|
52
|
-
cmd.option('--require-signing', 'Require request signing', Env.SQLSERVER_PROXY_REQUIRE_SIGNING);
|
|
54
|
+
cmd.option('--require-signing', 'Require request signing', Env.getBool('SQLSERVER_PROXY_REQUIRE_SIGNING', true));
|
|
53
55
|
cmd.option('--signing-window-ms <ms>', 'Signing window in milliseconds', String(Env.getInt('SQLSERVER_PROXY_SIGNING_WINDOW_MS', 60000)));
|
|
54
56
|
cmd.option('--watch', 'Watch mode: restart on file changes');
|
|
55
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WranglerProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/WranglerProxyCommandUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"WranglerProxyCommandUtils.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/WranglerProxyCommandUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkBrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,2BAA2B,GAAG,cAAc,GAAG;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,+BAA+B,CAAC,OAAO,EAAE,QAAQ,SAAS,2BAA2B,IAAI;IAC5F,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACvC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC;IAC3E,cAAc,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAC;IAC5C,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;CACjD,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,SAAS,OAAO,EAAE,eAAe,MAAM,KAAG,IAIrF,CAAC;AAMF,eAAO,MAAM,0BAA0B,GAAI,OAAO,EAAE,QAAQ,SAAS,2BAA2B,EAC9F,OAAO,+BAA+B,CAAC,OAAO,EAAE,QAAQ,CAAC,KACxD,YAoFF,CAAC"}
|
|
@@ -1,37 +1,18 @@
|
|
|
1
1
|
import { BaseCommand } from '../BaseCommand.js';
|
|
2
2
|
import { withWranglerDevVarsSnapshot } from '../cloudflare/CloudflareWranglerDevEnv.js';
|
|
3
|
-
import { maybeRunProxyWatchMode, parseIntOption } from '../commands/ProxyCommandUtils.js';
|
|
3
|
+
import { ensureProxyEnvLoadedForCwd, maybeRunProxyWatchMode, parseIntOption, } from '../commands/ProxyCommandUtils.js';
|
|
4
4
|
import { ensureProxyEntrypoint, ensureWranglerConfig, renderProxyWranglerDevConfig, resolveConfigPath, } from '../commands/ProxyScaffoldUtils.js';
|
|
5
|
-
import { EnvFileLoader } from '../utils/EnvFileLoader.js';
|
|
6
5
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
7
6
|
import { Logger } from '../../config/logger.js';
|
|
8
|
-
import {
|
|
7
|
+
import { mkdirSync, writeFileSync } from '../../node-singletons/fs.js';
|
|
9
8
|
import { dirname, join } from '../../node-singletons/path.js';
|
|
10
9
|
export const addWranglerProxyBaseOptions = (command, defaultConfig) => {
|
|
11
10
|
command.option('-c, --config <path>', 'Wrangler config file', defaultConfig);
|
|
12
11
|
command.option('--port <port>', 'Local Wrangler dev port');
|
|
13
12
|
command.option('--watch', 'Auto-restart proxy on file changes');
|
|
14
13
|
};
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
while (true) {
|
|
18
|
-
if (existsSync(join(current, 'package.json')))
|
|
19
|
-
return current;
|
|
20
|
-
const parent = dirname(current);
|
|
21
|
-
if (parent === current)
|
|
22
|
-
return undefined;
|
|
23
|
-
current = parent;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
const resolveProxyProjectRoot = (cwd) => {
|
|
27
|
-
return findNearestPackageJsonDir(cwd) ?? cwd;
|
|
28
|
-
};
|
|
29
|
-
const ensureProxyEnvLoaded = (cwd, projectRoot) => {
|
|
30
|
-
EnvFileLoader.ensureLoaded({
|
|
31
|
-
cwd: projectRoot,
|
|
32
|
-
includeCwd: true,
|
|
33
|
-
...(cwd === projectRoot ? {} : { extraCwds: [cwd] }),
|
|
34
|
-
});
|
|
14
|
+
const toRootedProxyConfigContent = (content) => {
|
|
15
|
+
return content.replaceAll('": "../../', '": "./');
|
|
35
16
|
};
|
|
36
17
|
export const createWranglerProxyCommand = (input) => {
|
|
37
18
|
return BaseCommand.create({
|
|
@@ -44,8 +25,7 @@ export const createWranglerProxyCommand = (input) => {
|
|
|
44
25
|
await maybeRunProxyWatchMode(typedOptions.watch);
|
|
45
26
|
const port = parseIntOption(typedOptions.port, 'port');
|
|
46
27
|
const cwd = process.cwd();
|
|
47
|
-
const projectRoot =
|
|
48
|
-
ensureProxyEnvLoaded(cwd, projectRoot);
|
|
28
|
+
const projectRoot = ensureProxyEnvLoadedForCwd(cwd);
|
|
49
29
|
const entrypoint = ensureProxyEntrypoint({
|
|
50
30
|
cwd,
|
|
51
31
|
entryFile: input.entryFile,
|
|
@@ -72,24 +52,23 @@ export const createWranglerProxyCommand = (input) => {
|
|
|
72
52
|
}
|
|
73
53
|
input.afterConfigResolved?.(result.values);
|
|
74
54
|
const proxyConfigContent = renderProxyWranglerDevConfig(result.content, input.envName);
|
|
75
|
-
const proxyConfigDir =
|
|
76
|
-
const proxyConfigPath = join(proxyConfigDir,
|
|
55
|
+
const proxyConfigDir = cwd;
|
|
56
|
+
const proxyConfigPath = join(proxyConfigDir, `.zin.proxy.${input.envName}.jsonc`);
|
|
77
57
|
if (proxyConfigContent !== undefined) {
|
|
78
58
|
mkdirSync(proxyConfigDir, { recursive: true });
|
|
79
|
-
writeFileSync(proxyConfigPath, proxyConfigContent, 'utf-8');
|
|
59
|
+
writeFileSync(proxyConfigPath, toRootedProxyConfigContent(proxyConfigContent), 'utf-8');
|
|
80
60
|
}
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
];
|
|
61
|
+
const wranglerRunConfigPath = proxyConfigContent === undefined ? configPath : proxyConfigPath;
|
|
62
|
+
const wranglerDevVarsCwd = proxyConfigContent === undefined ? cwd : dirname(proxyConfigPath);
|
|
63
|
+
const wranglerDevVarsEnvName = proxyConfigContent === undefined ? input.envName : '';
|
|
64
|
+
const args = ['dev', '--config', wranglerRunConfigPath];
|
|
86
65
|
if (port !== undefined) {
|
|
87
66
|
args.push('--port', String(port));
|
|
88
67
|
}
|
|
89
68
|
const exitCode = await withWranglerDevVarsSnapshot({
|
|
90
|
-
cwd,
|
|
69
|
+
cwd: wranglerDevVarsCwd,
|
|
91
70
|
projectRoot,
|
|
92
|
-
envName:
|
|
71
|
+
envName: wranglerDevVarsEnvName,
|
|
93
72
|
configPath,
|
|
94
73
|
runtimeEnv: process.env,
|
|
95
74
|
}, async () => {
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.4.
|
|
2
|
+
* @zintrust/core v0.4.81
|
|
3
3
|
*
|
|
4
4
|
* ZinTrust Framework - Production-Grade TypeScript Backend
|
|
5
5
|
* Built for performance, type safety, and exceptional developer experience
|
|
6
6
|
*
|
|
7
7
|
* Build Information:
|
|
8
|
-
* Built: 2026-04-
|
|
8
|
+
* Built: 2026-04-08T13:57:15.723Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Available at runtime for debugging and health checks
|
|
22
22
|
*/
|
|
23
23
|
export const ZINTRUST_VERSION = '0.1.41';
|
|
24
|
-
export const ZINTRUST_BUILD_DATE = '2026-04-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-04-08T13:57:15.665Z'; // Replaced during build
|
|
25
25
|
export { Application } from './boot/Application.js';
|
|
26
26
|
export { AwsSigV4 } from './common/index.js';
|
|
27
27
|
export { SignedRequest } from './security/SignedRequest.js';
|