@serve.zone/interfaces 32.118.0 → 32.120.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 +12 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/cloudlyconfig.d.ts +5 -5
- package/dist_ts/data/cloudlyconfig.js +38 -123
- package/dist_ts/data/cloudlyhostcontract.d.ts +141 -0
- package/dist_ts/data/cloudlyhostcontract.js +179 -0
- package/dist_ts/data/hostedapp.d.ts +3 -0
- package/dist_ts/data/hostedapp.js +2 -2
- package/dist_ts/data/index.d.ts +1 -0
- package/dist_ts/data/index.js +2 -1
- package/dist_ts/data/nodeaction.js +2 -2
- package/dist_ts/runtime.workloadinit.d.ts +11 -5
- package/dist_ts/runtime.workloadinit.js +29 -8
- package/package.json +4 -4
- package/readme.md +19 -12
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/cloudlyconfig.ts +42 -122
- package/ts/data/cloudlyhostcontract.ts +209 -0
- package/ts/data/hostedapp.ts +5 -1
- package/ts/data/index.ts +1 -0
- package/ts/data/nodeaction.ts +1 -1
- package/ts/runtime.workloadinit.ts +41 -12
package/ts/data/cloudlyconfig.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import * as plugins from '../plugins.js';
|
|
2
|
-
import {
|
|
1
|
+
import type * as plugins from '../plugins.js';
|
|
2
|
+
import {
|
|
3
|
+
cloudlyHostContractOptionalEnvVars as optionalEnv,
|
|
4
|
+
cloudlyHostContractRequiredEnvVars as requiredEnv,
|
|
5
|
+
cloudlyHostExtraCapabilities,
|
|
6
|
+
} from './cloudlyhostcontract.js';
|
|
3
7
|
|
|
4
8
|
export interface ICloudlyConfig {
|
|
5
9
|
environment?: 'production' | 'integration';
|
|
@@ -46,43 +50,19 @@ export interface ICloudlyConfig {
|
|
|
46
50
|
|
|
47
51
|
/**
|
|
48
52
|
* The environment a host must give the Cloudly server: Cloudly refuses to start when one of these
|
|
49
|
-
* is missing, naming every missing variable (its `qenv.yml` required list).
|
|
50
|
-
*
|
|
53
|
+
* is missing, naming every missing variable (its `qenv.yml` required list). Retains the published
|
|
54
|
+
* tuple shape. The named constants live in `cloudlyHostContractRequiredEnvVars`.
|
|
51
55
|
*/
|
|
52
56
|
export const cloudlyHostRequiredEnvironment = Object.freeze([
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* `host[:port]`.
|
|
63
|
-
*/
|
|
64
|
-
'SERVEZONE_PUBLIC_ORIGIN',
|
|
65
|
-
/**
|
|
66
|
-
* `external` (TLS is terminated in front of Cloudly) or `none`. Cloudly terminates no TLS itself.
|
|
67
|
-
*/
|
|
68
|
-
'SERVEZONE_SSLMODE',
|
|
69
|
-
/**
|
|
70
|
-
* The path of the secret keyring file. The host delivers it as a private file: a regular file
|
|
71
|
-
* that is not a symlink, has one hard link, is owned by the process user and grants no group or
|
|
72
|
-
* other permission, in a directory owned by that user that neither group nor others may write.
|
|
73
|
-
* This is the host's obligation; the Cloudly server does not check it yet.
|
|
74
|
-
*/
|
|
75
|
-
'SERVEZONE_SECRET_KEYRING_PATH',
|
|
76
|
-
/** The MongoDB connection URL of Cloudly's database. */
|
|
77
|
-
'MONGODB_URL',
|
|
78
|
-
/** The S3 endpoint of Cloudly's object storage. */
|
|
79
|
-
'S3_ENDPOINT',
|
|
80
|
-
/** The S3 access key. */
|
|
81
|
-
'S3_ACCESSKEY',
|
|
82
|
-
/** The S3 secret key. */
|
|
83
|
-
'S3_SECRETKEY',
|
|
84
|
-
/** The bucket Cloudly keeps its objects in; Cloudly creates it when it does not exist. */
|
|
85
|
-
'S3_BUCKET',
|
|
57
|
+
requiredEnv.environment,
|
|
58
|
+
requiredEnv.publicOrigin,
|
|
59
|
+
requiredEnv.sslMode,
|
|
60
|
+
requiredEnv.secretKeyringPath,
|
|
61
|
+
requiredEnv.mongoDbUrl,
|
|
62
|
+
requiredEnv.s3Endpoint,
|
|
63
|
+
requiredEnv.s3AccessKey,
|
|
64
|
+
requiredEnv.s3SecretKey,
|
|
65
|
+
requiredEnv.s3Bucket,
|
|
86
66
|
] as const);
|
|
87
67
|
|
|
88
68
|
/** One variable a host must give the Cloudly server. */
|
|
@@ -95,11 +75,11 @@ export type TCloudlyHostRequiredEnvironmentName = typeof cloudlyHostRequiredEnvi
|
|
|
95
75
|
* `SERVEZONE_PUBLIC_ORIGIN`, and the audience equals the client ID.
|
|
96
76
|
*/
|
|
97
77
|
export const cloudlyHostPlatformOidcEnvironment = Object.freeze([
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
78
|
+
optionalEnv.platformOidcIssuer,
|
|
79
|
+
optionalEnv.platformOidcClientId,
|
|
80
|
+
optionalEnv.platformOidcClientSecret,
|
|
81
|
+
optionalEnv.platformOidcRedirectUri,
|
|
82
|
+
optionalEnv.platformOidcAudience,
|
|
103
83
|
] as const);
|
|
104
84
|
|
|
105
85
|
/** One variable of the platform OIDC sign-in group. */
|
|
@@ -107,90 +87,32 @@ export type TCloudlyHostPlatformOidcEnvironmentName =
|
|
|
107
87
|
typeof cloudlyHostPlatformOidcEnvironment[number];
|
|
108
88
|
|
|
109
89
|
/**
|
|
110
|
-
* The environment the Cloudly server reads but starts without.
|
|
111
|
-
*
|
|
90
|
+
* The environment the Cloudly server reads but starts without. Retains the published tuple
|
|
91
|
+
* shape. The named constants live in `cloudlyHostContractOptionalEnvVars`.
|
|
112
92
|
*
|
|
113
93
|
* Two more names are deliberately outside the contract: `SERVEZONE_ADMINACCOUNT` is deprecated
|
|
114
94
|
* (`ICloudlyConfig.servezoneAdminaccount`) and read until Cloudly 34.0.0, and
|
|
115
95
|
* `SERVEZONE_INSTALL_DEMO_DATA` installs destructive demo data, so a host never sets either.
|
|
116
96
|
*/
|
|
117
97
|
export const cloudlyHostOptionalEnvironment = Object.freeze([
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
'MONGODB_NAME',
|
|
128
|
-
/** Optional member of the Mongo descriptor (user). */
|
|
129
|
-
'MONGODB_USER',
|
|
130
|
-
/** Optional member of the Mongo descriptor (password). */
|
|
131
|
-
'MONGODB_PASS',
|
|
132
|
-
/** The S3 port. This contract states no default. */
|
|
133
|
-
'S3_PORT',
|
|
134
|
-
/** Whether S3 is reached over TLS (`true` or `false`). This contract states no default. */
|
|
135
|
-
'S3_USESSL',
|
|
136
|
-
/**
|
|
137
|
-
* The host channel of a hosted Cloudly, together with `SERVEZONE_APP_CONTROL_TOKEN`
|
|
138
|
-
* (`hostedAppRuntimeIdentityKeys`). Cloudly counts as hosted only while both are set.
|
|
139
|
-
*/
|
|
140
|
-
hostedAppRuntimeIdentityKeys.runtimeUrl,
|
|
141
|
-
/** The host's machine JWT for the host channel, delivered as a secret. */
|
|
142
|
-
hostedAppRuntimeIdentityKeys.controlToken,
|
|
98
|
+
optionalEnv.listenPort,
|
|
99
|
+
optionalEnv.workloadInitApprovalPath,
|
|
100
|
+
optionalEnv.mongoDbName,
|
|
101
|
+
optionalEnv.mongoDbUser,
|
|
102
|
+
optionalEnv.mongoDbPass,
|
|
103
|
+
optionalEnv.s3Port,
|
|
104
|
+
optionalEnv.s3UseSsl,
|
|
105
|
+
optionalEnv.runtimeUrl,
|
|
106
|
+
optionalEnv.controlToken,
|
|
143
107
|
...cloudlyHostPlatformOidcEnvironment,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
'CLOUDLY_BASEOS_IMAGE_CLEANUP_INTERVAL_MS',
|
|
153
|
-
/**
|
|
154
|
-
* This controller site's own origin (Linus rulings 69 Q3 and 79 Q1): a canonical `https` origin
|
|
155
|
-
* (`data.validateControllerOrigin`), the `IControllerPeerSet.activeOrigin` this site states while
|
|
156
|
-
* it is active and the origin the witness names it by. While unset, the site counts as
|
|
157
|
-
* `SERVEZONE_PUBLIC_ORIGIN`, but only while the controller row lists no shadow; once it lists one,
|
|
158
|
-
* a start refuses an unset value or one equal to `SERVEZONE_PUBLIC_ORIGIN`. A fact about this one
|
|
159
|
-
* site, never stored in the replicated controller database.
|
|
160
|
-
*/
|
|
161
|
-
'SERVEZONE_SITE_ORIGIN',
|
|
162
|
-
/**
|
|
163
|
-
* The canonical `https` origin of the witness this site reads (`requests.witness`). Set together
|
|
164
|
-
* with `SERVEZONE_WITNESS_BEARER_PATH` or not at all: a start with only one of them is refused,
|
|
165
|
-
* naming the one that is unset. Required once the controller row lists another site as a shadow.
|
|
166
|
-
*/
|
|
167
|
-
'SERVEZONE_WITNESS_ORIGIN',
|
|
168
|
-
/**
|
|
169
|
-
* The path of this site's witness bearer, a private file under the rules of the secret keyring
|
|
170
|
-
* (`SERVEZONE_SECRET_KEYRING_PATH`) holding the 43-character base64url of 32 random bytes
|
|
171
|
-
* (`data.witnessContract.bearerRandomBytes`). The host creates it; Cloudly only reads it and
|
|
172
|
-
* hashes it, never writes or logs it. Set together with `SERVEZONE_WITNESS_ORIGIN` or not at all.
|
|
173
|
-
*/
|
|
174
|
-
'SERVEZONE_WITNESS_BEARER_PATH',
|
|
175
|
-
/**
|
|
176
|
-
* The port of Cloudly's relayed listener (Linus ruling 141 C7), a second port beside
|
|
177
|
-
* `SERVEZONE_LISTENPORT` that the host's relay ingress forwards to, and only to. Relayedness is
|
|
178
|
-
* the accepting listener, so this port serves the human surface only: the UI, human sign-in and
|
|
179
|
-
* human typed requests, never machine endpoints or Destroy. This contract states no default. A
|
|
180
|
-
* host that advertises `relayIngress` (`cloudlyHostExtras`) sets it together with
|
|
181
|
-
* `SERVEZONE_RELAY_INGRESS_ADDRESS`.
|
|
182
|
-
*/
|
|
183
|
-
'SERVEZONE_RELAYED_LISTENPORT',
|
|
184
|
-
/**
|
|
185
|
-
* Where Cloudly's cloud access connector dials the host's relay ingress (Linus ruling 141 C6 and
|
|
186
|
-
* C7, amendment 141a point 4): `<host>:<port>`, an IPv6 address in brackets
|
|
187
|
-
* (`[2001:db8::1]:8443`). The relay ingress is the host's second listener, reachable from the
|
|
188
|
-
* Cloudly container, that serves `SERVEZONE_PUBLIC_ORIGIN`'s TLS and forwards only to
|
|
189
|
-
* `SERVEZONE_RELAYED_LISTENPORT`. The connector never dials the public origin by name, whose
|
|
190
|
-
* public DNS points at the relay, nor an address taken from a request. A host that advertises
|
|
191
|
-
* `relayIngress` sets it together with `SERVEZONE_RELAYED_LISTENPORT`.
|
|
192
|
-
*/
|
|
193
|
-
'SERVEZONE_RELAY_INGRESS_ADDRESS',
|
|
108
|
+
optionalEnv.backupCron,
|
|
109
|
+
optionalEnv.backupKeepLast,
|
|
110
|
+
optionalEnv.baseOsImageCleanupIntervalMs,
|
|
111
|
+
optionalEnv.siteOrigin,
|
|
112
|
+
optionalEnv.witnessOrigin,
|
|
113
|
+
optionalEnv.witnessBearerPath,
|
|
114
|
+
optionalEnv.relayedListenPort,
|
|
115
|
+
optionalEnv.relayIngressAddress,
|
|
194
116
|
] as const);
|
|
195
117
|
|
|
196
118
|
/** One variable the Cloudly server reads but starts without. */
|
|
@@ -213,9 +135,7 @@ export type TCloudlyHostOptionalEnvironmentName = typeof cloudlyHostOptionalEnvi
|
|
|
213
135
|
* (`hostedAppGetLifecycleState`), and `validateHostedAppHostExtras` judges it. Cloudly uses only the
|
|
214
136
|
* names it knows (`isCloudlyHostExtra`) and ignores every other one, because an extra is an offer.
|
|
215
137
|
*/
|
|
216
|
-
export const cloudlyHostExtras =
|
|
217
|
-
'relayIngress',
|
|
218
|
-
] as const);
|
|
138
|
+
export const cloudlyHostExtras = cloudlyHostExtraCapabilities;
|
|
219
139
|
|
|
220
140
|
/** One host extra. */
|
|
221
141
|
export type TCloudlyHostExtra = typeof cloudlyHostExtras[number];
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { readDataElements, readExactDataRecord } from '../private/dataproperties.js';
|
|
2
|
+
import { hostedAppRuntimeIdentityKeys } from './hostedapp.js';
|
|
3
|
+
|
|
4
|
+
/** The environment Cloudly requires at startup, as verified by its `qenv.yml`. */
|
|
5
|
+
export const cloudlyHostContractRequiredEnvVars = Object.freeze({
|
|
6
|
+
/**
|
|
7
|
+
* The deployment environment. Production hosts set `production`; any other value turns on
|
|
8
|
+
* development reloading. The value is fixed for the life of a database: Cloudly binds it into
|
|
9
|
+
* the credentials and sessions it stores.
|
|
10
|
+
*/
|
|
11
|
+
environment: 'SERVEZONE_ENVIRONMENT',
|
|
12
|
+
/**
|
|
13
|
+
* The origin clients reach Cloudly under: `http` or `https`, with an optional port, and no path,
|
|
14
|
+
* query or fragment. Ingress passes the request's `Host` unchanged, so it equals this origin's
|
|
15
|
+
* `host[:port]`.
|
|
16
|
+
*/
|
|
17
|
+
publicOrigin: 'SERVEZONE_PUBLIC_ORIGIN',
|
|
18
|
+
/**
|
|
19
|
+
* `external` (TLS is terminated in front of Cloudly) or `none`. Cloudly terminates no TLS itself.
|
|
20
|
+
*/
|
|
21
|
+
sslMode: 'SERVEZONE_SSLMODE',
|
|
22
|
+
/**
|
|
23
|
+
* The path of the secret keyring file. The host delivers it as a private file: a regular file
|
|
24
|
+
* that is not a symlink, has one hard link, is owned by the process user and grants no group or
|
|
25
|
+
* other permission, in a directory owned by that user that neither group nor others may write.
|
|
26
|
+
* This is the host's obligation; the Cloudly server does not check it yet.
|
|
27
|
+
*/
|
|
28
|
+
secretKeyringPath: 'SERVEZONE_SECRET_KEYRING_PATH',
|
|
29
|
+
/** The MongoDB connection URL of Cloudly's database. */
|
|
30
|
+
mongoDbUrl: 'MONGODB_URL',
|
|
31
|
+
/** The S3 endpoint of Cloudly's object storage. */
|
|
32
|
+
s3Endpoint: 'S3_ENDPOINT',
|
|
33
|
+
/** The S3 access key. */
|
|
34
|
+
s3AccessKey: 'S3_ACCESSKEY',
|
|
35
|
+
/** The S3 secret key. */
|
|
36
|
+
s3SecretKey: 'S3_SECRETKEY',
|
|
37
|
+
/** The bucket Cloudly keeps its objects in; Cloudly creates it when it does not exist. */
|
|
38
|
+
s3Bucket: 'S3_BUCKET',
|
|
39
|
+
} as const);
|
|
40
|
+
|
|
41
|
+
export const cloudlyHostContractRequiredEnvVarList = Object.freeze(
|
|
42
|
+
Object.values(cloudlyHostContractRequiredEnvVars),
|
|
43
|
+
);
|
|
44
|
+
export type TCloudlyHostRequiredEnvVar = typeof cloudlyHostContractRequiredEnvVarList[number];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Optional configuration. Both lists exclude `SERVEZONE_ADMINACCOUNT` (deprecated bootstrap)
|
|
48
|
+
* and `SERVEZONE_APP_HOST_TYPE` (display only).
|
|
49
|
+
*/
|
|
50
|
+
export const cloudlyHostContractOptionalEnvVars = Object.freeze({
|
|
51
|
+
/** The port the server binds; `cloudlyDefaultListenPort` when unset. */
|
|
52
|
+
listenPort: 'SERVEZONE_LISTENPORT',
|
|
53
|
+
/**
|
|
54
|
+
* The path of the WorkloadInit release approval file, a private file under the same rules as
|
|
55
|
+
* the secret keyring. Unset, the requests that need an approval answer
|
|
56
|
+
* `workloadinit-unconfigured`.
|
|
57
|
+
*/
|
|
58
|
+
workloadInitApprovalPath: 'SERVEZONE_WORKLOADINIT_APPROVAL_PATH',
|
|
59
|
+
/** Optional member of the Mongo descriptor (database name). */
|
|
60
|
+
mongoDbName: 'MONGODB_NAME',
|
|
61
|
+
/** Optional member of the Mongo descriptor (user). */
|
|
62
|
+
mongoDbUser: 'MONGODB_USER',
|
|
63
|
+
/** Optional member of the Mongo descriptor (password). */
|
|
64
|
+
mongoDbPass: 'MONGODB_PASS',
|
|
65
|
+
/** The S3 port. This contract states no default. */
|
|
66
|
+
s3Port: 'S3_PORT',
|
|
67
|
+
/** Whether S3 is reached over TLS (`true` or `false`). This contract states no default. */
|
|
68
|
+
s3UseSsl: 'S3_USESSL',
|
|
69
|
+
/**
|
|
70
|
+
* The host channel of a hosted Cloudly, together with `SERVEZONE_APP_CONTROL_TOKEN`
|
|
71
|
+
* (`hostedAppRuntimeIdentityKeys`). Cloudly counts as hosted only while both are set.
|
|
72
|
+
*/
|
|
73
|
+
runtimeUrl: hostedAppRuntimeIdentityKeys.runtimeUrl,
|
|
74
|
+
/** The host's machine JWT for the host channel, delivered as a secret. */
|
|
75
|
+
controlToken: hostedAppRuntimeIdentityKeys.controlToken,
|
|
76
|
+
platformOidcIssuer: 'SERVEZONE_PLATFORM_OIDC_ISSUER',
|
|
77
|
+
platformOidcClientId: 'SERVEZONE_PLATFORM_OIDC_CLIENT_ID',
|
|
78
|
+
platformOidcClientSecret: 'SERVEZONE_PLATFORM_OIDC_CLIENT_SECRET',
|
|
79
|
+
platformOidcRedirectUri: 'SERVEZONE_PLATFORM_OIDC_REDIRECT_URI',
|
|
80
|
+
platformOidcAudience: 'SERVEZONE_PLATFORM_OIDC_AUDIENCE',
|
|
81
|
+
/** The schedule of the backup of every service; unset, Cloudly schedules no backup. */
|
|
82
|
+
backupCron: 'CLOUDLY_BACKUP_CRON',
|
|
83
|
+
/** How many backups of a service the retention keeps; `24` when unset. */
|
|
84
|
+
backupKeepLast: 'CLOUDLY_BACKUP_KEEP_LAST',
|
|
85
|
+
/**
|
|
86
|
+
* The interval of the periodic BaseOS image build cleanup in milliseconds; 43,200,000 (12 hours)
|
|
87
|
+
* when unset. A value that is not a positive number turns the periodic cleanup off.
|
|
88
|
+
*/
|
|
89
|
+
baseOsImageCleanupIntervalMs: 'CLOUDLY_BASEOS_IMAGE_CLEANUP_INTERVAL_MS',
|
|
90
|
+
/**
|
|
91
|
+
* This controller site's own origin (Linus rulings 69 Q3 and 79 Q1): a canonical `https` origin
|
|
92
|
+
* (`data.validateControllerOrigin`), the `IControllerPeerSet.activeOrigin` this site states while
|
|
93
|
+
* it is active and the origin the witness names it by. While unset, the site counts as
|
|
94
|
+
* `SERVEZONE_PUBLIC_ORIGIN`, but only while the controller row lists no shadow; once it lists one,
|
|
95
|
+
* a start refuses an unset value or one equal to `SERVEZONE_PUBLIC_ORIGIN`. A fact about this one
|
|
96
|
+
* site, never stored in the replicated controller database.
|
|
97
|
+
*/
|
|
98
|
+
siteOrigin: 'SERVEZONE_SITE_ORIGIN',
|
|
99
|
+
/**
|
|
100
|
+
* The canonical `https` origin of the witness this site reads (`requests.witness`). Set together
|
|
101
|
+
* with `SERVEZONE_WITNESS_BEARER_PATH` or not at all: a start with only one of them is refused,
|
|
102
|
+
* naming the one that is unset. Required once the controller row lists another site as a shadow.
|
|
103
|
+
*/
|
|
104
|
+
witnessOrigin: 'SERVEZONE_WITNESS_ORIGIN',
|
|
105
|
+
/**
|
|
106
|
+
* The path of this site's witness bearer, a private file under the rules of the secret keyring
|
|
107
|
+
* (`SERVEZONE_SECRET_KEYRING_PATH`) holding the 43-character base64url of 32 random bytes
|
|
108
|
+
* (`data.witnessContract.bearerRandomBytes`). The host creates it; Cloudly only reads it and
|
|
109
|
+
* hashes it, never writes or logs it. Set together with `SERVEZONE_WITNESS_ORIGIN` or not at all.
|
|
110
|
+
*/
|
|
111
|
+
witnessBearerPath: 'SERVEZONE_WITNESS_BEARER_PATH',
|
|
112
|
+
/**
|
|
113
|
+
* The port of Cloudly's relayed listener (Linus ruling 141 C7), a second port beside
|
|
114
|
+
* `SERVEZONE_LISTENPORT` that the host's relay ingress forwards to, and only to. Relayedness is
|
|
115
|
+
* the accepting listener, so this port serves the human surface only: the UI, human sign-in and
|
|
116
|
+
* human typed requests, never machine endpoints or Destroy. This contract states no default. A
|
|
117
|
+
* host that advertises `relayIngress` (`cloudlyHostExtras`) sets it together with
|
|
118
|
+
* `SERVEZONE_RELAY_INGRESS_ADDRESS`.
|
|
119
|
+
*/
|
|
120
|
+
relayedListenPort: 'SERVEZONE_RELAYED_LISTENPORT',
|
|
121
|
+
/**
|
|
122
|
+
* Where Cloudly's cloud access connector dials the host's relay ingress (Linus ruling 141 C6 and
|
|
123
|
+
* C7, amendment 141a point 4): `<host>:<port>`, an IPv6 address in brackets
|
|
124
|
+
* (`[2001:db8::1]:8443`). The relay ingress is the host's second listener, reachable from the
|
|
125
|
+
* Cloudly container, that serves `SERVEZONE_PUBLIC_ORIGIN`'s TLS and forwards only to
|
|
126
|
+
* `SERVEZONE_RELAYED_LISTENPORT`. The connector never dials the public origin by name, whose
|
|
127
|
+
* public DNS points at the relay, nor an address taken from a request. A host that advertises
|
|
128
|
+
* `relayIngress` sets it together with `SERVEZONE_RELAYED_LISTENPORT`.
|
|
129
|
+
*/
|
|
130
|
+
relayIngressAddress: 'SERVEZONE_RELAY_INGRESS_ADDRESS',
|
|
131
|
+
} as const);
|
|
132
|
+
|
|
133
|
+
export const cloudlyHostContractOptionalEnvVarList = Object.freeze(
|
|
134
|
+
Object.values(cloudlyHostContractOptionalEnvVars),
|
|
135
|
+
);
|
|
136
|
+
export type TCloudlyHostOptionalEnvVar = typeof cloudlyHostContractOptionalEnvVarList[number];
|
|
137
|
+
|
|
138
|
+
/** Standard optional offers. These are separate from the advertised extras. */
|
|
139
|
+
export const cloudlyHostStandardOffers = Object.freeze([
|
|
140
|
+
'hosted-runtime-identity',
|
|
141
|
+
'backups',
|
|
142
|
+
'local-node',
|
|
143
|
+
'shadow-pairing',
|
|
144
|
+
] as const);
|
|
145
|
+
|
|
146
|
+
/** Closed vocabulary for the versioned host advertisement. */
|
|
147
|
+
export const cloudlyHostExtraCapabilities = Object.freeze([
|
|
148
|
+
'relayIngress',
|
|
149
|
+
] as const);
|
|
150
|
+
export type TCloudlyHostExtraCapability = typeof cloudlyHostExtraCapabilities[number];
|
|
151
|
+
|
|
152
|
+
export interface ICloudlyHostAdvertisedExtras {
|
|
153
|
+
readonly contractVersion: 1;
|
|
154
|
+
readonly capabilities: readonly TCloudlyHostExtraCapability[];
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const advertisedExtrasContractVersion = 1;
|
|
158
|
+
const advertisedExtrasKeys = ['contractVersion', 'capabilities'] as const satisfies
|
|
159
|
+
readonly (keyof ICloudlyHostAdvertisedExtras)[];
|
|
160
|
+
const isCloudlyHostExtraCapability = (valueArg: unknown): valueArg is TCloudlyHostExtraCapability =>
|
|
161
|
+
(cloudlyHostExtraCapabilities as readonly unknown[]).includes(valueArg);
|
|
162
|
+
|
|
163
|
+
const readCloudlyHostAdvertisedExtras = (valueArg: unknown): ICloudlyHostAdvertisedExtras | string => {
|
|
164
|
+
const record = readExactDataRecord(valueArg, advertisedExtrasKeys);
|
|
165
|
+
if (record === null) {
|
|
166
|
+
return 'Cloudly host advertised extras must be an object with exactly contractVersion and capabilities';
|
|
167
|
+
}
|
|
168
|
+
if (record.contractVersion !== advertisedExtrasContractVersion) {
|
|
169
|
+
return 'Cloudly host advertised extras contractVersion must be 1';
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const elements = readDataElements(record.capabilities, cloudlyHostExtraCapabilities.length);
|
|
173
|
+
if (elements === null || new Set(elements).size !== elements.length) {
|
|
174
|
+
return 'Cloudly host advertised extras capabilities must be a dense array of unique capabilities';
|
|
175
|
+
}
|
|
176
|
+
if (!elements.every(isCloudlyHostExtraCapability)) {
|
|
177
|
+
return 'Cloudly host advertised extras contains an unknown capability';
|
|
178
|
+
}
|
|
179
|
+
return { contractVersion: advertisedExtrasContractVersion, capabilities: elements };
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/** Validate a stated advertisement. Only normalization accepts absence. */
|
|
183
|
+
export const validateCloudlyHostAdvertisedExtras = (valueArg: unknown): string[] => {
|
|
184
|
+
const result = readCloudlyHostAdvertisedExtras(valueArg);
|
|
185
|
+
return typeof result === 'string' ? [result] : [];
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/** No host channel or advertisement means no extras. A malformed advertisement throws. */
|
|
189
|
+
export const normalizeCloudlyHostAdvertisedExtras = (
|
|
190
|
+
valueArg: unknown,
|
|
191
|
+
): ICloudlyHostAdvertisedExtras => {
|
|
192
|
+
if (valueArg === undefined || valueArg === null) {
|
|
193
|
+
return { contractVersion: advertisedExtrasContractVersion, capabilities: [] };
|
|
194
|
+
}
|
|
195
|
+
const result = readCloudlyHostAdvertisedExtras(valueArg);
|
|
196
|
+
if (typeof result === 'string') {
|
|
197
|
+
throw new Error(result);
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/** Only a valid advertisement can offer a capability. */
|
|
203
|
+
export const hasCloudlyHostExtraCapability = (
|
|
204
|
+
extrasArg: ICloudlyHostAdvertisedExtras | null | undefined,
|
|
205
|
+
capabilityArg: TCloudlyHostExtraCapability,
|
|
206
|
+
): boolean => {
|
|
207
|
+
const result = readCloudlyHostAdvertisedExtras(extrasArg);
|
|
208
|
+
return typeof result !== 'string' && result.capabilities.includes(capabilityArg);
|
|
209
|
+
};
|
package/ts/data/hostedapp.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { ICloudlyHostAdvertisedExtras } from './cloudlyhostcontract.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The kind of host running a hosted app (`onebox`, `cloudly`, or another host's name), for display
|
|
3
5
|
* only: never branch on it. A host's capabilities reach an app only through the extras the host
|
|
@@ -438,6 +440,8 @@ export interface IHostedAppLifecycleState extends IHostedAppLifecycleReport {
|
|
|
438
440
|
* nothing, and so does a list the validator refuses.
|
|
439
441
|
*/
|
|
440
442
|
hostExtras?: string[];
|
|
443
|
+
/** Optional host-owned advertisement in the Cloudly host contract's closed format. */
|
|
444
|
+
advertisedExtras?: ICloudlyHostAdvertisedExtras;
|
|
441
445
|
}
|
|
442
446
|
|
|
443
447
|
type THostedAppBootstrapActionServerFields =
|
|
@@ -471,7 +475,7 @@ const hostedAppLifecycleReportKeys: ReadonlySet<string> = new Set<
|
|
|
471
475
|
|
|
472
476
|
const hostedAppLifecycleHostOwnedKeys: ReadonlySet<string> = new Set<
|
|
473
477
|
Exclude<keyof IHostedAppLifecycleState, keyof IHostedAppLifecycleReport>
|
|
474
|
-
>(['appInstanceId', 'hostType', 'reportedAt', 'bootstrapAction', 'upgradeState', 'hostExtras']);
|
|
478
|
+
>(['appInstanceId', 'hostType', 'reportedAt', 'bootstrapAction', 'upgradeState', 'hostExtras', 'advertisedExtras']);
|
|
475
479
|
|
|
476
480
|
const hostedAppCapabilityRegex = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,99}$/;
|
|
477
481
|
const hostedAppNameListMaximumLength = 64;
|
package/ts/data/index.ts
CHANGED
package/ts/data/nodeaction.ts
CHANGED
|
@@ -172,7 +172,7 @@ export const nodeActionRestartsRuntime = (actionNameArg: TNodeActionName, reboot
|
|
|
172
172
|
*/
|
|
173
173
|
export const nodeActionFailureRemedies = Object.freeze({
|
|
174
174
|
'download-failed': 'Spark could not download the target release. Check that the node reaches '
|
|
175
|
-
+ '
|
|
175
|
+
+ 'foss.global, then request the update again.',
|
|
176
176
|
'installer-mismatch': 'The downloaded install.sh does not have the SHA-256 the target states. '
|
|
177
177
|
+ 'Nothing was installed; set the fleet Spark target again, then request the update again.',
|
|
178
178
|
'install-failed': 'The node bundle installer failed and left the installed release in place. '
|
|
@@ -4,8 +4,8 @@ import { hasExactKeys } from './private/dataproperties.js';
|
|
|
4
4
|
|
|
5
5
|
export const workloadInitReleaseContract = Object.freeze({
|
|
6
6
|
packageName: '@serve.zone/workloadinit',
|
|
7
|
-
sourceRepository: 'https://
|
|
8
|
-
imageRegistry: '
|
|
7
|
+
sourceRepository: 'https://foss.global/serve.zone/workloadinit.git',
|
|
8
|
+
imageRegistry: 'foss.global',
|
|
9
9
|
imageRepository: 'serve.zone/workloadinit',
|
|
10
10
|
imageIndexMediaType: 'application/vnd.oci.image.index.v1+json',
|
|
11
11
|
statementType: 'https://in-toto.io/Statement/v1',
|
|
@@ -16,6 +16,23 @@ export const workloadInitReleaseContract = Object.freeze({
|
|
|
16
16
|
signatureAlgorithm: 'ecdsa-p256-sha256',
|
|
17
17
|
} as const);
|
|
18
18
|
|
|
19
|
+
/** Legacy authority repositories retained so previously approved releases validate during rolling migration. */
|
|
20
|
+
const legacyWorkloadInitReleaseRepositories = Object.freeze({
|
|
21
|
+
sourceRepository: 'https://code.foss.global/serve.zone/workloadinit.git',
|
|
22
|
+
imageRegistry: 'code.foss.global',
|
|
23
|
+
} as const);
|
|
24
|
+
|
|
25
|
+
const acceptedWorkloadInitAuthorities = Object.freeze([
|
|
26
|
+
{
|
|
27
|
+
sourceRepository: workloadInitReleaseContract.sourceRepository,
|
|
28
|
+
imageRegistry: workloadInitReleaseContract.imageRegistry,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
sourceRepository: legacyWorkloadInitReleaseRepositories.sourceRepository,
|
|
32
|
+
imageRegistry: legacyWorkloadInitReleaseRepositories.imageRegistry,
|
|
33
|
+
},
|
|
34
|
+
] as const);
|
|
35
|
+
|
|
19
36
|
export interface IWorkloadInitBuildToolVersions {
|
|
20
37
|
dockerBuildx: string;
|
|
21
38
|
gitzone: string;
|
|
@@ -26,11 +43,15 @@ export interface IWorkloadInitBuildToolVersions {
|
|
|
26
43
|
export interface IWorkloadInitReleaseIdentity {
|
|
27
44
|
packageName: typeof workloadInitReleaseContract.packageName;
|
|
28
45
|
version: string;
|
|
29
|
-
sourceRepository:
|
|
46
|
+
sourceRepository:
|
|
47
|
+
| typeof workloadInitReleaseContract.sourceRepository
|
|
48
|
+
| typeof legacyWorkloadInitReleaseRepositories.sourceRepository;
|
|
30
49
|
sourceRevision: string;
|
|
31
50
|
sourceRef: string;
|
|
32
51
|
sourceDirty: false;
|
|
33
|
-
imageRegistry:
|
|
52
|
+
imageRegistry:
|
|
53
|
+
| typeof workloadInitReleaseContract.imageRegistry
|
|
54
|
+
| typeof legacyWorkloadInitReleaseRepositories.imageRegistry;
|
|
34
55
|
imageRepository: typeof workloadInitReleaseContract.imageRepository;
|
|
35
56
|
imageTag: string;
|
|
36
57
|
}
|
|
@@ -55,7 +76,7 @@ export interface IWorkloadInitReleaseAttestationStatement {
|
|
|
55
76
|
tag: string;
|
|
56
77
|
};
|
|
57
78
|
source: {
|
|
58
|
-
repository:
|
|
79
|
+
repository: IWorkloadInitReleaseIdentity['sourceRepository'];
|
|
59
80
|
tag: string;
|
|
60
81
|
dirty: false;
|
|
61
82
|
};
|
|
@@ -161,9 +182,12 @@ export const validateWorkloadInitReleaseIdentity = (
|
|
|
161
182
|
return ['WorkloadInit release identity must use its exact schema'];
|
|
162
183
|
}
|
|
163
184
|
const errors: string[] = [];
|
|
185
|
+
const matchingAuthority = acceptedWorkloadInitAuthorities.some((authorityArg) => (
|
|
186
|
+
releaseArg.sourceRepository === authorityArg.sourceRepository
|
|
187
|
+
&& releaseArg.imageRegistry === authorityArg.imageRegistry
|
|
188
|
+
));
|
|
164
189
|
if (releaseArg.packageName !== workloadInitReleaseContract.packageName
|
|
165
|
-
||
|
|
166
|
-
|| releaseArg.imageRegistry !== workloadInitReleaseContract.imageRegistry
|
|
190
|
+
|| !matchingAuthority
|
|
167
191
|
|| releaseArg.imageRepository !== workloadInitReleaseContract.imageRepository) {
|
|
168
192
|
errors.push('WorkloadInit release identity must use the canonical package and repositories');
|
|
169
193
|
}
|
|
@@ -298,20 +322,25 @@ export const validateWorkloadInitReleaseAttestationStatement = (
|
|
|
298
322
|
const source = buildDefinition.externalParameters.source;
|
|
299
323
|
const dependency = buildDefinition.resolvedDependencies[0];
|
|
300
324
|
const toolVersions = runDetails.builder.version;
|
|
325
|
+
const matchedAuthority = isRecord(artifact)
|
|
326
|
+
? acceptedWorkloadInitAuthorities.find((authorityArg) => (
|
|
327
|
+
artifact.repository === `${authorityArg.imageRegistry}/${workloadInitReleaseContract.imageRepository}`
|
|
328
|
+
))
|
|
329
|
+
: undefined;
|
|
301
330
|
if (!isRecord(artifact)
|
|
302
331
|
|| !hasExactKeys(artifact, ['mediaType', 'platforms', 'repository', 'tag'])
|
|
303
332
|
|| artifact.mediaType !== workloadInitReleaseContract.imageIndexMediaType
|
|
304
333
|
|| JSON.stringify(artifact.platforms) !== JSON.stringify(['linux/amd64', 'linux/arm64'])
|
|
305
|
-
||
|
|
306
|
-
workloadInitReleaseContract.imageRepository
|
|
307
|
-
}`
|
|
334
|
+
|| !matchedAuthority
|
|
308
335
|
|| typeof artifact.tag !== 'string'
|
|
309
336
|
|| !/^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/.test(artifact.tag)) {
|
|
310
337
|
errors.push('WorkloadInit release attestation artifact must be canonical and version-tagged');
|
|
311
338
|
}
|
|
339
|
+
const expectedSourceRepository = matchedAuthority?.sourceRepository
|
|
340
|
+
?? workloadInitReleaseContract.sourceRepository;
|
|
312
341
|
if (!isRecord(source)
|
|
313
342
|
|| !hasExactKeys(source, ['repository', 'tag', 'dirty'])
|
|
314
|
-
|| source.repository !==
|
|
343
|
+
|| source.repository !== expectedSourceRepository
|
|
315
344
|
|| source.dirty !== false
|
|
316
345
|
|| typeof source.tag !== 'string'
|
|
317
346
|
|| source.tag !== `refs/tags/${artifact && isRecord(artifact) ? artifact.tag : ''}`) {
|
|
@@ -323,7 +352,7 @@ export const validateWorkloadInitReleaseAttestationStatement = (
|
|
|
323
352
|
|| !hasExactKeys(dependency.digest, ['gitCommit'])
|
|
324
353
|
|| typeof dependency.digest.gitCommit !== 'string'
|
|
325
354
|
|| !gitRevisionRegex.test(dependency.digest.gitCommit)
|
|
326
|
-
|| dependency.uri !== `git+${
|
|
355
|
+
|| dependency.uri !== `git+${expectedSourceRepository}@${source && isRecord(source)
|
|
327
356
|
? source.tag
|
|
328
357
|
: ''}`) {
|
|
329
358
|
errors.push('WorkloadInit release attestation source dependency must be canonical');
|