refactor: Phase 1 code cleanup - constants, logging, and repository organization

This commit is contained in:
2026-03-28 18:54:39 -07:00
parent f1b0ac43d0
commit 6c3848102b
24 changed files with 17078 additions and 50 deletions

View File

@@ -12,7 +12,7 @@
<!-- Setup Button (not configured state) -->
<div id="totp-setup-section">
<button id="totp-setup-btn" style="width: 100%; padding: 12px; background: var(--accent, #8FD6FF); color: #0b0f1a; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.95rem;">
<button id="totp-setup-btn" class="btn-accent-solid" style="width: 100%; padding: 12px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.95rem;">
Generate New Secret
</button>
<div style="display: flex; align-items: center; gap: 8px; margin: 10px 0 0;">
@@ -29,6 +29,7 @@
Import
</button>
</div>
<div id="totp-import-error" style="color: var(--bad-fg, #ff9aa3); font-size: 0.8rem; min-height: 1.2em; margin-top: 6px;"></div>
</div>
</div>
@@ -55,7 +56,7 @@
<div style="display: flex; gap: 8px; margin-top: 8px;">
<input type="text" id="totp-setup-code" maxlength="6" inputmode="numeric" pattern="[0-9]{6}" placeholder="000000"
style="flex: 1; text-align: center; font-size: 1.3rem; padding: 10px; font-family: 'Sami Grotesk', monospace; letter-spacing: 4px; background: var(--bg); color: var(--fg); border: 2px solid var(--border); border-radius: 8px; outline: none;" />
<button id="totp-confirm-setup" style="padding: 10px 20px; background: var(--accent, #8FD6FF); color: #0b0f1a; border: none; border-radius: 8px; cursor: pointer; font-weight: 600;">
<button id="totp-confirm-setup" class="btn-accent-solid" style="padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600;">
Confirm
</button>
</div>
@@ -191,7 +192,12 @@
// Import existing secret button
document.getElementById('totp-import-btn')?.addEventListener('click', async () => {
const secret = document.getElementById('totp-import-key').value.trim();
if (!secret) return;
const errorEl = document.getElementById('totp-import-error');
errorEl.textContent = '';
if (!secret) {
errorEl.textContent = 'Paste a Base32 secret key first';
return;
}
try {
const res = await secureFetch('/api/v1/totp/setup', {
method: 'POST',
@@ -200,6 +206,7 @@
});
const data = await res.json();
if (data.success) {
errorEl.textContent = '';
document.getElementById('totp-qr-image').src = data.qrCode;
document.getElementById('totp-manual-key').textContent = data.manualKey;
document.getElementById('totp-setup-section').style.display = 'none';
@@ -208,11 +215,10 @@
document.getElementById('totp-setup-error').textContent = '';
document.getElementById('totp-setup-code').focus();
} else {
document.getElementById('totp-import-key').style.borderColor = 'var(--bad-fg)';
setTimeout(() => { document.getElementById('totp-import-key').style.borderColor = ''; }, 2000);
errorEl.textContent = data.error || data.message || 'Import failed';
}
} catch (e) {
console.error('TOTP import failed:', e);
errorEl.textContent = 'Connection error — try refreshing the page';
}
});