@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,298 @@
1
+ /*
2
+ * The typed content of the five gateway configuration areas (Linus rulings 117 §2 and 121): what
3
+ * `IGatewayAreaTable.content` and `IGatewayAreaExport.content` hold for each area name of
4
+ * `gatewayConfigAreaApplyOrder`. `validateGatewayAreaTables` (`gatewayareas.validation.ts`) judges
5
+ * a document's contents; both sides digest a table with `computeGatewayAreaTableDigest` unchanged.
6
+ *
7
+ * Intent only. A table holds what an operator, a gateway client or the controller authored. What a
8
+ * gateway derives from intent plus live state stays on the gateway and is never exported or pushed
9
+ * (`managedBy` DNS records, ACME challenge records, DKIM public records and active selectors,
10
+ * redirects, SmartProxy's run-time HTTP-01 answers, reactive blocks, `email`/`dns` system routes),
11
+ * and so do observed state (provider zone listings and mirrored provider records, delegation
12
+ * evidence, provider health) and local state (VPN keys and clients, DKIM private keys, the ACME
13
+ * account and certificate store, spool, logs, stats, testing, connector state, host facts).
14
+ *
15
+ * Canonical form, every area, both sides:
16
+ *
17
+ * - An area's content is one object with exactly the members its type names.
18
+ * - A member is either a row list or a singleton. A row list holds objects with a string `id`,
19
+ * strictly ascending by `compareWireTokens` (so each `id` once); rows hold no nested row lists.
20
+ * A singleton is one object or `null`, except the `edges` hub and the `mail` server settings,
21
+ * which are always an object (`IGatewayEdgesArea.hub`, `IGatewayMailArea.server`). No row list carries meaning in its order: where order
22
+ * matters it is data (`IGatewayDnsServerSettings.primaryNameserver`).
23
+ * - Exact keys. An absent value is `null`, never a missing key or `undefined`. Where the gateway
24
+ * reads an absent list as an empty one (its documentation says so per member), the canonical form
25
+ * is the empty list and never `null`, so one meaning has one spelling.
26
+ * - A set inside a typed member is strictly ascending (`compareWireTokens` for strings, numeric
27
+ * for numbers, the member's stated order for objects). A list whose order carries meaning
28
+ * (`sourceBindings`, `extendsProfiles`, a network target's hosts) keeps its stated order.
29
+ * Arrays inside engine configuration keep their stated order.
30
+ * - Numbers are safe integers; strings are Unicode scalar strings (`createGatewayAreaTableDigestInput`).
31
+ * - No time stamps, authors, counters of the gateway's own bookkeeping, resolution snapshots or
32
+ * observed values. No record value in a row id.
33
+ * - One meaning has one spelling also where two authors write it (the gateway's exporter before a
34
+ * takeover, the controller's compile after it), or every push would move the digest: a route's
35
+ * `match.ports` is the list `canonicalizeGatewayRoutePorts` answers and a route target's `port` an
36
+ * integer or `'preserve'` (`IGatewayRouteRow.route`); an edge setting that states nothing is `null`,
37
+ * never an object of `null` members or an empty list (`IGatewayEdgePerformance`, `IGatewayEdgeEgress`
38
+ * members). Where `null` and an object would mean the same, the object is canonical and the member
39
+ * is never `null` (Linus ruling 128, B2): the mail server's `emailPortConfig` (none is
40
+ * `{ portMapping: null, portSettings: {} }`) and an edge's `egress` (the gateway reads no policy as
41
+ * a disabled one, so off is the disabled policy).
42
+ *
43
+ * Engine configuration (`TGatewayEngineConfig`) is configuration whose type another engine owns:
44
+ * SmartProxy (routes, route security, rate limits, challenges, the proxy security policy), SmartMTA
45
+ * (`emailConfig`). It travels as a strict JSON object; the gateway judges its engine semantics in
46
+ * the same check-first pass (`invalid-table`). Every type dcrouter declares is typed exactly here,
47
+ * not only those in its `ts_interfaces`, and so are the remote-ingress shapes it stores in its own
48
+ * documents (Linus rulings 121 Q15 and 124 §2). The secrets the gateway needs are lifted into typed
49
+ * sealed members. What is enforced where (Linus ruling 124, part 2):
50
+ *
51
+ * - This package refuses the closed key vocabulary `gatewayAreaRefusedEngineKeys` (secret names,
52
+ * host-path names, header-injection members) at any depth of every engine configuration, record
53
+ * keys included (`validateGatewayAreaTables`). It does not know the engine types and does not claim
54
+ * that a name outside the vocabulary is safe.
55
+ * - Completeness against the engine types is the gateway's: dcrouter classifies every member of its
56
+ * pinned SmartProxy and SmartMTA types, checked against those types (every secret or host-path
57
+ * member's name is in the vocabulary, no safe member's name is), refuses a stored engine path it has
58
+ * not classified by name at export, and refuses one as `invalid-table` at apply.
59
+ *
60
+ * Canonical spelling is the author's: the gateway's exporter and, after takeover, the controller's
61
+ * compile write the canonical form. The validators judge it and never rewrite a value.
62
+ *
63
+ * Secret classes:
64
+ *
65
+ * - `sealed` (`IGatewaySealedValue`): a value the gateway needs in plaintext to serve. It travels in
66
+ * the table over the authenticated connector socket and is sealed at rest in Cloudly: DNS provider
67
+ * API tokens, route and mail TLS keys, route and source profile basic-auth user lists and JWT
68
+ * secrets, route request headers, remote ingress edge secrets.
69
+ * - `verifier`: a credential the gateway only checks, carried as its verifier and never as the
70
+ * secret: API token hashes (`IGatewayTokenHash`), SMTP and WorkApp SCRAM verifiers
71
+ * (`IGatewayScramVerifier`), CoreMail argon2id verifiers (`IGatewayCoreMailCredentialVerifier`).
72
+ * - Revisions, diffs, logs and refusals name row ids, member paths and sealed versions, never a
73
+ * value (`listGatewayAreaSecrets`).
74
+ *
75
+ * Hard references are validated: a missing target would widen access or leave a row unservable.
76
+ * They are exactly `routes.routes[].metadata.networkTargetRef` (→ `routes.networkTargets`),
77
+ * `routes.routes[].metadata.sourceBindings[].sourceProfileRef` and
78
+ * `routes.sourceProfiles[].extendsProfiles[]` (→ `routes.sourceProfiles`),
79
+ * `dns.records[].domainId` (→ a `dcrouter`-source row of `dns.domains`),
80
+ * `dns.domains[].providerId` (→ `dns.providers`) and the cross-area
81
+ * `mail.domains[].linkedDomainId` (→ `dns.domains`), plus `dns.server.primaryNameserver`
82
+ * (→ `dns.nameservers`). Cross-area references point backwards in apply order and are judged per
83
+ * whole document. Every other reference is soft and resolves to nothing when its target is absent:
84
+ * target profile `routeRefs`, edge filters (edge ids or tags), VPN client ids in route security,
85
+ * gateway client ids in attributions and token policies, CoreMail service ids, mail identity
86
+ * domains, `disabledSystemRoutes`.
87
+ */
88
+ // ---------------------------------------------------------------------------------------------
89
+ // Bounds and vocabulary
90
+ // ---------------------------------------------------------------------------------------------
91
+ /** The bounds every area content obeys; `validateGatewayAreaTables` refuses beyond them. */
92
+ export const gatewayAreaContentContract = Object.freeze({
93
+ /** A row id: 1 to this many UTF-16 code units, no control character. */
94
+ maximumRowIdLength: 256,
95
+ /** A name, a username, a hostname pattern or another short text. */
96
+ maximumNameLength: 256,
97
+ /** A description or a reason. */
98
+ maximumTextLength: 1024,
99
+ /** A sealed value's `value`, in UTF-16 code units. */
100
+ maximumSealedValueLength: 16_384,
101
+ /** A DNS record value, in UTF-16 code units. */
102
+ maximumRecordValueLength: 8192,
103
+ /** One engine configuration object, as the length of its strict canonical JSON. */
104
+ maximumEngineConfigLength: 65_536,
105
+ /** Entries of a set or ordered list inside a row (scopes, tags, ports, filters, bindings). */
106
+ maximumListEntries: 1024,
107
+ /** Rows per member. */
108
+ maximumRows: Object.freeze({
109
+ security: Object.freeze({ blockRules: 4096, apiTokens: 1024 }),
110
+ dns: Object.freeze({
111
+ nameservers: 16,
112
+ providers: 64,
113
+ domains: 1024,
114
+ records: 65_536,
115
+ staticRecords: 1024,
116
+ protectedHostnames: 4096,
117
+ authorityZones: 1024,
118
+ clientHostnames: 4096,
119
+ }),
120
+ routes: Object.freeze({
121
+ routes: 4096,
122
+ sourceProfiles: 1024,
123
+ networkTargets: 1024,
124
+ targetProfiles: 1024,
125
+ disabledSystemRoutes: 1024,
126
+ }),
127
+ mail: Object.freeze({ domains: 1024, smtpAccounts: 1024, identities: 16_384, coreMailPeers: 256 }),
128
+ edges: Object.freeze({ edges: 256 }),
129
+ }),
130
+ });
131
+ /**
132
+ * The API token scopes a gateway (dcrouter) knows, in its own order: the vocabulary a controller
133
+ * mints from. A table carries any scope of the scope syntax (`isGatewayApiTokenScope`), and a scope
134
+ * the gateway does not know authorizes nothing, so a newer scope never makes a table invalid.
135
+ */
136
+ export const gatewayApiTokenScopes = Object.freeze([
137
+ '*',
138
+ 'routes:read',
139
+ 'routes:write',
140
+ 'config:read',
141
+ 'stats:read',
142
+ 'logs:read',
143
+ 'config-events:read',
144
+ 'config-events:write',
145
+ 'security:read',
146
+ 'security:write',
147
+ 'emails:read',
148
+ 'emails:write',
149
+ 'certificates:read',
150
+ 'certificates:write',
151
+ 'tokens:read',
152
+ 'tokens:manage',
153
+ 'users:read',
154
+ 'users:manage',
155
+ 'source-profiles:read',
156
+ 'source-profiles:write',
157
+ 'target-profiles:read',
158
+ 'target-profiles:write',
159
+ 'targets:read',
160
+ 'targets:write',
161
+ 'dns-providers:read',
162
+ 'dns-providers:write',
163
+ 'domains:read',
164
+ 'domains:write',
165
+ 'dns-authority:read',
166
+ 'dns-authority:write',
167
+ 'dns-records:read',
168
+ 'dns-records:write',
169
+ 'acme-config:read',
170
+ 'acme-config:write',
171
+ 'email-domains:read',
172
+ 'email-domains:write',
173
+ 'smtp-accounts:read',
174
+ 'smtp-accounts:write',
175
+ 'remote-ingress:read',
176
+ 'remote-ingress:write',
177
+ 'vpn:read',
178
+ 'vpn:write',
179
+ 'radius:read',
180
+ 'radius:write',
181
+ 'gateway-clients:read',
182
+ 'gateway-clients:write',
183
+ 'workhosters:read',
184
+ 'workhosters:write',
185
+ 'testing:read',
186
+ 'testing:write',
187
+ 'testing:manage',
188
+ ]);
189
+ /**
190
+ * The scope syntax: `*`, or `<resource>:<action>` where each part is a lowercase letter followed by
191
+ * lowercase letters, digits or hyphens; at most 64 characters.
192
+ */
193
+ export const isGatewayApiTokenScope = (valueArg) => (typeof valueArg === 'string'
194
+ && valueArg.length <= 64
195
+ && (valueArg === '*' || /^[a-z][a-z0-9-]*:[a-z][a-z0-9-]*$/.test(valueArg)));
196
+ /** The iteration count of every WorkApp mail identity verifier (Linus ruling 121, Q10). */
197
+ export const gatewayMailIdentityScramIterations = 4096;
198
+ // ---------------------------------------------------------------------------------------------
199
+ // security
200
+ // ---------------------------------------------------------------------------------------------
201
+ /** Block rule types, sorted. */
202
+ export const gatewayBlockRuleTypes = Object.freeze(['asn', 'cidr', 'ip', 'organization']);
203
+ // ---------------------------------------------------------------------------------------------
204
+ // dns
205
+ // ---------------------------------------------------------------------------------------------
206
+ /** The record types a gateway stores, sorted. */
207
+ export const gatewayDnsRecordTypes = Object.freeze(['A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'SOA', 'TXT']);
208
+ /** The record types of a static record (config.json `dnsRecords`), sorted. */
209
+ export const gatewayDnsStaticRecordTypes = Object.freeze(['A', 'AAAA', 'CNAME', 'MX', 'NS', 'SOA', 'TXT']);
210
+ // ---------------------------------------------------------------------------------------------
211
+ // routes
212
+ // ---------------------------------------------------------------------------------------------
213
+ /** dcrouter's route path classes, in its own order. */
214
+ export const gatewayRoutePathClasses = Object.freeze([
215
+ 'git-smart-http', 'static', 'normal-html', 'expensive-html', 'raw', 'archive',
216
+ ]);
217
+ /** The members of each area, in the order its doc lists them. */
218
+ export const gatewayAreaMembers = Object.freeze({
219
+ security: Object.freeze(['blockRules', 'apiTokens', 'proxyPolicy']),
220
+ dns: Object.freeze([
221
+ 'server', 'nameservers', 'acme', 'providers', 'domains', 'records', 'staticRecords', 'protectedHostnames',
222
+ 'authorityZones', 'clientHostnames',
223
+ ]),
224
+ routes: Object.freeze([
225
+ 'routes', 'sourceProfiles', 'networkTargets', 'targetProfiles', 'disabledSystemRoutes', 'http3',
226
+ ]),
227
+ mail: Object.freeze(['server', 'domains', 'smtpAccounts', 'identities', 'coreMailPeers']),
228
+ edges: Object.freeze(['hub', 'edges']),
229
+ });
230
+ /**
231
+ * The closed key vocabulary refused inside every engine configuration (a route's `route`, a source
232
+ * profile's `security`, the mail server's `emailConfig`, the proxy policy, and every policy override
233
+ * `value`), at any depth and in every position: a record key that is one of these names is refused
234
+ * like a member (`validateGatewayAreaTables`). Each list is ascending by `compareWireTokens`.
235
+ *
236
+ * - `secret` (`secret-in-engine-config`): keys that denote a secret. The ones the gateway needs
237
+ * travel in typed sealed members instead (`IGatewayRouteSecrets`, `IGatewaySourceProfileSecrets`,
238
+ * `IGatewayMailServerSettings.tlsKey`); the rest have no table form.
239
+ * - `hostPath` (`host-path-in-engine-config`): key names that denote a path on the gateway's host.
240
+ * - `headerInjection` (`secret-in-engine-config`): members whose headers the engine adds to a
241
+ * request, which can carry a credential.
242
+ *
243
+ * An entry is a key name or `parent.name`. A key name is refused under any parent; `parent.name` is
244
+ * a key `name` directly inside a key `parent` (a list between them is transparent) and refuses only
245
+ * there, so a member that mixes settings and credentials keeps its settings (all three
246
+ * lists share this one matcher).
247
+ *
248
+ * The vocabulary is what the pinned engine types name, read from their declarations: SmartProxy
249
+ * 27.22.1 `dist_ts/proxies/smart-proxy/models/route-types.d.ts` (and its `ISmartProxySecurityPolicy`,
250
+ * which names none), smartchallenge 1.1.0 `IRouteChallengeConfig` (names none; its `settings` record is
251
+ * walked like every record), SmartMTA 13.1.0 `IUnifiedEmailServerOptions` and `IEmailAction`, and the
252
+ * host-path members dcrouter adds to them. SmartMTA 13.1.0's config-shaped `auth` keys are exactly
253
+ * `IUnifiedEmailServerOptions.auth` (`required`, `methods`, `users`, `accounts`) and the route action's
254
+ * `forward.auth` (`{ user, pass }`); its other `auth` declarations are parameters of
255
+ * `RustSecurityBridge` methods (`ISmtpSendOptions`, `ISmtpSendRawTransportOptions`,
256
+ * `ISmtpVerifyOptions`), never configuration. A SmartMTA pin bump that adds a config-shaped `auth`
257
+ * member gets its own path entry through dcrouter's classification (Linus rulings 124 and 126).
258
+ * Version skew (Linus ruling 124): a controller with an
259
+ * older vocabulary than a gateway's could store a newly named secret before the gateway refuses it,
260
+ * so Cloudly writes no engine configuration for a gateway stating a newer `interfacesVersion` than
261
+ * its own.
262
+ */
263
+ export const gatewayAreaRefusedEngineKeys = Object.freeze({
264
+ secret: Object.freeze([
265
+ 'auth.accounts', // SmartMTA `IUnifiedEmailServerOptions.auth.accounts` (`ISmtpAuthAccount[]`; the rows are `smtpAccounts`)
266
+ 'credential', // SmartMTA `ISmtpAuthAccount.credential` (`{ verifier }` or `{ password }`)
267
+ 'credentials', // SmartProxy `IRouteAuthentication.credentials` (`security.authentication`)
268
+ 'forward.auth', // SmartMTA `IEmailAction.forward.auth` (`{ user, pass }`), refused whole whatever its members
269
+ 'jwtSecret', // SmartProxy `IRouteAuthentication.jwtSecret`
270
+ 'key', // SmartProxy `IRouteTls.certificate.key` (action and target `tls`; lifted to `secrets.tlsKey`)
271
+ 'keyPem', // SmartMTA `IUnifiedEmailServerOptions.tls.keyPem` (lifted to `tlsKey`)
272
+ 'oauthClientSecret', // SmartProxy `IRouteAuthentication.oauthClientSecret`
273
+ 'pass', // SmartMTA `IEmailAction.forward.auth.pass`
274
+ 'password', // SmartProxy `basicAuth.users[].password`, `IRouteAuthentication.credentials[].password`; SmartMTA `auth.users[].password`, `ISmtpAuthAccount.credential.password`
275
+ 'privateKey', // SmartMTA `IEmailAction.options.mtaOptions.dkimOptions.privateKey`
276
+ 'secret', // SmartProxy `IRouteSecurity.jwtAuth.secret` (lifted to `secrets.jwtSecret`)
277
+ 'serverKey', // SmartMTA `ISmtpScramVerifier.serverKey`
278
+ 'storedKey', // SmartMTA `ISmtpScramVerifier.storedKey`
279
+ 'users', // SmartProxy `IRouteSecurity.basicAuth.users` (lifted to `secrets.basicAuthUsers`); SmartMTA `auth.users` (no table form)
280
+ 'verifier', // SmartMTA `ISmtpAuthAccount.credential.verifier` (`ISmtpScramVerifier`)
281
+ ]),
282
+ hostPath: Object.freeze([
283
+ 'caPath', // dcrouter `IDcRouterOptions.tls.caPath` (Linus ruling 121, Q10)
284
+ 'certFile', // SmartProxy `IRouteTls.certificate.certFile`
285
+ 'certPath', // dcrouter `IDcRouterEmailTlsConfig.certPath` (SmartMTA `tls` plus paths)
286
+ 'directory', // SmartProxy `IRouteStaticFiles.directory` (`advanced.staticFiles`)
287
+ 'keyFile', // SmartProxy `IRouteTls.certificate.keyFile`
288
+ 'keyPath', // dcrouter `IDcRouterEmailTlsConfig.keyPath`
289
+ 'receivedEmailsPath', // dcrouter `IEmailPortConfig.receivedEmailsPath`
290
+ 'root', // SmartProxy `IRouteStaticFiles.root` (`advanced.staticFiles`)
291
+ ]),
292
+ headerInjection: Object.freeze([
293
+ 'advanced.headers', // SmartProxy `IRouteAdvanced.headers` (action and every target)
294
+ 'customHeaders', // SmartProxy `IRouteWebSocket.customHeaders` (action and every target)
295
+ 'headers.request', // SmartProxy `IRouteHeaders.request` (route and every target; lifted to `secrets.requestHeaders`)
296
+ ]),
297
+ });
298
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2F0ZXdheWFyZWFzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvZGF0YS9nYXRld2F5YXJlYXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBc0ZHO0FBWUgsZ0dBQWdHO0FBQ2hHLHdCQUF3QjtBQUN4QixnR0FBZ0c7QUFFaEcsNEZBQTRGO0FBQzVGLE1BQU0sQ0FBQyxNQUFNLDBCQUEwQixHQUFHLE1BQU0sQ0FBQyxNQUFNLENBQUM7SUFDdEQsd0VBQXdFO0lBQ3hFLGtCQUFrQixFQUFFLEdBQUc7SUFDdkIsb0VBQW9FO0lBQ3BFLGlCQUFpQixFQUFFLEdBQUc7SUFDdEIsaUNBQWlDO0lBQ2pDLGlCQUFpQixFQUFFLElBQUk7SUFDdkIsc0RBQXNEO0lBQ3RELHdCQUF3QixFQUFFLE1BQU07SUFDaEMsZ0RBQWdEO0lBQ2hELHdCQUF3QixFQUFFLElBQUk7SUFDOUIsbUZBQW1GO0lBQ25GLHlCQUF5QixFQUFFLE1BQU07SUFDakMsOEZBQThGO0lBQzlGLGtCQUFrQixFQUFFLElBQUk7SUFDeEIsdUJBQXVCO0lBQ3ZCLFdBQVcsRUFBRSxNQUFNLENBQUMsTUFBTSxDQUFDO1FB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E4RjtRQUM5RyxXQUFXLEVBQUUsOENBQThDO1FBQzNELEtBQUssRUFBRSwrRkFBK0Y7UUFDdEcsUUFBUSxFQUFFLHdFQUF3RTtRQUNsRixtQkFBbUIsRUFBRSxzREFBc0Q7UUFDM0UsTUFBTSxFQUFFLDRDQUE0QztRQUNwRCxVQUFVLEVBQUUsbUtBQW1LO1FBQy9LLFlBQVksRUFBRSxvRUFBb0U7UUFDbEYsUUFBUSxFQUFFLDZFQUE2RTtRQUN2RixXQUFXLEVBQUUsMENBQTBDO1FBQ3ZELFdBQVcsRUFBRSwwQ0FBMEM7UUFDdkQsT0FBTyxFQUFFLDBIQUEwSDtRQUNuSSxVQUFVLEVBQUUseUVBQXlFO0tBQzdFLENBQUM7SUFDWCxRQUFRLEVBQUUsTUFBTSxDQUFDLE1BQU0sQ0FBQztRQUN0QixRQUFRLEVBQUUsaUVBQWlFO1FBQzNFLFVBQVUsRUFBRSw4Q0FBOEM7UUFDMUQsVUFBVSxFQUFFLDBFQUEwRTtRQUN0RixXQUFXLEVBQUUsb0VBQW9FO1FBQ2pGLFNBQVMsRUFBRSw2Q0FBNkM7UUFDeEQsU0FBUyxFQUFFLDZDQUE2QztRQUN4RCxvQkFBb0IsRUFBRSxpREFBaUQ7UUFDdkUsTUFBTSxFQUFFLCtEQUErRDtLQUMvRCxDQUFDO0lBQ1gsZUFBZSxFQUFFLE1BQU0sQ0FBQyxNQUFNLENBQUM7UUFDN0Isa0JBQWtCLEVBQUUsZ0VBQWdFO1FBQ3BGLGVBQWUsRUFBRSx1RUFBdUU7UUFDeEYsaUJBQWlCLEVBQUUsa0dBQWtHO0tBQzdHLENBQUM7Q0FDSCxDQUFDLENBQUMifQ==
@@ -0,0 +1,104 @@
1
+ import { type IGatewayDnsStaticRecordRow, type TGatewayAreaContent, type TGatewayRoutePortEntry, type TGatewayRoutePortsInput } from './gatewayareas.js';
2
+ import { type IGatewayAreaTable, type TGatewayConfigArea } from './gatewayconnector.js';
3
+ /** Every reason an area content is refused. */
4
+ export declare const gatewayAreaContentRefusalCodes: readonly ["not-strict-json", "exact-keys", "invalid-value", "bound-exceeded", "invalid-row-id", "rows-not-ascending", "set-not-ascending", "duplicate-key", "dangling-reference", "reference-not-dcrouter-zone", "reference-cycle", "referenced-area-missing", "area-repeated", "invalid-sealed-value", "secret-engine-mismatch", "secret-in-engine-config", "host-path-in-engine-config", "typed-member-in-engine-config", "invalid-scope", "invalid-verifier", "immutable-member-changed"];
5
+ /** One reason an area content is refused. */
6
+ export type TGatewayAreaContentRefusalCode = typeof gatewayAreaContentRefusalCodes[number];
7
+ /**
8
+ * One refusal of an area content: where and why, never a value. `rowId` is the row's id when the
9
+ * id itself is valid; `path` is the key path inside the row or singleton (`[n]` for a list
10
+ * position, and the row's position when its id is invalid).
11
+ */
12
+ export interface IGatewayAreaContentRefusal {
13
+ /** `null` only for a document's table whose area is outside `gatewayConfigAreaApplyOrder`. */
14
+ area: TGatewayConfigArea | null;
15
+ /** The area member; `null` for the content object or the document. */
16
+ member: string | null;
17
+ rowId: string | null;
18
+ path: string | null;
19
+ code: TGatewayAreaContentRefusalCode;
20
+ }
21
+ /** One line for a log or an apply report's `invalid-table` detail; values never appear. */
22
+ export declare const formatGatewayAreaContentRefusal: (refusalArg: IGatewayAreaContentRefusal) => string;
23
+ /** One basic-auth user as SmartProxy states it. */
24
+ export interface IGatewayBasicAuthUser {
25
+ username: string;
26
+ password: string;
27
+ }
28
+ /**
29
+ * The `value` of a sealed `basicAuthUsers`: the strict canonical JSON of the whole SmartProxy
30
+ * `security.basicAuth.users` list, in its stated order.
31
+ */
32
+ export declare const encodeGatewayBasicAuthUsers: (usersArg: readonly IGatewayBasicAuthUser[]) => string;
33
+ /** The users of a sealed `basicAuthUsers` value; `null` when the value is not that encoding. */
34
+ export declare const decodeGatewayBasicAuthUsers: (valueArg: string) => IGatewayBasicAuthUser[] | null;
35
+ /** The `value` of a sealed `requestHeaders`: the strict canonical JSON of the whole `headers.request` record. */
36
+ export declare const encodeGatewayRequestHeaders: (headersArg: Readonly<Record<string, string>>) => string;
37
+ /** The record of a sealed `requestHeaders` value; `null` when the value is not that encoding. */
38
+ export declare const decodeGatewayRequestHeaders: (valueArg: string) => Record<string, string> | null;
39
+ /** Ports `canonicalizeGatewayRoutePorts` refuses; the message names the entry by position, never a route. */
40
+ export declare class GatewayRoutePortsError extends Error {
41
+ constructor(reasonArg: string);
42
+ }
43
+ /**
44
+ * The table's one spelling of a route's `match.ports` (`IGatewayRouteRow.route`) from any spelling
45
+ * SmartProxy takes: the maximal runs of the ports named, ascending, a port alone as a number and a
46
+ * run of two or more consecutive ports as `{ from, to }`; overlapping and touching entries merge.
47
+ * A bare `443` answers `[443]`, `[445, 80, { from: 443, to: 444 }]` answers
48
+ * `[80, { from: 443, to: 445 }]`. Throws `GatewayRoutePortsError` for a port outside 1 to 65535, a
49
+ * range whose `from` is above its `to`, or an entry that is neither. Both authors of route rows (a
50
+ * gateway's exporter, the controller's compile) call it; the validators only judge its result.
51
+ */
52
+ export declare const canonicalizeGatewayRoutePorts: (portsArg: TGatewayRoutePortsInput) => TGatewayRoutePortEntry[];
53
+ /**
54
+ * The id of a static record: `static-` and the SHA-256 of the record's name, type and value, so
55
+ * both sides derive one id and no row id carries a record value.
56
+ */
57
+ export declare const createGatewayDnsStaticRecordId: (recordArg: Pick<IGatewayDnsStaticRecordRow, 'name' | 'type' | 'value'>) => Promise<string>;
58
+ /**
59
+ * Validates one area's content on its own and names every reason it is refused. Cross-area hard
60
+ * references (`mail.domains[].linkedDomainId`) are not judged here: `validateGatewayAreaTables`
61
+ * judges them per whole document. An area outside `gatewayConfigAreaApplyOrder` is refused
62
+ * `invalid-value` with `area: null`.
63
+ */
64
+ export declare const validateGatewayAreaContent: (areaArg: TGatewayConfigArea, contentArg: unknown) => IGatewayAreaContentRefusal[];
65
+ /**
66
+ * Validates the contents of one whole document (a desired state's `areas`, or the five exports a
67
+ * takeover carries) and names every reason they are refused, area by area in
68
+ * `gatewayConfigAreaApplyOrder`. Cross-area hard references are judged against the document's own
69
+ * tables: a mail table with domains needs the document's dns table (`referenced-area-missing`). A
70
+ * table whose area is outside `gatewayConfigAreaApplyOrder` is refused `invalid-value` with
71
+ * `area: null` and its position in `tablesArg` as the path (`[n]`), never skipped.
72
+ *
73
+ * What it enforces inside engine configuration is the closed key vocabulary
74
+ * (`gatewayAreaRefusedEngineKeys`) at any depth; completeness against the engine types is the
75
+ * gateway's own classification (see `gatewayareas.ts`).
76
+ *
77
+ * Not judged here, because no single document shows it: whether a sealed value's version names the
78
+ * value the gateway stored under it (the gateway refuses the same version with a different value as
79
+ * `invalid-table`), whether a domain changed `source` or `providerId` under one id
80
+ * (`validateGatewayAreaContentChange`), and every engine semantic (the gateway's own check).
81
+ */
82
+ export declare const validateGatewayAreaTables: (tablesArg: readonly Pick<IGatewayAreaTable, 'area' | 'content'>[]) => IGatewayAreaContentRefusal[];
83
+ /**
84
+ * Judges a change of one area's content against the content it replaces, both already valid: a
85
+ * domain keeps its `source` and `providerId` under one id. Every other area has no such rule yet.
86
+ */
87
+ export declare const validateGatewayAreaContentChange: <TArea extends TGatewayConfigArea>(areaArg: TArea, previousArg: TGatewayAreaContent<TArea>, nextArg: TGatewayAreaContent<TArea>) => IGatewayAreaContentRefusal[];
88
+ /** One secret-class value of a table, by where it is and its version, never its value. */
89
+ export interface IGatewayAreaSecretReference {
90
+ area: TGatewayConfigArea;
91
+ member: string;
92
+ /** `null` for a singleton. */
93
+ rowId: string | null;
94
+ /** The key path inside the row or singleton. */
95
+ path: string;
96
+ secretClass: 'sealed' | 'verifier';
97
+ /** The sealed version; `null` for a verifier. */
98
+ version: string | null;
99
+ }
100
+ /**
101
+ * Every secret-class value of a valid area content: what a controller seals, and what its
102
+ * revisions and diffs name by version instead of by value.
103
+ */
104
+ export declare const listGatewayAreaSecrets: <TArea extends TGatewayConfigArea>(areaArg: TArea, contentArg: TGatewayAreaContent<TArea>) => IGatewayAreaSecretReference[];