feat(client): fix square QR layout and add dynamic multi-auth, strictness presets, and backup UI
This commit is contained in:
parent
4915bce1e4
commit
90a8bf8553
8 changed files with 683 additions and 96 deletions
|
|
@ -12,6 +12,8 @@ import {
|
|||
THEME_STORAGE_KEY,
|
||||
applyTheme,
|
||||
initialDeviceSafeMode,
|
||||
type ClientAuthRequirements,
|
||||
type ClientSecuritySettings,
|
||||
type ClientState,
|
||||
type ConfigOverview,
|
||||
type RouteId,
|
||||
|
|
@ -87,10 +89,13 @@ function updateTopBarUi(): void {
|
|||
|
||||
themeSelect.value = state.theme;
|
||||
|
||||
if (state.elevatedUntil && state.elevatedUntil > Date.now()) {
|
||||
if (state.security?.stepUpPolicy === 'off') {
|
||||
stepupBadge.hidden = false;
|
||||
stepupBadge.textContent = '[STEP-UP: OFF]';
|
||||
} else if (state.elevatedUntil && state.elevatedUntil > Date.now()) {
|
||||
const remSec = Math.ceil((state.elevatedUntil - Date.now()) / 1000);
|
||||
stepupBadge.hidden = false;
|
||||
stepupBadge.textContent = `[2FA: ${remSec}s]`;
|
||||
stepupBadge.textContent = remSec > 86400 ? '[ELEVATED: SESSION]' : `[2FA: ${remSec}s]`;
|
||||
} else {
|
||||
state.elevatedUntil = null;
|
||||
stepupBadge.hidden = true;
|
||||
|
|
@ -122,9 +127,15 @@ async function renderCurrentView(): Promise<void> {
|
|||
updateTopBarUi();
|
||||
|
||||
if (!state.authenticated) {
|
||||
await renderAuthView(root, state.bootstrapped, state.safeMode, async () => {
|
||||
await bootstrapApp();
|
||||
});
|
||||
await renderAuthView(
|
||||
root,
|
||||
state.bootstrapped,
|
||||
state.safeMode,
|
||||
state.authRequirements,
|
||||
async () => {
|
||||
await bootstrapApp();
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -210,6 +221,8 @@ async function syncStatusAndRender(): Promise<void> {
|
|||
isPanicLocked?: boolean;
|
||||
defaultMobileSafeMode: boolean;
|
||||
theme: string;
|
||||
security?: ClientSecuritySettings;
|
||||
authRequirements?: ClientAuthRequirements;
|
||||
}>('/api/auth/status');
|
||||
|
||||
state.bootstrapped = status.bootstrapped;
|
||||
|
|
@ -218,6 +231,8 @@ async function syncStatusAndRender(): Promise<void> {
|
|||
state.isPanicLocked = Boolean(status.isPanicLocked);
|
||||
state.defaultMobileSafeMode = status.defaultMobileSafeMode;
|
||||
state.elevatedUntil = status.elevatedUntil ?? null;
|
||||
state.security = status.security;
|
||||
state.authRequirements = status.authRequirements;
|
||||
|
||||
if (!localStorage.getItem(THEME_STORAGE_KEY)) {
|
||||
state.theme = status.theme;
|
||||
|
|
@ -255,10 +270,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||
applyTheme(state.theme);
|
||||
|
||||
registerStepUpHandler(() =>
|
||||
promptStepUp((until) => {
|
||||
state.elevatedUntil = until;
|
||||
updateTopBarUi();
|
||||
}),
|
||||
promptStepUp(
|
||||
() => state.authRequirements,
|
||||
(until) => {
|
||||
state.elevatedUntil = until;
|
||||
updateTopBarUi();
|
||||
},
|
||||
),
|
||||
);
|
||||
registerUnauthorizedHandler(() => {
|
||||
handleLocalSessionReset(false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue