@serve.zone/dcrouter 10.1.8 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist_serve/bundle.js +431 -431
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.dcrouter.d.ts +1 -1
- package/dist_ts/opsserver/classes.opsserver.d.ts +12 -1
- package/dist_ts/opsserver/classes.opsserver.js +21 -4
- package/dist_ts/opsserver/handlers/admin.handler.d.ts +1 -1
- package/dist_ts/opsserver/handlers/api-token.handler.d.ts +0 -6
- package/dist_ts/opsserver/handlers/api-token.handler.js +10 -27
- package/dist_ts/opsserver/handlers/certificate.handler.d.ts +0 -2
- package/dist_ts/opsserver/handlers/certificate.handler.js +11 -9
- package/dist_ts/opsserver/handlers/config.handler.d.ts +0 -2
- package/dist_ts/opsserver/handlers/config.handler.js +4 -5
- package/dist_ts/opsserver/handlers/email-ops.handler.d.ts +0 -2
- package/dist_ts/opsserver/handlers/email-ops.handler.js +8 -7
- package/dist_ts/opsserver/handlers/logs.handler.d.ts +0 -2
- package/dist_ts/opsserver/handlers/logs.handler.js +5 -6
- package/dist_ts/opsserver/handlers/radius.handler.d.ts +0 -2
- package/dist_ts/opsserver/handlers/radius.handler.js +27 -28
- package/dist_ts/opsserver/handlers/remoteingress.handler.d.ts +0 -2
- package/dist_ts/opsserver/handlers/remoteingress.handler.js +14 -12
- package/dist_ts/opsserver/handlers/route-management.handler.d.ts +2 -1
- package/dist_ts/opsserver/handlers/security.handler.d.ts +0 -2
- package/dist_ts/opsserver/handlers/security.handler.js +7 -8
- package/dist_ts/opsserver/handlers/stats.handler.d.ts +0 -2
- package/dist_ts/opsserver/handlers/stats.handler.js +9 -10
- package/dist_ts/opsserver/helpers/guards.d.ts +8 -6
- package/dist_ts/opsserver/helpers/guards.js +5 -3
- package/dist_ts/sms/classes.smsservice.d.ts +1 -1
- package/dist_ts_interfaces/requests/api-tokens.d.ts +5 -5
- package/dist_ts_interfaces/requests/certificate.d.ts +6 -6
- package/dist_ts_interfaces/requests/config.d.ts +1 -1
- package/dist_ts_interfaces/requests/email-ops.d.ts +3 -3
- package/dist_ts_interfaces/requests/logs.d.ts +2 -2
- package/dist_ts_interfaces/requests/radius.d.ts +12 -12
- package/dist_ts_interfaces/requests/remoteingress.d.ts +7 -7
- package/dist_ts_interfaces/requests/stats.d.ts +44 -8
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/appstate.js +21 -1
- package/package.json +4 -4
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/opsserver/classes.opsserver.ts +28 -7
- package/ts/opsserver/handlers/api-token.handler.ts +10 -28
- package/ts/opsserver/handlers/certificate.handler.ts +13 -9
- package/ts/opsserver/handlers/config.handler.ts +4 -5
- package/ts/opsserver/handlers/email-ops.handler.ts +10 -7
- package/ts/opsserver/handlers/logs.handler.ts +5 -5
- package/ts/opsserver/handlers/radius.handler.ts +26 -28
- package/ts/opsserver/handlers/remoteingress.handler.ts +16 -12
- package/ts/opsserver/handlers/security.handler.ts +9 -10
- package/ts/opsserver/handlers/stats.handler.ts +10 -11
- package/ts/opsserver/helpers/guards.ts +10 -8
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/appstate.ts +11 -4
|
@@ -10,12 +10,9 @@ let logPushDestinationInstalled = false;
|
|
|
10
10
|
let currentOpsServerRef: OpsServer | null = null;
|
|
11
11
|
|
|
12
12
|
export class LogsHandler {
|
|
13
|
-
public typedrouter = new plugins.typedrequest.TypedRouter();
|
|
14
13
|
private activeStreamStops: Set<() => void> = new Set();
|
|
15
14
|
|
|
16
15
|
constructor(private opsServerRef: OpsServer) {
|
|
17
|
-
// Add this handler's router to the parent
|
|
18
|
-
this.opsServerRef.typedrouter.addTypedRouter(this.typedrouter);
|
|
19
16
|
this.registerHandlers();
|
|
20
17
|
this.setupLogPushDestination();
|
|
21
18
|
}
|
|
@@ -35,8 +32,11 @@ export class LogsHandler {
|
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
private registerHandlers(): void {
|
|
35
|
+
// All log endpoints register directly on viewRouter (valid identity required via middleware)
|
|
36
|
+
const router = this.opsServerRef.viewRouter;
|
|
37
|
+
|
|
38
38
|
// Get Recent Logs Handler
|
|
39
|
-
|
|
39
|
+
router.addTypedHandler(
|
|
40
40
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRecentLogs>(
|
|
41
41
|
'getRecentLogs',
|
|
42
42
|
async (dataArg, toolsArg) => {
|
|
@@ -59,7 +59,7 @@ export class LogsHandler {
|
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
// Get Log Stream Handler
|
|
62
|
-
|
|
62
|
+
router.addTypedHandler(
|
|
63
63
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetLogStream>(
|
|
64
64
|
'getLogStream',
|
|
65
65
|
async (dataArg, toolsArg) => {
|
|
@@ -3,21 +3,19 @@ import type { OpsServer } from '../classes.opsserver.js';
|
|
|
3
3
|
import * as interfaces from '../../../ts_interfaces/index.js';
|
|
4
4
|
|
|
5
5
|
export class RadiusHandler {
|
|
6
|
-
public typedrouter = new plugins.typedrequest.TypedRouter();
|
|
7
|
-
|
|
8
6
|
constructor(private opsServerRef: OpsServer) {
|
|
9
|
-
// Add this handler's router to the parent
|
|
10
|
-
this.opsServerRef.typedrouter.addTypedRouter(this.typedrouter);
|
|
11
7
|
this.registerHandlers();
|
|
12
8
|
}
|
|
13
9
|
|
|
14
10
|
private registerHandlers(): void {
|
|
11
|
+
const viewRouter = this.opsServerRef.viewRouter;
|
|
12
|
+
const adminRouter = this.opsServerRef.adminRouter;
|
|
15
13
|
// ========================================================================
|
|
16
14
|
// RADIUS Client Management
|
|
17
15
|
// ========================================================================
|
|
18
16
|
|
|
19
|
-
// Get all RADIUS clients
|
|
20
|
-
|
|
17
|
+
// Get all RADIUS clients (read)
|
|
18
|
+
viewRouter.addTypedHandler(
|
|
21
19
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRadiusClients>(
|
|
22
20
|
'getRadiusClients',
|
|
23
21
|
async (dataArg, toolsArg) => {
|
|
@@ -40,8 +38,8 @@ export class RadiusHandler {
|
|
|
40
38
|
)
|
|
41
39
|
);
|
|
42
40
|
|
|
43
|
-
// Add or update a RADIUS client
|
|
44
|
-
|
|
41
|
+
// Add or update a RADIUS client (write)
|
|
42
|
+
adminRouter.addTypedHandler(
|
|
45
43
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_SetRadiusClient>(
|
|
46
44
|
'setRadiusClient',
|
|
47
45
|
async (dataArg, toolsArg) => {
|
|
@@ -61,8 +59,8 @@ export class RadiusHandler {
|
|
|
61
59
|
)
|
|
62
60
|
);
|
|
63
61
|
|
|
64
|
-
// Remove a RADIUS client
|
|
65
|
-
|
|
62
|
+
// Remove a RADIUS client (write)
|
|
63
|
+
adminRouter.addTypedHandler(
|
|
66
64
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_RemoveRadiusClient>(
|
|
67
65
|
'removeRadiusClient',
|
|
68
66
|
async (dataArg, toolsArg) => {
|
|
@@ -85,8 +83,8 @@ export class RadiusHandler {
|
|
|
85
83
|
// VLAN Mapping Management
|
|
86
84
|
// ========================================================================
|
|
87
85
|
|
|
88
|
-
// Get all VLAN mappings
|
|
89
|
-
|
|
86
|
+
// Get all VLAN mappings (read)
|
|
87
|
+
viewRouter.addTypedHandler(
|
|
90
88
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetVlanMappings>(
|
|
91
89
|
'getVlanMappings',
|
|
92
90
|
async (dataArg, toolsArg) => {
|
|
@@ -121,8 +119,8 @@ export class RadiusHandler {
|
|
|
121
119
|
)
|
|
122
120
|
);
|
|
123
121
|
|
|
124
|
-
// Add or update a VLAN mapping
|
|
125
|
-
|
|
122
|
+
// Add or update a VLAN mapping (write)
|
|
123
|
+
adminRouter.addTypedHandler(
|
|
126
124
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_SetVlanMapping>(
|
|
127
125
|
'setVlanMapping',
|
|
128
126
|
async (dataArg, toolsArg) => {
|
|
@@ -153,8 +151,8 @@ export class RadiusHandler {
|
|
|
153
151
|
)
|
|
154
152
|
);
|
|
155
153
|
|
|
156
|
-
// Remove a VLAN mapping
|
|
157
|
-
|
|
154
|
+
// Remove a VLAN mapping (write)
|
|
155
|
+
adminRouter.addTypedHandler(
|
|
158
156
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_RemoveVlanMapping>(
|
|
159
157
|
'removeVlanMapping',
|
|
160
158
|
async (dataArg, toolsArg) => {
|
|
@@ -174,8 +172,8 @@ export class RadiusHandler {
|
|
|
174
172
|
)
|
|
175
173
|
);
|
|
176
174
|
|
|
177
|
-
// Update VLAN configuration
|
|
178
|
-
|
|
175
|
+
// Update VLAN configuration (write)
|
|
176
|
+
adminRouter.addTypedHandler(
|
|
179
177
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_UpdateVlanConfig>(
|
|
180
178
|
'updateVlanConfig',
|
|
181
179
|
async (dataArg, toolsArg) => {
|
|
@@ -206,8 +204,8 @@ export class RadiusHandler {
|
|
|
206
204
|
)
|
|
207
205
|
);
|
|
208
206
|
|
|
209
|
-
// Test VLAN assignment
|
|
210
|
-
|
|
207
|
+
// Test VLAN assignment (read)
|
|
208
|
+
viewRouter.addTypedHandler(
|
|
211
209
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_TestVlanAssignment>(
|
|
212
210
|
'testVlanAssignment',
|
|
213
211
|
async (dataArg, toolsArg) => {
|
|
@@ -240,8 +238,8 @@ export class RadiusHandler {
|
|
|
240
238
|
// Accounting / Session Management
|
|
241
239
|
// ========================================================================
|
|
242
240
|
|
|
243
|
-
// Get active sessions
|
|
244
|
-
|
|
241
|
+
// Get active sessions (read)
|
|
242
|
+
viewRouter.addTypedHandler(
|
|
245
243
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRadiusSessions>(
|
|
246
244
|
'getRadiusSessions',
|
|
247
245
|
async (dataArg, toolsArg) => {
|
|
@@ -289,8 +287,8 @@ export class RadiusHandler {
|
|
|
289
287
|
)
|
|
290
288
|
);
|
|
291
289
|
|
|
292
|
-
// Disconnect a session
|
|
293
|
-
|
|
290
|
+
// Disconnect a session (write)
|
|
291
|
+
adminRouter.addTypedHandler(
|
|
294
292
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_DisconnectRadiusSession>(
|
|
295
293
|
'disconnectRadiusSession',
|
|
296
294
|
async (dataArg, toolsArg) => {
|
|
@@ -314,8 +312,8 @@ export class RadiusHandler {
|
|
|
314
312
|
)
|
|
315
313
|
);
|
|
316
314
|
|
|
317
|
-
// Get accounting summary
|
|
318
|
-
|
|
315
|
+
// Get accounting summary (read)
|
|
316
|
+
viewRouter.addTypedHandler(
|
|
319
317
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRadiusAccountingSummary>(
|
|
320
318
|
'getRadiusAccountingSummary',
|
|
321
319
|
async (dataArg, toolsArg) => {
|
|
@@ -351,8 +349,8 @@ export class RadiusHandler {
|
|
|
351
349
|
// Statistics
|
|
352
350
|
// ========================================================================
|
|
353
351
|
|
|
354
|
-
// Get RADIUS statistics
|
|
355
|
-
|
|
352
|
+
// Get RADIUS statistics (read)
|
|
353
|
+
viewRouter.addTypedHandler(
|
|
356
354
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRadiusStatistics>(
|
|
357
355
|
'getRadiusStatistics',
|
|
358
356
|
async (dataArg, toolsArg) => {
|
|
@@ -3,16 +3,18 @@ import type { OpsServer } from '../classes.opsserver.js';
|
|
|
3
3
|
import * as interfaces from '../../../ts_interfaces/index.js';
|
|
4
4
|
|
|
5
5
|
export class RemoteIngressHandler {
|
|
6
|
-
public typedrouter = new plugins.typedrequest.TypedRouter();
|
|
7
|
-
|
|
8
6
|
constructor(private opsServerRef: OpsServer) {
|
|
9
|
-
this.opsServerRef.typedrouter.addTypedRouter(this.typedrouter);
|
|
10
7
|
this.registerHandlers();
|
|
11
8
|
}
|
|
12
9
|
|
|
13
10
|
private registerHandlers(): void {
|
|
11
|
+
const viewRouter = this.opsServerRef.viewRouter;
|
|
12
|
+
const adminRouter = this.opsServerRef.adminRouter;
|
|
13
|
+
|
|
14
|
+
// ---- Read endpoints (viewRouter — valid identity required via middleware) ----
|
|
15
|
+
|
|
14
16
|
// Get all remote ingress edges
|
|
15
|
-
|
|
17
|
+
viewRouter.addTypedHandler(
|
|
16
18
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRemoteIngresses>(
|
|
17
19
|
'getRemoteIngresses',
|
|
18
20
|
async (dataArg, toolsArg) => {
|
|
@@ -36,8 +38,10 @@ export class RemoteIngressHandler {
|
|
|
36
38
|
),
|
|
37
39
|
);
|
|
38
40
|
|
|
41
|
+
// ---- Write endpoints (adminRouter) ----
|
|
42
|
+
|
|
39
43
|
// Create a new remote ingress edge
|
|
40
|
-
|
|
44
|
+
adminRouter.addTypedHandler(
|
|
41
45
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_CreateRemoteIngress>(
|
|
42
46
|
'createRemoteIngress',
|
|
43
47
|
async (dataArg, toolsArg) => {
|
|
@@ -69,7 +73,7 @@ export class RemoteIngressHandler {
|
|
|
69
73
|
);
|
|
70
74
|
|
|
71
75
|
// Delete a remote ingress edge
|
|
72
|
-
|
|
76
|
+
adminRouter.addTypedHandler(
|
|
73
77
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_DeleteRemoteIngress>(
|
|
74
78
|
'deleteRemoteIngress',
|
|
75
79
|
async (dataArg, toolsArg) => {
|
|
@@ -94,7 +98,7 @@ export class RemoteIngressHandler {
|
|
|
94
98
|
);
|
|
95
99
|
|
|
96
100
|
// Update a remote ingress edge
|
|
97
|
-
|
|
101
|
+
adminRouter.addTypedHandler(
|
|
98
102
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_UpdateRemoteIngress>(
|
|
99
103
|
'updateRemoteIngress',
|
|
100
104
|
async (dataArg, toolsArg) => {
|
|
@@ -138,7 +142,7 @@ export class RemoteIngressHandler {
|
|
|
138
142
|
);
|
|
139
143
|
|
|
140
144
|
// Regenerate secret for an edge
|
|
141
|
-
|
|
145
|
+
adminRouter.addTypedHandler(
|
|
142
146
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_RegenerateRemoteIngressSecret>(
|
|
143
147
|
'regenerateRemoteIngressSecret',
|
|
144
148
|
async (dataArg, toolsArg) => {
|
|
@@ -164,8 +168,8 @@ export class RemoteIngressHandler {
|
|
|
164
168
|
),
|
|
165
169
|
);
|
|
166
170
|
|
|
167
|
-
// Get runtime status of all edges
|
|
168
|
-
|
|
171
|
+
// Get runtime status of all edges (read)
|
|
172
|
+
viewRouter.addTypedHandler(
|
|
169
173
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRemoteIngressStatus>(
|
|
170
174
|
'getRemoteIngressStatus',
|
|
171
175
|
async (dataArg, toolsArg) => {
|
|
@@ -178,8 +182,8 @@ export class RemoteIngressHandler {
|
|
|
178
182
|
),
|
|
179
183
|
);
|
|
180
184
|
|
|
181
|
-
// Get a connection token for an edge
|
|
182
|
-
|
|
185
|
+
// Get a connection token for an edge (write — exposes secret)
|
|
186
|
+
adminRouter.addTypedHandler(
|
|
183
187
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRemoteIngressConnectionToken>(
|
|
184
188
|
'getRemoteIngressConnectionToken',
|
|
185
189
|
async (dataArg, toolsArg) => {
|
|
@@ -4,17 +4,16 @@ import * as interfaces from '../../../ts_interfaces/index.js';
|
|
|
4
4
|
import { MetricsManager } from '../../monitoring/index.js';
|
|
5
5
|
|
|
6
6
|
export class SecurityHandler {
|
|
7
|
-
public typedrouter = new plugins.typedrequest.TypedRouter();
|
|
8
|
-
|
|
9
7
|
constructor(private opsServerRef: OpsServer) {
|
|
10
|
-
// Add this handler's router to the parent
|
|
11
|
-
this.opsServerRef.typedrouter.addTypedRouter(this.typedrouter);
|
|
12
8
|
this.registerHandlers();
|
|
13
9
|
}
|
|
14
|
-
|
|
10
|
+
|
|
15
11
|
private registerHandlers(): void {
|
|
12
|
+
// All security endpoints register directly on viewRouter (valid identity required via middleware)
|
|
13
|
+
const router = this.opsServerRef.viewRouter;
|
|
14
|
+
|
|
16
15
|
// Security Metrics Handler
|
|
17
|
-
|
|
16
|
+
router.addTypedHandler(
|
|
18
17
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetSecurityMetrics>(
|
|
19
18
|
'getSecurityMetrics',
|
|
20
19
|
async (dataArg, toolsArg) => {
|
|
@@ -40,7 +39,7 @@ export class SecurityHandler {
|
|
|
40
39
|
);
|
|
41
40
|
|
|
42
41
|
// Active Connections Handler
|
|
43
|
-
|
|
42
|
+
router.addTypedHandler(
|
|
44
43
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetActiveConnections>(
|
|
45
44
|
'getActiveConnections',
|
|
46
45
|
async (dataArg, toolsArg) => {
|
|
@@ -77,8 +76,8 @@ export class SecurityHandler {
|
|
|
77
76
|
);
|
|
78
77
|
|
|
79
78
|
// Network Stats Handler - provides comprehensive network metrics
|
|
80
|
-
|
|
81
|
-
new plugins.typedrequest.TypedHandler(
|
|
79
|
+
router.addTypedHandler(
|
|
80
|
+
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetNetworkStats>(
|
|
82
81
|
'getNetworkStats',
|
|
83
82
|
async (dataArg, toolsArg) => {
|
|
84
83
|
// Get network stats from MetricsManager if available
|
|
@@ -121,7 +120,7 @@ export class SecurityHandler {
|
|
|
121
120
|
);
|
|
122
121
|
|
|
123
122
|
// Rate Limit Status Handler
|
|
124
|
-
|
|
123
|
+
router.addTypedHandler(
|
|
125
124
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetRateLimitStatus>(
|
|
126
125
|
'getRateLimitStatus',
|
|
127
126
|
async (dataArg, toolsArg) => {
|
|
@@ -5,17 +5,16 @@ import { MetricsManager } from '../../monitoring/index.js';
|
|
|
5
5
|
import { SecurityLogger } from '../../security/classes.securitylogger.js';
|
|
6
6
|
|
|
7
7
|
export class StatsHandler {
|
|
8
|
-
public typedrouter = new plugins.typedrequest.TypedRouter();
|
|
9
|
-
|
|
10
8
|
constructor(private opsServerRef: OpsServer) {
|
|
11
|
-
// Add this handler's router to the parent
|
|
12
|
-
this.opsServerRef.typedrouter.addTypedRouter(this.typedrouter);
|
|
13
9
|
this.registerHandlers();
|
|
14
10
|
}
|
|
15
|
-
|
|
11
|
+
|
|
16
12
|
private registerHandlers(): void {
|
|
13
|
+
// All stats endpoints register directly on viewRouter (valid identity required via middleware)
|
|
14
|
+
const router = this.opsServerRef.viewRouter;
|
|
15
|
+
|
|
17
16
|
// Server Statistics Handler
|
|
18
|
-
|
|
17
|
+
router.addTypedHandler(
|
|
19
18
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetServerStatistics>(
|
|
20
19
|
'getServerStatistics',
|
|
21
20
|
async (dataArg, toolsArg) => {
|
|
@@ -38,7 +37,7 @@ export class StatsHandler {
|
|
|
38
37
|
);
|
|
39
38
|
|
|
40
39
|
// Email Statistics Handler
|
|
41
|
-
|
|
40
|
+
router.addTypedHandler(
|
|
42
41
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetEmailStatistics>(
|
|
43
42
|
'getEmailStatistics',
|
|
44
43
|
async (dataArg, toolsArg) => {
|
|
@@ -77,7 +76,7 @@ export class StatsHandler {
|
|
|
77
76
|
);
|
|
78
77
|
|
|
79
78
|
// DNS Statistics Handler
|
|
80
|
-
|
|
79
|
+
router.addTypedHandler(
|
|
81
80
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetDnsStatistics>(
|
|
82
81
|
'getDnsStatistics',
|
|
83
82
|
async (dataArg, toolsArg) => {
|
|
@@ -114,7 +113,7 @@ export class StatsHandler {
|
|
|
114
113
|
);
|
|
115
114
|
|
|
116
115
|
// Queue Status Handler
|
|
117
|
-
|
|
116
|
+
router.addTypedHandler(
|
|
118
117
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetQueueStatus>(
|
|
119
118
|
'getQueueStatus',
|
|
120
119
|
async (dataArg, toolsArg) => {
|
|
@@ -142,7 +141,7 @@ export class StatsHandler {
|
|
|
142
141
|
);
|
|
143
142
|
|
|
144
143
|
// Health Status Handler
|
|
145
|
-
|
|
144
|
+
router.addTypedHandler(
|
|
146
145
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetHealthStatus>(
|
|
147
146
|
'getHealthStatus',
|
|
148
147
|
async (dataArg, toolsArg) => {
|
|
@@ -167,7 +166,7 @@ export class StatsHandler {
|
|
|
167
166
|
);
|
|
168
167
|
|
|
169
168
|
// Combined Metrics Handler - More efficient for frontend polling
|
|
170
|
-
|
|
169
|
+
router.addTypedHandler(
|
|
171
170
|
new plugins.typedrequest.TypedHandler<interfaces.requests.IReq_GetCombinedMetrics>(
|
|
172
171
|
'getCombinedMetrics',
|
|
173
172
|
async (dataArg, toolsArg) => {
|
|
@@ -22,16 +22,17 @@ export async function passGuards<T extends { identity?: any }>(
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Helper to check admin identity in handlers
|
|
25
|
+
* Helper to check admin identity in handlers and middleware.
|
|
26
|
+
* Accepts both optional and required identity for flexibility.
|
|
26
27
|
*/
|
|
27
|
-
export async function requireAdminIdentity
|
|
28
|
+
export async function requireAdminIdentity(
|
|
28
29
|
adminHandler: AdminHandler,
|
|
29
|
-
dataArg:
|
|
30
|
+
dataArg: { identity?: interfaces.data.IIdentity }
|
|
30
31
|
): Promise<void> {
|
|
31
32
|
if (!dataArg.identity) {
|
|
32
33
|
throw new plugins.typedrequest.TypedResponseError('No identity provided');
|
|
33
34
|
}
|
|
34
|
-
|
|
35
|
+
|
|
35
36
|
const passed = await adminHandler.adminIdentityGuard.exec({ identity: dataArg.identity });
|
|
36
37
|
if (!passed) {
|
|
37
38
|
throw new plugins.typedrequest.TypedResponseError('Admin access required');
|
|
@@ -39,16 +40,17 @@ export async function requireAdminIdentity<T extends { identity?: interfaces.dat
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
* Helper to check valid identity in handlers
|
|
43
|
+
* Helper to check valid identity in handlers and middleware.
|
|
44
|
+
* Accepts both optional and required identity for flexibility.
|
|
43
45
|
*/
|
|
44
|
-
export async function requireValidIdentity
|
|
46
|
+
export async function requireValidIdentity(
|
|
45
47
|
adminHandler: AdminHandler,
|
|
46
|
-
dataArg:
|
|
48
|
+
dataArg: { identity?: interfaces.data.IIdentity }
|
|
47
49
|
): Promise<void> {
|
|
48
50
|
if (!dataArg.identity) {
|
|
49
51
|
throw new plugins.typedrequest.TypedResponseError('No identity provided');
|
|
50
52
|
}
|
|
51
|
-
|
|
53
|
+
|
|
52
54
|
const passed = await adminHandler.validIdentityGuard.exec({ identity: dataArg.identity });
|
|
53
55
|
if (!passed) {
|
|
54
56
|
throw new plugins.typedrequest.TypedResponseError('Valid identity required');
|
package/ts_web/appstate.ts
CHANGED
|
@@ -298,8 +298,8 @@ export const logoutAction = loginStatePart.createAction(async (statePartArg) =>
|
|
|
298
298
|
// Fetch All Stats Action - Using combined endpoint for efficiency
|
|
299
299
|
export const fetchAllStatsAction = statsStatePart.createAction(async (statePartArg) => {
|
|
300
300
|
const context = getActionContext();
|
|
301
|
-
|
|
302
301
|
const currentState = statePartArg.getState();
|
|
302
|
+
if (!context.identity) return currentState;
|
|
303
303
|
|
|
304
304
|
try {
|
|
305
305
|
// Use combined metrics endpoint - single request instead of 4
|
|
@@ -340,8 +340,8 @@ export const fetchAllStatsAction = statsStatePart.createAction(async (statePartA
|
|
|
340
340
|
// Fetch Configuration Action (read-only)
|
|
341
341
|
export const fetchConfigurationAction = configStatePart.createAction(async (statePartArg) => {
|
|
342
342
|
const context = getActionContext();
|
|
343
|
-
|
|
344
343
|
const currentState = statePartArg.getState();
|
|
344
|
+
if (!context.identity) return currentState;
|
|
345
345
|
|
|
346
346
|
try {
|
|
347
347
|
const configRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
@@ -373,6 +373,7 @@ export const fetchRecentLogsAction = logStatePart.createAction<{
|
|
|
373
373
|
category?: 'smtp' | 'dns' | 'security' | 'system' | 'email';
|
|
374
374
|
}>(async (statePartArg, dataArg) => {
|
|
375
375
|
const context = getActionContext();
|
|
376
|
+
if (!context.identity) return statePartArg.getState();
|
|
376
377
|
|
|
377
378
|
const logsRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
378
379
|
interfaces.requests.IReq_GetRecentLogs
|
|
@@ -448,8 +449,8 @@ export const setActiveViewAction = uiStatePart.createAction<string>(async (state
|
|
|
448
449
|
// Fetch Network Stats Action
|
|
449
450
|
export const fetchNetworkStatsAction = networkStatePart.createAction(async (statePartArg) => {
|
|
450
451
|
const context = getActionContext();
|
|
451
|
-
|
|
452
452
|
const currentState = statePartArg.getState();
|
|
453
|
+
if (!context.identity) return currentState;
|
|
453
454
|
|
|
454
455
|
try {
|
|
455
456
|
// Fetch active connections using the existing endpoint
|
|
@@ -522,6 +523,7 @@ export const fetchNetworkStatsAction = networkStatePart.createAction(async (stat
|
|
|
522
523
|
export const fetchAllEmailsAction = emailOpsStatePart.createAction(async (statePartArg) => {
|
|
523
524
|
const context = getActionContext();
|
|
524
525
|
const currentState = statePartArg.getState();
|
|
526
|
+
if (!context.identity) return currentState;
|
|
525
527
|
|
|
526
528
|
try {
|
|
527
529
|
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
@@ -554,6 +556,7 @@ export const fetchAllEmailsAction = emailOpsStatePart.createAction(async (stateP
|
|
|
554
556
|
export const fetchCertificateOverviewAction = certificateStatePart.createAction(async (statePartArg) => {
|
|
555
557
|
const context = getActionContext();
|
|
556
558
|
const currentState = statePartArg.getState();
|
|
559
|
+
if (!context.identity) return currentState;
|
|
557
560
|
|
|
558
561
|
try {
|
|
559
562
|
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
@@ -697,6 +700,7 @@ export async function fetchConnectionToken(edgeId: string) {
|
|
|
697
700
|
export const fetchRemoteIngressAction = remoteIngressStatePart.createAction(async (statePartArg) => {
|
|
698
701
|
const context = getActionContext();
|
|
699
702
|
const currentState = statePartArg.getState();
|
|
703
|
+
if (!context.identity) return currentState;
|
|
700
704
|
|
|
701
705
|
try {
|
|
702
706
|
const edgesRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
@@ -903,6 +907,7 @@ export const toggleRemoteIngressAction = remoteIngressStatePart.createAction<{
|
|
|
903
907
|
export const fetchMergedRoutesAction = routeManagementStatePart.createAction(async (statePartArg) => {
|
|
904
908
|
const context = getActionContext();
|
|
905
909
|
const currentState = statePartArg.getState();
|
|
910
|
+
if (!context.identity) return currentState;
|
|
906
911
|
|
|
907
912
|
try {
|
|
908
913
|
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
@@ -1068,6 +1073,7 @@ export const removeRouteOverrideAction = routeManagementStatePart.createAction<s
|
|
|
1068
1073
|
export const fetchApiTokensAction = routeManagementStatePart.createAction(async (statePartArg) => {
|
|
1069
1074
|
const context = getActionContext();
|
|
1070
1075
|
const currentState = statePartArg.getState();
|
|
1076
|
+
if (!context.identity) return currentState;
|
|
1071
1077
|
|
|
1072
1078
|
try {
|
|
1073
1079
|
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
@@ -1220,8 +1226,9 @@ async function disconnectSocket() {
|
|
|
1220
1226
|
// Combined refresh action for efficient polling
|
|
1221
1227
|
async function dispatchCombinedRefreshAction() {
|
|
1222
1228
|
const context = getActionContext();
|
|
1229
|
+
if (!context.identity) return;
|
|
1223
1230
|
const currentView = uiStatePart.getState().activeView;
|
|
1224
|
-
|
|
1231
|
+
|
|
1225
1232
|
try {
|
|
1226
1233
|
// Always fetch basic stats for dashboard widgets
|
|
1227
1234
|
const combinedRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|