aboutsummaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static/platform.js
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-18 12:54:29 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-18 12:54:29 +0200
commit06062d2e8352a205fa634970d260ab0f5de97f04 (patch)
tree0b10ee28d0de9d9af5fea0febfb404658177e1d5 /packages/meshbay-hub/src/meshbay_hub/static/platform.js
parent7c46b4e7dc2893974a37d6a701123a95803fcb95 (diff)
downloadmeshbay-06062d2e8352a205fa634970d260ab0f5de97f04.tar.gz
fix(client): three defects a real desktop found in ten minutes
All three came from the operator running the application on Ubuntu GNOME. None would have been found by anything already in the suite. **A second copy of the hub address.** `keyderive.js` carried `const HUB = '' // same origin` — true of a page the hub served, false of one loaded from a package, where the origin is `app://meshbay` and `/v1/users/register` resolves against the application's own protocol handler. **Sign-up and sign-in, the first two things anybody does, failed with "Not found."** The seam was changed in `app.js` and in the signalling call and this was missed: the same shape as the duplicate `MNP_VERSION` in `protocol.py`, a second copy of a constant that is harmless until the context changes. `test_hub_address_seam.py` refuses any file that decides where the hub is, and any `fetch('/v1/…')` relative to the page origin. **A window handler reading a variable another path reassigns.** Changing the hub closes one window and opens another; `closed` arrives *after* the replacement is assigned, so the outgoing window nulled the reference to the incoming one and its `ready-to-show` crashed on it — a modal "A JavaScript error occurred in the main process". Every handler now belongs to the window it was created with. The CDP test wrote `config.json` in advance, so it never took the one path that creates a second window; it does now, starting from an empty user-data dir. **A first run that could not be undone.** The hub address was accepted on anything URL-shaped and there was no way to change it afterwards — the prompt only appears when none is set, so a typo meant editing JSON by hand. `https` typed at a hub speaking `http` produced `TypeError: fetch failed`, which names nothing. Now: the address is probed before being written, failures say which URL and why ("does not speak https. If this hub is on your own machine, it is probably http"), Settings can change it, and Electron's "Error invoking remote method" wrapper is stripped from what a person reads. Verified on the operator's desktop: **safeStorage really uses the GNOME keyring** — Settings reports `gnome-libsecret`, and `secrets.bin` is written 0600 with Chromium's `v11` prefix, the marker for keyring-backed encryption (the fixed-key fallback writes `v10`). Headless, the same code reports `unavailable` and refuses to store rather than downgrading in silence, which is now explained in Settings instead of shown as a bare word. Unrelated but found while testing: `test_locales.py` assigned to `globalThis.navigator`, which is read-only from Node 22. The client's build already requires Node 22+, so the first CI machine configured for it would have failed these tests for no visible reason. 809 tests pass on Node 18 and Node 24. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static/platform.js')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/platform.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/platform.js b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
index ae04e53..994f558 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
@@ -103,6 +103,20 @@ export const secrets = {
* keypair bundle on each node is what a second browser recovers — which is
* finding C4, and the reason the application exists.
*/
+/**
+ * The sentence out of a bridge error.
+ *
+ * Electron wraps anything thrown in the main process as
+ * "Error invoking remote method 'hub:set': Error: …", which puts plumbing in
+ * front of a message written for a person. The message is the part that was
+ * written for them.
+ */
+export function bridgeMessage(err) {
+ const raw = (err && err.message) || String(err);
+ const m = raw.match(/^Error invoking remote method '[^']*':\s*(?:\w*Error:\s*)?(.*)$/s);
+ return m ? m[1] : raw;
+}
+
export const device = {
available: Boolean(bridge && bridge.device),
async ensure() {
@@ -168,7 +182,7 @@ export async function nativeSave(suggestedName, size) {
}
export default { isNative, hubBase, capabilities, secrets, nativeSave,
- apiFetch, device };
+ apiFetch, device, bridgeMessage };
// Also a global, because `transport.js` is loaded as a classic script — it
// predates the module graph and exposes `MeshBayTransport` the same way. The
@@ -176,5 +190,6 @@ export default { isNative, hubBase, capabilities, secrets, nativeSave,
// hub end up disagreeing about how to reach it.
if (typeof window !== 'undefined') {
window.MeshBayPlatform = { isNative, hubBase, capabilities, secrets,
- nativeSave, apiFetch, device };
+ nativeSave, apiFetch, device,
+ bridgeMessage };
}