@aperture-browser/control-api 0.0.0-init.0 → 0.0.0-nightly.148.08402157055a
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/LICENSE +21 -0
- package/README.md +35 -1
- package/dist/api-EoqsY4JE.js +1083 -0
- package/dist/api-EoqsY4JE.js.map +1 -0
- package/dist/api-mf9iSwea.d.ts +2227 -0
- package/dist/client.d.ts +859 -0
- package/dist/client.js +18 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +166 -0
- package/dist/errors.js +90 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/package.json +45 -5
|
@@ -0,0 +1,1083 @@
|
|
|
1
|
+
import { AccountInUse, AccountInvalid, AccountNotFound, ApiTokenNotFound, EmailTaken, FileLinkInvalid, Forbidden, GrantNotFound, NoNode, NodeNotFound, NodeRefused, NodeUnreachable, OAuthClientNotFound, PersonNotFound, ProviderConfigured, ProviderInvalid, ProviderNotFound, ProviderTaken, RedirectRefused, RegistrationTokenNotFound, SessionHasNoNode, SessionNotFound, ShareNotFound, SnapshotNotFound, Unauthorized, WorkspaceInUse, WorkspaceNotFound } from "./errors.js";
|
|
2
|
+
import * as Context from "effect/Context";
|
|
3
|
+
import * as HttpApi from "effect/http-api/HttpApi";
|
|
4
|
+
import * as HttpApiEndpoint from "effect/http-api/HttpApiEndpoint";
|
|
5
|
+
import * as HttpApiGroup from "effect/http-api/HttpApiGroup";
|
|
6
|
+
import * as HttpApiMiddleware from "effect/http-api/HttpApiMiddleware";
|
|
7
|
+
import * as HttpApiSchema from "effect/http-api/HttpApiSchema";
|
|
8
|
+
import * as HttpApiSecurity from "effect/http-api/HttpApiSecurity";
|
|
9
|
+
import * as OpenApi from "effect/http-api/OpenApi";
|
|
10
|
+
import * as Schema from "effect/Schema";
|
|
11
|
+
//#region package.json
|
|
12
|
+
var version = "0.0.0-nightly.148.08402157055a";
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/schemas.ts
|
|
15
|
+
/** What a node's executor says its sessions may have, in the words of the glossary. */
|
|
16
|
+
const Offers = Schema.Struct({
|
|
17
|
+
version: Schema.String,
|
|
18
|
+
features: Schema.Array(Schema.String),
|
|
19
|
+
network: Schema.Struct({
|
|
20
|
+
tcp: Schema.String,
|
|
21
|
+
udp: Schema.String
|
|
22
|
+
}),
|
|
23
|
+
/** The limits of a session that has none of its own; one that is left out is not held. */
|
|
24
|
+
limits: Schema.Struct({
|
|
25
|
+
memoryBytes: Schema.optional(Schema.Number),
|
|
26
|
+
swapBytes: Schema.optional(Schema.Number),
|
|
27
|
+
cpus: Schema.optional(Schema.Number),
|
|
28
|
+
tasks: Schema.optional(Schema.Number),
|
|
29
|
+
suspendIdleAfterSeconds: Schema.optional(Schema.Number)
|
|
30
|
+
}),
|
|
31
|
+
holdsResources: Schema.Boolean,
|
|
32
|
+
/** Whether its snapshots are kept where other nodes find them. */
|
|
33
|
+
sharesSnapshots: Schema.Boolean
|
|
34
|
+
});
|
|
35
|
+
/** What whoever owns the session asked it to be. */
|
|
36
|
+
const DesiredState = Schema.Literals(["running", "suspended"]);
|
|
37
|
+
/**
|
|
38
|
+
* What the session's node last said it is. `gone` is a session its node has no more
|
|
39
|
+
* though nobody asked the control plane to delete it.
|
|
40
|
+
*/
|
|
41
|
+
const ObservedState = Schema.Literals([
|
|
42
|
+
"suspended",
|
|
43
|
+
"starting",
|
|
44
|
+
"running",
|
|
45
|
+
"suspending",
|
|
46
|
+
"failed",
|
|
47
|
+
"gone"
|
|
48
|
+
]);
|
|
49
|
+
/** The areas of a session a ticket gives access to, each read, written or both. */
|
|
50
|
+
const Access = Schema.Record(Schema.Literals([
|
|
51
|
+
"input",
|
|
52
|
+
"tabs",
|
|
53
|
+
"lease",
|
|
54
|
+
"sound",
|
|
55
|
+
"clipboard",
|
|
56
|
+
"uploads",
|
|
57
|
+
"downloads",
|
|
58
|
+
"recordings",
|
|
59
|
+
"proxy",
|
|
60
|
+
"mcp",
|
|
61
|
+
"cdp",
|
|
62
|
+
"tunnel"
|
|
63
|
+
]), Schema.optional(Schema.Literals([
|
|
64
|
+
"r",
|
|
65
|
+
"w",
|
|
66
|
+
"rw"
|
|
67
|
+
])));
|
|
68
|
+
/**
|
|
69
|
+
* What a share link lets a guest do in its session: watch it, or control it as well, which
|
|
70
|
+
* is giving input, opening and closing tabs, taking a tab, the clipboard and the sound.
|
|
71
|
+
*/
|
|
72
|
+
const ShareRole = Schema.Literals(["watch", "control"]);
|
|
73
|
+
/**
|
|
74
|
+
* How a session's browser connections are routed. The first rule that matches a
|
|
75
|
+
* connection decides; one no rule matches is made from the session's node.
|
|
76
|
+
*/
|
|
77
|
+
const ProxyConfig = Schema.Struct({
|
|
78
|
+
/** The upstreams rules can route through, by name. */
|
|
79
|
+
upstreams: Schema.optional(Schema.Record(Schema.NonEmptyString, Schema.Struct({
|
|
80
|
+
/** A proxy, with its credentials in the URL: `socks5://`, `http://`, `https://`. */
|
|
81
|
+
url: Schema.NonEmptyString,
|
|
82
|
+
/** The secret a tunnel is dialed with. */
|
|
83
|
+
auth: Schema.optional(Schema.String)
|
|
84
|
+
}))),
|
|
85
|
+
rules: Schema.Array(Schema.Struct({
|
|
86
|
+
/**
|
|
87
|
+
* `host` or `host:port`; the host is a name, `*.suffix`, `*` for any, an address or
|
|
88
|
+
* a network (`10.0.0.0/8`). What is IPv6 takes a port in brackets: `[::1]:443`.
|
|
89
|
+
*/
|
|
90
|
+
match: Schema.NonEmptyString,
|
|
91
|
+
/** `direct`, `refuse`, `local`, an upstream's name, or a proxy's URL. */
|
|
92
|
+
via: Schema.NonEmptyString,
|
|
93
|
+
to: Schema.optional(Schema.String),
|
|
94
|
+
tls: Schema.optional(Schema.Boolean)
|
|
95
|
+
}))
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* What an API token is held to: it does what its scopes name and nothing else. Writing
|
|
99
|
+
* something includes reading it. `sessions:read` sees sessions and watches them, and
|
|
100
|
+
* `sessions:write` does everything else in one; `workspaces:read` tells which workspaces
|
|
101
|
+
* its account is in and who else is; `events:read` reads the events of its account and of
|
|
102
|
+
* the workspaces that is in, and `admin` is what an admin's token keeps an admin's with.
|
|
103
|
+
*/
|
|
104
|
+
const Scope = Schema.Literals([
|
|
105
|
+
"sessions:read",
|
|
106
|
+
"sessions:write",
|
|
107
|
+
"snapshots:read",
|
|
108
|
+
"snapshots:write",
|
|
109
|
+
"workspaces:read",
|
|
110
|
+
"workspaces:write",
|
|
111
|
+
"tokens:write",
|
|
112
|
+
"events:read",
|
|
113
|
+
"admin"
|
|
114
|
+
]);
|
|
115
|
+
/** Whether scopes cover one that is asked for; no scopes at all cover everything. */
|
|
116
|
+
const covers = (held, asked) => held === null || held.includes(asked) || asked.endsWith(":read") && held.includes(asked.replace(":read", ":write"));
|
|
117
|
+
/**
|
|
118
|
+
* What an API token is held to besides its scopes: with resources it reaches only the
|
|
119
|
+
* sessions and snapshots that are named, and those of the workspaces that are named.
|
|
120
|
+
*/
|
|
121
|
+
const TokenResources = Schema.Struct({
|
|
122
|
+
workspaces: Schema.Array(Schema.String),
|
|
123
|
+
sessions: Schema.Array(Schema.String),
|
|
124
|
+
snapshots: Schema.Array(Schema.String)
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* What an event says was done. The set is closed: what reads events knows every kind
|
|
128
|
+
* there is, and a new one is added here.
|
|
129
|
+
*/
|
|
130
|
+
const EventKind = Schema.Literals([
|
|
131
|
+
"sign_in.succeeded",
|
|
132
|
+
"sign_in.failed",
|
|
133
|
+
"account.created",
|
|
134
|
+
"account.changed",
|
|
135
|
+
"account.disabled",
|
|
136
|
+
"account.enabled",
|
|
137
|
+
"account.removed",
|
|
138
|
+
"account.setup_link_made",
|
|
139
|
+
"account.second_factor_reset",
|
|
140
|
+
"account.passkeys_removed",
|
|
141
|
+
"token.created",
|
|
142
|
+
"token.revoked",
|
|
143
|
+
"grant.given",
|
|
144
|
+
"grant.revoked",
|
|
145
|
+
"registration_token.created",
|
|
146
|
+
"registration_token.revoked",
|
|
147
|
+
"workspace.created",
|
|
148
|
+
"workspace.renamed",
|
|
149
|
+
"workspace.deleted",
|
|
150
|
+
"workspace.member_admitted",
|
|
151
|
+
"workspace.member_dismissed",
|
|
152
|
+
"session.created",
|
|
153
|
+
"session.suspended",
|
|
154
|
+
"session.resumed",
|
|
155
|
+
"session.deleted",
|
|
156
|
+
"snapshot.taken",
|
|
157
|
+
"snapshot.replaced",
|
|
158
|
+
"snapshot.deleted",
|
|
159
|
+
"share.created",
|
|
160
|
+
"share.revoked",
|
|
161
|
+
"share.joined",
|
|
162
|
+
"node.registered",
|
|
163
|
+
"node.refused",
|
|
164
|
+
"node.released",
|
|
165
|
+
"node.silent",
|
|
166
|
+
"provider.added",
|
|
167
|
+
"provider.changed",
|
|
168
|
+
"provider.enabled",
|
|
169
|
+
"provider.disabled",
|
|
170
|
+
"provider.removed"
|
|
171
|
+
]);
|
|
172
|
+
/**
|
|
173
|
+
* Who did what an event says: an account, the guest of a share link, the holder of the
|
|
174
|
+
* bootstrap token, someone who is not known, as whoever failed to sign in, or the control
|
|
175
|
+
* plane by itself.
|
|
176
|
+
*/
|
|
177
|
+
const EventActor = Schema.Struct({
|
|
178
|
+
kind: Schema.Literals([
|
|
179
|
+
"account",
|
|
180
|
+
"guest",
|
|
181
|
+
"bootstrap",
|
|
182
|
+
"anonymous",
|
|
183
|
+
"system"
|
|
184
|
+
]),
|
|
185
|
+
/** An account's id, or `share:<id>` for a guest; none for the others. */
|
|
186
|
+
id: Schema.NullOr(Schema.String),
|
|
187
|
+
/** What they were called then. */
|
|
188
|
+
name: Schema.NullOr(Schema.String)
|
|
189
|
+
});
|
|
190
|
+
/** What an event is about, as it was called then: it may be gone, or called otherwise, since. */
|
|
191
|
+
const EventResource = Schema.Struct({
|
|
192
|
+
kind: Schema.Literals([
|
|
193
|
+
"account",
|
|
194
|
+
"token",
|
|
195
|
+
"grant",
|
|
196
|
+
"registration_token",
|
|
197
|
+
"workspace",
|
|
198
|
+
"session",
|
|
199
|
+
"snapshot",
|
|
200
|
+
"share",
|
|
201
|
+
"node",
|
|
202
|
+
"provider"
|
|
203
|
+
]),
|
|
204
|
+
id: Schema.String,
|
|
205
|
+
label: Schema.NullOr(Schema.String)
|
|
206
|
+
});
|
|
207
|
+
/** What else an event of its kind says, in a few plain values. Never a secret. */
|
|
208
|
+
const EventDetail = Schema.Record(Schema.String, Schema.Union([
|
|
209
|
+
Schema.String,
|
|
210
|
+
Schema.Number,
|
|
211
|
+
Schema.Boolean,
|
|
212
|
+
Schema.Null,
|
|
213
|
+
Schema.Array(Schema.String)
|
|
214
|
+
]));
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/api.ts
|
|
217
|
+
/** Where the control plane's API is, apart from the routes of sessions and of nodes. */
|
|
218
|
+
const PREFIX = "/api/control";
|
|
219
|
+
const WorkspaceRole = Schema.Literals(["member", "admin"]);
|
|
220
|
+
const Account = Schema.Struct({
|
|
221
|
+
id: Schema.String,
|
|
222
|
+
name: Schema.String,
|
|
223
|
+
admin: Schema.Boolean,
|
|
224
|
+
/** A person, who signs in, or a service, which comes with API tokens alone. */
|
|
225
|
+
kind: Schema.Literals(["person", "service"]),
|
|
226
|
+
/** The address a person signs in with; none for a service. */
|
|
227
|
+
email: Schema.NullOr(Schema.String),
|
|
228
|
+
createdAt: Schema.DateTimeUtcFromString,
|
|
229
|
+
/** Since when it is disabled: nothing of it signs in or is taken as a caller. */
|
|
230
|
+
disabledAt: Schema.NullOr(Schema.DateTimeUtcFromString)
|
|
231
|
+
});
|
|
232
|
+
/**
|
|
233
|
+
* The account a caller is, with what the caller itself may do as it: what the token it came
|
|
234
|
+
* with is held to. Whoever signed in with cookies is held to nothing.
|
|
235
|
+
*/
|
|
236
|
+
const CurrentAccount = Schema.Struct({
|
|
237
|
+
...Account.fields,
|
|
238
|
+
/** What the caller is held to; none for one that does whatever its account does. */
|
|
239
|
+
scopes: Schema.NullOr(Schema.Array(Scope)),
|
|
240
|
+
/** The resources the caller is held to; none for one that reaches all its account does. */
|
|
241
|
+
resources: Schema.NullOr(TokenResources)
|
|
242
|
+
});
|
|
243
|
+
/** What a person signs in with. */
|
|
244
|
+
const SignInMethods = Schema.Struct({
|
|
245
|
+
/** Whether they have a password: one they set, since nobody is given one. */
|
|
246
|
+
password: Schema.Boolean,
|
|
247
|
+
secondFactor: Schema.Boolean,
|
|
248
|
+
/** How many passkeys they added. */
|
|
249
|
+
passkeys: Schema.Number,
|
|
250
|
+
/** The providers they came through, by what each is called. */
|
|
251
|
+
providers: Schema.Array(Schema.String)
|
|
252
|
+
});
|
|
253
|
+
/** An account as an admin is told of it: with what its person signs in with, for a person's. */
|
|
254
|
+
const ListedAccount = Schema.Struct({
|
|
255
|
+
...Account.fields,
|
|
256
|
+
signIn: Schema.NullOr(SignInMethods)
|
|
257
|
+
});
|
|
258
|
+
/** A workspace as its caller has it: `role` is none for an admin who is no member. */
|
|
259
|
+
const Workspace = Schema.Struct({
|
|
260
|
+
id: Schema.String,
|
|
261
|
+
name: Schema.String,
|
|
262
|
+
createdAt: Schema.DateTimeUtcFromString,
|
|
263
|
+
role: Schema.NullOr(WorkspaceRole)
|
|
264
|
+
});
|
|
265
|
+
/** A workspace an account is in, with what the account does there. */
|
|
266
|
+
const AccountWorkspace = Schema.Struct({
|
|
267
|
+
...Workspace.fields,
|
|
268
|
+
role: WorkspaceRole
|
|
269
|
+
});
|
|
270
|
+
const WorkspaceMember = Schema.Struct({
|
|
271
|
+
accountId: Schema.String,
|
|
272
|
+
name: Schema.String,
|
|
273
|
+
kind: Account.fields.kind,
|
|
274
|
+
/** The address a person signs in with; none for a service. */
|
|
275
|
+
email: Account.fields.email,
|
|
276
|
+
role: WorkspaceRole
|
|
277
|
+
});
|
|
278
|
+
/** A person's account as whoever asked for it by its address is told of it. */
|
|
279
|
+
const AccountLookup = Schema.Struct({
|
|
280
|
+
id: Schema.String,
|
|
281
|
+
name: Schema.String,
|
|
282
|
+
email: Schema.String
|
|
283
|
+
});
|
|
284
|
+
/** An API token as its account sees it: never the token. */
|
|
285
|
+
const ApiToken = Schema.Struct({
|
|
286
|
+
id: Schema.String,
|
|
287
|
+
accountId: Schema.String,
|
|
288
|
+
name: Schema.String,
|
|
289
|
+
createdAt: Schema.DateTimeUtcFromString,
|
|
290
|
+
expiresAt: Schema.NullOr(Schema.DateTimeUtcFromString),
|
|
291
|
+
revokedAt: Schema.NullOr(Schema.DateTimeUtcFromString),
|
|
292
|
+
/** What it is held to. */
|
|
293
|
+
scopes: Schema.Array(Scope),
|
|
294
|
+
/** The resources it is held to; none for a token that reaches all its account does. */
|
|
295
|
+
resources: Schema.NullOr(TokenResources)
|
|
296
|
+
});
|
|
297
|
+
/** A token as it is told once, when it is made. */
|
|
298
|
+
const ApiTokenCreated = Schema.Struct({
|
|
299
|
+
...ApiToken.fields,
|
|
300
|
+
token: Schema.String
|
|
301
|
+
});
|
|
302
|
+
const NewApiToken = Schema.Struct({
|
|
303
|
+
name: Schema.NonEmptyString,
|
|
304
|
+
/** How many days it is good for; for as long as it is not taken back, without. */
|
|
305
|
+
/** What it does: a token is made for something, and does nothing else. */
|
|
306
|
+
scopes: Schema.NonEmptyArray(Scope),
|
|
307
|
+
/** The resources it is held to; all that its account reaches, without. */
|
|
308
|
+
resources: Schema.optional(TokenResources),
|
|
309
|
+
expiresInDays: Schema.optional(Schema.Int.check(Schema.isBetween({
|
|
310
|
+
minimum: 1,
|
|
311
|
+
maximum: 3650
|
|
312
|
+
})))
|
|
313
|
+
});
|
|
314
|
+
const RegistrationToken = Schema.Struct({
|
|
315
|
+
id: Schema.String,
|
|
316
|
+
name: Schema.String,
|
|
317
|
+
createdAt: Schema.DateTimeUtcFromString,
|
|
318
|
+
/** Since when it registers no new node; the nodes that registered with it stay. */
|
|
319
|
+
revokedAt: Schema.NullOr(Schema.DateTimeUtcFromString)
|
|
320
|
+
});
|
|
321
|
+
const RegistrationTokenCreated = Schema.Struct({
|
|
322
|
+
...RegistrationToken.fields,
|
|
323
|
+
token: Schema.String
|
|
324
|
+
});
|
|
325
|
+
/** A node as its admin sees it: without the operator token. */
|
|
326
|
+
const Node = Schema.Struct({
|
|
327
|
+
id: Schema.String,
|
|
328
|
+
name: Schema.String,
|
|
329
|
+
internalUrl: Schema.String,
|
|
330
|
+
balancerUrl: Schema.NullOr(Schema.String),
|
|
331
|
+
publicUrl: Schema.NullOr(Schema.String),
|
|
332
|
+
offers: Schema.NullOr(Offers),
|
|
333
|
+
registeredAt: Schema.DateTimeUtcFromString,
|
|
334
|
+
lastSeenAt: Schema.DateTimeUtcFromString,
|
|
335
|
+
/** Whether its last keepalive is recent enough for it to be used. */
|
|
336
|
+
alive: Schema.Boolean
|
|
337
|
+
});
|
|
338
|
+
const Session = Schema.Struct({
|
|
339
|
+
id: Schema.String,
|
|
340
|
+
/**
|
|
341
|
+
* The account that made it. A session of no workspace is that account's own; one of a
|
|
342
|
+
* workspace is the workspace's, and names none where nobody is known to have made it
|
|
343
|
+
* or the account was removed since.
|
|
344
|
+
*/
|
|
345
|
+
accountId: Schema.NullOr(Schema.String),
|
|
346
|
+
workspaceId: Schema.NullOr(Schema.String),
|
|
347
|
+
nodeId: Schema.NullOr(Schema.String),
|
|
348
|
+
/** What the node it is on is called; none for a session on no node. */
|
|
349
|
+
nodeName: Schema.NullOr(Schema.String),
|
|
350
|
+
desiredState: DesiredState,
|
|
351
|
+
observedState: ObservedState,
|
|
352
|
+
failure: Schema.NullOr(Schema.String),
|
|
353
|
+
unreachableSince: Schema.NullOr(Schema.DateTimeUtcFromString),
|
|
354
|
+
snapshotId: Schema.NullOr(Schema.String),
|
|
355
|
+
label: Schema.NullOr(Schema.String),
|
|
356
|
+
tags: Schema.Record(Schema.String, Schema.String),
|
|
357
|
+
createdAt: Schema.DateTimeUtcFromString,
|
|
358
|
+
observedAt: Schema.DateTimeUtcFromString,
|
|
359
|
+
/**
|
|
360
|
+
* Where the session is reached through a proxy before the nodes, below the proxy's own
|
|
361
|
+
* address; none for a session on no node. It changes when the session moves.
|
|
362
|
+
*/
|
|
363
|
+
path: Schema.NullOr(Schema.String)
|
|
364
|
+
});
|
|
365
|
+
const Snapshot = Schema.Struct({
|
|
366
|
+
id: Schema.String,
|
|
367
|
+
/** The account that made it, as a session's is. */
|
|
368
|
+
accountId: Schema.NullOr(Schema.String),
|
|
369
|
+
workspaceId: Schema.NullOr(Schema.String),
|
|
370
|
+
name: Schema.NullOr(Schema.String),
|
|
371
|
+
description: Schema.NullOr(Schema.String),
|
|
372
|
+
tags: Schema.Record(Schema.String, Schema.String),
|
|
373
|
+
sessionId: Schema.NullOr(Schema.String),
|
|
374
|
+
nodeId: Schema.NullOr(Schema.String),
|
|
375
|
+
shared: Schema.Boolean,
|
|
376
|
+
createdAt: Schema.DateTimeUtcFromString
|
|
377
|
+
});
|
|
378
|
+
/** What a person gave an app that asked to act as their account. */
|
|
379
|
+
const Grant = Schema.Struct({
|
|
380
|
+
id: Schema.String,
|
|
381
|
+
accountId: Schema.String,
|
|
382
|
+
clientId: Schema.String,
|
|
383
|
+
clientName: Schema.String,
|
|
384
|
+
scopes: Schema.Array(Scope),
|
|
385
|
+
/** The resources it is held to; none for a grant that reaches all its account does. */
|
|
386
|
+
resources: Schema.NullOr(TokenResources),
|
|
387
|
+
createdAt: Schema.DateTimeUtcFromString
|
|
388
|
+
});
|
|
389
|
+
/** A provider people sign in through, as the page that signs them in names it. */
|
|
390
|
+
const Provider = Schema.Struct({
|
|
391
|
+
/** What it is known by in addresses. */
|
|
392
|
+
id: Schema.String,
|
|
393
|
+
name: Schema.String,
|
|
394
|
+
/** Which provider's mark it is shown with, as whoever added it said; none said, without. */
|
|
395
|
+
icon: Schema.NullOr(Schema.String)
|
|
396
|
+
});
|
|
397
|
+
/** What a provider is known by: a part of the address it sends people back to. */
|
|
398
|
+
const ProviderId = Schema.String.check(Schema.isPattern(/^(?!credential$)[a-z0-9][a-z0-9-]{0,39}$/u));
|
|
399
|
+
/**
|
|
400
|
+
* Which provider's mark one is shown with, by what that provider is known as among those
|
|
401
|
+
* the console draws: `github`, `google`. One it does not draw is shown with no mark of
|
|
402
|
+
* any provider's; it is for whoever shows providers, and nothing is done by it.
|
|
403
|
+
*/
|
|
404
|
+
const ProviderIcon = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9-]{0,39}$/u));
|
|
405
|
+
/** What is asked of a provider for the people it signs in, each a word of its own. */
|
|
406
|
+
const ProviderScopes = Schema.Array(Schema.String.check(Schema.isPattern(/^[\x21\x23-\x5b\x5d-\x7e]+$/u)));
|
|
407
|
+
/** The domains of email addresses, as `example.com`. */
|
|
408
|
+
const ProviderDomains = Schema.Array(Schema.String.check(Schema.isPattern(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/iu)));
|
|
409
|
+
/**
|
|
410
|
+
* What a provider speaks: OpenID Connect, whose signed token says who someone is, or OAuth
|
|
411
|
+
* 2.0 alone, where that is asked of the provider with the token it gave.
|
|
412
|
+
*/
|
|
413
|
+
const ProviderKind = Schema.Literals(["oidc", "oauth2"]);
|
|
414
|
+
/**
|
|
415
|
+
* Where a provider that speaks OAuth 2.0 alone is asked: where people are sent, where what
|
|
416
|
+
* they come back with is exchanged for a token, and where the token tells who they are,
|
|
417
|
+
* which is a document with their `id` or `sub`, and their `email` with `email_verified`.
|
|
418
|
+
* Where it lists their addresses apart as GitHub does, each with `primary` and `verified`,
|
|
419
|
+
* the one that is theirs first is taken from there. Nobody signs in on an address the
|
|
420
|
+
* provider does not say it verified.
|
|
421
|
+
*/
|
|
422
|
+
const ProviderEndpoints = Schema.Struct({
|
|
423
|
+
authorization: Schema.String,
|
|
424
|
+
token: Schema.String,
|
|
425
|
+
userInfo: Schema.String,
|
|
426
|
+
emails: Schema.NullOr(Schema.String)
|
|
427
|
+
});
|
|
428
|
+
const GivenProviderEndpoints = Schema.Struct({
|
|
429
|
+
authorization: Schema.NonEmptyString,
|
|
430
|
+
token: Schema.NonEmptyString,
|
|
431
|
+
userInfo: Schema.NonEmptyString,
|
|
432
|
+
/** None, where it is left out or empty. */
|
|
433
|
+
emails: Schema.optional(Schema.NullOr(Schema.String))
|
|
434
|
+
});
|
|
435
|
+
/**
|
|
436
|
+
* A provider as an admin is told of it: all that was said of it but its client secret,
|
|
437
|
+
* of which only whether there is one is told.
|
|
438
|
+
*/
|
|
439
|
+
const SignInProvider = Schema.Struct({
|
|
440
|
+
id: Schema.String,
|
|
441
|
+
name: Schema.String,
|
|
442
|
+
/** Which provider's mark it is shown with; none said, for one the settings name. */
|
|
443
|
+
icon: Schema.NullOr(Schema.String),
|
|
444
|
+
kind: ProviderKind,
|
|
445
|
+
/**
|
|
446
|
+
* Its issuer, or its discovery document where that was given in place of it; nothing
|
|
447
|
+
* for one that speaks OAuth 2.0 alone, which has `endpoints` in its place.
|
|
448
|
+
*/
|
|
449
|
+
issuer: Schema.String,
|
|
450
|
+
endpoints: Schema.NullOr(ProviderEndpoints),
|
|
451
|
+
clientId: Schema.String,
|
|
452
|
+
secretSet: Schema.Boolean,
|
|
453
|
+
scopes: Schema.Array(Schema.String),
|
|
454
|
+
/** Whether someone it vouches for, whom no admin made a person, is made one. */
|
|
455
|
+
provision: Schema.Boolean,
|
|
456
|
+
/** The domains of the addresses people are made for so; any address where none is named. */
|
|
457
|
+
domains: Schema.Array(Schema.String),
|
|
458
|
+
/** Whether people sign in through it now. */
|
|
459
|
+
enabled: Schema.Boolean,
|
|
460
|
+
/** Kept here, where an admin changes it, or named by the settings, which alone change it. */
|
|
461
|
+
source: Schema.Literals(["stored", "configuration"]),
|
|
462
|
+
/** When it was added and last changed here; never, for one the settings name. */
|
|
463
|
+
createdAt: Schema.NullOr(Schema.DateTimeUtcFromString),
|
|
464
|
+
updatedAt: Schema.NullOr(Schema.DateTimeUtcFromString)
|
|
465
|
+
});
|
|
466
|
+
const SignInProviders = Schema.Struct({
|
|
467
|
+
/** What a provider is told to send people back to, once its id is put after it. */
|
|
468
|
+
callbackBase: Schema.String,
|
|
469
|
+
providers: Schema.Array(SignInProvider)
|
|
470
|
+
});
|
|
471
|
+
const NewSignInProvider = Schema.Struct({
|
|
472
|
+
id: ProviderId,
|
|
473
|
+
name: Schema.NonEmptyString,
|
|
474
|
+
icon: Schema.optional(Schema.NullOr(ProviderIcon)),
|
|
475
|
+
/** OpenID Connect, without. It stays what it is said to be here. */
|
|
476
|
+
kind: Schema.optional(ProviderKind),
|
|
477
|
+
/** Of one that speaks OpenID Connect, which has to have one. */
|
|
478
|
+
issuer: Schema.optional(Schema.NonEmptyString),
|
|
479
|
+
/** Of one that speaks OAuth 2.0 alone, which has to have them. */
|
|
480
|
+
endpoints: Schema.optional(GivenProviderEndpoints),
|
|
481
|
+
clientId: Schema.NonEmptyString,
|
|
482
|
+
/** Told here and never again. */
|
|
483
|
+
clientSecret: Schema.NonEmptyString,
|
|
484
|
+
/** `openid email profile` without, and none for one that speaks OAuth 2.0 alone. */
|
|
485
|
+
scopes: Schema.optional(ProviderScopes),
|
|
486
|
+
provision: Schema.optional(Schema.Boolean),
|
|
487
|
+
domains: Schema.optional(ProviderDomains),
|
|
488
|
+
/** One that is not enabled is kept whether or not it is reached. */
|
|
489
|
+
enabled: Schema.optional(Schema.Boolean)
|
|
490
|
+
});
|
|
491
|
+
/** What is said anew of a provider; what is left out stays as it was. */
|
|
492
|
+
const ChangedSignInProvider = Schema.Struct({
|
|
493
|
+
name: Schema.optional(Schema.NonEmptyString),
|
|
494
|
+
/** Given as none, it is shown with no provider's mark from then on. */
|
|
495
|
+
icon: Schema.optional(Schema.NullOr(ProviderIcon)),
|
|
496
|
+
issuer: Schema.optional(Schema.NonEmptyString),
|
|
497
|
+
endpoints: Schema.optional(GivenProviderEndpoints),
|
|
498
|
+
clientId: Schema.optional(Schema.NonEmptyString),
|
|
499
|
+
/** The secret it has stays where none is given, or an empty one. */
|
|
500
|
+
clientSecret: Schema.optional(Schema.String),
|
|
501
|
+
scopes: Schema.optional(ProviderScopes),
|
|
502
|
+
provision: Schema.optional(Schema.Boolean),
|
|
503
|
+
domains: Schema.optional(ProviderDomains),
|
|
504
|
+
enabled: Schema.optional(Schema.Boolean)
|
|
505
|
+
});
|
|
506
|
+
/** What came of asking a provider how it is reached: nothing wrong, or why not. */
|
|
507
|
+
const ProviderChecked = Schema.Struct({
|
|
508
|
+
ok: Schema.Boolean,
|
|
509
|
+
/** What is wrong, each a sentence; nothing where it is reached as it should be. */
|
|
510
|
+
problems: Schema.Array(Schema.String),
|
|
511
|
+
/** The scopes it says it gives, where it is reached and says any. */
|
|
512
|
+
scopes: Schema.Array(Schema.String)
|
|
513
|
+
});
|
|
514
|
+
/** A ticket into a session, as it is told to whoever asked for it. */
|
|
515
|
+
const Admission = Schema.Struct({
|
|
516
|
+
/** What a request to the session carries: as a bearer token, or as `token` in its query. */
|
|
517
|
+
ticket: Schema.String,
|
|
518
|
+
expiresAt: Schema.DateTimeUtcFromString,
|
|
519
|
+
/**
|
|
520
|
+
* The session's workbench, for a person to open in a browser: on its node where that
|
|
521
|
+
* has an address of its own, and through the proxy before the nodes otherwise. What
|
|
522
|
+
* comes before its `?` is where the session's other routes are.
|
|
523
|
+
*/
|
|
524
|
+
url: Schema.String
|
|
525
|
+
});
|
|
526
|
+
/** What a file of a session is found by, below its files: `recordings/1a2b.mkv`. */
|
|
527
|
+
const SessionFilePath = Schema.String.check(Schema.isPattern(/^(uploads|downloads|recordings|screenshots)(\/(?!\.)[^/\\?#]+)+$/u));
|
|
528
|
+
/** An address one file of a session is read at, or put to, by whoever is given it. */
|
|
529
|
+
const FileLink = Schema.Struct({
|
|
530
|
+
url: Schema.String,
|
|
531
|
+
/** What a request to it is made with: `GET` reads the file, `PUT` puts its bytes there. */
|
|
532
|
+
method: Schema.Literals(["GET", "PUT"]),
|
|
533
|
+
expiresAt: Schema.DateTimeUtcFromString
|
|
534
|
+
});
|
|
535
|
+
/** The longest a file link is good for, in seconds. */
|
|
536
|
+
const FILE_LINK_MOST = 3600;
|
|
537
|
+
/** A share link as whoever has its session sees it: never its secret. */
|
|
538
|
+
const Share = Schema.Struct({
|
|
539
|
+
id: Schema.String,
|
|
540
|
+
sessionId: Schema.String,
|
|
541
|
+
/** The account that made it. */
|
|
542
|
+
accountId: Schema.String,
|
|
543
|
+
name: Schema.String,
|
|
544
|
+
role: ShareRole,
|
|
545
|
+
createdAt: Schema.DateTimeUtcFromString,
|
|
546
|
+
expiresAt: Schema.NullOr(Schema.DateTimeUtcFromString),
|
|
547
|
+
lastUsedAt: Schema.NullOr(Schema.DateTimeUtcFromString)
|
|
548
|
+
});
|
|
549
|
+
/** A link as it is told once, when it is made: `url` is what a guest opens. */
|
|
550
|
+
const ShareCreated = Schema.Struct({
|
|
551
|
+
...Share.fields,
|
|
552
|
+
url: Schema.String
|
|
553
|
+
});
|
|
554
|
+
/** Something that was done, by whom and to what: written once, and never changed. */
|
|
555
|
+
const Event = Schema.Struct({
|
|
556
|
+
id: Schema.String,
|
|
557
|
+
at: Schema.DateTimeUtcFromString,
|
|
558
|
+
kind: EventKind,
|
|
559
|
+
actor: EventActor,
|
|
560
|
+
/** What it was about; nothing where that is not known, as with whoever nobody knows. */
|
|
561
|
+
resource: Schema.NullOr(EventResource),
|
|
562
|
+
/** The workspace what it was about is of, where it is of one. */
|
|
563
|
+
workspaceId: Schema.NullOr(Schema.String),
|
|
564
|
+
/** Where the request that did it came from, where one did and that is known. */
|
|
565
|
+
address: Schema.NullOr(Schema.String),
|
|
566
|
+
detail: EventDetail
|
|
567
|
+
});
|
|
568
|
+
/** Events, the newest first, and what the ones after them are asked for with. */
|
|
569
|
+
const EventPage = Schema.Struct({
|
|
570
|
+
events: Schema.Array(Event),
|
|
571
|
+
/** The cursor of the events before these; none where these are the oldest. */
|
|
572
|
+
next: Schema.NullOr(Schema.String)
|
|
573
|
+
});
|
|
574
|
+
/** Who the request comes from, for what handles it. */
|
|
575
|
+
var CurrentCaller = class extends Context.Service()("@aperture-browser/control/CurrentCaller") {};
|
|
576
|
+
/** Lets in whoever comes with an account's API token, or with the bootstrap token. */
|
|
577
|
+
var Authorization = class extends HttpApiMiddleware.Service()("@aperture-browser/control/Authorization", {
|
|
578
|
+
security: { bearer: HttpApiSecurity.bearer },
|
|
579
|
+
error: Unauthorized
|
|
580
|
+
}) {};
|
|
581
|
+
/**
|
|
582
|
+
* What an account, a workspace, an API token, a grant or a share link is found by. A path
|
|
583
|
+
* that names one by anything else names nothing, and is refused before it is looked for.
|
|
584
|
+
*/
|
|
585
|
+
const Id = Schema.String.check(Schema.isUUID());
|
|
586
|
+
const session = { id: Schema.String };
|
|
587
|
+
/** What a session or a snapshot is found by: names, each with what it is set to. */
|
|
588
|
+
const Tags = Schema.Record(Schema.NonEmptyString, Schema.String);
|
|
589
|
+
/** A session's routing as it was last set through the control plane; none goes direct. */
|
|
590
|
+
const SessionProxy = Schema.Struct({ proxy: Schema.NullOr(ProxyConfig) });
|
|
591
|
+
/** A tag something is listed by: `name=value`, or `name` alone for whatever it is set to. */
|
|
592
|
+
const TagFilter = Schema.NonEmptyString;
|
|
593
|
+
/** `none` for what is of no workspace: its account's own. */
|
|
594
|
+
const WorkspaceFilter = Schema.NonEmptyString;
|
|
595
|
+
const ofNode = [
|
|
596
|
+
Forbidden,
|
|
597
|
+
SessionNotFound,
|
|
598
|
+
SessionHasNoNode,
|
|
599
|
+
NodeUnreachable,
|
|
600
|
+
NodeNotFound,
|
|
601
|
+
NodeRefused
|
|
602
|
+
];
|
|
603
|
+
var AccountsGroup = class extends HttpApiGroup.make("accounts").add(HttpApiEndpoint.get("current", "/account", {
|
|
604
|
+
success: CurrentAccount,
|
|
605
|
+
error: Forbidden
|
|
606
|
+
}), HttpApiEndpoint.get("tokens", "/account/tokens", {
|
|
607
|
+
success: Schema.Array(ApiToken),
|
|
608
|
+
error: Forbidden
|
|
609
|
+
}), HttpApiEndpoint.post("createOwnToken", "/account/tokens", {
|
|
610
|
+
payload: NewApiToken,
|
|
611
|
+
success: ApiTokenCreated.pipe(HttpApiSchema.status(201)),
|
|
612
|
+
error: Forbidden
|
|
613
|
+
}), HttpApiEndpoint.delete("revokeToken", "/account/tokens/:id", {
|
|
614
|
+
params: { id: Id },
|
|
615
|
+
error: [Forbidden, ApiTokenNotFound]
|
|
616
|
+
}), HttpApiEndpoint.get("list", "/accounts", {
|
|
617
|
+
success: Schema.Array(ListedAccount),
|
|
618
|
+
error: Forbidden
|
|
619
|
+
}), HttpApiEndpoint.get("lookup", "/accounts/lookup", {
|
|
620
|
+
/** The whole address: a part of one finds nobody. */
|
|
621
|
+
query: { email: Schema.NonEmptyString },
|
|
622
|
+
success: AccountLookup,
|
|
623
|
+
error: [Forbidden, PersonNotFound]
|
|
624
|
+
}), HttpApiEndpoint.post("create", "/accounts", {
|
|
625
|
+
payload: Schema.Struct({
|
|
626
|
+
name: Schema.NonEmptyString,
|
|
627
|
+
admin: Schema.optional(Schema.Boolean),
|
|
628
|
+
kind: Schema.optional(Schema.Literals(["person", "service"])),
|
|
629
|
+
/** For a person: the address they sign in with, once they set a password. */
|
|
630
|
+
email: Schema.optional(Schema.NonEmptyString)
|
|
631
|
+
}),
|
|
632
|
+
success: Account.pipe(HttpApiSchema.status(201)),
|
|
633
|
+
error: [
|
|
634
|
+
Forbidden,
|
|
635
|
+
EmailTaken,
|
|
636
|
+
AccountInvalid
|
|
637
|
+
]
|
|
638
|
+
}), HttpApiEndpoint.get("get", "/accounts/:id", {
|
|
639
|
+
params: { id: Id },
|
|
640
|
+
success: ListedAccount,
|
|
641
|
+
error: [Forbidden, AccountNotFound]
|
|
642
|
+
}), HttpApiEndpoint.patch("change", "/accounts/:id", {
|
|
643
|
+
params: { id: Id },
|
|
644
|
+
/** What is said anew of the account; what is left out stays as it was. */
|
|
645
|
+
payload: Schema.Struct({
|
|
646
|
+
name: Schema.optional(Schema.NonEmptyString),
|
|
647
|
+
admin: Schema.optional(Schema.Boolean)
|
|
648
|
+
}),
|
|
649
|
+
success: Account,
|
|
650
|
+
error: [
|
|
651
|
+
Forbidden,
|
|
652
|
+
AccountNotFound,
|
|
653
|
+
AccountInUse
|
|
654
|
+
]
|
|
655
|
+
}), HttpApiEndpoint.post("resetSecondFactor", "/accounts/:id/second-factor/reset", {
|
|
656
|
+
params: { id: Id },
|
|
657
|
+
error: [
|
|
658
|
+
Forbidden,
|
|
659
|
+
AccountNotFound,
|
|
660
|
+
PersonNotFound
|
|
661
|
+
]
|
|
662
|
+
}), HttpApiEndpoint.post("disable", "/accounts/:id/disable", {
|
|
663
|
+
params: { id: Id },
|
|
664
|
+
success: Account,
|
|
665
|
+
error: [
|
|
666
|
+
Forbidden,
|
|
667
|
+
AccountNotFound,
|
|
668
|
+
AccountInUse
|
|
669
|
+
]
|
|
670
|
+
}), HttpApiEndpoint.post("enable", "/accounts/:id/enable", {
|
|
671
|
+
params: { id: Id },
|
|
672
|
+
success: Account,
|
|
673
|
+
error: [Forbidden, AccountNotFound]
|
|
674
|
+
}), HttpApiEndpoint.delete("remove", "/accounts/:id", {
|
|
675
|
+
params: { id: Id },
|
|
676
|
+
error: [
|
|
677
|
+
Forbidden,
|
|
678
|
+
AccountNotFound,
|
|
679
|
+
AccountInUse
|
|
680
|
+
]
|
|
681
|
+
}), HttpApiEndpoint.post("removePasskeys", "/accounts/:id/passkeys/remove", {
|
|
682
|
+
params: { id: Id },
|
|
683
|
+
error: [
|
|
684
|
+
Forbidden,
|
|
685
|
+
AccountNotFound,
|
|
686
|
+
PersonNotFound
|
|
687
|
+
]
|
|
688
|
+
}), HttpApiEndpoint.post("createSetupToken", "/accounts/:id/setup-token", {
|
|
689
|
+
params: { id: Id },
|
|
690
|
+
success: Schema.Struct({ token: Schema.String }).pipe(HttpApiSchema.status(201)),
|
|
691
|
+
error: [
|
|
692
|
+
Forbidden,
|
|
693
|
+
AccountNotFound,
|
|
694
|
+
PersonNotFound
|
|
695
|
+
]
|
|
696
|
+
}), HttpApiEndpoint.post("createToken", "/accounts/:id/tokens", {
|
|
697
|
+
params: { id: Id },
|
|
698
|
+
payload: NewApiToken,
|
|
699
|
+
success: ApiTokenCreated.pipe(HttpApiSchema.status(201)),
|
|
700
|
+
error: [Forbidden, AccountNotFound]
|
|
701
|
+
}), HttpApiEndpoint.get("tokensOf", "/accounts/:id/tokens", {
|
|
702
|
+
params: { id: Id },
|
|
703
|
+
success: Schema.Array(ApiToken),
|
|
704
|
+
error: [Forbidden, AccountNotFound]
|
|
705
|
+
}), HttpApiEndpoint.delete("revokeTokenOf", "/accounts/:id/tokens/:tokenId", {
|
|
706
|
+
params: {
|
|
707
|
+
id: Id,
|
|
708
|
+
tokenId: Id
|
|
709
|
+
},
|
|
710
|
+
error: [
|
|
711
|
+
Forbidden,
|
|
712
|
+
AccountNotFound,
|
|
713
|
+
ApiTokenNotFound
|
|
714
|
+
]
|
|
715
|
+
})).annotateMerge(OpenApi.annotations({
|
|
716
|
+
title: "Accounts",
|
|
717
|
+
description: "Accounts and their API tokens. Only an admin makes them, changes what they are called and whether they are admins, disables them and removes them, and sees and takes back the tokens of an account that is not their own. Whoever says who is in a workspace finds a person's account by the whole of their email address."
|
|
718
|
+
})) {};
|
|
719
|
+
var NodesGroup = class extends HttpApiGroup.make("nodes").add(HttpApiEndpoint.get("list", "/nodes", {
|
|
720
|
+
success: Schema.Array(Node),
|
|
721
|
+
error: Forbidden
|
|
722
|
+
}), HttpApiEndpoint.post("release", "/nodes/:id/release", {
|
|
723
|
+
params: { id: Id },
|
|
724
|
+
error: [Forbidden, NodeNotFound]
|
|
725
|
+
}), HttpApiEndpoint.get("registrationTokens", "/registration-tokens", {
|
|
726
|
+
success: Schema.Array(RegistrationToken),
|
|
727
|
+
error: Forbidden
|
|
728
|
+
}), HttpApiEndpoint.post("createRegistrationToken", "/registration-tokens", {
|
|
729
|
+
payload: Schema.Struct({ name: Schema.NonEmptyString }),
|
|
730
|
+
success: RegistrationTokenCreated.pipe(HttpApiSchema.status(201)),
|
|
731
|
+
error: Forbidden
|
|
732
|
+
}), HttpApiEndpoint.delete("revokeRegistrationToken", "/registration-tokens/:id", {
|
|
733
|
+
params: { id: Id },
|
|
734
|
+
error: [Forbidden, RegistrationTokenNotFound]
|
|
735
|
+
})).annotateMerge(OpenApi.annotations({
|
|
736
|
+
title: "Nodes",
|
|
737
|
+
description: "The nodes that registered, and the tokens that let nodes register. A token that is revoked registers no new node, and the nodes that registered with it stay. A node keeps its name with the operator token it registered with: nothing else registers under the name, whatever registration token it has. Releasing a node lets its name go to the next that registers under it, for a node that was installed again."
|
|
738
|
+
})) {};
|
|
739
|
+
var SessionsGroup = class extends HttpApiGroup.make("sessions").add(HttpApiEndpoint.get("list", "/sessions", {
|
|
740
|
+
/** Each narrows the list; together, a session has to be all of them. */
|
|
741
|
+
query: {
|
|
742
|
+
workspaceId: Schema.optional(WorkspaceFilter),
|
|
743
|
+
state: Schema.optional(ObservedState),
|
|
744
|
+
label: Schema.optional(Schema.NonEmptyString),
|
|
745
|
+
tag: Schema.optional(TagFilter)
|
|
746
|
+
},
|
|
747
|
+
success: Schema.Array(Session),
|
|
748
|
+
error: Forbidden
|
|
749
|
+
}), HttpApiEndpoint.post("create", "/sessions", {
|
|
750
|
+
payload: Schema.Struct({
|
|
751
|
+
suspended: Schema.optional(Schema.Boolean),
|
|
752
|
+
snapshotId: Schema.optional(Schema.NonEmptyString),
|
|
753
|
+
label: Schema.optional(Schema.NonEmptyString),
|
|
754
|
+
/** The workspace the session is of; the caller's own account's without. */
|
|
755
|
+
workspaceId: Schema.optional(Schema.NonEmptyString),
|
|
756
|
+
tags: Schema.optional(Tags),
|
|
757
|
+
proxy: Schema.optional(ProxyConfig)
|
|
758
|
+
}),
|
|
759
|
+
success: Session.pipe(HttpApiSchema.status(201)),
|
|
760
|
+
error: [
|
|
761
|
+
Forbidden,
|
|
762
|
+
WorkspaceNotFound,
|
|
763
|
+
SnapshotNotFound,
|
|
764
|
+
NoNode,
|
|
765
|
+
NodeRefused
|
|
766
|
+
]
|
|
767
|
+
}), HttpApiEndpoint.get("get", "/sessions/:id", {
|
|
768
|
+
params: session,
|
|
769
|
+
success: Session,
|
|
770
|
+
error: [Forbidden, SessionNotFound]
|
|
771
|
+
}), HttpApiEndpoint.patch("describe", "/sessions/:id", {
|
|
772
|
+
params: session,
|
|
773
|
+
payload: Schema.Struct({
|
|
774
|
+
label: Schema.optional(Schema.NullOr(Schema.NonEmptyString)),
|
|
775
|
+
tags: Schema.optional(Tags)
|
|
776
|
+
}),
|
|
777
|
+
success: Session,
|
|
778
|
+
error: [Forbidden, SessionNotFound]
|
|
779
|
+
}), HttpApiEndpoint.get("proxy", "/sessions/:id/proxy", {
|
|
780
|
+
params: session,
|
|
781
|
+
success: SessionProxy,
|
|
782
|
+
error: [Forbidden, SessionNotFound]
|
|
783
|
+
}), HttpApiEndpoint.put("setProxy", "/sessions/:id/proxy", {
|
|
784
|
+
params: session,
|
|
785
|
+
payload: SessionProxy,
|
|
786
|
+
success: SessionProxy,
|
|
787
|
+
error: ofNode
|
|
788
|
+
}), HttpApiEndpoint.post("suspend", "/sessions/:id/suspend", {
|
|
789
|
+
params: session,
|
|
790
|
+
success: Session,
|
|
791
|
+
error: ofNode
|
|
792
|
+
}), HttpApiEndpoint.post("resume", "/sessions/:id/resume", {
|
|
793
|
+
params: session,
|
|
794
|
+
success: Session,
|
|
795
|
+
error: ofNode
|
|
796
|
+
}), HttpApiEndpoint.delete("delete", "/sessions/:id", {
|
|
797
|
+
params: session,
|
|
798
|
+
error: ofNode
|
|
799
|
+
}), HttpApiEndpoint.post("createTicket", "/sessions/:id/tickets", {
|
|
800
|
+
params: session,
|
|
801
|
+
payload: Schema.Struct({
|
|
802
|
+
name: Schema.optional(Schema.NonEmptyString),
|
|
803
|
+
access: Schema.optional(Access)
|
|
804
|
+
}),
|
|
805
|
+
success: Admission.pipe(HttpApiSchema.status(201)),
|
|
806
|
+
error: [
|
|
807
|
+
Forbidden,
|
|
808
|
+
SessionNotFound,
|
|
809
|
+
SessionHasNoNode
|
|
810
|
+
]
|
|
811
|
+
}), HttpApiEndpoint.post("createFileLink", "/sessions/:id/file-links", {
|
|
812
|
+
params: session,
|
|
813
|
+
payload: Schema.Struct({
|
|
814
|
+
path: SessionFilePath,
|
|
815
|
+
/** A link a file is put at, in `uploads` alone; one it is read at, without. */
|
|
816
|
+
write: Schema.optional(Schema.Boolean),
|
|
817
|
+
/** Five minutes, without. */
|
|
818
|
+
expiresInSeconds: Schema.optional(Schema.Int.check(Schema.isBetween({
|
|
819
|
+
minimum: 1,
|
|
820
|
+
maximum: FILE_LINK_MOST
|
|
821
|
+
})))
|
|
822
|
+
}),
|
|
823
|
+
success: FileLink.pipe(HttpApiSchema.status(201)),
|
|
824
|
+
error: [
|
|
825
|
+
Forbidden,
|
|
826
|
+
SessionNotFound,
|
|
827
|
+
SessionHasNoNode,
|
|
828
|
+
FileLinkInvalid
|
|
829
|
+
]
|
|
830
|
+
})).annotateMerge(OpenApi.annotations({
|
|
831
|
+
title: "Sessions",
|
|
832
|
+
description: "An account's sessions, wherever they run, the tickets into them, and links to their files. A ticket with no access watches, which a token that reads sessions asks for; a ticket that does more, and a link to a file, is for a token that writes them."
|
|
833
|
+
})) {};
|
|
834
|
+
var SharesGroup = class extends HttpApiGroup.make("shares").add(HttpApiEndpoint.get("list", "/sessions/:id/shares", {
|
|
835
|
+
params: session,
|
|
836
|
+
success: Schema.Array(Share),
|
|
837
|
+
error: [Forbidden, SessionNotFound]
|
|
838
|
+
}), HttpApiEndpoint.post("create", "/sessions/:id/shares", {
|
|
839
|
+
params: session,
|
|
840
|
+
payload: Schema.Struct({
|
|
841
|
+
/** What whoever makes it knows it by; guests are not told. */
|
|
842
|
+
name: Schema.NonEmptyString.check(Schema.isMaxLength(100)),
|
|
843
|
+
role: ShareRole,
|
|
844
|
+
/** How many hours it is good for; for as long as it is not taken back, without. */
|
|
845
|
+
expiresInHours: Schema.optional(Schema.Int.check(Schema.isBetween({
|
|
846
|
+
minimum: 1,
|
|
847
|
+
maximum: 87600
|
|
848
|
+
})))
|
|
849
|
+
}),
|
|
850
|
+
success: ShareCreated.pipe(HttpApiSchema.status(201)),
|
|
851
|
+
error: [Forbidden, SessionNotFound]
|
|
852
|
+
}), HttpApiEndpoint.delete("revoke", "/sessions/:id/shares/:shareId", {
|
|
853
|
+
params: {
|
|
854
|
+
...session,
|
|
855
|
+
shareId: Id
|
|
856
|
+
},
|
|
857
|
+
error: [
|
|
858
|
+
Forbidden,
|
|
859
|
+
SessionNotFound,
|
|
860
|
+
ShareNotFound
|
|
861
|
+
]
|
|
862
|
+
})).annotateMerge(OpenApi.annotations({
|
|
863
|
+
title: "Share links",
|
|
864
|
+
description: "Links that let someone with no account into one session, to watch it or to control it."
|
|
865
|
+
})) {};
|
|
866
|
+
var SnapshotsGroup = class extends HttpApiGroup.make("snapshots").add(HttpApiEndpoint.get("list", "/snapshots", {
|
|
867
|
+
/** Each narrows the list; together, a snapshot has to be all of them. */
|
|
868
|
+
query: {
|
|
869
|
+
workspaceId: Schema.optional(WorkspaceFilter),
|
|
870
|
+
name: Schema.optional(Schema.NonEmptyString),
|
|
871
|
+
tag: Schema.optional(TagFilter)
|
|
872
|
+
},
|
|
873
|
+
success: Schema.Array(Snapshot),
|
|
874
|
+
error: Forbidden
|
|
875
|
+
}), HttpApiEndpoint.post("take", "/sessions/:id/snapshots", {
|
|
876
|
+
params: session,
|
|
877
|
+
payload: Schema.Struct({
|
|
878
|
+
name: Schema.optional(Schema.NonEmptyString),
|
|
879
|
+
description: Schema.optional(Schema.NonEmptyString),
|
|
880
|
+
tags: Schema.optional(Tags),
|
|
881
|
+
/**
|
|
882
|
+
* A snapshot this one takes the place of: it is deleted once this is taken, and
|
|
883
|
+
* what it was called, said to be and tagged with stays where nothing else is given.
|
|
884
|
+
*/
|
|
885
|
+
replaces: Schema.optional(Schema.NonEmptyString)
|
|
886
|
+
}),
|
|
887
|
+
success: Snapshot.pipe(HttpApiSchema.status(201)),
|
|
888
|
+
error: [...ofNode, SnapshotNotFound]
|
|
889
|
+
}), HttpApiEndpoint.get("get", "/snapshots/:id", {
|
|
890
|
+
params: { id: Schema.String },
|
|
891
|
+
success: Snapshot,
|
|
892
|
+
error: [Forbidden, SnapshotNotFound]
|
|
893
|
+
}), HttpApiEndpoint.patch("describe", "/snapshots/:id", {
|
|
894
|
+
params: { id: Schema.String },
|
|
895
|
+
payload: Schema.Struct({
|
|
896
|
+
name: Schema.optional(Schema.NullOr(Schema.NonEmptyString)),
|
|
897
|
+
description: Schema.optional(Schema.NullOr(Schema.NonEmptyString)),
|
|
898
|
+
tags: Schema.optional(Tags)
|
|
899
|
+
}),
|
|
900
|
+
success: Snapshot,
|
|
901
|
+
error: [Forbidden, SnapshotNotFound]
|
|
902
|
+
}), HttpApiEndpoint.delete("delete", "/snapshots/:id", {
|
|
903
|
+
params: { id: Schema.String },
|
|
904
|
+
error: [
|
|
905
|
+
Forbidden,
|
|
906
|
+
SnapshotNotFound,
|
|
907
|
+
NodeUnreachable,
|
|
908
|
+
NodeRefused
|
|
909
|
+
]
|
|
910
|
+
})).annotateMerge(OpenApi.annotations({
|
|
911
|
+
title: "Snapshots",
|
|
912
|
+
description: "Snapshots of an account's sessions, and what sessions are created from."
|
|
913
|
+
})) {};
|
|
914
|
+
const workspace = { id: Id };
|
|
915
|
+
var WorkspacesGroup = class extends HttpApiGroup.make("workspaces").add(HttpApiEndpoint.get("list", "/workspaces", { success: Schema.Array(Workspace) }), HttpApiEndpoint.post("create", "/workspaces", {
|
|
916
|
+
payload: Schema.Struct({ name: Schema.NonEmptyString }),
|
|
917
|
+
success: Workspace.pipe(HttpApiSchema.status(201)),
|
|
918
|
+
error: Forbidden
|
|
919
|
+
}), HttpApiEndpoint.patch("rename", "/workspaces/:id", {
|
|
920
|
+
params: workspace,
|
|
921
|
+
payload: Schema.Struct({ name: Schema.NonEmptyString }),
|
|
922
|
+
success: Workspace,
|
|
923
|
+
error: [WorkspaceNotFound, Forbidden]
|
|
924
|
+
}), HttpApiEndpoint.delete("delete", "/workspaces/:id", {
|
|
925
|
+
params: workspace,
|
|
926
|
+
error: [
|
|
927
|
+
WorkspaceNotFound,
|
|
928
|
+
Forbidden,
|
|
929
|
+
WorkspaceInUse
|
|
930
|
+
]
|
|
931
|
+
}), HttpApiEndpoint.get("members", "/workspaces/:id/members", {
|
|
932
|
+
params: workspace,
|
|
933
|
+
success: Schema.Array(WorkspaceMember),
|
|
934
|
+
error: [WorkspaceNotFound, Forbidden]
|
|
935
|
+
}), HttpApiEndpoint.put("admit", "/workspaces/:id/members/:accountId", {
|
|
936
|
+
params: {
|
|
937
|
+
...workspace,
|
|
938
|
+
accountId: Id
|
|
939
|
+
},
|
|
940
|
+
payload: Schema.Struct({ role: WorkspaceRole }),
|
|
941
|
+
error: [
|
|
942
|
+
WorkspaceNotFound,
|
|
943
|
+
Forbidden,
|
|
944
|
+
AccountNotFound
|
|
945
|
+
]
|
|
946
|
+
}), HttpApiEndpoint.delete("dismiss", "/workspaces/:id/members/:accountId", {
|
|
947
|
+
params: {
|
|
948
|
+
...workspace,
|
|
949
|
+
accountId: Id
|
|
950
|
+
},
|
|
951
|
+
error: [WorkspaceNotFound, Forbidden]
|
|
952
|
+
}), HttpApiEndpoint.get("ofAccount", "/accounts/:accountId/workspaces", {
|
|
953
|
+
params: { accountId: Id },
|
|
954
|
+
success: Schema.Array(AccountWorkspace),
|
|
955
|
+
error: [Forbidden, AccountNotFound]
|
|
956
|
+
})).annotateMerge(OpenApi.annotations({
|
|
957
|
+
title: "Workspaces",
|
|
958
|
+
description: "Where accounts keep sessions and snapshots together: what is a workspace's is all its members'. Any token is told the workspaces its account is in, of those it is held to where it is held to resources; who else is in one is for a token that reads workspaces. An admin of a workspace says who is in it, naming an account by its id; an admin is told which workspaces any account is in."
|
|
959
|
+
})) {};
|
|
960
|
+
const EVENTS_MOST = 200;
|
|
961
|
+
var EventsGroup = class extends HttpApiGroup.make("events").add(HttpApiEndpoint.get("list", "/events", {
|
|
962
|
+
query: {
|
|
963
|
+
kind: Schema.optional(EventKind),
|
|
964
|
+
/** An account's id, or a part of what the actor was called. */
|
|
965
|
+
actor: Schema.optional(Schema.NonEmptyString),
|
|
966
|
+
resourceKind: Schema.optional(EventResource.fields.kind),
|
|
967
|
+
resourceId: Schema.optional(Schema.NonEmptyString),
|
|
968
|
+
workspaceId: Schema.optional(Schema.NonEmptyString),
|
|
969
|
+
/** Events from this moment on. */
|
|
970
|
+
since: Schema.optional(Schema.DateTimeUtcFromString),
|
|
971
|
+
/** Events before this moment. */
|
|
972
|
+
until: Schema.optional(Schema.DateTimeUtcFromString),
|
|
973
|
+
/** What a page before said the next is asked for with. */
|
|
974
|
+
cursor: Schema.optional(Schema.String.check(Schema.isPattern(/^\d{1,16}_[0-9a-f-]{36}$/u))),
|
|
975
|
+
limit: Schema.optional(Schema.FiniteFromString.check(Schema.isInt(), Schema.isBetween({
|
|
976
|
+
minimum: 1,
|
|
977
|
+
maximum: 200
|
|
978
|
+
})))
|
|
979
|
+
},
|
|
980
|
+
success: EventPage,
|
|
981
|
+
error: Forbidden
|
|
982
|
+
})).annotateMerge(OpenApi.annotations({
|
|
983
|
+
title: "Events",
|
|
984
|
+
description: "What was done by whom, the newest first. An admin reads all of it; anyone else what their own account did or had done to it, and what was done in the workspaces they are in."
|
|
985
|
+
})) {};
|
|
986
|
+
/** What an app asks a person for, as its authorization request says it. */
|
|
987
|
+
const asked = {
|
|
988
|
+
clientId: Schema.NonEmptyString,
|
|
989
|
+
redirectUri: Schema.NonEmptyString
|
|
990
|
+
};
|
|
991
|
+
var GrantsGroup = class extends HttpApiGroup.make("grants").add(HttpApiEndpoint.get("asking", "/oauth/request", {
|
|
992
|
+
query: asked,
|
|
993
|
+
success: Schema.Struct({
|
|
994
|
+
clientId: Schema.String,
|
|
995
|
+
clientName: Schema.String
|
|
996
|
+
}),
|
|
997
|
+
error: [OAuthClientNotFound, RedirectRefused]
|
|
998
|
+
}), HttpApiEndpoint.get("list", "/oauth/grants", {
|
|
999
|
+
success: Schema.Array(Grant),
|
|
1000
|
+
error: Forbidden
|
|
1001
|
+
}), HttpApiEndpoint.post("approve", "/oauth/grants", {
|
|
1002
|
+
payload: Schema.Struct({
|
|
1003
|
+
...asked,
|
|
1004
|
+
/** What the app sent to know its own request by; it is sent back as it came. */
|
|
1005
|
+
state: Schema.optional(Schema.String),
|
|
1006
|
+
codeChallenge: Schema.NonEmptyString,
|
|
1007
|
+
/** What the app does: a grant is given for something, and does nothing else. */
|
|
1008
|
+
scopes: Schema.NonEmptyArray(Scope),
|
|
1009
|
+
/** The resources it is held to; all that the account reaches, without. */
|
|
1010
|
+
resources: Schema.optional(TokenResources)
|
|
1011
|
+
}),
|
|
1012
|
+
/** Where the person's browser goes with the answer: back to the app. */
|
|
1013
|
+
success: Schema.Struct({ redirectTo: Schema.String }).pipe(HttpApiSchema.status(201)),
|
|
1014
|
+
error: [
|
|
1015
|
+
Forbidden,
|
|
1016
|
+
OAuthClientNotFound,
|
|
1017
|
+
RedirectRefused
|
|
1018
|
+
]
|
|
1019
|
+
}), HttpApiEndpoint.delete("revoke", "/oauth/grants/:id", {
|
|
1020
|
+
params: { id: Id },
|
|
1021
|
+
error: [Forbidden, GrantNotFound]
|
|
1022
|
+
})).annotateMerge(OpenApi.annotations({
|
|
1023
|
+
title: "Grants",
|
|
1024
|
+
description: "What people give apps that ask to act as their account over OAuth, as MCP clients do."
|
|
1025
|
+
})) {};
|
|
1026
|
+
var ProvidersGroup = class extends HttpApiGroup.make("providers").add(HttpApiEndpoint.get("list", "/sign-in-providers", {
|
|
1027
|
+
success: SignInProviders,
|
|
1028
|
+
error: Forbidden
|
|
1029
|
+
}), HttpApiEndpoint.post("create", "/sign-in-providers", {
|
|
1030
|
+
payload: NewSignInProvider,
|
|
1031
|
+
success: SignInProvider.pipe(HttpApiSchema.status(201)),
|
|
1032
|
+
error: [
|
|
1033
|
+
Forbidden,
|
|
1034
|
+
ProviderTaken,
|
|
1035
|
+
ProviderInvalid
|
|
1036
|
+
]
|
|
1037
|
+
}), HttpApiEndpoint.post("check", "/sign-in-providers/check", {
|
|
1038
|
+
payload: Schema.Struct({
|
|
1039
|
+
issuer: Schema.optional(Schema.String),
|
|
1040
|
+
endpoints: Schema.optional(GivenProviderEndpoints)
|
|
1041
|
+
}),
|
|
1042
|
+
success: ProviderChecked,
|
|
1043
|
+
error: Forbidden
|
|
1044
|
+
}), HttpApiEndpoint.patch("change", "/sign-in-providers/:id", {
|
|
1045
|
+
params: { id: Schema.String },
|
|
1046
|
+
payload: ChangedSignInProvider,
|
|
1047
|
+
success: SignInProvider,
|
|
1048
|
+
error: [
|
|
1049
|
+
Forbidden,
|
|
1050
|
+
ProviderNotFound,
|
|
1051
|
+
ProviderConfigured,
|
|
1052
|
+
ProviderInvalid
|
|
1053
|
+
]
|
|
1054
|
+
}), HttpApiEndpoint.delete("remove", "/sign-in-providers/:id", {
|
|
1055
|
+
params: { id: Schema.String },
|
|
1056
|
+
error: [
|
|
1057
|
+
Forbidden,
|
|
1058
|
+
ProviderNotFound,
|
|
1059
|
+
ProviderConfigured
|
|
1060
|
+
]
|
|
1061
|
+
})).annotateMerge(OpenApi.annotations({
|
|
1062
|
+
title: "Sign-in providers",
|
|
1063
|
+
description: "The providers people sign in through, which an admin adds, changes, disables and removes while the control plane runs. One speaks OpenID Connect and says at its issuer how it is reached, or OAuth 2.0 alone, as GitHub does, and is asked where it is said to be. Those the settings name are told beside them and changed there alone. A client secret is given and never told. Removing or disabling a provider removes nobody: whoever came through it alone does not sign in until it is back."
|
|
1064
|
+
})) {};
|
|
1065
|
+
var SignInGroup = class extends HttpApiGroup.make("signIn").add(HttpApiEndpoint.get("providers", "/sign-in/providers", { success: Schema.Array(Provider) })).annotateMerge(OpenApi.annotations({
|
|
1066
|
+
title: "Signing in",
|
|
1067
|
+
description: "What whoever is not signed in yet is told: the providers people sign in through."
|
|
1068
|
+
})) {};
|
|
1069
|
+
/** Whether this program serves: nothing of what it knows, and for anyone who asks. */
|
|
1070
|
+
const Health = Schema.Struct({ status: Schema.Literal("ok") });
|
|
1071
|
+
var HealthGroup = class extends HttpApiGroup.make("health").add(HttpApiEndpoint.get("check", "/health", { success: Health })).annotateMerge(OpenApi.annotations({
|
|
1072
|
+
title: "Health",
|
|
1073
|
+
description: "Whether the control plane serves, for what stands before it and what starts it: answered once its database is there, to anyone, and telling nothing."
|
|
1074
|
+
})) {};
|
|
1075
|
+
var Api = class extends HttpApi.make("control").add(AccountsGroup, EventsGroup, GrantsGroup, NodesGroup, ProvidersGroup, SessionsGroup, SharesGroup, SnapshotsGroup, WorkspacesGroup).middleware(Authorization).add(SignInGroup, HealthGroup).prefix(PREFIX).annotateMerge(OpenApi.annotations({
|
|
1076
|
+
title: "Aperture control plane",
|
|
1077
|
+
version,
|
|
1078
|
+
description: "Accounts, nodes, where sessions run, and tickets into them. A request carries an account's API token, or the access token an app was given over OAuth, as `Authorization: Bearer`."
|
|
1079
|
+
})) {};
|
|
1080
|
+
//#endregion
|
|
1081
|
+
export { EventResource as $, ProvidersGroup as A, SignInMethods as B, Node as C, ProviderChecked as D, Provider as E, SessionsGroup as F, Workspace as G, SignInProviders as H, Share as I, Access as J, WorkspaceMember as K, ShareCreated as L, RegistrationTokenCreated as M, Session as N, ProviderId as O, SessionFilePath as P, EventKind as Q, SharesGroup as R, ListedAccount as S, PREFIX as T, Snapshot as U, SignInProvider as V, SnapshotsGroup as W, EventActor as X, DesiredState as Y, EventDetail as Z, FileLink as _, Admission as a, TokenResources as at, Health as b, ApiTokenCreated as c, CurrentCaller as d, ObservedState as et, EVENTS_MOST as f, FILE_LINK_MOST as g, EventsGroup as h, AccountsGroup as i, ShareRole as it, RegistrationToken as j, ProviderKind as k, Authorization as l, EventPage as m, AccountLookup as n, ProxyConfig as nt, Api as o, covers as ot, Event as p, WorkspacesGroup as q, AccountWorkspace as r, Scope as rt, ApiToken as s, Account as t, Offers as tt, CurrentAccount as u, Grant as v, NodesGroup as w, HealthGroup as x, GrantsGroup as y, SignInGroup as z };
|
|
1082
|
+
|
|
1083
|
+
//# sourceMappingURL=api-EoqsY4JE.js.map
|