diff --git a/README.md b/README.md index 3c859b6..c342e2a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,12 @@ Direct messages are end-to-end encrypted. or host immediately. Accounts add direct messages, a persistent identity, and stats. - End-to-end encrypted DMs (ECDH P-256 + AES-GCM); the server stores only - ciphertext it cannot read. + ciphertext it cannot read. Keys are per-device, with a passphrase-protected + backup to carry your history to another device. +- Use one account from several devices at once; messages reach all of them. + +**Installable** — Beacon is a PWA: install it from the browser's address bar +for an app window and an offline shell. --- diff --git a/ROADMAP.md b/ROADMAP.md index 3fe07e8..87783de 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,6 +1,6 @@ # Beacon Roadmap -Where the project stands and everything left to do. Updated 2026-07-03. +Where the project stands and everything left to do. Updated 2026-07-04. ## Done @@ -27,28 +27,29 @@ Where the project stands and everything left to do. Updated 2026-07-03. - **Cinema mode** — pure-CSS lights-down while playing. - **Reliability** — P2P connections fail gracefully with a clear error + retry (no more infinite spinner); shared playback control (anyone can pause/seek). -- **Deployed** — live on an Oracle Cloud free VM behind Caddy (HTTPS), systemd, - SQLite on a persistent path. See `deploy/DEPLOY.md`. +- **Multi-device** — one account can be connected from several devices at once; + DMs, offers, invites, and presence track all of them. +- **DM key backup** — passphrase-encrypted export/restore of the message key, + so history can move to a new device. +- **Installable PWA** — web manifest, app icon, and an offline app shell. +- **Hardening** — audited and patched: no email leakage, proxy-aware rate + limits, hostile-peer defenses in the P2P receiver (with regression tests), + clean dependency audit enforced in CI. +- **UI** — pared back from the templated look to a restrained, neutral theme; + all panels on the design tokens; own favicon. +- **Ops** — nightly SQLite backup script; CI runs typecheck, build, and audit. +- **Deployed** — live on an Oracle Cloud free VM behind Caddy (HTTPS + security + headers), systemd, SQLite on a persistent path. See `deploy/DEPLOY.md`. ## Remaining -### UI polish -- [ ] The inner FileShare, VideoFileSharing, and Voice panels still carry - pre-design-system blue/green accents. -- [ ] Replace the default Vite favicon with a real one. - ### Connectivity - [ ] Firefox + TURN: the free Metered relay gives Firefox zero relay candidates (see QUESTIONS.md). Try another provider and verify on two - real devices on different networks. - -### PWA -- [ ] Installable app: manifest, icons, offline shell ("add to home screen"). -- [ ] (Optional, later) Tauri desktop wrapper from the same web code. + real devices on different networks. (Needs a provider account.) ### Smaller debt -- [ ] DM key backup (passphrase) + device-only delivery toggle (deferred from - the DM work). -- [ ] OPFS cleanup sweep for abandoned partial transfers. +- [ ] Device-only DM delivery toggle (deferred from the DM work). - [ ] Swap the temporary hostname for a real (sub)domain when one is available: edit the Caddyfile site line + ALLOWED_ORIGINS, reload Caddy. +- [ ] (Optional, later) Tauri desktop wrapper from the same web code. diff --git a/client/index.html b/client/index.html index 44ae045..c0986a8 100644 --- a/client/index.html +++ b/client/index.html @@ -3,6 +3,9 @@ + + + Beacon diff --git a/client/public/app-icon.svg b/client/public/app-icon.svg new file mode 100644 index 0000000..4ade105 --- /dev/null +++ b/client/public/app-icon.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/client/public/manifest.webmanifest b/client/public/manifest.webmanifest new file mode 100644 index 0000000..cbd9081 --- /dev/null +++ b/client/public/manifest.webmanifest @@ -0,0 +1,18 @@ +{ + "name": "Beacon", + "short_name": "Beacon", + "description": "Watch videos in sync and send files directly between browsers.", + "start_url": "/", + "scope": "/", + "display": "standalone", + "background_color": "#10131A", + "theme_color": "#10131A", + "icons": [ + { + "src": "/app-icon.svg", + "type": "image/svg+xml", + "sizes": "any", + "purpose": "any maskable" + } + ] +} diff --git a/client/public/sw.js b/client/public/sw.js index bff5b07..bef55d3 100644 --- a/client/public/sw.js +++ b/client/public/sw.js @@ -10,8 +10,25 @@ const streams = new Map() // key -> { size, mime, clientId } const MAX_WINDOW = 2 * 1024 * 1024 // cap each 206 response; browser follows up -self.addEventListener('install', () => self.skipWaiting()) -self.addEventListener('activate', (event) => event.waitUntil(self.clients.claim())) +// App-shell cache, so an installed PWA opens offline. Bump the version to +// invalidate old entries on the next activate. Hashed build assets are +// immutable, so caching them is safe; the HTML shell is refreshed +// network-first below. +const SHELL_CACHE = 'beacon-shell-v1' +const SHELL_URLS = ['/', '/index.html', '/favicon.svg', '/manifest.webmanifest'] + +self.addEventListener('install', (event) => { + event.waitUntil( + caches.open(SHELL_CACHE).then((c) => c.addAll(SHELL_URLS)).catch(() => {}).then(() => self.skipWaiting()), + ) +}) +self.addEventListener('activate', (event) => { + event.waitUntil( + caches.keys() + .then((keys) => Promise.all(keys.filter((k) => k !== SHELL_CACHE).map((k) => caches.delete(k)))) + .then(() => self.clients.claim()), + ) +}) self.addEventListener('message', (event) => { const { t } = event.data ?? {} @@ -41,6 +58,44 @@ async function fetchRangeFromClient(entry, key, start, end) { self.addEventListener('fetch', (event) => { const url = new URL(event.request.url) + + // App-shell caching for same-origin GETs — but never the P2P stream, the + // API, or the socket transport, which must always hit the live server/peer. + if ( + event.request.method === 'GET' && + url.origin === self.location.origin && + !url.pathname.startsWith('/p2p/') && + !url.pathname.startsWith('/api/') && + !url.pathname.startsWith('/socket.io/') + ) { + if (event.request.mode === 'navigate') { + // Network-first for navigations so a fresh shell wins when online, with + // the cached shell as the offline fallback. + event.respondWith( + fetch(event.request).catch(() => caches.match('/index.html').then((r) => r ?? Response.error())), + ) + return + } + // Cache-first only for content-hashed build assets — never media, and + // never a Range request (partial responses would corrupt the cache and + // break video seeking). + const isAsset = /\.(js|mjs|css|woff2?|svg|png|ico|webmanifest)$/.test(url.pathname) + if (isAsset && !event.request.headers.has('range')) { + event.respondWith( + caches.match(event.request).then((hit) => + hit ?? fetch(event.request).then((res) => { + if (res.ok && res.type === 'basic') { + const copy = res.clone() + caches.open(SHELL_CACHE).then((c) => c.put(event.request, copy)).catch(() => {}) + } + return res + }), + ), + ) + } + return + } + if (!url.pathname.startsWith('/p2p/')) return const key = url.pathname.slice('/p2p/'.length) const entry = streams.get(key) diff --git a/client/src/main.jsx b/client/src/main.jsx index 0291fe5..c7939e8 100644 --- a/client/src/main.jsx +++ b/client/src/main.jsx @@ -7,4 +7,13 @@ ReactDOM.createRoot(document.getElementById('root')).render( , -) \ No newline at end of file +) + +// Register the service worker so the app is installable and opens offline. +// It's the same worker that powers stream-while-downloading; registering it on +// load (rather than lazily on first stream) is what makes the PWA installable. +if ('serviceWorker' in navigator) { + window.addEventListener('load', () => { + navigator.serviceWorker.register('/sw.js').catch(() => {}) + }) +} \ No newline at end of file