@serve.zone/dcrouter 15.0.1 → 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.
Files changed (117) hide show
  1. package/deno.json +1 -1
  2. package/dist_serve/bundle.js +768 -768
  3. package/dist_ts/00_commitinfo_data.js +1 -1
  4. package/dist_ts/acme/classes.smartacme-lifecycle.d.ts +25 -0
  5. package/dist_ts/acme/classes.smartacme-lifecycle.js +144 -0
  6. package/dist_ts/acme/index.d.ts +1 -0
  7. package/dist_ts/acme/index.js +2 -1
  8. package/dist_ts/classes.dcrouter.d.ts +21 -139
  9. package/dist_ts/classes.dcrouter.js +71 -1585
  10. package/dist_ts/dns/classes.dns-server-runtime.d.ts +37 -0
  11. package/dist_ts/dns/classes.dns-server-runtime.js +449 -0
  12. package/dist_ts/dns/index.d.ts +1 -0
  13. package/dist_ts/dns/index.js +2 -1
  14. package/dist_ts/email/classes.accepted-email-spool.d.ts +55 -0
  15. package/dist_ts/email/classes.accepted-email-spool.js +345 -0
  16. package/dist_ts/email/classes.email-route-builder.d.ts +28 -0
  17. package/dist_ts/email/classes.email-route-builder.js +260 -0
  18. package/dist_ts/email/index.d.ts +2 -0
  19. package/dist_ts/email/index.js +3 -1
  20. package/dist_ts/opsserver/handlers/gatewayclient.handler.js +10 -8
  21. package/dist_ts/remoteingress/classes.hub-lifecycle.d.ts +27 -0
  22. package/dist_ts/remoteingress/classes.hub-lifecycle.js +241 -0
  23. package/dist_ts/remoteingress/classes.remoteingress-manager.d.ts +1 -2
  24. package/dist_ts/remoteingress/index.d.ts +1 -0
  25. package/dist_ts/remoteingress/index.js +2 -1
  26. package/dist_ts/security/classes.route-policy-augmenter.d.ts +22 -0
  27. package/dist_ts/security/classes.route-policy-augmenter.js +120 -0
  28. package/dist_ts/security/index.d.ts +1 -0
  29. package/dist_ts/security/index.js +2 -1
  30. package/dist_ts/vpn/classes.vpn-access-resolver.d.ts +34 -0
  31. package/dist_ts/vpn/classes.vpn-access-resolver.js +101 -0
  32. package/dist_ts/vpn/index.d.ts +1 -0
  33. package/dist_ts/vpn/index.js +2 -1
  34. package/dist_ts_migrations/index.js +92 -9
  35. package/dist_ts_web/00_commitinfo_data.js +1 -1
  36. package/dist_ts_web/appstate/acme.d.ts +17 -0
  37. package/dist_ts_web/appstate/acme.js +64 -0
  38. package/dist_ts_web/appstate/certificates.d.ts +37 -0
  39. package/dist_ts_web/appstate/certificates.js +107 -0
  40. package/dist_ts_web/appstate/config.d.ts +9 -0
  41. package/dist_ts_web/appstate/config.js +35 -0
  42. package/dist_ts_web/appstate/domains.d.ts +80 -0
  43. package/dist_ts_web/appstate/domains.js +324 -0
  44. package/dist_ts_web/appstate/email-domains.d.ts +25 -0
  45. package/dist_ts_web/appstate/email-domains.js +104 -0
  46. package/dist_ts_web/appstate/email-ops.d.ts +10 -0
  47. package/dist_ts_web/appstate/email-ops.js +40 -0
  48. package/dist_ts_web/appstate/login.d.ts +30 -0
  49. package/dist_ts_web/appstate/login.js +83 -0
  50. package/dist_ts_web/appstate/logs.d.ts +16 -0
  51. package/dist_ts_web/appstate/logs.js +27 -0
  52. package/dist_ts_web/appstate/network.d.ts +50 -0
  53. package/dist_ts_web/appstate/network.js +122 -0
  54. package/dist_ts_web/appstate/profiles-targets.d.ts +45 -0
  55. package/dist_ts_web/appstate/profiles-targets.js +173 -0
  56. package/dist_ts_web/appstate/remoteingress.d.ts +47 -0
  57. package/dist_ts_web/appstate/remoteingress.js +204 -0
  58. package/dist_ts_web/appstate/routes.d.ts +76 -0
  59. package/dist_ts_web/appstate/routes.js +316 -0
  60. package/dist_ts_web/appstate/runtime.d.ts +1 -0
  61. package/dist_ts_web/appstate/runtime.js +276 -0
  62. package/dist_ts_web/appstate/security.d.ts +29 -0
  63. package/dist_ts_web/appstate/security.js +167 -0
  64. package/dist_ts_web/appstate/shared.d.ts +3 -0
  65. package/dist_ts_web/appstate/shared.js +13 -0
  66. package/dist_ts_web/appstate/stats.d.ts +15 -0
  67. package/dist_ts_web/appstate/stats.js +59 -0
  68. package/dist_ts_web/appstate/target-profiles.d.ts +37 -0
  69. package/dist_ts_web/appstate/target-profiles.js +118 -0
  70. package/dist_ts_web/appstate/ui.d.ts +11 -0
  71. package/dist_ts_web/appstate/ui.js +55 -0
  72. package/dist_ts_web/appstate/users.d.ts +27 -0
  73. package/dist_ts_web/appstate/users.js +85 -0
  74. package/dist_ts_web/appstate/vpn.d.ts +44 -0
  75. package/dist_ts_web/appstate/vpn.js +148 -0
  76. package/dist_ts_web/appstate.d.ts +20 -568
  77. package/dist_ts_web/appstate.js +24 -2418
  78. package/package.json +1 -1
  79. package/ts/00_commitinfo_data.ts +1 -1
  80. package/ts/acme/classes.smartacme-lifecycle.ts +155 -0
  81. package/ts/acme/index.ts +1 -0
  82. package/ts/classes.dcrouter.ts +118 -1919
  83. package/ts/dns/classes.dns-server-runtime.ts +525 -0
  84. package/ts/dns/index.ts +1 -0
  85. package/ts/email/classes.accepted-email-spool.ts +434 -0
  86. package/ts/email/classes.email-route-builder.ts +312 -0
  87. package/ts/email/index.ts +2 -0
  88. package/ts/opsserver/handlers/gatewayclient.handler.ts +9 -7
  89. package/ts/remoteingress/classes.hub-lifecycle.ts +278 -0
  90. package/ts/remoteingress/classes.remoteingress-manager.ts +1 -1
  91. package/ts/remoteingress/index.ts +1 -0
  92. package/ts/security/classes.route-policy-augmenter.ts +140 -0
  93. package/ts/security/index.ts +1 -0
  94. package/ts/vpn/classes.vpn-access-resolver.ts +126 -0
  95. package/ts/vpn/index.ts +1 -0
  96. package/ts_web/00_commitinfo_data.ts +1 -1
  97. package/ts_web/appstate/acme.ts +93 -0
  98. package/ts_web/appstate/certificates.ts +159 -0
  99. package/ts_web/appstate/config.ts +49 -0
  100. package/ts_web/appstate/domains.ts +429 -0
  101. package/ts_web/appstate/email-domains.ts +155 -0
  102. package/ts_web/appstate/email-ops.ts +57 -0
  103. package/ts_web/appstate/login.ts +128 -0
  104. package/ts_web/appstate/logs.ts +50 -0
  105. package/ts_web/appstate/network.ts +161 -0
  106. package/ts_web/appstate/profiles-targets.ts +240 -0
  107. package/ts_web/appstate/remoteingress.ts +300 -0
  108. package/ts_web/appstate/routes.ts +447 -0
  109. package/ts_web/appstate/runtime.ts +308 -0
  110. package/ts_web/appstate/security.ts +229 -0
  111. package/ts_web/appstate/shared.ts +15 -0
  112. package/ts_web/appstate/stats.ts +79 -0
  113. package/ts_web/appstate/target-profiles.ts +164 -0
  114. package/ts_web/appstate/ui.ts +75 -0
  115. package/ts_web/appstate/users.ts +133 -0
  116. package/ts_web/appstate/vpn.ts +234 -0
  117. 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
+ });