From 6d167392f6f8ede37e2794a68a3738f8ba03131d Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Wed, 30 Sep 2026 16:58:31 +0200 Subject: 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 --- packages/meshbay-hub/src/meshbay_hub/static/playlists.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'packages/meshbay-hub/src/meshbay_hub/static/playlists.js') diff --git a/packages/meshbay-hub/src/meshbay_hub/static/playlists.js b/packages/meshbay-hub/src/meshbay_hub/static/playlists.js index eec94e8..afcb122 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/playlists.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/playlists.js @@ -4,6 +4,7 @@ import { toStored, fromStored, livePlaylists, repairTracks, indexTracks, } from './playlist-merge.js'; import { derivePlaylistKey, seal, open } from './playlist-crypto.js'; +import * as platform from './platform.js'; import { session, _loadBundleKey, openDB, IDB_PLAYLISTS, } from './hub-client.js'; @@ -108,6 +109,16 @@ async function playlistKey(userId) { bundleKey = await _loadBundleKey(); if (bundleKey) session.bundleKey = bundleKey; } + if (bundleKey && bundleKey.native) { + // The desktop application keeps the master key and hands this one key + // over: it opens nothing but the playlists this page shows anyway. + const raw = await platform.keys.playlistKey(bundleKey.userId); + _key = await crypto.subtle.importKey( + 'raw', Uint8Array.from(atob(raw), c => c.charCodeAt(0)), + { name: 'AES-GCM' }, false, ['encrypt', 'decrypt']); + _keyFor = userId; + return _key; + } if (!bundleKey || !bundleKey.v3) return null; _key = await derivePlaylistKey(bundleKey.v3); _keyFor = userId; -- cgit v1.2.3