@serve.zone/interfaces 32.75.0 → 32.76.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 +15 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/controller.d.ts +70 -0
- package/dist_ts/data/controller.js +44 -0
- package/dist_ts/data/gatewayconnector.d.ts +278 -0
- package/dist_ts/data/gatewayconnector.js +418 -0
- package/dist_ts/data/index.d.ts +2 -0
- package/dist_ts/data/index.js +3 -1
- package/dist_ts/data/location.d.ts +3 -1
- package/dist_ts/data/location.js +7 -5
- package/dist_ts/private/controllercontract.d.ts +8 -0
- package/dist_ts/private/controllercontract.js +50 -0
- package/dist_ts/requests/baremetal.d.ts +2 -1
- package/dist_ts/requests/cluster.d.ts +5 -3
- package/dist_ts/requests/gatewayconnector.d.ts +133 -0
- package/dist_ts/requests/gatewayconnector.js +2 -0
- package/dist_ts/requests/index.d.ts +2 -1
- package/dist_ts/requests/index.js +3 -2
- package/dist_ts/requests/node.d.ts +4 -1
- package/dist_ts/runtime.corestore.database.d.ts +23 -0
- package/dist_ts/runtime.corestore.database.js +41 -0
- package/dist_ts/runtime.d.ts +1 -0
- package/dist_ts/runtime.js +2 -1
- package/package.json +2 -2
- package/readme.md +98 -5
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/controller.ts +106 -0
- package/ts/data/gatewayconnector.ts +714 -0
- package/ts/data/index.ts +2 -0
- package/ts/data/location.ts +6 -4
- package/ts/private/controllercontract.ts +59 -0
- package/ts/requests/baremetal.ts +2 -1
- package/ts/requests/cluster.ts +5 -3
- package/ts/requests/gatewayconnector.ts +168 -0
- package/ts/requests/index.ts +2 -0
- package/ts/requests/node.ts +4 -1
- package/ts/runtime.corestore.database.ts +64 -0
- package/ts/runtime.ts +1 -0
package/changelog.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2026-11-11 - 32.76.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Gateway connector (AGL-1182, Linus ruling 30, slice 1): a gateway dials its controller and is adopted with a one-time code. `data.IGateway` (required `locationId`; `connection` is `legacy` with URL and gateway client id, or `adopted` with machine user and credential generation), `data.IControllerPeerSet` (`controllerId`, `epoch`, `activeOrigin`, `shadowOrigins`; a gateway refuses another controller and an older epoch), `data.IControllerRevision`, `data.IGatewayAdoptionFacts`, the desired state `data.IGatewayDesiredState` of whole area tables (`data.IGatewayAreaTable`, untyped `content`, `takeover.localDigest`), `data.TGatewayConfigArea` with `data.gatewayConfigAreaApplyOrder` (`security`, `dns`, `routes`, `mail`, `edges`), `data.gatewayApplyRefusals`, `data.IGatewayAreaApplyState`, `data.IGatewayApplyReport`, `data.IGatewayStatusDocument` (`listeningPorts` as `data.IGatewayListeningPorts` `{ tcp, udp }`, each a list of merged `data.IGatewayPortRange` `{ from, to }` ranges, so a wide route range such as 10000–20000 is one entry; lowercase `dnsZones`) and `data.IGatewayAreaExport`. `data.compareControllerRevisionOrder` orders by epoch, then revision; `data.computeGatewayAreaTableDigest` is the one area table digest (domain `serve.zone/gateway-area-table`); `data.gatewayConnectorContract` holds the bounds (`maximumListeningPortRanges` 1024 per transport) and the 5 s status push interval; exact-key validators `data.validateControllerPeerSet`, `data.validateGatewayAdoptionFacts`, `data.validateRegisterGatewaySessionRequest`, `data.validateGatewayDesiredState`, `data.validateGatewayApplyReport`, `data.validateGatewayStatusDocument` and `data.validateGatewayAreaExport`. Requests (`requests.gatewayconnector`): `adoptGateway`, `registerGatewaySession` and `pushGatewayStatus` (gateway → Cloudly), `applyDesiredState` and `exportGatewayArea` (Cloudly → gateway on the gateway's socket), and the administrator requests `createGatewayAdoptionCode` and `getGateways` (optional `locationScope` with its `appliedLocationScope` echo). Spec: `test.gatewayconnector`.
|
|
8
|
+
- Corestore database helpers in the Node-only `/runtime` export (Linus ruling 31, U7), moved from `@serve.zone/corestore`'s `corestore.database.ts` so its readers (Onebox) drop the Corestore dependency: `runtime.getCorestoreDatabaseIdentity(serviceId, serviceName?)` with `runtime.ICorestoreDatabaseIdentity`, byte-identical to Corestore's `getCoreStoreDatabaseIdentity` (pinned against Corestore 34.1.4's answers), and `runtime.corestoreDatabaseAllocationReferencesEqual`. The allocation reference and its reader were already here as `runtime.ICorestoreDatabaseAllocationReference` and `runtime.normalizeCorestoreDatabaseAllocationReference`. Spec: `test.corestoredatabase`.
|
|
9
|
+
|
|
10
|
+
### Documentation
|
|
11
|
+
|
|
12
|
+
- Locations (AGL-1197, Linus ruling 34), docs only: the scoped lists `getClusters`, `getNodes` and `getBaremetalServers` are refused `location-not-found` when no location has the `locationScope` id; a cluster whose nodes span locations is in no scoped `getClusters` answer; `location-needs-node` and `createCluster.locationId` name a setup mode that provisions no node (today every mode but `hetzner`); `data.locationRefusals` states that at a jump-code claim or node enrollment Cloudly logs the refusal by name and the claimant receives that path's single refusal sentence; the readme names Cloudly's location data step `initial-location` instead of Cloudly's version numbers.
|
|
13
|
+
|
|
14
|
+
### Maintenance
|
|
15
|
+
|
|
16
|
+
- Release tooling: `@git.zone/tsrepo` 2.0.0 → 2.1.0. `@types/node` 26.6.6 and pnpm 12.17.0 stay the newest eligible (pnpm 12.18.0 clears the seven-day age gate on 2026-11-12). The published package is unchanged by this.
|
|
17
|
+
|
|
3
18
|
## 2026-11-11 - 32.75.0
|
|
4
19
|
|
|
5
20
|
### Features
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@serve.zone/interfaces',
|
|
6
|
-
version: '32.
|
|
6
|
+
version: '32.76.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=
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The controller as the components that dial it know it: which controller they belong to, which
|
|
3
|
+
* epoch it is in and where to reach it.
|
|
4
|
+
*
|
|
5
|
+
* A dialling component (a gateway today) stores this when it is adopted and replaces it with every
|
|
6
|
+
* answer the controller gives it. It refuses any other `controllerId` and any older `epoch`: a
|
|
7
|
+
* takeover and a database restore both raise the epoch, so the controller that answers with the
|
|
8
|
+
* highest one is the one whose revisions count. Later controller contracts extend this shape and
|
|
9
|
+
* never define a second one.
|
|
10
|
+
*/
|
|
11
|
+
export interface IControllerPeerSet {
|
|
12
|
+
/** Fixed for the controller's life; stored at adoption. */
|
|
13
|
+
controllerId: string;
|
|
14
|
+
/** A positive safe integer; never lowered while the controller lives. */
|
|
15
|
+
epoch: number;
|
|
16
|
+
/** The canonical `https` origin of the active controller, dialled first. */
|
|
17
|
+
activeOrigin: string;
|
|
18
|
+
/** The canonical `https` origins of the shadow controllers, dialled in this order after the active one. */
|
|
19
|
+
shadowOrigins: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare const controllerPeerSetContract: Readonly<{
|
|
22
|
+
readonly maximumOriginLength: 2048;
|
|
23
|
+
readonly maximumShadowOrigins: 16;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Negative, zero or positive as the left controller position is older than, the same as or newer
|
|
27
|
+
* than the right one: the epoch decides first and the revision only within one epoch, so a higher
|
|
28
|
+
* epoch with a lower revision (after a takeover or a restore) is still newer.
|
|
29
|
+
*/
|
|
30
|
+
export declare const compareControllerRevisionOrder: (leftArg: Readonly<{
|
|
31
|
+
epoch: number;
|
|
32
|
+
revision: number;
|
|
33
|
+
}>, rightArg: Readonly<{
|
|
34
|
+
epoch: number;
|
|
35
|
+
revision: number;
|
|
36
|
+
}>) => number;
|
|
37
|
+
/**
|
|
38
|
+
* One record of the controller-wide revision sequence, written in the same transaction as the
|
|
39
|
+
* change it records. A secret appears in `changes` by its ids and versions only, never by value.
|
|
40
|
+
*/
|
|
41
|
+
export interface IControllerRevision {
|
|
42
|
+
/** A positive safe integer from the one controller-wide sequence. */
|
|
43
|
+
revision: number;
|
|
44
|
+
/** The controller epoch the revision was written in. */
|
|
45
|
+
epoch: number;
|
|
46
|
+
/** Unix milliseconds on the controller's clock. */
|
|
47
|
+
at: number;
|
|
48
|
+
actor: {
|
|
49
|
+
kind: 'person' | 'machine' | 'system';
|
|
50
|
+
/** The acting identity's subject; `null` for the controller itself (`system`). */
|
|
51
|
+
sub: string | null;
|
|
52
|
+
displayName: string;
|
|
53
|
+
};
|
|
54
|
+
kind: 'change' | 'adoption' | 'import' | 'revert';
|
|
55
|
+
changes: {
|
|
56
|
+
objectKind: string;
|
|
57
|
+
objectId: string;
|
|
58
|
+
/** The object before the change; `null` when the change created it. */
|
|
59
|
+
before: unknown;
|
|
60
|
+
/** The object after the change; `null` when the change deleted it. */
|
|
61
|
+
after: unknown;
|
|
62
|
+
}[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Validates one controller peer set and names every reason it is refused.
|
|
66
|
+
*
|
|
67
|
+
* Shape only: whether the controller id is the one a gateway stored, and whether the epoch is not
|
|
68
|
+
* older than its stored one, is the dialling component's decision against its own state.
|
|
69
|
+
*/
|
|
70
|
+
export declare const validateControllerPeerSet: (valueArg: unknown, pathArg?: string) => string[];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { validateControllerCounter, validateControllerIdentifier, validateControllerOrigin, } from '../private/controllercontract.js';
|
|
2
|
+
import { readDataElements, readExactDataRecord } from '../private/dataproperties.js';
|
|
3
|
+
export const controllerPeerSetContract = Object.freeze({
|
|
4
|
+
maximumOriginLength: 2048,
|
|
5
|
+
maximumShadowOrigins: 16,
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* Negative, zero or positive as the left controller position is older than, the same as or newer
|
|
9
|
+
* than the right one: the epoch decides first and the revision only within one epoch, so a higher
|
|
10
|
+
* epoch with a lower revision (after a takeover or a restore) is still newer.
|
|
11
|
+
*/
|
|
12
|
+
export const compareControllerRevisionOrder = (leftArg, rightArg) => Math.sign(leftArg.epoch - rightArg.epoch) || Math.sign(leftArg.revision - rightArg.revision);
|
|
13
|
+
/**
|
|
14
|
+
* Validates one controller peer set and names every reason it is refused.
|
|
15
|
+
*
|
|
16
|
+
* Shape only: whether the controller id is the one a gateway stored, and whether the epoch is not
|
|
17
|
+
* older than its stored one, is the dialling component's decision against its own state.
|
|
18
|
+
*/
|
|
19
|
+
export const validateControllerPeerSet = (valueArg, pathArg = 'controller peer set') => {
|
|
20
|
+
const record = readExactDataRecord(valueArg, ['controllerId', 'epoch', 'activeOrigin', 'shadowOrigins']);
|
|
21
|
+
if (record === null) {
|
|
22
|
+
return [`${pathArg} must use its exact schema`];
|
|
23
|
+
}
|
|
24
|
+
const { maximumOriginLength, maximumShadowOrigins } = controllerPeerSetContract;
|
|
25
|
+
const errors = [
|
|
26
|
+
...validateControllerIdentifier(record.controllerId, `${pathArg} controllerId`),
|
|
27
|
+
...validateControllerCounter(record.epoch, `${pathArg} epoch`),
|
|
28
|
+
...validateControllerOrigin(record.activeOrigin, `${pathArg} activeOrigin`, maximumOriginLength),
|
|
29
|
+
];
|
|
30
|
+
const shadowOrigins = readDataElements(record.shadowOrigins, maximumShadowOrigins);
|
|
31
|
+
if (shadowOrigins === null) {
|
|
32
|
+
errors.push(`${pathArg} shadowOrigins must be a dense list of at most ${maximumShadowOrigins} origins`);
|
|
33
|
+
return errors;
|
|
34
|
+
}
|
|
35
|
+
shadowOrigins.forEach((originArg, indexArg) => {
|
|
36
|
+
errors.push(...validateControllerOrigin(originArg, `${pathArg} shadowOrigins[${indexArg}]`, maximumOriginLength));
|
|
37
|
+
});
|
|
38
|
+
const origins = [record.activeOrigin, ...shadowOrigins];
|
|
39
|
+
if (new Set(origins).size !== origins.length) {
|
|
40
|
+
errors.push(`${pathArg} must name each origin once`);
|
|
41
|
+
}
|
|
42
|
+
return errors;
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJvbGxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3RzL2RhdGEvY29udHJvbGxlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wseUJBQXlCLEVBQ3pCLDRCQUE0QixFQUM1Qix3QkFBd0IsR0FDekIsTUFBTSxrQ0FBa0MsQ0FBQztBQUMxQyxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQXVCckYsTUFBTSxDQUFDLE1BQU0seUJBQXlCLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQztJQUNyRCxtQkFBbUIsRUFBRSxJQUFJO0lBQ3pCLG9CQUFvQixFQUFFLEVBQUU7Q0FDaEIsQ0FBQyxDQUFDO0FBRVo7Ozs7R0FJRztBQUNILE1BQU0sQ0FBQyxNQUFNLDhCQUE4QixHQUFHLENBQzVDLE9BQXNELEVBQ3RELFFBQXVELEVBQy9DLEVBQUUsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxLQUFLLEdBQUcsUUFBUSxDQUFDLEtBQUssQ0FBQyxJQUFJLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLFFBQVEsR0FBRyxRQUFRLENBQUMsUUFBUSxDQUFDLENBQUM7QUE4QjFHOzs7OztHQUtHO0FBQ0gsTUFBTSxDQUFDLE1BQU0seUJBQXlCLEdBQUcsQ0FDdkMsUUFBaUIsRUFDakIsT0FBTyxHQUFHLHFCQUFxQixFQUNyQixFQUFFO0lBQ1osTUFBTSxNQUFNLEdBQUcsbUJBQW1CLENBQUMsUUFBUSxFQUFFLENBQUMsY0FBYyxFQUFFLE9BQU8sRUFBRSxjQUFjLEVBQUUsZUFBZSxDQUFDLENBQUMsQ0FBQztJQUN6RyxJQUFJLE1BQU0sS0FBSyxJQUFJLEVBQUUsQ0FBQztRQUNwQixPQUFPLENBQUMsR0FBRyxPQUFPLDRCQUE0QixDQUFDLENBQUM7SUFDbEQsQ0FBQztJQUNELE1BQU0sRUFBRSxtQkFBbUIsRUFBRSxvQkFBb0IsRUFBRSxHQUFHLHlCQUF5QixDQUFDO0lBQ2hGLE1BQU0sTUFBTSxHQUFHO1FBQ2IsR0FBRyw0QkFBNEIsQ0FBQyxNQUFNLENBQUMsWUFBWSxFQUFFLEdBQUcsT0FBTyxlQUFlLENBQUM7UUFDL0UsR0FBRyx5QkFBeUIsQ0FBQyxNQUFNLENBQUMsS0FBSyxFQUFFLEdBQUcsT0FBTyxRQUFRLENBQUM7UUFDOUQsR0FBRyx3QkFBd0IsQ0FBQyxNQUFNLENBQUMsWUFBWSxFQUFFLEdBQUcsT0FBTyxlQUFlLEVBQUUsbUJBQW1CLENBQUM7S0FDakcsQ0FBQztJQUNGLE1BQU0sYUFBYSxHQUFHLGdCQUFnQixDQUFDLE1BQU0sQ0FBQyxhQUFhLEVBQUUsb0JBQW9CLENBQUMsQ0FBQztJQUNuRixJQUFJLGFBQWEsS0FBSyxJQUFJLEVBQUUsQ0FBQztRQUMzQixNQUFNLENBQUMsSUFBSSxDQUFDLEdBQUcsT0FBTyxrREFBa0Qsb0JBQW9CLFVBQVUsQ0FBQyxDQUFDO1FBQ3hHLE9BQU8sTUFBTSxDQUFDO0lBQ2hCLENBQUM7SUFDRCxhQUFhLENBQUMsT0FBTyxDQUFDLENBQUMsU0FBUyxFQUFFLFFBQVEsRUFBRSxFQUFFO1FBQzVDLE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyx3QkFBd0IsQ0FBQyxTQUFTLEVBQUUsR0FBRyxPQUFPLGtCQUFrQixRQUFRLEdBQUcsRUFDeEYsbUJBQW1CLENBQUMsQ0FBQyxDQUFDO0lBQzFCLENBQUMsQ0FBQyxDQUFDO0lBQ0gsTUFBTSxPQUFPLEdBQUcsQ0FBQyxNQUFNLENBQUMsWUFBWSxFQUFFLEdBQUcsYUFBYSxDQUFDLENBQUM7SUFDeEQsSUFBSSxJQUFJLEdBQUcsQ0FBQyxPQUFPLENBQUMsQ0FBQyxJQUFJLEtBQUssT0FBTyxDQUFDLE1BQU0sRUFBRSxDQUFDO1FBQzdDLE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxPQUFPLDZCQUE2QixDQUFDLENBQUM7SUFDdkQsQ0FBQztJQUNELE9BQU8sTUFBTSxDQUFDO0FBQ2hCLENBQUMsQ0FBQyJ9
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { type IControllerPeerSet } from './controller.js';
|
|
2
|
+
import type { TSha256Digest } from './immutableimage.js';
|
|
3
|
+
/**
|
|
4
|
+
* Every configuration area of a gateway, in the one order a gateway applies a desired state's
|
|
5
|
+
* areas in. Each area is one whole table with exactly one owner per gateway: the gateway itself or
|
|
6
|
+
* its controller.
|
|
7
|
+
*/
|
|
8
|
+
export declare const gatewayConfigAreaApplyOrder: readonly ["security", "dns", "routes", "mail", "edges"];
|
|
9
|
+
/** One configuration area of a gateway. */
|
|
10
|
+
export type TGatewayConfigArea = typeof gatewayConfigAreaApplyOrder[number];
|
|
11
|
+
/** True for one of `gatewayConfigAreaApplyOrder`. */
|
|
12
|
+
export declare const isGatewayConfigArea: (valueArg: unknown) => valueArg is TGatewayConfigArea;
|
|
13
|
+
export declare const gatewayConnectorContract: Readonly<{
|
|
14
|
+
/** The digest domain of `computeGatewayAreaTableDigest`. */
|
|
15
|
+
readonly areaTableDigestDomain: 'serve.zone/gateway-area-table';
|
|
16
|
+
/** A gateway pushes its status document at most once in this many milliseconds. */
|
|
17
|
+
readonly minimumStatusPushIntervalMs: 5000;
|
|
18
|
+
/** Each of `publicIps`, `proxyIps` and `forwardSourceAddresses`. */
|
|
19
|
+
readonly maximumAddresses: 64;
|
|
20
|
+
/** Ranges per transport in `IGatewayStatusDocument.listeningPorts`; a range of any width counts once. */
|
|
21
|
+
readonly maximumListeningPortRanges: 1024;
|
|
22
|
+
readonly maximumDnsZones: 1024;
|
|
23
|
+
readonly maximumHostnameLength: 253;
|
|
24
|
+
readonly maximumRefusalDetailLength: 1024;
|
|
25
|
+
readonly maximumStorageBackendLength: 64;
|
|
26
|
+
readonly maximumStoragePathLength: 4096;
|
|
27
|
+
}>;
|
|
28
|
+
/**
|
|
29
|
+
* One gateway as its controller records it.
|
|
30
|
+
*
|
|
31
|
+
* `connection` says how the two reach each other. A `legacy` gateway is the dcrouter the
|
|
32
|
+
* controller still dials at its URL as the named gateway client. An `adopted` gateway dials the
|
|
33
|
+
* controller and is never dialled, so it carries no URL.
|
|
34
|
+
*/
|
|
35
|
+
export interface IGateway {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
/** The location the gateway stands in (`data.ILocation`); every gateway stands in one. */
|
|
39
|
+
locationId: string;
|
|
40
|
+
forwardSourceAddresses: string[];
|
|
41
|
+
connection: {
|
|
42
|
+
kind: 'legacy';
|
|
43
|
+
url: string;
|
|
44
|
+
gatewayClientId: string;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'adopted';
|
|
47
|
+
/** Unix milliseconds on the controller's clock. */
|
|
48
|
+
adoptedAt: number;
|
|
49
|
+
/** The machine identity the gateway authenticates as. */
|
|
50
|
+
machineUserId: string;
|
|
51
|
+
/** Raised by every re-adoption; the previous generation is dead from then on. */
|
|
52
|
+
credentialGeneration: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/** What a gateway states about itself when it is adopted (`adoptGateway`). */
|
|
56
|
+
export interface IGatewayAdoptionFacts {
|
|
57
|
+
/** The dcrouter release the gateway runs (`data.isReleaseVersion`). */
|
|
58
|
+
dcrouterVersion: string;
|
|
59
|
+
/** The release of this package the gateway speaks (`data.isReleaseVersion`). */
|
|
60
|
+
interfacesVersion: string;
|
|
61
|
+
/** The host name of the gateway's machine: dot-separated RFC 1123 labels. */
|
|
62
|
+
hostname: string;
|
|
63
|
+
/** Canonical IPv4 or IPv6 addresses, each at most once. */
|
|
64
|
+
publicIps: string[];
|
|
65
|
+
/** Canonical IPv4 or IPv6 addresses, each at most once. */
|
|
66
|
+
proxyIps: string[];
|
|
67
|
+
/** Canonical IPv4 or IPv6 addresses, each at most once. */
|
|
68
|
+
forwardSourceAddresses: string[];
|
|
69
|
+
/**
|
|
70
|
+
* The areas this gateway can take from a controller, as a canonical token list (sorted by
|
|
71
|
+
* `compareWireTokens`, each once). A controller never pushes an area the gateway does not name.
|
|
72
|
+
*/
|
|
73
|
+
controllerAreas: TGatewayConfigArea[];
|
|
74
|
+
}
|
|
75
|
+
/** One whole area table of a desired state. */
|
|
76
|
+
export interface IGatewayAreaTable {
|
|
77
|
+
area: TGatewayConfigArea;
|
|
78
|
+
/** `computeGatewayAreaTableDigest(area, content)`. */
|
|
79
|
+
digest: TSha256Digest;
|
|
80
|
+
/**
|
|
81
|
+
* The whole table, strict canonical JSON. Untyped in this contract: each area's content type and
|
|
82
|
+
* validator ship with the release that moves that area to the controller.
|
|
83
|
+
*/
|
|
84
|
+
content: unknown;
|
|
85
|
+
/**
|
|
86
|
+
* Set on the push that moves the area from the gateway to the controller: the digest
|
|
87
|
+
* `exportGatewayArea` answered. The gateway applies it only while its local table still has that
|
|
88
|
+
* digest and refuses `local-changed-since-export` otherwise. `null` on every other push.
|
|
89
|
+
*/
|
|
90
|
+
takeover: {
|
|
91
|
+
localDigest: TSha256Digest;
|
|
92
|
+
} | null;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The whole desired state a controller pushes to one gateway (`applyDesiredState`).
|
|
96
|
+
*
|
|
97
|
+
* Documents are ordered by `(epoch, revision)` (`data.compareControllerRevisionOrder`): a newer one
|
|
98
|
+
* is applied, an equal one is an idempotent replay answered with the stored report, and an older
|
|
99
|
+
* one is refused `stale`.
|
|
100
|
+
*/
|
|
101
|
+
export interface IGatewayDesiredState {
|
|
102
|
+
gatewayId: string;
|
|
103
|
+
controllerId: string;
|
|
104
|
+
epoch: number;
|
|
105
|
+
revision: number;
|
|
106
|
+
/** One table per controller-owned area, each area at most once. */
|
|
107
|
+
areas: IGatewayAreaTable[];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Every reason a gateway refuses an area of a desired state. Each is reported per area in
|
|
111
|
+
* `IGatewayAreaApplyState.refusal`.
|
|
112
|
+
*/
|
|
113
|
+
export declare const gatewayApplyRefusals: readonly ["stale", "controller-mismatch", "invalid-table", "unsupported-area", "local-changed-since-export", "apply-failed"];
|
|
114
|
+
/** One of the reasons a gateway refuses an area of a desired state. */
|
|
115
|
+
export type TGatewayApplyRefusal = typeof gatewayApplyRefusals[number];
|
|
116
|
+
/** True for one of `gatewayApplyRefusals`. */
|
|
117
|
+
export declare const isGatewayApplyRefusal: (valueArg: unknown) => valueArg is TGatewayApplyRefusal;
|
|
118
|
+
/** Where one area of one gateway stands after the last desired state it received. */
|
|
119
|
+
export interface IGatewayAreaApplyState {
|
|
120
|
+
area: TGatewayConfigArea;
|
|
121
|
+
/** Who writes the area on this gateway. It moves to `controller` once and never back. */
|
|
122
|
+
owner: 'gateway' | 'controller';
|
|
123
|
+
/** The digest of the table the gateway serves for the area; `null` while it serves none. */
|
|
124
|
+
digest: TSha256Digest | null;
|
|
125
|
+
/** The controller revision of that table; `null` for a table no controller pushed. */
|
|
126
|
+
revision: number | null;
|
|
127
|
+
/**
|
|
128
|
+
* `applied` with no refusal; `rejected` with the refusal; `not-attempted` for an area a gateway
|
|
129
|
+
* did not reach because an earlier area of the same document was refused.
|
|
130
|
+
*/
|
|
131
|
+
state: 'applied' | 'rejected' | 'not-attempted';
|
|
132
|
+
refusal: {
|
|
133
|
+
reason: TGatewayApplyRefusal;
|
|
134
|
+
detail: string;
|
|
135
|
+
} | null;
|
|
136
|
+
}
|
|
137
|
+
/** What a gateway applied, as `applyDesiredState` answers and the status document carries it. */
|
|
138
|
+
export interface IGatewayApplyReport {
|
|
139
|
+
/** The epoch of the last document applied whole; `null` before the first. */
|
|
140
|
+
epoch: number | null;
|
|
141
|
+
/**
|
|
142
|
+
* The revision of the last document applied whole; `null` before the first. It advances only
|
|
143
|
+
* when every area of a document is applied, so a gateway applied revision N exactly when this is
|
|
144
|
+
* at least N.
|
|
145
|
+
*/
|
|
146
|
+
appliedRevision: number | null;
|
|
147
|
+
/** Each area at most once. */
|
|
148
|
+
areas: IGatewayAreaApplyState[];
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* An inclusive range of ports a gateway listens on, as a route's `match.ports` states it
|
|
152
|
+
* (SmartProxy's `{ from, to }`); one port is `{ from: port, to: port }`.
|
|
153
|
+
*/
|
|
154
|
+
export interface IGatewayPortRange {
|
|
155
|
+
/** 1 to 65535. */
|
|
156
|
+
from: number;
|
|
157
|
+
/** `from` to 65535. */
|
|
158
|
+
to: number;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Every port a gateway listens on, per socket transport; each list in the canonical range form:
|
|
162
|
+
* sorted by `from`, and each range starts at least two ports after the previous one ends, so ranges
|
|
163
|
+
* neither overlap nor touch (a gateway merges `{ 80, 80 }` and `{ 81, 81 }` into `{ 80, 81 }`), at
|
|
164
|
+
* most `gatewayConnectorContract.maximumListeningPortRanges` ranges per transport.
|
|
165
|
+
*
|
|
166
|
+
* A gateway reports every public socket it has open, not only its SmartProxy routes. dcrouter
|
|
167
|
+
* derives a route's transports as its inbound proxy listener keys do: `match.transport` `udp` is
|
|
168
|
+
* udp, `all` is both, `tcp` or absent is tcp. QUIC and HTTP/3 count under udp. Each transport is
|
|
169
|
+
* merged on its own, never across transports, so one port may appear in both lists.
|
|
170
|
+
*/
|
|
171
|
+
export interface IGatewayListeningPorts {
|
|
172
|
+
tcp: IGatewayPortRange[];
|
|
173
|
+
udp: IGatewayPortRange[];
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Everything a gateway reports about itself, in one document (`pushGatewayStatus`). It is also
|
|
177
|
+
* what the gateway's own status page and CLI read.
|
|
178
|
+
*/
|
|
179
|
+
export interface IGatewayStatusDocument {
|
|
180
|
+
gatewayId: string;
|
|
181
|
+
/** `data.isReleaseVersion`. */
|
|
182
|
+
dcrouterVersion: string;
|
|
183
|
+
/** `data.isReleaseVersion`. */
|
|
184
|
+
interfacesVersion: string;
|
|
185
|
+
/** The controller the gateway stored. */
|
|
186
|
+
controller: IControllerPeerSet;
|
|
187
|
+
/** Unix milliseconds since the current controller connection; `null` while disconnected. */
|
|
188
|
+
connectedSince: number | null;
|
|
189
|
+
applied: IGatewayApplyReport;
|
|
190
|
+
/** Unix milliseconds of the last whole apply; `null` before the first. */
|
|
191
|
+
appliedAt: number | null;
|
|
192
|
+
publicIps: string[];
|
|
193
|
+
proxyIps: string[];
|
|
194
|
+
forwardSourceAddresses: string[];
|
|
195
|
+
/** Every port the gateway listens on, per transport (`IGatewayListeningPorts`). */
|
|
196
|
+
listeningPorts: IGatewayListeningPorts;
|
|
197
|
+
storage: {
|
|
198
|
+
backend: string;
|
|
199
|
+
path: string | null;
|
|
200
|
+
};
|
|
201
|
+
/** Each zone at most once. */
|
|
202
|
+
dnsZones: {
|
|
203
|
+
zone: string;
|
|
204
|
+
recordsServed: number;
|
|
205
|
+
}[];
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The hello a gateway sends after `registerCloudlyClientSession` on its socket. The gateway is the
|
|
209
|
+
* one the verified machine identity names and is never a field here.
|
|
210
|
+
*/
|
|
211
|
+
export interface IRegisterGatewaySessionRequest {
|
|
212
|
+
/**
|
|
213
|
+
* Counts up once per attempt within one gateway process and restarts at 0 with the process; a
|
|
214
|
+
* controller refuses one that does not advance.
|
|
215
|
+
*/
|
|
216
|
+
registrationSequence: number;
|
|
217
|
+
/** `data.isReleaseVersion`. */
|
|
218
|
+
dcrouterVersion: string;
|
|
219
|
+
/** `data.isReleaseVersion`. */
|
|
220
|
+
interfacesVersion: string;
|
|
221
|
+
/** As in `IGatewayAdoptionFacts.controllerAreas`. */
|
|
222
|
+
controllerAreas: TGatewayConfigArea[];
|
|
223
|
+
/** The controller and epoch the gateway stored; `null` when it stored none. */
|
|
224
|
+
known: {
|
|
225
|
+
controllerId: string;
|
|
226
|
+
epoch: number;
|
|
227
|
+
} | null;
|
|
228
|
+
applied: IGatewayApplyReport;
|
|
229
|
+
}
|
|
230
|
+
/** One area table as the gateway holds it locally, as `exportGatewayArea` answers it. */
|
|
231
|
+
export interface IGatewayAreaExport {
|
|
232
|
+
area: TGatewayConfigArea;
|
|
233
|
+
/** `computeGatewayAreaTableDigest(area, content)`. */
|
|
234
|
+
digest: TSha256Digest;
|
|
235
|
+
content: unknown;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The canonical JSON an area table digest hashes: the digest domain, the area and the whole
|
|
239
|
+
* content. Throws for an unknown area and for content that is not strict canonical JSON (safe
|
|
240
|
+
* integers only, no `undefined`, no cycle, no accessor).
|
|
241
|
+
*/
|
|
242
|
+
export declare const createGatewayAreaTableDigestInput: (areaArg: TGatewayConfigArea, contentArg: unknown) => string;
|
|
243
|
+
/**
|
|
244
|
+
* `sha256:<hex>` of `createGatewayAreaTableDigestInput`, through Web Crypto. The controller and the
|
|
245
|
+
* gateway digest a table with this one function, so an exported local table and the controller's
|
|
246
|
+
* compiled table of the same content have the same digest.
|
|
247
|
+
*/
|
|
248
|
+
export declare const computeGatewayAreaTableDigest: (areaArg: TGatewayConfigArea, contentArg: unknown) => Promise<TSha256Digest>;
|
|
249
|
+
/**
|
|
250
|
+
* Validates one desired state and names every reason it is refused.
|
|
251
|
+
*
|
|
252
|
+
* The envelope only: every table's digest has the digest form and its content is strict canonical
|
|
253
|
+
* JSON, but whether the digest is `computeGatewayAreaTableDigest` of the content, what the content
|
|
254
|
+
* of an area must hold, and how the document orders against the one applied are the gateway's to
|
|
255
|
+
* judge (`invalid-table`, `stale`).
|
|
256
|
+
*/
|
|
257
|
+
export declare const validateGatewayDesiredState: (valueArg: unknown, pathArg?: string) => string[];
|
|
258
|
+
/** Validates one apply report and names every reason it is refused. */
|
|
259
|
+
export declare const validateGatewayApplyReport: (valueArg: unknown, pathArg?: string) => string[];
|
|
260
|
+
/** Validates the facts a gateway states at adoption and names every reason they are refused. */
|
|
261
|
+
export declare const validateGatewayAdoptionFacts: (valueArg: unknown, pathArg?: string) => string[];
|
|
262
|
+
/**
|
|
263
|
+
* Validates one status document and names every reason it is refused. A controller stores a
|
|
264
|
+
* status document only when this returns no errors.
|
|
265
|
+
*/
|
|
266
|
+
export declare const validateGatewayStatusDocument: (valueArg: unknown, pathArg?: string) => string[];
|
|
267
|
+
/**
|
|
268
|
+
* Validates one gateway session hello and names every reason it is refused.
|
|
269
|
+
*
|
|
270
|
+
* Shape only: whether the sequence advances, and whether `known` names this controller at an
|
|
271
|
+
* epoch it may hold, is the controller's to decide against the session it holds.
|
|
272
|
+
*/
|
|
273
|
+
export declare const validateRegisterGatewaySessionRequest: (valueArg: unknown, pathArg?: string) => string[];
|
|
274
|
+
/**
|
|
275
|
+
* Validates one exported area table and names every reason it is refused. Whether the digest is
|
|
276
|
+
* `computeGatewayAreaTableDigest` of the content is the controller's to check.
|
|
277
|
+
*/
|
|
278
|
+
export declare const validateGatewayAreaExport: (valueArg: unknown, pathArg?: string) => string[];
|