Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat(auth): add forgot/reset password frontend pages
nirholas58c4d30d2215
diff --git a/public/dashboard/dashboard.js b/public/dashboard/dashboard.jsindex f3b861e45..91af6a5a3 100644--- a/public/dashboard/dashboard.js+++ b/public/dashboard/dashboard.js@@ -2608,26 +2608,26 @@ async function renderAnimations(root) {rightCol.appendChild(rh);if (presets.length) {- const presetsHeader = document.createElement(‘div’);- presetsHeader.className = ‘presets-header’;- const pl = document.createElement(‘p’);- pl.className = ‘muted’;- pl.style.margin = ‘0’;- pl.textContent = ‘Presets’;- const addAllBtn = document.createElement(‘button’);- addAllBtn.className = ‘btn sec add-all-btn’;- addAllBtn.textContent = ‘Add all’;- addAllBtn.addEventListener(‘click’, addAllPresets);+ const presetsHeader = document.createElement('div');+ presetsHeader.className = 'presets-header';+ const pl = document.createElement('p');+ pl.className = 'muted';+ pl.style.margin = '0';+ pl.textContent = 'Presets';+ const addAllBtn = document.createElement('button');+ addAllBtn.className = 'btn sec add-all-btn';+ addAllBtn.textContent = 'Add all';+ addAllBtn.addEventListener('click', addAllPresets);presetsHeader.appendChild(pl);presetsHeader.appendChild(addAllBtn);rightCol.appendChild(presetsHeader);- presetGridEl = document.createElement(‘div’);- presetGridEl.className = ‘preset-grid’;+ presetGridEl = document.createElement('div');+ presetGridEl.className = 'preset-grid';rightCol.appendChild(presetGridEl);} else if (presetsError) {- const pe = document.createElement(‘div’);- pe.className = ‘anim-inline-err’;- pe.style.marginBottom = ‘12px’;+ const pe = document.createElement('div');+ pe.className = 'anim-inline-err';+ pe.style.marginBottom = '12px';pe.textContent = `Couldn’t load presets (${presetsError}).`;rightCol.appendChild(pe);}diff --git a/public/forgot-password.html b/public/forgot-password.htmlnew file mode 100644index 000000000..539ea8e69--- /dev/null+++ b/public/forgot-password.html@@ -0,0 +1,175 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>Forgot password · three.ws</title>+ <link rel="icon" href="/favicon.ico" />+ <style>+ :root {+ color-scheme: dark;+ --accent: #6a5cff;+ --accent2: #ff5ca8;+ }+ * {+ box-sizing: border-box;+ }+ body {+ font:+ 15px/1.5 -apple-system,+ system-ui,+ Segoe UI,+ Roboto,+ sans-serif;+ background: radial-gradient(1200px 600px at 50% -100px, #1a1a2e 0, #080814 60%);+ color: #eee;+ margin: 0;+ min-height: 100vh;+ display: grid;+ place-items: center;+ padding: 24px;+ }+ a {+ color: #9a8cff;+ }+ .card {+ background: #14141c;+ border: 1px solid #2a2a36;+ border-radius: 16px;+ padding: 32px;+ max-width: 400px;+ width: 100%;+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);+ }+ h1 {+ font-size: 22px;+ margin: 0 0 4px;+ letter-spacing: -0.01em;+ }+ .sub {+ color: #888;+ margin: 0 0 24px;+ font-size: 14px;+ }+ label {+ display: block;+ font-size: 13px;+ color: #aaa;+ margin: 14px 0 6px;+ }+ input {+ width: 100%;+ padding: 11px 13px;+ background: #0f0f17;+ border: 1px solid #2a2a36;+ border-radius: 9px;+ color: #eee;+ font-size: 15px;+ }+ input:focus {+ outline: none;+ border-color: var(--accent);+ box-shadow: 0 0 0 3px rgba(106, 92, 255, 0.15);+ }+ button {+ width: 100%;+ margin-top: 20px;+ padding: 12px 16px;+ border: 0;+ border-radius: 10px;+ background: linear-gradient(135deg, var(--accent), var(--accent2));+ color: #fff;+ font-weight: 600;+ font-size: 15px;+ cursor: pointer;+ }+ button:disabled {+ opacity: 0.6;+ cursor: default;+ }+ .err {+ margin-top: 14px;+ padding: 10px 12px;+ background: rgba(255, 92, 92, 0.1);+ border: 1px solid rgba(255, 92, 92, 0.3);+ border-radius: 8px;+ color: #ffb3b3;+ font-size: 13px;+ display: none;+ }+ .ok {+ margin-top: 14px;+ padding: 10px 12px;+ background: rgba(92, 200, 130, 0.08);+ border: 1px solid rgba(92, 200, 130, 0.3);+ border-radius: 8px;+ color: #b3e6c4;+ font-size: 13px;+ }+ .foot {+ margin-top: 20px;+ text-align: center;+ font-size: 13px;+ color: #888;+ }+ .brand {+ font-size: 12px;+ letter-spacing: 0.1em;+ text-transform: uppercase;+ color: var(--accent);+ margin: 0 0 8px;+ }+ </style>+ </head>+ <body>+ <form class="card" id="f">+ <p class="brand">three.ws</p>+ <h1>Forgot password</h1>+ <p class="sub">Enter your email and we'll send you a reset link.</p>+ <label for="email">Email</label>+ <input+ id="email"+ type="email"+ autocomplete="email"+ required+ aria-describedby="email-hint"+ />+ <button id="submit" type="submit">Send reset link</button>+ <div class="err" id="err" role="alert"></div>+ <div class="ok" id="ok" style="display:none">+ If an account exists for that email, a reset link has been sent.+ </div>+ <p class="foot"><a href="/login">Back to sign in</a></p>+ </form>+ <script>+ const form = document.getElementById('f');+ const err = document.getElementById('err');+ const ok = document.getElementById('ok');+ const btn = document.getElementById('submit');+ form.addEventListener('submit', async (e) => {+ e.preventDefault();+ err.style.display = 'none';+ ok.style.display = 'none';+ btn.disabled = true;+ btn.textContent = 'Sending…';+ try {+ await fetch('/api/auth/forgot-password', {+ method: 'POST',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({+ email: document.getElementById('email').value,+ }),+ });+ // Anti-enumeration: always show the same success message.+ ok.style.display = 'block';+ } catch {+ // Even on network failure we keep the same message to avoid leaking signal.+ ok.style.display = 'block';+ } finally {+ btn.disabled = false;+ btn.textContent = 'Send reset link';+ }+ });+ </script>+ </body>+</html>diff --git a/public/login.html b/public/login.htmlindex abcf075b3..32f0ec434 100644--- a/public/login.html+++ b/public/login.html@@ -179,6 +179,9 @@requiredminlength="10"/>+ <p class="hint" style="font-size:12px;color:#666;margin-top:4px;text-align:right">+ <a href="/forgot-password">Forgot password?</a>+ </p><button id="submit" type="submit">Sign in</button><div class="divider">or connect wallet</div><div class="chain-tabs">diff --git a/public/reset-password.html b/public/reset-password.htmlnew file mode 100644index 000000000..9f35d2eb6--- /dev/null+++ b/public/reset-password.html@@ -0,0 +1,215 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="utf-8" />+ <meta name="viewport" content="width=device-width,initial-scale=1" />+ <title>Reset password · three.ws</title>+ <link rel="icon" href="/favicon.ico" />+ <style>+ :root {+ color-scheme: dark;+ --accent: #6a5cff;+ --accent2: #ff5ca8;+ }+ * {+ box-sizing: border-box;+ }+ body {+ font:+ 15px/1.5 -apple-system,+ system-ui,+ Segoe UI,+ Roboto,+ sans-serif;+ background: radial-gradient(1200px 600px at 50% -100px, #1a1a2e 0, #080814 60%);+ color: #eee;+ margin: 0;+ min-height: 100vh;+ display: grid;+ place-items: center;+ padding: 24px;+ }+ a {+ color: #9a8cff;+ }+ .card {+ background: #14141c;+ border: 1px solid #2a2a36;+ border-radius: 16px;+ padding: 32px;+ max-width: 400px;+ width: 100%;+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);+ }+ h1 {+ font-size: 22px;+ margin: 0 0 4px;+ letter-spacing: -0.01em;+ }+ .sub {+ color: #888;+ margin: 0 0 24px;+ font-size: 14px;+ }+ label {+ display: block;+ font-size: 13px;+ color: #aaa;+ margin: 14px 0 6px;+ }+ input {+ width: 100%;+ padding: 11px 13px;+ background: #0f0f17;+ border: 1px solid #2a2a36;+ border-radius: 9px;+ color: #eee;+ font-size: 15px;+ }+ input:focus {+ outline: none;+ border-color: var(--accent);+ box-shadow: 0 0 0 3px rgba(106, 92, 255, 0.15);+ }+ .hint {+ font-size: 12px;+ color: #666;+ margin-top: 4px;+ }+ button {+ width: 100%;+ margin-top: 20px;+ padding: 12px 16px;+ border: 0;+ border-radius: 10px;+ background: linear-gradient(135deg, var(--accent), var(--accent2));+ color: #fff;+ font-weight: 600;+ font-size: 15px;+ cursor: pointer;+ }+ button:disabled {+ opacity: 0.6;+ cursor: default;+ }+ .err {+ margin-top: 14px;+ padding: 10px 12px;+ background: rgba(255, 92, 92, 0.1);+ border: 1px solid rgba(255, 92, 92, 0.3);+ border-radius: 8px;+ color: #ffb3b3;+ font-size: 13px;+ display: none;+ }+ .ok {+ margin-top: 14px;+ padding: 10px 12px;+ background: rgba(92, 200, 130, 0.08);+ border: 1px solid rgba(92, 200, 130, 0.3);+ border-radius: 8px;+ color: #b3e6c4;+ font-size: 13px;+ }+ .foot {+ margin-top: 20px;+ text-align: center;+ font-size: 13px;+ color: #888;+ }+ .brand {+ font-size: 12px;+ letter-spacing: 0.1em;+ text-transform: uppercase;+ color: var(--accent);+ margin: 0 0 8px;+ }+ </style>+ </head>+ <body>+ <form class="card" id="f">+ <p class="brand">three.ws</p>+ <h1>Reset password</h1>+ <p class="sub">Choose a new password for your account.</p>+ <label for="password">New password</label>+ <input+ id="password"+ type="password"+ autocomplete="new-password"+ required+ minlength="10"+ maxlength="200"+ aria-describedby="password-hint"+ />+ <p id="password-hint" class="hint">Minimum 10 characters</p>+ <label for="confirm">Confirm new password</label>+ <input+ id="confirm"+ type="password"+ autocomplete="new-password"+ required+ minlength="10"+ maxlength="200"+ />+ <button id="submit" type="submit">Reset password</button>+ <div class="err" id="err" role="alert"></div>+ <p class="foot"><a href="/login">Back to sign in</a></p>+ </form>+ <div class="card" id="done" style="display:none">+ <p class="brand">three.ws</p>+ <h1>Password reset</h1>+ <div class="ok">Password reset. You can now log in.</div>+ <p class="foot"><a href="/login">Go to sign in</a></p>+ </div>+ <script>+ const params = new URLSearchParams(location.search);+ const token = params.get('token') || '';+ const form = document.getElementById('f');+ const err = document.getElementById('err');+ const btn = document.getElementById('submit');+ const done = document.getElementById('done');++ function showErr(msg) {+ err.textContent = msg;+ err.style.display = 'block';+ }++ if (!token) {+ showErr('Missing or invalid reset token. Request a new reset link.');+ btn.disabled = true;+ }++ form.addEventListener('submit', async (e) => {+ e.preventDefault();+ err.style.display = 'none';+ const password = document.getElementById('password').value;+ const confirm = document.getElementById('confirm').value;+ if (password.length < 10) {+ showErr('Password must be at least 10 characters.');+ return;+ }+ if (password !== confirm) {+ showErr('Passwords do not match.');+ return;+ }+ btn.disabled = true;+ btn.textContent = 'Resetting…';+ try {+ const res = await fetch('/api/auth/reset-password', {+ method: 'POST',+ headers: { 'content-type': 'application/json' },+ body: JSON.stringify({ token, password }),+ });+ const data = await res.json().catch(() => ({}));+ if (!res.ok) throw new Error(data.error || 'Reset failed');+ form.style.display = 'none';+ done.style.display = 'block';+ } catch (e) {+ showErr(e.message);+ btn.disabled = false;+ btn.textContent = 'Reset password';+ }+ });+ </script>+ </body>+</html>diff --git a/vercel.json b/vercel.jsonindex 07842d9a3..38ba68c6e 100644--- a/vercel.json+++ b/vercel.json@@ -31,6 +31,8 @@{ "src": "/login", "dest": "/login.html" },{ "src": "/register", "dest": "/register.html" },+ { "src": "/forgot-password", "dest": "/forgot-password.html" },+ { "src": "/reset-password", "dest": "/reset-password.html" },{ "src": "/wallet-login.js", "dest": "/wallet-login.js" },{ "src": "/wallet/(.*)", "dest": "/wallet/$1" },{ "src": "/deploy", "dest": "/app.html" },@@ -97,6 +99,7 @@"dest": "/api/widgets/[id]/duplicate?id=$1"},{ "src": "/api/widgets/([A-Za-z0-9_-]+)/stats", "dest": "/api/widgets/[id]/stats?id=$1" },+ { "src": "/api/widgets/([A-Za-z0-9_-]+)/chat", "dest": "/api/widgets/[id]/chat?id=$1" },{ "src": "/api/widgets", "dest": "/api/widgets" },{ "src": "/api/widgets/([A-Za-z0-9_-]+)", "dest": "/api/widgets/[id]?id=$1" },{ "src": "/w/([A-Za-z0-9_-]+)", "dest": "/api/widgets/page?id=$1" },