@serve.zone/interfaces 32.85.0 → 32.87.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.
@@ -0,0 +1,891 @@
1
+ import type { TCoreMailCredentialState, TCoreMailCredentialVerifierFormat } from './coremail.js';
2
+ import type { IGatewayTokenCapabilities, TGatewayClientType, TGatewayRouteDnsMode, TGatewayTokenRole, TManagedRouteKind } from './gateway.js';
3
+ import type { TGatewayConfigArea } from './gatewayconnector.js';
4
+ /** The bounds every area content obeys; `validateGatewayAreaTables` refuses beyond them. */
5
+ export declare const gatewayAreaContentContract: Readonly<{
6
+ /** A row id: 1 to this many UTF-16 code units, no control character. */
7
+ readonly maximumRowIdLength: 256;
8
+ /** A name, a username, a hostname pattern or another short text. */
9
+ readonly maximumNameLength: 256;
10
+ /** A description or a reason. */
11
+ readonly maximumTextLength: 1024;
12
+ /** A sealed value's `value`, in UTF-16 code units. */
13
+ readonly maximumSealedValueLength: 16384;
14
+ /** A DNS record value, in UTF-16 code units. */
15
+ readonly maximumRecordValueLength: 8192;
16
+ /** One engine configuration object, as the length of its strict canonical JSON. */
17
+ readonly maximumEngineConfigLength: 65536;
18
+ /** Entries of a set or ordered list inside a row (scopes, tags, ports, filters, bindings). */
19
+ readonly maximumListEntries: 1024;
20
+ /** Rows per member. */
21
+ readonly maximumRows: Readonly<{
22
+ security: Readonly<{
23
+ blockRules: 4096;
24
+ apiTokens: 1024;
25
+ }>;
26
+ dns: Readonly<{
27
+ nameservers: 16;
28
+ providers: 64;
29
+ domains: 1024;
30
+ records: 65536;
31
+ staticRecords: 1024;
32
+ protectedHostnames: 4096;
33
+ authorityZones: 1024;
34
+ clientHostnames: 4096;
35
+ }>;
36
+ routes: Readonly<{
37
+ routes: 4096;
38
+ sourceProfiles: 1024;
39
+ networkTargets: 1024;
40
+ targetProfiles: 1024;
41
+ disabledSystemRoutes: 1024;
42
+ }>;
43
+ mail: Readonly<{
44
+ domains: 1024;
45
+ smtpAccounts: 1024;
46
+ identities: 16384;
47
+ coreMailPeers: 256;
48
+ }>;
49
+ edges: Readonly<{
50
+ edges: 256;
51
+ }>;
52
+ }>;
53
+ }>;
54
+ /**
55
+ * The API token scopes a gateway (dcrouter) knows, in its own order: the vocabulary a controller
56
+ * mints from. A table carries any scope of the scope syntax (`isGatewayApiTokenScope`), and a scope
57
+ * the gateway does not know authorizes nothing, so a newer scope never makes a table invalid.
58
+ */
59
+ export declare const gatewayApiTokenScopes: readonly ["*", "routes:read", "routes:write", "config:read", "stats:read", "logs:read", "config-events:read", "config-events:write", "security:read", "security:write", "emails:read", "emails:write", "certificates:read", "certificates:write", "tokens:read", "tokens:manage", "users:read", "users:manage", "source-profiles:read", "source-profiles:write", "target-profiles:read", "target-profiles:write", "targets:read", "targets:write", "dns-providers:read", "dns-providers:write", "domains:read", "domains:write", "dns-authority:read", "dns-authority:write", "dns-records:read", "dns-records:write", "acme-config:read", "acme-config:write", "email-domains:read", "email-domains:write", "smtp-accounts:read", "smtp-accounts:write", "remote-ingress:read", "remote-ingress:write", "vpn:read", "vpn:write", "radius:read", "radius:write", "gateway-clients:read", "gateway-clients:write", "workhosters:read", "workhosters:write", "testing:read", "testing:write", "testing:manage"];
60
+ /** One scope of `gatewayApiTokenScopes`. */
61
+ export type TGatewayApiTokenScope = typeof gatewayApiTokenScopes[number];
62
+ /**
63
+ * The scope syntax: `*`, or `<resource>:<action>` where each part is a lowercase letter followed by
64
+ * lowercase letters, digits or hyphens; at most 64 characters.
65
+ */
66
+ export declare const isGatewayApiTokenScope: (valueArg: unknown) => valueArg is string;
67
+ /** The iteration count of every WorkApp mail identity verifier (Linus ruling 121, Q10). */
68
+ export declare const gatewayMailIdentityScramIterations = 4096;
69
+ /** A JSON value in strict canonical form: safe integers only, no `undefined`. */
70
+ export type TGatewayStrictJsonValue = null | boolean | number | string | TGatewayStrictJsonValue[] | {
71
+ [key: string]: TGatewayStrictJsonValue;
72
+ };
73
+ /**
74
+ * Configuration whose type SmartProxy or SmartMTA owns, carried as a strict JSON object. Its keys
75
+ * follow the engine's own type (an absent engine member is an absent key); its arrays keep their
76
+ * stated order.
77
+ */
78
+ export type TGatewayEngineConfig = {
79
+ [key: string]: TGatewayStrictJsonValue;
80
+ };
81
+ /** A row of a row list that holds nothing but its key. */
82
+ export interface IGatewayAreaKeyRow {
83
+ id: string;
84
+ }
85
+ /**
86
+ * A secret the gateway needs in plaintext (secret class `sealed`).
87
+ *
88
+ * `version` is minted by whoever sets `value` (a controller write, or a gateway's local write and
89
+ * its 34.9.0 data step before the takeover) and stored beside it; a new value gets a new version
90
+ * and an export never mints one. Revisions, diffs, logs and refusals carry the version, never the
91
+ * value; the version also salts the table digest against guessing a weak value. The same version
92
+ * with a different value than the one a gateway stored is the gateway's `invalid-table` refusal:
93
+ * a validator over one document cannot see it.
94
+ */
95
+ export interface IGatewaySealedValue {
96
+ /** 22 base64url characters (128 random bits). */
97
+ version: string;
98
+ /** 1 to `gatewayAreaContentContract.maximumSealedValueLength` characters. */
99
+ value: string;
100
+ }
101
+ /** The verifier of an API token: the lowercase hex SHA-256 of the token (secret class `verifier`). */
102
+ export interface IGatewayTokenHash {
103
+ algorithm: 'sha256';
104
+ /** 64 lowercase hex digits. */
105
+ hash: string;
106
+ }
107
+ /**
108
+ * A SCRAM-SHA-256 verifier (RFC 5802/7677 stored form, SmartMTA's `ISmtpScramVerifier`; secret
109
+ * class `verifier`). A WorkApp mail identity's verifier uses
110
+ * `gatewayMailIdentityScramIterations` iterations.
111
+ */
112
+ export interface IGatewayScramVerifier {
113
+ algorithm: 'SCRAM-SHA-256';
114
+ /** Canonical padded base64 of the PBKDF2 salt, 16 to 64 bytes. */
115
+ salt: string;
116
+ /** 4096 to 1000000. */
117
+ iterations: number;
118
+ /** Canonical padded base64 of 32 bytes. */
119
+ storedKey: string;
120
+ /** Canonical padded base64 of 32 bytes. */
121
+ serverKey: string;
122
+ }
123
+ /**
124
+ * A CoreMail binding credential verifier: `data.ICoreMailBindingCredentialVerifier` in canonical
125
+ * form, `acceptUntil` `null` exactly for a `current` credential (secret class `verifier`).
126
+ */
127
+ export interface IGatewayCoreMailCredentialVerifier {
128
+ credentialId: string;
129
+ version: number;
130
+ state: TCoreMailCredentialState;
131
+ format: TCoreMailCredentialVerifierFormat;
132
+ /** The canonical argon2id PHC string (`normalizeCoreMailCredentialVerifier`). */
133
+ verificationHash: string;
134
+ /** Unix milliseconds, positive; `null` exactly for a `current` credential. */
135
+ acceptUntil: number | null;
136
+ }
137
+ /**
138
+ * The gateway client that authored a client-authored row: routes, DNS hostname claims, mail
139
+ * identities and CoreMail peers carry this one shape. Gateway clients themselves are local to the
140
+ * gateway (frozen at takeover); the id is a soft reference.
141
+ *
142
+ * `appId` and `externalKey` are set on every row the client keyed, routes included (dcrouter stores
143
+ * both on every gateway-client route), and are `null` only where the gateway stored none: a DNS
144
+ * hostname claim has no `externalKey`, a CoreMail peer neither.
145
+ */
146
+ export interface IGatewayRowClientAttribution {
147
+ gatewayClientType: TGatewayClientType;
148
+ /** `isGatewayClientIdText`. */
149
+ gatewayClientId: string;
150
+ /** The client's application. */
151
+ appId: string | null;
152
+ /** The client's own key for the row. */
153
+ externalKey: string | null;
154
+ }
155
+ /** Block rule types, sorted. */
156
+ export declare const gatewayBlockRuleTypes: readonly ["asn", "cidr", "ip", "organization"];
157
+ export type TGatewayBlockRuleType = typeof gatewayBlockRuleTypes[number];
158
+ /**
159
+ * One static block rule. The address set an `asn` or `organization` rule compiles to is derived on
160
+ * the gateway from its IP intelligence and never stored here.
161
+ */
162
+ export interface IGatewayBlockRuleRow {
163
+ id: string;
164
+ type: TGatewayBlockRuleType;
165
+ value: string;
166
+ /** Set exactly on an `organization` rule (the gateway reads an absent mode as `contains`). */
167
+ matchMode: 'exact' | 'contains' | null;
168
+ reason: string | null;
169
+ enabled: boolean;
170
+ }
171
+ /** One host a gateway client token may route to (`data.IGatewayRouteTargetAllowance`, canonical). */
172
+ export interface IGatewayApiTokenRouteTarget {
173
+ host: string;
174
+ /** A set of ports, 1 to 65535, ascending. */
175
+ ports: number[];
176
+ /** The gateway reads an absent flag as `false`. */
177
+ allowAnyPort: boolean;
178
+ }
179
+ /**
180
+ * Every capability flag a gateway client token can carry (`data.IGatewayTokenCapabilities`),
181
+ * each stated: the gateway reads an absent flag as `false`.
182
+ */
183
+ export type TGatewayApiTokenCapabilities = Required<IGatewayTokenCapabilities>;
184
+ /**
185
+ * A token's policy (dcrouter's `IApiTokenPolicy`), canonical. Testing credentials are local to the
186
+ * gateway, so `testingClient` is no role here. The gateway reads an absent list as an empty one
187
+ * and absent capabilities as all `false`; those are the canonical spellings.
188
+ */
189
+ export interface IGatewayApiTokenPolicy {
190
+ role: TGatewayTokenRole;
191
+ /** Scopes the policy adds to the token's own; a canonical scope list (as the row's `scopes`). */
192
+ scopes: string[];
193
+ /** Set exactly on role `gatewayClient`: the client the token is bound to. */
194
+ gatewayClient: {
195
+ type: TGatewayClientType;
196
+ id: string;
197
+ policyGeneration: number;
198
+ } | null;
199
+ /** A set of hostname patterns. */
200
+ hostnamePatterns: string[];
201
+ /** A set, ascending by `host`, then by `ports`, then `allowAnyPort`. */
202
+ allowedRouteTargets: IGatewayApiTokenRouteTarget[];
203
+ /** A set of canonical address prefixes (`validateGatewayAllowedDnsRecordAddresses`). */
204
+ allowedDnsRecordAddresses: string[];
205
+ capabilities: TGatewayApiTokenCapabilities;
206
+ }
207
+ /**
208
+ * One API token the controller minted. The token itself is shown once at minting and never stored;
209
+ * the gateway checks a presented token against `credential` locally, controller away or not. The
210
+ * gateway's local tokens (its environment admin token `env-admin-token`, testing credentials) never
211
+ * appear here; a table row with a local token's id is the gateway's `invalid-table`.
212
+ */
213
+ export interface IGatewayApiTokenRow {
214
+ id: string;
215
+ name: string;
216
+ credential: IGatewayTokenHash;
217
+ /** A canonical scope list: scope syntax (`isGatewayApiTokenScope`), strictly ascending. */
218
+ scopes: string[];
219
+ /** `null` for a token without a policy. */
220
+ policy: IGatewayApiTokenPolicy | null;
221
+ /** Unix milliseconds; `null` never expires. */
222
+ expiresAt: number | null;
223
+ enabled: boolean;
224
+ }
225
+ /** The `security` area. */
226
+ export interface IGatewaySecurityArea {
227
+ blockRules: IGatewayBlockRuleRow[];
228
+ apiTokens: IGatewayApiTokenRow[];
229
+ /** SmartProxy's static security policy (config.json `smartProxyConfig.securityPolicy`). */
230
+ proxyPolicy: TGatewayEngineConfig | null;
231
+ }
232
+ /** The record types a gateway stores, sorted. */
233
+ export declare const gatewayDnsRecordTypes: readonly ["A", "AAAA", "CAA", "CNAME", "MX", "NS", "SOA", "TXT"];
234
+ export type TGatewayDnsRecordType = typeof gatewayDnsRecordTypes[number];
235
+ /** The record types of a static record (config.json `dnsRecords`), sorted. */
236
+ export declare const gatewayDnsStaticRecordTypes: readonly ["A", "AAAA", "CNAME", "MX", "NS", "SOA", "TXT"];
237
+ export type TGatewayDnsStaticRecordType = typeof gatewayDnsStaticRecordTypes[number];
238
+ /** The gateway's own name service; `null` exactly when `nameservers` is empty. */
239
+ export interface IGatewayDnsServerSettings {
240
+ /** The SOA mname (config.json `dnsNsDomains[0]`): one of `nameservers`. */
241
+ primaryNameserver: string;
242
+ }
243
+ /** One DNS provider the gateway writes provider zones through. Cloudflare is the only type. */
244
+ export interface IGatewayDnsProviderRow {
245
+ id: string;
246
+ name: string;
247
+ credentials: {
248
+ type: 'cloudflare';
249
+ apiToken: IGatewaySealedValue;
250
+ };
251
+ }
252
+ /**
253
+ * One zone. The provider's zone id, nameservers and last sync are observed and stay on the
254
+ * gateway; `authoritative` is derived. `source` and `providerId` never change under one id
255
+ * (`validateGatewayAreaContentChange`): moving a zone is a new row.
256
+ */
257
+ export interface IGatewayDnsDomainRow {
258
+ id: string;
259
+ /** Lowercase zone name, no trailing dot; unique among the domains. */
260
+ name: string;
261
+ source: 'dcrouter' | 'provider';
262
+ /** A row of `providers`, set exactly on a `provider` zone. */
263
+ providerId: string | null;
264
+ description: string | null;
265
+ }
266
+ /**
267
+ * One authored record of a `dcrouter`-source zone. Records of provider zones are the provider's
268
+ * (observed), and records a reconciler owns (`managedBy`) are derived; neither is ever here.
269
+ */
270
+ export interface IGatewayDnsRecordRow {
271
+ id: string;
272
+ /** A `dcrouter`-source row of `domains`. */
273
+ domainId: string;
274
+ /**
275
+ * Inside its zone: the zone's `name` itself, or a name that ends in `.` and the zone's `name`,
276
+ * compared as written.
277
+ */
278
+ name: string;
279
+ type: TGatewayDnsRecordType;
280
+ /**
281
+ * The record value in the gateway's value syntax. An `A` value is one dotted IPv4 address (four
282
+ * decimal octets of one to three digits, each at most 255) and an `AAAA` value one IPv6 address in
283
+ * hex groups of one to four digits, either case, eight groups or fewer with exactly one `::`, no
284
+ * IPv4 tail and no zone id: the forms the gateway's DNS encoder takes, with nothing around them.
285
+ */
286
+ value: string;
287
+ /** Seconds, positive. */
288
+ ttl: number;
289
+ }
290
+ /**
291
+ * One static record (config.json `dnsRecords`). Its id is derived from the record
292
+ * (`createGatewayDnsStaticRecordId`), never the record value itself.
293
+ */
294
+ export interface IGatewayDnsStaticRecordRow {
295
+ /** `static-` followed by 64 lowercase hex digits. */
296
+ id: string;
297
+ name: string;
298
+ type: TGatewayDnsStaticRecordType;
299
+ /** As `IGatewayDnsRecordRow.value`, the `A` and `AAAA` forms included. */
300
+ value: string;
301
+ /** Seconds; `null` for the gateway's default. */
302
+ ttl: number | null;
303
+ /** `null` for the gateway's default (`true`). */
304
+ useIngressProxy: boolean | null;
305
+ }
306
+ /** A hostname no automation may write at, except to release. */
307
+ export interface IGatewayDnsProtectedHostnameRow {
308
+ /** The exact hostname: lowercase, no trailing dot, no wildcard. */
309
+ id: string;
310
+ reason: string;
311
+ }
312
+ /**
313
+ * A gateway client's claim on a hostname without a route. The record the gateway writes for it,
314
+ * its conflict outcome and the orphan verdict are derived on the gateway; once the controller owns
315
+ * dns a claim is served because it is in the table.
316
+ */
317
+ export interface IGatewayDnsClientHostnameRow {
318
+ /** The hostname (`isGatewayClientHostname`). */
319
+ id: string;
320
+ /** `appId` set, `externalKey` `null`. */
321
+ client: IGatewayRowClientAttribution;
322
+ /** The address record the client asks for; `null` for a certificate-only claim. */
323
+ record: {
324
+ type: 'A' | 'AAAA';
325
+ value: string;
326
+ ttl: number;
327
+ } | null;
328
+ holdsCertificate: boolean;
329
+ }
330
+ /** The certificate issuer. The ACME account and issued keys stay on the gateway. */
331
+ export interface IGatewayAcmeSettings {
332
+ accountEmail: string;
333
+ enabled: boolean;
334
+ useProduction: boolean;
335
+ /** Another CA's directory; `null` for Let's Encrypt. */
336
+ directoryUrl: string | null;
337
+ autoRenew: boolean;
338
+ /** Days, positive. */
339
+ renewThresholdDays: number;
340
+ }
341
+ /** The `dns` area. */
342
+ export interface IGatewayDnsArea {
343
+ server: IGatewayDnsServerSettings | null;
344
+ /** The gateway's nameserver hostnames (config.json `dnsNsDomains`), keyed by hostname. */
345
+ nameservers: IGatewayAreaKeyRow[];
346
+ acme: IGatewayAcmeSettings | null;
347
+ providers: IGatewayDnsProviderRow[];
348
+ domains: IGatewayDnsDomainRow[];
349
+ records: IGatewayDnsRecordRow[];
350
+ staticRecords: IGatewayDnsStaticRecordRow[];
351
+ protectedHostnames: IGatewayDnsProtectedHostnameRow[];
352
+ /**
353
+ * Zones the gateway may answer for once it has proven their delegation itself, keyed by zone
354
+ * name. The proof and its evidence stay on the gateway; it serves the proven ones.
355
+ */
356
+ authorityZones: IGatewayAreaKeyRow[];
357
+ clientHostnames: IGatewayDnsClientHostnameRow[];
358
+ }
359
+ /** dcrouter's route path classes, in its own order. */
360
+ export declare const gatewayRoutePathClasses: readonly ["git-smart-http", "static", "normal-html", "expensive-html", "raw", "archive"];
361
+ export type TGatewayRoutePathClass = typeof gatewayRoutePathClasses[number];
362
+ /**
363
+ * A source-policy override of a profile member (dcrouter's tri-state): `inherit` keeps the
364
+ * profile's value (an absent member), `clear` removes it (`null`), `set` replaces it with `value`.
365
+ * `value` is set exactly for `set`; it is SmartProxy configuration (a rate limit or a challenge).
366
+ */
367
+ export interface IGatewayRoutePolicyOverride {
368
+ mode: 'inherit' | 'clear' | 'set';
369
+ value: TGatewayEngineConfig | null;
370
+ }
371
+ /** The answer a source policy gives when a limit is exceeded. */
372
+ export interface IGatewayRouteExceededAction {
373
+ type: '429';
374
+ errorMessage: string | null;
375
+ }
376
+ /** One path-class variant inside a source binding (dcrouter's `IRoutePathPolicyBinding`). */
377
+ export interface IGatewayRoutePathPolicyBinding {
378
+ id: string | null;
379
+ pathClass: TGatewayRoutePathClass;
380
+ /** A set of path patterns; `null` for the class's built-in patterns. */
381
+ pathPatterns: string[] | null;
382
+ rateLimit: IGatewayRoutePolicyOverride;
383
+ challenge: IGatewayRoutePolicyOverride;
384
+ /** Non-negative; `null` inherits. */
385
+ maxConnections: number | null;
386
+ onExceeded: IGatewayRouteExceededAction | null;
387
+ }
388
+ /** One source binding of a route (dcrouter's `IRouteSourceBinding` without its name snapshot). */
389
+ export interface IGatewayRouteSourceBinding {
390
+ id: string | null;
391
+ /** A row of `sourceProfiles` (hard reference). */
392
+ sourceProfileRef: string;
393
+ rateLimit: IGatewayRoutePolicyOverride;
394
+ challenge: IGatewayRoutePolicyOverride;
395
+ /** Non-negative; `null` inherits. */
396
+ maxConnections: number | null;
397
+ onExceeded: IGatewayRouteExceededAction | null;
398
+ /** In stated order; path-specific variants win over the fallback. */
399
+ pathPolicies: IGatewayRoutePathPolicyBinding[];
400
+ }
401
+ /** What a route row says about its owner and its references (dcrouter's `IRouteMetadata`). */
402
+ export interface IGatewayRouteRowMetadata {
403
+ /** The gateway reads an absent owner type as `operator`. */
404
+ ownerType: 'operator' | 'gatewayClient' | 'system';
405
+ /** Set exactly on a `gatewayClient` row, with `appId` and `externalKey` as the gateway stored them. */
406
+ client: IGatewayRowClientAttribution | null;
407
+ /** In stated order: the first matching source profile wins. */
408
+ sourceBindings: IGatewayRouteSourceBinding[];
409
+ /** A row of `networkTargets` (hard reference); the gateway resolves the route's targets from it. */
410
+ networkTargetRef: string | null;
411
+ dnsMode: TGatewayRouteDnsMode | null;
412
+ dnsProxied: boolean | null;
413
+ /** An HTTP-01 forward is an ordinary stored route; SmartProxy's challenge answers are derived. */
414
+ managedRouteKind: TManagedRouteKind | null;
415
+ }
416
+ /** The ingress paths a route accepts (dcrouter's `IRouteIngress`). */
417
+ export interface IGatewayRouteIngress {
418
+ directHub: boolean;
419
+ smartVpn: boolean;
420
+ }
421
+ /** A route's remote ingress (dcrouter's `IRouteRemoteIngress`). */
422
+ export interface IGatewayRouteRemoteIngress {
423
+ enabled: boolean;
424
+ /** A set of edge ids or tags; empty reaches every edge (the gateway reads absent as empty). */
425
+ edgeFilter: string[];
426
+ }
427
+ /**
428
+ * The secrets lifted out of a route's SmartProxy configuration; the gateway merges each back at
429
+ * its engine path. Each is set exactly when its engine member is present.
430
+ *
431
+ * `security.basicAuth` and `security.jwtAuth` stay in the route as objects without their secret, and
432
+ * the validator holds "the object exactly when its secret is set": there is no representation of a
433
+ * basic-auth object with an empty user list or a JWT object without a secret. A gateway that stores
434
+ * one refuses to export it, by name (Linus ruling 124, part 2 (iii)).
435
+ */
436
+ export interface IGatewayRouteSecrets {
437
+ /** `action.tls.certificate.key`; set exactly when `action.tls.certificate` is an object. */
438
+ tlsKey: IGatewaySealedValue | null;
439
+ /** `security.basicAuth.users`, the whole list (`encodeGatewayBasicAuthUsers`); set exactly with `security.basicAuth`. */
440
+ basicAuthUsers: IGatewaySealedValue | null;
441
+ /** `security.jwtAuth.secret`; set exactly with `security.jwtAuth`. */
442
+ jwtSecret: IGatewaySealedValue | null;
443
+ /** `headers.request`, the whole record (`encodeGatewayRequestHeaders`); `null` without request headers. */
444
+ requestHeaders: IGatewaySealedValue | null;
445
+ }
446
+ /**
447
+ * One entry of a route's `match.ports`: a port, or a range `{ from, to }`. In the table's spelling a
448
+ * range is a run of two or more consecutive ports (`from < to`); both ends are 1 to 65535. An object
449
+ * type, so a canonical list goes into engine configuration (`TGatewayEngineConfig`) as it is.
450
+ */
451
+ export type TGatewayRoutePortEntry = number | {
452
+ from: number;
453
+ to: number;
454
+ };
455
+ /**
456
+ * Every spelling SmartProxy 27.22.1 takes for `match.ports` (`TPortRange`): one port, or a list of
457
+ * ports and `{ from, to }` ranges in any order. `canonicalizeGatewayRoutePorts` turns one into the
458
+ * table's spelling.
459
+ */
460
+ export type TGatewayRoutePortsInput = number | readonly TGatewayRoutePortEntry[];
461
+ /**
462
+ * One stored route. Routes the gateway derives from mail and DNS intent (`email`, `dns` origins)
463
+ * are never here; their operator toggle is `disabledSystemRoutes`. The gateway orders routes for
464
+ * SmartProxy by `(priority desc, id)`.
465
+ */
466
+ export interface IGatewayRouteRow {
467
+ id: string;
468
+ /** `config` for a route from config.json, else `api`. */
469
+ origin: 'api' | 'config';
470
+ /** Set exactly on a `config` row: `config:<route name>`. */
471
+ systemKey: string | null;
472
+ enabled: boolean;
473
+ /**
474
+ * The SmartProxy route (dcrouter's `IDcRouterRouteConfig`) without the members typed beside it
475
+ * (`ingress`, `remoteIngress`, `vpnOnly`), without the secrets `secrets` carries, and without
476
+ * `action.targets` when `metadata.networkTargetRef` is set.
477
+ *
478
+ * Its ports have one spelling each, whoever writes the row. `match.ports` is always a list of the
479
+ * maximal port runs in ascending order: a port alone is a number, a run of two or more consecutive
480
+ * ports is `{ from, to }` with `from < to`, no two entries overlap or touch, every port is 1 to
481
+ * 65535 (`canonicalizeGatewayRoutePorts` answers it from any spelling SmartProxy takes: a bare
482
+ * `443` is `[443]`, `[80, 443, 444, 445]` is `[80, { from: 443, to: 445 }]`). Each
483
+ * `action.targets[].port` is an integer 1 to 65535 or `'preserve'`; a digit string is refused, so
484
+ * a gateway that stored one writes its number. The validator refuses any other spelling and never
485
+ * rewrites one; the authors canonicalise.
486
+ */
487
+ route: TGatewayEngineConfig;
488
+ ingress: IGatewayRouteIngress | null;
489
+ remoteIngress: IGatewayRouteRemoteIngress | null;
490
+ /** Read only while `ingress` is `null`; the gateway reads absent as `false`. */
491
+ vpnOnly: boolean;
492
+ secrets: IGatewayRouteSecrets;
493
+ metadata: IGatewayRouteRowMetadata;
494
+ }
495
+ /**
496
+ * The secrets lifted out of a source profile's security, under the same rule as
497
+ * `IGatewayRouteSecrets`: `basicAuth` and `jwtAuth` are objects exactly when their secret is set, and
498
+ * a gateway refuses to export an empty user list or a secret-less JWT object, by name.
499
+ */
500
+ export interface IGatewaySourceProfileSecrets {
501
+ /** `security.basicAuth.users`, the whole list; set exactly with `security.basicAuth`. */
502
+ basicAuthUsers: IGatewaySealedValue | null;
503
+ /** `security.jwtAuth.secret`; set exactly with `security.jwtAuth`. */
504
+ jwtSecret: IGatewaySealedValue | null;
505
+ }
506
+ /** One reusable source policy routes bind to. */
507
+ export interface IGatewaySourceProfileRow {
508
+ id: string;
509
+ name: string;
510
+ description: string | null;
511
+ /** dcrouter's `IRouteSecurity` (SmartProxy route security) without the secrets `secrets` carries. */
512
+ security: TGatewayEngineConfig;
513
+ secrets: IGatewaySourceProfileSecrets;
514
+ /** Rows of `sourceProfiles` (hard references), in stated order, each once, never the row itself. */
515
+ extendsProfiles: string[];
516
+ }
517
+ /** One named backend routes refer to. */
518
+ export interface IGatewayNetworkTargetRow {
519
+ id: string;
520
+ name: string;
521
+ description: string | null;
522
+ /** One host, or at least two in stated order. */
523
+ host: string | string[];
524
+ /** 1 to 65535. */
525
+ port: number;
526
+ }
527
+ /** One target profile; the gateway's local VPN clients reference these by id. */
528
+ export interface IGatewayTargetProfileRow {
529
+ id: string;
530
+ /** Unique among the target profiles. */
531
+ name: string;
532
+ description: string | null;
533
+ /** A set of domain patterns. */
534
+ domains: string[];
535
+ /** A set, ascending by `ip`, then `port`. */
536
+ targets: {
537
+ ip: string;
538
+ port: number;
539
+ }[];
540
+ /** A set of route row ids (soft references). */
541
+ routeRefs: string[];
542
+ allowRoutesByClientSourceIp: boolean;
543
+ }
544
+ /**
545
+ * HTTP/3 augmentation of every qualifying route. This package owns the stored and the wire shape
546
+ * (Linus ruling 124, §2): dcrouter's stored home holds exactly this shape and imports it, so its
547
+ * export is a read and its apply a write. dcrouter's `IHttp3Config` remains only its config.json
548
+ * seed and augmentation option type, until 35.0.0 removes the seed.
549
+ */
550
+ export interface IGatewayHttp3Settings {
551
+ /** `null` for the gateway's default (`true`). */
552
+ enabled: boolean | null;
553
+ quicSettings: {
554
+ maxIdleTimeout: number | null;
555
+ maxConcurrentBidiStreams: number | null;
556
+ maxConcurrentUniStreams: number | null;
557
+ initialCongestionWindow: number | null;
558
+ } | null;
559
+ altSvc: {
560
+ port: number | null;
561
+ maxAge: number | null;
562
+ } | null;
563
+ udpSettings: {
564
+ sessionTimeout: number | null;
565
+ maxSessionsPerIP: number | null;
566
+ maxDatagramSize: number | null;
567
+ } | null;
568
+ }
569
+ /** The `routes` area. */
570
+ export interface IGatewayRoutesArea {
571
+ routes: IGatewayRouteRow[];
572
+ sourceProfiles: IGatewaySourceProfileRow[];
573
+ networkTargets: IGatewayNetworkTargetRow[];
574
+ targetProfiles: IGatewayTargetProfileRow[];
575
+ /** `systemKey`s of derived `email`/`dns` routes the operator disabled. */
576
+ disabledSystemRoutes: IGatewayAreaKeyRow[];
577
+ http3: IGatewayHttp3Settings | null;
578
+ }
579
+ /** One port's settings in the email port configuration. */
580
+ export interface IGatewayMailPortSettings {
581
+ /** The gateway reads an absent flag as `false`. */
582
+ terminateTls: boolean;
583
+ /** A non-empty route name; `null` for the gateway's own. */
584
+ routeName: string | null;
585
+ }
586
+ /**
587
+ * dcrouter's `IEmailPortConfig`, canonical. Record keys are decimal ports 1 to 65535 without a
588
+ * leading zero. `receivedEmailsPath` is a host path and stays on the gateway.
589
+ *
590
+ * Always stated (Linus ruling 128, B2): no port configuration is `{ portMapping: null,
591
+ * portSettings: {} }`, never `null`; the gateway may store the object for `receivedEmailsPath`
592
+ * alone, so its presence says nothing about the row.
593
+ */
594
+ export interface IGatewayMailPortConfig {
595
+ /**
596
+ * External to internal port, at least one entry; `null` for the gateway's default mapping. The
597
+ * gateway maps a port the mapping does not name to port + 10000, as it does without a mapping, so
598
+ * `{}` is a second spelling of `null` and refused.
599
+ */
600
+ portMapping: Record<string, number> | null;
601
+ /** The gateway reads absent settings as none. */
602
+ portSettings: Record<string, IGatewayMailPortSettings>;
603
+ }
604
+ /**
605
+ * The mail server settings singleton (the stored settings, never the run-time options).
606
+ * `emailConfig` is SmartMTA's server options. `auth.users` and `auth.accounts` are out; the rest of
607
+ * `auth` (`required`, `methods`) travels inside `emailConfig` (Linus ruling 126, which amends ruling
608
+ * 121). SMTP accounts are rows of `smtpAccounts`; plaintext `auth.users` logins have no table form,
609
+ * so a gateway that holds one refuses to export by name. Host paths stay out, and `tls.keyPem` is
610
+ * `tlsKey`.
611
+ */
612
+ export interface IGatewayMailServerSettings {
613
+ enabled: boolean;
614
+ outboundMode: 'direct' | 'remoteIngress';
615
+ emailConfig: TGatewayEngineConfig | null;
616
+ /** `emailConfig.tls.keyPem`; only with `emailConfig.tls`. */
617
+ tlsKey: IGatewaySealedValue | null;
618
+ emailPortConfig: IGatewayMailPortConfig;
619
+ /** The effective source: what the gateway serves for settings stored without one. */
620
+ tlsSource: 'managedCertificate' | 'configuredMaterial';
621
+ }
622
+ /** dcrouter's `IEmailDomainRateLimits`, canonical. */
623
+ export interface IGatewayMailDomainRateLimits {
624
+ outbound: {
625
+ messagesPerMinute: number | null;
626
+ messagesPerHour: number | null;
627
+ messagesPerDay: number | null;
628
+ } | null;
629
+ inbound: {
630
+ messagesPerMinute: number | null;
631
+ connectionsPerIp: number | null;
632
+ recipientsPerMessage: number | null;
633
+ } | null;
634
+ }
635
+ /**
636
+ * One mail domain. The active DKIM selector (`dkim.selector` on the gateway), DKIM keys, public
637
+ * records and the DNS status are derived or local on the gateway.
638
+ */
639
+ export interface IGatewayMailDomainRow {
640
+ id: string;
641
+ /** Unique among the mail domains. */
642
+ domain: string;
643
+ /** A row of the dns area's `domains` (hard cross-area reference). */
644
+ linkedDomainId: string;
645
+ /** A non-empty prefix; `null` for the bare domain. */
646
+ subdomain: string | null;
647
+ dkim: {
648
+ /** The selector of the domain's first key. */
649
+ initialSelector: string;
650
+ keySize: number;
651
+ rotateKeys: boolean;
652
+ rotationIntervalDays: number;
653
+ retirementOverlapDays: number | null;
654
+ };
655
+ rateLimits: IGatewayMailDomainRateLimits | null;
656
+ /** A set of edge ids or tags; empty reaches every mail edge (the gateway reads absent as empty). */
657
+ edgeFilter: string[];
658
+ }
659
+ /** One SMTP submission account. */
660
+ export interface IGatewaySmtpAccountRow {
661
+ id: string;
662
+ /** Unique among the SMTP accounts. */
663
+ username: string;
664
+ description: string;
665
+ enabled: boolean;
666
+ credential: IGatewayScramVerifier;
667
+ /** Sets; both empty is an unrestricted sender scope. */
668
+ senderScope: {
669
+ addresses: string[];
670
+ domains: string[];
671
+ };
672
+ /** Sets, enforced only for `restricted`. */
673
+ recipientScope: {
674
+ mode: 'any' | 'restricted';
675
+ addresses: string[];
676
+ domains: string[];
677
+ };
678
+ mailPolicy: {
679
+ dkimSign: boolean;
680
+ queue: 'normal' | 'priority' | 'bulk' | null;
681
+ };
682
+ }
683
+ /** Where a WorkApp mail identity's inbound mail goes (`data.IMailInboundTarget`, the kinds dcrouter serves). */
684
+ export type TGatewayMailIdentityInboundTarget = {
685
+ type: 'smtpForward';
686
+ smtpForward: {
687
+ host: string;
688
+ port: number;
689
+ credentialRef: string | null;
690
+ preserveHeaders: boolean | null;
691
+ addHeaders: Record<string, string> | null;
692
+ };
693
+ } | {
694
+ type: 'typedEndpoint';
695
+ typedEndpoint: {
696
+ method: string;
697
+ serviceRef: string | null;
698
+ queueName: string | null;
699
+ timeoutMs: number | null;
700
+ };
701
+ } | {
702
+ type: 'coreMail';
703
+ coreMail: {
704
+ coreMailServiceId: string;
705
+ };
706
+ };
707
+ /**
708
+ * One WorkApp mail identity, one row per identity. Its SMTP credential is a verifier with
709
+ * `gatewayMailIdentityScramIterations` iterations; the password passes once through the
710
+ * controller's answer to the client and is never stored.
711
+ */
712
+ export interface IGatewayMailIdentityRow {
713
+ id: string;
714
+ /** `appId` (the WorkApp) and `externalKey` set. */
715
+ client: IGatewayRowClientAttribution;
716
+ /** Lowercase; the address is `localPart@domain`, unique among the identities. */
717
+ localPart: string;
718
+ /** Lowercase ASCII domain. */
719
+ domain: string;
720
+ enabled: boolean;
721
+ displayName: string | null;
722
+ inboundTarget: TGatewayMailIdentityInboundTarget | null;
723
+ smtp: {
724
+ enabled: boolean;
725
+ username: string;
726
+ };
727
+ credential: IGatewayScramVerifier;
728
+ }
729
+ /** One CoreMail service's gateway binding. */
730
+ export interface IGatewayCoreMailPeerRow {
731
+ id: string;
732
+ /** `appId` and `externalKey` `null`. */
733
+ client: IGatewayRowClientAttribution;
734
+ coreMailServiceId: string;
735
+ transferOrigin: string;
736
+ /** Strictly ascending by `version`. */
737
+ credentials: IGatewayCoreMailCredentialVerifier[];
738
+ }
739
+ /** The `mail` area. */
740
+ export interface IGatewayMailArea {
741
+ /**
742
+ * Always stated, never `null` (Linus ruling 128, B1): a gateway always stores mail server
743
+ * settings. Mail a gateway never configured is exported as `{ enabled: false, outboundMode:
744
+ * 'remoteIngress', emailConfig: null, tlsKey: null, emailPortConfig: { portMapping: null,
745
+ * portSettings: {} }, tlsSource: 'managedCertificate' }` (dcrouter's seeded settings document with
746
+ * its defaults).
747
+ */
748
+ server: IGatewayMailServerSettings;
749
+ domains: IGatewayMailDomainRow[];
750
+ smtpAccounts: IGatewaySmtpAccountRow[];
751
+ identities: IGatewayMailIdentityRow[];
752
+ coreMailPeers: IGatewayCoreMailPeerRow[];
753
+ }
754
+ /**
755
+ * dcrouter's `IRemoteIngressPerformanceConfig`, canonical; `null` members take the gateway default.
756
+ * At least one member is set: settings that state nothing are the owner's `performance: null`, never
757
+ * an object of `null` members (Linus ruling 125, Q-b7; the gateway stores and exports them as no
758
+ * setting).
759
+ */
760
+ export interface IGatewayEdgePerformance {
761
+ profile: 'balanced' | 'throughput' | 'highConcurrency' | null;
762
+ maxStreamsPerEdge: number | null;
763
+ totalWindowBudgetBytes: number | null;
764
+ minStreamWindowBytes: number | null;
765
+ maxStreamWindowBytes: number | null;
766
+ sustainedStreamWindowBytes: number | null;
767
+ quicDatagramReceiveBufferBytes: number | null;
768
+ streamFramePayloadBytes: number | null;
769
+ firstDataConnectTimeoutMs: number | null;
770
+ clientWriteTimeoutMs: number | null;
771
+ maxHalfClosedStreams: number | null;
772
+ halfCloseDrainTimeoutMs: number | null;
773
+ /** A non-empty set of ports; `null` for none (never `[]`). */
774
+ serverFirstPorts: number[] | null;
775
+ }
776
+ /**
777
+ * dcrouter's `IRemoteIngressEgressPolicyConfig`, canonical; `null` members take the gateway default.
778
+ * An enabled policy states its ports (the gateway's default `[25]` is written out, never `null`); a
779
+ * disabled one states nothing else, every other member `null`, because the gateway keeps only
780
+ * `enabled` of it. A list member is `null` or non-empty, never `[]` (Linus ruling 125, Q-b7).
781
+ *
782
+ * Always stated on an edge row (`IGatewayEdgeRow.egress`): the gateway reads an edge without a
783
+ * policy and one with a disabled policy alike, so egress off has the one spelling
784
+ * `{ enabled: false, allowedPorts: null, allowPrivateRanges: null, deniedCidrs: null,
785
+ * allowedHostPatterns: null, maxConcurrentStreams: null }` and never `null` (the object is
786
+ * canonical, as for the mail port configuration, Linus ruling 128 B2).
787
+ */
788
+ export interface IGatewayEdgeEgress {
789
+ enabled: boolean;
790
+ /** A non-empty set of ports exactly when `enabled`; `null` otherwise. */
791
+ allowedPorts: number[] | null;
792
+ allowPrivateRanges: boolean | null;
793
+ /** A non-empty set of CIDRs, or `null`. */
794
+ deniedCidrs: string[] | null;
795
+ /** A non-empty set of host patterns, or `null`. */
796
+ allowedHostPatterns: string[] | null;
797
+ maxConcurrentStreams: number | null;
798
+ }
799
+ /** One remote ingress edge. Its tunnel listener port is a host fact and never here. */
800
+ export interface IGatewayEdgeRow {
801
+ id: string;
802
+ name: string;
803
+ /** The edge's tunnel secret. */
804
+ secret: IGatewaySealedValue;
805
+ /** A set of manually listed TCP ports; derived ports are computed on the gateway. */
806
+ listenPorts: number[];
807
+ /** A set of manually listed UDP ports (the gateway reads absent as empty). */
808
+ listenPortsUdp: number[];
809
+ enabled: boolean;
810
+ autoDerivePorts: boolean;
811
+ performance: IGatewayEdgePerformance | null;
812
+ /** Never `null`: egress off is the disabled policy (`IGatewayEdgeEgress`). */
813
+ egress: IGatewayEdgeEgress;
814
+ /** A set of tags (the gateway reads absent as empty). */
815
+ tags: string[];
816
+ publicIp: string | null;
817
+ /** dcrouter stores it as `publicIpV6`. */
818
+ publicIpv6: string | null;
819
+ mailHostname: string | null;
820
+ }
821
+ /** The tunnel hub singleton, without its listener port and TLS files. */
822
+ export interface IGatewayEdgeHubSettings {
823
+ enabled: boolean;
824
+ hubDomain: string | null;
825
+ performance: IGatewayEdgePerformance | null;
826
+ }
827
+ /** The `edges` area. */
828
+ export interface IGatewayEdgesArea {
829
+ /**
830
+ * Always stated, never `null` (Linus ruling 125, Q-b5): a gateway always has hub settings. A hub
831
+ * that is off is `enabled: false`, with `hubDomain` and `performance` `null` when it has none.
832
+ */
833
+ hub: IGatewayEdgeHubSettings;
834
+ edges: IGatewayEdgeRow[];
835
+ }
836
+ /** The content type of each area's table, by area name. */
837
+ export interface IGatewayAreaContents {
838
+ security: IGatewaySecurityArea;
839
+ dns: IGatewayDnsArea;
840
+ routes: IGatewayRoutesArea;
841
+ mail: IGatewayMailArea;
842
+ edges: IGatewayEdgesArea;
843
+ }
844
+ /** The content of one area's table. */
845
+ export type TGatewayAreaContent<TArea extends TGatewayConfigArea = TGatewayConfigArea> = IGatewayAreaContents[TArea];
846
+ /** The members of each area, in the order its doc lists them. */
847
+ export declare const gatewayAreaMembers: Readonly<{
848
+ readonly security: readonly ["blockRules", "apiTokens", "proxyPolicy"];
849
+ readonly dns: readonly ["server", "nameservers", "acme", "providers", "domains", "records", "staticRecords", "protectedHostnames", "authorityZones", "clientHostnames"];
850
+ readonly routes: readonly ["routes", "sourceProfiles", "networkTargets", "targetProfiles", "disabledSystemRoutes", "http3"];
851
+ readonly mail: readonly ["server", "domains", "smtpAccounts", "identities", "coreMailPeers"];
852
+ readonly edges: readonly ["hub", "edges"];
853
+ }>;
854
+ /**
855
+ * The closed key vocabulary refused inside every engine configuration (a route's `route`, a source
856
+ * profile's `security`, the mail server's `emailConfig`, the proxy policy, and every policy override
857
+ * `value`), at any depth and in every position: a record key that is one of these names is refused
858
+ * like a member (`validateGatewayAreaTables`). Each list is ascending by `compareWireTokens`.
859
+ *
860
+ * - `secret` (`secret-in-engine-config`): keys that denote a secret. The ones the gateway needs
861
+ * travel in typed sealed members instead (`IGatewayRouteSecrets`, `IGatewaySourceProfileSecrets`,
862
+ * `IGatewayMailServerSettings.tlsKey`); the rest have no table form.
863
+ * - `hostPath` (`host-path-in-engine-config`): key names that denote a path on the gateway's host.
864
+ * - `headerInjection` (`secret-in-engine-config`): members whose headers the engine adds to a
865
+ * request, which can carry a credential.
866
+ *
867
+ * An entry is a key name or `parent.name`. A key name is refused under any parent; `parent.name` is
868
+ * a key `name` directly inside a key `parent` (a list between them is transparent) and refuses only
869
+ * there, so a member that mixes settings and credentials keeps its settings (all three
870
+ * lists share this one matcher).
871
+ *
872
+ * The vocabulary is what the pinned engine types name, read from their declarations: SmartProxy
873
+ * 27.22.1 `dist_ts/proxies/smart-proxy/models/route-types.d.ts` (and its `ISmartProxySecurityPolicy`,
874
+ * which names none), smartchallenge 1.1.0 `IRouteChallengeConfig` (names none; its `settings` record is
875
+ * walked like every record), SmartMTA 13.1.0 `IUnifiedEmailServerOptions` and `IEmailAction`, and the
876
+ * host-path members dcrouter adds to them. SmartMTA 13.1.0's config-shaped `auth` keys are exactly
877
+ * `IUnifiedEmailServerOptions.auth` (`required`, `methods`, `users`, `accounts`) and the route action's
878
+ * `forward.auth` (`{ user, pass }`); its other `auth` declarations are parameters of
879
+ * `RustSecurityBridge` methods (`ISmtpSendOptions`, `ISmtpSendRawTransportOptions`,
880
+ * `ISmtpVerifyOptions`), never configuration. A SmartMTA pin bump that adds a config-shaped `auth`
881
+ * member gets its own path entry through dcrouter's classification (Linus rulings 124 and 126).
882
+ * Version skew (Linus ruling 124): a controller with an
883
+ * older vocabulary than a gateway's could store a newly named secret before the gateway refuses it,
884
+ * so Cloudly writes no engine configuration for a gateway stating a newer `interfacesVersion` than
885
+ * its own.
886
+ */
887
+ export declare const gatewayAreaRefusedEngineKeys: Readonly<{
888
+ readonly secret: readonly ["auth.accounts", "credential", "credentials", "forward.auth", "jwtSecret", "key", "keyPem", "oauthClientSecret", "pass", "password", "privateKey", "secret", "serverKey", "storedKey", "users", "verifier"];
889
+ readonly hostPath: readonly ["caPath", "certFile", "certPath", "directory", "keyFile", "keyPath", "receivedEmailsPath", "root"];
890
+ readonly headerInjection: readonly ["advanced.headers", "customHeaders", "headers.request"];
891
+ }>;