diff --git a/HANDOFF.md b/HANDOFF.md index bc42e0b..2d80192 100644 --- a/HANDOFF.md +++ b/HANDOFF.md @@ -104,7 +104,7 @@ Against local open-oscar-server 0.25.0 with `DISABLE_AUTH=true`, TOC listener 98 2. **UI polish follow-up:** unread indicators, chat room membership/invite-send UI, better mobile layout. (Tab close/leave for PMs and chat rooms added 2026-12-03.) 3. **Harden TOC client:** handle reconnect/backoff, keepalive timeout, parse CONFIG2 buddy list properly, handle TOC1/TOC2 variants, handle chat errors/room not found. 4. **Chat UX:** show chat room membership, leave button, invite-send UI, better system messages, error states. -5. **Security follow-up:** login target host/ports are validated: localhost/private/reserved IPs and hostnames resolving to them are blocked (`isDisallowedHost`), and Web API/TOC ports must be within +/-5 of configured default ports (`isAllowedPort`) to limit port scanning. Login failures always return generic `login failed` after a minimum 15s delay to reduce timing/oracle abuse. Bot check is basic (scriptable); rely on rate limits and consider stronger CAPTCHA if abuse appears. +5. **Security follow-up:** login target host/ports are validated: localhost/private/reserved IPs and hostnames resolving to them are blocked (`isDisallowedHost`), and Web API/TOC ports must be within +/-5 of configured default ports (`isAllowedPort`) to limit port scanning. Login failures always return generic `login failed` after a minimum 7s delay to reduce timing/oracle abuse. Bot check is basic (scriptable); rely on rate limits and consider stronger CAPTCHA if abuse appears. ## Files of interest diff --git a/public/app.js b/public/app.js index c3c2763..b941e6b 100644 --- a/public/app.js +++ b/public/app.js @@ -6,9 +6,9 @@ // - Dedupe matters because TOC/Web API paths and SSE replay can surface the same message; // we use msgId when present, otherwise a short recent text/from/mine heuristic. // - UI rendering is delegated to js/ui.js; API calls to js/api.js; SSE to js/stream.js. -import { api } from './js/api.js?v=35'; -import { createStream } from './js/stream.js?v=35'; -import * as ui from './js/ui.js?v=35'; +import { api } from './js/api.js?v=36'; +import { createStream } from './js/stream.js?v=36'; +import * as ui from './js/ui.js?v=36'; window.addEventListener('error', (e) => { console.error('[ui] error', e.error || e.message); @@ -341,6 +341,12 @@ async function loadChallenge() { document.getElementById('loginForm').addEventListener('submit', async (e) => { e.preventDefault(); ui.setLoginError(''); + const submitBtn = e.currentTarget.querySelector('.login-submit'); + const originalBtnHtml = submitBtn ? submitBtn.innerHTML : ''; + if (submitBtn) { + submitBtn.disabled = true; + submitBtn.innerHTML = 'Signing in...'; + } const screenName = document.getElementById('screenName').value.trim(); const password = document.getElementById('password').value; const host = document.getElementById('serverHost').value.trim(); @@ -353,6 +359,11 @@ document.getElementById('loginForm').addEventListener('submit', async (e) => { } catch (err) { ui.setLoginError(err.message); loadChallenge().catch(() => {}); + } finally { + if (submitBtn) { + submitBtn.disabled = false; + submitBtn.innerHTML = originalBtnHtml || 'Sign in'; + } } }); diff --git a/public/index.html b/public/index.html index 8818a10..66473d7 100644 --- a/public/index.html +++ b/public/index.html @@ -4,7 +4,7 @@ Web OSCAR Chat - +
@@ -98,6 +98,6 @@
- + diff --git a/public/style.css b/public/style.css index 02054e4..c7722a1 100644 --- a/public/style.css +++ b/public/style.css @@ -101,6 +101,19 @@ main { padding: 1rem; max-width: 1600px; margin: 0 auto; } .captcha-label { min-width: 0; } .captcha-q { color: var(--text); font-weight: 600; margin-left: 0.35rem; font-family: var(--mono); font-size: 0.9rem; } .login-submit { min-width: 120px; height: 2.5rem; } +.login-submit[disabled] { opacity: 0.8; cursor: wait; } +.spinner { + display: inline-block; + width: 0.95em; + height: 0.95em; + border: 2px solid rgba(255,255,255,0.35); + border-top-color: currentColor; + border-radius: 50%; + animation: spin 0.8s linear infinite; + vertical-align: -0.15em; + margin-right: 0.45em; +} +@keyframes spin { to { transform: rotate(360deg); } } @media (max-width: 560px) { .login-grid, .login-grid-server, .login-grid-captcha { grid-template-columns: 1fr; } .login-submit { width: 100%; } diff --git a/src/routes/auth.js b/src/routes/auth.js index 41ebfe7..f2222f7 100644 --- a/src/routes/auth.js +++ b/src/routes/auth.js @@ -123,7 +123,7 @@ async function tryTocLogin(rec, { screenName, host, tocPort, password, webapiBas return next; } -const LOGIN_FAIL_DELAY_MS = 15_000; +const LOGIN_FAIL_DELAY_MS = 7_000; async function failLogin(res, startedAt) { const elapsed = Date.now() - startedAt;