@zintrust/core 0.7.7 → 0.7.9
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 +1 -1
- package/src/auth/LoginFlow.d.ts +7 -1
- package/src/auth/LoginFlow.d.ts.map +1 -1
- package/src/auth/LoginFlow.js +98 -2
- package/src/cli/OptionalCliExtensions.d.ts +1 -0
- package/src/cli/OptionalCliExtensions.d.ts.map +1 -1
- package/src/cli/OptionalCliExtensions.js +24 -2
- package/src/cli/commands/MySqlProxyCommand.d.ts.map +1 -1
- package/src/cli/commands/MySqlProxyCommand.js +1 -1
- package/src/cli/commands/RoutesCommand.d.ts.map +1 -1
- package/src/cli/commands/RoutesCommand.js +39 -2
- package/src/cli/commands/ScheduleStartCommand.d.ts.map +1 -1
- package/src/cli/commands/ScheduleStartCommand.js +14 -9
- package/src/cli/commands/schedule/ScheduleCliSupport.d.ts.map +1 -1
- package/src/cli/commands/schedule/ScheduleCliSupport.js +29 -4
- package/src/config/env.d.ts +2 -0
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +2 -0
- package/src/http/Request.d.ts +1 -0
- package/src/http/Request.d.ts.map +1 -1
- package/src/http/Request.js +3 -0
- package/src/index.d.ts +8 -4
- package/src/index.d.ts.map +1 -1
- package/src/index.js +7 -4
- package/src/middleware/BulletproofAuthMiddleware.d.ts +2 -1
- package/src/middleware/BulletproofAuthMiddleware.d.ts.map +1 -1
- package/src/middleware/BulletproofAuthMiddleware.js +106 -36
- package/src/runtime/useFileLoader.d.ts +5 -0
- package/src/runtime/useFileLoader.d.ts.map +1 -1
- package/src/runtime/useFileLoader.js +58 -37
- package/src/security/BulletproofDeviceStore.d.ts +18 -0
- package/src/security/BulletproofDeviceStore.d.ts.map +1 -0
- package/src/security/BulletproofDeviceStore.js +243 -0
- package/src/security/JwtVerifier.d.ts +75 -0
- package/src/security/JwtVerifier.d.ts.map +1 -0
- package/src/security/JwtVerifier.js +336 -0
- package/src/templates/project/basic/app/Controllers/AuthController.ts.tpl +24 -10
- package/src/templates/project/basic/config/trace.ts.tpl +73 -0
- package/src/templates/project/basic/database/migrations/20260419000000_create_bulletproof_devices_table.ts.tpl +36 -0
package/package.json
CHANGED
package/src/auth/LoginFlow.d.ts
CHANGED
|
@@ -24,6 +24,12 @@ export type LoginFlowIssuerInput<TContext = unknown> = {
|
|
|
24
24
|
verified: LoginFlowVerifiedRecord;
|
|
25
25
|
context: TContext;
|
|
26
26
|
};
|
|
27
|
+
export type BulletproofJwtIssued = Readonly<{
|
|
28
|
+
token: string;
|
|
29
|
+
token_type: 'Bearer';
|
|
30
|
+
deviceId: string;
|
|
31
|
+
deviceSecret: string;
|
|
32
|
+
}>;
|
|
27
33
|
export type LoginFlowIssuer<TContext = unknown> = (input: LoginFlowIssuerInput<TContext>) => Promise<unknown>;
|
|
28
34
|
export type LoginFlowAuditEvent<TContext = unknown> = {
|
|
29
35
|
status: 'success' | 'failed';
|
|
@@ -36,7 +42,7 @@ export type LoginFlowAuditEvent<TContext = unknown> = {
|
|
|
36
42
|
error?: unknown;
|
|
37
43
|
context: TContext;
|
|
38
44
|
};
|
|
39
|
-
export type LoginFlowAuditor<TContext = unknown> = (event: LoginFlowAuditEvent<TContext>) => Promise<void>;
|
|
45
|
+
export type LoginFlowAuditor<TContext = unknown> = (event: LoginFlowAuditEvent<TContext>) => void | Promise<void>;
|
|
40
46
|
export type LoginFlowCreateOptions<TContext = unknown> = {
|
|
41
47
|
provider: string | LoginFlowProvider<TContext>;
|
|
42
48
|
context: TContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoginFlow.d.ts","sourceRoot":"","sources":["../../../src/auth/LoginFlow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoginFlow.d.ts","sourceRoot":"","sources":["../../../src/auth/LoginFlow.ts"],"names":[],"mappings":"AAaA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEnE,MAA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th/LoginFlow.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { SystemTraceBridge } from '../trace/SystemTraceBridge.js';
|
|
2
2
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
3
3
|
import { isFunction, isNonEmptyString, isObject } from '../helper/index.js';
|
|
4
|
+
import { detectRuntimePlatform, RuntimeServices, } from '../runtime/RuntimeServices.js';
|
|
5
|
+
import { BulletproofDeviceStore, } from '../security/BulletproofDeviceStore.js';
|
|
4
6
|
import { JwtManager } from '../security/JwtManager.js';
|
|
5
7
|
const providerRegistry = new Map();
|
|
6
8
|
const issuerRegistry = new Map();
|
|
@@ -98,12 +100,105 @@ const createJwtIssuer = async ({ verified, }) => {
|
|
|
98
100
|
}
|
|
99
101
|
return JwtManager.signAccessToken(claims);
|
|
100
102
|
};
|
|
101
|
-
const
|
|
103
|
+
const getContextRecord = (context) => {
|
|
104
|
+
return isObject(context) ? context : {};
|
|
105
|
+
};
|
|
106
|
+
const getContextRequest = (context) => {
|
|
107
|
+
const request = getContextRecord(context)['request'];
|
|
108
|
+
return isObject(request) ? request : undefined;
|
|
109
|
+
};
|
|
110
|
+
const getContextString = (context, key) => {
|
|
111
|
+
const value = getContextRecord(context)[key];
|
|
112
|
+
return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
|
|
113
|
+
};
|
|
114
|
+
const getBodyString = (request, key) => {
|
|
115
|
+
if (request === undefined || typeof request.getBody !== 'function')
|
|
116
|
+
return undefined;
|
|
117
|
+
const body = request.getBody();
|
|
118
|
+
if (!isObject(body))
|
|
119
|
+
return undefined;
|
|
120
|
+
const value = body[key];
|
|
121
|
+
return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
|
|
122
|
+
};
|
|
123
|
+
const getRequestHeaderString = (request, name) => {
|
|
124
|
+
if (request === undefined || typeof request.getHeader !== 'function')
|
|
125
|
+
return undefined;
|
|
126
|
+
const value = request.getHeader(name);
|
|
127
|
+
if (Array.isArray(value)) {
|
|
128
|
+
return typeof value[0] === 'string' && value[0].trim() !== '' ? value[0].trim() : undefined;
|
|
129
|
+
}
|
|
130
|
+
return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;
|
|
131
|
+
};
|
|
132
|
+
const bytesToHex = (bytes) => {
|
|
133
|
+
let out = '';
|
|
134
|
+
for (const byte of bytes)
|
|
135
|
+
out += byte.toString(16).padStart(2, '0');
|
|
136
|
+
return out;
|
|
137
|
+
};
|
|
138
|
+
const getRuntimeCrypto = () => RuntimeServices.create(detectRuntimePlatform()).crypto;
|
|
139
|
+
const generateDeviceId = () => {
|
|
140
|
+
const bytes = getRuntimeCrypto().getRandomValues(new Uint8Array(16));
|
|
141
|
+
return `dev_${bytesToHex(bytes)}`;
|
|
142
|
+
};
|
|
143
|
+
const generateDeviceSecret = () => {
|
|
144
|
+
const bytes = getRuntimeCrypto().getRandomValues(new Uint8Array(32));
|
|
145
|
+
return `hex:${bytesToHex(bytes)}`;
|
|
146
|
+
};
|
|
147
|
+
const getClaimedDeviceId = (claims) => {
|
|
148
|
+
const deviceId = claims['deviceId'];
|
|
149
|
+
return typeof deviceId === 'string' && deviceId.trim() !== '' ? deviceId.trim() : undefined;
|
|
150
|
+
};
|
|
151
|
+
const resolveBulletproofDeviceId = (context, request, claims) => {
|
|
152
|
+
return (getContextString(context, 'deviceId') ??
|
|
153
|
+
getBodyString(request, 'deviceId') ??
|
|
154
|
+
getClaimedDeviceId(claims) ??
|
|
155
|
+
generateDeviceId());
|
|
156
|
+
};
|
|
157
|
+
const resolveBulletproofUserId = (context, verified) => {
|
|
158
|
+
const subjectUserId = isNonEmptyString(verified.subject) ? verified.subject.trim() : undefined;
|
|
159
|
+
const verifiedUserId = isObject(verified.user) && verified.user['id'] !== undefined
|
|
160
|
+
? String(verified.user['id'])
|
|
161
|
+
: undefined;
|
|
162
|
+
return getContextString(context, 'userId') ?? subjectUserId ?? verifiedUserId;
|
|
163
|
+
};
|
|
164
|
+
const buildBulletproofDeviceRecord = (context, verified, request, claims, deviceSecret) => {
|
|
165
|
+
const deviceId = resolveBulletproofDeviceId(context, request, claims);
|
|
166
|
+
const userId = resolveBulletproofUserId(context, verified);
|
|
167
|
+
const userAgent = getRequestHeaderString(request, 'user-agent');
|
|
168
|
+
return {
|
|
169
|
+
deviceId,
|
|
170
|
+
record: {
|
|
171
|
+
deviceId,
|
|
172
|
+
signingSecret: deviceSecret,
|
|
173
|
+
lastSeenAt: new Date(),
|
|
174
|
+
...(isNonEmptyString(userId) ? { userId } : {}),
|
|
175
|
+
...(userAgent === undefined ? {} : { userAgent }),
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
const createBulletproofIssuer = async ({ verified, context, }) => {
|
|
180
|
+
const claims = isObject(verified.claims) ? { ...verified.claims } : {};
|
|
181
|
+
if (isNonEmptyString(verified.subject) && !isNonEmptyString(claims.sub)) {
|
|
182
|
+
claims.sub = verified.subject;
|
|
183
|
+
}
|
|
184
|
+
const request = getContextRequest(context);
|
|
185
|
+
const deviceSecret = generateDeviceSecret();
|
|
186
|
+
const { deviceId, record } = buildBulletproofDeviceRecord(context, verified, request, claims, deviceSecret);
|
|
187
|
+
claims['deviceId'] = deviceId;
|
|
188
|
+
await BulletproofDeviceStore.upsert(record);
|
|
189
|
+
const token = await JwtManager.signAccessToken(claims);
|
|
190
|
+
return Object.freeze({
|
|
191
|
+
token,
|
|
192
|
+
token_type: 'Bearer',
|
|
193
|
+
deviceId,
|
|
194
|
+
deviceSecret,
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
const createTraceAuditor = (event) => {
|
|
102
198
|
const subject = typeof event.verified?.subject === 'string' && event.verified.subject.trim() !== ''
|
|
103
199
|
? event.verified.subject
|
|
104
200
|
: undefined;
|
|
105
201
|
SystemTraceBridge.emitAuth(event.status === 'success' ? 'login' : 'failed', subject);
|
|
106
|
-
return Promise.resolve();
|
|
107
202
|
};
|
|
108
203
|
const ensureNamedRegistration = (kind, name) => {
|
|
109
204
|
if (!isNonEmptyString(name)) {
|
|
@@ -334,6 +429,7 @@ const clearRegistrations = () => {
|
|
|
334
429
|
issuerRegistry.clear();
|
|
335
430
|
auditorRegistry.clear();
|
|
336
431
|
issuerRegistry.set('jwt', createJwtIssuer);
|
|
432
|
+
issuerRegistry.set('bulletproof', createBulletproofIssuer);
|
|
337
433
|
auditorRegistry.set('trace', createTraceAuditor);
|
|
338
434
|
};
|
|
339
435
|
clearRegistrations();
|
|
@@ -24,6 +24,7 @@ export declare const OptionalCliExtensions: Readonly<{
|
|
|
24
24
|
findRequestedExtension: (args: string[]) => OptionalCliExtension | undefined;
|
|
25
25
|
}>;
|
|
26
26
|
export declare const OptionalCliExtensionsInternal: Readonly<{
|
|
27
|
+
loadAllInstalledExtensions: () => Promise<OptionalCliExtensionStatus[]>;
|
|
27
28
|
getProjectCwd: () => string;
|
|
28
29
|
resolveProjectRoot: () => string;
|
|
29
30
|
resolveProjectInstalledUrl: (entry: OptionalCliExtension, options?: OptionalCliExtensionLoadOptions) => string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionalCliExtensions.d.ts","sourceRoot":"","sources":["../../../src/cli/OptionalCliExtensions.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,KAAK,8BAA8B,GAAG,SAAS,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE3F,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM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M;wCA+G5B,oBAAoB,YACjB,+BAA+B,KACxC,MAAM,GAAG,IAAI;kCAzGqB,+BAA+B,KAAG,OAAO;4BAMnE,MAAM,QACT,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACnB,+BAA+B,KACxC,IAAI;8CAsHE,oBAAoB,YACjB,+BAA+B,KACxC,OAAO,CAAC,OAAO,CAAC;qCA0BV,oBAAoB,YACjB,+BAA+B,KACxC,OAAO,CAAC,OAAO,CAAC;uCAgCV,oBAAoB,YACjB,+BAA+B,KACxC,OAAO,CAAC,OAAO,CAAC;gCAuBV,oBAAoB,YACjB,+BAA+B,KACxC,OAAO,CAAC,0BAA0B,CAAC;gCAmDH,MAAM,EAAE,KAAG,MAAM,GAAG,SAAS;mCAU1B,MAAM,EAAE,KAAG,oBAAoB,GAAG,SAAS;8BAOhD,MAAM,EAAE,KAAG,OAAO;uCAlNT,oBAAoB,KAAG,MAAM,EAAE;gCAwBtC,oBAAoB,KAAG,MAAM,EAAE;EAgQhE,CAAC"}
|
|
@@ -13,11 +13,23 @@ const getProjectCwd = () => {
|
|
|
13
13
|
}
|
|
14
14
|
return packageRoot;
|
|
15
15
|
};
|
|
16
|
+
const findNearestPackageJsonDir = (cwd) => {
|
|
17
|
+
let current = cwd;
|
|
18
|
+
while (true) {
|
|
19
|
+
if (existsSync(path.join(current, 'package.json')))
|
|
20
|
+
return current;
|
|
21
|
+
const parent = path.dirname(current);
|
|
22
|
+
if (parent === current)
|
|
23
|
+
return undefined;
|
|
24
|
+
current = parent;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
16
27
|
const resolveProjectRoot = () => {
|
|
17
28
|
const configured = readEnvString('ZINTRUST_PROJECT_ROOT').trim();
|
|
18
29
|
if (configured !== '')
|
|
19
30
|
return configured;
|
|
20
|
-
|
|
31
|
+
const cwd = getProjectCwd();
|
|
32
|
+
return findNearestPackageJsonDir(cwd) ?? cwd;
|
|
21
33
|
};
|
|
22
34
|
const shouldLogFailures = (options) => {
|
|
23
35
|
if (options?.logFailures === true)
|
|
@@ -86,6 +98,7 @@ const OPTIONAL_CLI_EXTENSIONS = Object.freeze([
|
|
|
86
98
|
],
|
|
87
99
|
},
|
|
88
100
|
]);
|
|
101
|
+
let installedExtensionsPromise;
|
|
89
102
|
const getProjectLocalCandidates = (entry) => {
|
|
90
103
|
const projectRoot = resolveProjectRoot();
|
|
91
104
|
if (projectRoot === packageRoot)
|
|
@@ -220,6 +233,13 @@ const tryImportExtension = async (entry, options) => {
|
|
|
220
233
|
source: 'missing',
|
|
221
234
|
};
|
|
222
235
|
};
|
|
236
|
+
const loadAllInstalledExtensions = async () => {
|
|
237
|
+
return OPTIONAL_CLI_EXTENSIONS.reduce(async (statusesPromise, entry) => {
|
|
238
|
+
const statuses = await statusesPromise;
|
|
239
|
+
const status = await tryImportExtension(entry, { logFailures: false });
|
|
240
|
+
return [...statuses, status];
|
|
241
|
+
}, Promise.resolve([]));
|
|
242
|
+
};
|
|
223
243
|
const getRequestedCommand = (args) => {
|
|
224
244
|
if (args.length === 0)
|
|
225
245
|
return undefined;
|
|
@@ -244,7 +264,8 @@ const isRootHelpRequest = (args) => {
|
|
|
244
264
|
};
|
|
245
265
|
export const OptionalCliExtensions = Object.freeze({
|
|
246
266
|
async tryImportInstalledExtensions() {
|
|
247
|
-
|
|
267
|
+
installedExtensionsPromise ??= loadAllInstalledExtensions();
|
|
268
|
+
return installedExtensionsPromise;
|
|
248
269
|
},
|
|
249
270
|
async loadForArgs(args) {
|
|
250
271
|
const requestedExtension = findRequestedExtension(args);
|
|
@@ -272,6 +293,7 @@ export const OptionalCliExtensions = Object.freeze({
|
|
|
272
293
|
findRequestedExtension,
|
|
273
294
|
});
|
|
274
295
|
export const OptionalCliExtensionsInternal = Object.freeze({
|
|
296
|
+
loadAllInstalledExtensions,
|
|
275
297
|
getProjectCwd,
|
|
276
298
|
resolveProjectRoot,
|
|
277
299
|
resolveProjectInstalledUrl,
|
|
@@ -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;AA+BrE,eAAO,MAAM,iBAAiB;cAClB,YAAY;EActB,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -2,7 +2,6 @@ import { BaseCommand } from '../BaseCommand.js';
|
|
|
2
2
|
import { ensureProxyEnvLoadedForCwd } from '../commands/ProxyCommandUtils.js';
|
|
3
3
|
import { addSqlProxyOptions, runSqlProxyCommand, } from '../commands/SqlProxyCommandUtils.js';
|
|
4
4
|
import { Env } from '../../config/env.js';
|
|
5
|
-
import { MySqlProxyServer } from '../../proxy/mysql/MySqlProxyServer.js';
|
|
6
5
|
const addOptions = (command) => {
|
|
7
6
|
ensureProxyEnvLoadedForCwd();
|
|
8
7
|
addSqlProxyOptions(command, {
|
|
@@ -25,6 +24,7 @@ export const MySqlProxyCommand = Object.freeze({
|
|
|
25
24
|
addOptions,
|
|
26
25
|
execute: async (options) => {
|
|
27
26
|
await runSqlProxyCommand(options, async (input) => {
|
|
27
|
+
const { MySqlProxyServer } = await import('../../proxy/mysql/MySqlProxyServer.js');
|
|
28
28
|
await MySqlProxyServer.start(input);
|
|
29
29
|
});
|
|
30
30
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutesCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/RoutesCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"RoutesCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/RoutesCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAoYvF,eAAO,MAAM,aAAa;cACd,YAAY;EAatB,CAAC;AAEH,eAAe,aAAa,CAAC"}
|
|
@@ -9,6 +9,8 @@ import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
|
9
9
|
import { isObject } from '../../helper/index.js';
|
|
10
10
|
import { getServicePrefix } from '../../microservices/ServiceManifest.js';
|
|
11
11
|
import { ProjectRuntime } from '../../runtime/ProjectRuntime.js';
|
|
12
|
+
import { resolveNodeProjectRoot } from '../../runtime/resolveNodeProjectRoot.js';
|
|
13
|
+
import { useFileLoader } from '../../runtime/useFileLoader.js';
|
|
12
14
|
const parseGroupBy = (value) => {
|
|
13
15
|
const raw = typeof value === 'string' ? value.trim().toLowerCase() : '';
|
|
14
16
|
if (raw === '' || raw === 'group')
|
|
@@ -194,6 +196,39 @@ const registerManifestRoutes = async (router) => {
|
|
|
194
196
|
}
|
|
195
197
|
}
|
|
196
198
|
};
|
|
199
|
+
const ensureProjectRootEnv = async () => {
|
|
200
|
+
const projectRoot = await resolveNodeProjectRoot();
|
|
201
|
+
if ((process.env['ZINTRUST_PROJECT_ROOT'] ?? '').trim() === '') {
|
|
202
|
+
process.env['ZINTRUST_PROJECT_ROOT'] = projectRoot;
|
|
203
|
+
}
|
|
204
|
+
return projectRoot;
|
|
205
|
+
};
|
|
206
|
+
const loadProjectRouteRegistrar = async () => {
|
|
207
|
+
await ensureProjectRootEnv();
|
|
208
|
+
const loader = useFileLoader('routes/api.ts');
|
|
209
|
+
if (loader.exists()) {
|
|
210
|
+
try {
|
|
211
|
+
const routeModule = await loader.getModule();
|
|
212
|
+
const registerRoutes = isObject(routeModule) ? routeModule['registerRoutes'] : undefined;
|
|
213
|
+
if (typeof registerRoutes === 'function') {
|
|
214
|
+
return registerRoutes;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// Fall back to the framework alias import when the project file cannot be imported.
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
const routeModule = (await import('../../../routes/api.js'));
|
|
223
|
+
const registerRoutes = isObject(routeModule) ? routeModule['registerRoutes'] : undefined;
|
|
224
|
+
return typeof registerRoutes === 'function'
|
|
225
|
+
? registerRoutes
|
|
226
|
+
: undefined;
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
197
232
|
const buildRows = async (options) => {
|
|
198
233
|
const groupBy = parseGroupBy(options.groupBy);
|
|
199
234
|
const filterText = typeof options.filter === 'string' ? options.filter.trim().toLowerCase() : '';
|
|
@@ -205,8 +240,10 @@ const buildRows = async (options) => {
|
|
|
205
240
|
registerCoreRoutes(router);
|
|
206
241
|
// 2. Try to load application routes if available
|
|
207
242
|
try {
|
|
208
|
-
const
|
|
209
|
-
registerRoutes
|
|
243
|
+
const registerRoutes = await loadProjectRouteRegistrar();
|
|
244
|
+
if (typeof registerRoutes === 'function') {
|
|
245
|
+
registerRoutes(router);
|
|
246
|
+
}
|
|
210
247
|
}
|
|
211
248
|
catch {
|
|
212
249
|
// routes/api.ts not found, continue with just core routes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScheduleStartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ScheduleStartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"ScheduleStartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ScheduleStartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAqDrE,eAAO,MAAM,oBAAoB;cACrB,YAAY;EAOtB,CAAC;AAEH,eAAe,oBAAoB,CAAC"}
|
|
@@ -21,15 +21,20 @@ const execute = async (_options) => {
|
|
|
21
21
|
if (await ScheduleCliSupport.ensureProjectSourceContext()) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
try {
|
|
25
|
+
await ScheduleCliSupport.registerAll();
|
|
26
|
+
const registeredCount = SchedulerRuntime.list().length;
|
|
27
|
+
Logger.info('Starting schedules daemon', { registeredCount });
|
|
28
|
+
SchedulerRuntime.start();
|
|
29
|
+
const signal = await waitForSignal();
|
|
30
|
+
Logger.info('Stopping schedules daemon', { signal });
|
|
31
|
+
const timeoutMs = Env.getInt('SCHEDULE_SHUTDOWN_TIMEOUT_MS', 30000);
|
|
32
|
+
await SchedulerRuntime.stop(timeoutMs);
|
|
33
|
+
Logger.info('Schedules daemon stopped');
|
|
34
|
+
}
|
|
35
|
+
finally {
|
|
36
|
+
await ScheduleCliSupport.shutdownCliResources();
|
|
37
|
+
}
|
|
33
38
|
};
|
|
34
39
|
export const ScheduleStartCommand = Object.freeze({
|
|
35
40
|
create() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScheduleCliSupport.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/schedule/ScheduleCliSupport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScheduleCliSupport.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/schedule/ScheduleCliSupport.ts"],"names":[],"mappings":"AAyPA,eAAO,MAAM,kBAAkB;sCAzEc,OAAO,CAAC,OAAO,CAAC;mBA2EtC,OAAO,CAAC,IAAI,CAAC;gCA3BG,OAAO,CAAC,IAAI,CAAC;EAqClD,CAAC;AAEH,eAAe,kBAAkB,CAAC"}
|
|
@@ -14,6 +14,28 @@ const isSchedule = (value) => {
|
|
|
14
14
|
return false;
|
|
15
15
|
return 'name' in value && typeof value.name === 'string';
|
|
16
16
|
};
|
|
17
|
+
const getDefaultExport = (moduleNamespace) => {
|
|
18
|
+
return Object.hasOwn(moduleNamespace, 'default') ? moduleNamespace['default'] : undefined;
|
|
19
|
+
};
|
|
20
|
+
const flattenScheduleCandidates = (moduleNamespace) => {
|
|
21
|
+
const candidates = [
|
|
22
|
+
...Object.values(moduleNamespace),
|
|
23
|
+
getDefaultExport(moduleNamespace),
|
|
24
|
+
];
|
|
25
|
+
return candidates.flatMap((value) => (Array.isArray(value) ? value : [value]));
|
|
26
|
+
};
|
|
27
|
+
const collectSchedules = (moduleNamespace) => {
|
|
28
|
+
const flattenedCandidates = flattenScheduleCandidates(moduleNamespace);
|
|
29
|
+
const seen = new Set();
|
|
30
|
+
return flattenedCandidates.filter(isSchedule).filter((schedule) => {
|
|
31
|
+
const normalizedName = schedule.name.trim();
|
|
32
|
+
if (normalizedName === '' || seen.has(normalizedName)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
seen.add(normalizedName);
|
|
36
|
+
return true;
|
|
37
|
+
});
|
|
38
|
+
};
|
|
17
39
|
const getProjectScheduleLoaders = () => [
|
|
18
40
|
useFileLoader('app/Schedules/index.ts'),
|
|
19
41
|
useFileLoader('app/Schedules.ts'),
|
|
@@ -80,7 +102,7 @@ const tryLoadProjectScheduleModuleFromFiles = async () => {
|
|
|
80
102
|
}
|
|
81
103
|
try {
|
|
82
104
|
return {
|
|
83
|
-
module: await entry.loader.
|
|
105
|
+
module: await entry.loader.getModule(),
|
|
84
106
|
loadedPath: entry.loadedPath,
|
|
85
107
|
};
|
|
86
108
|
}
|
|
@@ -91,13 +113,16 @@ const tryLoadProjectScheduleModuleFromFiles = async () => {
|
|
|
91
113
|
return tryAt(0);
|
|
92
114
|
};
|
|
93
115
|
const loadAppScheduleModule = async () => {
|
|
116
|
+
const fileLoaded = await tryLoadProjectScheduleModuleFromFiles();
|
|
117
|
+
if (fileLoaded !== undefined) {
|
|
118
|
+
return fileLoaded;
|
|
119
|
+
}
|
|
94
120
|
try {
|
|
95
121
|
return {
|
|
96
122
|
module: (await import('../../../../app/Schedules/index.js')),
|
|
97
123
|
};
|
|
98
124
|
}
|
|
99
125
|
catch {
|
|
100
|
-
const fileLoaded = await tryLoadProjectScheduleModuleFromFiles();
|
|
101
126
|
return fileLoaded ?? { module: {} };
|
|
102
127
|
}
|
|
103
128
|
};
|
|
@@ -105,8 +130,8 @@ const loadScheduleModules = async () => {
|
|
|
105
130
|
const coreSchedules = await import('../../../schedules/index.js');
|
|
106
131
|
const appSchedules = await loadAppScheduleModule();
|
|
107
132
|
return {
|
|
108
|
-
core:
|
|
109
|
-
app:
|
|
133
|
+
core: collectSchedules(coreSchedules),
|
|
134
|
+
app: collectSchedules(appSchedules.module),
|
|
110
135
|
};
|
|
111
136
|
};
|
|
112
137
|
const ensureProjectSourceContext = async () => {
|
package/src/config/env.d.ts
CHANGED
|
@@ -191,6 +191,8 @@ export declare const Env: Readonly<{
|
|
|
191
191
|
JWT_REVOCATION_DRIVER: string;
|
|
192
192
|
JWT_REVOCATION_DB_CONNECTION: string;
|
|
193
193
|
JWT_REVOCATION_DB_TABLE: string;
|
|
194
|
+
BULLETPROOF_DEVICE_DB_CONNECTION: string;
|
|
195
|
+
BULLETPROOF_DEVICE_DB_TABLE: string;
|
|
194
196
|
JWT_REVOCATION_REDIS_DB: number;
|
|
195
197
|
JWT_REVOCATION_REDIS_PREFIX: string;
|
|
196
198
|
JWT_REVOCATION_KV_BINDING: string;
|
package/src/config/env.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/config/env.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CA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MAAM,CAOhD,CAAC;AAEF,eAAO,MAAM,kBAAkB,QAAO,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAKjE,CAAC;AACF,eAAO,MAAM,mBAAmB,QAAuC,CAAC;AAKxE,eAAO,MAAM,GAAG;eAnES,MAAM,iBAAiB,MAAM,KAAG,MAAM;uBA1B9B,MAAM,KAAG,MAAM,GAAG,SAAS;kBAwChC,MAAM,gBAAgB,MAAM,KAAG,MAAM;mBAYpC,MAAM,iBAAiB,OAAO,KAAG,OAAO;oBANvC,MAAM,iBAAiB,MAAM,KAAG,MAAM;eAvC3C,MAAM,KAAG,OAAO;eAmDhB,MAAM,SAAS,MAAM,KAAG,IAAI;iBAK1B,MAAM,KAAG,IAAI;wBAMN,SAAS,GAAG,IAAI,KAAG,IAAI;oBAI7B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;uBA7DjB,MAAM,KAAG,MAAM,GAAG,SAAS;2BAOzB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;4BAIrB,gBAAgB;cAuFN,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAkOpB,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoFxF,CAAC;AAEH,eAAO,MAAM,aAAa,QAAO,MAchC,CAAC"}
|
package/src/config/env.js
CHANGED
|
@@ -440,6 +440,8 @@ export const Env = Object.freeze({
|
|
|
440
440
|
JWT_REVOCATION_DRIVER: get('JWT_REVOCATION_DRIVER', 'database'),
|
|
441
441
|
JWT_REVOCATION_DB_CONNECTION: get('JWT_REVOCATION_DB_CONNECTION', 'default'),
|
|
442
442
|
JWT_REVOCATION_DB_TABLE: get('JWT_REVOCATION_DB_TABLE', 'zintrust_jwt_revocations'),
|
|
443
|
+
BULLETPROOF_DEVICE_DB_CONNECTION: get('BULLETPROOF_DEVICE_DB_CONNECTION', 'default'),
|
|
444
|
+
BULLETPROOF_DEVICE_DB_TABLE: get('BULLETPROOF_DEVICE_DB_TABLE', 'zintrust_bulletproof_devices'),
|
|
443
445
|
JWT_REVOCATION_REDIS_DB: getInt('JWT_REVOCATION_REDIS_DB', 0),
|
|
444
446
|
JWT_REVOCATION_REDIS_PREFIX: get('JWT_REVOCATION_REDIS_PREFIX', 'zt:jwt:revoked:'),
|
|
445
447
|
JWT_REVOCATION_KV_BINDING: get('JWT_REVOCATION_KV_BINDING', 'CACHE'),
|
package/src/http/Request.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface IRequest {
|
|
|
22
22
|
getHeaders(): http.IncomingHttpHeaders;
|
|
23
23
|
readonly headers: http.IncomingHttpHeaders;
|
|
24
24
|
getHeader(name: string): HeadParam;
|
|
25
|
+
header(name: string): HeadParam;
|
|
25
26
|
getParams(): Record<string, string>;
|
|
26
27
|
getParam(key: string): string | undefined;
|
|
27
28
|
setParams(params: Record<string, string>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Request.d.ts","sourceRoot":"","sources":["../../../src/http/Request.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE5F,OAAO,KAAK,KAAK,IAAI,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,KAAK,SAAS,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAE/C,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;I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S,EAAE,MAAM,GAAG,OAAO,CAAC;IACpC,UAAU,IAAI,kBAAkB,CAAC;IAEjC;;;OAGG;IACH,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEhC;;OAEG;IACH,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CACpD;AAED,MAAM,MAAM,gBAAgB,CAC1B,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,OAAO,EAChB,OAAO,GAAG,OAAO,EACjB,QAAQ,GAAG,OAAO,IAChB,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG;IAChC,SAAS,EAAE;QACT,IAAI,EAAE,KAAK,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,OAAO,CAAC;QAChB,OAAO,EAAE,QAAQ,CAAC;KACnB,CAAC;CACH,CAAC;AA+SF,eAAO,MAAM,OAAO;IAClB;;OAEG;gBACS,IAAI,CAAC,eAAe,GAAG,QAAQ;EAO3C,CAAC;AAEH,eAAe,OAAO,CAAC"}
|
package/src/http/Request.js
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export { RequestContext } from './http/RequestContext';
|
|
|
31
31
|
export { Response } from './http/Response';
|
|
32
32
|
export type { IResponse } from './http/Response';
|
|
33
33
|
export { getValidatedBody, getValidatedHeaders, getValidatedParams, getValidatedQuery, hasValidatedBody, requireValidatedBody, ValidationHelper, } from './http/ValidationHelper';
|
|
34
|
+
export { BulletproofAuthMiddleware } from './middleware/BulletproofAuthMiddleware';
|
|
34
35
|
export { CsrfMiddleware } from './middleware/CsrfMiddleware';
|
|
35
36
|
export { ErrorHandlerMiddleware } from './middleware/ErrorHandlerMiddleware';
|
|
36
37
|
export { LoggingMiddleware } from './middleware/LoggingMiddleware';
|
|
@@ -64,8 +65,8 @@ export type { RouteMeta, RouteMetaInput, RouteRegistration } from './routes/Rout
|
|
|
64
65
|
export { DatabaseAdapterRegistry } from './orm/DatabaseAdapterRegistry';
|
|
65
66
|
export { generateSecureJobId, generateUuid, getString, Utilities, type UtilitiesType, } from './common/utility';
|
|
66
67
|
export { ContextLoader } from './common/ContextLoader';
|
|
67
|
-
export { delay, ensureDirSafe } from './common/index';
|
|
68
68
|
export type { ContextLoaderBatchHandler, ContextLoaderBatchKey, ContextLoaderBatchResult, ContextLoaderContext, ContextLoaderInstance, ContextLoaderMode, ContextLoaderPlan, ContextLoaderResolver, } from './common/ContextLoader';
|
|
69
|
+
export { delay, ensureDirSafe } from './common/index';
|
|
69
70
|
export { collect, Collection } from './collections/index';
|
|
70
71
|
export type { ICollection, PrimitiveKey } from './collections/index';
|
|
71
72
|
export { HttpClient } from './tools/http/Http';
|
|
@@ -87,6 +88,7 @@ export type { FieldError } from './validation/ValidationError';
|
|
|
87
88
|
export { Schema, Validator } from './validation/Validator';
|
|
88
89
|
export type { ISchema, SchemaType } from './validation/Validator';
|
|
89
90
|
export { Schedule } from './scheduler/Schedule';
|
|
91
|
+
export { BulletproofDeviceStore } from './security/BulletproofDeviceStore';
|
|
90
92
|
export { CsrfTokenManager } from './security/CsrfTokenManager';
|
|
91
93
|
export type { CsrfTokenData, CsrfTokenManagerType, ICsrfTokenManager, } from './security/CsrfTokenManager';
|
|
92
94
|
export { EncryptedEnvelope } from './security/EncryptedEnvelope';
|
|
@@ -95,6 +97,8 @@ export { Hash } from './security/Hash';
|
|
|
95
97
|
export { JwtManager } from './security/JwtManager';
|
|
96
98
|
export type { IJwtManager, JwtAlgorithm, JwtManagerType, JwtOptions, JwtPayload, } from './security/JwtManager';
|
|
97
99
|
export { JwtSessions } from './security/JwtSessions';
|
|
100
|
+
export { JwtVerifier } from './security/JwtVerifier';
|
|
101
|
+
export type { JwtVerifierAlgorithm, JwtVerifierFailure, JwtVerifierFailureReason, JwtVerifierJwk, JwtVerifierJwksDocument, JwtVerifierResult, JwtVerifierSuccess, JwtVerifierWithJwkInput, JwtVerifierWithJwksInput, } from './security/JwtVerifier';
|
|
98
102
|
export { PasswordResetTokenBroker } from './security/PasswordResetTokenBroker';
|
|
99
103
|
export type { IPasswordResetTokenBroker, IPasswordResetTokenStore, PasswordResetTokenBrokerOptions, PasswordResetTokenBrokerType, PasswordResetTokenRecord, } from './security/PasswordResetTokenBroker';
|
|
100
104
|
export { createSanitizer, Sanitizer, type SanitizerType } from './security/Sanitizer';
|
|
@@ -178,13 +182,13 @@ export { SendGridDriver } from './tools/mail/drivers/SendGrid';
|
|
|
178
182
|
export type { SendGridConfig, MailAddress as SendGridMailAddress, MailAttachment as SendGridMailAttachment, MailMessage as SendGridMailMessage, SendResult as SendGridSendResult, } from './tools/mail/drivers/SendGrid';
|
|
179
183
|
export { MailgunDriver } from './tools/mail/drivers/Mailgun';
|
|
180
184
|
export type { MailgunConfig, MailMessage as MailgunMessage, SendResult as MailgunResult, } from './tools/mail/drivers/Mailgun';
|
|
185
|
+
export { NotificationComposer } from './tools/notification/Composer';
|
|
186
|
+
export type { NotificationChannelHandler, NotificationComposeBuilder, NotificationComposeChannelResult, NotificationComposeError, NotificationComposeOptions, NotificationComposePolicy, NotificationComposeResult, } from './tools/notification/Composer';
|
|
181
187
|
export { sendSlackWebhook } from './tools/notification/drivers/Slack';
|
|
182
188
|
export { TermiiDriver } from './tools/notification/drivers/Termii';
|
|
183
189
|
export { sendSms } from './tools/notification/drivers/Twilio';
|
|
184
190
|
export { Notification } from './tools/notification/Notification';
|
|
185
|
-
export { NotificationComposer } from './tools/notification/Composer';
|
|
186
191
|
export { NotificationRegistry } from './tools/notification/Registry';
|
|
187
|
-
export type { NotificationChannelHandler, NotificationComposeBuilder, NotificationComposeChannelResult, NotificationComposeError, NotificationComposeOptions, NotificationComposePolicy, NotificationComposeResult, } from './tools/notification/Composer';
|
|
188
192
|
export { MarkdownRenderer } from './tools/templates';
|
|
189
193
|
export { RuntimeHealthProbes } from './health/RuntimeHealthProbes';
|
|
190
194
|
export { Broadcast } from './tools/broadcast/Broadcast';
|
|
@@ -223,7 +227,7 @@ export { default as logCleanup } from './schedules/log-cleanup';
|
|
|
223
227
|
export * as NodeSingletons from './node-singletons/index';
|
|
224
228
|
export { Auth } from './auth/Auth';
|
|
225
229
|
export { LoginFlow } from './auth/LoginFlow';
|
|
226
|
-
export type { LoginFlowAuditEvent, LoginFlowAuditor, LoginFlowBuilder, LoginFlowCreateOptions, LoginFlowError, LoginFlowIdentity, LoginFlowIssuer, LoginFlowIssuerInput, LoginFlowProvider, LoginFlowResult, LoginFlowStage, LoginFlowVerifiedRecord, } from './auth/LoginFlow';
|
|
230
|
+
export type { BulletproofJwtIssued, LoginFlowAuditEvent, LoginFlowAuditor, LoginFlowBuilder, LoginFlowCreateOptions, LoginFlowError, LoginFlowIdentity, LoginFlowIssuer, LoginFlowIssuerInput, LoginFlowProvider, LoginFlowResult, LoginFlowStage, LoginFlowVerifiedRecord, } from './auth/LoginFlow';
|
|
227
231
|
export { MicroserviceGenerator } from './microservices/MicroserviceGenerator';
|
|
228
232
|
export type { GenerateServiceOptions, IMicroserviceGenerator, } from './microservices/MicroserviceGenerator';
|
|
229
233
|
export { ErrorHandler as ProxyErrorHandler } from './proxy/ErrorHandler';
|