@openupstream/sdk 0.9.1 → 0.12.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/README.md +25 -0
- package/dist/index.d.ts +44 -2
- package/dist/index.js +72 -1
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +129 -13
- package/dist/internal.js +55 -5
- package/dist/internal.js.map +1 -1
- package/dist/keys.d.ts +54 -0
- package/dist/keys.js +84 -0
- package/dist/keys.js.map +1 -0
- package/dist/model.d.ts +415 -7
- package/dist/model.js +64 -4
- package/dist/model.js.map +1 -1
- package/package.json +5 -1
package/dist/keys.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Strings given with a value when it is encrypted, which must be given again, equal, to decrypt it. Not secret, and recorded. */
|
|
2
|
+
export type KeyContext = Readonly<Record<string, string>>;
|
|
3
|
+
export type KeysError =
|
|
4
|
+
/** This container has no grant on any Key: the two environment variables are missing. */
|
|
5
|
+
{
|
|
6
|
+
readonly kind: 'no-identity';
|
|
7
|
+
readonly message: string;
|
|
8
|
+
}
|
|
9
|
+
/** The key API could not be reached, also after trying again. */
|
|
10
|
+
| {
|
|
11
|
+
readonly kind: 'unreachable';
|
|
12
|
+
readonly message: string;
|
|
13
|
+
}
|
|
14
|
+
/** The key API's answer: 403 without a grant for the operation, 404 for no such Key, 400 for what cannot be decrypted, 429 above the rate limit, … */
|
|
15
|
+
| {
|
|
16
|
+
readonly kind: 'status';
|
|
17
|
+
readonly status: number;
|
|
18
|
+
readonly message: string;
|
|
19
|
+
};
|
|
20
|
+
export type KeysResult<T> = {
|
|
21
|
+
readonly ok: true;
|
|
22
|
+
readonly value: T;
|
|
23
|
+
} | {
|
|
24
|
+
readonly ok: false;
|
|
25
|
+
readonly error: KeysError;
|
|
26
|
+
};
|
|
27
|
+
export interface KeysOptions {
|
|
28
|
+
/** The process's environment by default. */
|
|
29
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
30
|
+
readonly fetch?: typeof fetch;
|
|
31
|
+
readonly readToken?: (path: string) => Promise<string>;
|
|
32
|
+
/**
|
|
33
|
+
* How often a call that could not connect is tried again, a second
|
|
34
|
+
* apart (5 by default). A container's connections in its first second
|
|
35
|
+
* are refused, until the platform's network knows its address.
|
|
36
|
+
*/
|
|
37
|
+
readonly retries?: number;
|
|
38
|
+
readonly retryDelayMs?: number;
|
|
39
|
+
/** How long one attempt may take before it counts as not connected (10 s by default). */
|
|
40
|
+
readonly timeoutMs?: number;
|
|
41
|
+
}
|
|
42
|
+
/** The client for the key API of the container it runs in. */
|
|
43
|
+
export declare function keys(options?: KeysOptions): {
|
|
44
|
+
/**
|
|
45
|
+
* Encrypts at most KEY_CALL_LIMITS.maxPlaintextBytes bytes with the
|
|
46
|
+
* Key `key` of this Project. The result is a string to store
|
|
47
|
+
* anywhere; it names its Key and version.
|
|
48
|
+
*/
|
|
49
|
+
encrypt(key: string, plaintext: Uint8Array | string, context?: KeyContext): Promise<KeysResult<string>>;
|
|
50
|
+
/** Decrypts what `encrypt` returned, given the same context. */
|
|
51
|
+
decrypt(key: string, ciphertext: string, context?: KeyContext): Promise<KeysResult<Uint8Array>>;
|
|
52
|
+
/** `decrypt` for a value that was text. */
|
|
53
|
+
decryptText(key: string, ciphertext: string, context?: KeyContext): Promise<KeysResult<string>>;
|
|
54
|
+
};
|
package/dist/keys.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encrypting and decrypting with a Key from inside a Service or Job
|
|
3
|
+
* (`@openupstream/sdk/keys`; ARCHITECTURE.md, "Keys"). An entry point of
|
|
4
|
+
* its own, since it reads a file and so runs in Node only; the rest of the
|
|
5
|
+
* sdk also runs in a browser.
|
|
6
|
+
*
|
|
7
|
+
* A container whose Service or Job has a grant on a Key (`oup key grant`)
|
|
8
|
+
* gets `OUP_KEYS_URL` and `OUP_KEYS_TOKEN_FILE`. The platform replaces the
|
|
9
|
+
* token in that file about once an hour, so it is read on every call.
|
|
10
|
+
*/
|
|
11
|
+
import { readFile } from 'node:fs/promises';
|
|
12
|
+
import { KEYS_TOKEN_FILE_ENV, KEYS_URL_ENV } from './internal.js';
|
|
13
|
+
import { errorMessage } from './index.js';
|
|
14
|
+
import { KEY_CALL_LIMITS } from './model.js';
|
|
15
|
+
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
16
|
+
/** The client for the key API of the container it runs in. */
|
|
17
|
+
export function keys(options = {}) {
|
|
18
|
+
const env = options.env ?? process.env;
|
|
19
|
+
const request = options.fetch ?? fetch;
|
|
20
|
+
const readToken = options.readToken ?? ((path) => readFile(path, 'utf8'));
|
|
21
|
+
const retries = options.retries ?? 5;
|
|
22
|
+
const retryDelayMs = options.retryDelayMs ?? 1000;
|
|
23
|
+
const timeoutMs = options.timeoutMs ?? 10_000;
|
|
24
|
+
const call = async (key, operation, body) => {
|
|
25
|
+
const url = env[KEYS_URL_ENV];
|
|
26
|
+
const tokenFile = env[KEYS_TOKEN_FILE_ENV];
|
|
27
|
+
if (url === undefined || url === '' || tokenFile === undefined || tokenFile === '') {
|
|
28
|
+
return {
|
|
29
|
+
ok: false,
|
|
30
|
+
error: { kind: 'no-identity', message: `${KEYS_URL_ENV} and ${KEYS_TOKEN_FILE_ENV} are not set: this Service or Job has no grant on a Key (oup key grant)` },
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const attempt = async (left) => {
|
|
34
|
+
const sent = await readToken(tokenFile)
|
|
35
|
+
.then((token) => request(`${url}/v1/keys/${encodeURIComponent(key)}/${operation}`, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: { authorization: `Bearer ${token.trim()}`, 'content-type': 'application/json' },
|
|
38
|
+
body: JSON.stringify(body),
|
|
39
|
+
// A connection that is accepted but never answered must not hold the caller for good.
|
|
40
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
41
|
+
}))
|
|
42
|
+
.then((response) => ({ response }), (error) => ({ failure: error instanceof Error ? error.message : String(error) }));
|
|
43
|
+
if ('failure' in sent) {
|
|
44
|
+
if (left > 0) {
|
|
45
|
+
await wait(retryDelayMs);
|
|
46
|
+
return attempt(left - 1);
|
|
47
|
+
}
|
|
48
|
+
return { ok: false, error: { kind: 'unreachable', message: sent.failure } };
|
|
49
|
+
}
|
|
50
|
+
const answer = await sent.response.json().catch(() => undefined);
|
|
51
|
+
return sent.response.ok ? { ok: true, value: answer } : { ok: false, error: { kind: 'status', status: sent.response.status, message: errorMessage(answer, sent.response.statusText || `HTTP ${sent.response.status}`) } };
|
|
52
|
+
};
|
|
53
|
+
return attempt(retries);
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
/**
|
|
57
|
+
* Encrypts at most KEY_CALL_LIMITS.maxPlaintextBytes bytes with the
|
|
58
|
+
* Key `key` of this Project. The result is a string to store
|
|
59
|
+
* anywhere; it names its Key and version.
|
|
60
|
+
*/
|
|
61
|
+
async encrypt(key, plaintext, context) {
|
|
62
|
+
const bytes = typeof plaintext === 'string' ? Buffer.from(plaintext, 'utf8') : Buffer.from(plaintext);
|
|
63
|
+
if (bytes.length > KEY_CALL_LIMITS.maxPlaintextBytes) {
|
|
64
|
+
return {
|
|
65
|
+
ok: false,
|
|
66
|
+
error: { kind: 'status', status: 400, message: `a plaintext has at most ${KEY_CALL_LIMITS.maxPlaintextBytes} bytes; encrypt larger data with a key of your own and that key with the Key` },
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const result = await call(key, 'encrypt', { plaintext: bytes.toString('base64'), ...(context === undefined ? {} : { context }) });
|
|
70
|
+
return result.ok ? { ok: true, value: result.value.ciphertext } : result;
|
|
71
|
+
},
|
|
72
|
+
/** Decrypts what `encrypt` returned, given the same context. */
|
|
73
|
+
async decrypt(key, ciphertext, context) {
|
|
74
|
+
const result = await call(key, 'decrypt', { ciphertext, ...(context === undefined ? {} : { context }) });
|
|
75
|
+
return result.ok ? { ok: true, value: new Uint8Array(Buffer.from(result.value.plaintext, 'base64')) } : result;
|
|
76
|
+
},
|
|
77
|
+
/** `decrypt` for a value that was text. */
|
|
78
|
+
async decryptText(key, ciphertext, context) {
|
|
79
|
+
const result = await this.decrypt(key, ciphertext, context);
|
|
80
|
+
return result.ok ? { ok: true, value: Buffer.from(result.value).toString('utf8') } : result;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=keys.js.map
|
package/dist/keys.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA+B7C,MAAM,IAAI,GAAG,CAAC,EAAU,EAAiB,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAE9F,8DAA8D;AAC9D,MAAM,UAAU,IAAI,CAAC,UAAuB,EAAE;IAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACvC,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACvC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAClF,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,CAAC,CAAC;IACrC,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC;IAClD,MAAM,SAAS,GA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3C,KAAK,CAAC,WAAW,CAAC,GAAW,EAAE,UAAkB,EAAE,OAAoB;YACnE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAC5D,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;QAChG,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/dist/model.d.ts
CHANGED
|
@@ -72,6 +72,179 @@ export interface NodesReport {
|
|
|
72
72
|
nodes: NodeInfo[];
|
|
73
73
|
problems: SiteProblem[];
|
|
74
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* One pod of a platform Database or component (`GET /v1/admin/platform`):
|
|
77
|
+
* where it runs and whether it runs.
|
|
78
|
+
*/
|
|
79
|
+
export interface PlatformInstance {
|
|
80
|
+
/** The pod's name. */
|
|
81
|
+
name: string;
|
|
82
|
+
/** Its node's Site; null before it is scheduled, or on a node without one. */
|
|
83
|
+
site: Site | null;
|
|
84
|
+
/** Running with every container started, and not being deleted. */
|
|
85
|
+
running: boolean;
|
|
86
|
+
}
|
|
87
|
+
/** An instance of a platform Database: its primary, or the standby. */
|
|
88
|
+
export interface PlatformDatabaseInstance extends PlatformInstance {
|
|
89
|
+
/** CloudNativePG's current primary; false for the standby, and for every instance while the Cluster cannot be read. */
|
|
90
|
+
primary: boolean;
|
|
91
|
+
}
|
|
92
|
+
/** One of the platform's own Databases, read live like a customer's (`GET /v1/admin/platform`). */
|
|
93
|
+
export interface PlatformDatabase {
|
|
94
|
+
id: Id;
|
|
95
|
+
name: string;
|
|
96
|
+
/** Where the primary runs when nothing has failed. */
|
|
97
|
+
homeSite: Site;
|
|
98
|
+
memoryMb: number;
|
|
99
|
+
storageGb: number;
|
|
100
|
+
state: DatabaseState;
|
|
101
|
+
/** The primary runs outside the Home site: a failover moved it, and it stays there until a switchover moves it back. */
|
|
102
|
+
failedOver: boolean;
|
|
103
|
+
instances: PlatformDatabaseInstance[];
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* - `running`: every replica available
|
|
107
|
+
* - `deploying`: a rollout is under way
|
|
108
|
+
* - `degraded`: some replicas available, not all
|
|
109
|
+
* - `down`: none available
|
|
110
|
+
* - `absent`: no Deployment of that name (e.g. an installation without the dashboard)
|
|
111
|
+
* - `unknown`: the platform could not check just now
|
|
112
|
+
*/
|
|
113
|
+
export type PlatformComponentState = 'running' | 'deploying' | 'degraded' | 'down' | 'absent' | 'unknown';
|
|
114
|
+
/** A component of the platform: a Deployment in the platform Project's namespace. */
|
|
115
|
+
export interface PlatformComponent {
|
|
116
|
+
/** The Deployment's name: `control-plane`, `madauth` or `dashboard`. */
|
|
117
|
+
name: string;
|
|
118
|
+
state: PlatformComponentState;
|
|
119
|
+
/** The replicas it asks for, and those available; 0 and 0 when absent or unknown. */
|
|
120
|
+
replicas: number;
|
|
121
|
+
availableReplicas: number;
|
|
122
|
+
instances: PlatformInstance[];
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The platform's own Account and Project, read-only, for the installation's
|
|
126
|
+
* admins, who are never Members of it (decision 164): its Databases and the
|
|
127
|
+
* platform's components, where each runs and how it is.
|
|
128
|
+
*/
|
|
129
|
+
export interface PlatformReport {
|
|
130
|
+
account: {
|
|
131
|
+
id: Id;
|
|
132
|
+
name: string;
|
|
133
|
+
};
|
|
134
|
+
project: {
|
|
135
|
+
id: Id;
|
|
136
|
+
name: string;
|
|
137
|
+
};
|
|
138
|
+
databases: PlatformDatabase[];
|
|
139
|
+
components: PlatformComponent[];
|
|
140
|
+
/** The compute Sites with their descriptions, to name the Sites above. */
|
|
141
|
+
sites: SiteInfo[];
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* A node's CPU (millicores) or memory (bytes) as the installation's admins
|
|
145
|
+
* see it (`GET /v1/admin/capacity`, decision 183).
|
|
146
|
+
*/
|
|
147
|
+
export interface NodeAmount {
|
|
148
|
+
/** What Kubernetes may place on the node (its allocatable). */
|
|
149
|
+
allocatable: number;
|
|
150
|
+
/** What the pods on it request: what the scheduler counts as taken. */
|
|
151
|
+
requested: number;
|
|
152
|
+
/** What the whole machine uses now, its system and k3s included; null when not measured. */
|
|
153
|
+
used: number | null;
|
|
154
|
+
}
|
|
155
|
+
/** A node with its CPU and memory: given, requested, used. */
|
|
156
|
+
export interface NodeCapacity {
|
|
157
|
+
name: string;
|
|
158
|
+
/** Its Site; null when it has none. */
|
|
159
|
+
site: Site | null;
|
|
160
|
+
/** Labelled a node of a compute Site: Databases, Services and Jobs run there. */
|
|
161
|
+
compute: boolean;
|
|
162
|
+
/** Kubernetes reports it Ready; one that is not adds no room for a new Database. */
|
|
163
|
+
ready: boolean;
|
|
164
|
+
cpuMillicores: NodeAmount;
|
|
165
|
+
memoryBytes: NodeAmount;
|
|
166
|
+
}
|
|
167
|
+
/** CPU (millicores) or memory (bytes) of a namespace's pods. */
|
|
168
|
+
export interface PodsAmount {
|
|
169
|
+
/** What its pods request. */
|
|
170
|
+
requested: number;
|
|
171
|
+
/** What its pods use now; null when not measured. */
|
|
172
|
+
used: number | null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* One namespace with what its running pods request and use: a customer's
|
|
176
|
+
* Project, the platform's own Project, or a namespace of the platform
|
|
177
|
+
* (monitoring, Garage, Kubernetes' own).
|
|
178
|
+
*/
|
|
179
|
+
export interface NamespaceCapacity {
|
|
180
|
+
namespace: string;
|
|
181
|
+
/**
|
|
182
|
+
* The Project the namespace belongs to, with its Account; null for a
|
|
183
|
+
* namespace of the platform, or of a Project whose row is gone.
|
|
184
|
+
* `deletedAt` is set for a deleted Project, listed while it still has
|
|
185
|
+
* pods: the cleanup removes its namespace a few minutes after the
|
|
186
|
+
* delete (decision 188).
|
|
187
|
+
*/
|
|
188
|
+
project: {
|
|
189
|
+
id: Id;
|
|
190
|
+
name: string;
|
|
191
|
+
accountId: Id;
|
|
192
|
+
accountName: string;
|
|
193
|
+
deletedAt: Timestamp | null;
|
|
194
|
+
} | null;
|
|
195
|
+
/** The platform's: its own Project or one of its namespaces. */
|
|
196
|
+
platform: boolean;
|
|
197
|
+
/** Its pods that are scheduled or waiting to be, not those that ended. */
|
|
198
|
+
pods: number;
|
|
199
|
+
cpuMillicores: PodsAmount;
|
|
200
|
+
memoryBytes: PodsAmount;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* How full the installation's nodes are and who fills them, for its admins
|
|
204
|
+
* (`GET /v1/admin/capacity`, decision 183). Requests from Kubernetes, use
|
|
205
|
+
* from the platform's Prometheus. Not what is billed.
|
|
206
|
+
*/
|
|
207
|
+
export interface CapacityReport {
|
|
208
|
+
measuredAt: Timestamp;
|
|
209
|
+
/** Prometheus answered: the `used` figures are filled where it has them. */
|
|
210
|
+
measured: boolean;
|
|
211
|
+
nodes: NodeCapacity[];
|
|
212
|
+
/** Every live Project, with or without pods, each deleted Project with pods, then every other namespace that has pods. */
|
|
213
|
+
namespaces: NamespaceCapacity[];
|
|
214
|
+
/**
|
|
215
|
+
* Per compute Site as the Home site: the most memory a new Database
|
|
216
|
+
* could get now, its standby in another compute Site included, by what
|
|
217
|
+
* the Ready nodes have left to request (decision 151). Disk is not counted.
|
|
218
|
+
*/
|
|
219
|
+
largestDatabase: {
|
|
220
|
+
site: Site;
|
|
221
|
+
memoryBytes: number;
|
|
222
|
+
}[];
|
|
223
|
+
/** The compute Sites with their descriptions, to name the Sites above. */
|
|
224
|
+
sites: SiteInfo[];
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The task "save the key-encryption key" of an installation's admins
|
|
228
|
+
* (decision 180). The key makes the control plane's Database readable and
|
|
229
|
+
* is in no backup.
|
|
230
|
+
*/
|
|
231
|
+
export interface KeyEncryptionKeyTask {
|
|
232
|
+
/** The id of the key the control plane runs with, e.g. `kek-20261128`. */
|
|
233
|
+
id: string;
|
|
234
|
+
/** Who confirmed having saved this key and when; null while the task is open. */
|
|
235
|
+
saved: {
|
|
236
|
+
by: string;
|
|
237
|
+
at: Timestamp;
|
|
238
|
+
} | null;
|
|
239
|
+
}
|
|
240
|
+
/** The key itself, returned only while its task is open. */
|
|
241
|
+
export interface KeyEncryptionKeyCopy {
|
|
242
|
+
id: string;
|
|
243
|
+
/** Base64 of the 32 bytes: the value of `SECRETS_KEK`. */
|
|
244
|
+
key: string;
|
|
245
|
+
/** SHA-256 of `key` in hex, which confirms the copy. */
|
|
246
|
+
sha256: string;
|
|
247
|
+
}
|
|
75
248
|
/** The customer: pays, receives one invoice, owns Projects. */
|
|
76
249
|
export interface Account {
|
|
77
250
|
id: Id;
|
|
@@ -194,6 +367,19 @@ export interface Project {
|
|
|
194
367
|
/** DNS label, unique within the Account. */
|
|
195
368
|
name: string;
|
|
196
369
|
createdAt: Timestamp;
|
|
370
|
+
/**
|
|
371
|
+
* How many Resources of each kind the Project holds (`GET /v1/projects`
|
|
372
|
+
* only); left out for a caller who reaches the Project through a grant
|
|
373
|
+
* alone, who sees nothing else of it (decision 139).
|
|
374
|
+
*/
|
|
375
|
+
resources?: ProjectResources;
|
|
376
|
+
}
|
|
377
|
+
/** A Project's Resources counted per kind; deleted ones do not count. */
|
|
378
|
+
export interface ProjectResources {
|
|
379
|
+
databases: number;
|
|
380
|
+
services: number;
|
|
381
|
+
jobs: number;
|
|
382
|
+
buckets: number;
|
|
197
383
|
}
|
|
198
384
|
/** Postgres always runs with at least this much memory. */
|
|
199
385
|
export declare const DATABASE_MIN_MEMORY_MB = 256;
|
|
@@ -351,7 +537,8 @@ export interface BucketInput {
|
|
|
351
537
|
/**
|
|
352
538
|
* How to reach a Bucket with any S3 client: virtual-hosted style only, at
|
|
353
539
|
* `endpoint` (the Bucket's own hostname), with the Bucket's key. The key
|
|
354
|
-
* reads and writes this Bucket and no other
|
|
540
|
+
* reads and writes this Bucket and no other, and sets its CORS rules
|
|
541
|
+
* (`PutBucketCors`).
|
|
355
542
|
*/
|
|
356
543
|
export interface BucketAccess {
|
|
357
544
|
/** `https://<name>.s3.<customer domain>`. */
|
|
@@ -420,8 +607,56 @@ export interface Service {
|
|
|
420
607
|
homeSite: Site | null;
|
|
421
608
|
/** Whether the image is pulled with registry credentials. */
|
|
422
609
|
registryAuth: boolean;
|
|
610
|
+
/** The Project's Secrets its containers read, by name: each is an environment variable of that name (decision 170). */
|
|
611
|
+
secrets: string[];
|
|
612
|
+
/** Its plain settings, environment variables anyone who may read the Project can see; not for credentials. */
|
|
613
|
+
variables: Record<string, string>;
|
|
614
|
+
/**
|
|
615
|
+
* The Databases of its Project that its containers reach, in its order
|
|
616
|
+
* (decision 173): each as a Postgres role of its own, or as the
|
|
617
|
+
* Database's owner. One that names none gets no `DATABASE_URL` and
|
|
618
|
+
* holds no database password. The first one's URL is also
|
|
619
|
+
* `DATABASE_URL`.
|
|
620
|
+
*/
|
|
621
|
+
databases: NamedDatabase[];
|
|
622
|
+
/**
|
|
623
|
+
* Its pre-deploy Job (decision 173): a Job of its Project that is run,
|
|
624
|
+
* and waited for, before each of its rollouts; null when it has none.
|
|
625
|
+
*/
|
|
626
|
+
preDeployJobId: Id | null;
|
|
627
|
+
/**
|
|
628
|
+
* The pre-deploy run of its latest deploy: `pending` until it is
|
|
629
|
+
* started (it waits for the Job to be ready), `running`, then
|
|
630
|
+
* `succeeded` or `failed`. Unless it succeeded, the Service runs what
|
|
631
|
+
* it ran before. Null when its latest deploy had no pre-deploy Job.
|
|
632
|
+
*/
|
|
633
|
+
preDeploy: {
|
|
634
|
+
state: PreDeployState;
|
|
635
|
+
runId: string | null;
|
|
636
|
+
} | null;
|
|
637
|
+
/**
|
|
638
|
+
* Its own hostname under the customer domain, `<name>-<random>`, when it
|
|
639
|
+
* is public (decision 182): every path there goes to this Service. Null
|
|
640
|
+
* when it is not; it is then served only by Routes of the Project's
|
|
641
|
+
* Domains.
|
|
642
|
+
*/
|
|
643
|
+
publicHostname: string | null;
|
|
423
644
|
createdAt: Timestamp;
|
|
424
645
|
}
|
|
646
|
+
/**
|
|
647
|
+
* Limits of what a Service's or Job's definition names for its containers'
|
|
648
|
+
* environment (decision 170). The values of the Secrets a definition names
|
|
649
|
+
* share one Kubernetes Secret, hence their total.
|
|
650
|
+
*/
|
|
651
|
+
export declare const ENVIRONMENT_LIMITS: {
|
|
652
|
+
readonly maxSecrets: 256;
|
|
653
|
+
readonly maxVariables: 256;
|
|
654
|
+
readonly maxVariableValueBytes: number;
|
|
655
|
+
readonly maxVariablesTotalBytes: number;
|
|
656
|
+
readonly maxNamedSecretsTotalBytes: number;
|
|
657
|
+
};
|
|
658
|
+
/** Names starting with this are the platform's own variables and cannot be a Secret's or a Variable's in a definition. */
|
|
659
|
+
export declare const RESERVED_ENVIRONMENT_PREFIX = "OUP_";
|
|
425
660
|
/** Creates a Service; the tag is resolved to a digest while the request waits. */
|
|
426
661
|
export interface ServiceInput {
|
|
427
662
|
name: string;
|
|
@@ -434,11 +669,23 @@ export interface ServiceInput {
|
|
|
434
669
|
cpuMillicores: number;
|
|
435
670
|
homeSite?: Site;
|
|
436
671
|
registryAuth?: RegistryAuth;
|
|
672
|
+
/** Names of Secrets of the Project; default none. An unknown name is refused. */
|
|
673
|
+
secrets?: string[];
|
|
674
|
+
/** Default none. */
|
|
675
|
+
variables?: Record<string, string>;
|
|
676
|
+
/** The Databases it reaches; default none. An unknown name is refused. */
|
|
677
|
+
databases?: NamedDatabaseInput[];
|
|
678
|
+
/** A Job of the Project to run before each rollout; default none. */
|
|
679
|
+
preDeployJobId?: Id;
|
|
680
|
+
/** Gives it a hostname of its own (`publicHostname`); needs a port. Default false. */
|
|
681
|
+
public?: boolean;
|
|
437
682
|
}
|
|
438
683
|
/**
|
|
439
684
|
* Changes a Service. A new `image` or `registryAuth` resolves the tag again;
|
|
440
685
|
* `registryAuth: null` removes the credentials, `homeSite: null` the choice,
|
|
441
|
-
* `port: null` the port (refused while a Route serves the Service
|
|
686
|
+
* `port: null` the port (refused while a Route serves the Service, or
|
|
687
|
+
* while it is public). `public: false` takes its hostname away; `true`
|
|
688
|
+
* again gives it a new one.
|
|
442
689
|
*/
|
|
443
690
|
export interface ServicePatch {
|
|
444
691
|
image?: string;
|
|
@@ -448,16 +695,59 @@ export interface ServicePatch {
|
|
|
448
695
|
cpuMillicores?: number;
|
|
449
696
|
homeSite?: Site | null;
|
|
450
697
|
registryAuth?: RegistryAuth | null;
|
|
698
|
+
/** Replaces the whole list. */
|
|
699
|
+
secrets?: string[];
|
|
700
|
+
/** Replaces the whole map. */
|
|
701
|
+
variables?: Record<string, string>;
|
|
702
|
+
/** Replaces the whole list. */
|
|
703
|
+
databases?: NamedDatabaseInput[];
|
|
704
|
+
/** Another pre-deploy Job, or null for none. */
|
|
705
|
+
preDeployJobId?: Id | null;
|
|
706
|
+
public?: boolean;
|
|
451
707
|
}
|
|
452
708
|
/**
|
|
453
709
|
* Read live from its Deployment: `deploying` until the first replica is
|
|
454
710
|
* up and while a new version rolls out, `running` with every replica
|
|
455
711
|
* available, `degraded` with some, `unknown` when Kubernetes cannot be asked.
|
|
712
|
+
* Before a rollout of a Service with a pre-deploy Job: `pre-deploy` while
|
|
713
|
+
* that Job's run is waited for, `pre-deploy-failed` when it failed, and
|
|
714
|
+
* the Service then keeps running what it ran before.
|
|
456
715
|
*/
|
|
457
|
-
|
|
716
|
+
/**
|
|
717
|
+
* How a Service or Job reaches a Database it names (decision 173): `own`,
|
|
718
|
+
* as a Postgres role of its own (`svc_<name>`, `job_<name>`) that can
|
|
719
|
+
* connect and nothing else until the Database's owner grants it rights in
|
|
720
|
+
* SQL; `owner`, as the role that owns the Database, for what changes the
|
|
721
|
+
* schema and gives those rights.
|
|
722
|
+
*/
|
|
723
|
+
export declare const DEFINITION_DATABASE_ACCESS: readonly ["own", "owner"];
|
|
724
|
+
export type DefinitionDatabaseAccess = (typeof DEFINITION_DATABASE_ACCESS)[number];
|
|
725
|
+
/** A Database a Service or Job names, by its name. */
|
|
726
|
+
export interface NamedDatabase {
|
|
727
|
+
name: string;
|
|
728
|
+
access: DefinitionDatabaseAccess;
|
|
729
|
+
}
|
|
730
|
+
/** A Database to name: `access` is `own` when left out. */
|
|
731
|
+
export interface NamedDatabaseInput {
|
|
732
|
+
name: string;
|
|
733
|
+
access?: DefinitionDatabaseAccess;
|
|
734
|
+
}
|
|
735
|
+
/** A Service or Job names at most this many Databases. */
|
|
736
|
+
export declare const MAX_NAMED_DATABASES = 16;
|
|
737
|
+
/** The longest name of a Service or Job that can have a role of its own: Postgres's names end at 63, and the role's has a prefix of 4. */
|
|
738
|
+
export declare const MAX_NAME_WITH_OWN_ROLE = 59;
|
|
739
|
+
export type ServiceState = 'pre-deploy' | 'pre-deploy-failed' | 'deploying' | 'running' | 'degraded' | 'unknown';
|
|
740
|
+
/** How the pre-deploy run of a Service's deploy stands. */
|
|
741
|
+
export type PreDeployState = 'pending' | 'running' | 'succeeded' | 'failed';
|
|
458
742
|
/** A Service as the API returns it. */
|
|
459
743
|
export interface ServiceDetails extends Service {
|
|
460
744
|
state: ServiceState;
|
|
745
|
+
/**
|
|
746
|
+
* Those of its `secrets` and `variables` whose value its containers do
|
|
747
|
+
* not get, because the platform sets a variable of that name for the
|
|
748
|
+
* Project's Databases (`DATABASE_URL…`, decision 97) and its value wins.
|
|
749
|
+
*/
|
|
750
|
+
overridden: string[];
|
|
461
751
|
}
|
|
462
752
|
/** Limits of a Job, checked by the API; memory and CPU as for a Service. */
|
|
463
753
|
export declare const JOB_LIMITS: {
|
|
@@ -508,6 +798,12 @@ export interface Job {
|
|
|
508
798
|
homeSite: Site | null;
|
|
509
799
|
/** Whether the image is pulled with registry credentials. */
|
|
510
800
|
registryAuth: boolean;
|
|
801
|
+
/** The Project's Secrets its runs read, by name, as a Service's. */
|
|
802
|
+
secrets: string[];
|
|
803
|
+
/** Its plain settings, as a Service's. A run's own `env` wins over both. */
|
|
804
|
+
variables: Record<string, string>;
|
|
805
|
+
/** The Databases its runs reach, as a Service's. */
|
|
806
|
+
databases: NamedDatabase[];
|
|
511
807
|
createdAt: Timestamp;
|
|
512
808
|
}
|
|
513
809
|
/** Creates a Job; the tag is resolved to a digest while the request waits. */
|
|
@@ -524,6 +820,12 @@ export interface JobInput {
|
|
|
524
820
|
timeZone?: string;
|
|
525
821
|
homeSite?: Site;
|
|
526
822
|
registryAuth?: RegistryAuth;
|
|
823
|
+
/** Names of Secrets of the Project; default none. */
|
|
824
|
+
secrets?: string[];
|
|
825
|
+
/** Default none. */
|
|
826
|
+
variables?: Record<string, string>;
|
|
827
|
+
/** The Databases its runs reach; default none. */
|
|
828
|
+
databases?: NamedDatabaseInput[];
|
|
527
829
|
}
|
|
528
830
|
/**
|
|
529
831
|
* Changes a Job. A new `image` or `registryAuth` resolves the tag again;
|
|
@@ -541,6 +843,12 @@ export interface JobPatch {
|
|
|
541
843
|
timeZone?: string | null;
|
|
542
844
|
homeSite?: Site | null;
|
|
543
845
|
registryAuth?: RegistryAuth | null;
|
|
846
|
+
/** Replaces the whole list. */
|
|
847
|
+
secrets?: string[];
|
|
848
|
+
/** Replaces the whole map. */
|
|
849
|
+
variables?: Record<string, string>;
|
|
850
|
+
/** Replaces the whole list. */
|
|
851
|
+
databases?: NamedDatabaseInput[];
|
|
544
852
|
}
|
|
545
853
|
/**
|
|
546
854
|
* Read live from its CronJob: `deploying` until the Jobs operator has
|
|
@@ -551,6 +859,8 @@ export type JobState = 'deploying' | 'ready' | 'unknown';
|
|
|
551
859
|
/** A Job as the API returns it. */
|
|
552
860
|
export interface JobDetails extends Job {
|
|
553
861
|
state: JobState;
|
|
862
|
+
/** Those of its `secrets` and `variables` that the platform's own variables override, as a Service's. */
|
|
863
|
+
overridden: string[];
|
|
554
864
|
}
|
|
555
865
|
/**
|
|
556
866
|
* Read live from its Kubernetes Job: `pending` until its container runs
|
|
@@ -632,12 +942,12 @@ export interface LogQuery {
|
|
|
632
942
|
/** A Secret's name is an environment variable name (the schema checks the same). */
|
|
633
943
|
export declare const SECRET_NAME: RegExp;
|
|
634
944
|
/**
|
|
635
|
-
* At most this many bytes (UTF-8) per value
|
|
636
|
-
* together
|
|
637
|
-
* Secret (1 MiB at most) and into every container's environment.
|
|
945
|
+
* At most this many bytes (UTF-8) per value. The values one Service or Job
|
|
946
|
+
* names together are limited by ENVIRONMENT_LIMITS.maxNamedSecretsTotalBytes.
|
|
638
947
|
*/
|
|
639
948
|
export declare const SECRET_VALUE_MAX_BYTES: number;
|
|
640
|
-
|
|
949
|
+
/** At most this many Secrets per Project: what bounds a Project's Secrets, since no limit is on their size together. */
|
|
950
|
+
export declare const SECRETS_MAX_PER_PROJECT = 1000;
|
|
641
951
|
/**
|
|
642
952
|
* A Secret's value is write-only: the API accepts it and hands it to the
|
|
643
953
|
* Project's Services and jobs as an environment variable, but never returns it.
|
|
@@ -649,11 +959,109 @@ export interface Secret {
|
|
|
649
959
|
name: string;
|
|
650
960
|
createdAt: Timestamp;
|
|
651
961
|
updatedAt: Timestamp;
|
|
962
|
+
/** The Services and Jobs that name it: only their containers get it, and a change restarts those Services. Empty: unused. */
|
|
963
|
+
usedBy: {
|
|
964
|
+
kind: 'service' | 'job';
|
|
965
|
+
id: Id;
|
|
966
|
+
name: string;
|
|
967
|
+
}[];
|
|
652
968
|
}
|
|
653
969
|
export interface SecretInput {
|
|
654
970
|
name: string;
|
|
655
971
|
value: string;
|
|
656
972
|
}
|
|
973
|
+
/** Limits of Keys (ARCHITECTURE.md, decision 167). */
|
|
974
|
+
export declare const KEY_LIMITS: {
|
|
975
|
+
/** Keys per Project, those pending deletion included. */
|
|
976
|
+
readonly maxPerProject: 20;
|
|
977
|
+
/** How long a deleted Key refuses every call and can still be restored, before it is erased. */
|
|
978
|
+
readonly deletionDays: 7;
|
|
979
|
+
/** Versions of one Key: every one is kept for the Key's life, so `rotate` is refused above this. */
|
|
980
|
+
readonly maxVersions: 1000;
|
|
981
|
+
};
|
|
982
|
+
/** Limits of one call of the key API (decision 167). */
|
|
983
|
+
export declare const KEY_CALL_LIMITS: {
|
|
984
|
+
/** A plaintext, decoded: larger data is encrypted with a key of the customer's own, which is encrypted with the Key. */
|
|
985
|
+
readonly maxPlaintextBytes: 4096;
|
|
986
|
+
readonly maxContextEntries: 16;
|
|
987
|
+
/** A context's names and values together, as UTF-8. */
|
|
988
|
+
readonly maxContextBytes: 1024;
|
|
989
|
+
/** A request's body. */
|
|
990
|
+
readonly maxBodyBytes: number;
|
|
991
|
+
/** How long a call's record is kept (decision 169). */
|
|
992
|
+
readonly retentionDays: 30;
|
|
993
|
+
/** Records one listing returns at most, and by default. */
|
|
994
|
+
readonly maxListed: 1000;
|
|
995
|
+
readonly defaultListed: 100;
|
|
996
|
+
};
|
|
997
|
+
/**
|
|
998
|
+
* One call of the key API as its record has it (decision 169): who used the
|
|
999
|
+
* Key, for what and how it ended. Never a plaintext or a ciphertext.
|
|
1000
|
+
*/
|
|
1001
|
+
export interface KeyCall {
|
|
1002
|
+
/** Grows with time; the `before` of the next page. */
|
|
1003
|
+
id: string;
|
|
1004
|
+
at: Timestamp;
|
|
1005
|
+
holder: 'service' | 'job';
|
|
1006
|
+
holderId: Id;
|
|
1007
|
+
/** The Service's or Job's name when it called; null if it could not be read. */
|
|
1008
|
+
holderName: string | null;
|
|
1009
|
+
operation: 'encrypt' | 'decrypt';
|
|
1010
|
+
/**
|
|
1011
|
+
* `ok`; `forbidden` (no grant for the operation); `pending-deletion`;
|
|
1012
|
+
* `invalid` (a body that is no such request); `cannot-decrypt` (another
|
|
1013
|
+
* context, another Key or a changed ciphertext); `rate-limited` (calls
|
|
1014
|
+
* above the limit, one record per minute with their number in `calls`).
|
|
1015
|
+
*/
|
|
1016
|
+
outcome: 'ok' | 'forbidden' | 'pending-deletion' | 'invalid' | 'cannot-decrypt' | 'rate-limited';
|
|
1017
|
+
/** The Key's version that encrypted or was asked to decrypt; null when the call did not get that far. */
|
|
1018
|
+
version: number | null;
|
|
1019
|
+
/** 1, or for `rate-limited` how many calls the record stands for. */
|
|
1020
|
+
calls: number;
|
|
1021
|
+
/** The context as sent, which is not secret and is stored; null when none could be read. */
|
|
1022
|
+
context: Record<string, string> | null;
|
|
1023
|
+
}
|
|
1024
|
+
/** What a grant on a Key allows. Not ordered: `encrypt` does not include `decrypt`, nor the reverse. */
|
|
1025
|
+
export declare const KEY_ACCESS: readonly ["encrypt", "decrypt", "both"];
|
|
1026
|
+
export type KeyAccess = (typeof KEY_ACCESS)[number];
|
|
1027
|
+
/** A Service's or a Job's grant on a Key (decision 168): its pods may call the key API for that Key. */
|
|
1028
|
+
export interface KeyGrant {
|
|
1029
|
+
holder: 'service' | 'job';
|
|
1030
|
+
/** The Service's or Job's id. */
|
|
1031
|
+
id: Id;
|
|
1032
|
+
name: string;
|
|
1033
|
+
access: KeyAccess;
|
|
1034
|
+
createdAt: Timestamp;
|
|
1035
|
+
}
|
|
1036
|
+
export interface KeyGrantInput {
|
|
1037
|
+
access: KeyAccess;
|
|
1038
|
+
}
|
|
1039
|
+
/** `active`, or `pending-deletion` from its delete until it is erased or restored. */
|
|
1040
|
+
export type KeyState = 'active' | 'pending-deletion';
|
|
1041
|
+
/**
|
|
1042
|
+
* An encryption key of a Project that never leaves the platform
|
|
1043
|
+
* (ARCHITECTURE.md, "Keys"): the API creates, rotates and deletes it and
|
|
1044
|
+
* never returns its material.
|
|
1045
|
+
*/
|
|
1046
|
+
export interface Key {
|
|
1047
|
+
id: Id;
|
|
1048
|
+
projectId: Id;
|
|
1049
|
+
/** DNS label, unique within the Project, also while the Key is pending deletion. */
|
|
1050
|
+
name: string;
|
|
1051
|
+
/** The newest version, which encrypting uses; `rotate` adds one, and older ones keep decrypting. */
|
|
1052
|
+
version: number;
|
|
1053
|
+
state: KeyState;
|
|
1054
|
+
/** When a Key pending deletion is erased, and what it encrypted becomes unreadable; null while it is active. */
|
|
1055
|
+
deletesAt: Timestamp | null;
|
|
1056
|
+
createdAt: Timestamp;
|
|
1057
|
+
/** When the newest version was added: at creation, then at each rotation. */
|
|
1058
|
+
rotatedAt: Timestamp;
|
|
1059
|
+
/** The Services and Jobs of the Project that may use it, by name. */
|
|
1060
|
+
grants: KeyGrant[];
|
|
1061
|
+
}
|
|
1062
|
+
export interface KeyInput {
|
|
1063
|
+
name: string;
|
|
1064
|
+
}
|
|
657
1065
|
/**
|
|
658
1066
|
* Where `oup login` signs in (`GET /v1/login`, no token needed): madAuth's
|
|
659
1067
|
* issuer and the CLI's client ID there, for the device authorization grant.
|