05/02/2026 updated code for security 2

This commit is contained in:
2026-05-02 18:44:39 -04:00
parent c7b1806ec8
commit 78feedc5c7
15 changed files with 1347 additions and 182 deletions
+38
View File
@@ -919,6 +919,44 @@ const Vault = (() => {
document.getElementById('btn-export-csv')?.addEventListener('click', async () => {
const vaultKey = VaultSession.getKey();
if (!vaultKey) { showUnlockOverlay(); return; }
// Warn the user that this export contains plaintext passwords before proceeding.
const confirmed = await new Promise((resolve) => {
const overlay = document.createElement('div');
overlay.style.cssText = [
'position:fixed', 'inset:0', 'background:rgba(0,0,0,0.55)',
'z-index:9999', 'display:flex', 'align-items:center', 'justify-content:center',
].join(';');
overlay.innerHTML = `
<div style="background:#fff;border-radius:12px;padding:28px 24px;max-width:380px;width:90%;box-shadow:0 8px 32px rgba(0,0,0,0.22);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;">
<div style="display:flex;align-items:center;gap:10px;margin-bottom:14px;">
<svg width="22" height="22" viewBox="0 0 24 24" fill="none">
<path d="M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z" stroke="#d97706" stroke-width="1.8" fill="none"/>
<line x1="12" y1="9" x2="12" y2="13" stroke="#d97706" stroke-width="1.8" stroke-linecap="round"/>
<line x1="12" y1="17" x2="12.01" y2="17" stroke="#d97706" stroke-width="2" stroke-linecap="round"/>
</svg>
<strong style="font-size:15px;color:#111827;">Export plaintext passwords?</strong>
</div>
<p style="font-size:13px;color:#374151;margin-bottom:6px;">
The CSV file will contain <strong>all your passwords in plaintext</strong>.
Anyone with access to the file can read them.
</p>
<p style="font-size:13px;color:#374151;margin-bottom:20px;">
Store the file in a secure location and delete it when you no longer need it.
</p>
<div style="display:flex;gap:10px;justify-content:flex-end;">
<button id="_csv_cancel" style="padding:8px 18px;border:1px solid #d1d5db;border-radius:7px;background:transparent;cursor:pointer;font-size:13px;color:#374151;">Cancel</button>
<button id="_csv_confirm" style="padding:8px 18px;border:none;border-radius:7px;background:#c0392b;color:#fff;cursor:pointer;font-size:13px;font-weight:600;">Export anyway</button>
</div>
</div>`;
document.body.appendChild(overlay);
overlay.querySelector('#_csv_cancel').addEventListener('click', () => { overlay.remove(); resolve(false); });
overlay.querySelector('#_csv_confirm').addEventListener('click', () => { overlay.remove(); resolve(true); });
overlay.addEventListener('click', (e) => { if (e.target === overlay) { overlay.remove(); resolve(false); } });
});
if (!confirmed) return;
try {
const res = await apiFetch('/api/vault');
if (!res) return;