cicy-desktop 2.1.332 → 2.1.333
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/package.json +1 -1
- package/src/backends/homepage-window.js +18 -18
- package/test/homepage-remote.test.js +26 -13
package/package.json
CHANGED
|
@@ -4,24 +4,23 @@
|
|
|
4
4
|
// Homepage window — primary CiCy Desktop window. Singleton; closing it
|
|
5
5
|
// does NOT quit the app.
|
|
6
6
|
//
|
|
7
|
-
// URL selection: the
|
|
8
|
-
//
|
|
9
|
-
//
|
|
7
|
+
// URL selection: the homepage IS the deployed web build
|
|
8
|
+
// (https://desktop.cicy-ai.com — the desktop-render Worker). Shipping homepage
|
|
9
|
+
// changes then means deploying the Worker, not shipping a new desktop build.
|
|
10
10
|
//
|
|
11
|
-
// The
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// because it was only ever loaded from file://. A remote origin on that channel
|
|
17
|
-
// gets ungated exec_*/file_* on every desktop, so whoever controls the domain
|
|
18
|
-
// controls the fleet. Turn it on per machine with CICY_HOMEPAGE_URL (any URL) or
|
|
19
|
-
// prefs.homepageRemote:true (uses REMOTE_HOMEPAGE), and only for an origin you
|
|
20
|
-
// trust exactly as much as the bundled bundle itself.
|
|
11
|
+
// The bundled file:// snapshot stays in the package as the FALLBACK: a
|
|
12
|
+
// main-frame load failure, or a load that never commits within 15s (a blank 200
|
|
13
|
+
// from a broken deploy), swaps to it — a CDN outage can never leave the app with
|
|
14
|
+
// no homepage. Set CICY_HOMEPAGE_URL to point somewhere else (e.g. a vite dev
|
|
15
|
+
// server), or prefs.homepageRemote:false to pin a machine to the snapshot.
|
|
21
16
|
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
//
|
|
17
|
+
// Note what this grants: the home tab runs homepage-preload, whose bridge is the
|
|
18
|
+
// UNGUARDED "rpc" channel — no origin gate, no dangerous-tool gate (see
|
|
19
|
+
// utils/rpc-guard), because it predates the homepage ever being remote. The
|
|
20
|
+
// homepage origin therefore has ungated exec_*/file_* on the machine, so
|
|
21
|
+
// desktop.cicy-ai.com must be treated as first-party code, exactly like the
|
|
22
|
+
// bundle it replaces: whoever can deploy that Worker can run commands on every
|
|
23
|
+
// desktop.
|
|
25
24
|
|
|
26
25
|
const path = require("path");
|
|
27
26
|
const { BrowserWindow } = require("electron");
|
|
@@ -49,10 +48,11 @@ function readHomepagePrefs() {
|
|
|
49
48
|
function pickHomepageURL() {
|
|
50
49
|
const env = String(process.env.CICY_HOMEPAGE_URL || "").trim();
|
|
51
50
|
if (env) return env;
|
|
51
|
+
// Opt OUT only: an explicit false pins this machine to the bundled snapshot.
|
|
52
52
|
try {
|
|
53
|
-
if (readHomepagePrefs().homepageRemote ===
|
|
53
|
+
if (readHomepagePrefs().homepageRemote === false) return LOCAL_URL;
|
|
54
54
|
} catch {}
|
|
55
|
-
return
|
|
55
|
+
return REMOTE_HOMEPAGE;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// Fall back to the bundled snapshot when a remote homepage fails to load or
|
|
@@ -54,23 +54,36 @@ function loadPicker() {
|
|
|
54
54
|
return mod.exports;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
test("defaults to the
|
|
57
|
+
test("defaults to the deployed web build", () => {
|
|
58
58
|
withHome(() => {
|
|
59
|
-
const { pickHomepageURL,
|
|
60
|
-
assert.equal(pickHomepageURL(),
|
|
61
|
-
assert.
|
|
59
|
+
const { pickHomepageURL, REMOTE_HOMEPAGE } = loadPicker();
|
|
60
|
+
assert.equal(pickHomepageURL(), REMOTE_HOMEPAGE);
|
|
61
|
+
assert.equal(REMOTE_HOMEPAGE, "https://desktop.cicy-ai.com/");
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
test("prefs.homepageRemote
|
|
65
|
+
test("prefs.homepageRemote:false pins a machine to the bundled snapshot", () => {
|
|
66
66
|
withHome((home) => {
|
|
67
67
|
fs.writeFileSync(
|
|
68
68
|
path.join(home, "cicy-ai", "db", "prefs.json"),
|
|
69
|
-
JSON.stringify({ homepageRemote:
|
|
69
|
+
JSON.stringify({ homepageRemote: false })
|
|
70
70
|
);
|
|
71
|
-
const { pickHomepageURL,
|
|
72
|
-
assert.equal(pickHomepageURL(),
|
|
73
|
-
assert.
|
|
71
|
+
const { pickHomepageURL, LOCAL_URL } = loadPicker();
|
|
72
|
+
assert.equal(pickHomepageURL(), LOCAL_URL);
|
|
73
|
+
assert.match(pickHomepageURL(), /^file:\/\//);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("any value other than an explicit false stays on the web build", () => {
|
|
78
|
+
withHome((home) => {
|
|
79
|
+
for (const v of [true, "false", 0, null]) {
|
|
80
|
+
fs.writeFileSync(
|
|
81
|
+
path.join(home, "cicy-ai", "db", "prefs.json"),
|
|
82
|
+
JSON.stringify({ homepageRemote: v })
|
|
83
|
+
);
|
|
84
|
+
const { pickHomepageURL, REMOTE_HOMEPAGE } = loadPicker();
|
|
85
|
+
assert.equal(pickHomepageURL(), REMOTE_HOMEPAGE, `homepageRemote=${JSON.stringify(v)}`);
|
|
86
|
+
}
|
|
74
87
|
});
|
|
75
88
|
});
|
|
76
89
|
|
|
@@ -78,7 +91,7 @@ test("CICY_HOMEPAGE_URL wins over prefs and the default", () => {
|
|
|
78
91
|
withHome((home) => {
|
|
79
92
|
fs.writeFileSync(
|
|
80
93
|
path.join(home, "cicy-ai", "db", "prefs.json"),
|
|
81
|
-
JSON.stringify({ homepageRemote:
|
|
94
|
+
JSON.stringify({ homepageRemote: false })
|
|
82
95
|
);
|
|
83
96
|
process.env.CICY_HOMEPAGE_URL = "http://127.0.0.1:5173/";
|
|
84
97
|
try {
|
|
@@ -89,11 +102,11 @@ test("CICY_HOMEPAGE_URL wins over prefs and the default", () => {
|
|
|
89
102
|
});
|
|
90
103
|
});
|
|
91
104
|
|
|
92
|
-
test("a malformed prefs file
|
|
105
|
+
test("a malformed prefs file keeps the default rather than throwing", () => {
|
|
93
106
|
withHome((home) => {
|
|
94
107
|
fs.writeFileSync(path.join(home, "cicy-ai", "db", "prefs.json"), "{ not json");
|
|
95
|
-
const { pickHomepageURL,
|
|
96
|
-
assert.equal(pickHomepageURL(),
|
|
108
|
+
const { pickHomepageURL, REMOTE_HOMEPAGE } = loadPicker();
|
|
109
|
+
assert.equal(pickHomepageURL(), REMOTE_HOMEPAGE);
|
|
97
110
|
});
|
|
98
111
|
});
|
|
99
112
|
|