@serve.zone/interfaces 32.88.0 → 32.89.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/cloudaccess.d.ts +402 -0
- package/dist_ts/data/cloudaccess.js +685 -0
- package/dist_ts/data/cloudlyconfig.d.ts +20 -0
- package/dist_ts/data/cloudlyconfig.js +21 -1
- package/dist_ts/data/gatewayareas.d.ts +114 -19
- package/dist_ts/data/gatewayareas.js +36 -1
- package/dist_ts/data/gatewayareas.validation.js +178 -36
- package/dist_ts/data/gatewayconnector.d.ts +2 -2
- package/dist_ts/data/gatewayconnector.js +20 -1
- package/dist_ts/data/gatewayintent.d.ts +154 -0
- package/dist_ts/data/gatewayintent.js +61 -0
- package/dist_ts/data/index.d.ts +2 -0
- package/dist_ts/data/index.js +3 -1
- package/dist_ts/data/witness.js +4 -9
- package/dist_ts/private/bearerencoding.d.ts +9 -0
- package/dist_ts/private/bearerencoding.js +17 -0
- package/dist_ts/private/storagecontract.js +3 -3
- package/dist_ts/requests/cloudaccess.d.ts +125 -0
- package/dist_ts/requests/cloudaccess.js +2 -0
- package/dist_ts/requests/gatewayconnector.d.ts +33 -1
- package/dist_ts/requests/index.d.ts +2 -1
- package/dist_ts/requests/index.js +3 -2
- package/package.json +1 -1
- package/readme.md +146 -10
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/cloudaccess.ts +1133 -0
- package/ts/data/cloudlyconfig.ts +27 -0
- package/ts/data/gatewayareas.ts +82 -19
- package/ts/data/gatewayareas.validation.ts +192 -34
- package/ts/data/gatewayconnector.ts +19 -0
- package/ts/data/gatewayintent.ts +209 -0
- package/ts/data/index.ts +2 -0
- package/ts/data/witness.ts +3 -10
- package/ts/private/bearerencoding.ts +24 -0
- package/ts/private/storagecontract.ts +2 -2
- package/ts/requests/cloudaccess.ts +201 -0
- package/ts/requests/gatewayconnector.ts +41 -1
- package/ts/requests/index.ts +2 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* What a controller answers about the gateway intent it holds: the per-gateway, per-area tables it
|
|
3
|
+
* authored once it took a gateway over (`gatewayareas.ts`). These are the read shapes an
|
|
4
|
+
* administrator's tools and the dashboard see: a gateway's takeover state and the dry run of its
|
|
5
|
+
* takeover. The tables themselves, their revisions and how a controller compiles them are the
|
|
6
|
+
* controller's own; nothing here carries a table value.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { IControllerRevision } from './controller.js';
|
|
10
|
+
import type { TGatewayConfigArea, TGatewayConnectorMomentaryRefusal } from './gatewayconnector.js';
|
|
11
|
+
import type { TSha256Digest } from './immutableimage.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Every reason the gateway intent refuses an operation: the controller's one vocabulary, which it
|
|
15
|
+
* imports from here and keeps no copy of.
|
|
16
|
+
*
|
|
17
|
+
* The reads this package declares name only some of them: a dry run's `refusals` and the report's
|
|
18
|
+
* `code` name `gateway-not-found`, `area-contract-missing`, `export-missing`, `area-table-invalid`,
|
|
19
|
+
* `controller-origin-unserved`, `lifeline-unjudged` and `compiled-table-invalid`. The others are
|
|
20
|
+
* answered only by operations of the controller that this package declares no request for (a
|
|
21
|
+
* takeover, an operator's write of an area table, a recompile from the controller's records).
|
|
22
|
+
*
|
|
23
|
+
* A reader of these reads shows a name it does not know as text and never refuses the answer for
|
|
24
|
+
* it: the reads have no validator, and a controller built after the reader may name a newer reason.
|
|
25
|
+
*/
|
|
26
|
+
export const gatewayIntentRefusals = Object.freeze([
|
|
27
|
+
/** The registry records no such gateway. */
|
|
28
|
+
'gateway-not-found',
|
|
29
|
+
/** Only an adopted gateway can be taken over: nothing else applies a desired state. */
|
|
30
|
+
'gateway-not-adopted',
|
|
31
|
+
/** The gateway's current session does not offer every area to its controller (`controllerAreas`). */
|
|
32
|
+
'gateway-areas-not-offered',
|
|
33
|
+
/** An area has no typed content contract, so nothing can validate its tables. */
|
|
34
|
+
'area-contract-missing',
|
|
35
|
+
/** The gateway was taken over already; a takeover runs once. */
|
|
36
|
+
'gateway-taken-over',
|
|
37
|
+
/** The gateway was not taken over, so the controller holds no table of it. */
|
|
38
|
+
'gateway-not-taken-over',
|
|
39
|
+
/** An area has no exported table, or more than one. */
|
|
40
|
+
'export-missing',
|
|
41
|
+
/** A table fails its envelope, its digest, its canonical rows or its area contract. */
|
|
42
|
+
'area-table-invalid',
|
|
43
|
+
/** The compiled document differs from the exported tables, so the takeover would change the data plane. */
|
|
44
|
+
'takeover-not-pure',
|
|
45
|
+
/** The revision leaves the controller's public origin unserved on a gateway that served it. */
|
|
46
|
+
'controller-origin-unserved',
|
|
47
|
+
/** The routes table changes and no routes contract can judge the lifeline. */
|
|
48
|
+
'lifeline-unjudged',
|
|
49
|
+
/** The table moved past the revision the write was based on. */
|
|
50
|
+
'intent-revision-stale',
|
|
51
|
+
/**
|
|
52
|
+
* A compile from the controller's records cannot build a record's rows (the operation that wrote
|
|
53
|
+
* that record fails, the rest compile), or builds a table it cannot place: one its area contract
|
|
54
|
+
* refuses, or two records stating one row (the whole compile is refused).
|
|
55
|
+
*/
|
|
56
|
+
'compiled-table-invalid',
|
|
57
|
+
/** An operator write changes a row the controller's records compile. */
|
|
58
|
+
'row-compile-owned',
|
|
59
|
+
/**
|
|
60
|
+
* The write sets engine configuration for a gateway that speaks a newer release of this package
|
|
61
|
+
* than the controller, or states none it can compare: an older vocabulary could carry a value the
|
|
62
|
+
* newer one names a secret.
|
|
63
|
+
*/
|
|
64
|
+
'gateway-vocabulary-newer',
|
|
65
|
+
] as const);
|
|
66
|
+
|
|
67
|
+
/** One of the reasons the gateway intent refuses an operation. */
|
|
68
|
+
export type TGatewayIntentRefusal = typeof gatewayIntentRefusals[number];
|
|
69
|
+
|
|
70
|
+
/** The kinds of controller record whose rows a compile builds. */
|
|
71
|
+
export type TGatewayCompileRecordKind = 'service' | 'cluster-relay' | 'coremail';
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The table members a compile builds rows of from the controller's records, by their names in the
|
|
75
|
+
* area contents: `routes` (`IGatewayRoutesArea`), `clientHostnames` (`IGatewayDnsArea`), and
|
|
76
|
+
* `identities` and `coreMailPeers` (`IGatewayMailArea`).
|
|
77
|
+
*/
|
|
78
|
+
export type TGatewayCompileHeldMember = 'routes' | 'clientHostnames' | 'identities' | 'coreMailPeers';
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A controller record whose rows the compile cannot build now: its target is not determinable, a
|
|
82
|
+
* row of it does not build, or its row's id is held by a row it does not own. The table keeps
|
|
83
|
+
* exactly the rows the last compile claimed for it (a record no compile built before contributes
|
|
84
|
+
* none), the compile of every other record proceeds, and the operation that wrote this record fails
|
|
85
|
+
* `compiled-table-invalid` naming it when it answers for the member that holds it.
|
|
86
|
+
*
|
|
87
|
+
* A record is held per table member (Linus ruling 144, Q6): one entry names one record in one
|
|
88
|
+
* member, so a record held in two members has two entries, and its rows in a member that does not
|
|
89
|
+
* hold it compile. Computed by every compile and never stored, `member` included; a list of entries
|
|
90
|
+
* is sorted by kind, then id, then member, each compared in this package's wire-token order
|
|
91
|
+
* (`compareWireTokens`).
|
|
92
|
+
*/
|
|
93
|
+
export interface IGatewayCompileHeld {
|
|
94
|
+
kind: TGatewayCompileRecordKind;
|
|
95
|
+
id: string;
|
|
96
|
+
/** The table member whose rows of this record the compile cannot build now. */
|
|
97
|
+
member: TGatewayCompileHeldMember;
|
|
98
|
+
/** Why its rows cannot be built, as operator text; never a value of a row. */
|
|
99
|
+
reason: string;
|
|
100
|
+
/**
|
|
101
|
+
* The rows of it the table keeps, `<member>/<row id>`, ascending: the rows of this entry's
|
|
102
|
+
* `member` only, so the kept rows of a record held in two members are listed in two entries.
|
|
103
|
+
*/
|
|
104
|
+
keptRowIds: string[];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Which rows differ between two tables of one area, by row id only. */
|
|
108
|
+
export interface IGatewayAreaRowDiff {
|
|
109
|
+
/** In the second table only. */
|
|
110
|
+
added: string[];
|
|
111
|
+
/** In both, with another canonical form. */
|
|
112
|
+
changed: string[];
|
|
113
|
+
/** In the first table only. */
|
|
114
|
+
removed: string[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Where one area stands in a dry run: whether its tables validate and which rows the compile changes. */
|
|
118
|
+
export interface IGatewayAreaDryRun {
|
|
119
|
+
area: TGatewayConfigArea;
|
|
120
|
+
validates: boolean;
|
|
121
|
+
/** Validator sentences: members, positions, ids and digests, never a value. */
|
|
122
|
+
problems: string[];
|
|
123
|
+
/** The digest of the exported table; `null` when none was exported. */
|
|
124
|
+
exportDigest: TSha256Digest | null;
|
|
125
|
+
/** The digest of the compiled table; `null` when it could not be compiled. */
|
|
126
|
+
compiledDigest: TSha256Digest | null;
|
|
127
|
+
/** The compiled table is the exported one (same digest). */
|
|
128
|
+
emptyDiff: boolean;
|
|
129
|
+
/** From the exported table to the compiled one. */
|
|
130
|
+
rows: IGatewayAreaRowDiff;
|
|
131
|
+
/**
|
|
132
|
+
* Rows of the exported table that name the controller's bound gateway client and that no
|
|
133
|
+
* controller record claims: they are imported as operator rows. Ascending.
|
|
134
|
+
*/
|
|
135
|
+
unclaimedClientRows: string[];
|
|
136
|
+
/**
|
|
137
|
+
* The records whose rows the compile cannot build now (`IGatewayCompileHeld`), computed by this
|
|
138
|
+
* dry run. Before a takeover no row of theirs is the controller's yet, so any of them refuses the
|
|
139
|
+
* dry run `compiled-table-invalid`.
|
|
140
|
+
*/
|
|
141
|
+
held: IGatewayCompileHeld[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Whether a revision keeps the controller's public origin served: `unchanged` (the routes table is
|
|
146
|
+
* the same), `kept`, `not-served-before`, `lost` (refused `controller-origin-unserved`) or
|
|
147
|
+
* `unjudged` (no routes contract; refused `lifeline-unjudged`).
|
|
148
|
+
*/
|
|
149
|
+
export type TGatewayLifeline = 'unchanged' | 'kept' | 'not-served-before' | 'lost' | 'unjudged';
|
|
150
|
+
|
|
151
|
+
/** A dry run of one gateway's compiled document against its exported tables. */
|
|
152
|
+
export interface IGatewayIntentDryRun {
|
|
153
|
+
gatewayId: string;
|
|
154
|
+
/** The compile started from the stored intent (`true`) or from the exports as a takeover would import them. */
|
|
155
|
+
takenOver: boolean;
|
|
156
|
+
/** Five, in `gatewayConfigAreaApplyOrder`. */
|
|
157
|
+
areas: IGatewayAreaDryRun[];
|
|
158
|
+
lifeline: TGatewayLifeline;
|
|
159
|
+
/** Empty when the dry run passes. */
|
|
160
|
+
refusals: TGatewayIntentRefusal[];
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** One gateway's takeover state as the controller holds it now. */
|
|
164
|
+
export interface IGatewayTakeoverState {
|
|
165
|
+
gatewayId: string;
|
|
166
|
+
/** The controller holds the gateway's five area tables: an operator took it over. */
|
|
167
|
+
takenOver: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* The takeover's `import` revision (its tables' `importRevision`) with who made it and when, read
|
|
170
|
+
* from that revision; `null` while the gateway was not taken over.
|
|
171
|
+
*/
|
|
172
|
+
imported: {
|
|
173
|
+
revision: number;
|
|
174
|
+
/** Unix milliseconds, the revision's `at`. */
|
|
175
|
+
at: number;
|
|
176
|
+
actor: IControllerRevision['actor'];
|
|
177
|
+
} | null;
|
|
178
|
+
/**
|
|
179
|
+
* The areas the gateway's live session offers its controller (`controllerAreas` of its hello),
|
|
180
|
+
* in apply order; `null` while no socket carries the gateway. A takeover needs all five.
|
|
181
|
+
*/
|
|
182
|
+
offeredAreas: TGatewayConfigArea[] | null;
|
|
183
|
+
/**
|
|
184
|
+
* The records whose rows the compile cannot build now and whose rows the gateway's tables keep as
|
|
185
|
+
* they were (kind, id, member, reason, rows kept), computed by the compile at this read and never
|
|
186
|
+
* stored; `null` while the gateway was not taken over.
|
|
187
|
+
*/
|
|
188
|
+
held: IGatewayCompileHeld[] | null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Why the running controller answered no dry run of a gateway: a refusal of the gateway intent (the
|
|
193
|
+
* controller records no such gateway, or the gateway exported an entry that names no area), no
|
|
194
|
+
* socket carries the gateway now, so its tables cannot be exported, or the gateway kept answering an
|
|
195
|
+
* export with a momentary refusal (`local-changing-during-export`: ask again later).
|
|
196
|
+
*/
|
|
197
|
+
export type TGatewayDryRunRefusal = TGatewayIntentRefusal | 'controller-gateway-disconnected'
|
|
198
|
+
| TGatewayConnectorMomentaryRefusal;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* A gateway's dry run: per area whether the exported and compiled tables validate, their digests and
|
|
202
|
+
* the row ids that differ, the rows of the controller's client that no record claims and the records
|
|
203
|
+
* the compile holds, the lifeline, the refusals by name, and whether it passes (every area validates,
|
|
204
|
+
* every compiled table is the exported one, nothing is refused); or the refusal that left no dry
|
|
205
|
+
* run. No table value.
|
|
206
|
+
*/
|
|
207
|
+
export type TGatewayDryRunReport =
|
|
208
|
+
| { ok: true; passes: boolean; dryRun: IGatewayIntentDryRun }
|
|
209
|
+
| { ok: false; code: TGatewayDryRunRefusal };
|
package/ts/data/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './cloudaccess.js';
|
|
1
2
|
export * from './cloudlyconfig.js';
|
|
2
3
|
export * from './cluster.js';
|
|
3
4
|
export * from './clusterruntime.js';
|
|
@@ -31,6 +32,7 @@ export * from './gateway.js';
|
|
|
31
32
|
export * from './gatewayareas.js';
|
|
32
33
|
export * from './gatewayareas.validation.js';
|
|
33
34
|
export * from './gatewayconnector.js';
|
|
35
|
+
export * from './gatewayintent.js';
|
|
34
36
|
export * from './hostedapp.js';
|
|
35
37
|
export * from './image.js';
|
|
36
38
|
export * from './immutableimage.js';
|
package/ts/data/witness.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
validateControllerOrigin,
|
|
6
6
|
} from '../private/controllercontract.js';
|
|
7
7
|
import { readDataElements, readExactDataRecord } from '../private/dataproperties.js';
|
|
8
|
+
import { isCanonicalBase64url32, isSha256Hex } from '../private/bearerencoding.js';
|
|
8
9
|
import type { TCompleteKeyList } from '../private/keylist.js';
|
|
9
10
|
import { controllerPeerSetContract } from './controller.js';
|
|
10
11
|
import { isReleaseVersion } from './releaseversion.js';
|
|
@@ -425,23 +426,15 @@ const validateOrigin = (valueArg: unknown, pathArg: string): string[] => (
|
|
|
425
426
|
validateControllerOrigin(valueArg, pathArg, witnessContract.maximumOriginLength)
|
|
426
427
|
);
|
|
427
428
|
|
|
428
|
-
/**
|
|
429
|
-
* The canonical unpadded base64url of 32 bytes: 42 characters of six bits each and a last one that
|
|
430
|
-
* carries the remaining four bits, so its two low bits are zero.
|
|
431
|
-
*/
|
|
432
|
-
const bearerPattern = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
|
|
433
|
-
|
|
434
429
|
/** A bearer as `IWitnessMemberCredential.bearer` states it; the refusal names the field, never the value. */
|
|
435
430
|
const validateBearer = (valueArg: unknown, pathArg: string): string[] => (
|
|
436
|
-
|
|
431
|
+
isCanonicalBase64url32(valueArg)
|
|
437
432
|
? []
|
|
438
433
|
: [`${pathArg} must be the base64url of ${witnessContract.bearerRandomBytes} random bytes: 43 characters`]
|
|
439
434
|
);
|
|
440
435
|
|
|
441
|
-
const sha256Pattern = /^[0-9a-f]{64}$/;
|
|
442
|
-
|
|
443
436
|
const validateBearerSha256 = (valueArg: unknown, pathArg: string): string[] => (
|
|
444
|
-
|
|
437
|
+
isSha256Hex(valueArg)
|
|
445
438
|
? []
|
|
446
439
|
: [`${pathArg} must be a SHA-256 digest of 64 lowercase hex characters`]
|
|
447
440
|
);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The text encodings of the random bearers and tokens and of the digests the contracts exchange,
|
|
3
|
+
* stated once so their validators cannot drift apart (Linus amendment 141a). Each call site keeps
|
|
4
|
+
* its own refusal sentence.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The canonical unpadded base64url of 32 bytes: 42 characters of six bits each and a last one that
|
|
9
|
+
* carries the remaining four bits, so its two low bits are zero.
|
|
10
|
+
*/
|
|
11
|
+
const canonicalBase64url32Pattern = /^[A-Za-z0-9_-]{42}[AEIMQUYcgkosw048]$/;
|
|
12
|
+
|
|
13
|
+
/** A SHA-256 digest as 64 lowercase hex characters. */
|
|
14
|
+
const sha256HexPattern = /^[0-9a-f]{64}$/;
|
|
15
|
+
|
|
16
|
+
/** True for the canonical unpadded base64url of 32 bytes: exactly 43 characters. */
|
|
17
|
+
export const isCanonicalBase64url32 = (valueArg: unknown): valueArg is string => (
|
|
18
|
+
typeof valueArg === 'string' && canonicalBase64url32Pattern.test(valueArg)
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
/** True for a SHA-256 digest as 64 lowercase hex characters. */
|
|
22
|
+
export const isSha256Hex = (valueArg: unknown): valueArg is string => (
|
|
23
|
+
typeof valueArg === 'string' && sha256HexPattern.test(valueArg)
|
|
24
|
+
);
|
|
@@ -15,6 +15,7 @@ import type {
|
|
|
15
15
|
} from '../appstore/types.js';
|
|
16
16
|
import { normalizeServiceAbsolutePath } from '../data/service.js';
|
|
17
17
|
import type { TObjectStorageDelivery } from '../platform/storage.js';
|
|
18
|
+
import { isSha256Hex } from './bearerencoding.js';
|
|
18
19
|
import type { TCanonicalJsonFailure } from './canonicaljson.js';
|
|
19
20
|
|
|
20
21
|
/** Byte bounds every reader of a storage control string applies. */
|
|
@@ -26,7 +27,6 @@ export const storageContractStringLimits = Object.freeze({
|
|
|
26
27
|
|
|
27
28
|
const canonicalIdPattern = /^[A-Za-z0-9][A-Za-z0-9._:@-]{0,191}$/;
|
|
28
29
|
const environmentKeyPattern = /^[A-Z_][A-Z0-9_]{0,255}$/;
|
|
29
|
-
const sha256Pattern = /^[a-f0-9]{64}$/;
|
|
30
30
|
const capacityPattern = /^[1-9][0-9]*(?:KiB|MiB|GiB|TiB)$/;
|
|
31
31
|
/**
|
|
32
32
|
* The mount a Secret file is delivered under. A filesystem request that mounts it, or anything
|
|
@@ -181,7 +181,7 @@ export const createStorageContractReaders = (failArg: TCanonicalJsonFailure) =>
|
|
|
181
181
|
};
|
|
182
182
|
|
|
183
183
|
const readSha256 = (valueArg: unknown, fieldNameArg: string): string => {
|
|
184
|
-
if (
|
|
184
|
+
if (!isSha256Hex(valueArg)) {
|
|
185
185
|
return failArg(`${fieldNameArg} must be a bare lowercase 64-hex SHA-256 digest`);
|
|
186
186
|
}
|
|
187
187
|
return valueArg;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import * as plugins from '../plugins.js';
|
|
2
|
+
import type {
|
|
3
|
+
IAuthenticateCloudAccessBindingRequest,
|
|
4
|
+
ICloudAccessBindingState,
|
|
5
|
+
ICloudAccessEnrollment,
|
|
6
|
+
ICloudAccessEnrollmentHandle,
|
|
7
|
+
ICloudAccessEnrollmentState,
|
|
8
|
+
ICloudAccessReport,
|
|
9
|
+
IEnrollCloudAccessBindingRequest,
|
|
10
|
+
IGetCloudAccessBindingStateRequest,
|
|
11
|
+
IOpenCloudAccessStreamRequest,
|
|
12
|
+
IRegisterCloudAccessSessionRequest,
|
|
13
|
+
IRegisterCloudAccessSessionResponse,
|
|
14
|
+
} from '../data/cloudaccess.js';
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* Cloud access (AGL-1181, Linus ruling 141 C3, C5 and C6, amendment 141a). Cloudly dials one
|
|
18
|
+
* typedsocket to cloud access (`wss://cloudaccess.serve.zone`, WebPKI with Node's defaults) and
|
|
19
|
+
* sends the `Cloudly_CloudAccess` requests over it. Cloud access sends exactly one request back over
|
|
20
|
+
* that socket, `CloudAccess_Cloudly` `openCloudAccessStream`, and Cloudly serves it on a dedicated
|
|
21
|
+
* TypedRouter that registers that one handler and nothing else.
|
|
22
|
+
*
|
|
23
|
+
* Either side refuses a request by one of `data.cloudAccessRefusals`, as a `TypedResponseError`
|
|
24
|
+
* whose `errorData` is `data.ICloudAccessRefusalErrorData` (`data.readCloudAccessRefusalErrorData`).
|
|
25
|
+
* Every request is checked against its validator first (`request-invalid`).
|
|
26
|
+
* `registerCloudAccessSession` needs a socket that authenticated, and `reportCloudAccessStatus`,
|
|
27
|
+
* `getCloudAccessBindingState` and `disconnectCloudAccessBinding` one that also registered its
|
|
28
|
+
* session (`handshake-incomplete`); they are refused `binding-gone` once the binding was deleted.
|
|
29
|
+
* `authenticateCloudAccessBinding` carries the bearer and `openCloudAccessStream` a stream token:
|
|
30
|
+
* exclude both bodies from logs.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Cloudly enrolls on an unauthenticated socket (C3 step 1) with the SHA-256 of the bearer it
|
|
35
|
+
* created and keeps in its secret store. Cloud access assigns a random `bindingId` and a pairing
|
|
36
|
+
* code; the enrollment lives on this socket and ends when the socket closes or at `expiresAt`.
|
|
37
|
+
* Refused `rate-limited` (10 per address per hour, 10,000 open in all).
|
|
38
|
+
*/
|
|
39
|
+
export interface IReq_Cloudly_CloudAccess_EnrollCloudAccessBinding extends plugins.typedrequestInterfaces.implementsTR<
|
|
40
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
41
|
+
IReq_Cloudly_CloudAccess_EnrollCloudAccessBinding
|
|
42
|
+
> {
|
|
43
|
+
method: 'enrollCloudAccessBinding';
|
|
44
|
+
/** `data.validateEnrollCloudAccessBindingRequest`. */
|
|
45
|
+
request: IEnrollCloudAccessBindingRequest;
|
|
46
|
+
/** `data.validateCloudAccessEnrollment`; Cloudly checks it before it shows the code. */
|
|
47
|
+
response: ICloudAccessEnrollment;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Cloudly's Settings, still open on the code, polls whether a person entered it (C3 step 4). Only
|
|
52
|
+
* on the enrolling socket; refused `enrollment-gone` once the enrollment ended.
|
|
53
|
+
*/
|
|
54
|
+
export interface IReq_Cloudly_CloudAccess_GetCloudAccessEnrollmentState
|
|
55
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
56
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
57
|
+
IReq_Cloudly_CloudAccess_GetCloudAccessEnrollmentState
|
|
58
|
+
> {
|
|
59
|
+
method: 'getCloudAccessEnrollmentState';
|
|
60
|
+
/** `data.validateCloudAccessEnrollmentHandle`. */
|
|
61
|
+
request: ICloudAccessEnrollmentHandle;
|
|
62
|
+
/** `data.validateCloudAccessEnrollmentState`. */
|
|
63
|
+
response: ICloudAccessEnrollmentState;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The controller's Administrator confirms the pending claim Cloudly showed, which activates the
|
|
68
|
+
* binding for the claimed organization and ends the enrollment. Only on the enrolling socket.
|
|
69
|
+
* Refused `not-claimed` while nobody has entered the code, `enrollment-gone` once it ended. A
|
|
70
|
+
* caller whose answer was lost authenticates with its bearer: that succeeds once the confirmation
|
|
71
|
+
* was stored and is refused `not-confirmed` or `binding-gone` otherwise.
|
|
72
|
+
*/
|
|
73
|
+
export interface IReq_Cloudly_CloudAccess_ConfirmCloudAccessEnrollment
|
|
74
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
75
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
76
|
+
IReq_Cloudly_CloudAccess_ConfirmCloudAccessEnrollment
|
|
77
|
+
> {
|
|
78
|
+
method: 'confirmCloudAccessEnrollment';
|
|
79
|
+
/** `data.validateCloudAccessEnrollmentHandle`. */
|
|
80
|
+
request: ICloudAccessEnrollmentHandle;
|
|
81
|
+
response: {};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The controller's Administrator rejects the pending claim, or ends an enrollment nobody claimed
|
|
86
|
+
* yet: the enrollment and its code end, and no binding remains. Only on the enrolling socket;
|
|
87
|
+
* refused `enrollment-gone` once it ended.
|
|
88
|
+
*/
|
|
89
|
+
export interface IReq_Cloudly_CloudAccess_RejectCloudAccessEnrollment
|
|
90
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
91
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
92
|
+
IReq_Cloudly_CloudAccess_RejectCloudAccessEnrollment
|
|
93
|
+
> {
|
|
94
|
+
method: 'rejectCloudAccessEnrollment';
|
|
95
|
+
/** `data.validateCloudAccessEnrollmentHandle`. */
|
|
96
|
+
request: ICloudAccessEnrollmentHandle;
|
|
97
|
+
response: {};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Cloudly presents its bearer on every new socket (C3 step 5). Cloud access compares its SHA-256
|
|
102
|
+
* with the binding's in constant time and tags the socket with the binding, server-side. Refused
|
|
103
|
+
* `binding-gone` (no binding authenticates with this id and bearer) and `not-confirmed` (the
|
|
104
|
+
* bearer is right but the claim is not confirmed yet). Exclude the body from logs.
|
|
105
|
+
*/
|
|
106
|
+
export interface IReq_Cloudly_CloudAccess_AuthenticateCloudAccessBinding
|
|
107
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
108
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
109
|
+
IReq_Cloudly_CloudAccess_AuthenticateCloudAccessBinding
|
|
110
|
+
> {
|
|
111
|
+
method: 'authenticateCloudAccessBinding';
|
|
112
|
+
/** `data.validateAuthenticateCloudAccessBindingRequest`; no refusal carries the bearer. */
|
|
113
|
+
request: IAuthenticateCloudAccessBindingRequest;
|
|
114
|
+
response: {};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The session registration after `authenticateCloudAccessBinding`: which site this socket is, the
|
|
119
|
+
* epoch it holds and the releases it runs and speaks. Every site of a controller dials, the shadow
|
|
120
|
+
* too. Only the live socket that registered `active: true` with the highest epoch is counted: its
|
|
121
|
+
* reports count and it alone receives `openCloudAccessStream`. Two live sockets registered
|
|
122
|
+
* `active: true` with the same epoch route nothing (`epoch-conflict` on `reportCloudAccessStatus`).
|
|
123
|
+
*/
|
|
124
|
+
export interface IReq_Cloudly_CloudAccess_RegisterCloudAccessSession
|
|
125
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
126
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
127
|
+
IReq_Cloudly_CloudAccess_RegisterCloudAccessSession
|
|
128
|
+
> {
|
|
129
|
+
method: 'registerCloudAccessSession';
|
|
130
|
+
/** `data.validateRegisterCloudAccessSessionRequest`. */
|
|
131
|
+
request: IRegisterCloudAccessSessionRequest;
|
|
132
|
+
/** `data.validateRegisterCloudAccessSessionResponse`. */
|
|
133
|
+
response: IRegisterCloudAccessSessionResponse;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The counted socket reports every `data.cloudAccessContract.reportIntervalMs`. Refused
|
|
138
|
+
* `report-too-large` above `data.cloudAccessContract.maximumReportBytes`, `report-too-soon` sooner
|
|
139
|
+
* than `minimumReportIntervalMs` after the last accepted one, `not-active` from a socket that is
|
|
140
|
+
* not counted, and `epoch-conflict` while two sockets claim one epoch.
|
|
141
|
+
*/
|
|
142
|
+
export interface IReq_Cloudly_CloudAccess_ReportCloudAccessStatus extends plugins.typedrequestInterfaces.implementsTR<
|
|
143
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
144
|
+
IReq_Cloudly_CloudAccess_ReportCloudAccessStatus
|
|
145
|
+
> {
|
|
146
|
+
method: 'reportCloudAccessStatus';
|
|
147
|
+
request: {
|
|
148
|
+
/** `data.validateCloudAccessReport`. */
|
|
149
|
+
report: ICloudAccessReport;
|
|
150
|
+
};
|
|
151
|
+
response: {};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The binding's hostname proof and route, and the records to publish, for Cloudly's Settings.
|
|
156
|
+
* `recheck` runs the proof first (refused `rate-limited` when asked too often).
|
|
157
|
+
*/
|
|
158
|
+
export interface IReq_Cloudly_CloudAccess_GetCloudAccessBindingState
|
|
159
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
160
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
161
|
+
IReq_Cloudly_CloudAccess_GetCloudAccessBindingState
|
|
162
|
+
> {
|
|
163
|
+
method: 'getCloudAccessBindingState';
|
|
164
|
+
/** `data.validateGetCloudAccessBindingStateRequest`. */
|
|
165
|
+
request: IGetCloudAccessBindingStateRequest;
|
|
166
|
+
/** `data.validateCloudAccessBindingState`. */
|
|
167
|
+
response: ICloudAccessBindingState;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Cloudly ends its binding (C3 step 7): cloud access deletes it, drops the bearer hash and the
|
|
172
|
+
* verified name, and closes the binding's sockets. Cloudly deletes its bearer whether or not this
|
|
173
|
+
* answer arrives, so stopping works offline.
|
|
174
|
+
*/
|
|
175
|
+
export interface IReq_Cloudly_CloudAccess_DisconnectCloudAccessBinding
|
|
176
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
177
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
178
|
+
IReq_Cloudly_CloudAccess_DisconnectCloudAccessBinding
|
|
179
|
+
> {
|
|
180
|
+
method: 'disconnectCloudAccessBinding';
|
|
181
|
+
request: {};
|
|
182
|
+
response: {};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The one request cloud access sends (C6): a browser opened a connection to the binding's verified
|
|
187
|
+
* name. Cloudly's connector opens a TLS connection to `tunnel.cloudaccess.serve.zone`, verified by
|
|
188
|
+
* WebPKI, writes the preamble (`data.cloudAccessTunnelPreamble`, carrying `token`) only after that
|
|
189
|
+
* handshake verified, connects the host's relay ingress and splices bytes. It names no target, and
|
|
190
|
+
* the connector never dials an address taken from it. Cloudly refuses `not-active` on a socket of a
|
|
191
|
+
* site that is not active and `stream-limit` over its own limits. Exclude the body from logs.
|
|
192
|
+
*/
|
|
193
|
+
export interface IReq_CloudAccess_Cloudly_OpenCloudAccessStream extends plugins.typedrequestInterfaces.implementsTR<
|
|
194
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
195
|
+
IReq_CloudAccess_Cloudly_OpenCloudAccessStream
|
|
196
|
+
> {
|
|
197
|
+
method: 'openCloudAccessStream';
|
|
198
|
+
/** `data.validateOpenCloudAccessStreamRequest`; no refusal carries the token. */
|
|
199
|
+
request: IOpenCloudAccessStreamRequest;
|
|
200
|
+
response: {};
|
|
201
|
+
}
|
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
IRegisterGatewaySessionRequest,
|
|
12
12
|
TGatewayConfigArea,
|
|
13
13
|
} from '../data/gatewayconnector.js';
|
|
14
|
+
import type { IGatewayTakeoverState, TGatewayDryRunReport } from '../data/gatewayintent.js';
|
|
14
15
|
import type { IGatewayRouteDnsResult } from '../data/gateway.js';
|
|
15
16
|
import type { ILocationScope } from '../data/location.js';
|
|
16
17
|
import type { IIdentityCredential } from '../data/user.js';
|
|
@@ -140,7 +141,8 @@ export interface IReq_Cloudly_Gateway_ExportGatewayArea extends plugins.typedreq
|
|
|
140
141
|
* desired state, and `null` when that pass ran against a routes table no controller pushed or when
|
|
141
142
|
* no pass has observed one of the requested hostnames yet (Linus ruling 125, Q-b2; such a hostname
|
|
142
143
|
* answers the retryable `zone-unavailable`). A request that fails
|
|
143
|
-
* `data.validateGatewayRouteDnsResultsRequest` is refused `request-invalid
|
|
144
|
+
* `data.validateGatewayRouteDnsResultsRequest` is refused `request-invalid`, and a gateway that runs
|
|
145
|
+
* no route DNS reconciler now answers the momentary `route-dns-unavailable`. The controller judges
|
|
144
146
|
* every answer with `data.validateGatewayRouteDnsResultsResponse` before it acts on it, and one text
|
|
145
147
|
* over `data.gatewayRouteDnsResultContract.maximumTextLength` refuses the whole answer: the gateway
|
|
146
148
|
* shortens every text (a provider's error in `message`, for example) to that bound before it answers.
|
|
@@ -217,3 +219,41 @@ export interface IReq_Admin_Cloudly_GetGateways extends plugins.typedrequestInte
|
|
|
217
219
|
appliedLocationScope?: ILocationScope;
|
|
218
220
|
};
|
|
219
221
|
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* An administrator reads one gateway's takeover state: whether the controller took it over, the
|
|
225
|
+
* areas its live session offers and the records its compile holds. A gateway the controller does not
|
|
226
|
+
* record is refused `gateway-not-found`.
|
|
227
|
+
*/
|
|
228
|
+
export interface IReq_Admin_Cloudly_GetGatewayTakeoverState extends plugins.typedrequestInterfaces.implementsTR<
|
|
229
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
230
|
+
IReq_Admin_Cloudly_GetGatewayTakeoverState
|
|
231
|
+
> {
|
|
232
|
+
method: 'getGatewayTakeoverState';
|
|
233
|
+
request: {
|
|
234
|
+
identity: IIdentityCredential;
|
|
235
|
+
gatewayId: string;
|
|
236
|
+
};
|
|
237
|
+
response: {
|
|
238
|
+
state: IGatewayTakeoverState;
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* An administrator asks the running controller, the process that would take the gateway over, for
|
|
244
|
+
* the dry run of the tables the gateway's socket exports now against the document compiled from the
|
|
245
|
+
* controller's records. It reads only: no revision, table or claim is written, and nothing is pushed.
|
|
246
|
+
*/
|
|
247
|
+
export interface IReq_Admin_Cloudly_GetGatewayDryRun extends plugins.typedrequestInterfaces.implementsTR<
|
|
248
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
249
|
+
IReq_Admin_Cloudly_GetGatewayDryRun
|
|
250
|
+
> {
|
|
251
|
+
method: 'getGatewayDryRun';
|
|
252
|
+
request: {
|
|
253
|
+
identity: IIdentityCredential;
|
|
254
|
+
gatewayId: string;
|
|
255
|
+
};
|
|
256
|
+
response: {
|
|
257
|
+
report: TGatewayDryRunReport;
|
|
258
|
+
};
|
|
259
|
+
}
|
package/ts/requests/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import * as baremetalRequests from './baremetal.js';
|
|
|
6
6
|
import * as baseOsRequests from './baseos.js';
|
|
7
7
|
import * as backupRequests from './backup.js';
|
|
8
8
|
import * as certificateRequests from './certificate.js';
|
|
9
|
+
import * as cloudAccessRequests from './cloudaccess.js';
|
|
9
10
|
import * as clusterRequests from './cluster.js';
|
|
10
11
|
import * as clusterIngressRequests from './clusteringress.js';
|
|
11
12
|
import * as configRequests from './config.js';
|
|
@@ -51,6 +52,7 @@ export {
|
|
|
51
52
|
baseOsRequests as baseos,
|
|
52
53
|
backupRequests as backup,
|
|
53
54
|
certificateRequests as certificate,
|
|
55
|
+
cloudAccessRequests as cloudaccess,
|
|
54
56
|
clusterRequests as cluster,
|
|
55
57
|
clusterIngressRequests as clusteringress,
|
|
56
58
|
configRequests as config,
|