cipher/public/index.html
maverick bd112d07fe Fix: namespace encrypted store per-account so two accounts can coexist on one browser
Root cause of 'two users can't chat': all accounts on one browser shared a
single IndexedDB, so the second registration overwrote the first's Signal
identity keys, corrupting both. Verified via two-isolated-client integration
test (real crypto.js + store.js) that the protocol itself is correct.

- store.js: useAccount(username) namespaces IndexedDB as cipher:<username>;
  keys generated at registration now persist under the right account
- accounts.js: localStorage-backed account registry + active pointer
- app.js: multi-account boot/activate, account-switch/add/logout menu,
  error toasts on send/decrypt failures (no more silent failures)
- login guards against missing on-device keys (multi-device linking still TODO)
- SW cache v2->v3 + precache accounts.js

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 02:48:00 +10:00

139 lines
7 KiB
HTML

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta name="theme-color" content="#0b141a" />
<title>Cipher — encrypted messaging</title>
<link rel="manifest" href="/manifest.webmanifest" />
<link rel="icon" href="/icons/icon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/icons/icon.svg" />
<style>
:root {
--bg: #0b141a;
--panel: #111b21;
--panel-2: #202c33;
--accent: #00a884;
--accent-2: #005c4b;
--text: #e9edef;
--muted: #8696a0;
--bubble-in: #202c33;
--bubble-out: #005c4b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
background: var(--bg); color: var(--text); height: 100dvh; overflow: hidden;
}
#app { height: 100dvh; }
/* ---- auth ---- */
.auth-card {
max-width: 360px; margin: 12vh auto 0; padding: 32px 24px;
background: var(--panel); border-radius: 16px; display: flex; flex-direction: column; gap: 12px;
box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.auth-card h1 { margin: 0; text-align: center; color: var(--accent); letter-spacing: .5px; }
.tagline { margin: 0 0 8px; text-align: center; color: var(--muted); font-size: 13px; }
.auth-card input {
padding: 12px 14px; border-radius: 10px; border: 1px solid var(--panel-2);
background: var(--panel-2); color: var(--text); font-size: 15px;
}
.auth-card input:focus { outline: 2px solid var(--accent); }
.auth-err { color: #f15c6d; font-size: 13px; min-height: 16px; text-align: center; }
button { cursor: pointer; font-size: 15px; padding: 12px 14px; border-radius: 10px; border: none; }
button.primary { background: var(--accent); color: #04140f; font-weight: 600; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
button:disabled { opacity: .6; cursor: default; }
/* ---- shell ---- */
.shell { display: grid; grid-template-columns: 340px 1fr; height: 100dvh; }
.sidebar { background: var(--panel); border-right: 1px solid #0a0f13; display: flex; flex-direction: column; min-height: 0; }
.side-header { padding: 16px; border-bottom: 1px solid #0a0f13; }
.me { font-weight: 600; }
.handle { color: var(--muted); font-size: 13px; }
.new-chat { margin: 12px; background: var(--panel-2); color: var(--text); text-align: left; }
.chat-list { overflow-y: auto; flex: 1; }
.chat-item { display: flex; gap: 12px; padding: 12px 16px; cursor: pointer; align-items: center; }
.chat-item:hover { background: var(--panel-2); }
.avatar {
width: 42px; height: 42px; border-radius: 50%; background: var(--accent-2);
display: grid; place-items: center; font-weight: 700; color: var(--text); flex: none;
}
.chat-name { font-weight: 500; }
.chat-sub { color: var(--muted); font-size: 13px; }
/* ---- main ---- */
.main { display: flex; flex-direction: column; min-height: 0; background:
linear-gradient(rgba(11,20,26,.95), rgba(11,20,26,.95)); }
.empty { margin: auto; color: var(--muted); }
.chat-head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid #0a0f13; }
.back-btn { display: none; background: transparent; color: var(--text); font-size: 26px; line-height: 1; padding: 0 6px; }
.thread { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 65%; padding: 8px 10px 6px; border-radius: 10px; font-size: 14.5px; line-height: 1.35; position: relative; word-wrap: break-word; }
.bubble.in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 2px; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 2px; }
.bubble .time { font-size: 10.5px; color: var(--muted); text-align: right; margin-top: 2px; }
.media-img { max-width: 260px; border-radius: 8px; display: block; }
.media-file { color: var(--text); text-decoration: none; }
.composer { display: flex; gap: 10px; padding: 12px 16px; background: var(--panel); align-items: center; }
.composer input[type=text], .composer input:not([type]) {
flex: 1; padding: 11px 14px; border-radius: 20px; border: none; background: var(--panel-2); color: var(--text); font-size: 15px;
}
.composer input:focus { outline: none; }
.attach { cursor: pointer; font-size: 20px; user-select: none; }
.send { background: var(--accent); color: #04140f; font-weight: 600; border-radius: 20px; }
/* ---- modal ---- */
.modal-overlay {
position: fixed; inset: 0; background: rgba(0,0,0,.6);
display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal-card {
background: var(--panel); border-radius: 14px; padding: 24px;
width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px;
box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-title { margin: 0; font-size: 18px; }
.modal-input {
padding: 12px 14px; border-radius: 10px; border: 1px solid var(--panel-2);
background: var(--panel-2); color: var(--text); font-size: 15px;
}
.modal-input:focus { outline: 2px solid var(--accent); }
.modal-err { color: #f15c6d; font-size: 13px; min-height: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
.modal-actions button { padding: 10px 16px; }
/* ---- account menu ---- */
.side-header { cursor: pointer; }
.side-header:hover { background: var(--panel-2); }
.caret { color: var(--muted); font-size: 12px; }
.acct-row, .acct-action {
text-align: left; background: var(--panel-2); color: var(--text);
padding: 11px 14px; border-radius: 10px;
}
.acct-row.active { outline: 1px solid var(--accent); }
.acct-action { background: transparent; color: var(--accent); border: 1px solid var(--panel-2); }
.acct-action.danger { color: #f15c6d; border-color: #4a2a2f; }
/* ---- toasts ---- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { padding: 12px 18px; border-radius: 10px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.5); max-width: 90vw; }
.toast.error { background: #3a1c22; color: #ffb3bd; border: 1px solid #5a2a33; }
.toast.info { background: var(--panel-2); color: var(--text); }
@media (max-width: 720px) {
.shell { grid-template-columns: 1fr; }
/* Sidebar shows by default; hide it once a chat is open so the thread is full-width. */
.shell.chat-open .sidebar { display: none; }
.shell:not(.chat-open) .main { display: none; }
.back-btn { display: block; }
}
</style>
</head>
<body>
<div id="app"></div>
<script type="module" src="/js/app.js"></script>
</body>
</html>