@serve.zone/dcrouter 15.0.2 → 15.0.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/deno.json +1 -1
- package/dist_serve/bundle.js +768 -768
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts_web/00_commitinfo_data.js +1 -1
- package/dist_ts_web/appstate/acme.d.ts +17 -0
- package/dist_ts_web/appstate/acme.js +64 -0
- package/dist_ts_web/appstate/certificates.d.ts +37 -0
- package/dist_ts_web/appstate/certificates.js +107 -0
- package/dist_ts_web/appstate/config.d.ts +9 -0
- package/dist_ts_web/appstate/config.js +35 -0
- package/dist_ts_web/appstate/domains.d.ts +80 -0
- package/dist_ts_web/appstate/domains.js +324 -0
- package/dist_ts_web/appstate/email-domains.d.ts +25 -0
- package/dist_ts_web/appstate/email-domains.js +104 -0
- package/dist_ts_web/appstate/email-ops.d.ts +10 -0
- package/dist_ts_web/appstate/email-ops.js +40 -0
- package/dist_ts_web/appstate/login.d.ts +30 -0
- package/dist_ts_web/appstate/login.js +83 -0
- package/dist_ts_web/appstate/logs.d.ts +16 -0
- package/dist_ts_web/appstate/logs.js +27 -0
- package/dist_ts_web/appstate/network.d.ts +50 -0
- package/dist_ts_web/appstate/network.js +122 -0
- package/dist_ts_web/appstate/profiles-targets.d.ts +45 -0
- package/dist_ts_web/appstate/profiles-targets.js +173 -0
- package/dist_ts_web/appstate/remoteingress.d.ts +47 -0
- package/dist_ts_web/appstate/remoteingress.js +204 -0
- package/dist_ts_web/appstate/routes.d.ts +76 -0
- package/dist_ts_web/appstate/routes.js +316 -0
- package/dist_ts_web/appstate/runtime.d.ts +1 -0
- package/dist_ts_web/appstate/runtime.js +276 -0
- package/dist_ts_web/appstate/security.d.ts +29 -0
- package/dist_ts_web/appstate/security.js +167 -0
- package/dist_ts_web/appstate/shared.d.ts +3 -0
- package/dist_ts_web/appstate/shared.js +13 -0
- package/dist_ts_web/appstate/stats.d.ts +15 -0
- package/dist_ts_web/appstate/stats.js +59 -0
- package/dist_ts_web/appstate/target-profiles.d.ts +37 -0
- package/dist_ts_web/appstate/target-profiles.js +118 -0
- package/dist_ts_web/appstate/ui.d.ts +11 -0
- package/dist_ts_web/appstate/ui.js +55 -0
- package/dist_ts_web/appstate/users.d.ts +27 -0
- package/dist_ts_web/appstate/users.js +85 -0
- package/dist_ts_web/appstate/vpn.d.ts +44 -0
- package/dist_ts_web/appstate/vpn.js +148 -0
- package/dist_ts_web/appstate.d.ts +20 -568
- package/dist_ts_web/appstate.js +24 -2418
- package/package.json +1 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts_web/00_commitinfo_data.ts +1 -1
- package/ts_web/appstate/acme.ts +93 -0
- package/ts_web/appstate/certificates.ts +159 -0
- package/ts_web/appstate/config.ts +49 -0
- package/ts_web/appstate/domains.ts +429 -0
- package/ts_web/appstate/email-domains.ts +155 -0
- package/ts_web/appstate/email-ops.ts +57 -0
- package/ts_web/appstate/login.ts +128 -0
- package/ts_web/appstate/logs.ts +50 -0
- package/ts_web/appstate/network.ts +161 -0
- package/ts_web/appstate/profiles-targets.ts +240 -0
- package/ts_web/appstate/remoteingress.ts +300 -0
- package/ts_web/appstate/routes.ts +447 -0
- package/ts_web/appstate/runtime.ts +308 -0
- package/ts_web/appstate/security.ts +229 -0
- package/ts_web/appstate/shared.ts +15 -0
- package/ts_web/appstate/stats.ts +79 -0
- package/ts_web/appstate/target-profiles.ts +164 -0
- package/ts_web/appstate/ui.ts +75 -0
- package/ts_web/appstate/users.ts +133 -0
- package/ts_web/appstate/vpn.ts +234 -0
- package/ts_web/appstate.ts +24 -3403
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import * as plugins from '../plugins.js';
|
|
2
|
+
import * as interfaces from '../../ts_interfaces/index.js';
|
|
3
|
+
import { appState } from './shared.js';
|
|
4
|
+
import { getActionContext } from './login.js';
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// Remote Ingress State
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
export interface IRemoteIngressState {
|
|
11
|
+
edges: interfaces.data.IRemoteIngress[];
|
|
12
|
+
statuses: interfaces.data.IRemoteIngressStatus[];
|
|
13
|
+
hubSettings: interfaces.data.IRemoteIngressHubSettings | null;
|
|
14
|
+
selectedEdgeId: string | null;
|
|
15
|
+
newEdgeId: string | null;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
error: string | null;
|
|
18
|
+
lastUpdated: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const remoteIngressStatePart = await appState.getStatePart<IRemoteIngressState>(
|
|
22
|
+
'remoteIngress',
|
|
23
|
+
{
|
|
24
|
+
edges: [],
|
|
25
|
+
statuses: [],
|
|
26
|
+
hubSettings: null,
|
|
27
|
+
selectedEdgeId: null,
|
|
28
|
+
newEdgeId: null,
|
|
29
|
+
isLoading: false,
|
|
30
|
+
error: null,
|
|
31
|
+
lastUpdated: 0,
|
|
32
|
+
},
|
|
33
|
+
'soft'
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Remote Ingress Standalone Functions
|
|
37
|
+
// ============================================================================
|
|
38
|
+
|
|
39
|
+
export async function fetchConnectionToken(edgeId: string) {
|
|
40
|
+
const context = getActionContext();
|
|
41
|
+
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
42
|
+
interfaces.requests.IReq_GetRemoteIngressConnectionToken
|
|
43
|
+
>('/typedrequest', 'getRemoteIngressConnectionToken');
|
|
44
|
+
return request.fire({ identity: context.identity!, edgeId });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Remote Ingress Actions
|
|
49
|
+
// ============================================================================
|
|
50
|
+
|
|
51
|
+
export const fetchRemoteIngressAction = remoteIngressStatePart.createAction(async (statePartArg): Promise<IRemoteIngressState> => {
|
|
52
|
+
const context = getActionContext();
|
|
53
|
+
const currentState = statePartArg.getState()!;
|
|
54
|
+
if (!context.identity) return currentState;
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
const edgesRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
58
|
+
interfaces.requests.IReq_GetRemoteIngresses
|
|
59
|
+
>('/typedrequest', 'getRemoteIngresses');
|
|
60
|
+
|
|
61
|
+
const statusRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
62
|
+
interfaces.requests.IReq_GetRemoteIngressStatus
|
|
63
|
+
>('/typedrequest', 'getRemoteIngressStatus');
|
|
64
|
+
|
|
65
|
+
const hubSettingsRequest = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
66
|
+
interfaces.requests.IReq_GetRemoteIngressHubSettings
|
|
67
|
+
>('/typedrequest', 'getRemoteIngressHubSettings');
|
|
68
|
+
|
|
69
|
+
const [edgesResponse, statusResponse, hubSettingsResponse] = await Promise.all([
|
|
70
|
+
edgesRequest.fire({ identity: context.identity }),
|
|
71
|
+
statusRequest.fire({ identity: context.identity }),
|
|
72
|
+
hubSettingsRequest.fire({ identity: context.identity }),
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
...currentState,
|
|
77
|
+
edges: edgesResponse.edges,
|
|
78
|
+
statuses: statusResponse.statuses,
|
|
79
|
+
hubSettings: hubSettingsResponse.settings,
|
|
80
|
+
isLoading: false,
|
|
81
|
+
error: null,
|
|
82
|
+
lastUpdated: Date.now(),
|
|
83
|
+
};
|
|
84
|
+
} catch (error) {
|
|
85
|
+
return {
|
|
86
|
+
...currentState,
|
|
87
|
+
isLoading: false,
|
|
88
|
+
error: error instanceof Error ? error.message : 'Failed to fetch remote ingress data',
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export const createRemoteIngressAction = remoteIngressStatePart.createAction<{
|
|
94
|
+
name: string;
|
|
95
|
+
listenPorts?: number[];
|
|
96
|
+
autoDerivePorts?: boolean;
|
|
97
|
+
performance?: interfaces.data.IRemoteIngressPerformanceConfig;
|
|
98
|
+
tags?: string[];
|
|
99
|
+
}>(async (statePartArg, dataArg, actionContext): Promise<IRemoteIngressState> => {
|
|
100
|
+
const context = getActionContext();
|
|
101
|
+
const currentState = statePartArg.getState()!;
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
105
|
+
interfaces.requests.IReq_CreateRemoteIngress
|
|
106
|
+
>('/typedrequest', 'createRemoteIngress');
|
|
107
|
+
|
|
108
|
+
const response = await request.fire({
|
|
109
|
+
identity: context.identity!,
|
|
110
|
+
name: dataArg.name,
|
|
111
|
+
listenPorts: dataArg.listenPorts,
|
|
112
|
+
autoDerivePorts: dataArg.autoDerivePorts,
|
|
113
|
+
performance: dataArg.performance,
|
|
114
|
+
tags: dataArg.tags,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if (response.success) {
|
|
118
|
+
// Refresh the list
|
|
119
|
+
await actionContext!.dispatch(fetchRemoteIngressAction, null);
|
|
120
|
+
|
|
121
|
+
return {
|
|
122
|
+
...statePartArg.getState()!,
|
|
123
|
+
newEdgeId: response.edge.id,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return currentState;
|
|
128
|
+
} catch (error: unknown) {
|
|
129
|
+
return {
|
|
130
|
+
...currentState,
|
|
131
|
+
error: error instanceof Error ? error.message : 'Failed to create edge',
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
export const deleteRemoteIngressAction = remoteIngressStatePart.createAction<string>(
|
|
137
|
+
async (statePartArg, edgeId, actionContext): Promise<IRemoteIngressState> => {
|
|
138
|
+
const context = getActionContext();
|
|
139
|
+
const currentState = statePartArg.getState()!;
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
143
|
+
interfaces.requests.IReq_DeleteRemoteIngress
|
|
144
|
+
>('/typedrequest', 'deleteRemoteIngress');
|
|
145
|
+
|
|
146
|
+
await request.fire({
|
|
147
|
+
identity: context.identity!,
|
|
148
|
+
id: edgeId,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
return await actionContext!.dispatch(fetchRemoteIngressAction, null);
|
|
152
|
+
} catch (error: unknown) {
|
|
153
|
+
return {
|
|
154
|
+
...currentState,
|
|
155
|
+
error: error instanceof Error ? error.message : 'Failed to delete edge',
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
export const updateRemoteIngressAction = remoteIngressStatePart.createAction<{
|
|
162
|
+
id: string;
|
|
163
|
+
name?: string;
|
|
164
|
+
listenPorts?: number[];
|
|
165
|
+
autoDerivePorts?: boolean;
|
|
166
|
+
performance?: interfaces.data.IRemoteIngressPerformanceConfig;
|
|
167
|
+
tags?: string[];
|
|
168
|
+
}>(async (statePartArg, dataArg, actionContext): Promise<IRemoteIngressState> => {
|
|
169
|
+
const context = getActionContext();
|
|
170
|
+
const currentState = statePartArg.getState()!;
|
|
171
|
+
|
|
172
|
+
try {
|
|
173
|
+
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
174
|
+
interfaces.requests.IReq_UpdateRemoteIngress
|
|
175
|
+
>('/typedrequest', 'updateRemoteIngress');
|
|
176
|
+
|
|
177
|
+
await request.fire({
|
|
178
|
+
identity: context.identity!,
|
|
179
|
+
id: dataArg.id,
|
|
180
|
+
name: dataArg.name,
|
|
181
|
+
listenPorts: dataArg.listenPorts,
|
|
182
|
+
autoDerivePorts: dataArg.autoDerivePorts,
|
|
183
|
+
performance: dataArg.performance,
|
|
184
|
+
tags: dataArg.tags,
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
return await actionContext!.dispatch(fetchRemoteIngressAction, null);
|
|
188
|
+
} catch (error: unknown) {
|
|
189
|
+
return {
|
|
190
|
+
...currentState,
|
|
191
|
+
error: error instanceof Error ? error.message : 'Failed to update edge',
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
export const updateRemoteIngressHubSettingsAction = remoteIngressStatePart.createAction<{
|
|
197
|
+
enabled?: boolean;
|
|
198
|
+
tunnelPort?: number;
|
|
199
|
+
hubDomain?: string | null;
|
|
200
|
+
performance?: interfaces.data.IRemoteIngressPerformanceConfig | null;
|
|
201
|
+
}>(async (statePartArg, dataArg, actionContext): Promise<IRemoteIngressState> => {
|
|
202
|
+
const context = getActionContext();
|
|
203
|
+
const currentState = statePartArg.getState()!;
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
207
|
+
interfaces.requests.IReq_UpdateRemoteIngressHubSettings
|
|
208
|
+
>('/typedrequest', 'updateRemoteIngressHubSettings');
|
|
209
|
+
|
|
210
|
+
const response = await request.fire({
|
|
211
|
+
identity: context.identity!,
|
|
212
|
+
enabled: dataArg.enabled,
|
|
213
|
+
tunnelPort: dataArg.tunnelPort,
|
|
214
|
+
hubDomain: dataArg.hubDomain,
|
|
215
|
+
performance: dataArg.performance,
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
if (!response.success) {
|
|
219
|
+
return {
|
|
220
|
+
...currentState,
|
|
221
|
+
error: response.message || 'Failed to update RemoteIngress hub settings',
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return await actionContext!.dispatch(fetchRemoteIngressAction, null);
|
|
226
|
+
} catch (error: unknown) {
|
|
227
|
+
return {
|
|
228
|
+
...currentState,
|
|
229
|
+
error: error instanceof Error ? error.message : 'Failed to update RemoteIngress hub settings',
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
export const regenerateRemoteIngressSecretAction = remoteIngressStatePart.createAction<string>(
|
|
235
|
+
async (statePartArg, edgeId): Promise<IRemoteIngressState> => {
|
|
236
|
+
const context = getActionContext();
|
|
237
|
+
const currentState = statePartArg.getState()!;
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
241
|
+
interfaces.requests.IReq_RegenerateRemoteIngressSecret
|
|
242
|
+
>('/typedrequest', 'regenerateRemoteIngressSecret');
|
|
243
|
+
|
|
244
|
+
const response = await request.fire({
|
|
245
|
+
identity: context.identity!,
|
|
246
|
+
id: edgeId,
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
if (response.success) {
|
|
250
|
+
return {
|
|
251
|
+
...currentState,
|
|
252
|
+
newEdgeId: edgeId,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return currentState;
|
|
257
|
+
} catch (error) {
|
|
258
|
+
return {
|
|
259
|
+
...currentState,
|
|
260
|
+
error: error instanceof Error ? error.message : 'Failed to regenerate secret',
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
export const clearNewEdgeIdAction = remoteIngressStatePart.createAction(
|
|
267
|
+
async (statePartArg): Promise<IRemoteIngressState> => {
|
|
268
|
+
return {
|
|
269
|
+
...statePartArg.getState()!,
|
|
270
|
+
newEdgeId: null,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
|
|
275
|
+
export const toggleRemoteIngressAction = remoteIngressStatePart.createAction<{
|
|
276
|
+
id: string;
|
|
277
|
+
enabled: boolean;
|
|
278
|
+
}>(async (statePartArg, dataArg, actionContext): Promise<IRemoteIngressState> => {
|
|
279
|
+
const context = getActionContext();
|
|
280
|
+
const currentState = statePartArg.getState()!;
|
|
281
|
+
|
|
282
|
+
try {
|
|
283
|
+
const request = new plugins.domtools.plugins.typedrequest.TypedRequest<
|
|
284
|
+
interfaces.requests.IReq_UpdateRemoteIngress
|
|
285
|
+
>('/typedrequest', 'updateRemoteIngress');
|
|
286
|
+
|
|
287
|
+
await request.fire({
|
|
288
|
+
identity: context.identity!,
|
|
289
|
+
id: dataArg.id,
|
|
290
|
+
enabled: dataArg.enabled,
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
return await actionContext!.dispatch(fetchRemoteIngressAction, null);
|
|
294
|
+
} catch (error: unknown) {
|
|
295
|
+
return {
|
|
296
|
+
...currentState,
|
|
297
|
+
error: error instanceof Error ? error.message : 'Failed to toggle edge',
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
});
|