@parhelia/capture 0.4.13062 → 0.4.13194
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 +23 -4
- package/dist/cli.js +101 -19
- package/dist/cmsJob.d.ts +9 -0
- package/dist/cmsJob.d.ts.map +1 -1
- package/dist/cmsJob.js +81 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/install/install.d.ts +4 -0
- package/dist/install/install.d.ts.map +1 -1
- package/dist/install/install.js +40 -10
- package/dist/install/layout.d.ts +9 -0
- package/dist/install/layout.d.ts.map +1 -1
- package/dist/install/layout.js +7 -1
- package/dist/install/manifestSignature.d.ts +30 -0
- package/dist/install/manifestSignature.d.ts.map +1 -0
- package/dist/install/manifestSignature.js +93 -0
- package/dist/install/releaseKeys.d.ts +2 -0
- package/dist/install/releaseKeys.d.ts.map +1 -0
- package/dist/install/releaseKeys.js +16 -0
- package/dist/install/services.d.ts +12 -0
- package/dist/install/services.d.ts.map +1 -1
- package/dist/install/services.js +45 -1
- package/dist/install/units.d.ts +8 -0
- package/dist/install/units.d.ts.map +1 -1
- package/dist/install/units.js +39 -3
- package/dist/install/updateLock.d.ts +14 -0
- package/dist/install/updateLock.d.ts.map +1 -0
- package/dist/install/updateLock.js +75 -0
- package/dist/install/updater.d.ts +28 -1
- package/dist/install/updater.d.ts.map +1 -1
- package/dist/install/updater.js +74 -2
- package/dist/install/versions.d.ts +11 -1
- package/dist/install/versions.d.ts.map +1 -1
- package/dist/install/versions.js +16 -2
- package/dist/isolation.d.ts +17 -1
- package/dist/isolation.d.ts.map +1 -1
- package/dist/isolation.js +21 -5
- package/dist/keptFor.d.ts +8 -0
- package/dist/keptFor.d.ts.map +1 -0
- package/dist/keptFor.js +28 -0
- package/dist/parheliaClient.d.ts +13 -0
- package/dist/parheliaClient.d.ts.map +1 -1
- package/dist/parheliaClient.js +7 -0
- package/dist/webIsolation.d.ts +2 -0
- package/dist/webIsolation.d.ts.map +1 -1
- package/dist/webIsolation.js +7 -5
- package/dist/webJob.d.ts +13 -0
- package/dist/webJob.d.ts.map +1 -1
- package/dist/webJob.js +90 -10
- package/dist/webPage.d.ts +30 -0
- package/dist/webPage.d.ts.map +1 -0
- package/dist/webPage.js +257 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +6 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,14 +25,15 @@ What `install` sets up on Linux: the users `parhelia-capture` (the worker) and `
|
|
|
25
25
|
whose only group is `parhelia-capture-ipc`); the code under `/opt/parhelia-capture/versions/<version>` with the `current`
|
|
26
26
|
link, root-owned and read-only to both; the key `/etc/parhelia-capture/worker.key` (0600, the worker's); Chromium's libraries
|
|
27
27
|
and an emoji font on apt systems; the units `parhelia-capture-worker`, `parhelia-capture-browser-host` (no network of its
|
|
28
|
-
own, see below)
|
|
29
|
-
the code under `%ProgramFiles%\Parhelia Capture`, the data and key under
|
|
30
|
-
off, the browser's outbound firewall rule, and
|
|
28
|
+
own, see below), `parhelia-capture-updater` with its timer and `parhelia-capture-update-watch`; and the command
|
|
29
|
+
`/usr/local/sbin/parhelia-capture`. On Windows: the code under `%ProgramFiles%\Parhelia Capture`, the data and key under
|
|
30
|
+
`%ProgramData%\Parhelia Capture` with inheritance off, the browser's outbound firewall rule, and four scheduled tasks.
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
33
|
parhelia-capture status # versions, services, last poll, public websites, the updater's last run
|
|
34
34
|
parhelia-capture doctor # names what is wrong (Node, origin, SSO, key, permissions, sandbox, proxy or CA)
|
|
35
|
-
parhelia-capture update # an update now (also for "Notify only" workers); --from <tarball> for air-gapped ones
|
|
35
|
+
parhelia-capture update # an update now (also for "Notify only" workers); --from <tarball> for air-gapped ones;
|
|
36
|
+
# --allow-downgrade to go back to an older version the host names
|
|
36
37
|
parhelia-capture uninstall # removes everything; revoke the worker under Settings › Capture service
|
|
37
38
|
```
|
|
38
39
|
|
|
@@ -46,6 +47,19 @@ and waits for the new version's first poll, else it rolls back. Each worker's po
|
|
|
46
47
|
default) or **Notify only**. Below the security minimum, or with a browser past its age, screenshots of public websites stay
|
|
47
48
|
off by themselves; CMS captures continue.
|
|
48
49
|
|
|
50
|
+
Releases are signed: the pipeline signs each manifest with an Ed25519 release key, and a sidecar that trusts release keys
|
|
51
|
+
(`src/install/releaseKeys.ts`) installs nothing whose manifest carries no valid signature, so a host that is compromised or
|
|
52
|
+
impersonated cannot name a build of its own. No updater goes back to an older version by itself
|
|
53
|
+
(`parhelia-capture update --allow-downgrade` does, by hand). Each worker follows the **Stable** or the **Canary** channel:
|
|
54
|
+
canary workers are named a new release first, and a reviewed promotion makes it the stable one
|
|
55
|
+
(docs/capture-service.md § Releasing).
|
|
56
|
+
|
|
57
|
+
The updater checks on a timer (every six hours on Linux, daily on Windows). **Update now** under Settings › Capture service
|
|
58
|
+
does not wait for it: the update watch (`parhelia-capture update-watch`, its own unit or task, as root/SYSTEM) holds a long
|
|
59
|
+
poll against Parhelia with the worker key and runs the same update the moment an administrator asks, also for "Notify only"
|
|
60
|
+
workers. One update runs at a time on a machine. An install from before the update watch gets it at the first check its new
|
|
61
|
+
version makes.
|
|
62
|
+
|
|
49
63
|
## What each job gets
|
|
50
64
|
|
|
51
65
|
- A browser of its own (the sidecar's Chromium build, sandbox on) whose every connection goes through the job's egress
|
|
@@ -80,5 +94,10 @@ socket but its own, D-Bus must be unreachable, and Chromium must run sandboxed.
|
|
|
80
94
|
be refused. When Parhelia runs on the same machine, name a probe on another host with `--probe-url`. On Windows, a sidecar
|
|
81
95
|
on the machine that runs Parhelia refuses `public-web` by name, because loopback is not filtered there.
|
|
82
96
|
|
|
97
|
+
An administrator can accept that on Windows with `install --accept-colocated-web --probe-url <a URL on another host>`. Only
|
|
98
|
+
the egress proxy then keeps a captured page from Parhelia and that machine's local services, so the self-test requires the
|
|
99
|
+
proxy's refusal of Parhelia's address, and the worker reports `capture-web-colocated-accepted` as a problem on every poll.
|
|
100
|
+
The option changes nothing on Linux or on a machine that does not run Parhelia.
|
|
101
|
+
|
|
83
102
|
Local development: `npm run capture` (repository root) runs a worker from source against :5090 with a dev key;
|
|
84
103
|
`scripts/run-scenario.ps1 <scenario> -Capture` starts one with the scenario and gives the host the matching key.
|
package/dist/cli.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
* Capture sidecar CS4-CS6: the command line.
|
|
4
4
|
* install / uninstall / status / update the service on this machine (CS6: units or tasks, the updater, the hashes)
|
|
5
|
+
* update-watch the updater's long poll for "Update now" (its unit or task starts it)
|
|
5
6
|
* start the worker (an installed one reads --config; with --web the public-web profile)
|
|
6
7
|
* browser-host the isolated browser host (its unit starts it)
|
|
7
8
|
* doctor names what is wrong; --profile public-web proves the isolation; --quick is the
|
|
@@ -18,9 +19,10 @@ import { runBrowserHost } from "./browserHost.js";
|
|
|
18
19
|
import { generalChecks, printChecks, quickCapture } from "./install/doctor.js";
|
|
19
20
|
import { install, statusLines, uninstall } from "./install/install.js";
|
|
20
21
|
import { layoutFor } from "./install/layout.js";
|
|
21
|
-
import { selfTest, services, windowsFirewall } from "./install/services.js";
|
|
22
|
+
import { ensureUpdateWatch, restartUpdateWatch, selfTest, services, windowsFirewall } from "./install/services.js";
|
|
22
23
|
import { realSys } from "./install/sys.js";
|
|
23
|
-
import {
|
|
24
|
+
import { acquireUpdateLock } from "./install/updateLock.js";
|
|
25
|
+
import { runUpdate, watchForUpdateRequests } from "./install/updater.js";
|
|
24
26
|
import { browserOf, readRecord } from "./install/versions.js";
|
|
25
27
|
import { browserHostUnitProperties, ownAddresses, parheliaIsColocated, socketDirectoriesOutsideHiddenTrees } from "./isolation.js";
|
|
26
28
|
import { ParheliaClient, newWorkerKey } from "./parheliaClient.js";
|
|
@@ -34,17 +36,21 @@ Install (root on Linux, Administrator on Windows; Node 22 or later):
|
|
|
34
36
|
npx @parhelia/capture install --origin <url> --pair <XXXXX-XXXXX-XXXXX-XXXXX> [--name <name>] [--no-web]
|
|
35
37
|
[--probe-url <url>] [--public-url <url>] [--registry <url>] [--browser-mirror <url>]
|
|
36
38
|
[--browser-path <chrome> | --from <tarball>] [--key-file <path>]
|
|
37
|
-
|
|
39
|
+
[--accept-colocated-web]
|
|
40
|
+
parhelia-capture status | doctor [--profile public-web] | update [--from <tarball>] [--allow-downgrade] | uninstall [--keep-key]
|
|
38
41
|
|
|
39
42
|
By hand:
|
|
40
43
|
parhelia-capture pair --origin <url> --code <code> --key-file <path> [--name <name>]
|
|
41
44
|
parhelia-capture start (--config <file> | --origin <url> (--key-file <path> | env PARHELIA_CAPTURE_KEY)) [--browser <chrome>]
|
|
42
|
-
[--web [--socket-dir <dir>] [--probe-url <url>] [--public-url <url>]]
|
|
45
|
+
[--web [--socket-dir <dir>] [--probe-url <url>] [--public-url <url>] [--accept-colocated-web]]
|
|
43
46
|
parhelia-capture browser-host [--socket-dir <dir>] [--install-dir <dir> | --browser <chrome>]
|
|
44
47
|
parhelia-capture doctor --profile public-web (--config <file> | --origin <url> --key-file <path>) [--socket-dir <dir>]
|
|
48
|
+
[--probe-url <url>] [--public-url <url>] [--accept-colocated-web]
|
|
45
49
|
parhelia-capture unit-properties [--socket-dir <dir>] [--read-only <path>]... [--user-unit]
|
|
46
50
|
|
|
47
|
-
--origin is the address this machine reaches Parhelia at (often an internal one). The socket directory defaults to ${DEFAULT_SOCKET_DIR}
|
|
51
|
+
--origin is the address this machine reaches Parhelia at (often an internal one). The socket directory defaults to ${DEFAULT_SOCKET_DIR}.
|
|
52
|
+
--accept-colocated-web (Windows, with --probe-url) takes screenshots of public websites on the machine that runs Parhelia although
|
|
53
|
+
loopback is not filtered there: only the egress proxy then keeps a captured page from Parhelia, and the worker reports that as a problem.`;
|
|
48
54
|
function option(args, name) {
|
|
49
55
|
const at = args.indexOf(name);
|
|
50
56
|
return at >= 0 ? args[at + 1] : undefined;
|
|
@@ -78,6 +84,10 @@ function readConfig(args, fallback) {
|
|
|
78
84
|
return undefined;
|
|
79
85
|
}
|
|
80
86
|
}
|
|
87
|
+
/** Windows: the administrator's acceptance of public-web on Parhelia's own machine: an install's own, or by hand the flag. */
|
|
88
|
+
function acceptsColocated(args, config) {
|
|
89
|
+
return config ? config.acceptColocatedWeb === true : args.includes("--accept-colocated-web");
|
|
90
|
+
}
|
|
81
91
|
/** The running package and its playwright-core (a source build installs these as they are). */
|
|
82
92
|
function self() {
|
|
83
93
|
const require = createRequire(import.meta.url);
|
|
@@ -89,6 +99,24 @@ function self() {
|
|
|
89
99
|
};
|
|
90
100
|
}
|
|
91
101
|
const log = (line) => console.log(JSON.stringify({ at: new Date().toISOString(), ...line }));
|
|
102
|
+
/** What the updater's commands (`update`, `update-watch`) run with: the installed configuration, as root or an Administrator. */
|
|
103
|
+
function updaterContext(sys, args) {
|
|
104
|
+
const layout = layoutFor(process.platform);
|
|
105
|
+
const config = readConfig(args, layout.configFile);
|
|
106
|
+
if (!config)
|
|
107
|
+
throw new Error("The capture service is not installed here (no configuration).");
|
|
108
|
+
if (!sys.isPrivileged())
|
|
109
|
+
throw new Error("The updater owns the code: run it as root (Linux) or from an Administrator shell (Windows).");
|
|
110
|
+
const client = new ParheliaClient({ origin: config.origin, key: readKey(args, config), version: SIDECAR_VERSION });
|
|
111
|
+
return { layout, config, client };
|
|
112
|
+
}
|
|
113
|
+
function updaterDeps(sys, layout, config, client) {
|
|
114
|
+
return {
|
|
115
|
+
sys, layout, config, fetchManifest: () => client.manifest(), selfTest: selfTest(sys, layout, config),
|
|
116
|
+
services: services(sys, layout, config.web), firewall: process.platform === "win32" && config.web ? windowsFirewall(sys) : undefined,
|
|
117
|
+
log: (line) => console.log(line),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
92
120
|
async function main(argv) {
|
|
93
121
|
const [command, ...args] = argv;
|
|
94
122
|
if (Number(process.versions.node.split(".")[0]) < 22)
|
|
@@ -101,6 +129,7 @@ async function main(argv) {
|
|
|
101
129
|
const report = await install({
|
|
102
130
|
sys, layout, origin, pairCode: option(args, "--pair"), keyFile: option(args, "--key-file"), name: option(args, "--name") ?? hostname(),
|
|
103
131
|
web: args.includes("--no-web") ? false : undefined, probeUrl: option(args, "--probe-url"), publicUrl: option(args, "--public-url"),
|
|
132
|
+
acceptColocated: args.includes("--accept-colocated-web"),
|
|
104
133
|
registry: option(args, "--registry"), browserMirror: option(args, "--browser-mirror"), browserPath: option(args, "--browser-path"),
|
|
105
134
|
fromTarball: option(args, "--from"), self: self(), newKey: newWorkerKey,
|
|
106
135
|
pair: (at, code, key, name) => ParheliaClient.pair(at, code, key, name),
|
|
@@ -128,22 +157,74 @@ async function main(argv) {
|
|
|
128
157
|
console.log(line);
|
|
129
158
|
return;
|
|
130
159
|
case "update": {
|
|
131
|
-
const layout =
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
160
|
+
const { layout, config, client } = updaterContext(sys, args);
|
|
161
|
+
const auto = args.includes("--auto");
|
|
162
|
+
const release = acquireUpdateLock(layout.updateLockFile);
|
|
163
|
+
if (!release) {
|
|
164
|
+
// The update watch (or an update by hand) is at work: this check has nothing to add.
|
|
165
|
+
if (auto)
|
|
166
|
+
return void console.log("Another update is running on this machine; this check leaves it to it.");
|
|
167
|
+
throw new Error("Another update is running on this machine. 'parhelia-capture status' shows its outcome.");
|
|
168
|
+
}
|
|
169
|
+
let result;
|
|
170
|
+
try {
|
|
171
|
+
result = await runUpdate(updaterDeps(sys, layout, config, client), { auto, fromTarball: option(args, "--from"), allowDowngrade: !auto && args.includes("--allow-downgrade") });
|
|
172
|
+
}
|
|
173
|
+
finally {
|
|
174
|
+
release();
|
|
175
|
+
}
|
|
176
|
+
// An install from before "Update now" gets its update watch from the first check its new version makes.
|
|
177
|
+
try {
|
|
178
|
+
if (ensureUpdateWatch(sys, layout, config))
|
|
179
|
+
console.log("The update watch is installed: 'Update now' under Settings › Capture service reaches this machine.");
|
|
180
|
+
else if (result.result === "updated")
|
|
181
|
+
restartUpdateWatch(sys, layout);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
console.log(`The update watch could not be installed: ${error instanceof Error ? error.message : String(error)}`);
|
|
185
|
+
}
|
|
143
186
|
if (result.result === "refused" || result.result === "rolled-back" || result.result === "unreachable")
|
|
144
187
|
process.exitCode = 1;
|
|
145
188
|
return;
|
|
146
189
|
}
|
|
190
|
+
case "update-watch": {
|
|
191
|
+
const { layout, config, client } = updaterContext(sys, args);
|
|
192
|
+
const stopping = new AbortController();
|
|
193
|
+
process.once("SIGINT", () => stopping.abort());
|
|
194
|
+
process.once("SIGTERM", () => stopping.abort());
|
|
195
|
+
const sleep = (ms) => new Promise((resolve) => {
|
|
196
|
+
const timer = setTimeout(done, ms);
|
|
197
|
+
function done() {
|
|
198
|
+
clearTimeout(timer);
|
|
199
|
+
stopping.signal.removeEventListener("abort", done);
|
|
200
|
+
resolve();
|
|
201
|
+
}
|
|
202
|
+
stopping.signal.addEventListener("abort", done, { once: true });
|
|
203
|
+
});
|
|
204
|
+
const outcome = await watchForUpdateRequests({
|
|
205
|
+
wait: (waitMs) => client.updateWait(waitMs, AbortSignal.any([stopping.signal, AbortSignal.timeout(waitMs + 20_000)])),
|
|
206
|
+
update: async () => {
|
|
207
|
+
// The timer's check may be at work: wait for it, then look again (it may have installed the version already).
|
|
208
|
+
let release = acquireUpdateLock(layout.updateLockFile);
|
|
209
|
+
for (const until = Date.now() + 35 * 60_000; !release && Date.now() < until && !stopping.signal.aborted;) {
|
|
210
|
+
await sleep(5_000);
|
|
211
|
+
release = acquireUpdateLock(layout.updateLockFile);
|
|
212
|
+
}
|
|
213
|
+
if (!release)
|
|
214
|
+
throw new Error("another update on this machine did not finish");
|
|
215
|
+
try {
|
|
216
|
+
return await runUpdate(updaterDeps(sys, layout, config, client), { auto: false });
|
|
217
|
+
}
|
|
218
|
+
finally {
|
|
219
|
+
release();
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
sleep, now: Date.now, stopping: () => stopping.signal.aborted, log: (line) => console.log(line),
|
|
223
|
+
});
|
|
224
|
+
// After an update this process is the old version: it ends, and the service manager starts the new version's watch
|
|
225
|
+
// (systemd restarts it whatever the exit code; a Windows task restarts only one that failed).
|
|
226
|
+
process.exit(outcome === "updated" && process.platform === "win32" ? 1 : 0);
|
|
227
|
+
}
|
|
147
228
|
case "pair": {
|
|
148
229
|
const origin = required(args, "--origin");
|
|
149
230
|
const keyFile = required(args, "--key-file");
|
|
@@ -164,7 +245,8 @@ async function main(argv) {
|
|
|
164
245
|
const link = web ? await BrowserHostLink.listen(option(args, "--socket-dir") ?? config?.socketDir ?? DEFAULT_SOCKET_DIR, log, { groupAccess: config?.socketGroupAccess }) : undefined;
|
|
165
246
|
const worker = startWorker({
|
|
166
247
|
origin: config?.origin ?? required(args, "--origin"), key: readKey(args, config), version: SIDECAR_VERSION, launch: defaultLaunch(browser),
|
|
167
|
-
web: link ? { link, isolation: { probeUrl: option(args, "--probe-url") ?? config?.probeUrl, publicUrl: option(args, "--public-url") ?? config?.publicUrl
|
|
248
|
+
web: link ? { link, isolation: { probeUrl: option(args, "--probe-url") ?? config?.probeUrl, publicUrl: option(args, "--public-url") ?? config?.publicUrl,
|
|
249
|
+
acceptColocated: acceptsColocated(args, config) } } : undefined,
|
|
168
250
|
install: config ? { record, statusFile: config.statusFile, updaterStatusFile: config.updaterStatusFile } : undefined,
|
|
169
251
|
});
|
|
170
252
|
const stop = () => void worker.stop();
|
|
@@ -203,7 +285,7 @@ async function main(argv) {
|
|
|
203
285
|
if (!host)
|
|
204
286
|
throw new Error(`No browser host connected within 30 s: start 'parhelia-capture browser-host --socket-dir ${link.socketDir}' in its unit.`);
|
|
205
287
|
const report = await verifyWebIsolation({ client, link, probeUrl: option(args, "--probe-url") ?? config?.probeUrl,
|
|
206
|
-
publicUrl: option(args, "--public-url") ?? config?.publicUrl });
|
|
288
|
+
publicUrl: option(args, "--public-url") ?? config?.publicUrl, acceptColocated: acceptsColocated(args, config) });
|
|
207
289
|
printChecks(report.checks);
|
|
208
290
|
console.log(report.ok ? "The public-web profile can run here." : `${report.code}: ${report.reason}`);
|
|
209
291
|
if (!report.ok)
|
package/dist/cmsJob.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare const PREVIEW_HANDLE_COOKIE = "parhelia-preview";
|
|
|
13
13
|
export declare const PREVIEW_REFUSAL_HEADER = "parhelia-preview-refusal";
|
|
14
14
|
/** Stops animations, transitions and the caret before measurement (plan CS-D4 step 1); applied through re-validation. */
|
|
15
15
|
export declare const PRECONDITION_CSS = "*,*::before,*::after{animation:none!important;transition:none!important;caret-color:transparent!important;scroll-behavior:auto!important}";
|
|
16
|
+
/** The version of a job's `originAliases` this worker reads; any other is ignored. */
|
|
17
|
+
export declare const ORIGIN_ALIASES_VERSION = 1;
|
|
16
18
|
export type JobOutcome = {
|
|
17
19
|
kind: "result";
|
|
18
20
|
result: unknown;
|
|
@@ -38,6 +40,13 @@ export type CmsJobOptions = {
|
|
|
38
40
|
};
|
|
39
41
|
/** The `host:port` of an origin as the egress proxy sees it on CONNECT or in an absolute request URL. */
|
|
40
42
|
export declare function hostPortOf(origin: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* The origins a job names as its Parhelia's own (`originAliases`), as `scheme://host[:port]`, without the worker's own origin: none for a
|
|
45
|
+
* job without the field, of a version this worker does not know, or naming nothing that is an http(s) origin.
|
|
46
|
+
*/
|
|
47
|
+
export declare function originAliasesOf(offer: Pick<CaptureJobOffer, "originAliases">, origin: string): string[];
|
|
48
|
+
/** Where the job's browser loads `url` from: on an alias, the same path and query on the worker's own origin; null for any other URL. */
|
|
49
|
+
export declare function aliasedUrl(url: string, aliases: readonly string[], origin: string): string | null;
|
|
41
50
|
export declare function runCmsJob(offer: CaptureJobOffer, options: CmsJobOptions): Promise<JobOutcome>;
|
|
42
51
|
/** The code a frame URL carries and the same URL without it (the rest of the query as spelled); null for a URL with none. */
|
|
43
52
|
export declare function previewCodeOf(url: string): {
|
package/dist/cmsJob.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmsJob.d.ts","sourceRoot":"","sources":["../src/cmsJob.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cmsJob.d.ts","sourceRoot":"","sources":["../src/cmsJob.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,OAAO,EAAyC,MAAM,iBAAiB,CAAC;AACtF,OAAO,EAAqC,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,eAAO,MAAM,eAAe,iCAAiC,CAAC;AAC9D,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AACpD,eAAO,MAAM,iBAAiB,yBAAyB,CAAC;AACxD,eAAO,MAAM,aAAa,yBAAyB,CAAC;AACpD,eAAO,MAAM,aAAa,2BAA2B,CAAC;AACtD,eAAO,MAAM,cAAc,qBAAqB,CAAC;AACjD,0HAA0H;AAC1H,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AACzD,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AACxD,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE,yHAAyH;AACzH,eAAO,MAAM,gBAAgB,8IACgH,CAAC;AAE9I,sFAAsF;AACtF,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAOxC,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,CAAC;AAE1B,MAAM,MAAM,aAAa,G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ER = "parhelia-preview-refusal";
|
|
12
12
|
/** Stops animations, transitions and the caret before measurement (plan CS-D4 step 1); applied through re-validation. */
|
|
13
13
|
export const PRECONDITION_CSS = "*,*::before,*::after{animation:none!important;transition:none!important;caret-color:transparent!important;scroll-behavior:auto!important}";
|
|
14
|
+
/** The version of a job's `originAliases` this worker reads; any other is ignored. */
|
|
15
|
+
export const ORIGIN_ALIASES_VERSION = 1;
|
|
16
|
+
/** The most aliases a job's browser routes. */
|
|
17
|
+
const MAX_ORIGIN_ALIASES = 8;
|
|
14
18
|
const PREVIEW_REDEEM_TIMEOUT_MS = 15_000;
|
|
15
19
|
const PREVIEW_SESSION_TIMEOUT_MS = 3_000;
|
|
16
20
|
/** The `host:port` of an origin as the egress proxy sees it on CONNECT or in an absolute request URL. */
|
|
@@ -19,6 +23,80 @@ export function hostPortOf(origin) {
|
|
|
19
23
|
const port = url.port || (url.protocol === "https:" ? "443" : "80");
|
|
20
24
|
return `${url.hostname.toLowerCase()}:${port}`;
|
|
21
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* The origins a job names as its Parhelia's own (`originAliases`), as `scheme://host[:port]`, without the worker's own origin: none for a
|
|
28
|
+
* job without the field, of a version this worker does not know, or naming nothing that is an http(s) origin.
|
|
29
|
+
*/
|
|
30
|
+
export function originAliasesOf(offer, origin) {
|
|
31
|
+
const field = offer.originAliases;
|
|
32
|
+
if (!field || field.version !== ORIGIN_ALIASES_VERSION || !Array.isArray(field.origins))
|
|
33
|
+
return [];
|
|
34
|
+
const own = new URL(origin).origin;
|
|
35
|
+
const aliases = new Set();
|
|
36
|
+
for (const entry of field.origins) {
|
|
37
|
+
if (typeof entry !== "string")
|
|
38
|
+
continue;
|
|
39
|
+
let url;
|
|
40
|
+
try {
|
|
41
|
+
url = new URL(entry);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if ((url.protocol !== "http:" && url.protocol !== "https:") || url.username || url.password || url.origin === own)
|
|
47
|
+
continue;
|
|
48
|
+
aliases.add(url.origin);
|
|
49
|
+
if (aliases.size >= MAX_ORIGIN_ALIASES)
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
return [...aliases];
|
|
53
|
+
}
|
|
54
|
+
/** Where the job's browser loads `url` from: on an alias, the same path and query on the worker's own origin; null for any other URL. */
|
|
55
|
+
export function aliasedUrl(url, aliases, origin) {
|
|
56
|
+
let parsed;
|
|
57
|
+
try {
|
|
58
|
+
parsed = new URL(url);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
if (!aliases.includes(parsed.origin))
|
|
64
|
+
return null;
|
|
65
|
+
return new URL(parsed.pathname + parsed.search, new URL(origin).origin).toString();
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Routes the context's requests on an alias to the worker's own origin (`aliasedUrl`): fetched with the context's own cookies for that
|
|
69
|
+
* origin, redirects not followed (the browser follows them itself, through its egress proxy), and fulfilled as the answer of the URL the
|
|
70
|
+
* page asked for. Logs the first load per job and the count at the end (paths only: a query may carry a code).
|
|
71
|
+
*/
|
|
72
|
+
async function routeOriginAliases(context, aliases, origin, jobId, log) {
|
|
73
|
+
if (aliases.length === 0)
|
|
74
|
+
return () => undefined;
|
|
75
|
+
let loads = 0;
|
|
76
|
+
let failures = 0;
|
|
77
|
+
await context.route((url) => aliases.includes(url.origin), async (route) => {
|
|
78
|
+
const target = aliasedUrl(route.request().url(), aliases, origin);
|
|
79
|
+
if (!target)
|
|
80
|
+
return route.continue();
|
|
81
|
+
try {
|
|
82
|
+
// The cookies are the context's own for the worker's origin (Playwright adds them where the request names none), never a
|
|
83
|
+
// header the page's request carried for the alias.
|
|
84
|
+
const headers = Object.fromEntries(Object.entries(route.request().headers()).filter(([name]) => !/^(cookie|host)$/i.test(name)));
|
|
85
|
+
const response = await route.fetch({ url: target, headers, maxRedirects: 0 });
|
|
86
|
+
if (loads++ === 0)
|
|
87
|
+
log({ event: "origin-alias-loaded", job: jobId, path: new URL(target).pathname, status: response.status() });
|
|
88
|
+
await route.fulfill({ response });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
failures++;
|
|
92
|
+
log({ event: "origin-alias-failed", job: jobId, path: new URL(target).pathname,
|
|
93
|
+
message: (error instanceof Error ? error.message : String(error)).slice(0, 300) });
|
|
94
|
+
await route.abort("failed").catch(() => undefined);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
log({ event: "origin-aliases", job: jobId, aliases: aliases.length });
|
|
98
|
+
return () => log({ event: "origin-aliases-done", job: jobId, loads, failures });
|
|
99
|
+
}
|
|
22
100
|
export async function runCmsJob(offer, options) {
|
|
23
101
|
const log = options.log ?? (() => undefined);
|
|
24
102
|
const now = options.now ?? Date.now;
|
|
@@ -30,6 +108,7 @@ export async function runCmsJob(offer, options) {
|
|
|
30
108
|
const allow = [...new Set([hostPortOf(origin), ...offer.allowlist.map((entry) => entry.toLowerCase())])];
|
|
31
109
|
const proxy = await startEgressProxy({ allow, log: options.egressLog });
|
|
32
110
|
let browser;
|
|
111
|
+
let aliasesDone = () => { };
|
|
33
112
|
try {
|
|
34
113
|
browser = await options.launch(proxyLaunchArgs(proxy.url));
|
|
35
114
|
const context = await browser.newContext({
|
|
@@ -43,6 +122,7 @@ export async function runCmsJob(offer, options) {
|
|
|
43
122
|
permissions: ["local-network-access"],
|
|
44
123
|
});
|
|
45
124
|
await addCaptureCookie(context, origin, offer);
|
|
125
|
+
aliasesDone = await routeOriginAliases(context, originAliasesOf(offer, origin), origin, offer.jobId, log);
|
|
46
126
|
return await drive(context, offer, { ...options, origin }, controllerUrl, targetUrl, log, now);
|
|
47
127
|
}
|
|
48
128
|
catch (error) {
|
|
@@ -51,6 +131,7 @@ export async function runCmsJob(offer, options) {
|
|
|
51
131
|
return { kind: "failed", errorCode: "capture-worker-failed", message: error instanceof Error ? error.message : String(error) };
|
|
52
132
|
}
|
|
53
133
|
finally {
|
|
134
|
+
aliasesDone();
|
|
54
135
|
await browser?.close().catch(() => undefined);
|
|
55
136
|
await proxy.close();
|
|
56
137
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { runCmsJob, hostPortOf, type CmsJobOptions, type JobOutcome } from "./cm
|
|
|
3
3
|
export { runWebJob, normalizeWebParameters, type WebCaptureResult, type WebJobOutcome } from "./webJob.js";
|
|
4
4
|
export { runBrowserHost, startForwarder, visibleSockets, type BrowserHostOptions } from "./browserHost.js";
|
|
5
5
|
export { BrowserHostLink, type EgressPolicy } from "./browserHostLink.js";
|
|
6
|
-
export { browserHostUnitProperties, socketDirectoriesOutsideHiddenTrees, judgeIsolation, webPreconditionRefusal, parheliaIsColocated, ownAddresses, type IsolationReport, type IsolationCheck, } from "./isolation.js";
|
|
6
|
+
export { browserHostUnitProperties, socketDirectoriesOutsideHiddenTrees, judgeIsolation, webPreconditionRefusal, parheliaIsColocated, ownAddresses, colocatedAccepted, COLOCATED_ACCEPTED_CODE, COLOCATED_ACCEPTED_NOTE, type IsolationReport, type IsolationCheck, } from "./isolation.js";
|
|
7
7
|
export { verifyWebIsolation, webDenyAddresses } from "./webIsolation.js";
|
|
8
8
|
export { startEgressProxy, decideEgress, isBlockedAddress, blockListOf, proxyLaunchArgs, BASELINE_BLOCKED_RANGES, type EgressLogEntry, } from "./egressProxy.js";
|
|
9
9
|
export { ParheliaClient, ParheliaRefusedError, newWorkerKey, workerKeyHash, type CaptureJobOffer, type CapturePollAnswer } from "./parheliaClient.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzI,OAAO,EAAE,SAAS,EAAE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EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3G,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EACL,yBAAyB,EAAE,mCAAmC,EAAE,cAAc,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,YAAY,EACzI,iBAAiB,EAAE,uBAAuB,EAAE,uBAAuB,EACnE,KAAK,eAAe,EAAE,KAAK,cAAc,GAC1C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACL,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,uBAAuB,EAAE,KAAK,cAAc,GAC7H,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,YAAY,EAAE,aAAa,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACtJ,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ export { runCmsJob, hostPortOf } from "./cmsJob.js";
|
|
|
3
3
|
export { runWebJob, normalizeWebParameters } from "./webJob.js";
|
|
4
4
|
export { runBrowserHost, startForwarder, visibleSockets } from "./browserHost.js";
|
|
5
5
|
export { BrowserHostLink } from "./browserHostLink.js";
|
|
6
|
-
export { browserHostUnitProperties, socketDirectoriesOutsideHiddenTrees, judgeIsolation, webPreconditionRefusal, parheliaIsColocated, ownAddresses, } from "./isolation.js";
|
|
6
|
+
export { browserHostUnitProperties, socketDirectoriesOutsideHiddenTrees, judgeIsolation, webPreconditionRefusal, parheliaIsColocated, ownAddresses, colocatedAccepted, COLOCATED_ACCEPTED_CODE, COLOCATED_ACCEPTED_NOTE, } from "./isolation.js";
|
|
7
7
|
export { verifyWebIsolation, webDenyAddresses } from "./webIsolation.js";
|
|
8
8
|
export { startEgressProxy, decideEgress, isBlockedAddress, blockListOf, proxyLaunchArgs, BASELINE_BLOCKED_RANGES, } from "./egressProxy.js";
|
|
9
9
|
export { ParheliaClient, ParheliaRefusedError, newWorkerKey, workerKeyHash } from "./parheliaClient.js";
|
|
@@ -20,6 +20,8 @@ export type InstallInput = {
|
|
|
20
20
|
web?: boolean;
|
|
21
21
|
probeUrl?: string;
|
|
22
22
|
publicUrl?: string;
|
|
23
|
+
/** Windows: run public-web on the machine that runs Parhelia all the same (`--accept-colocated-web`). */
|
|
24
|
+
acceptColocated?: boolean;
|
|
23
25
|
registry?: string;
|
|
24
26
|
browserMirror?: string;
|
|
25
27
|
browserPath?: string;
|
|
@@ -41,6 +43,8 @@ export type InstallInput = {
|
|
|
41
43
|
firewall?: Firewall;
|
|
42
44
|
/** How long to wait for the worker's first good poll (0: do not wait). */
|
|
43
45
|
waitMs?: number;
|
|
46
|
+
/** The release keys the host's manifest must be signed by (default: the ones this build ships). */
|
|
47
|
+
trustedKeys?: readonly string[];
|
|
44
48
|
log?: (line: string) => void;
|
|
45
49
|
};
|
|
46
50
|
export type InstallReport = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/install/install.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/install/install.ts"],"names":[],"mappings":"AAcA,OAAO,EACmE,KAAK,aAAa,EAAE,KAAK,MAAM,EACxG,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAgB,MAAM,cAAc,CAAC;AAI3E,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,MA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,EAAE,CAyB9D"}
|
package/dist/install/install.js
CHANGED
|
@@ -4,13 +4,16 @@
|
|
|
4
4
|
* Linux (root, systemd): the ipc group and two service users (the worker, and the browser user whose only group is the ipc
|
|
5
5
|
* group); /opt/parhelia-capture root-owned and read-only to both; the key (0600, the worker's); the version the host names,
|
|
6
6
|
* installed with every hash checked (a source build: the running package); Chromium's libraries and emoji fonts on apt systems;
|
|
7
|
-
* the socket scan (A7); the worker, browser host and
|
|
7
|
+
* the socket scan (A7); the worker, browser host, updater and update watch units and the timer; then it waits for the worker's
|
|
8
|
+
* first poll.
|
|
8
9
|
* Windows (Administrator): the code under Program Files, the data directory and key with inheritance off (the service account,
|
|
9
|
-
* Administrators, SYSTEM), the browser's outbound firewall rule installed and verified before it runs, and
|
|
10
|
-
* On a Windows machine that runs Parhelia itself, public-web is refused by name (plan §8) and CMS captures still install
|
|
10
|
+
* Administrators, SYSTEM), the browser's outbound firewall rule installed and verified before it runs, and four scheduled tasks.
|
|
11
|
+
* On a Windows machine that runs Parhelia itself, public-web is refused by name (plan §8) and CMS captures still install;
|
|
12
|
+
* `--accept-colocated-web` lifts that refusal by the administrator's choice (a probe on another host is then required).
|
|
11
13
|
*/
|
|
12
|
-
import { webPreconditionRefusal } from "../isolation.js";
|
|
14
|
+
import { COLOCATED_ACCEPTED_NOTE, webPreconditionRefusal } from "../isolation.js";
|
|
13
15
|
import { BROWSER_USER, IPC_GROUP, TASK, UNIT, WORKER_USER, } from "./layout.js";
|
|
16
|
+
import { RELEASE_KEYS } from "./releaseKeys.js";
|
|
14
17
|
import { services } from "./services.js";
|
|
15
18
|
import { dataDirAclArgs, keyFileAclArgs, keyFileAclHolds, launcherScript, linuxUnits, windowsTasks } from "./units.js";
|
|
16
19
|
import { readJson } from "./updater.js";
|
|
@@ -109,13 +112,25 @@ export async function install(input) {
|
|
|
109
112
|
web = false;
|
|
110
113
|
webNote = "The pairing does not allow screenshots of public websites.";
|
|
111
114
|
}
|
|
115
|
+
// The acceptance is Windows' alone and recorded only where it applies: a machine Parhelia does not run on keeps both
|
|
116
|
+
// protections, and one Parhelia moves onto later is refused until the administrator installs again.
|
|
117
|
+
let acceptColocated = false;
|
|
112
118
|
if (web && layout.platform === "win32") {
|
|
113
|
-
const
|
|
119
|
+
const colocated = await input.colocated();
|
|
120
|
+
const refusal = webPreconditionRefusal({ platform: "win32", colocated, probeUrl: input.probeUrl, acceptColocated: input.acceptColocated });
|
|
114
121
|
if (refusal) {
|
|
115
122
|
web = false;
|
|
116
123
|
webNote = `${refusal.code}: ${refusal.message}`;
|
|
117
124
|
}
|
|
125
|
+
else if (colocated && input.acceptColocated) {
|
|
126
|
+
acceptColocated = true;
|
|
127
|
+
warnings.push(COLOCATED_ACCEPTED_NOTE);
|
|
128
|
+
}
|
|
118
129
|
}
|
|
130
|
+
if (input.acceptColocated && !acceptColocated && !webNote)
|
|
131
|
+
warnings.push(layout.platform === "win32"
|
|
132
|
+
? "--accept-colocated-web was not needed: Parhelia does not run on this machine, or public websites are off."
|
|
133
|
+
: "--accept-colocated-web applies to Windows only; on Linux the browser host has no network of its own.");
|
|
119
134
|
// 4. Chromium's libraries and fonts (apt systems; elsewhere named as a warning).
|
|
120
135
|
if (layout.platform === "linux") {
|
|
121
136
|
if (sys.exec("sh", ["-c", "command -v apt-get"]).status === 0) {
|
|
@@ -132,6 +147,7 @@ export async function install(input) {
|
|
|
132
147
|
// 5. The code: the version the host names (hash-checked), or this running package for a source build.
|
|
133
148
|
const config = {
|
|
134
149
|
origin: new URL(input.origin).origin, keyFile: layout.keyFile, web, probeUrl: input.probeUrl, publicUrl: input.publicUrl,
|
|
150
|
+
...(acceptColocated ? { acceptColocatedWeb: true } : {}),
|
|
135
151
|
socketDir: layout.socketDir, installDir: layout.currentLink, versionsDir: layout.versionsDir, statusFile: layout.statusFile,
|
|
136
152
|
updaterStatusFile: layout.updaterStatusFile, socketGroupAccess: layout.platform === "linux", registry: input.registry,
|
|
137
153
|
browserMirror: input.browserMirror, browserPath: input.browserPath,
|
|
@@ -140,7 +156,7 @@ export async function install(input) {
|
|
|
140
156
|
let versionDir;
|
|
141
157
|
if (answer.release) {
|
|
142
158
|
log(`Installing version ${answer.manifest.version} (named by Parhelia)`);
|
|
143
|
-
versionDir = await installRelease(sys, layout, config, answer.manifest, { fromTarball: input.fromTarball, log });
|
|
159
|
+
versionDir = await installRelease(sys, layout, config, answer.manifest, { fromTarball: input.fromTarball, log, trustedKeys: input.trustedKeys });
|
|
144
160
|
}
|
|
145
161
|
else {
|
|
146
162
|
log("Parhelia names no release (a source build): installing this package as it is, unchecked");
|
|
@@ -155,6 +171,7 @@ export async function install(input) {
|
|
|
155
171
|
if (!held?.ok) {
|
|
156
172
|
web = false;
|
|
157
173
|
config.web = false;
|
|
174
|
+
delete config.acceptColocatedWeb;
|
|
158
175
|
webNote = `capture-web-firewall: the browser's outbound rule could not be installed and verified${held ? ` (${held.detail})` : ""}; screenshots of public websites stay off.`;
|
|
159
176
|
}
|
|
160
177
|
}
|
|
@@ -174,11 +191,16 @@ export async function install(input) {
|
|
|
174
191
|
if (!web)
|
|
175
192
|
sys.remove(layout.join(layout.unitDir, UNIT.browserHost));
|
|
176
193
|
must(sys.exec("systemctl", ["daemon-reload"]), "Reloading systemd");
|
|
177
|
-
must(sys.exec("systemctl", ["enable", UNIT.worker, ...(web ? [UNIT.browserHost] : []), UNIT.updaterTimer]), "Enabling the units");
|
|
194
|
+
must(sys.exec("systemctl", ["enable", UNIT.worker, ...(web ? [UNIT.browserHost] : []), UNIT.updaterTimer, UNIT.updateWatch]), "Enabling the units");
|
|
178
195
|
sys.exec("systemctl", ["stop", UNIT.worker]);
|
|
179
196
|
must(sys.exec("systemctl", ["start", UNIT.updaterTimer]), "Starting the update timer");
|
|
197
|
+
// "Update now": the updater's long poll (restart: a reinstall runs the version just installed).
|
|
198
|
+
must(sys.exec("systemctl", ["restart", UNIT.updateWatch]), "Starting the update watch");
|
|
180
199
|
}
|
|
181
200
|
else {
|
|
201
|
+
// A reinstall: the worker and the browser host still run the previous version with its configuration, and a running
|
|
202
|
+
// task ignores /Run (and outlives /Delete). Both are ended first, whatever this install runs.
|
|
203
|
+
services(sys, layout, true).stop();
|
|
182
204
|
sys.mkdir(layout.unitDir);
|
|
183
205
|
for (const [name, text] of Object.entries(windowsTasks(unitInput))) {
|
|
184
206
|
const file = layout.join(layout.unitDir, `${name}.xml`);
|
|
@@ -187,6 +209,9 @@ export async function install(input) {
|
|
|
187
209
|
}
|
|
188
210
|
if (!web)
|
|
189
211
|
sys.exec("schtasks", ["/Delete", "/TN", TASK.folder + TASK.browserHost, "/F"]);
|
|
212
|
+
// "Update now": the updater's long poll (ended first: a reinstall runs the version just installed).
|
|
213
|
+
sys.exec("schtasks", ["/End", "/TN", TASK.folder + TASK.updateWatch]);
|
|
214
|
+
must(sys.exec("schtasks", ["/Run", "/TN", TASK.folder + TASK.updateWatch]), "Starting the update watch");
|
|
190
215
|
}
|
|
191
216
|
services(sys, layout, web).start();
|
|
192
217
|
// 8. The first good poll proves origin, key and code.
|
|
@@ -209,7 +234,7 @@ export function uninstall(input) {
|
|
|
209
234
|
const { sys, layout } = input;
|
|
210
235
|
preflight(sys, layout);
|
|
211
236
|
if (layout.platform === "linux") {
|
|
212
|
-
sys.exec("systemctl", ["disable", "--now", UNIT.updaterTimer, UNIT.browserHost, UNIT.worker]);
|
|
237
|
+
sys.exec("systemctl", ["disable", "--now", UNIT.updateWatch, UNIT.updaterTimer, UNIT.browserHost, UNIT.worker]);
|
|
213
238
|
for (const unit of Object.values(UNIT))
|
|
214
239
|
sys.remove(layout.join(layout.unitDir, unit));
|
|
215
240
|
sys.exec("systemctl", ["daemon-reload"]);
|
|
@@ -226,7 +251,7 @@ export function uninstall(input) {
|
|
|
226
251
|
sys.exec("groupdel", [IPC_GROUP]);
|
|
227
252
|
return;
|
|
228
253
|
}
|
|
229
|
-
for (const task of [TASK.worker, TASK.browserHost, TASK.updater]) {
|
|
254
|
+
for (const task of [TASK.updateWatch, TASK.worker, TASK.browserHost, TASK.updater]) {
|
|
230
255
|
sys.exec("schtasks", ["/End", "/TN", TASK.folder + task]);
|
|
231
256
|
sys.exec("schtasks", ["/Delete", "/TN", TASK.folder + task, "/F"]);
|
|
232
257
|
}
|
|
@@ -251,12 +276,17 @@ export function statusLines(sys, layout) {
|
|
|
251
276
|
lines.push(`Parhelia: ${config.origin}`);
|
|
252
277
|
lines.push(`Version: ${current ?? "none"}${record ? ` (${record.source === "release" ? "checked against Parhelia's hashes" : "source build, unchecked"}; browser ${record.browserRevision ?? "?"})` : ""}`);
|
|
253
278
|
if (layout.platform === "linux") {
|
|
254
|
-
for (const unit of [UNIT.worker, ...(config.web ? [UNIT.browserHost] : []), UNIT.updaterTimer])
|
|
279
|
+
for (const unit of [UNIT.worker, ...(config.web ? [UNIT.browserHost] : []), UNIT.updaterTimer, UNIT.updateWatch])
|
|
255
280
|
lines.push(`${unit}: ${sys.exec("systemctl", ["is-active", unit]).stdout.trim() || "unknown"}`);
|
|
256
281
|
}
|
|
257
282
|
const status = readJson(sys, layout.statusFile);
|
|
258
283
|
lines.push(status ? `Last poll: ${status.lastPollUtc ?? "never"} (${status.lastPollOk ? "ok" : status.lastPollError ?? "failed"})` : "Last poll: none yet");
|
|
259
284
|
lines.push(`Screenshots of public websites: ${!config.web ? "not installed" : status?.web?.ok ? "on" : `off (${status?.web?.reason ?? "not verified yet"})`}`);
|
|
285
|
+
if (config.web && config.acceptColocatedWeb)
|
|
286
|
+
lines.push(` Accepted: ${COLOCATED_ACCEPTED_NOTE}`);
|
|
287
|
+
lines.push(RELEASE_KEYS.length > 0
|
|
288
|
+
? `Release signatures: required (${RELEASE_KEYS.length} trusted key${RELEASE_KEYS.length === 1 ? "" : "s"})`
|
|
289
|
+
: "Release signatures: not checked (this build trusts no release key)");
|
|
260
290
|
const updater = readJson(sys, layout.updaterStatusFile);
|
|
261
291
|
if (updater) {
|
|
262
292
|
lines.push(`Updater: ${updater.result} at ${updater.checkedUtc}${updater.wanted ? `, Parhelia names ${updater.wanted}` : ""}`);
|