function generateKey() { if (!confirm('WARNING: Generating a new master key will make all existing encrypted credentials UNREADABLE. ' + 'You will need to re-enter all SSH credentials. Continue?')) return; fetch('/admin/security/generate-key', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]')?.content || '', }, body: '_csrf_token=' + encodeURIComponent(document.querySelector('meta[name="csrf-token"]')?.content || ''), }) .then(r => r.json()) .then(data => { showToast(data.success ? 'success' : 'error', data.message); }); }