@serve.zone/interfaces 32.74.0 → 32.75.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.
- package/changelog.md +11 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/gateway.d.ts +64 -1
- package/dist_ts/data/gateway.js +87 -2
- package/dist_ts/requests/gateway.d.ts +9 -5
- package/package.json +1 -1
- package/readme.md +31 -1
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/gateway.ts +137 -2
- package/ts/requests/gateway.ts +9 -5
package/changelog.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-11-11 - 32.75.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Gateway route request headers: `data.IGatewayRouteAction.requestHeaders` asks a gateway to set request header fields on every request and WebSocket upgrade it forwards to the route's targets, each replacing every copy of its name the client sent, so a gateway client can hand its backend a trusted-proxy secret. `data.gatewayRouteRequestHeadersContract` bounds it (1 to 16 fields, names of at most 64 characters in lowercase hyphen-separated words, values of 1 to 1,024 characters of visible ASCII and spaces without a leading or trailing space, at most 4,096 characters together) and reserves the fields a gateway owns on the backend leg (`host`, `connection`, `keep-alive`, `te`, `trailer`, `transfer-encoding`, `upgrade`, `http2-settings`, `content-length`, `expect`, `forwarded`, `via`, `x-real-ip`, `x-forwarded-*`, `proxy-*`, `sec-websocket-*`); `data.validateGatewayRouteRequestHeaders` names every refusal without repeating a value, and `data.isGatewayRouteRequestHeaderName` judges one name. The member is write-only: each `syncGatewayClientRoute` states the complete set (a sync without it removes the fields), and reads never return values: `data.IGatewayClientRoute.requestHeaderNames` lists the names, sorted, and its `route.action` never carries the member. `data.IGatewayCapabilities.routes.requestHeaders` says a gateway accepts it. A gateway built before this release reads a route by its exact keys and refuses a route that carries the member, so a client sends it only to a gateway that answers `routes.requestHeaders: true`. Spec: `test.gatewayrequestheaders`.
|
|
8
|
+
- Gateway route source profile read-back: `data.IGatewayClientRoute.sourceProfileName` (optional string) names the source profile a route is bound to, next to its id in `sourceProfileRef`, so a gateway client reads the binding back by the name it synced. A gateway built before this release omits it. Spec: `test.gatewayrequestheaders`.
|
|
9
|
+
|
|
10
|
+
### Fixes
|
|
11
|
+
|
|
12
|
+
- `syncGatewayClientRoute` documentation: an omitted `sourceProfileRef` binds the route to the gateway's `STANDARD` source profile on every sync, an update included, not to a public profile or the profile stored before, and an id or name the gateway cannot resolve fails the sync; an omitted `dnsMode` keeps the stored mode (`skip` for a new route), which `data.TGatewayRouteDnsMode` now says too, and `reconcile` never claims or replaces a manual record, as that type already said since 32.61.0. The readme's gateway DNS section said the same stale things and now matches.
|
|
13
|
+
|
|
3
14
|
## 2026-11-10 - 32.74.0
|
|
4
15
|
|
|
5
16
|
### Features
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@serve.zone/interfaces',
|
|
6
|
-
version: '32.
|
|
6
|
+
version: '32.75.0',
|
|
7
7
|
description: 'Shared TypeScript interfaces and TypedRequest contracts for the serve.zone ecosystem.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx3QkFBd0I7SUFDOUIsT0FBTyxFQUFFLFNBQVM7SUFDbEIsV0FBVyxFQUFFLHVGQUF1RjtDQUNyRyxDQUFBIn0=
|
|
@@ -21,7 +21,9 @@ export type TManagedRouteKind = 'letsencrypt-http01-forward';
|
|
|
21
21
|
* hostname while another enabled route on the gateway serves it, the owned
|
|
22
22
|
* record is released to manual ownership instead of deleted.
|
|
23
23
|
* - 'observe' reports DNS state without mutating it.
|
|
24
|
-
* - 'skip' bypasses DNS inspection and mutation
|
|
24
|
+
* - 'skip' bypasses DNS inspection and mutation.
|
|
25
|
+
*
|
|
26
|
+
* An omitted mode keeps the route's stored mode, and is 'skip' for a new route.
|
|
25
27
|
*/
|
|
26
28
|
export type TGatewayRouteDnsMode = 'reconcile' | 'observe' | 'skip';
|
|
27
29
|
/**
|
|
@@ -100,6 +102,11 @@ export interface IGatewayCapabilities {
|
|
|
100
102
|
read: boolean;
|
|
101
103
|
write: boolean;
|
|
102
104
|
idempotentSync: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* `syncGatewayClientRoute` accepts `IGatewayRouteAction.requestHeaders`. Absent means
|
|
107
|
+
* unsupported: such a gateway reads a route by its exact keys and refuses the whole route.
|
|
108
|
+
*/
|
|
109
|
+
requestHeaders?: boolean;
|
|
103
110
|
};
|
|
104
111
|
domains: {
|
|
105
112
|
read: boolean;
|
|
@@ -389,6 +396,21 @@ export interface IGatewayRouteAction {
|
|
|
389
396
|
websocket?: {
|
|
390
397
|
enabled: boolean;
|
|
391
398
|
};
|
|
399
|
+
/**
|
|
400
|
+
* Request header fields the gateway sets on every request and WebSocket upgrade it forwards to
|
|
401
|
+
* the targets, by name. Each replaces every copy of its name the client sent, whatever its
|
|
402
|
+
* casing, so a client can neither forge nor duplicate one: this is how a gateway client hands
|
|
403
|
+
* its backend a trusted-proxy secret. Names and values follow `gatewayRouteRequestHeadersContract`
|
|
404
|
+
* and `validateGatewayRouteRequestHeaders`.
|
|
405
|
+
*
|
|
406
|
+
* Write-only. A sync states the complete set: a route synced without it sets no header, also
|
|
407
|
+
* when an earlier sync set some. No read returns the values; `IGatewayClientRoute` names the
|
|
408
|
+
* fields in `requestHeaderNames`, and its `route.action` never carries this member.
|
|
409
|
+
*
|
|
410
|
+
* Gate it on the gateway: one built before this member refuses a route that carries it, so send
|
|
411
|
+
* it only to a gateway whose `getGatewayCapabilities` answers `routes.requestHeaders: true`.
|
|
412
|
+
*/
|
|
413
|
+
requestHeaders?: Record<string, string>;
|
|
392
414
|
}
|
|
393
415
|
/**
|
|
394
416
|
* Platform-neutral desired state for one gateway route.
|
|
@@ -433,8 +455,22 @@ export interface IGatewayClientRoute {
|
|
|
433
455
|
name: string;
|
|
434
456
|
enabled: boolean;
|
|
435
457
|
ownership: IGatewayClientOwnership;
|
|
458
|
+
/** The route as synced, without `action.requestHeaders`, which is write-only. */
|
|
436
459
|
route: IGatewayRouteConfig;
|
|
460
|
+
/**
|
|
461
|
+
* Names of the request header fields the route sets (`action.requestHeaders`), sorted; their
|
|
462
|
+
* values are never returned. Absent when the route sets none.
|
|
463
|
+
*/
|
|
464
|
+
requestHeaderNames?: string[];
|
|
465
|
+
/** Id of the gateway source profile the route is bound to. */
|
|
437
466
|
sourceProfileRef?: string;
|
|
467
|
+
/**
|
|
468
|
+
* Name of that source profile, as the gateway recorded it for the route, so a client can read the
|
|
469
|
+
* binding back by the name it synced (`syncGatewayClientRoute` resolves `sourceProfileRef` by id
|
|
470
|
+
* or name). Optional: a gateway built before this member omits it, so absence says nothing about
|
|
471
|
+
* the binding.
|
|
472
|
+
*/
|
|
473
|
+
sourceProfileName?: string;
|
|
438
474
|
/** Persisted DNS handling mode for this managed route. */
|
|
439
475
|
dnsMode?: TGatewayRouteDnsMode;
|
|
440
476
|
/** Explicit provider proxy intent for the managed address record. */
|
|
@@ -598,4 +634,31 @@ export declare const validateGatewayClientDnsRecord: (valueArg: unknown, pathArg
|
|
|
598
634
|
* widens what a record may point at.
|
|
599
635
|
*/
|
|
600
636
|
export declare const isGatewayClientDnsRecordAllowed: (recordArg: IGatewayClientDnsRecord, allowedDnsRecordAddressesArg: readonly string[] | undefined) => boolean;
|
|
637
|
+
/**
|
|
638
|
+
* Bounds and reserved names of `IGatewayRouteAction.requestHeaders`.
|
|
639
|
+
*
|
|
640
|
+
* A name is lowercase letters and digits in hyphen-separated words, so a field has one spelling and
|
|
641
|
+
* no two entries of one map name the same field. A value is visible ASCII and spaces, without a
|
|
642
|
+
* leading or trailing space. Reserved are the fields a gateway owns on the backend leg: hop-by-hop
|
|
643
|
+
* and message framing fields, the request target (`host`), the forwarding chain (`forwarded`,
|
|
644
|
+
* `via`, `x-real-ip`, `x-forwarded-*`), proxy credentials (`proxy-*`) and the WebSocket handshake
|
|
645
|
+
* (`sec-websocket-*`).
|
|
646
|
+
*/
|
|
647
|
+
export declare const gatewayRouteRequestHeadersContract: Readonly<{
|
|
648
|
+
maxHeaders: 16;
|
|
649
|
+
maxNameLength: 64;
|
|
650
|
+
maxValueLength: 1024;
|
|
651
|
+
/** Bound of the summed lengths of every name and value of one map. */
|
|
652
|
+
maxTotalLength: 4096;
|
|
653
|
+
reservedNames: readonly string[];
|
|
654
|
+
reservedNamePrefixes: readonly string[];
|
|
655
|
+
}>;
|
|
656
|
+
/** True for a request header name a route may set: canonical lowercase and not reserved. */
|
|
657
|
+
export declare const isGatewayRouteRequestHeaderName: (valueArg: unknown) => valueArg is string;
|
|
658
|
+
/**
|
|
659
|
+
* Validates a route's `requestHeaders` and names every reason it is refused.
|
|
660
|
+
*
|
|
661
|
+
* The reasons name the fields, never a value: a value is commonly a secret.
|
|
662
|
+
*/
|
|
663
|
+
export declare const validateGatewayRouteRequestHeaders: (valueArg: unknown, pathArg?: string) => string[];
|
|
601
664
|
export {};
|
package/dist_ts/data/gateway.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hasExactKeys, readDataElements, readDataProperties } from '../private/dataproperties.js';
|
|
1
|
+
import { hasExactKeys, isPlainRecord, readDataElements, readDataProperties } from '../private/dataproperties.js';
|
|
2
2
|
import { isPlausibleUnicastIpv4 } from '../private/ipv4.js';
|
|
3
3
|
import { ipPrefixContains, parseCanonicalIpAddress, parseCanonicalIpPrefix, } from '../private/ipaddress.js';
|
|
4
4
|
/**
|
|
@@ -112,4 +112,89 @@ export const isGatewayClientDnsRecordAllowed = (recordArg, allowedDnsRecordAddre
|
|
|
112
112
|
return prefix !== null && ipPrefixContains(prefix, address);
|
|
113
113
|
});
|
|
114
114
|
};
|
|
115
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Bounds and reserved names of `IGatewayRouteAction.requestHeaders`.
|
|
117
|
+
*
|
|
118
|
+
* A name is lowercase letters and digits in hyphen-separated words, so a field has one spelling and
|
|
119
|
+
* no two entries of one map name the same field. A value is visible ASCII and spaces, without a
|
|
120
|
+
* leading or trailing space. Reserved are the fields a gateway owns on the backend leg: hop-by-hop
|
|
121
|
+
* and message framing fields, the request target (`host`), the forwarding chain (`forwarded`,
|
|
122
|
+
* `via`, `x-real-ip`, `x-forwarded-*`), proxy credentials (`proxy-*`) and the WebSocket handshake
|
|
123
|
+
* (`sec-websocket-*`).
|
|
124
|
+
*/
|
|
125
|
+
export const gatewayRouteRequestHeadersContract = Object.freeze({
|
|
126
|
+
maxHeaders: 16,
|
|
127
|
+
maxNameLength: 64,
|
|
128
|
+
maxValueLength: 1024,
|
|
129
|
+
/** Bound of the summed lengths of every name and value of one map. */
|
|
130
|
+
maxTotalLength: 4096,
|
|
131
|
+
reservedNames: Object.freeze([
|
|
132
|
+
'connection',
|
|
133
|
+
'content-length',
|
|
134
|
+
'expect',
|
|
135
|
+
'forwarded',
|
|
136
|
+
'host',
|
|
137
|
+
'http2-settings',
|
|
138
|
+
'keep-alive',
|
|
139
|
+
'te',
|
|
140
|
+
'trailer',
|
|
141
|
+
'transfer-encoding',
|
|
142
|
+
'upgrade',
|
|
143
|
+
'via',
|
|
144
|
+
'x-real-ip',
|
|
145
|
+
]),
|
|
146
|
+
reservedNamePrefixes: Object.freeze(['proxy-', 'sec-websocket-', 'x-forwarded-']),
|
|
147
|
+
});
|
|
148
|
+
const gatewayRouteRequestHeaderName = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
149
|
+
const gatewayRouteRequestHeaderValue = /^[\x21-\x7e](?:[\x20-\x7e]*[\x21-\x7e])?$/;
|
|
150
|
+
/** True when the name follows the request header name syntax, reserved or not. */
|
|
151
|
+
const isGatewayRouteRequestHeaderNameSyntax = (valueArg) => (valueArg.length <= gatewayRouteRequestHeadersContract.maxNameLength
|
|
152
|
+
&& gatewayRouteRequestHeaderName.test(valueArg));
|
|
153
|
+
/** True when the name is one a gateway owns on the backend leg. */
|
|
154
|
+
const isGatewayRouteRequestHeaderNameReserved = (valueArg) => (gatewayRouteRequestHeadersContract.reservedNames.includes(valueArg)
|
|
155
|
+
|| gatewayRouteRequestHeadersContract.reservedNamePrefixes.some((prefixArg) => valueArg.startsWith(prefixArg)));
|
|
156
|
+
/** True for a request header name a route may set: canonical lowercase and not reserved. */
|
|
157
|
+
export const isGatewayRouteRequestHeaderName = (valueArg) => (typeof valueArg === 'string'
|
|
158
|
+
&& isGatewayRouteRequestHeaderNameSyntax(valueArg)
|
|
159
|
+
&& !isGatewayRouteRequestHeaderNameReserved(valueArg));
|
|
160
|
+
/**
|
|
161
|
+
* Validates a route's `requestHeaders` and names every reason it is refused.
|
|
162
|
+
*
|
|
163
|
+
* The reasons name the fields, never a value: a value is commonly a secret.
|
|
164
|
+
*/
|
|
165
|
+
export const validateGatewayRouteRequestHeaders = (valueArg, pathArg = 'requestHeaders') => {
|
|
166
|
+
const { maxHeaders, maxNameLength, maxValueLength, maxTotalLength } = gatewayRouteRequestHeadersContract;
|
|
167
|
+
// The bound is judged before any property is copied, as `readDataElements` does for lists.
|
|
168
|
+
const headers = isPlainRecord(valueArg) && Reflect.ownKeys(valueArg).length <= maxHeaders
|
|
169
|
+
? readDataProperties(valueArg)
|
|
170
|
+
: null;
|
|
171
|
+
if (headers === null || Object.keys(headers).length === 0) {
|
|
172
|
+
return [`${pathArg} must map 1 to ${maxHeaders} header names to string values; omit it to set none`];
|
|
173
|
+
}
|
|
174
|
+
const errors = [];
|
|
175
|
+
let totalLength = 0;
|
|
176
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
177
|
+
// Quoted with escapes and cut to the longest valid name, so a refused name prints as one line.
|
|
178
|
+
const label = name.length <= maxNameLength
|
|
179
|
+
? JSON.stringify(name)
|
|
180
|
+
: `${JSON.stringify(name.slice(0, maxNameLength))}…`;
|
|
181
|
+
if (!isGatewayRouteRequestHeaderNameSyntax(name)) {
|
|
182
|
+
errors.push(`${pathArg} name ${label} must be 1 to ${maxNameLength} characters of lowercase `
|
|
183
|
+
+ 'letters and digits in hyphen-separated words');
|
|
184
|
+
}
|
|
185
|
+
else if (isGatewayRouteRequestHeaderNameReserved(name)) {
|
|
186
|
+
errors.push(`${pathArg} must not set ${label}: the gateway owns it on the backend leg`);
|
|
187
|
+
}
|
|
188
|
+
if (typeof value !== 'string' || value.length > maxValueLength
|
|
189
|
+
|| !gatewayRouteRequestHeaderValue.test(value)) {
|
|
190
|
+
errors.push(`${pathArg} value of ${label} must be 1 to ${maxValueLength} characters of visible `
|
|
191
|
+
+ 'ASCII and spaces, without a leading or trailing space');
|
|
192
|
+
}
|
|
193
|
+
totalLength += name.length + (typeof value === 'string' ? value.length : 0);
|
|
194
|
+
}
|
|
195
|
+
if (totalLength > maxTotalLength) {
|
|
196
|
+
errors.push(`${pathArg} names and values must total at most ${maxTotalLength} characters`);
|
|
197
|
+
}
|
|
198
|
+
return errors;
|
|
199
|
+
};
|
|
200
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2F0ZXdheS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL2RhdGEvZ2F0ZXdheS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEVBQUUsWUFBWSxFQUFFLGFBQWEsRUFBRSxnQkFBZ0IsRUFBRSxrQkFBa0IsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBQ2pILE9BQU8sRUFBRSxzQkFBc0IsRUFBRSxNQUFN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QixhQUFhLDJCQUEyQjtrQkFDekYsOENBQThDLENBQUMsQ0FBQztRQUN0RCxDQUFDO2FBQU0sSUFBSSx1Q0FBdUMsQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDO1lBQ3pELE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxPQUFPLGlCQUFpQixLQUFLLDBDQUEwQyxDQUFDLENBQUM7UUFDMUYsQ0FBQztRQUNELElBQUksT0FBTyxLQUFLLEtBQUssUUFBUSxJQUFJLEtBQUssQ0FBQyxNQUFNLEdBQUcsY0FBYztlQUN6RCxDQUFDLDhCQUE4QixDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDO1lBQ2pELE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxPQUFPLGFBQWEsS0FBSyxpQkFBaUIsY0FBYyx5QkFBeUI7a0JBQzVGLHVEQUF1RCxDQUFDLENBQUM7UUFDL0QsQ0FBQztRQUNELFdBQVcsSUFBSSxJQUFJLENBQUMsTUFBTSxHQUFHLENBQUMsT0FBTyxLQUFLLEtBQUssUUFBUSxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUM5RSxDQUFDO0lBQ0QsSUFBSSxXQUFXLEdBQUcsY0FBYyxFQUFFLENBQUM7UUFDakMsTUFBTSxDQUFDLElBQUksQ0FBQyxHQUFHLE9BQU8sd0NBQXdDLGNBQWMsYUFBYSxDQUFDLENBQUM7SUFDN0YsQ0FBQztJQUNELE9BQU8sTUFBTSxDQUFDO0FBQ2hCLENBQUMsQ0FBQyJ9
|
|
@@ -154,9 +154,9 @@ export interface IReq_SyncGatewayClientRoute extends plugins.typedrequestInterfa
|
|
|
154
154
|
enabled?: boolean;
|
|
155
155
|
delete?: boolean;
|
|
156
156
|
/**
|
|
157
|
-
* Omission
|
|
158
|
-
*
|
|
159
|
-
*
|
|
157
|
+
* Omission keeps the route's stored mode, and is 'skip' for a new route.
|
|
158
|
+
* Reconciliation never adopts, replaces or deletes a record the route's
|
|
159
|
+
* gateway DNS ownership does not hold; see `TGatewayRouteDnsMode`.
|
|
160
160
|
*/
|
|
161
161
|
dnsMode?: TGatewayRouteDnsMode;
|
|
162
162
|
/**
|
|
@@ -165,8 +165,12 @@ export interface IReq_SyncGatewayClientRoute extends plugins.typedrequestInterfa
|
|
|
165
165
|
*/
|
|
166
166
|
dnsProxied?: boolean;
|
|
167
167
|
/**
|
|
168
|
-
* Gateway source profile to bind the route to
|
|
169
|
-
*
|
|
168
|
+
* Gateway source profile to bind the route to, by id or name (an id
|
|
169
|
+
* first, then a name, case-insensitive). A profile the gateway cannot
|
|
170
|
+
* resolve fails the sync. Omission binds the route to the gateway's
|
|
171
|
+
* `STANDARD` profile on every sync, an update included, never to the
|
|
172
|
+
* profile stored before: send it explicitly, for example
|
|
173
|
+
* `'LOCAL NETWORK'` for a route only private networks may reach.
|
|
170
174
|
*/
|
|
171
175
|
sourceProfileRef?: string;
|
|
172
176
|
};
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -4172,7 +4172,37 @@ A delivery state of `pushServiceAccepted` means only that the remote push servic
|
|
|
4172
4172
|
|
|
4173
4173
|
### Gateway Client Lifecycle and DNS
|
|
4174
4174
|
|
|
4175
|
-
`syncGatewayClientRoute` accepts an optional `dnsMode`. Omission means `skip` for
|
|
4175
|
+
`syncGatewayClientRoute` accepts an optional `dnsMode`. Omission keeps the route's stored mode and means `skip` for a new route. `observe` reports DNS without changing it. `reconcile` creates, updates and deletes only the exact-host A or AAAA record the route's gateway DNS ownership holds; it never adopts, replaces or deletes a record without that ownership (`data.TGatewayRouteDnsMode`), so a differing manual record is a non-retryable `record-conflict` and matching manual records are `manual-satisfied`. Its optional `dns` result contains a closed status, retryability, the desired A/AAAA target, `checkedAt`, and `authoritativeVerifiedAt` once the provider or authoritative server confirms the state. Consumers can carry that evidence while retrying public propagation instead of treating an immediate recursive lookup miss as permanent.
|
|
4176
|
+
|
|
4177
|
+
`sourceProfileRef` names the gateway source profile a route binds to, by id or name. Omission binds the route to the gateway's `STANDARD` profile on every sync, an update included, not to the profile stored before; a route meant for private networks only sends its profile explicitly, for example `'LOCAL NETWORK'`. A route read (`data.IGatewayClientRoute`) returns the bound profile's id in `sourceProfileRef` and its name in `sourceProfileName`, so a client compares the binding by the name it synced; `sourceProfileName` is optional, and a gateway built before it omits it.
|
|
4178
|
+
|
|
4179
|
+
`route.action.requestHeaders` sets request header fields on everything the gateway forwards to the route's targets, requests and WebSocket upgrades alike, replacing every copy of the same name the client sent; a gateway client hands its backend a trusted-proxy secret this way. Names are lowercase hyphen-separated words, values visible ASCII, at most 16 fields (`data.gatewayRouteRequestHeadersContract`, `data.validateGatewayRouteRequestHeaders`), and the fields a gateway owns on the backend leg (`host`, hop-by-hop and framing fields, `forwarded`, `via`, `x-real-ip`, `x-forwarded-*`, `proxy-*`, `sec-websocket-*`) are refused. The member is write-only: each sync states the complete set, and a sync without it removes the fields; `getGatewayClientRoutes` never returns the values and lists the names in `requestHeaderNames`. A gateway built before it refuses the whole route, because gateways read routes by their exact keys, so a client sends it only to a gateway whose `getGatewayCapabilities` answers `routes.requestHeaders: true`.
|
|
4180
|
+
|
|
4181
|
+
```typescript
|
|
4182
|
+
import { data, requests } from '@serve.zone/interfaces';
|
|
4183
|
+
|
|
4184
|
+
const sync: requests.gateway.IReq_SyncGatewayClientRoute['request'] = {
|
|
4185
|
+
apiToken: 'gateway-client-token',
|
|
4186
|
+
ownership: { appId: 'controller', hostname: 'app.example.com' },
|
|
4187
|
+
route: {
|
|
4188
|
+
name: 'controller',
|
|
4189
|
+
match: { ports: [443], domains: ['app.example.com'] },
|
|
4190
|
+
action: {
|
|
4191
|
+
type: 'forward',
|
|
4192
|
+
targets: [{ host: '192.0.2.10', port: 4097 }],
|
|
4193
|
+
tls: { mode: 'terminate', certificate: 'auto' },
|
|
4194
|
+
websocket: { enabled: true },
|
|
4195
|
+
requestHeaders: { 'x-trusted-proxy-secret': 'sealed-secret-value' },
|
|
4196
|
+
},
|
|
4197
|
+
ingress: { directHub: true, smartVpn: true },
|
|
4198
|
+
remoteIngress: { enabled: false },
|
|
4199
|
+
},
|
|
4200
|
+
sourceProfileRef: 'LOCAL NETWORK',
|
|
4201
|
+
dnsMode: 'reconcile',
|
|
4202
|
+
dnsProxied: false,
|
|
4203
|
+
};
|
|
4204
|
+
const refusals = data.validateGatewayRouteRequestHeaders(sync.route!.action.requestHeaders);
|
|
4205
|
+
```
|
|
4176
4206
|
|
|
4177
4207
|
Use `requests.gateway.IReq_ProvisionGatewayClientCredential` to replace an admin/bootstrap token with a first-class gateway-client credential. The admin-authenticated request idempotently upserts a `data.IGatewayClient`, durably creates a new bound credential, returns its raw value once, and then revokes older credentials bound to that client. It never revokes the bootstrap/admin credential. A successful response is discriminated with `success: true` and always includes the action, durable client, one-time credential, and revocation count.
|
|
4178
4208
|
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/data/gateway.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TDnsRecordType } from './dns.js';
|
|
2
|
-
import { hasExactKeys, readDataElements, readDataProperties } from '../private/dataproperties.js';
|
|
2
|
+
import { hasExactKeys, isPlainRecord, readDataElements, readDataProperties } from '../private/dataproperties.js';
|
|
3
3
|
import { isPlausibleUnicastIpv4 } from '../private/ipv4.js';
|
|
4
4
|
import {
|
|
5
5
|
ipPrefixContains,
|
|
@@ -31,7 +31,9 @@ export type TManagedRouteKind = 'letsencrypt-http01-forward';
|
|
|
31
31
|
* hostname while another enabled route on the gateway serves it, the owned
|
|
32
32
|
* record is released to manual ownership instead of deleted.
|
|
33
33
|
* - 'observe' reports DNS state without mutating it.
|
|
34
|
-
* - 'skip' bypasses DNS inspection and mutation
|
|
34
|
+
* - 'skip' bypasses DNS inspection and mutation.
|
|
35
|
+
*
|
|
36
|
+
* An omitted mode keeps the route's stored mode, and is 'skip' for a new route.
|
|
35
37
|
*/
|
|
36
38
|
export type TGatewayRouteDnsMode = 'reconcile' | 'observe' | 'skip';
|
|
37
39
|
|
|
@@ -134,6 +136,11 @@ export interface IGatewayCapabilities {
|
|
|
134
136
|
read: boolean;
|
|
135
137
|
write: boolean;
|
|
136
138
|
idempotentSync: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* `syncGatewayClientRoute` accepts `IGatewayRouteAction.requestHeaders`. Absent means
|
|
141
|
+
* unsupported: such a gateway reads a route by its exact keys and refuses the whole route.
|
|
142
|
+
*/
|
|
143
|
+
requestHeaders?: boolean;
|
|
137
144
|
};
|
|
138
145
|
domains: {
|
|
139
146
|
read: boolean;
|
|
@@ -444,6 +451,21 @@ export interface IGatewayRouteAction {
|
|
|
444
451
|
websocket?: {
|
|
445
452
|
enabled: boolean;
|
|
446
453
|
};
|
|
454
|
+
/**
|
|
455
|
+
* Request header fields the gateway sets on every request and WebSocket upgrade it forwards to
|
|
456
|
+
* the targets, by name. Each replaces every copy of its name the client sent, whatever its
|
|
457
|
+
* casing, so a client can neither forge nor duplicate one: this is how a gateway client hands
|
|
458
|
+
* its backend a trusted-proxy secret. Names and values follow `gatewayRouteRequestHeadersContract`
|
|
459
|
+
* and `validateGatewayRouteRequestHeaders`.
|
|
460
|
+
*
|
|
461
|
+
* Write-only. A sync states the complete set: a route synced without it sets no header, also
|
|
462
|
+
* when an earlier sync set some. No read returns the values; `IGatewayClientRoute` names the
|
|
463
|
+
* fields in `requestHeaderNames`, and its `route.action` never carries this member.
|
|
464
|
+
*
|
|
465
|
+
* Gate it on the gateway: one built before this member refuses a route that carries it, so send
|
|
466
|
+
* it only to a gateway whose `getGatewayCapabilities` answers `routes.requestHeaders: true`.
|
|
467
|
+
*/
|
|
468
|
+
requestHeaders?: Record<string, string>;
|
|
447
469
|
}
|
|
448
470
|
|
|
449
471
|
/**
|
|
@@ -490,8 +512,22 @@ export interface IGatewayClientRoute {
|
|
|
490
512
|
name: string;
|
|
491
513
|
enabled: boolean;
|
|
492
514
|
ownership: IGatewayClientOwnership;
|
|
515
|
+
/** The route as synced, without `action.requestHeaders`, which is write-only. */
|
|
493
516
|
route: IGatewayRouteConfig;
|
|
517
|
+
/**
|
|
518
|
+
* Names of the request header fields the route sets (`action.requestHeaders`), sorted; their
|
|
519
|
+
* values are never returned. Absent when the route sets none.
|
|
520
|
+
*/
|
|
521
|
+
requestHeaderNames?: string[];
|
|
522
|
+
/** Id of the gateway source profile the route is bound to. */
|
|
494
523
|
sourceProfileRef?: string;
|
|
524
|
+
/**
|
|
525
|
+
* Name of that source profile, as the gateway recorded it for the route, so a client can read the
|
|
526
|
+
* binding back by the name it synced (`syncGatewayClientRoute` resolves `sourceProfileRef` by id
|
|
527
|
+
* or name). Optional: a gateway built before this member omits it, so absence says nothing about
|
|
528
|
+
* the binding.
|
|
529
|
+
*/
|
|
530
|
+
sourceProfileName?: string;
|
|
495
531
|
/** Persisted DNS handling mode for this managed route. */
|
|
496
532
|
dnsMode?: TGatewayRouteDnsMode;
|
|
497
533
|
/** Explicit provider proxy intent for the managed address record. */
|
|
@@ -788,3 +824,102 @@ export const isGatewayClientDnsRecordAllowed = (
|
|
|
788
824
|
return prefix !== null && ipPrefixContains(prefix, address);
|
|
789
825
|
});
|
|
790
826
|
};
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Bounds and reserved names of `IGatewayRouteAction.requestHeaders`.
|
|
830
|
+
*
|
|
831
|
+
* A name is lowercase letters and digits in hyphen-separated words, so a field has one spelling and
|
|
832
|
+
* no two entries of one map name the same field. A value is visible ASCII and spaces, without a
|
|
833
|
+
* leading or trailing space. Reserved are the fields a gateway owns on the backend leg: hop-by-hop
|
|
834
|
+
* and message framing fields, the request target (`host`), the forwarding chain (`forwarded`,
|
|
835
|
+
* `via`, `x-real-ip`, `x-forwarded-*`), proxy credentials (`proxy-*`) and the WebSocket handshake
|
|
836
|
+
* (`sec-websocket-*`).
|
|
837
|
+
*/
|
|
838
|
+
export const gatewayRouteRequestHeadersContract = Object.freeze({
|
|
839
|
+
maxHeaders: 16,
|
|
840
|
+
maxNameLength: 64,
|
|
841
|
+
maxValueLength: 1024,
|
|
842
|
+
/** Bound of the summed lengths of every name and value of one map. */
|
|
843
|
+
maxTotalLength: 4096,
|
|
844
|
+
reservedNames: Object.freeze([
|
|
845
|
+
'connection',
|
|
846
|
+
'content-length',
|
|
847
|
+
'expect',
|
|
848
|
+
'forwarded',
|
|
849
|
+
'host',
|
|
850
|
+
'http2-settings',
|
|
851
|
+
'keep-alive',
|
|
852
|
+
'te',
|
|
853
|
+
'trailer',
|
|
854
|
+
'transfer-encoding',
|
|
855
|
+
'upgrade',
|
|
856
|
+
'via',
|
|
857
|
+
'x-real-ip',
|
|
858
|
+
]) as readonly string[],
|
|
859
|
+
reservedNamePrefixes: Object.freeze(['proxy-', 'sec-websocket-', 'x-forwarded-']) as readonly string[],
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
const gatewayRouteRequestHeaderName = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
863
|
+
const gatewayRouteRequestHeaderValue = /^[\x21-\x7e](?:[\x20-\x7e]*[\x21-\x7e])?$/;
|
|
864
|
+
|
|
865
|
+
/** True when the name follows the request header name syntax, reserved or not. */
|
|
866
|
+
const isGatewayRouteRequestHeaderNameSyntax = (valueArg: string): boolean => (
|
|
867
|
+
valueArg.length <= gatewayRouteRequestHeadersContract.maxNameLength
|
|
868
|
+
&& gatewayRouteRequestHeaderName.test(valueArg)
|
|
869
|
+
);
|
|
870
|
+
|
|
871
|
+
/** True when the name is one a gateway owns on the backend leg. */
|
|
872
|
+
const isGatewayRouteRequestHeaderNameReserved = (valueArg: string): boolean => (
|
|
873
|
+
gatewayRouteRequestHeadersContract.reservedNames.includes(valueArg)
|
|
874
|
+
|| gatewayRouteRequestHeadersContract.reservedNamePrefixes.some((prefixArg) => valueArg.startsWith(prefixArg))
|
|
875
|
+
);
|
|
876
|
+
|
|
877
|
+
/** True for a request header name a route may set: canonical lowercase and not reserved. */
|
|
878
|
+
export const isGatewayRouteRequestHeaderName = (valueArg: unknown): valueArg is string => (
|
|
879
|
+
typeof valueArg === 'string'
|
|
880
|
+
&& isGatewayRouteRequestHeaderNameSyntax(valueArg)
|
|
881
|
+
&& !isGatewayRouteRequestHeaderNameReserved(valueArg)
|
|
882
|
+
);
|
|
883
|
+
|
|
884
|
+
/**
|
|
885
|
+
* Validates a route's `requestHeaders` and names every reason it is refused.
|
|
886
|
+
*
|
|
887
|
+
* The reasons name the fields, never a value: a value is commonly a secret.
|
|
888
|
+
*/
|
|
889
|
+
export const validateGatewayRouteRequestHeaders = (
|
|
890
|
+
valueArg: unknown,
|
|
891
|
+
pathArg = 'requestHeaders',
|
|
892
|
+
): string[] => {
|
|
893
|
+
const { maxHeaders, maxNameLength, maxValueLength, maxTotalLength } = gatewayRouteRequestHeadersContract;
|
|
894
|
+
// The bound is judged before any property is copied, as `readDataElements` does for lists.
|
|
895
|
+
const headers = isPlainRecord(valueArg) && Reflect.ownKeys(valueArg).length <= maxHeaders
|
|
896
|
+
? readDataProperties(valueArg)
|
|
897
|
+
: null;
|
|
898
|
+
if (headers === null || Object.keys(headers).length === 0) {
|
|
899
|
+
return [`${pathArg} must map 1 to ${maxHeaders} header names to string values; omit it to set none`];
|
|
900
|
+
}
|
|
901
|
+
const errors: string[] = [];
|
|
902
|
+
let totalLength = 0;
|
|
903
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
904
|
+
// Quoted with escapes and cut to the longest valid name, so a refused name prints as one line.
|
|
905
|
+
const label = name.length <= maxNameLength
|
|
906
|
+
? JSON.stringify(name)
|
|
907
|
+
: `${JSON.stringify(name.slice(0, maxNameLength))}…`;
|
|
908
|
+
if (!isGatewayRouteRequestHeaderNameSyntax(name)) {
|
|
909
|
+
errors.push(`${pathArg} name ${label} must be 1 to ${maxNameLength} characters of lowercase `
|
|
910
|
+
+ 'letters and digits in hyphen-separated words');
|
|
911
|
+
} else if (isGatewayRouteRequestHeaderNameReserved(name)) {
|
|
912
|
+
errors.push(`${pathArg} must not set ${label}: the gateway owns it on the backend leg`);
|
|
913
|
+
}
|
|
914
|
+
if (typeof value !== 'string' || value.length > maxValueLength
|
|
915
|
+
|| !gatewayRouteRequestHeaderValue.test(value)) {
|
|
916
|
+
errors.push(`${pathArg} value of ${label} must be 1 to ${maxValueLength} characters of visible `
|
|
917
|
+
+ 'ASCII and spaces, without a leading or trailing space');
|
|
918
|
+
}
|
|
919
|
+
totalLength += name.length + (typeof value === 'string' ? value.length : 0);
|
|
920
|
+
}
|
|
921
|
+
if (totalLength > maxTotalLength) {
|
|
922
|
+
errors.push(`${pathArg} names and values must total at most ${maxTotalLength} characters`);
|
|
923
|
+
}
|
|
924
|
+
return errors;
|
|
925
|
+
};
|
package/ts/requests/gateway.ts
CHANGED
|
@@ -219,9 +219,9 @@ export interface IReq_SyncGatewayClientRoute extends plugins.typedrequestInterfa
|
|
|
219
219
|
enabled?: boolean;
|
|
220
220
|
delete?: boolean;
|
|
221
221
|
/**
|
|
222
|
-
* Omission
|
|
223
|
-
*
|
|
224
|
-
*
|
|
222
|
+
* Omission keeps the route's stored mode, and is 'skip' for a new route.
|
|
223
|
+
* Reconciliation never adopts, replaces or deletes a record the route's
|
|
224
|
+
* gateway DNS ownership does not hold; see `TGatewayRouteDnsMode`.
|
|
225
225
|
*/
|
|
226
226
|
dnsMode?: TGatewayRouteDnsMode;
|
|
227
227
|
/**
|
|
@@ -230,8 +230,12 @@ export interface IReq_SyncGatewayClientRoute extends plugins.typedrequestInterfa
|
|
|
230
230
|
*/
|
|
231
231
|
dnsProxied?: boolean;
|
|
232
232
|
/**
|
|
233
|
-
* Gateway source profile to bind the route to
|
|
234
|
-
*
|
|
233
|
+
* Gateway source profile to bind the route to, by id or name (an id
|
|
234
|
+
* first, then a name, case-insensitive). A profile the gateway cannot
|
|
235
|
+
* resolve fails the sync. Omission binds the route to the gateway's
|
|
236
|
+
* `STANDARD` profile on every sync, an update included, never to the
|
|
237
|
+
* profile stored before: send it explicitly, for example
|
|
238
|
+
* `'LOCAL NETWORK'` for a route only private networks may reach.
|
|
235
239
|
*/
|
|
236
240
|
sourceProfileRef?: string;
|
|
237
241
|
};
|