Files
inbuxa-server/resources/html-templates/passkey.html
jcoffey-dev fc2b886c5d
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 12m46s
Passkeys: sign in with a passkey (#334)
Third part of passkeys (docs/spec/features/passkeys.md, PK-8 to PK-12).

The login page offers passkeys in the authorization-code flow: the
browser's autofill on the username field where it supports conditional
mediation, and a "Sign in with a passkey" button. Each try asks
POST /api/auth/passkey for a challenge (anonymous and limited like the
login request), kept in the in-memory store for two minutes and good
once, so any node can answer the next step. The login request then
carries the browser's assertion in a new passkey field in place of the
name and password.

The server finds the passkey by credential id and the account by user
handle, and both must agree. It checks the signature, the origin, user
verification, that the passkey was made for the current relying-party
id, and the counter: one that didn't go up fails and is logged as a
possibly cloned passkey. Then the same checks run as for a password: a
locked account fails the same way, and the client, redirect URI and
PKCE checks are unchanged. A passkey signs in on its own, with no TOTP
code after it. Failures count toward the same sign-in blocking as wrong
passwords. A successful sign-in keeps the new counter and lastUsedAt,
raises auth.success with type passkey, and is recorded in the audit log
with via passkey where sign-ins are recorded.

The registration page now takes one of the account's active passkeys
instead of the password, and refuses an app password.

The device flow, the settings and the external-directory rule follow in
the last part.
2026-11-18 20:29:42 -07:00

601 lines
33 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="referrer" content="no-referrer">
<script>
// INBUXA (#375): the app that opened this page can pass theme=light or
// theme=dark so the page matches it; anything else follows the OS.
(function () {
var t = new URLSearchParams(window.location.search).get('theme');
if (t === 'light' || t === 'dark') document.documentElement.setAttribute('data-theme', t);
})();
</script>
<title>Add a passkey · inbuxa</title>
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAIAAAAlC+aJAAAR4ElEQVRo3u1aeXSV1bXf+5xvuHNyczOQGCAhCQQSEQEBEX3ocqJWUVwq8Vmxdnhaq3ZZO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IQkpnZhLqx8/PE12Z4SckZBSqlF1czyFeQdfXLP3V4vH/suNnopS2TPAEFLXVoajmGMMkTEjEOjatrvxqWVAMPZb8yMzJjrRGAABMnLTfkaug2TsdfOxSp42UaoiTR53AClK9A0UXHyeGcltfHr5Jw/9ofJr1xdMP5sQ9WQiO7M94NpxYtUYrmlHVr7TtmlHoLy04vbr/GXFTn9MD/qT/BQmKxxM9rYZJ0eZ3QFlHEIBACIBIYCSKu/8iRNHjWh8alnj4pdj+5vsQbtqVInbUZ060mfBSgAgwC0P/PzFVW8VlhYXThyrB70iZiNnqTIZ0wCACN0j14zy0yVSkKXXopT+k4gBQQmp+bwiGuv8uLGro3N0SeGGxY+XFBYoInYm5O7xm0KJxA8f+93L723t6exWUiFPHvcmWZ5M74fjjG+yuUmdVqaIckpXy5hZdkvFdd0bCkweN+bR73yzuqJ8eGiVTIa+raOzraOTcU6IWR3EEWXclkhRE6TIrfbcqE8q7YcMMejzjhlV+rnLeWcKIHmxkGioN/K+8Mj+1tnQbi1myVee0UDMsoj4IgD+Dsf/yZu7f1fjHx7A/wAJVRlLQg6OhgAAAABJRU5ErkJggg==">
<style>
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0
}
:root {
--bg: #f6f8fa;
--card: #ffffff;
--border: #e3e7ec;
--text: #111827;
--muted: #5b6472;
--accent: #0f766e;
--accent-fg: #ffffff;
--info: #0e7490;
--success: #15803d;
--radius: 10px;
--input-bg: #ffffff;
--brand-ink: #1C4053;
--danger: #b91c1c;
}
:root {
color-scheme: light dark;
}
:root[data-theme="light"] {
color-scheme: light;
}
@media(prefers-color-scheme:dark) {
:root:not([data-theme="light"]) {
--bg: #0b1220;
--card: #111a2b;
--border: #1f2a3d;
--text: #e5e9f0;
--muted: #9aa5b8;
--accent: #2dd4bf;
--accent-fg: #052e2b;
--info: #67e8f9;
--success: #4ade80;
--input-bg: #0d1524;
--brand-ink: #e5e9f0;
--danger: #f87171;
}
}
:root[data-theme="dark"] {
color-scheme: dark;
--bg: #0b1220;
--card: #111a2b;
--border: #1f2a3d;
--text: #e5e9f0;
--muted: #9aa5b8;
--accent: #2dd4bf;
--accent-fg: #052e2b;
--info: #67e8f9;
--success: #4ade80;
--input-bg: #0d1524;
--brand-ink: #e5e9f0;
--danger: #f87171;
}
body {
font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.card {
background: var(--card);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 0.5rem 2.25rem 2rem;
width: 100%;
max-width: 384px;
}
.logo-wrap {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
min-height: 72px;
margin: 0.25rem auto 0.5rem;
}
.logo-wrap svg.default-logo {
display: block;
width: calc(100% + 1rem);
height: auto;
margin: -0.25rem auto 0.1rem;
max-width: 320px;
}
.logo-wrap[data-loading] .default-logo {
visibility: hidden;
}
.logo-wrap img.custom-logo {
display: block;
max-width: 220px;
max-height: 96px;
width: auto;
height: auto;
object-fit: contain;
}
.default-logo .wordmark {
fill: var(--brand-ink)
}
h1 {
font-size: 1.125rem;
font-weight: 600;
letter-spacing: -.015em;
margin-bottom: .25rem
}
.sub {
font-size: .8125rem;
color: var(--muted);
margin-bottom: 1.75rem
}
.alert {
display: flex;
align-items: flex-start;
gap: .625rem;
padding: .625rem .75rem;
background: color-mix(in srgb, var(--danger, #dc2626) 10%, transparent);
border: 1px solid color-mix(in srgb, var(--danger, #dc2626) 30%, transparent);
border-radius: 8px;
font-size: .8125rem;
color: var(--danger, #b91c1c);
margin-bottom: .875rem;
}
.alert.success {
background: color-mix(in srgb, #0f7a3c 10%, transparent);
border-color: color-mix(in srgb, #0f7a3c 30%, transparent);
color: #0f7a3c;
}
@media(prefers-color-scheme:dark) {
:root:not([data-theme="light"]) .alert {
color: #f4839a
}
:root:not([data-theme="light"]) .alert.success {
color: #58c98a;
}
}
:root[data-theme="dark"] .alert {
color: #f4839a
}
:root[data-theme="dark"] .alert.success {
color: #58c98a;
}
.alert svg {
flex-shrink: 0;
margin-top: 1px
}
.fields {
display: flex;
flex-direction: column;
gap: .875rem
}
.field label {
font-size: .75rem;
font-weight: 500;
color: var(--muted);
letter-spacing: .03em;
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: .3125rem;
}
input[type=text],
input[type=password],
input[type=email] {
width: 100%;
padding: .5625rem .75rem;
font-size: .9375rem;
font-family: inherit;
background: var(--input-bg);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--text);
outline: none;
transition: border-color .15s;
-webkit-appearance: none;
}
input[type=text]:focus,
input[type=password]:focus,
input[type=email]:focus {
border-color: color-mix(in srgb, var(--info) 60%, transparent);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--info) 12%, transparent);
}
input[type=text]::placeholder,
input[type=password]::placeholder,
input[type=email]::placeholder {
color: var(--muted);
opacity: .7
}
#otp {
letter-spacing: .2em;
font-size: 1.0625rem;
text-align: center;
font-variant-numeric: tabular-nums
}
#device-code {
letter-spacing: .15em;
font-size: 1.0625rem;
text-align: center;
text-transform: uppercase;
font-variant-numeric: tabular-nums;
}
.btn {
width: 100%;
margin-top: .375rem;
padding: .625rem 0;
font-size: .9375rem;
font-weight: 500;
font-family: inherit;
background: var(--accent);
color: var(--accent-fg);
border: none;
border-radius: 8px;
cursor: pointer;
letter-spacing: -.01em;
transition: opacity .15s;
}
.btn:hover {
opacity: .88
}
.btn:active {
opacity: .75;
transform: scale(.99)
}
.btn[disabled] {
opacity: .55;
cursor: not-allowed;
transform: none;
}
.btn.secondary {
background: transparent;
color: var(--text);
border: 1px solid var(--border);
}
[hidden] {
display: none !important;
}
</style>
</head>
<body>
<div class="card">
<div class="logo-wrap" id="logo-wrap" data-loading>
<svg class="default-logo" xmlns="http://www.w3.org/2000/svg" viewBox="165 35 616 130" role="img" aria-label="inbuxa">
<g class="symbol" transform="translate(156.02,30.31) scale(1.0082)"><g stroke="#1C4053" stroke-linecap="round" stroke-linejoin="round"><g transform="translate(0 -12)"><path d="M18 58 L32 60 M19 67 L32 65 M110 58 L96 60 M109 67 L96 65" stroke-width="3" fill="none"/><g transform="translate(64 62) scale(0.9) translate(-64 -60)"><path d="M31 64 C30 50 31 38 34 27 Q36 20 42 23 L55 32 Q64 29.5 73 32 L86 23 Q92 20 94 27 C97 38 98 50 97 64 C96 83 82 92 64 92 C46 92 32 83 31 64 Z" fill="#F9A34C" stroke-width="5"/><path d="M38 30 L50 37.5 L40 45.5 Z M90 30 L78 37.5 L88 45.5 Z" fill="#F47F35" stroke="none"/><path d="M44 60 Q49.5 53 55 60 M73 60 Q78.5 53 84 60" stroke-width="4.2" fill="none"/><path d="M60.8 65.5 h6.4 l-3.2 3.6 z" fill="#1C4053" stroke-width="2"/><path d="M56 71.5 Q60 76.5 64 71.5 Q68 76.5 72 71.5" stroke-width="3.5" fill="none"/></g></g><rect x="12" y="73" width="104" height="51" rx="9" fill="#46CAC3" stroke-width="4.5"/><rect x="21" y="89" width="86" height="10" rx="2.5" fill="#1C4053" stroke="none"/><rect x="27" y="85.5" width="26" height="14" rx="2" fill="#FFFFFF" stroke-width="2.8"/><path d="M28.5 87 L40 93.5 L51.5 87" stroke-width="2.3" fill="none"/><circle cx="99" cy="94" r="2.5" fill="#9FF0E9" stroke="none"/><rect x="21" y="103" width="86" height="9" rx="2.5" fill="#1C4053" stroke="none"/><path d="M28 104.8 L31.8 107.5 L28 110.2 M34.8 110.2 H41" stroke="#9FF0E9" stroke-width="1.9" fill="none"/><circle cx="99" cy="107.5" r="2.5" fill="#9FF0E9" stroke="none"/><rect x="21" y="115.5" width="86" height="4.5" rx="2" fill="#2B8A86" stroke="none"/><circle cx="28" cy="117.75" r="1.6" fill="#F9A34C" stroke="none"/><circle cx="34" cy="117.75" r="1.6" fill="#9FF0E9" stroke="none"/><circle cx="40" cy="117.75" r="1.6" fill="#9FF0E9" stroke="none"/><g transform="translate(0 -12)"><path d="M36.5 90 C36 81 40 76.5 46 76.5 C52 76.5 56 81 55.5 90 C55.5 94 51 96 46 96 C41 96 36.5 94 36.5 90 Z" fill="#F9A34C" stroke-width="4"/><path d="M91.5 90 C92 81 88 76.5 82 76.5 C76 76.5 72 81 72.5 90 C72.5 94 77 96 82 96 C87 96 91.5 94 91.5 90 Z" fill="#F9A34C" stroke-width="4"/><path d="M43 88.5 V93 M49 88.5 V93 M79 88.5 V93 M85 88.5 V93" stroke-width="2.4" fill="none"/></g></g></g>
<g class="wordmark"><path d="M70 0V496H196V0ZM133 554Q99 554 75.5 576.0Q52 598 52 634Q52 670 75.5 692.0Q99 714 133 714Q168 714 191.0 692.0Q214 670 214 634Q214 598 191.0 576.0Q168 554 133 554Z" transform="translate(303.25,151.90) scale(0.150000,-0.150000)"/><path d="M70 0V496H194V431H212Q224 457 257.0 480.5Q290 504 357 504Q415 504 458.5 477.5Q502 451 526.0 404.5Q550 358 550 296V0H424V286Q424 342 396.5 370.0Q369 398 318 398Q260 398 228.0 359.5Q196 321 196 252V0Z" transform="translate(340.15,151.90) scale(0.150000,-0.150000)"/><path d="M368 -14Q301 -14 265.0 9.0Q229 32 212 60H194V0H70V700H196V439H214Q225 457 243.5 473.0Q262 489 292.5 499.5Q323 510 368 510Q428 510 479.0 480.5Q530 451 561.0 394.0Q592 337 592 256V240Q592 159 561.0 102.0Q530 45 479.0 15.5Q428 -14 368 -14ZM330 96Q388 96 427.0 133.5Q466 171 466 243V253Q466 325 427.5 362.5Q389 400 330 400Q272 400 233.0 362.5Q194 325 194 253V243Q194 171 233.0 133.5Q272 96 330 96Z" transform="translate(429.55,151.90) scale(0.150000,-0.150000)"/><path d="M259 -8Q201 -8 157.5 18.5Q114 45 90.0 92.0Q66 139 66 200V496H192V210Q192 154 219.5 126.0Q247 98 298 98Q356 98 388.0 136.5Q420 175 420 244V496H546V0H422V65H404Q392 40 359.0 16.0Q326 -8 259 -8Z" transform="translate(522.25,151.90) scale(0.150000,-0.150000)"/><path d="M26 0 206 250 28 496H174L287 331H305L418 496H564L386 250L566 0H418L305 167H287L174 0Z" transform="translate(611.65,151.90) scale(0.150000,-0.150000)"/><path d="M224 -14Q171 -14 129.0 4.5Q87 23 62.5 58.5Q38 94 38 145Q38 196 62.5 230.5Q87 265 130.5 282.5Q174 300 230 300H366V328Q366 363 344.0 385.5Q322 408 274 408Q227 408 204.0 386.5Q181 365 174 331L58 370Q70 408 96.5 439.5Q123 471 167.5 490.5Q212 510 276 510Q374 510 431.0 461.0Q488 412 488 319V134Q488 104 516 104H556V0H472Q435 0 411.0 18.0Q387 36 387 66V67H368Q364 55 350.0 35.5Q336 16 306.0 1.0Q276 -14 224 -14ZM246 88Q299 88 332.5 117.5Q366 147 366 196V206H239Q204 206 184.0 191.0Q164 176 164 149Q164 122 185.0 105.0Q206 88 246 88Z" transform="translate(697.45,151.90) scale(0.150000,-0.150000)"/></g>
</svg>
</div>
<h1 id="title">Add a passkey</h1>
<p class="sub" id="subtitle">Confirm it's you, then create the passkey on this device.</p>
<div class="alert" id="alert" hidden aria-live="polite">
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round">
<circle cx="12" cy="12" r="10" />
<line x1="12" y1="8" x2="12" y2="12" />
<line x1="12" y1="16" x2="12.01" y2="16" />
</svg>
<span id="alert-msg"></span>
</div>
<form class="fields" id="passkey-form" novalidate>
<div class="field" id="field-account" hidden>
<label for="account">Account</label>
<input id="account" name="username" type="text" autocomplete="username" readonly>
</div>
<div class="field" id="field-password">
<label for="password">Password</label>
<input id="password" name="password" type="password" placeholder="••••••••"
autocomplete="current-password" required>
</div>
<div class="field" id="field-otp" hidden>
<label for="otp">One-time code</label>
<input id="otp" name="otp" type="text" placeholder="000000" maxlength="6" inputmode="numeric"
pattern="\d{6}" autocomplete="one-time-code">
</div>
<button type="submit" class="btn" id="submit-btn">Continue</button>
<button type="button" class="btn secondary" id="passkey-btn" hidden>Use a passkey you already have</button>
</form>
</div>
<script>
// INBUXA (#334): registers a passkey for the ticket in this page's URL
// (passkeys spec PK-6 to PK-8). The password (and code) comes first;
// then the browser's own dialog makes the passkey.
(function () {
'use strict';
var $ = function (id) { return document.getElementById(id); };
function setText(el, text) { el.textContent = text == null ? '' : String(text); }
function show(el) { if (el) el.hidden = false; }
function hide(el) { if (el) el.hidden = true; }
function showError(msg) {
var a = $('alert');
a.classList.remove('success');
setText($('alert-msg'), msg);
show(a);
}
function showSuccess(msg) {
var a = $('alert');
a.classList.add('success');
setText($('alert-msg'), msg);
show(a);
}
function clearAlert() { hide($('alert')); }
var params = new URL(window.location.href).searchParams;
var ticket = params.get('ticket') || '';
var loginHint = null;
(function loadCustomLogo() {
var wrap = $('logo-wrap');
function showDefault() { wrap.removeAttribute('data-loading'); }
var params = [];
if (loginHint) {
var at = loginHint.lastIndexOf('@');
if (at !== -1 && at < loginHint.length - 1) {
params.push('domain=' + encodeURIComponent(loginHint.slice(at + 1).toLowerCase()));
}
}
// The dark-mode logo when this page shows dark (branding BT-27)
var theme = document.documentElement.getAttribute('data-theme');
if (theme === 'dark' || (theme !== 'light' && window.matchMedia &&
window.matchMedia('(prefers-color-scheme: dark)').matches)) {
params.push('theme=dark');
}
var target = '/logo' + (params.length ? '?' + params.join('&') : '');
// An image element, not fetch: it can follow /logo's redirect to
// a URL logo on another origin (branding BT-26)
var img = new Image();
img.className = 'custom-logo';
img.alt = 'Logo';
img.onload = function () {
while (wrap.firstChild) wrap.removeChild(wrap.firstChild);
wrap.appendChild(img);
wrap.removeAttribute('data-loading');
};
img.onerror = showDefault;
img.src = target;
})();
function finished(title, subtitle) {
hide($('passkey-form'));
setText($('title'), title);
setText($('subtitle'), subtitle);
}
if (!ticket) {
finished('Add a passkey', 'This page is opened by your mail app when you add a passkey.');
showError('Start adding the passkey from your mail app\'s settings.');
return;
}
if (!window.PublicKeyCredential || !navigator.credentials || !navigator.credentials.create) {
finished('Add a passkey', 'This browser can\'t make passkeys.');
showError('Open this page in a browser that supports passkeys, or use another device.');
return;
}
// WebAuthn's binary fields travel as base64url text
function fromB64(s) {
s = s.replace(/-/g, '+').replace(/_/g, '/');
while (s.length % 4) s += '=';
var bin = atob(s), out = new Uint8Array(bin.length);
for (var i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
return out.buffer;
}
function toB64(buf) {
var bytes = new Uint8Array(buf), bin = '';
for (var i = 0; i < bytes.length; i++) bin += String.fromCharCode(bytes[i]);
return btoa(bin).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
}
function post(body) {
return fetch('/api/passkey/register', {
method: 'POST',
credentials: 'omit',
cache: 'no-store',
headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' },
body: JSON.stringify(body)
}).then(function (res) {
if (res.status !== 200) throw new Error('http ' + res.status);
return res.json();
});
}
function expired() {
finished('Add a passkey', 'This link has run out or was already used.');
showError('Start again from your mail app\'s settings.');
}
function create(json) {
var pk = json.options.publicKey;
pk.challenge = fromB64(pk.challenge);
pk.user.id = fromB64(pk.user.id);
(pk.excludeCredentials || []).forEach(function (c) { c.id = fromB64(c.id); });
setText($('subtitle'), 'Follow your browser\'s steps to create the passkey "' + json.name + '".');
return navigator.credentials.create({ publicKey: pk }).then(function (cred) {
var response = {
attestationObject: toB64(cred.response.attestationObject),
clientDataJSON: toB64(cred.response.clientDataJSON)
};
if (cred.response.getTransports) response.transports = cred.response.getTransports();
return post({
step: 'finish',
ticket: ticket,
credential: {
id: cred.id,
rawId: toB64(cred.rawId),
type: cred.type,
response: response,
extensions: cred.getClientExtensionResults ? cred.getClientExtensionResults() : {}
}
});
}, function (err) {
console.log('navigator.credentials.create failed:', err);
throw { cancelled: true, name: err && err.name };
});
}
function getPasskey() {
return fetch('/api/auth/passkey', {
method: 'POST',
credentials: 'omit',
cache: 'no-store',
headers: { 'Accept': 'application/json' }
}).then(function (res) {
if (res.status !== 200) throw new Error('http ' + res.status);
return res.json();
}).then(function (c) {
var pk = c.options.publicKey;
pk.challenge = fromB64(pk.challenge);
(pk.allowCredentials || []).forEach(function (a) { a.id = fromB64(a.id); });
return navigator.credentials.get({ publicKey: pk }).then(function (cred) {
var r = cred.response;
return {
challengeId: c.challengeId,
credential: {
id: cred.id,
rawId: toB64(cred.rawId),
type: cred.type,
response: {
authenticatorData: toB64(r.authenticatorData),
clientDataJSON: toB64(r.clientDataJSON),
signature: toB64(r.signature),
userHandle: r.userHandle ? toB64(r.userHandle) : null
},
extensions: cred.getClientExtensionResults ? cred.getClientExtensionResults() : {}
}
};
});
});
}
function begin(body, viaPasskey) {
var btn = $('submit-btn');
btn.disabled = true;
$('passkey-btn').disabled = true;
return post(body).then(function (json) {
switch (json.type) {
case 'options':
$('account').value = json.accountName;
return create(json).then(function (done) {
if (done.type === 'registered') {
finished('Passkey added', 'You can close this window.');
showSuccess('"' + done.name + '" is ready. Use it the next time you sign in.');
} else if (done.type === 'expired') {
expired();
} else {
finished('Add a passkey', 'The passkey wasn\'t added.');
showError(done.reason || 'Start again from your mail app\'s settings.');
}
});
case 'mfaRequired':
show($('field-otp'));
setText($('subtitle'), 'Enter the 6-digit code from your authenticator app.');
setTimeout(function () { $('otp').focus(); }, 0);
return;
case 'expired':
expired();
return;
default:
if (viaPasskey) {
showError('That passkey isn\'t one of this account\'s. Use your password.');
} else {
showError(!$('field-otp').hidden ? 'The password or code is wrong.' : 'The password is wrong.');
}
$('otp').value = '';
}
}).catch(function (err) {
if (err && err.cancelled) {
// Nothing was used up: Continue asks again
setText($('subtitle'), 'The passkey wasn\'t created.');
showError(err.name === 'InvalidStateError'
? 'This device already has a passkey for your account.'
: 'Choose Continue to try again.');
return;
}
console.log('Passkey registration failed:', err);
showError('Temporary server failure. If the problem persists, contact your administrator.');
}).then(function () {
btn.disabled = false;
$('passkey-btn').disabled = false;
});
}
function submit(e) {
if (e) e.preventDefault();
clearAlert();
var password = $('password').value;
if (!password) { showError('Enter your password.'); return; }
var otp = $('otp').value.trim();
var body = { step: 'start', ticket: ticket, password: password };
if (!$('field-otp').hidden) {
if (!/^\d{6}$/.test(otp)) { showError('Enter the 6-digit code.'); return; }
body.mfaToken = otp;
}
begin(body, false);
}
// PK-8: an active passkey of the account instead of the password
if (navigator.credentials.get) {
show($('passkey-btn'));
$('passkey-btn').addEventListener('click', function () {
clearAlert();
getPasskey().then(function (assertion) {
begin({ step: 'start', ticket: ticket, passkey: assertion }, true);
}, function (err) {
console.log('Passkey sign-in did not finish:', err);
if (!err || (err.name !== 'NotAllowedError' && err.name !== 'AbortError')) {
showError('Passkeys aren\'t available right now. Use your password.');
}
});
});
}
$('passkey-form').addEventListener('submit', submit);
$('otp').addEventListener('input', function () { this.value = this.value.replace(/\D/g, ''); });
setTimeout(function () { $('password').focus(); }, 0);
})();
</script>
</body>
</html>