@serve.zone/dcrouter-apiclient 32.3.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.
Files changed (200) hide show
  1. package/dist_ts_apiclient/classes.apitoken.d.ts +41 -0
  2. package/dist_ts_apiclient/classes.apitoken.js +115 -0
  3. package/dist_ts_apiclient/classes.certificate.d.ts +57 -0
  4. package/dist_ts_apiclient/classes.certificate.js +69 -0
  5. package/dist_ts_apiclient/classes.config.d.ts +7 -0
  6. package/dist_ts_apiclient/classes.config.js +11 -0
  7. package/dist_ts_apiclient/classes.dcrouterapiclient.d.ts +54 -0
  8. package/dist_ts_apiclient/classes.dcrouterapiclient.js +97 -0
  9. package/dist_ts_apiclient/classes.email.d.ts +30 -0
  10. package/dist_ts_apiclient/classes.email.js +52 -0
  11. package/dist_ts_apiclient/classes.gatewayclient.d.ts +28 -0
  12. package/dist_ts_apiclient/classes.gatewayclient.js +52 -0
  13. package/dist_ts_apiclient/classes.logs.d.ts +28 -0
  14. package/dist_ts_apiclient/classes.logs.js +69 -0
  15. package/dist_ts_apiclient/classes.radius.d.ts +59 -0
  16. package/dist_ts_apiclient/classes.radius.js +95 -0
  17. package/dist_ts_apiclient/classes.remoteingress.d.ts +66 -0
  18. package/dist_ts_apiclient/classes.remoteingress.js +164 -0
  19. package/dist_ts_apiclient/classes.route.d.ts +39 -0
  20. package/dist_ts_apiclient/classes.route.js +125 -0
  21. package/dist_ts_apiclient/classes.stats.d.ts +47 -0
  22. package/dist_ts_apiclient/classes.stats.js +38 -0
  23. package/dist_ts_apiclient/classes.testing.d.ts +65 -0
  24. package/dist_ts_apiclient/classes.testing.js +120 -0
  25. package/dist_ts_apiclient/index.d.ts +12 -0
  26. package/dist_ts_apiclient/index.js +16 -0
  27. package/dist_ts_apiclient/plugins.d.ts +4 -0
  28. package/dist_ts_apiclient/plugins.js +6 -0
  29. package/dist_ts_interfaces/data/acme-config.d.ts +23 -0
  30. package/dist_ts_interfaces/data/acme-config.js +2 -0
  31. package/dist_ts_interfaces/data/auth.d.ts +8 -0
  32. package/dist_ts_interfaces/data/auth.js +2 -0
  33. package/dist_ts_interfaces/data/config-events.d.ts +34 -0
  34. package/dist_ts_interfaces/data/config-events.js +8 -0
  35. package/dist_ts_interfaces/data/dns-authority.d.ts +98 -0
  36. package/dist_ts_interfaces/data/dns-authority.js +26 -0
  37. package/dist_ts_interfaces/data/dns-provider.d.ts +136 -0
  38. package/dist_ts_interfaces/data/dns-provider.js +41 -0
  39. package/dist_ts_interfaces/data/dns-record.d.ts +48 -0
  40. package/dist_ts_interfaces/data/dns-record.js +2 -0
  41. package/dist_ts_interfaces/data/domain.d.ts +35 -0
  42. package/dist_ts_interfaces/data/domain.js +2 -0
  43. package/dist_ts_interfaces/data/email-domain.d.ts +177 -0
  44. package/dist_ts_interfaces/data/email-domain.js +2 -0
  45. package/dist_ts_interfaces/data/email-settings.d.ts +68 -0
  46. package/dist_ts_interfaces/data/email-settings.js +2 -0
  47. package/dist_ts_interfaces/data/index.d.ts +18 -0
  48. package/dist_ts_interfaces/data/index.js +19 -0
  49. package/dist_ts_interfaces/data/remoteingress.d.ts +181 -0
  50. package/dist_ts_interfaces/data/remoteingress.js +15 -0
  51. package/dist_ts_interfaces/data/route-management.d.ts +270 -0
  52. package/dist_ts_interfaces/data/route-management.js +130 -0
  53. package/dist_ts_interfaces/data/security-policy.d.ts +32 -0
  54. package/dist_ts_interfaces/data/security-policy.js +2 -0
  55. package/dist_ts_interfaces/data/smtp-account.d.ts +50 -0
  56. package/dist_ts_interfaces/data/smtp-account.js +9 -0
  57. package/dist_ts_interfaces/data/stats.d.ts +283 -0
  58. package/dist_ts_interfaces/data/stats.js +2 -0
  59. package/dist_ts_interfaces/data/target-profile.d.ts +30 -0
  60. package/dist_ts_interfaces/data/target-profile.js +2 -0
  61. package/dist_ts_interfaces/data/testing.d.ts +191 -0
  62. package/dist_ts_interfaces/data/testing.js +20 -0
  63. package/dist_ts_interfaces/data/vpn.d.ts +65 -0
  64. package/dist_ts_interfaces/data/vpn.js +2 -0
  65. package/dist_ts_interfaces/data/workhoster.d.ts +63 -0
  66. package/dist_ts_interfaces/data/workhoster.js +2 -0
  67. package/dist_ts_interfaces/index.d.ts +5 -0
  68. package/dist_ts_interfaces/index.js +8 -0
  69. package/dist_ts_interfaces/plugins.d.ts +2 -0
  70. package/dist_ts_interfaces/plugins.js +4 -0
  71. package/dist_ts_interfaces/requests/acme-config.d.ts +42 -0
  72. package/dist_ts_interfaces/requests/acme-config.js +2 -0
  73. package/dist_ts_interfaces/requests/admin.d.ts +69 -0
  74. package/dist_ts_interfaces/requests/admin.js +3 -0
  75. package/dist_ts_interfaces/requests/api-tokens.d.ts +85 -0
  76. package/dist_ts_interfaces/requests/api-tokens.js +2 -0
  77. package/dist_ts_interfaces/requests/certificate.d.ts +87 -0
  78. package/dist_ts_interfaces/requests/certificate.js +5 -0
  79. package/dist_ts_interfaces/requests/combined.stats.d.ts +29 -0
  80. package/dist_ts_interfaces/requests/combined.stats.js +2 -0
  81. package/dist_ts_interfaces/requests/config-events.d.ts +35 -0
  82. package/dist_ts_interfaces/requests/config-events.js +4 -0
  83. package/dist_ts_interfaces/requests/config.d.ts +93 -0
  84. package/dist_ts_interfaces/requests/config.js +3 -0
  85. package/dist_ts_interfaces/requests/dns-authority.d.ts +80 -0
  86. package/dist_ts_interfaces/requests/dns-authority.js +3 -0
  87. package/dist_ts_interfaces/requests/dns-providers.d.ts +117 -0
  88. package/dist_ts_interfaces/requests/dns-providers.js +2 -0
  89. package/dist_ts_interfaces/requests/dns-records.d.ts +89 -0
  90. package/dist_ts_interfaces/requests/dns-records.js +2 -0
  91. package/dist_ts_interfaces/requests/domains.d.ts +142 -0
  92. package/dist_ts_interfaces/requests/domains.js +2 -0
  93. package/dist_ts_interfaces/requests/email-domains.d.ts +154 -0
  94. package/dist_ts_interfaces/requests/email-domains.js +2 -0
  95. package/dist_ts_interfaces/requests/email-ops.d.ts +211 -0
  96. package/dist_ts_interfaces/requests/email-ops.js +3 -0
  97. package/dist_ts_interfaces/requests/email-settings.d.ts +26 -0
  98. package/dist_ts_interfaces/requests/email-settings.js +2 -0
  99. package/dist_ts_interfaces/requests/index.d.ts +29 -0
  100. package/dist_ts_interfaces/requests/index.js +30 -0
  101. package/dist_ts_interfaces/requests/logs.d.ts +43 -0
  102. package/dist_ts_interfaces/requests/logs.js +4 -0
  103. package/dist_ts_interfaces/requests/network-targets.d.ts +102 -0
  104. package/dist_ts_interfaces/requests/network-targets.js +2 -0
  105. package/dist_ts_interfaces/requests/radius.d.ts +280 -0
  106. package/dist_ts_interfaces/requests/radius.js +3 -0
  107. package/dist_ts_interfaces/requests/realtime.d.ts +38 -0
  108. package/dist_ts_interfaces/requests/realtime.js +12 -0
  109. package/dist_ts_interfaces/requests/remoteingress.d.ts +162 -0
  110. package/dist_ts_interfaces/requests/remoteingress.js +3 -0
  111. package/dist_ts_interfaces/requests/route-management.d.ts +147 -0
  112. package/dist_ts_interfaces/requests/route-management.js +2 -0
  113. package/dist_ts_interfaces/requests/security-policy.d.ts +105 -0
  114. package/dist_ts_interfaces/requests/security-policy.js +2 -0
  115. package/dist_ts_interfaces/requests/smtp-accounts.d.ts +125 -0
  116. package/dist_ts_interfaces/requests/smtp-accounts.js +2 -0
  117. package/dist_ts_interfaces/requests/source-profiles.d.ts +102 -0
  118. package/dist_ts_interfaces/requests/source-profiles.js +2 -0
  119. package/dist_ts_interfaces/requests/stats.d.ts +196 -0
  120. package/dist_ts_interfaces/requests/stats.js +4 -0
  121. package/dist_ts_interfaces/requests/target-profiles.d.ts +105 -0
  122. package/dist_ts_interfaces/requests/target-profiles.js +2 -0
  123. package/dist_ts_interfaces/requests/testing.d.ts +169 -0
  124. package/dist_ts_interfaces/requests/testing.js +2 -0
  125. package/dist_ts_interfaces/requests/users.d.ts +53 -0
  126. package/dist_ts_interfaces/requests/users.js +3 -0
  127. package/dist_ts_interfaces/requests/vpn.d.ts +188 -0
  128. package/dist_ts_interfaces/requests/vpn.js +3 -0
  129. package/dist_ts_interfaces/requests/workhoster.d.ts +79 -0
  130. package/dist_ts_interfaces/requests/workhoster.js +2 -0
  131. package/license +21 -0
  132. package/package.json +67 -0
  133. package/readme.md +218 -0
  134. package/ts_apiclient/classes.apitoken.ts +157 -0
  135. package/ts_apiclient/classes.certificate.ts +124 -0
  136. package/ts_apiclient/classes.config.ts +17 -0
  137. package/ts_apiclient/classes.dcrouterapiclient.ts +138 -0
  138. package/ts_apiclient/classes.email.ts +77 -0
  139. package/ts_apiclient/classes.gatewayclient.ts +110 -0
  140. package/ts_apiclient/classes.logs.ts +91 -0
  141. package/ts_apiclient/classes.radius.ts +180 -0
  142. package/ts_apiclient/classes.remoteingress.ts +217 -0
  143. package/ts_apiclient/classes.route.ts +166 -0
  144. package/ts_apiclient/classes.stats.ts +111 -0
  145. package/ts_apiclient/classes.testing.ts +152 -0
  146. package/ts_apiclient/index.ts +17 -0
  147. package/ts_apiclient/plugins.ts +10 -0
  148. package/ts_apiclient/readme.md +218 -0
  149. package/ts_interfaces/data/acme-config.ts +23 -0
  150. package/ts_interfaces/data/auth.ts +8 -0
  151. package/ts_interfaces/data/config-events.ts +38 -0
  152. package/ts_interfaces/data/dns-authority.ts +106 -0
  153. package/ts_interfaces/data/dns-provider.ts +174 -0
  154. package/ts_interfaces/data/dns-record.ts +50 -0
  155. package/ts_interfaces/data/domain.ts +36 -0
  156. package/ts_interfaces/data/email-domain.ts +206 -0
  157. package/ts_interfaces/data/email-settings.ts +75 -0
  158. package/ts_interfaces/data/index.ts +18 -0
  159. package/ts_interfaces/data/remoteingress.ts +204 -0
  160. package/ts_interfaces/data/route-management.ts +436 -0
  161. package/ts_interfaces/data/security-policy.ts +37 -0
  162. package/ts_interfaces/data/smtp-account.ts +63 -0
  163. package/ts_interfaces/data/stats.ts +305 -0
  164. package/ts_interfaces/data/target-profile.ts +31 -0
  165. package/ts_interfaces/data/testing.ts +184 -0
  166. package/ts_interfaces/data/vpn.ts +68 -0
  167. package/ts_interfaces/data/workhoster.ts +72 -0
  168. package/ts_interfaces/index.ts +9 -0
  169. package/ts_interfaces/plugins.ts +6 -0
  170. package/ts_interfaces/readme.md +194 -0
  171. package/ts_interfaces/requests/acme-config.ts +54 -0
  172. package/ts_interfaces/requests/admin.ts +96 -0
  173. package/ts_interfaces/requests/api-tokens.ts +109 -0
  174. package/ts_interfaces/requests/certificate.ts +106 -0
  175. package/ts_interfaces/requests/combined.stats.ts +30 -0
  176. package/ts_interfaces/requests/config-events.ts +45 -0
  177. package/ts_interfaces/requests/config.ts +94 -0
  178. package/ts_interfaces/requests/dns-authority.ts +104 -0
  179. package/ts_interfaces/requests/dns-providers.ts +154 -0
  180. package/ts_interfaces/requests/dns-records.ts +113 -0
  181. package/ts_interfaces/requests/domains.ts +178 -0
  182. package/ts_interfaces/requests/email-domains.ts +193 -0
  183. package/ts_interfaces/requests/email-ops.ts +266 -0
  184. package/ts_interfaces/requests/email-settings.ts +34 -0
  185. package/ts_interfaces/requests/index.ts +29 -0
  186. package/ts_interfaces/requests/logs.ts +58 -0
  187. package/ts_interfaces/requests/network-targets.ts +127 -0
  188. package/ts_interfaces/requests/radius.ts +341 -0
  189. package/ts_interfaces/requests/realtime.ts +59 -0
  190. package/ts_interfaces/requests/remoteingress.ts +202 -0
  191. package/ts_interfaces/requests/route-management.ts +194 -0
  192. package/ts_interfaces/requests/security-policy.ts +144 -0
  193. package/ts_interfaces/requests/smtp-accounts.ts +163 -0
  194. package/ts_interfaces/requests/source-profiles.ts +127 -0
  195. package/ts_interfaces/requests/stats.ts +207 -0
  196. package/ts_interfaces/requests/target-profiles.ts +130 -0
  197. package/ts_interfaces/requests/testing.ts +186 -0
  198. package/ts_interfaces/requests/users.ts +66 -0
  199. package/ts_interfaces/requests/vpn.ts +238 -0
  200. package/ts_interfaces/requests/workhoster.ts +100 -0
@@ -0,0 +1,436 @@
1
+ import type { IRouteConfig } from '@push.rocks/smartproxy';
2
+ import type { IRouteChallengeConfig } from '@push.rocks/smartchallenge';
3
+ import type * as servezoneInterfaces from '@serve.zone/interfaces';
4
+ import type { IDcRouterRouteConfig, IRouteRemoteIngress } from './remoteingress.js';
5
+
6
+ type TSmartProxyRouteRateLimit = NonNullable<NonNullable<IRouteConfig['security']>['rateLimit']>;
7
+ export type TRouteRateLimitExceededPolicy = NonNullable<TSmartProxyRouteRateLimit['onExceeded']>;
8
+
9
+ export interface IRouteRateLimit extends TSmartProxyRouteRateLimit {
10
+ onExceeded?: TRouteRateLimitExceededPolicy;
11
+ }
12
+
13
+ type TSmartProxyRouteSecurityBase = Omit<NonNullable<IRouteConfig['security']>, 'rateLimit' | 'challenge'>;
14
+
15
+ // Derive most security fields from SmartProxy and extend route protection fields
16
+ // with dcrouter's source-policy tri-state semantics.
17
+ export interface IRouteSecurity extends TSmartProxyRouteSecurityBase {
18
+ rateLimit?: IRouteRateLimit | null;
19
+ challenge?: IRouteChallengeConfig | null;
20
+ }
21
+
22
+ // ============================================================================
23
+ // Route Management Data Types
24
+ // ============================================================================
25
+
26
+ export const apiTokenScopes = [
27
+ '*',
28
+ 'routes:read',
29
+ 'routes:write',
30
+ 'config:read',
31
+ 'stats:read',
32
+ 'logs:read',
33
+ 'config-events:read',
34
+ 'config-events:write',
35
+ 'security:read',
36
+ 'security:write',
37
+ 'emails:read',
38
+ 'emails:write',
39
+ 'certificates:read',
40
+ 'certificates:write',
41
+ 'tokens:read',
42
+ 'tokens:manage',
43
+ 'users:read',
44
+ 'users:manage',
45
+ 'source-profiles:read',
46
+ 'source-profiles:write',
47
+ 'target-profiles:read',
48
+ 'target-profiles:write',
49
+ 'targets:read',
50
+ 'targets:write',
51
+ 'dns-providers:read',
52
+ 'dns-providers:write',
53
+ 'domains:read',
54
+ 'domains:write',
55
+ 'dns-authority:read',
56
+ 'dns-authority:write',
57
+ 'dns-records:read',
58
+ 'dns-records:write',
59
+ 'acme-config:read',
60
+ 'acme-config:write',
61
+ 'email-domains:read',
62
+ 'email-domains:write',
63
+ 'smtp-accounts:read',
64
+ 'smtp-accounts:write',
65
+ 'remote-ingress:read',
66
+ 'remote-ingress:write',
67
+ 'vpn:read',
68
+ 'vpn:write',
69
+ 'radius:read',
70
+ 'radius:write',
71
+ 'gateway-clients:read',
72
+ 'gateway-clients:write',
73
+ 'workhosters:read',
74
+ 'workhosters:write',
75
+ 'testing:read',
76
+ 'testing:write',
77
+ 'testing:manage',
78
+ ] as const;
79
+
80
+ export type TApiTokenScope = typeof apiTokenScopes[number];
81
+
82
+ export type TGatewayClientType = 'onebox' | 'cloudly' | 'custom';
83
+
84
+ export interface IApiTokenPolicy {
85
+ role: 'admin' | 'gatewayClient' | 'operator' | 'testingClient';
86
+ scopes?: TApiTokenScope[];
87
+ testingClient?: {
88
+ registrationId: string;
89
+ credentialGeneration: number;
90
+ };
91
+ gatewayClient?: {
92
+ type: TGatewayClientType;
93
+ id: string;
94
+ policyGeneration: number;
95
+ };
96
+ hostnamePatterns?: string[];
97
+ allowedRouteTargets?: Array<{
98
+ host: string;
99
+ ports: number[];
100
+ allowAnyPort?: boolean;
101
+ }>;
102
+ capabilities?: {
103
+ readDomains?: boolean;
104
+ readDnsRecords?: boolean;
105
+ readRoutes?: boolean;
106
+ syncRoutes?: boolean;
107
+ syncDnsRecords?: boolean;
108
+ readMail?: boolean;
109
+ manageMail?: boolean;
110
+ readCertificates?: boolean;
111
+ requestCertificates?: boolean;
112
+ readWebPush?: boolean;
113
+ manageWebPush?: boolean;
114
+ };
115
+ }
116
+
117
+ export interface IGatewayCredentialLifecycle {
118
+ source: 'provisioned';
119
+ state: 'candidate' | 'active';
120
+ /** Strictly monotonic within one gateway client. */
121
+ sequence: number;
122
+ /** Generation this credential was issued to activate. */
123
+ policyGeneration: number;
124
+ /** Digest of the exact durable policy snapshot this credential may activate. */
125
+ policyDigest: string;
126
+ /** Set once when a provisioned candidate first becomes active. */
127
+ finalizedAt: number | null;
128
+ /** Set only after older provisioned credentials have been durably cleaned up. */
129
+ cleanupCompletedAt: number | null;
130
+ /** Stable response value retained for idempotent finalization retries. */
131
+ revokedCredentialCount: number | null;
132
+ }
133
+
134
+ // ============================================================================
135
+ // Source Profile Types (source-side: who can access)
136
+ // ============================================================================
137
+
138
+ /**
139
+ * A reusable, named source profile that can be referenced by routes.
140
+ * Stores the full IRouteSecurity shape from SmartProxy.
141
+ *
142
+ * SourceProfile = source-side (who can access: ipAllowList, rateLimit, auth)
143
+ * TargetProfile = target-side (what can be accessed: domains, IP:port targets, route refs)
144
+ */
145
+ export interface ISourceProfile {
146
+ id: string;
147
+ name: string;
148
+ description?: string;
149
+ /** The security configuration — mirrors SmartProxy's IRouteSecurity. */
150
+ security: IRouteSecurity;
151
+ /** IDs of profiles this one extends (resolved top-down, later overrides earlier). */
152
+ extendsProfiles?: string[];
153
+ createdAt: number;
154
+ updatedAt: number;
155
+ createdBy: string;
156
+ }
157
+
158
+ export interface IRouteSourcePolicyExceededAction {
159
+ type: '429';
160
+ errorMessage?: string;
161
+ }
162
+
163
+ export const routePathClasses = [
164
+ 'git-smart-http',
165
+ 'static',
166
+ 'normal-html',
167
+ 'expensive-html',
168
+ 'raw',
169
+ 'archive',
170
+ ] as const;
171
+
172
+ export type TRoutePathClass = typeof routePathClasses[number];
173
+
174
+ export const giteaRoutePathClassLabels: Record<TRoutePathClass, string> = {
175
+ 'git-smart-http': 'Git Smart HTTP',
176
+ static: 'Static Assets',
177
+ 'normal-html': 'Normal HTML',
178
+ 'expensive-html': 'Expensive HTML',
179
+ raw: 'Raw Files',
180
+ archive: 'Archives',
181
+ };
182
+
183
+ export const giteaRoutePathClassPatterns: Record<TRoutePathClass, string[]> = {
184
+ 'git-smart-http': [
185
+ '/*/*.git/info/refs',
186
+ '/*/*.git/git-upload-pack',
187
+ '/*/*.git/git-receive-pack',
188
+ '/*/*.git/info/lfs',
189
+ '/*/*.git/info/lfs/*',
190
+ ],
191
+ static: [
192
+ '/assets/*',
193
+ '/avatars/*',
194
+ '/repo-avatars/*',
195
+ '/user/avatar/*',
196
+ '/img/*',
197
+ '/css/*',
198
+ '/js/*',
199
+ '/fonts/*',
200
+ '/favicon.ico',
201
+ ],
202
+ 'normal-html': [],
203
+ 'expensive-html': [
204
+ '/explore/*',
205
+ '/issues',
206
+ '/issues/*',
207
+ '/pulls',
208
+ '/pulls/*',
209
+ '/search',
210
+ '/*/*/commits/*',
211
+ '/*/*/graph',
212
+ '/*/*/activity',
213
+ '/*/*/stars',
214
+ '/*/*/forks',
215
+ '/*/*/watchers',
216
+ '/*/*/issues',
217
+ '/*/*/pulls',
218
+ '/*/*/projects',
219
+ '/*/*/actions',
220
+ '/*/*/packages',
221
+ ],
222
+ raw: [
223
+ '/*/*/raw/*',
224
+ '/*/*/src/*',
225
+ ],
226
+ archive: [
227
+ '/*/*/archive/*',
228
+ '/*/*/releases/download/*',
229
+ ],
230
+ };
231
+
232
+ export interface IRoutePathPolicyBinding {
233
+ id?: string;
234
+ pathClass: TRoutePathClass;
235
+ /** Optional custom patterns. When omitted, the Gitea defaults for the class are used. */
236
+ pathPatterns?: string[];
237
+ /** Optional path-class override for the source binding's rate limit. */
238
+ rateLimit?: IRouteSecurity['rateLimit'];
239
+ /** Optional path-class override for the source binding's browser challenge. */
240
+ challenge?: IRouteSecurity['challenge'];
241
+ /** Optional path-class override for the source binding's connection limit. */
242
+ maxConnections?: IRouteSecurity['maxConnections'];
243
+ onExceeded?: IRouteSourcePolicyExceededAction;
244
+ }
245
+
246
+ export interface IRouteSourceBinding {
247
+ id?: string;
248
+ sourceProfileRef: string;
249
+ /** Snapshot of the profile name at resolution time, for display. */
250
+ sourceProfileName?: string;
251
+ /** Optional route-level override for the referenced profile's rate limit. */
252
+ rateLimit?: IRouteSecurity['rateLimit'];
253
+ /** Optional route-level override for the referenced profile's browser challenge. */
254
+ challenge?: IRouteSecurity['challenge'];
255
+ /** Optional route-level override for the referenced profile's connection limit. */
256
+ maxConnections?: IRouteSecurity['maxConnections'];
257
+ /** Optional exceeded message for source-policy connection/rate responses; rate-limit challenge lives on rateLimit.onExceeded. */
258
+ onExceeded?: IRouteSourcePolicyExceededAction;
259
+ /** Optional path-class variants inside this source binding. Path-specific variants win over fallback variants. */
260
+ pathPolicies?: IRoutePathPolicyBinding[];
261
+ }
262
+
263
+ // ============================================================================
264
+ // Network Target Types
265
+ // ============================================================================
266
+
267
+ /**
268
+ * A reusable, named network target (host + port) that can be referenced by routes.
269
+ */
270
+ export interface INetworkTarget {
271
+ id: string;
272
+ name: string;
273
+ description?: string;
274
+ host: string | string[];
275
+ port: number;
276
+ createdAt: number;
277
+ updatedAt: number;
278
+ createdBy: string;
279
+ }
280
+
281
+ // ============================================================================
282
+ // Route Metadata Types
283
+ // ============================================================================
284
+
285
+ export const managedRouteKinds = ['letsencrypt-http01-forward'] as const;
286
+ export type TManagedRouteKind = typeof managedRouteKinds[number];
287
+
288
+ /**
289
+ * Operator input for a canonical Let's Encrypt HTTP-01 forward.
290
+ * Match port, path, protocol, priority, and source policy are server-managed.
291
+ */
292
+ export interface ILetsEncryptHttp01ForwardConfig {
293
+ name: string;
294
+ domains: string[];
295
+ target?: {
296
+ host: string;
297
+ port: number;
298
+ };
299
+ networkTargetRef?: string;
300
+ remoteIngress?: IRouteRemoteIngress;
301
+ }
302
+
303
+ /**
304
+ * Metadata on a stored route tracking where its resolved values came from.
305
+ */
306
+ export interface IRouteMetadata {
307
+ /** Ordered source profile bindings. The first matching source profile wins. */
308
+ sourceBindings?: IRouteSourceBinding[];
309
+ /** ID of the NetworkTargetDoc used to resolve this route's targets. */
310
+ networkTargetRef?: string;
311
+ /** Snapshot of the target name at resolution time, for display. */
312
+ networkTargetName?: string;
313
+ /** Timestamp of last reference resolution. */
314
+ lastResolvedAt?: number;
315
+ /** External route ownership, used by gateway client reconciliation. */
316
+ ownerType?: 'gatewayClient' | 'operator' | 'system';
317
+ gatewayClientType?: TGatewayClientType;
318
+ gatewayClientId?: string;
319
+ gatewayClientAppId?: string;
320
+ externalKey?: string;
321
+ /** Persisted DNS intent for gateway route reconciliation. */
322
+ gatewayDnsMode?: servezoneInterfaces.data.TGatewayRouteDnsMode;
323
+ /** Persisted provider proxy intent for gateway-managed DNS records. */
324
+ gatewayDnsProxied?: boolean;
325
+ /** Canonical server-managed route purpose. */
326
+ managedRouteKind?: TManagedRouteKind;
327
+ }
328
+
329
+ /**
330
+ * A route entry returned by the route management API.
331
+ */
332
+ export interface IMergedRoute {
333
+ route: IDcRouterRouteConfig;
334
+ id: string;
335
+ enabled: boolean;
336
+ origin: 'config' | 'email' | 'dns' | 'api';
337
+ systemKey?: string;
338
+ createdAt?: number;
339
+ updatedAt?: number;
340
+ metadata?: IRouteMetadata;
341
+ }
342
+
343
+ /**
344
+ * A warning generated during route startup/apply.
345
+ */
346
+ export interface IRouteWarning {
347
+ /**
348
+ * - 'disabled-route' → the route exists but is switched off.
349
+ * - 'unverified-domain-ownership' → the route requests an automatic
350
+ * certificate for a domain whose ownership dcrouter cannot prove, so ACME
351
+ * can never succeed for it. Surfaced rather than refused for already-stored
352
+ * routes; new and updated routes are refused outright.
353
+ */
354
+ type: 'disabled-route' | 'unverified-domain-ownership';
355
+ routeName: string;
356
+ message: string;
357
+ }
358
+
359
+ export type THttpRedirectStatus = 'active' | 'covered' | 'skipped';
360
+
361
+ /**
362
+ * Derived HTTP-to-HTTPS redirect shown in the Ops UI.
363
+ * These entries are generated from configured HTTPS routes and are not stored as routes.
364
+ */
365
+ export interface IHttpRedirectInfo {
366
+ id: string;
367
+ status: THttpRedirectStatus;
368
+ domainPattern: string;
369
+ pathPattern?: string;
370
+ fromTemplate: string;
371
+ toTemplate: string;
372
+ statusCode: number;
373
+ priority: number;
374
+ sourceRouteNames: string[];
375
+ sourceRouteIds: string[];
376
+ coveredByRouteNames: string[];
377
+ remoteIngress: boolean;
378
+ notes?: string;
379
+ }
380
+
381
+ /** Return the stored route ID behind a source-policy-compiled route variant. */
382
+ export function canonicalizeSourceRouteId(routeId: string): string {
383
+ const sourceVariantIndex = routeId.indexOf(':source:');
384
+ return sourceVariantIndex === -1 ? routeId : routeId.slice(0, sourceVariantIndex);
385
+ }
386
+
387
+ /**
388
+ * Public info about an API token (never includes the hash).
389
+ */
390
+ export interface IApiTokenInfo {
391
+ id: string;
392
+ name: string;
393
+ scopes: TApiTokenScope[];
394
+ policy?: IApiTokenPolicy;
395
+ createdAt: number;
396
+ expiresAt: number | null;
397
+ lastUsedAt: number | null;
398
+ enabled: boolean;
399
+ }
400
+
401
+ // ============================================================================
402
+ // Storage Schemas (persisted via StorageManager)
403
+ // ============================================================================
404
+
405
+ /**
406
+ * A route persisted in the database.
407
+ */
408
+ export interface IRoute {
409
+ id: string;
410
+ route: IDcRouterRouteConfig;
411
+ enabled: boolean;
412
+ createdAt: number;
413
+ updatedAt: number;
414
+ createdBy: string;
415
+ origin: 'config' | 'email' | 'dns' | 'api';
416
+ systemKey?: string;
417
+ metadata?: IRouteMetadata;
418
+ }
419
+
420
+ /**
421
+ * A stored API token, stored in /config-api/tokens/{id}.json
422
+ */
423
+ export interface IStoredApiToken {
424
+ id: string;
425
+ name: string;
426
+ tokenHash: string;
427
+ scopes: TApiTokenScope[];
428
+ policy?: IApiTokenPolicy;
429
+ /** Null/absent means an ordinary manually issued token. */
430
+ gatewayCredentialLifecycle?: IGatewayCredentialLifecycle | null;
431
+ createdAt: number;
432
+ expiresAt: number | null;
433
+ lastUsedAt: number | null;
434
+ createdBy: string;
435
+ enabled: boolean;
436
+ }
@@ -0,0 +1,37 @@
1
+ import type { IIpIntelligenceResult } from '@push.rocks/smartnetwork';
2
+
3
+ export type TSecurityBlockRuleType = 'ip' | 'cidr' | 'asn' | 'organization';
4
+ export type TSecurityBlockRuleMatchMode = 'exact' | 'contains';
5
+
6
+ export interface IIpIntelligenceRecord extends IIpIntelligenceResult {
7
+ ipAddress: string;
8
+ firstSeenAt: number;
9
+ lastSeenAt: number;
10
+ updatedAt: number;
11
+ seenCount: number;
12
+ }
13
+
14
+ export interface ISecurityBlockRule {
15
+ id: string;
16
+ type: TSecurityBlockRuleType;
17
+ value: string;
18
+ matchMode?: TSecurityBlockRuleMatchMode;
19
+ enabled: boolean;
20
+ reason?: string;
21
+ createdAt: number;
22
+ updatedAt: number;
23
+ createdBy: string;
24
+ }
25
+
26
+ export interface ISecurityCompiledPolicy {
27
+ blockedIps: string[];
28
+ blockedCidrs: string[];
29
+ }
30
+
31
+ export interface ISecurityPolicyAuditEvent {
32
+ id: string;
33
+ action: string;
34
+ actor: string;
35
+ details: Record<string, unknown>;
36
+ createdAt: number;
37
+ }
@@ -0,0 +1,63 @@
1
+ // ============================================================================
2
+ // SMTP Account Data Types
3
+ // ============================================================================
4
+ //
5
+ // Operator-managed authenticated SMTP submission accounts. Wire types never
6
+ // carry secrets: passwords are machine-generated, shown exactly once at
7
+ // create/rotate time, and only a hashed SCRAM verifier is persisted.
8
+
9
+ /**
10
+ * "Send AS who" scope. `addresses` are literal or local-part-wildcard address
11
+ * patterns (e.g. 'billing@example.com', '*@example.com' is expressed via
12
+ * `domains` instead); `domains` authorize every address of a domain.
13
+ * Both lists empty = unrestricted sender scope.
14
+ */
15
+ export interface ISmtpAccountSenderScope {
16
+ addresses: string[];
17
+ domains: string[];
18
+ }
19
+
20
+ /** 'any' = unrestricted recipients; 'restricted' = only listed addresses/domains. */
21
+ export type TSmtpRecipientScopeMode = 'any' | 'restricted';
22
+
23
+ /** "Send TO who" scope. Lists are only enforced when mode is 'restricted'. */
24
+ export interface ISmtpAccountRecipientScope {
25
+ mode: TSmtpRecipientScopeMode;
26
+ addresses: string[];
27
+ domains: string[];
28
+ }
29
+
30
+ /** Per-account outbound mail policy applied to generated relay routes. */
31
+ export interface ISmtpAccountMailPolicy {
32
+ /** Sign outbound mail with the sender domain's active managed DKIM key. */
33
+ dkimSign: boolean;
34
+ /** SmartMTA delivery queue (default 'normal'). */
35
+ queue?: 'normal' | 'priority' | 'bulk';
36
+ }
37
+
38
+ /** Per-sender-domain outbound readiness as reported by EmailDomainManager. */
39
+ export interface ISmtpAccountDomainReadiness {
40
+ domain: string;
41
+ ready: boolean;
42
+ reason?: string;
43
+ }
44
+
45
+ /**
46
+ * Public representation of an SMTP submission account. Never includes the
47
+ * password or the stored SCRAM verifier.
48
+ */
49
+ export interface ISmtpAccountInfo {
50
+ id: string;
51
+ username: string;
52
+ description: string;
53
+ enabled: boolean;
54
+ senderScope: ISmtpAccountSenderScope;
55
+ recipientScope: ISmtpAccountRecipientScope;
56
+ mailPolicy: ISmtpAccountMailPolicy;
57
+ createdAt: number;
58
+ updatedAt: number;
59
+ createdBy: string;
60
+ lastRotatedAt?: number;
61
+ /** Outbound readiness of each sender-scope domain (managed domains only). */
62
+ domainReadiness?: ISmtpAccountDomainReadiness[];
63
+ }