@firstpick/pi-package-webui 0.4.0 → 0.4.2
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 +24 -9
- package/bin/pi-webui.mjs +415 -29
- package/index.ts +16 -1
- package/lib/trust-boundaries.mjs +1 -0
- package/package.json +1 -1
- package/public/app.js +766 -47
- package/public/index.html +44 -1
- package/public/styles.css +516 -4
- package/tests/http-endpoints-harness.test.mjs +97 -1
- package/tests/mobile-static.test.mjs +21 -10
- package/tests/session-auth-harness.test.mjs +4 -0
package/index.ts
CHANGED
|
@@ -22,6 +22,7 @@ type WebuiAddress = {
|
|
|
22
22
|
type StartWebuiOptions = WebuiAddress & {
|
|
23
23
|
open: boolean;
|
|
24
24
|
noSession: boolean;
|
|
25
|
+
remoteAuth: boolean;
|
|
25
26
|
name?: string;
|
|
26
27
|
piArgs: string[];
|
|
27
28
|
};
|
|
@@ -104,6 +105,7 @@ function parseStartWebuiArgs(args: string): StartWebuiOptions {
|
|
|
104
105
|
port: DEFAULT_PORT,
|
|
105
106
|
open: true,
|
|
106
107
|
noSession: false,
|
|
108
|
+
remoteAuth: false,
|
|
107
109
|
piArgs: [],
|
|
108
110
|
};
|
|
109
111
|
const tokens = tokenizeArgs(args || "");
|
|
@@ -122,6 +124,14 @@ function parseStartWebuiArgs(args: string): StartWebuiOptions {
|
|
|
122
124
|
options.noSession = true;
|
|
123
125
|
continue;
|
|
124
126
|
}
|
|
127
|
+
if (token === "--remote-auth") {
|
|
128
|
+
options.remoteAuth = true;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (token === "--no-remote-auth") {
|
|
132
|
+
options.remoteAuth = false;
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
125
135
|
if (token === "--host") {
|
|
126
136
|
options.host = takeValue(tokens, i, token);
|
|
127
137
|
i++;
|
|
@@ -516,6 +526,7 @@ function waitForWebuiUrl(child: WebuiChild, timeoutMs = START_TIMEOUT_MS): Promi
|
|
|
516
526
|
async function startWebui(options: StartWebuiOptions, ctx: ExtensionCommandContext, restoreTabs: RestorableWebuiTab[] = []): Promise<string> {
|
|
517
527
|
const args = [webuiBin, "--host", options.host, "--port", String(options.port), "--cwd", ctx.cwd];
|
|
518
528
|
if (options.noSession) args.push("--no-session");
|
|
529
|
+
if (options.remoteAuth) args.push("--remote-auth");
|
|
519
530
|
if (options.name) args.push("--name", options.name);
|
|
520
531
|
if (options.piArgs.length > 0) args.push("--", ...options.piArgs);
|
|
521
532
|
|
|
@@ -688,8 +699,10 @@ function formatWebuiStatus(result: WebuiStatusFetchResult, requestedDetailed: bo
|
|
|
688
699
|
const network = data.network || {};
|
|
689
700
|
const tabs = Array.isArray(data.tabs) ? data.tabs : [];
|
|
690
701
|
const networkUrls = Array.isArray(network.networkUrls) ? network.networkUrls : [];
|
|
702
|
+
const auth = network.auth || {};
|
|
691
703
|
const pageUrl = data.pageUrl || network.localUrl || result.url;
|
|
692
704
|
const networkLabel = network.open ? `open to LAN${network.opening ? " (opening)" : ""}` : network.opening ? "opening" : "local only";
|
|
705
|
+
const authLabel = auth.enabled ? `remote PIN on${auth.pin ? ` · PIN ${auth.pin}` : ""}` : "remote PIN off";
|
|
693
706
|
|
|
694
707
|
if (!requestedDetailed) {
|
|
695
708
|
const lines = [
|
|
@@ -698,6 +711,7 @@ function formatWebuiStatus(result: WebuiStatusFetchResult, requestedDetailed: bo
|
|
|
698
711
|
detailLine("URL", pageUrl),
|
|
699
712
|
detailLine("Online", "yes"),
|
|
700
713
|
detailLine("Network", networkLabel),
|
|
714
|
+
detailLine("Auth", authLabel),
|
|
701
715
|
detailLine("Tabs", tabs.length || "?"),
|
|
702
716
|
];
|
|
703
717
|
if (networkUrls.length) lines.push(detailLine("LAN URLs", networkUrls.join(", ")));
|
|
@@ -712,6 +726,7 @@ function formatWebuiStatus(result: WebuiStatusFetchResult, requestedDetailed: bo
|
|
|
712
726
|
detailLine("URL", pageUrl),
|
|
713
727
|
detailLine("Online", "yes"),
|
|
714
728
|
detailLine("Network", networkLabel),
|
|
729
|
+
detailLine("Auth", authLabel),
|
|
715
730
|
detailLine("Bind", `${data.boundHost || network.host || "unknown"}:${data.port || network.port || "?"}`),
|
|
716
731
|
detailLine("Version", data.webuiVersion || "unknown"),
|
|
717
732
|
detailLine("PIDs", `webui ${data.webuiPid || "unknown"} · pi ${data.piPid || "unknown"}`),
|
|
@@ -758,7 +773,7 @@ function formatWebuiStatus(result: WebuiStatusFetchResult, requestedDetailed: bo
|
|
|
758
773
|
|
|
759
774
|
function usage(): string {
|
|
760
775
|
return [
|
|
761
|
-
"Usage: /webui-start [port] [--port N] [--no-open] [--no-session] [--name NAME] [-- --model provider/model]",
|
|
776
|
+
"Usage: /webui-start [port] [--port N] [--no-open] [--no-session] [--remote-auth] [--name NAME] [-- --model provider/model]",
|
|
762
777
|
"Starts the Pi Web UI companion server for the current cwd, prints the localhost URL, and opens it in your default browser.",
|
|
763
778
|
].join("\n");
|
|
764
779
|
}
|
package/lib/trust-boundaries.mjs
CHANGED
|
@@ -12,6 +12,7 @@ export const TRUST_GUARD_TYPES = new Set([
|
|
|
12
12
|
export const LOCALHOST_ONLY_POST_ROUTES = new Map([
|
|
13
13
|
["/api/network/open", "Opening to the network is only allowed from localhost"],
|
|
14
14
|
["/api/network/close", "Closing network access is only allowed from localhost"],
|
|
15
|
+
["/api/remote-auth/settings", "Remote PIN authentication settings are only allowed from localhost"],
|
|
15
16
|
["/api/restart", "Restart is only allowed from localhost"],
|
|
16
17
|
["/api/update", "Updating Pi from the Web UI is only allowed from localhost"],
|
|
17
18
|
["/api/shutdown", "Shutdown is only allowed from localhost"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firstpick/pi-package-webui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Pi Web UI companion package with a local browser UI CLI plus /webui-start and /webui-status commands.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/Firstp1ck/npm-packages/tree/main/pi-package-webui#readme",
|