@zintrust/core 0.7.2 → 0.7.3
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/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KVRemoteDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVRemoteDriver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"KVRemoteDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVRemoteDriver.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA6YtD,eAAO,MAAM,cAAc;kBAvEM,WAAW;EAyE1C,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -206,6 +206,25 @@ const createCloudflareKvApiClient = (resolveNamespaceId) => {
|
|
|
206
206
|
};
|
|
207
207
|
return { getJson, putJson, deleteKey };
|
|
208
208
|
};
|
|
209
|
+
const logKvRemoteProxyFallback = (operation, error) => {
|
|
210
|
+
Logger.warn(`KV remote proxy ${operation} failed; falling back to Cloudflare KV API`, Logger.withTraceSkipContext({
|
|
211
|
+
error: error instanceof Error ? error.message : String(error),
|
|
212
|
+
}));
|
|
213
|
+
};
|
|
214
|
+
const clearKvRemoteDriver = async () => {
|
|
215
|
+
Logger.warn('KV remote clear() is not implemented.');
|
|
216
|
+
await Promise.resolve();
|
|
217
|
+
};
|
|
218
|
+
const createKvRemoteHas = (getJson) => {
|
|
219
|
+
return async function has(key) {
|
|
220
|
+
if (!hasCloudflareApiCreds())
|
|
221
|
+
return (await this.get(key)) !== null;
|
|
222
|
+
const settings = getSettings();
|
|
223
|
+
if (!hasProxySigningCreds(settings))
|
|
224
|
+
return (await getJson(key)) !== null;
|
|
225
|
+
return (await this.get(key)) !== null;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
209
228
|
const createKvRemoteDriver = () => {
|
|
210
229
|
const resolveNamespaceId = createCloudflareNamespaceIdResolver();
|
|
211
230
|
const cf = createCloudflareKvApiClient(resolveNamespaceId);
|
|
@@ -226,11 +245,7 @@ const createKvRemoteDriver = () => {
|
|
|
226
245
|
catch (error) {
|
|
227
246
|
if (!hasCloudflareApiCreds())
|
|
228
247
|
throw error;
|
|
229
|
-
|
|
230
|
-
...Logger.withTraceSkipContext({
|
|
231
|
-
error: error instanceof Error ? error.message : String(error),
|
|
232
|
-
}),
|
|
233
|
-
});
|
|
248
|
+
logKvRemoteProxyFallback('GET', error);
|
|
234
249
|
return cf.getJson(key);
|
|
235
250
|
}
|
|
236
251
|
},
|
|
@@ -252,11 +267,7 @@ const createKvRemoteDriver = () => {
|
|
|
252
267
|
catch (error) {
|
|
253
268
|
if (!hasCloudflareApiCreds())
|
|
254
269
|
throw error;
|
|
255
|
-
|
|
256
|
-
...Logger.withTraceSkipContext({
|
|
257
|
-
error: error instanceof Error ? error.message : String(error),
|
|
258
|
-
}),
|
|
259
|
-
});
|
|
270
|
+
logKvRemoteProxyFallback('PUT', error);
|
|
260
271
|
await cf.putJson(key, value, ttl);
|
|
261
272
|
}
|
|
262
273
|
},
|
|
@@ -276,26 +287,12 @@ const createKvRemoteDriver = () => {
|
|
|
276
287
|
catch (error) {
|
|
277
288
|
if (!hasCloudflareApiCreds())
|
|
278
289
|
throw error;
|
|
279
|
-
|
|
280
|
-
...Logger.withTraceSkipContext({
|
|
281
|
-
error: error instanceof Error ? error.message : String(error),
|
|
282
|
-
}),
|
|
283
|
-
});
|
|
290
|
+
logKvRemoteProxyFallback('DELETE', error);
|
|
284
291
|
await cf.deleteKey(key);
|
|
285
292
|
}
|
|
286
293
|
},
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
await Promise.resolve();
|
|
290
|
-
},
|
|
291
|
-
async has(key) {
|
|
292
|
-
if (!hasCloudflareApiCreds())
|
|
293
|
-
return (await this.get(key)) !== null;
|
|
294
|
-
const settings = getSettings();
|
|
295
|
-
if (!hasProxySigningCreds(settings))
|
|
296
|
-
return (await cf.getJson(key)) !== null;
|
|
297
|
-
return (await this.get(key)) !== null;
|
|
298
|
-
},
|
|
294
|
+
clear: clearKvRemoteDriver,
|
|
295
|
+
has: createKvRemoteHas(cf.getJson),
|
|
299
296
|
};
|
|
300
297
|
};
|
|
301
298
|
export const KVRemoteDriver = Object.freeze({
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.7.
|
|
2
|
+
* @zintrust/core v0.7.3
|
|
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-18T19:
|
|
8
|
+
* Built: 2026-04-18T19:50:18.473Z
|
|
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-18T19:
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-04-18T19:50:18.439Z'; // 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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProxyServerUtils.d.ts","sourceRoot":"","sources":["../../../src/proxy/ProxyServerUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProxyServerUtils.d.ts","sourceRoot":"","sources":["../../../src/proxy/ProxyServerUtils.ts"],"names":[],"mappings":"AA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|
@@ -1,7 +1,38 @@
|
|
|
1
1
|
import { Env } from '../config/env.js';
|
|
2
2
|
import { Logger } from '../config/logger.js';
|
|
3
|
+
import { isNonEmptyString } from '../helper/index.js';
|
|
3
4
|
import { resolveProxySigningConfig } from './ProxySigningConfigResolver.js';
|
|
4
5
|
import { extractSigningHeaders, verifyProxySignatureIfNeeded } from './ProxySigningRequest.js';
|
|
6
|
+
const PROXY_DEBUG_ENV_BY_SERVICE = Object.freeze({
|
|
7
|
+
MySQLProxyServer: 'MYSQL_PROXY_DEBUG',
|
|
8
|
+
PostgresProxyServer: 'POSTGRES_PROXY_DEBUG',
|
|
9
|
+
RedisProxyServer: 'REDIS_PROXY_DEBUG',
|
|
10
|
+
SqlServerProxyServer: 'SQLSERVER_PROXY_DEBUG',
|
|
11
|
+
});
|
|
12
|
+
const parseProxyDebugValue = (raw) => {
|
|
13
|
+
const normalized = raw.trim().toLowerCase();
|
|
14
|
+
if (normalized === 'true' || normalized === '1' || normalized === 'yes')
|
|
15
|
+
return true;
|
|
16
|
+
if (normalized === 'false' || normalized === '0' || normalized === 'no')
|
|
17
|
+
return false;
|
|
18
|
+
return undefined;
|
|
19
|
+
};
|
|
20
|
+
const resolveProxyDebugEnabled = (serviceName) => {
|
|
21
|
+
const serviceEnvKey = PROXY_DEBUG_ENV_BY_SERVICE[serviceName];
|
|
22
|
+
const serviceRaw = serviceEnvKey ? Env.get(serviceEnvKey, '') : '';
|
|
23
|
+
if (isNonEmptyString(serviceRaw)) {
|
|
24
|
+
const parsed = parseProxyDebugValue(serviceRaw);
|
|
25
|
+
if (parsed !== undefined)
|
|
26
|
+
return parsed;
|
|
27
|
+
}
|
|
28
|
+
const sharedRaw = Env.get('ZT_PROXY_DEBUG', '');
|
|
29
|
+
if (isNonEmptyString(sharedRaw)) {
|
|
30
|
+
const parsed = parseProxyDebugValue(sharedRaw);
|
|
31
|
+
if (parsed !== undefined)
|
|
32
|
+
return parsed;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
};
|
|
5
36
|
export const resolveBaseConfig = (overrides, prefix, defaults) => {
|
|
6
37
|
const host = overrides.host ?? Env.get(`${prefix}_PROXY_HOST`, Env.HOST ?? defaults?.host ?? '127.0.0.1');
|
|
7
38
|
const port = overrides.port ?? Env.getInt(`${prefix}_PROXY_PORT`, Env.PORT ?? defaults?.port ?? 3000);
|
|
@@ -18,17 +49,19 @@ export const resolveBaseSigningConfig = (overrides, prefix) => resolveProxySigni
|
|
|
18
49
|
export const verifyRequestSignature = async (req, body, config, serviceName) => {
|
|
19
50
|
const headers = extractSigningHeaders(req);
|
|
20
51
|
const hasAnySigningHeader = Object.values(headers).some((value) => typeof value === 'string' && value.trim() !== '');
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
if (resolveProxyDebugEnabled(serviceName)) {
|
|
53
|
+
Logger.debug(`[${serviceName}] Verifying request signature`, {
|
|
54
|
+
...Logger.withTraceSkipContext({
|
|
55
|
+
path: req.url ?? '',
|
|
56
|
+
method: req.method ?? 'POST',
|
|
57
|
+
requireSigning: config.signing.require,
|
|
58
|
+
hasAnySigningHeader,
|
|
59
|
+
configuredKeyId: config.signing.keyId,
|
|
60
|
+
hasConfiguredSecret: config.signing.secret.trim() !== '',
|
|
61
|
+
bodyBytes: body.length,
|
|
62
|
+
}),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
32
65
|
const verified = await verifyProxySignatureIfNeeded(req, body, config.signing);
|
|
33
66
|
if (!verified.ok) {
|
|
34
67
|
const error = verified.error ?? { status: 401, message: 'Unauthorized' };
|