Cabin Chat 4.0: accounts, https, PWA, mentions, notifications

- accounts with name + password (salted sha256), one account on several
  devices at once, profile menu: change password, profile picture,
  link another device (QR code + one-time link), logout, delete account
- @mentions with picker and highlighting
- https by default with the router web admin's certificate; --http,
  --cert/--key installer options
- logo/favicon, app manifest, service worker (installable PWA)
- browser notifications via the service worker, no internet needed
- devserver: https option, ignore connections reset by the browser

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Pascal Suter
2026-11-16 15:28:11 +01:00
co-authored by Claude Opus 5.5
parent 863d30eeba
commit 1459b3228d
15 changed files with 4118 additions and 353 deletions
+30
View File
@@ -0,0 +1,30 @@
// Cabin Chat service worker: makes the chat installable as an app, opens the
// app from a notification and shows the last loaded page when the router is out
// of reach. Network first, so a new version on the router is used right away.
// Chat data (cgi-bin) and photos are never cached here.
const CACHE = 'cabinchat';
self.addEventListener('install', () => self.skipWaiting());
self.addEventListener('activate', e => e.waitUntil(self.clients.claim()));
self.addEventListener('fetch', e => {
const req = e.request, url = new URL(req.url);
if (req.method !== 'GET' || url.origin !== location.origin || /\/(cgi-bin|img)\//.test(url.pathname)) return;
e.respondWith(fetch(req).then(res => {
if (res.ok) { const copy = res.clone(); caches.open(CACHE).then(c => c.put(req, copy)); }
return res;
}).catch(() => caches.match(req, { ignoreSearch: true })
.then(r => r || (req.mode === 'navigate' ? caches.match('./') : Response.error()))));
});
self.addEventListener('notificationclick', e => {
e.notification.close();
const conv = (e.notification.data || {}).conv || '';
e.waitUntil(self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(list => {
for (const c of list) {
c.postMessage({ cc: 'open', conv });
return c.focus();
}
return self.clients.openWindow('./' + (conv ? '#c=' + conv : ''));
}));
});