107 lines
4.3 KiB
HTML
107 lines
4.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Dashboard - Passkey Authentication</title>
|
|
<link rel="stylesheet" href="/static/style.css">
|
|
<script src="/static/simplewebauthn-browser.min.js"></script>
|
|
<script src="/static/qrcodejs/qrcode.min.js"></script>
|
|
<script src="/static/awaitable-websocket.js"></script>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- Dashboard View -->
|
|
<div id="dashboardView" class="view active">
|
|
<h1>👋 Welcome!</h1>
|
|
<div id="userInfo" class="user-info"></div>
|
|
<div id="dashboardStatus"></div>
|
|
|
|
<h2>Your Passkeys</h2>
|
|
<div id="credentialList" class="credential-list">
|
|
<p>Loading credentials...</p>
|
|
</div>
|
|
|
|
<button onclick="addNewCredential()" class="btn-primary">
|
|
Add New Passkey
|
|
</button>
|
|
<button onclick="generateAndShowDeviceLink()" class="btn-secondary">
|
|
Generate Device Link
|
|
</button>
|
|
<button onclick="logout()" class="btn-danger">
|
|
Logout
|
|
</button>
|
|
|
|
<!-- Device Addition Section -->
|
|
<div id="deviceLinkSection" style="display: none;">
|
|
<h2>Device Addition Link</h2>
|
|
<div class="token-info">
|
|
<p><strong>Share this link to add this account to another device:</strong></p>
|
|
|
|
<div class="qr-container">
|
|
<div id="qrCode" class="qr-code"></div>
|
|
<p><small>Scan this QR code with your other device</small></p>
|
|
</div>
|
|
|
|
<div class="link-container">
|
|
<p class="link-text" id="deviceLinkText">Loading...</p>
|
|
<button class="copy-button" onclick="copyDeviceLink()">Copy Link</button>
|
|
</div>
|
|
|
|
<p><small>⚠️ This link expires in 24 hours and can only be used once.</small></p>
|
|
<p><strong>Human-readable code:</strong> <code id="deviceToken"></code></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/static/app.js"></script>
|
|
<script>
|
|
// Initialize the dashboard view when page loads
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
initializeApp();
|
|
});
|
|
|
|
// Override the generateAndShowDeviceLink function to show the device link section
|
|
function generateAndShowDeviceLink() {
|
|
clearStatus('dashboardStatus');
|
|
|
|
fetch('/api/create-device-link', {
|
|
method: 'POST',
|
|
credentials: 'include'
|
|
})
|
|
.then(response => response.json())
|
|
.then(result => {
|
|
if (result.error) throw new Error(result.error);
|
|
|
|
// Update UI with the link
|
|
document.getElementById('deviceLinkText').textContent = result.addition_link;
|
|
document.getElementById('deviceToken').textContent = result.token;
|
|
|
|
// Store link globally for copy function
|
|
window.currentDeviceLink = result.addition_link;
|
|
|
|
// Generate QR code
|
|
const qrCodeEl = document.getElementById('qrCode');
|
|
qrCodeEl.innerHTML = '';
|
|
new QRCode(qrCodeEl, {
|
|
text: result.addition_link,
|
|
width: 200,
|
|
height: 200,
|
|
colorDark: '#000000',
|
|
colorLight: '#ffffff',
|
|
correctLevel: QRCode.CorrectLevel.M
|
|
});
|
|
|
|
// Show the device link section
|
|
document.getElementById('deviceLinkSection').style.display = 'block';
|
|
|
|
showStatus('dashboardStatus', 'Device link generated successfully!', 'success');
|
|
})
|
|
.catch(error => {
|
|
console.error('Error generating device link:', error);
|
|
showStatus('dashboardStatus', `Failed to generate device link: ${error.message}`, 'error');
|
|
});
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|