Merge branch 'dev'
CI/CD / deploy (push) Successful in 3m0s
Details
CI/CD / deploy (push) Successful in 3m0s
Details
This commit is contained in:
commit
15a1b726d1
|
|
@ -3714,6 +3714,9 @@ app.get('/link', (c) => {
|
||||||
.btn { display: inline-block; padding: 0.75rem 2rem; background: linear-gradient(90deg, #00d4ff, #7c3aed); color: #fff; border: none; border-radius: 8px; font-weight: 600; font-size: 1rem; cursor: pointer; transition: transform 0.2s; }
|
.btn { display: inline-block; padding: 0.75rem 2rem; background: linear-gradient(90deg, #00d4ff, #7c3aed); color: #fff; border: none; border-radius: 8px; font-weight: 600; font-size: 1rem; cursor: pointer; transition: transform 0.2s; }
|
||||||
.btn:hover { transform: translateY(-2px); }
|
.btn:hover { transform: translateY(-2px); }
|
||||||
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
|
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
|
||||||
|
.btn-copy { display: inline-block; padding: 0.6rem 1.5rem; background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; font-size: 0.85rem; cursor: pointer; margin-top: 0.75rem; }
|
||||||
|
.btn-copy:active { background: rgba(255,255,255,0.2); }
|
||||||
|
.browser-hint { color: #94a3b8; font-size: 0.8rem; margin-top: 0.75rem; line-height: 1.5; }
|
||||||
.hidden { display: none; }
|
.hidden { display: none; }
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
@ -3723,6 +3726,11 @@ app.get('/link', (c) => {
|
||||||
<h1>Link This Device</h1>
|
<h1>Link This Device</h1>
|
||||||
<div id="status" class="status loading">Loading...</div>
|
<div id="status" class="status loading">Loading...</div>
|
||||||
<button id="link-btn" class="btn hidden" onclick="linkDevice()">Create Passkey on This Device</button>
|
<button id="link-btn" class="btn hidden" onclick="linkDevice()">Create Passkey on This Device</button>
|
||||||
|
<div id="no-webauthn" class="hidden">
|
||||||
|
<p class="browser-hint">Passkeys require a full browser.<br>Open this link in <strong>Safari</strong> (iOS) or <strong>Chrome</strong> (Android):</p>
|
||||||
|
<button class="btn-copy" onclick="copyLink()">Copy Link</button>
|
||||||
|
<p id="copy-confirm" class="browser-hint hidden" style="color:#22c55e;">Copied!</p>
|
||||||
|
</div>
|
||||||
<div id="done" class="hidden">
|
<div id="done" class="hidden">
|
||||||
<p style="color:#94a3b8;margin-top:1rem;font-size:0.9rem;">You can now sign in from this device using your passkey.</p>
|
<p style="color:#94a3b8;margin-top:1rem;font-size:0.9rem;">You can now sign in from this device using your passkey.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -3736,12 +3744,37 @@ app.get('/link', (c) => {
|
||||||
|
|
||||||
let linkInfo = null;
|
let linkInfo = null;
|
||||||
|
|
||||||
|
function copyLink() {
|
||||||
|
const url = window.location.href;
|
||||||
|
if (navigator.clipboard) {
|
||||||
|
navigator.clipboard.writeText(url).then(() => {
|
||||||
|
document.getElementById('copy-confirm').classList.remove('hidden');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Fallback for WebViews without clipboard API
|
||||||
|
const ta = document.createElement('textarea');
|
||||||
|
ta.value = url;
|
||||||
|
ta.style.position = 'fixed';
|
||||||
|
ta.style.opacity = '0';
|
||||||
|
document.body.appendChild(ta);
|
||||||
|
ta.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
document.body.removeChild(ta);
|
||||||
|
document.getElementById('copy-confirm').classList.remove('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
if (!linkToken) {
|
if (!linkToken) {
|
||||||
statusEl.className = 'status error';
|
statusEl.className = 'status error';
|
||||||
statusEl.textContent = 'No link token found.';
|
statusEl.textContent = 'No link token found.';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check WebAuthn support early — QR scanners often use WebViews that lack it
|
||||||
|
const webauthnSupported = window.PublicKeyCredential &&
|
||||||
|
typeof navigator.credentials?.create === 'function';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/device-link/' + encodeURIComponent(linkToken) + '/info');
|
const res = await fetch('/api/device-link/' + encodeURIComponent(linkToken) + '/info');
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
|
|
@ -3751,6 +3784,14 @@ app.get('/link', (c) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
linkInfo = data;
|
linkInfo = data;
|
||||||
|
|
||||||
|
if (!webauthnSupported) {
|
||||||
|
statusEl.className = 'status error';
|
||||||
|
statusEl.textContent = 'This browser does not support passkeys.';
|
||||||
|
document.getElementById('no-webauthn').classList.remove('hidden');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
statusEl.className = 'status success';
|
statusEl.className = 'status success';
|
||||||
statusEl.textContent = 'Link this device to ' + data.username + String.fromCharCode(39) + 's account';
|
statusEl.textContent = 'Link this device to ' + data.username + String.fromCharCode(39) + 's account';
|
||||||
btn.classList.remove('hidden');
|
btn.classList.remove('hidden');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue