overvues 0.0.1 → 0.4.10
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 +58 -2
- package/dist/ansi.js +24 -0
- package/dist/attach-client.js +586 -0
- package/dist/auth-connect-browser.js +112 -0
- package/dist/auth-connect.js +306 -0
- package/dist/browser-bootstrap.js +190 -0
- package/dist/browser-loopback.js +289 -0
- package/dist/build-identity.js +6 -0
- package/dist/codex-reviewer-apparmor.json +4 -0
- package/dist/codex-reviewer-seccomp.json +1238 -0
- package/dist/codex-runtime-protocol.js +1 -0
- package/dist/codex-subscription.js +53 -0
- package/dist/config.js +297 -0
- package/dist/connect-comparison-code.js +26 -0
- package/dist/development-runner.js +109 -0
- package/dist/dns-doctor.js +390 -0
- package/dist/docker-names.js +47 -0
- package/dist/doctor.js +114 -0
- package/dist/gadget-job.js +804 -0
- package/dist/health-check.js +112 -0
- package/dist/help.js +71 -0
- package/dist/host-auth.js +22 -0
- package/dist/host-diagnostics.js +20 -0
- package/dist/host-runtime-identity.js +39 -0
- package/dist/host-runtime-metadata.js +56 -0
- package/dist/host-service.js +377 -0
- package/dist/host-stack.js +484 -0
- package/dist/host-supervisor.js +237 -0
- package/dist/host-update.js +387 -0
- package/dist/hub-address.js +100 -0
- package/dist/hub-client.js +459 -0
- package/dist/hub-kind.js +88 -0
- package/dist/identity.js +73 -0
- package/dist/index.js +185 -0
- package/dist/init.js +295 -0
- package/dist/isolated-run-cache.js +116 -0
- package/dist/local-stack.js +685 -0
- package/dist/machine-capacity.js +128 -0
- package/dist/managed-runner-image.js +13 -0
- package/dist/os-acted-record.js +49 -0
- package/dist/os-adapter.js +8190 -0
- package/dist/os-command.js +292 -0
- package/dist/os-handoff.js +274 -0
- package/dist/os-keychain.js +247 -0
- package/dist/os-machine.js +818 -0
- package/dist/os-owner.js +61 -0
- package/dist/os-private-file.js +98 -0
- package/dist/os-protocol.js +468 -0
- package/dist/os-session-store.js +133 -0
- package/dist/os-status.js +102 -0
- package/dist/picker.js +863 -0
- package/dist/portable-workspace-capability.js +60 -0
- package/dist/project-environment-capability.js +62 -0
- package/dist/project-environment.js +28 -0
- package/dist/project-preparation.js +134 -0
- package/dist/readiness.js +28 -0
- package/dist/redaction.js +27 -0
- package/dist/reviewer-isolation-capability.js +61 -0
- package/dist/runner-api-auth.js +80 -0
- package/dist/runner-command-fence.js +536 -0
- package/dist/runner-inspection.js +57 -0
- package/dist/runner-inventory.js +587 -0
- package/dist/runner-server.js +2520 -0
- package/dist/runner-session.js +470 -0
- package/dist/runner-slug-folder.js +39 -0
- package/dist/runner-slug.js +40 -0
- package/dist/setup.js +139 -0
- package/dist/shutdown.js +102 -0
- package/dist/splash.js +65 -0
- package/dist/staged-workspaces.js +441 -0
- package/dist/staging-disk.js +97 -0
- package/dist/terminal-lane.js +339 -0
- package/dist/terminal-recovery.js +502 -0
- package/licenses/capnweb.txt +23 -0
- package/licenses/moby-profiles.txt +212 -0
- package/licenses/ws.txt +22 -0
- package/package.json +28 -7
- package/cli.js +0 -2
package/dist/os-owner.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// The owner check `tiller` makes when a machine is connected to the OS.
|
|
2
|
+
//
|
|
3
|
+
// Decrypting a handoff proves nothing about who sent it, so three things are compared, and the
|
|
4
|
+
// OS is the only one believed about whose session it is:
|
|
5
|
+
//
|
|
6
|
+
// 1. `tiller` signs in to the OS, at the address in its own command, and asks whose session
|
|
7
|
+
// it is. The user id the session's own text names must be that account.
|
|
8
|
+
// 2. The account from this machine's first connection is kept. A session for another account
|
|
9
|
+
// does not replace it; the person runs `tiller os forget` first.
|
|
10
|
+
// 3. The machine's own Hub is asked whose Hub it is (`GET /api/machine/os/owner`, with the
|
|
11
|
+
// credentials the machine has for its Hub). A session for another account than the Hub
|
|
12
|
+
// owner's is refused. The Hub's answer can only refuse: it never makes an account
|
|
13
|
+
// acceptable, and it never replaces the account kept in (2). When the Hub does not say, the
|
|
14
|
+
// person is asked at the terminal whether the account the OS named is theirs.
|
|
15
|
+
//
|
|
16
|
+
// The Hub is sent nothing by this: not the session, not the state, and not the account.
|
|
17
|
+
export const OS_OWNER_PATH = "/api/machine/os/owner";
|
|
18
|
+
/** The code a hub answers with when a request belongs to the other kind of hub (the hub's `hub-kind.ts`). */
|
|
19
|
+
export const HUB_KIND_REFUSED_CODE = "hub_kind";
|
|
20
|
+
/** Accounts on the OS are keyed by verified email. Compared without case, and nothing else is changed. */
|
|
21
|
+
export const sameAccount = (left, right) => left.trim().toLowerCase() === right.trim().toLowerCase();
|
|
22
|
+
const EMAIL = /^[^\s@]+@[^\s@]+$/;
|
|
23
|
+
/** Asks this machine's own Hub for its owner's email. Never throws. */
|
|
24
|
+
export async function askHubOwner(hubFetch) {
|
|
25
|
+
let response;
|
|
26
|
+
try {
|
|
27
|
+
response = await hubFetch(OS_OWNER_PATH, { method: "GET" });
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return { known: false, why: "your Hub could not be reached" };
|
|
31
|
+
}
|
|
32
|
+
if (response.status === 404)
|
|
33
|
+
return { known: false, why: "your Hub does not say who its owner is yet" };
|
|
34
|
+
if (response.status === 403) {
|
|
35
|
+
let refusal;
|
|
36
|
+
try {
|
|
37
|
+
refusal = JSON.parse((await response.text()).slice(0, 4096));
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
refusal = null;
|
|
41
|
+
}
|
|
42
|
+
if (refusal?.code === HUB_KIND_REFUSED_CODE) {
|
|
43
|
+
const said = typeof refusal.error === "string" && refusal.error.trim() ? refusal.error.trim().slice(0, 300) : "This hub has no link to Overvues.";
|
|
44
|
+
return { known: false, why: said, kindRefused: true };
|
|
45
|
+
}
|
|
46
|
+
return { known: false, why: "your Hub did not answer (HTTP 403)" };
|
|
47
|
+
}
|
|
48
|
+
if (!response.ok)
|
|
49
|
+
return { known: false, why: `your Hub did not answer (HTTP ${response.status})` };
|
|
50
|
+
let body;
|
|
51
|
+
try {
|
|
52
|
+
body = JSON.parse((await response.text()).slice(0, 4096));
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
body = null;
|
|
56
|
+
}
|
|
57
|
+
if (!body || body.protocol !== 1 || typeof body.ownerEmail !== "string" || body.ownerEmail.length > 320 || !EMAIL.test(body.ownerEmail.trim())) {
|
|
58
|
+
return { known: false, why: "your Hub's answer about its owner could not be read" };
|
|
59
|
+
}
|
|
60
|
+
return { known: true, email: body.ownerEmail.trim().toLowerCase() };
|
|
61
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Files only the owner can read: the OS session and the record of what this machine did on the
|
|
2
|
+
// OS. They live in `<tiller's config folder>/os`, a 0700 folder, as 0600 files. A file that is
|
|
3
|
+
// anything else when it is read (a link, another owner, readable by others) is not trusted.
|
|
4
|
+
import { randomBytes } from "node:crypto";
|
|
5
|
+
import { chmodSync, closeSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeSync, } from "node:fs";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
export class PrivateFileError extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "PrivateFileError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** The folder under `tiller`'s config folder that holds the OS session and the record. */
|
|
14
|
+
export function osFolder(configDir) {
|
|
15
|
+
return join(configDir, "os");
|
|
16
|
+
}
|
|
17
|
+
const ownUid = () => (typeof process.getuid === "function" ? process.getuid() : null);
|
|
18
|
+
function ensurePrivateFolder(folder) {
|
|
19
|
+
mkdirSync(folder, { recursive: true, mode: 0o700 });
|
|
20
|
+
const stat = lstatSync(folder);
|
|
21
|
+
if (!stat.isDirectory())
|
|
22
|
+
throw new PrivateFileError(`${folder} is not a folder`);
|
|
23
|
+
const uid = ownUid();
|
|
24
|
+
if (uid !== null && stat.uid !== uid)
|
|
25
|
+
throw new PrivateFileError(`${folder} belongs to another user`);
|
|
26
|
+
if ((stat.mode & 0o777) !== 0o700)
|
|
27
|
+
chmodSync(folder, 0o700);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The file's text, or null when there is no file. Throws when the file is not a plain file of
|
|
31
|
+
* this user's that nobody else can read: its content is then not used at all.
|
|
32
|
+
*/
|
|
33
|
+
export function readPrivateFile(path) {
|
|
34
|
+
let stat;
|
|
35
|
+
try {
|
|
36
|
+
stat = lstatSync(path);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error.code === "ENOENT")
|
|
40
|
+
return null;
|
|
41
|
+
throw new PrivateFileError(`${path} could not be read`);
|
|
42
|
+
}
|
|
43
|
+
if (!stat.isFile())
|
|
44
|
+
throw new PrivateFileError(`${path} is not a plain file`);
|
|
45
|
+
const uid = ownUid();
|
|
46
|
+
if (uid !== null && stat.uid !== uid)
|
|
47
|
+
throw new PrivateFileError(`${path} belongs to another user`);
|
|
48
|
+
if ((stat.mode & 0o077) !== 0)
|
|
49
|
+
throw new PrivateFileError(`${path} can be read by other users of this machine`);
|
|
50
|
+
const folder = lstatSync(dirname(path));
|
|
51
|
+
if (!folder.isDirectory() || (uid !== null && folder.uid !== uid) || (folder.mode & 0o077) !== 0) {
|
|
52
|
+
throw new PrivateFileError(`${dirname(path)} can be reached by other users of this machine`);
|
|
53
|
+
}
|
|
54
|
+
return readFileSync(path, "utf8");
|
|
55
|
+
}
|
|
56
|
+
/** Writes the file whole, as 0600 in a 0700 folder, and has it on disk before returning. */
|
|
57
|
+
export function writePrivateFile(path, text) {
|
|
58
|
+
const folder = dirname(path);
|
|
59
|
+
ensurePrivateFolder(folder);
|
|
60
|
+
const temporary = join(folder, `.${randomBytes(8).toString("hex")}.tmp`);
|
|
61
|
+
// "wx": the temporary file must be new, so a link planted under its name is never followed.
|
|
62
|
+
const handle = openSync(temporary, "wx", 0o600);
|
|
63
|
+
try {
|
|
64
|
+
writeSync(handle, text);
|
|
65
|
+
fsyncSync(handle);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
closeSync(handle);
|
|
69
|
+
rmSync(temporary, { force: true });
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
closeSync(handle);
|
|
73
|
+
chmodSync(temporary, 0o600);
|
|
74
|
+
renameSync(temporary, path);
|
|
75
|
+
try {
|
|
76
|
+
const folderHandle = openSync(folder, "r");
|
|
77
|
+
try {
|
|
78
|
+
fsyncSync(folderHandle);
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
closeSync(folderHandle);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// Not every platform lets a folder be synced; the file itself is.
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/** Removes the file. Returns whether there was one. */
|
|
89
|
+
export function removePrivateFile(path) {
|
|
90
|
+
try {
|
|
91
|
+
lstatSync(path);
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
rmSync(path, { force: true });
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the Hub may ask `tiller` to do on Overvues, and what `tiller` answers.
|
|
3
|
+
*
|
|
4
|
+
* The OS session is kept by `tiller` on the person's own machine and never leaves it. The Hub
|
|
5
|
+
* asks over the connection the machine already holds to it (`hub-client.ts`); `tiller` makes
|
|
6
|
+
* every OS call itself. This file is the whole contract. It must stay free of imports, Node
|
|
7
|
+
* modules included, because the Hub imports it (as it does `runner-slug.ts`).
|
|
8
|
+
*
|
|
9
|
+
* Rules `tiller` enforces (`os-machine.ts`):
|
|
10
|
+
* - A request is taken only from the Hub connection, addressed to this machine, and is refused
|
|
11
|
+
* unless every field validates here. Unknown fields are refused too.
|
|
12
|
+
* - With no OS session stored, everything is refused with `not-connected`.
|
|
13
|
+
* - A request that changes the OS (`deploy`, `redeploy`, `preview-publish`, `preview-connect`, `preview-remove`)
|
|
14
|
+
* needs an approval the owner's browser session made. `tiller` checks it back with the Hub
|
|
15
|
+
* over HTTPS, at the Hub address in its own settings, before it does anything
|
|
16
|
+
* (OS_APPROVAL_CHECK_PATH below).
|
|
17
|
+
* - Built files are fetched from the Hub by their fingerprint, at a path `tiller` builds itself
|
|
18
|
+
* (builtFilesPath), and are refused unless they hash to that fingerprint.
|
|
19
|
+
* - A `deploy` or a `preview-publish` runs only on the machine that built the files: the
|
|
20
|
+
* fingerprint, worked out here from the files handed over, must be in this machine's own
|
|
21
|
+
* record of what its build-and-test jobs produced for the app the request names (`appId`;
|
|
22
|
+
* `gadget-builds.json`). Otherwise it is refused with `not-built-here`, before anything is
|
|
23
|
+
* written or sent: the Ship id or approval id is not used up, and the same request may be sent
|
|
24
|
+
* again once this machine has built the files. This is what stops a Hub that changed the
|
|
25
|
+
* bytes and presented them under a new fingerprint. A `redeploy` takes its files from the OS
|
|
26
|
+
* itself and has no such check.
|
|
27
|
+
* - A Ship id or approval id is acted on once. A repeat is not acted on; it is answered from
|
|
28
|
+
* the record `tiller` keeps on disk.
|
|
29
|
+
*
|
|
30
|
+
* What the Hub implements (none of it is in `tiller`):
|
|
31
|
+
* 1. Send `os-request` and `os-watch` only on the WebSocket bound to the machine named, and
|
|
32
|
+
* only from the Hub's own code: never relay a client's message of these types. Take
|
|
33
|
+
* `os-received`, `os-response`, `os-status`, `os-head-changed` and `os-watch-problem` only
|
|
34
|
+
* from that machine's connection. Send `os-watch` again whenever `os-status` arrives.
|
|
35
|
+
* Keep what `os-status` said with the connection itself, so it lasts as long as the
|
|
36
|
+
* connection does (a Durable Object that hibernates keeps the socket and loses its memory),
|
|
37
|
+
* and with no word from a connection, send `os-status-request` rather than take the
|
|
38
|
+
* silence as "no session".
|
|
39
|
+
* 2. Approvals. A route that only the owner's signed-in browser session can call (not the
|
|
40
|
+
* control secret, not a machine or service credential) records an approval: its id (the
|
|
41
|
+
* Ship id for `deploy` and `redeploy`), who approved, and an end time at most an hour away.
|
|
42
|
+
* POST OS_APPROVAL_CHECK_PATH, called by the machine, answers `approved: true` only when
|
|
43
|
+
* that record exists, has not run out, and `osRequestSubject` of the request the Hub itself
|
|
44
|
+
* sent for it equals the `subject` posted; it answers with the subject it holds, not the
|
|
45
|
+
* one posted. The check may be repeated by the same machine; a different machine is refused.
|
|
46
|
+
* Nothing the control secret can call may create or change an approval. A `redeploy`
|
|
47
|
+
* names only Ship ids and the app, so its approval can be recorded in the same browser
|
|
48
|
+
* action as the Ship's, under a second Ship id the Hub picks then.
|
|
49
|
+
* 3. GET builtFilesPath(fingerprint): the files the build-and-test job froze, unchanged.
|
|
50
|
+
* 4. POST readFilesUploadPath(requestId): accepted only for a `read-files` request the Hub
|
|
51
|
+
* sent to that machine and has not had answered; the Hub checks the fingerprint itself.
|
|
52
|
+
* 5. Record a deploy's commit from `os-response` before anything else. On `already-acted`
|
|
53
|
+
* or a lost answer, read the head; never send the same Ship id expecting a second deploy.
|
|
54
|
+
* 6. Send a `deploy` or a `preview-publish` to the machine whose job built the files. On
|
|
55
|
+
* `not-built-here`, have the job run again on that machine; the same request may then be sent
|
|
56
|
+
* once more if the job gives the same fingerprint, and otherwise the person is asked to Ship
|
|
57
|
+
* (or publish the preview) again.
|
|
58
|
+
* 7. Read a `read-files` answer with parseOsReadFilesResult, which refuses a field this
|
|
59
|
+
* version does not know, as `tiller` refuses one in a request. Fields are added on both
|
|
60
|
+
* sides together: the optional `author` of `read-files` was (2026-11-13), and needed no
|
|
61
|
+
* new protocol number because both sides took it at once.
|
|
62
|
+
*/
|
|
63
|
+
export const OS_PROTOCOL = 1;
|
|
64
|
+
const ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
65
|
+
const WORKSPACE_ID = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/;
|
|
66
|
+
const COMMIT = /^[0-9a-f]{40}$/;
|
|
67
|
+
const FINGERPRINT = /^sha256:[0-9a-f]{64}$/;
|
|
68
|
+
/** As the OS adapter and the Gatekeeper catalog define a preview's id. */
|
|
69
|
+
const PREVIEW_ID = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,22}[A-Za-z0-9])?$/;
|
|
70
|
+
const APP_ID = /^[A-Za-z0-9][A-Za-z0-9_.:-]{0,127}$/;
|
|
71
|
+
const MAX_TITLE = 120;
|
|
72
|
+
const CONNECTION_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/;
|
|
73
|
+
/** A request, Ship or approval id: letters, digits, `_` and `-`, at most 64 characters. */
|
|
74
|
+
export const isOsId = (value) => typeof value === "string" && ID.test(value);
|
|
75
|
+
/** The Hub's id for an app, as the build-and-test job takes it: a plain name with no `..`. */
|
|
76
|
+
export const isOsAppId = (value) => typeof value === "string" && APP_ID.test(value) && !value.includes("..");
|
|
77
|
+
export const isOsWorkspaceId = (value) => typeof value === "string" && WORKSPACE_ID.test(value);
|
|
78
|
+
export const isOsGadgetId = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
79
|
+
export const isOsCommit = (value) => typeof value === "string" && COMMIT.test(value);
|
|
80
|
+
export const isOsFingerprint = (value) => typeof value === "string" && FINGERPRINT.test(value);
|
|
81
|
+
export const isOsPreviewId = (value) => typeof value === "string" && PREVIEW_ID.test(value);
|
|
82
|
+
/** A connection's name in an app, as gadget.json's `bindings` names it, such as `SHELF`. */
|
|
83
|
+
export const isOsConnectionName = (value) => typeof value === "string" && CONNECTION_NAME.test(value);
|
|
84
|
+
/** The most connections a preview request names as turned on. */
|
|
85
|
+
export const OS_PREVIEW_MAX_TURNED_ON = 32;
|
|
86
|
+
/** A title or a branch name: one line of text, at most 120 characters, no control characters. */
|
|
87
|
+
export const isOsTitle = (value) => typeof value === "string" && value.length > 0 && value.length <= MAX_TITLE && value.trim() === value
|
|
88
|
+
&& [...value].every((character) => {
|
|
89
|
+
const code = character.codePointAt(0) ?? 0;
|
|
90
|
+
return code >= 0x20 && code !== 0x7f && code !== 0x2028 && code !== 0x2029;
|
|
91
|
+
});
|
|
92
|
+
// ── Hub HTTP routes `tiller` calls ───────────────────────────────────
|
|
93
|
+
//
|
|
94
|
+
// All three are on the Hub address in `tiller`'s own settings, with the machine's credentials.
|
|
95
|
+
// A request never carries an address: `tiller` builds these paths itself.
|
|
96
|
+
/** POST. Body OsApprovalCheck, answer OsApprovalAnswer. */
|
|
97
|
+
export const OS_APPROVAL_CHECK_PATH = "/api/machine/os/approvals/check";
|
|
98
|
+
/** GET. Answers `{ "files": { "<path>": "<text>" } }`: the built files frozen under this fingerprint. */
|
|
99
|
+
export function builtFilesPath(fingerprint) {
|
|
100
|
+
if (!isOsFingerprint(fingerprint))
|
|
101
|
+
throw new Error("builtFilesPath: not a fingerprint");
|
|
102
|
+
return `/api/machine/os/built-files/${fingerprint.slice("sha256:".length)}`;
|
|
103
|
+
}
|
|
104
|
+
/** POST. Body OsReadFilesUpload: the files `read-files` read, for the request named. */
|
|
105
|
+
export function readFilesUploadPath(requestId) {
|
|
106
|
+
if (!isOsId(requestId))
|
|
107
|
+
throw new Error("readFilesUploadPath: not a request id");
|
|
108
|
+
return `/api/machine/os/read-files/${requestId}`;
|
|
109
|
+
}
|
|
110
|
+
/** How far back from a gadget's head `read-files` looks for the commit it is asked for. */
|
|
111
|
+
export const OS_READ_FILES_HISTORY_DEPTH = 200;
|
|
112
|
+
const MAX_AUTHOR_FIELD = 200;
|
|
113
|
+
/** One line of at most 200 characters with no control characters and no angle brackets: safe in a git author line. */
|
|
114
|
+
const isAuthorField = (value, empty) => typeof value === "string" && value.length <= MAX_AUTHOR_FIELD && (empty || value.trim().length > 0)
|
|
115
|
+
&& [...value].every((character) => {
|
|
116
|
+
const code = character.codePointAt(0) ?? 0;
|
|
117
|
+
return code >= 0x20 && code !== 0x7f && code !== 0x2028 && code !== 0x2029 && character !== "<" && character !== ">";
|
|
118
|
+
});
|
|
119
|
+
/** Whether an author can stand as a git commit's author: a name, an email (which may be empty), each one plain line. */
|
|
120
|
+
export function isOsCommitAuthor(value) {
|
|
121
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
122
|
+
return false;
|
|
123
|
+
const record = value;
|
|
124
|
+
return Object.keys(record).length === 2 && isAuthorField(record.name, false) && isAuthorField(record.email, true);
|
|
125
|
+
}
|
|
126
|
+
export const OS_NOT_CONNECTED_MESSAGE = "Connect this machine to the OS: run `tiller os connect` on it.";
|
|
127
|
+
export const OS_HUB_TO_MACHINE_TYPES = ["os-request", "os-watch", "os-status-request"];
|
|
128
|
+
// ── The approval ─────────────────────────────────────────────────────
|
|
129
|
+
/** An approval is refused if the Hub says it lasts longer than this from now. */
|
|
130
|
+
export const OS_APPROVAL_MAX_LIFETIME_MS = 60 * 60 * 1000;
|
|
131
|
+
/** What marks an approval as made by the owner's signed-in browser, and by nothing else. */
|
|
132
|
+
export const OS_APPROVED_BY = "owner-browser-session";
|
|
133
|
+
/** The id of the approval a request needs: the Ship id, or the request's own approval id. */
|
|
134
|
+
export function osApprovalId(request) {
|
|
135
|
+
return request.action === "deploy" || request.action === "redeploy" ? request.shipId : request.approvalId;
|
|
136
|
+
}
|
|
137
|
+
/** Whether a request changes the OS, and so needs an approval. */
|
|
138
|
+
export function needsOsApproval(request) {
|
|
139
|
+
return request.action === "deploy" || request.action === "redeploy"
|
|
140
|
+
|| request.action === "preview-publish" || request.action === "preview-connect" || request.action === "preview-remove";
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A request as one string, the same on both sides: JSON with every object's keys in order.
|
|
144
|
+
* An approval is for exactly one of these. The Hub computes it for the request it is about to
|
|
145
|
+
* send and compares it with what the owner's browser session approved; `tiller` compares what
|
|
146
|
+
* the Hub answers with the request it received.
|
|
147
|
+
*/
|
|
148
|
+
export function osRequestSubject(request) {
|
|
149
|
+
const ordered = (value) => {
|
|
150
|
+
if (Array.isArray(value))
|
|
151
|
+
return value.map(ordered);
|
|
152
|
+
if (value && typeof value === "object") {
|
|
153
|
+
const entries = Object.entries(value).filter(([, inner]) => inner !== undefined);
|
|
154
|
+
return Object.fromEntries(entries.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)).map(([key, inner]) => [key, ordered(inner)]));
|
|
155
|
+
}
|
|
156
|
+
return value;
|
|
157
|
+
};
|
|
158
|
+
return JSON.stringify(ordered(request));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Whether the Hub's answer approves exactly this request, now. Returns why not, in plain words,
|
|
162
|
+
* or null when it does.
|
|
163
|
+
*/
|
|
164
|
+
export function osApprovalProblem(answer, request, now) {
|
|
165
|
+
if (!answer || typeof answer !== "object")
|
|
166
|
+
return "the Hub's answer was not an approval";
|
|
167
|
+
const record = answer;
|
|
168
|
+
if (record.approved !== true)
|
|
169
|
+
return "the Hub has no approval for it from the owner's browser";
|
|
170
|
+
if (record.approvedBy !== OS_APPROVED_BY)
|
|
171
|
+
return "the approval was not made by the owner's browser session";
|
|
172
|
+
if (record.approvalId !== osApprovalId(request))
|
|
173
|
+
return "the approval is for another id";
|
|
174
|
+
if (record.subject !== osRequestSubject(request))
|
|
175
|
+
return "the approval is for a different request";
|
|
176
|
+
if (typeof record.expiresAt !== "number" || !Number.isFinite(record.expiresAt))
|
|
177
|
+
return "the approval has no end time";
|
|
178
|
+
if (record.expiresAt <= now)
|
|
179
|
+
return "the approval has run out";
|
|
180
|
+
if (record.expiresAt - now > OS_APPROVAL_MAX_LIFETIME_MS)
|
|
181
|
+
return "the approval lasts longer than an approval may";
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
const bad = (message) => ({ ok: false, message });
|
|
185
|
+
/** An object with exactly these keys present (and the optional ones, when given). */
|
|
186
|
+
function fields(value, required, optional = []) {
|
|
187
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
188
|
+
return "it is not an object";
|
|
189
|
+
const record = value;
|
|
190
|
+
for (const key of required)
|
|
191
|
+
if (record[key] === undefined)
|
|
192
|
+
return `it has no ${key}`;
|
|
193
|
+
for (const key of Object.keys(record)) {
|
|
194
|
+
if (!required.includes(key) && !optional.includes(key))
|
|
195
|
+
return `it has a field this version does not know: ${JSON.stringify(key.slice(0, 40))}`;
|
|
196
|
+
}
|
|
197
|
+
return record;
|
|
198
|
+
}
|
|
199
|
+
function appRef(value, what) {
|
|
200
|
+
const record = fields(value, ["workspaceId", "gadgetId"]);
|
|
201
|
+
if (typeof record === "string")
|
|
202
|
+
return `${what}: ${record}`;
|
|
203
|
+
if (!isOsWorkspaceId(record.workspaceId))
|
|
204
|
+
return `${what}: the workspace id is not one`;
|
|
205
|
+
if (!isOsGadgetId(record.gadgetId))
|
|
206
|
+
return `${what}: the gadget id is not one`;
|
|
207
|
+
return { workspaceId: record.workspaceId, gadgetId: record.gadgetId };
|
|
208
|
+
}
|
|
209
|
+
/** A list of connection names turned on: an array of names, each once, sorted, at most OS_PREVIEW_MAX_TURNED_ON. */
|
|
210
|
+
function turnedOnNames(value, what) {
|
|
211
|
+
if (!Array.isArray(value) || value.length > OS_PREVIEW_MAX_TURNED_ON)
|
|
212
|
+
return `${what}: the connections turned on are not a list of at most ${OS_PREVIEW_MAX_TURNED_ON}`;
|
|
213
|
+
if (!value.every(isOsConnectionName))
|
|
214
|
+
return `${what}: a connection turned on is not a connection's name`;
|
|
215
|
+
const names = value;
|
|
216
|
+
for (let i = 1; i < names.length; i += 1)
|
|
217
|
+
if (!(names[i - 1] < names[i]))
|
|
218
|
+
return `${what}: the connections turned on must be sorted, each once`;
|
|
219
|
+
return [...names];
|
|
220
|
+
}
|
|
221
|
+
/** Validates a request. What comes back holds only the fields this file defines. */
|
|
222
|
+
export function parseOsRequest(value) {
|
|
223
|
+
const action = value?.action;
|
|
224
|
+
switch (action) {
|
|
225
|
+
case "deploy": {
|
|
226
|
+
const record = fields(value, ["action", "shipId", "appId", "target", "fingerprint"]);
|
|
227
|
+
if (typeof record === "string")
|
|
228
|
+
return bad(`deploy: ${record}`);
|
|
229
|
+
if (!isOsId(record.shipId))
|
|
230
|
+
return bad("deploy: the Ship id is not one");
|
|
231
|
+
if (!isOsAppId(record.appId))
|
|
232
|
+
return bad("deploy: the app's id is not one");
|
|
233
|
+
if (!isOsFingerprint(record.fingerprint))
|
|
234
|
+
return bad("deploy: the fingerprint of the built files is not one");
|
|
235
|
+
const kind = record.target?.kind;
|
|
236
|
+
let target;
|
|
237
|
+
if (kind === "app") {
|
|
238
|
+
const t = fields(record.target, ["kind", "workspaceId", "gadgetId", "baseCommit"]);
|
|
239
|
+
if (typeof t === "string")
|
|
240
|
+
return bad(`deploy: the target: ${t}`);
|
|
241
|
+
if (!isOsWorkspaceId(t.workspaceId) || !isOsGadgetId(t.gadgetId))
|
|
242
|
+
return bad("deploy: the target's workspace or gadget id is not one");
|
|
243
|
+
if (!isOsCommit(t.baseCommit))
|
|
244
|
+
return bad("deploy: the base commit is not a commit");
|
|
245
|
+
target = { kind, workspaceId: t.workspaceId, gadgetId: t.gadgetId, baseCommit: t.baseCommit };
|
|
246
|
+
}
|
|
247
|
+
else if (kind === "first-deploy") {
|
|
248
|
+
const t = fields(record.target, ["kind", "title"], ["workspaceId"]);
|
|
249
|
+
if (typeof t === "string")
|
|
250
|
+
return bad(`deploy: the target: ${t}`);
|
|
251
|
+
if (!isOsTitle(t.title))
|
|
252
|
+
return bad("deploy: a first deploy needs the app's title");
|
|
253
|
+
if (t.workspaceId !== undefined && !isOsWorkspaceId(t.workspaceId))
|
|
254
|
+
return bad("deploy: the workspace id is not one");
|
|
255
|
+
target = { kind, title: t.title, ...(t.workspaceId !== undefined ? { workspaceId: t.workspaceId } : {}) };
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
return bad("deploy: the target must be an app or a first deploy");
|
|
259
|
+
}
|
|
260
|
+
return { ok: true, value: { action, shipId: record.shipId, appId: record.appId, target, fingerprint: record.fingerprint } };
|
|
261
|
+
}
|
|
262
|
+
case "redeploy": {
|
|
263
|
+
const record = fields(value, ["action", "shipId", "ofShipId", "workspaceId", "gadgetId"]);
|
|
264
|
+
if (typeof record === "string")
|
|
265
|
+
return bad(`redeploy: ${record}`);
|
|
266
|
+
if (!isOsId(record.shipId) || !isOsId(record.ofShipId))
|
|
267
|
+
return bad("redeploy: a Ship id is not one");
|
|
268
|
+
if (record.shipId === record.ofShipId)
|
|
269
|
+
return bad("redeploy: it needs a Ship id of its own");
|
|
270
|
+
if (!isOsWorkspaceId(record.workspaceId) || !isOsGadgetId(record.gadgetId))
|
|
271
|
+
return bad("redeploy: the workspace or gadget id is not one");
|
|
272
|
+
return { ok: true, value: { action, shipId: record.shipId, ofShipId: record.ofShipId, workspaceId: record.workspaceId, gadgetId: record.gadgetId } };
|
|
273
|
+
}
|
|
274
|
+
case "read-head":
|
|
275
|
+
case "read-connections": {
|
|
276
|
+
const record = fields(value, ["action", "for", "workspaceId", "gadgetId"]);
|
|
277
|
+
if (typeof record === "string")
|
|
278
|
+
return bad(`${action}: ${record}`);
|
|
279
|
+
if (!isOsWorkspaceId(record.workspaceId) || !isOsGadgetId(record.gadgetId))
|
|
280
|
+
return bad(`${action}: the workspace or gadget id is not one`);
|
|
281
|
+
if (action === "read-head") {
|
|
282
|
+
if (record.for !== "pull" && record.for !== "ship" && record.for !== "open")
|
|
283
|
+
return bad("read-head: it does not say what it is for");
|
|
284
|
+
return { ok: true, value: { action, for: record.for, workspaceId: record.workspaceId, gadgetId: record.gadgetId } };
|
|
285
|
+
}
|
|
286
|
+
if (record.for !== "connection-report")
|
|
287
|
+
return bad("read-connections: it does not say what it is for");
|
|
288
|
+
return { ok: true, value: { action, for: record.for, workspaceId: record.workspaceId, gadgetId: record.gadgetId } };
|
|
289
|
+
}
|
|
290
|
+
case "read-files": {
|
|
291
|
+
const record = fields(value, ["action", "for", "workspaceId", "gadgetId", "commitId"]);
|
|
292
|
+
if (typeof record === "string")
|
|
293
|
+
return bad(`read-files: ${record}`);
|
|
294
|
+
if (record.for !== "pull")
|
|
295
|
+
return bad("read-files: it does not say what it is for");
|
|
296
|
+
if (!isOsWorkspaceId(record.workspaceId) || !isOsGadgetId(record.gadgetId))
|
|
297
|
+
return bad("read-files: the workspace or gadget id is not one");
|
|
298
|
+
if (!isOsCommit(record.commitId))
|
|
299
|
+
return bad("read-files: the commit is not one");
|
|
300
|
+
return { ok: true, value: { action, for: record.for, workspaceId: record.workspaceId, gadgetId: record.gadgetId, commitId: record.commitId } };
|
|
301
|
+
}
|
|
302
|
+
case "preview-publish": {
|
|
303
|
+
const record = fields(value, ["action", "approvalId", "appId", "previewId", "live", "appTitle", "branchName", "fingerprint", "turnedOn"], ["previewsWorkspaceId"]);
|
|
304
|
+
if (typeof record === "string")
|
|
305
|
+
return bad(`preview-publish: ${record}`);
|
|
306
|
+
if (!isOsId(record.approvalId))
|
|
307
|
+
return bad("preview-publish: the approval id is not one");
|
|
308
|
+
if (!isOsAppId(record.appId))
|
|
309
|
+
return bad("preview-publish: the app's id is not one");
|
|
310
|
+
if (!isOsPreviewId(record.previewId))
|
|
311
|
+
return bad("preview-publish: the preview id is not one");
|
|
312
|
+
const live = appRef(record.live, "preview-publish: the live app");
|
|
313
|
+
if (typeof live === "string")
|
|
314
|
+
return bad(live);
|
|
315
|
+
if (!isOsTitle(record.appTitle) || !isOsTitle(record.branchName))
|
|
316
|
+
return bad("preview-publish: it needs the app's title and the change's name");
|
|
317
|
+
if (!isOsFingerprint(record.fingerprint))
|
|
318
|
+
return bad("preview-publish: the fingerprint of the built files is not one");
|
|
319
|
+
if (record.previewsWorkspaceId !== undefined && !isOsWorkspaceId(record.previewsWorkspaceId))
|
|
320
|
+
return bad("preview-publish: the Previews workspace id is not one");
|
|
321
|
+
if (record.previewsWorkspaceId === live.workspaceId)
|
|
322
|
+
return bad("preview-publish: a preview is never in the live app's workspace");
|
|
323
|
+
const turnedOn = turnedOnNames(record.turnedOn, "preview-publish");
|
|
324
|
+
if (typeof turnedOn === "string")
|
|
325
|
+
return bad(turnedOn);
|
|
326
|
+
return {
|
|
327
|
+
ok: true,
|
|
328
|
+
value: {
|
|
329
|
+
action, approvalId: record.approvalId, appId: record.appId, previewId: record.previewId, live,
|
|
330
|
+
...(record.previewsWorkspaceId !== undefined ? { previewsWorkspaceId: record.previewsWorkspaceId } : {}),
|
|
331
|
+
appTitle: record.appTitle, branchName: record.branchName, fingerprint: record.fingerprint, turnedOn,
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
case "preview-connect": {
|
|
336
|
+
const record = fields(value, ["action", "approvalId", "previewId", "workspaceId", "gadgetId", "live", "branchName", "turnedOn"]);
|
|
337
|
+
if (typeof record === "string")
|
|
338
|
+
return bad(`preview-connect: ${record}`);
|
|
339
|
+
if (!isOsId(record.approvalId))
|
|
340
|
+
return bad("preview-connect: the approval id is not one");
|
|
341
|
+
if (!isOsPreviewId(record.previewId))
|
|
342
|
+
return bad("preview-connect: the preview id is not one");
|
|
343
|
+
if (!isOsWorkspaceId(record.workspaceId) || !isOsGadgetId(record.gadgetId))
|
|
344
|
+
return bad("preview-connect: the workspace or gadget id is not one");
|
|
345
|
+
const live = appRef(record.live, "preview-connect: the live app");
|
|
346
|
+
if (typeof live === "string")
|
|
347
|
+
return bad(live);
|
|
348
|
+
if (live.workspaceId === record.workspaceId)
|
|
349
|
+
return bad("preview-connect: a preview is never in the live app's workspace");
|
|
350
|
+
if (!isOsTitle(record.branchName))
|
|
351
|
+
return bad("preview-connect: it needs the change's name");
|
|
352
|
+
const turnedOn = turnedOnNames(record.turnedOn, "preview-connect");
|
|
353
|
+
if (typeof turnedOn === "string")
|
|
354
|
+
return bad(turnedOn);
|
|
355
|
+
return {
|
|
356
|
+
ok: true,
|
|
357
|
+
value: {
|
|
358
|
+
action, approvalId: record.approvalId, previewId: record.previewId, workspaceId: record.workspaceId, gadgetId: record.gadgetId,
|
|
359
|
+
live, branchName: record.branchName, turnedOn,
|
|
360
|
+
},
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
case "preview-remove": {
|
|
364
|
+
const record = fields(value, ["action", "approvalId", "previewId", "workspaceId", "gadgetId", "live"]);
|
|
365
|
+
if (typeof record === "string")
|
|
366
|
+
return bad(`preview-remove: ${record}`);
|
|
367
|
+
if (!isOsId(record.approvalId))
|
|
368
|
+
return bad("preview-remove: the approval id is not one");
|
|
369
|
+
if (!isOsPreviewId(record.previewId))
|
|
370
|
+
return bad("preview-remove: the preview id is not one");
|
|
371
|
+
if (!isOsWorkspaceId(record.workspaceId) || (record.gadgetId !== null && !isOsGadgetId(record.gadgetId)))
|
|
372
|
+
return bad("preview-remove: the workspace or gadget id is not one");
|
|
373
|
+
const live = appRef(record.live, "preview-remove: the live app");
|
|
374
|
+
if (typeof live === "string")
|
|
375
|
+
return bad(live);
|
|
376
|
+
if (live.workspaceId === record.workspaceId)
|
|
377
|
+
return bad("preview-remove: a preview is never in the live app's workspace");
|
|
378
|
+
return {
|
|
379
|
+
ok: true,
|
|
380
|
+
value: { action, approvalId: record.approvalId, previewId: record.previewId, workspaceId: record.workspaceId, gadgetId: record.gadgetId, live },
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
default:
|
|
384
|
+
return bad("it names no action this version knows");
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Reads a `read-files` answer, for the Hub. A field this version does not know refuses the
|
|
389
|
+
* answer; an `author` that isOsCommitAuthor does not take is left out, not refused.
|
|
390
|
+
*/
|
|
391
|
+
export function parseOsReadFilesResult(value) {
|
|
392
|
+
const record = fields(value, ["workspaceId", "gadgetId", "commitId", "fingerprint", "fileCount", "notRead"], ["author"]);
|
|
393
|
+
if (typeof record === "string")
|
|
394
|
+
return bad(`read-files answer: ${record}`);
|
|
395
|
+
if (!isOsWorkspaceId(record.workspaceId) || !isOsGadgetId(record.gadgetId) || !isOsCommit(record.commitId) || !isOsFingerprint(record.fingerprint))
|
|
396
|
+
return bad("read-files answer: the app, commit or fingerprint is not one");
|
|
397
|
+
if (typeof record.fileCount !== "number" || !Number.isSafeInteger(record.fileCount) || record.fileCount < 0 || !Array.isArray(record.notRead))
|
|
398
|
+
return bad("read-files answer: the file count or the files not read are not ones");
|
|
399
|
+
return {
|
|
400
|
+
ok: true,
|
|
401
|
+
value: {
|
|
402
|
+
workspaceId: record.workspaceId, gadgetId: record.gadgetId, commitId: record.commitId, fingerprint: record.fingerprint,
|
|
403
|
+
fileCount: record.fileCount, notRead: record.notRead,
|
|
404
|
+
...(isOsCommitAuthor(record.author) ? { author: { name: record.author.name, email: record.author.email } } : {}),
|
|
405
|
+
},
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/** Validates an `os-request` message from the Hub. */
|
|
409
|
+
export function parseOsRequestMessage(value) {
|
|
410
|
+
const record = fields(value, ["type", "protocol", "requestId", "machineId", "request"]);
|
|
411
|
+
if (typeof record === "string")
|
|
412
|
+
return bad(`the request: ${record}`);
|
|
413
|
+
if (record.type !== "os-request")
|
|
414
|
+
return bad("it is not an OS request");
|
|
415
|
+
if (record.protocol !== OS_PROTOCOL)
|
|
416
|
+
return bad(`it is for another version of the protocol (this is version ${OS_PROTOCOL})`);
|
|
417
|
+
if (!isOsId(record.requestId))
|
|
418
|
+
return bad("the request id is not one");
|
|
419
|
+
if (typeof record.machineId !== "string" || !record.machineId)
|
|
420
|
+
return bad("it names no machine");
|
|
421
|
+
const request = parseOsRequest(record.request);
|
|
422
|
+
if (!request.ok)
|
|
423
|
+
return request;
|
|
424
|
+
return { ok: true, value: { type: "os-request", protocol: OS_PROTOCOL, requestId: record.requestId, machineId: record.machineId, request: request.value } };
|
|
425
|
+
}
|
|
426
|
+
export const OS_WATCH_MIN_SECONDS = 15;
|
|
427
|
+
export const OS_WATCH_MAX_SECONDS = 3600;
|
|
428
|
+
export const OS_WATCH_DEFAULT_SECONDS = 60;
|
|
429
|
+
export const OS_WATCH_MAX_APPS = 200;
|
|
430
|
+
/** Validates an `os-watch` message from the Hub. */
|
|
431
|
+
export function parseOsWatchMessage(value) {
|
|
432
|
+
const record = fields(value, ["type", "protocol", "machineId", "apps"], ["intervalSeconds", "checkNow"]);
|
|
433
|
+
if (typeof record === "string")
|
|
434
|
+
return bad(`the watch: ${record}`);
|
|
435
|
+
if (record.type !== "os-watch")
|
|
436
|
+
return bad("it is not a watch");
|
|
437
|
+
if (record.protocol !== OS_PROTOCOL)
|
|
438
|
+
return bad(`it is for another version of the protocol (this is version ${OS_PROTOCOL})`);
|
|
439
|
+
if (typeof record.machineId !== "string" || !record.machineId)
|
|
440
|
+
return bad("it names no machine");
|
|
441
|
+
if (!Array.isArray(record.apps) || record.apps.length > OS_WATCH_MAX_APPS)
|
|
442
|
+
return bad("the watch: its list of apps is not one");
|
|
443
|
+
const apps = [];
|
|
444
|
+
for (const entry of record.apps) {
|
|
445
|
+
const app = fields(entry, ["workspaceId", "gadgetId"], ["lastCommit"]);
|
|
446
|
+
if (typeof app === "string")
|
|
447
|
+
return bad(`the watch: an app: ${app}`);
|
|
448
|
+
if (!isOsWorkspaceId(app.workspaceId) || !isOsGadgetId(app.gadgetId))
|
|
449
|
+
return bad("the watch: an app's workspace or gadget id is not one");
|
|
450
|
+
if (app.lastCommit !== undefined && !isOsCommit(app.lastCommit))
|
|
451
|
+
return bad("the watch: an app's last commit is not a commit");
|
|
452
|
+
apps.push({ workspaceId: app.workspaceId, gadgetId: app.gadgetId, ...(app.lastCommit !== undefined ? { lastCommit: app.lastCommit } : {}) });
|
|
453
|
+
}
|
|
454
|
+
const interval = record.intervalSeconds;
|
|
455
|
+
if (interval !== undefined && (typeof interval !== "number" || !Number.isInteger(interval) || interval < OS_WATCH_MIN_SECONDS || interval > OS_WATCH_MAX_SECONDS)) {
|
|
456
|
+
return bad(`the watch: the interval must be between ${OS_WATCH_MIN_SECONDS} and ${OS_WATCH_MAX_SECONDS} seconds`);
|
|
457
|
+
}
|
|
458
|
+
if (record.checkNow !== undefined && typeof record.checkNow !== "boolean")
|
|
459
|
+
return bad("the watch: checkNow is not true or false");
|
|
460
|
+
return {
|
|
461
|
+
ok: true,
|
|
462
|
+
value: {
|
|
463
|
+
type: "os-watch", protocol: OS_PROTOCOL, machineId: record.machineId, apps,
|
|
464
|
+
...(interval !== undefined ? { intervalSeconds: interval } : {}),
|
|
465
|
+
...(record.checkNow !== undefined ? { checkNow: record.checkNow } : {}),
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
}
|