From e23e33adeaf8ee7439187d4451c856b37816a51f Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Tue, 11 Aug 2026 04:13:53 +0200 Subject: feat: Phase 9 — Web client SPA with WebRTC P2P transport MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complete browser-based client: Preact SPA with login, group file browser, encrypted download, video playback, group chat, i18n, and dark/light theme. Browser connects P2P to nodes behind residential NAT via WebRTC DataChannel (aiortc). Hub handles signaling only — all data flows E2E. Performance: pipelined downloads (8-chunk sliding window), binary msgpack wire format (no base64), redundant I/O elimination. Large file downloads stream to disk via File System Access API (showSaveFilePicker). Validated on SFR + Orange residential NATs, Chrome + Firefox, IPv4/IPv6. 132 tests passing. Deployed to meshbay.org + Orange node. Co-Authored-By: Claude Opus 4.6 --- packages/meshbay-hub/src/meshbay_hub/static/crypto.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'packages/meshbay-hub/src/meshbay_hub/static/crypto.js') diff --git a/packages/meshbay-hub/src/meshbay_hub/static/crypto.js b/packages/meshbay-hub/src/meshbay_hub/static/crypto.js index 7862283..ee442fb 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/crypto.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/crypto.js @@ -136,7 +136,7 @@ function b64decode(b64) { function hexToBytes(hex) { const bytes = new Uint8Array(hex.length / 2); for (let i = 0; i < hex.length; i += 2) - bytes[i / 2] = parseInt(hex.substring(i, 2), 16); + bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16); return bytes; } @@ -151,5 +151,12 @@ function concatBuffers(arrays) { return result; } +async function decryptChunkBin(gek, fileHashHex, chunkIndex, nonce, ct) { + const chunkKey = await deriveChunkKey(gek, fileHashHex, chunkIndex); + const plaintext = await crypto.subtle.decrypt( + { name: 'AES-GCM', iv: nonce }, chunkKey, ct); + return new Uint8Array(plaintext); +} + // Export for use in app.js -window.MeshBayCrypto = { importGEK, deriveChunkKey, decryptChunk, decryptFile }; +window.MeshBayCrypto = { importGEK, deriveChunkKey, decryptChunk, decryptChunkBin, decryptFile }; -- cgit v1.2.3