diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-30 16:58:31 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-30 16:58:31 +0200 |
| commit | 6d167392f6f8ede37e2794a68a3738f8ba03131d (patch) | |
| tree | 9caacef15dd034c6425f4bb623e0cd50a28ec52a /packages/meshbay-hub/src/meshbay_hub/static/platform.js | |
| parent | 8926f163dad9d32dc06c3a142658a4e11d9c12c1 (diff) | |
| download | meshbay-6d167392f6f8ede37e2794a68a3738f8ba03131d.tar.gz | |
feat(client): the desktop application keeps M and every node identity in its main process
keyring.js derives, opens, mints, seals, signs and agrees there; the page gets
public keys and a handle. Argon2 comes from the page's own WebAssembly build
(Electron's crypto has none). Without OS key storage the page keeps its keys as
a browser does. A node's bundle is settled after connecting, re-sealed when the
key changed.
Co-Authored-By: Claude Opus 5.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.js | 32 |
1 files changed, 30 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 8bf09b4..19f12a6 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js @@ -508,9 +508,36 @@ export async function setUiLocale(code) { return bridge.setLocale(code); } +/** + * The account's keys, held by the desktop application's main process + * (`meshbay-client/src/keyring.js`): the bundle master key and the identity on + * every node. The page asks for public keys, signatures and agreements. + * + * Null in a browser. `available()` is false in the application too where the + * OS has no key storage — identities kept there and lost at the next start + * would strand the account on every node — and the page then keeps its keys as + * a browser does. + */ +let _keysAvailable = null; +export const keys = (bridge && bridge.keys) ? { + ...bridge.keys, + async available() { + if (_keysAvailable === null) { + try { _keysAvailable = Boolean(await bridge.keys.available()); } + catch { _keysAvailable = false; } + } + return _keysAvailable; + }, +} : null; + +/** Whether this page's keys are held by the application rather than here. */ +export async function nativeKeys() { + return Boolean(keys && await keys.available()); +} + export default { isNative, hubBase, capabilities, secrets, nativeSave, apiFetch, device, bridgeMessage, folder, rootPicker, node, - cast, minimizeToTray, setTrayLabels, setUiLocale }; + cast, minimizeToTray, setTrayLabels, setUiLocale, keys, nativeKeys }; // Also a global, because `transport.js` is loaded as a classic script — it // predates the module graph and exposes `MeshBayTransport` the same way. The @@ -520,5 +547,6 @@ if (typeof window !== 'undefined') { window.MeshBayPlatform = { isNative, hubBase, capabilities, secrets, nativeSave, apiFetch, device, bridgeMessage, folder, rootPicker, node, - cast, minimizeToTray, setTrayLabels, setUiLocale }; + cast, minimizeToTray, setTrayLabels, setUiLocale, + keys, nativeKeys }; } |