Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(login): render login screen client-side via bootstrap
Elian Doran925f04c557d6
diff --git a/apps/client/src/index.ts b/apps/client/src/index.tsindex 2de268b354..e2c1ced52d 100644--- a/apps/client/src/index.ts+++ b/apps/client/src/index.ts@@ -142,6 +142,11 @@ async function loadScripts() {return;}+ if (glob.loggedIn === false) {+ await import("./login_page.js");+ return;+ }+switch (glob.device) {case "mobile":await import("./mobile.js");diff --git a/apps/client/src/login.css b/apps/client/src/login.cssnew file mode 100644index 0000000000..d007e9aecc--- /dev/null+++ b/apps/client/src/login.css@@ -0,0 +1,26 @@+/* The login page shares the set-password page's compact-card layout: the setup+ container's own padding is dropped (see set_password.css for why), and the short+ form is centred within the fixed wizard frame. */++/* The password variant wraps the whole page in a <form> so the footer's submit button+ triggers its submit handler; setup.css styles every form at 80% width, which would+ squeeze the page and float the footer. display: contents makes the form layout-+ transparent so the page and its full-bleed footer fill the frame. (SSO has no form.) */+body.setup .setup-container.login-container > form {+ display: contents;+}++body.setup .setup-container.login-container {+ padding: 0;+}++body.setup .page.login > main {+ justify-content: center;+ width: 75%;+ margin: auto;+}++body.setup .page.login .login-sso {+ display: flex;+ justify-content: center;+}diff --git a/apps/client/src/login.ts b/apps/client/src/login.tsdeleted file mode 100644index e707678401..0000000000--- a/apps/client/src/login.ts+++ /dev/null@@ -1,3 +0,0 @@-// @ts-ignore - module = undefined-// Required for correct loading of scripts in Electron-if (typeof module === 'object') {window.module = module; module = undefined;}diff --git a/apps/client/src/login_page.tsx b/apps/client/src/login_page.tsxnew file mode 100644index 0000000000..9dfd35b07c--- /dev/null+++ b/apps/client/src/login_page.tsx@@ -0,0 +1,173 @@+import "./setup.css";+import "./login.css";++import { LOCALE_IDS } from "@triliumnext/commons";+import { render } from "preact";+import { useRef, useState } from "preact/hooks";++import logo from "./assets/icon-color.svg?url";+import { initLocale, t } from "./services/i18n";+import Button from "./widgets/react/Button";+import { Card, CardSection } from "./widgets/react/Card";+import FormCheckbox from "./widgets/react/FormCheckbox";+import FormGroup from "./widgets/react/FormGroup";+import FormTextBox from "./widgets/react/FormTextBox";+import SetupPage from "./widgets/react/SetupPage";++async function main() {+ await initLocale((window.glob.currentLocale?.id ?? "en") as LOCALE_IDS);++ const bodyWrapper = document.createElement("div");+ bodyWrapper.classList.add("setup-outer-wrapper");+ // The device/theme body classes are already applied by index.ts (this page is+ // loaded through the regular bootstrap); we only add the setup styling hook.+ document.body.classList.add("setup");+ render(<App />, bodyWrapper);+ document.body.replaceChildren(bodyWrapper);+}++function App() {+ const config = window.glob.login;+ const illustration = <img src={logo} alt="" className="illustration-logo" />;++ const [ error, setError ] = useState<string | null>(ssoErrorMessage(config?.ssoError));+ const [ errorId, setErrorId ] = useState(0);++ function raiseError(message: string) {+ setError(message);+ setErrorId((id) => id + 1);+ }++ if (config?.ssoEnabled) {+ return (+ <div class="setup-container login-container">+ <SetupPage className="login" title={t("login.heading")} illustration={illustration} error={error} errorId={errorId}>+ <Card>+ <CardSection className="login-sso">+ {/* Server route that initiates the OpenID round-trip. */}+ <a href="/authenticate" class="google-login-btn">+ {config.ssoIssuerIcon+ ? <img src={config.ssoIssuerIcon} alt="" onError={(e) => (e.currentTarget as HTMLImageElement).remove()} />+ : null}+ {t("login.sign_in_with_sso", { ssoIssuerName: config.ssoIssuerName ?? "" })}+ </a>+ </CardSection>+ </Card>+ </SetupPage>+ </div>+ );+ }++ return (+ <div class="setup-container login-container">+ <PasswordLogin+ illustration={illustration}+ totpEnabled={config?.totpEnabled ?? false}+ error={error}+ errorId={errorId}+ onError={raiseError}+ />+ </div>+ );+}++function PasswordLogin({ illustration, totpEnabled, error, errorId, onError }: {+ illustration: preact.ComponentChildren;+ totpEnabled: boolean;+ error: string | null;+ errorId: number;+ onError: (message: string) => void;+}) {+ const passwordRef = useRef<HTMLInputElement>(null);+ const [ password, setPassword ] = useState("");+ const [ totpToken, setTotpToken ] = useState("");+ const [ rememberMe, setRememberMe ] = useState(false);+ const [ submitting, setSubmitting ] = useState(false);++ async function handleSubmit(e: Event) {+ e.preventDefault();+ if (submitting) {+ return;+ }+ setSubmitting(true);+ try {+ const body = new URLSearchParams({ password });+ if (totpEnabled) {+ body.set("totpToken", totpToken);+ }+ if (rememberMe) {+ body.set("rememberMe", "1");+ }++ const resp = await fetch("login", {+ method: "POST",+ headers: { "Content-Type": "application/x-www-form-urlencoded" },+ body+ });++ if (resp.ok) {+ // Session established — navigate to the app.+ window.location.assign(".");+ return;+ }++ const factor = resp.status === 401 ? (await resp.json().catch(() => ({}))).factor : undefined;+ onError(factor === "totp" ? t("login.incorrect-totp") : t("login.incorrect-password"));+ } catch {+ onError(t("login.incorrect-password"));+ } finally {+ setSubmitting(false);+ }+ }++ return (+ <form onSubmit={(e) => void handleSubmit(e)}>+ <SetupPage+ className="login"+ title={t("login.heading")}+ illustration={illustration}+ error={error}+ errorId={errorId}+ footer={<Button text={t("login.button")} kind="primary" disabled={submitting} />}+ >+ <Card>+ <CardSection>+ <FormGroup label={t("login.password")} name="password">+ <FormTextBox+ inputRef={passwordRef} autoFocus+ type="password" name="password"+ currentValue={password} onChange={setPassword}+ autocomplete="current-password" required+ />+ </FormGroup>+ </CardSection>++ {totpEnabled && (+ <CardSection>+ <FormGroup label={t("login.totp-token")} name="totpToken">+ <FormTextBox+ name="totpToken"+ currentValue={totpToken} onChange={setTotpToken}+ autocomplete="one-time-code" required+ />+ </FormGroup>+ </CardSection>+ )}++ <CardSection>+ <FormCheckbox name="rememberMe" label={t("login.remember-me")} currentValue={rememberMe} onChange={setRememberMe} />+ </CardSection>+ </Card>+ </SetupPage>+ </form>+ );+}++function ssoErrorMessage(ssoError: string | false | undefined): string | null {+ if (!ssoError) {+ return null;+ }+ return ssoError === "wrong_account" ? t("login.sso-wrong-account") : t("login.sso-not-enrolled");+}++main();diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 7982877fff..6bd4cb1e59 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2849,6 +2849,18 @@"sample_treeview": "TreeView","sample_wardley": "Wardley Map"},+ "login": {+ "heading": "Trilium Login",+ "password": "Password",+ "totp-token": "TOTP token",+ "button": "Login",+ "remember-me": "Remember me",+ "incorrect-password": "Password is incorrect. Please try again.",+ "incorrect-totp": "TOTP is incorrect. Please try again.",+ "sign_in_with_sso": "Sign in with {{ssoIssuerName}}",+ "sso-wrong-account": "That account isn't the one linked to this Trilium instance. Sign in with the linked account.",+ "sso-not-enrolled": "Single sign-on isn't set up yet. Sign in with your password first, then link your account from the settings."+ },"set_password": {"heading": "Set password","description": "Before you can start using Trilium from web, you need to set a password first. You will then use this password to login.",diff --git a/apps/client/vite.config.mts b/apps/client/vite.config.mtsindex 885ad96c20..c2dd6445f1 100644--- a/apps/client/vite.config.mts+++ b/apps/client/vite.config.mts@@ -97,7 +97,6 @@ export default defineConfig(() => ({rollupOptions: {input: {index: join(__dirname, "index.html"),- login: join(__dirname, "src", "login.ts"),runtime: join(__dirname, "src", "runtime.ts"),print: join(__dirname, "src", "print.tsx")},diff --git a/apps/server/src/assets/views/login.ejs b/apps/server/src/assets/views/login.ejsdeleted file mode 100644index ffd80c0cbd..0000000000--- a/apps/server/src/assets/views/login.ejs+++ /dev/null@@ -1,89 +0,0 @@-<!DOCTYPE html>-<html lang="en">-<head>- <meta charset="utf-8">- <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">- <title><%= t("login.title") %></title>- <link rel="apple-touch-icon" sizes="180x180" href="<%= assetPath %>/images/app-icons/ios/apple-touch-icon.png">- <link rel="shortcut icon" href="favicon.ico">- <style>- body {- /* Prevent the content from being rendered before the main stylesheet loads */- display: none;- }- </style>- <link rel="stylesheet" href="<%= assetPath %>/stylesheets/theme-next-light.css" media="(prefers-color-scheme: light)">- <link rel="stylesheet" href="<%= assetPath %>/stylesheets/theme-next-dark.css" media="(prefers-color-scheme: dark)">- <link rel="stylesheet" href="<%= assetPath %>/stylesheets/style.css">- <script src="<%= appPath %>/runtime.js" crossorigin type="module"></script>-</head>-<body lang="<%= currentLocale.id %>" dir="<%= currentLocale.rtl ? 'rtl' : 'ltr' %>">-<div class="container login-page">- <div class="col-xs-12 col-sm-10 col-md-6 col-lg-4 col-xl-4 mx-auto pt-4">- <img class="img-fluid d-block mx-auto" style="height: 8rem;" src="<%= assetPathFragment %>/images/icon-color.svg" aria-hidden="true" draggable="false" >- <h1 class="text-center"><%= t("login.heading") %></h1>-- <% if ( ssoError ) { %>- <div class="alert alert-warning">- <%= ssoError === "wrong_account" ? t("login.sso-wrong-account") : t("login.sso-not-enrolled") %>- </div>- <% } %>-- <% if (ssoEnabled) { %>- <a href="/authenticate" class="google-login-btn">- <% if (ssoIssuerIcon.length > 0) { %>- <img src="<%= ssoIssuerIcon %>" alt="<%= ssoIssuerName %>" onerror="this.remove()">- <% } %>- <%= t("login.sign_in_with_sso", { ssoIssuerName: ssoIssuerName }) %>- </a>- <% } else { %>- <form action="login" method="POST">- <div class="form-group">- <label for="password"><%= t("login.password") %></label>- <div class="controls">- <input id="password" name="password" placeholder="" class="form-control" type="password" autocomplete="current-password" autofocus>- </div>- </div>- <% if( totpEnabled ) { %>- <div class="form-group">- <label for="totpToken">TOTP Token</label>- <div class="controls">- <input id="totpToken" name="totpToken" placeholder="" class="form-control" type="text" autocomplete="one-time-code" required />- </div>- </div>- <% } %>-- <% if ( wrongPassword ) { %>- <div class="alert alert-warning">- <%= t("login.incorrect-password") %>- </div>- <% } %>- <% if ( totpEnabled ) { %>- <% if( wrongTotp ) { %>- <div class="alert alert-warning">- <%= t("login.incorrect-totp") %>- </div>- <% } %>- <% } %>--- <div class="form-group">- <div class="checkbox">- <label class="tn-checkbox">- <input id="remember-me" name="rememberMe" value="1" type="checkbox">- <%= t("login.remember-me") %>- </label>- </div>- </div>- <div class="form-group">- <button class="btn btn-success"><%= t("login.button") %></button>- </div>- </form>- <% } %>- </div>-</div>--<script src="<%= appPath %>/login.js" crossorigin type="module"></script>--</body>-</html>diff --git a/apps/server/src/routes/index.ts b/apps/server/src/routes/index.tsindex 8719083ae2..e4b51d9834 100644--- a/apps/server/src/routes/index.ts+++ b/apps/server/src/routes/index.ts@@ -8,7 +8,9 @@ import assetPath from "../services/asset_path.js";import config from "../services/config.js";import { getLog } from "@triliumnext/core";import port from "../services/port.js";+import openID from "../services/open_id.js";import { isDev, isElectron, isMac, isWindows11 } from "../services/utils.js";+import totp from "../services/totp.js";import { generateCsrfToken } from "./csrf_protection.js";type View = "desktop" | "mobile" | "print";@@ -25,6 +27,9 @@ export function bootstrap(req: Request, res: Response) {const view = getView(req);const isDbInitialized = sql_init.isDbInitialized();+ // When auth is disabled the user is implicitly authenticated, so the set-password+ // and login pre-auth screens never apply — fall through to the full payload.+ const noAuthentication = config.General?.noAuthentication === true;const commonItems = {...getSharedBootstrapItems(assetPath, isDbInitialized),baseApiUrl: "api/",@@ -56,7 +61,7 @@ export function bootstrap(req: Request, res: Response) {return;}- if (!isElectron && !passwordService.isPasswordSet()) {+ if (!isElectron && !noAuthentication && !passwordService.isPasswordSet()) {// Pre-auth window: the DB is initialized but no password has been set yet.// This screen is web/server-only — the desktop app manages its protected-notes// password through the options UI and never gates the app on it — so we exclude@@ -75,6 +80,35 @@ export function bootstrap(req: Request, res: Response) {return;}+ if (!isElectron && !noAuthentication && !req.session.loggedIn) {+ // Pre-auth window: a password is set but the user hasn't logged in. Web/server+ // only — the desktop app doesn't gate on a web session. Serve a minimal payload+ // (no CSRF token / session data) carrying `loggedIn: false` plus the login-screen+ // config, which the client uses to render the login screen. The one-shot SSO error+ // left by a failed OIDC round-trip is read and cleared here (previously done by the+ // login page).+ const ssoError = req.session.ssoError;+ if (ssoError) {+ delete req.session.ssoError;+ }+ res.send({+ ...commonItems,+ loggedIn: false,+ login: {+ ssoEnabled: openID.isOpenIDEnabled(),+ ssoIssuerName: openID.getSSOIssuerName(),+ ssoIssuerIcon: openID.getSSOIssuerIcon(),+ totpEnabled: totp.isTotpEnabled(),+ ssoError+ },+ platform: process.platform,+ hasNativeTitleBar: false,+ hasBackgroundEffects: false,+ isMainWindow: true+ } satisfies BootstrapDefinition);+ return;+ }+const csrfToken = generateCsrfToken(req, res, {overwrite: false,@@ -97,6 +131,7 @@ export function bootstrap(req: Request, res: Response) {...commonItems,dbInitialized: true,passwordSet: true,+ loggedIn: true,csrfToken,oauthJustEnrolled,platform: process.platform,diff --git a/apps/server/src/routes/login.spec.ts b/apps/server/src/routes/login.spec.tsindex f7555a2017..3aa8fdfd75 100644--- a/apps/server/src/routes/login.spec.ts+++ b/apps/server/src/routes/login.spec.ts@@ -24,15 +24,12 @@ describe("Login Route test", () => {vi.useRealTimers();});- it("should return the login page, when using a GET request", async () => {-- // RegExp for login page specific string in HTML+ it("redirects GET /login to the SPA root, since login is served client-side", async () => {const res = await supertest(app).get("/login")- .expect(200);-- expect(res.text).toMatch(/assets\/v[0-9.a-z]+\/src\/login\.js/);+ .expect(302);+ expect(res.headers.location).toBe(".");});it("returns a 401 status, when login fails with wrong password", async () => {diff --git a/apps/server/src/routes/login.ts b/apps/server/src/routes/login.tsindex f57e0e1574..024fe4c253 100644--- a/apps/server/src/routes/login.ts+++ b/apps/server/src/routes/login.ts@@ -1,8 +1,6 @@-import { i18n, password as passwordService, ValidationError } from "@triliumnext/core";+import { password as passwordService, ValidationError } from "@triliumnext/core";import type { Request, Response } from 'express';-import appPath from "../services/app_path.js";-import assetPath, { assetUrlFragment } from "../services/asset_path.js";import { verifyLoginCredentials } from "../services/auth.js";import openIDEncryption from '../services/encryption/open_id_encryption.js';import { getLog } from "@triliumnext/core";@@ -10,27 +8,10 @@ import openID from '../services/open_id.js';import totp from '../services/totp.js';function loginPage(req: Request, res: Response) {- // Login page is triggered twice. Once here, and another time (see sendLoginError) if the password is failed.- // A failed SSO round-trip (wrong account / not yet enrolled) leaves a one-shot reason on the session in- // the OIDC afterCallback; read and clear it so the message shows exactly once.- const ssoError = req.session.ssoError;- if (ssoError) {- delete req.session.ssoError;- }-- res.render('login', {- wrongPassword: false,- wrongTotp: false,- ssoError,- totpEnabled: totp.isTotpEnabled(),- ssoEnabled: openID.isOpenIDEnabled(),- ssoIssuerName: openID.getSSOIssuerName(),- ssoIssuerIcon: openID.getSSOIssuerIcon(),- assetPath,- assetPathFragment: assetUrlFragment,- appPath,- currentLocale: i18n.getCurrentLocale()- });+ // The login screen is served by the SPA at the root now (driven by the bootstrap+ // `loggedIn: false` payload, which also surfaces any one-shot SSO error left by a+ // failed OIDC round-trip); redirect any direct hits there.+ res.redirect(".");}function setPasswordPage(req: Request, res: Response) {@@ -122,6 +103,9 @@ async function login(req: Request, res: Response) {};req.session.loggedIn = true;+ // The client submits via fetch (following this redirect, which applies the new+ // session cookie) and then navigates to the app. The 302 also keeps the login+ // rate limiter skipping successful attempts (it only counts >= 400 responses).res.redirect('.');});}@@ -134,19 +118,9 @@ function sendLoginError(req: Request, res: Response, errorType: 'password' | 'togetLog().info(`WARNING: Wrong password from ${req.ip}, rejecting.`);}- res.status(401).render('login', {- wrongPassword: errorType === 'password',- wrongTotp: errorType === 'totp',- ssoError: false,- totpEnabled: totp.isTotpEnabled(),- ssoEnabled: openID.isOpenIDEnabled(),- ssoIssuerName: openID.getSSOIssuerName(),- ssoIssuerIcon: openID.getSSOIssuerIcon(),- assetPath,- assetPathFragment: assetUrlFragment,- appPath,- currentLocale: i18n.getCurrentLocale()- });+ // The client submits via fetch; report the failed factor as JSON. The 401 keeps the+ // login rate limiter counting failed attempts (it skips successful, <400 responses).+ res.status(401).json({ success: false, factor: errorType });}function logout(req: Request, res: Response) {diff --git a/apps/server/src/services/auth.spec.ts b/apps/server/src/services/auth.spec.tsindex ec61af9011..9f3670388f 100644--- a/apps/server/src/services/auth.spec.ts+++ b/apps/server/src/services/auth.spec.ts@@ -27,27 +27,24 @@ describe("Auth", () => {refreshAuth();});- it("goes to login and asks for TOTP if enabled", async () => {+ it("bootstrap login payload asks for TOTP when enabled", async () => {cls.init(() => {options.setOption("mfaMethod", "totp");options.setOption("totpVerificationHash", "hi");});- const response = await supertest(app)- .get("/")- .redirects(1)- .expect(200);- expect(response.text).toContain(`id="totpToken"`);+ // The login screen is rendered client-side now; the server reports the TOTP+ // requirement through the (unauthenticated) bootstrap payload.+ const response = await supertest(app).get("/bootstrap").expect(200);+ expect(response.body.loggedIn).toBe(false);+ expect(response.body.login?.totpEnabled).toBe(true);});- it("goes to login and doesn't ask for TOTP is disabled", async () => {+ it("bootstrap login payload doesn't ask for TOTP when disabled", async () => {cls.init(() => {options.setOption("totpVerificationHash", "");});- const response = await supertest(app)- .get("/")- .redirects(1)- .expect(200);- expect(response.text).not.toContain(`id="totpToken"`);+ const response = await supertest(app).get("/bootstrap").expect(200);+ expect(response.body.login?.totpEnabled).toBe(false);});});@@ -146,25 +143,30 @@ describe("Auth", () => {expect(next).toHaveBeenCalled();});- it("checkAuth redirects to login when not logged in (no bare-domain redirect)", () => {+ it("checkAuth serves the SPA (next) when not logged in (no bare-domain redirect)", () => {vi.spyOn(totp, "isTotpEnabled").mockReturnValue(false);vi.spyOn(openID, "isOpenIDEnabled").mockReturnValue(false);cls.init(() => options.setOption("redirectBareDomain", "false"));const res = makeRes();- auth.checkAuth(makeReq({ session: { loggedIn: false } }), res as never, vi.fn());- expect(res.redirectedTo).toBe("login");+ const next = vi.fn();+ // The login screen is served by the SPA now, so checkAuth falls through.+ auth.checkAuth(makeReq({ session: { loggedIn: false } }), res as never, next);+ expect(next).toHaveBeenCalled();+ expect(res.redirectedTo).toBeUndefined();});- it("checkAuth honours redirectBareDomain: redirects to share when a shareRoot exists, else to login", () => {+ it("checkAuth honours redirectBareDomain: redirects to share when a shareRoot exists, else serves the SPA", () => {vi.spyOn(totp, "isTotpEnabled").mockReturnValue(false);vi.spyOn(openID, "isOpenIDEnabled").mockReturnValue(false);cls.init(() => options.setOption("redirectBareDomain", "true"));- // No shareRoot configured: fall back to login instead of a 404 dead-end (#7869).+ // No shareRoot configured: fall through to the SPA login screen instead of a+ // 404 dead-end (#7869).const labelSpy = vi.spyOn(attributes, "getNotesWithLabel").mockReturnValue([]);const resLogin = makeRes();- auth.checkAuth(makeReq({ session: { loggedIn: false } }), resLogin as never, vi.fn());- expect(resLogin.redirectedTo).toBe("login");+ const nextLogin = vi.fn();+ auth.checkAuth(makeReq({ session: { loggedIn: false } }), resLogin as never, nextLogin);+ expect(nextLogin).toHaveBeenCalled();expect(resLogin.statusCode).not.toBe(404);labelSpy.mockReturnValue([{ noteId: "x" } as never]);@@ -309,7 +311,8 @@ describe("Auth", () => {const unsetSpy = vi.spyOn(passwordService, "isPasswordSet").mockReturnValue(false);const resSet = makeRes();auth.checkPasswordSet(makeReq(), resSet as never, vi.fn());- expect(resSet.redirectedTo).toBe("set-password");+ // The set-password screen is now served by the SPA at the root.+ expect(resSet.redirectedTo).toBe(".");const nextNotSet = vi.fn();auth.checkPasswordNotSet(makeReq(), makeRes() as never, nextNotSet);diff --git a/apps/server/src/services/auth.ts b/apps/server/src/services/auth.tsindex 035ad0f802..0fba755422 100644--- a/apps/server/src/services/auth.ts+++ b/apps/server/src/services/auth.ts@@ -47,14 +47,16 @@ function checkAuth(req: Request, res: Response, next: NextFunction) {if (hasRedirectBareDomain) {// Only redirect to the share page when a share root is actually configured.// Otherwise (e.g. the owner's session expired before they set one up) fall back- // to the login page rather than stranding the user on a 404. See #7869.+ // to the login screen rather than stranding the user on a 404. See #7869.const shareRootNotes = attributes.getNotesWithLabel("shareRoot");if (shareRootNotes.length > 0) {res.redirect("share");return;}}- res.redirect("login");+ // Otherwise serve the SPA, which renders the login screen from the bootstrap+ // `loggedIn: false` payload. The API stays protected separately via checkApiAuth.+ return next();} else if (currentTotpStatus !== lastAuthState.totpEnabled || currentSsoStatus !== lastAuthState.ssoEnabled) {req.session.destroy((err) => {if (err) console.error('Error destroying session:', err);diff --git a/packages/commons/src/lib/server_api.ts b/packages/commons/src/lib/server_api.tsindex 786e0805ab..169a0c8d9f 100644--- a/packages/commons/src/lib/server_api.ts+++ b/packages/commons/src/lib/server_api.ts@@ -393,6 +393,24 @@ export type BootstrapDefinition = {* as set) for the regular authenticated payload.*/passwordSet?: boolean;+ /**+ * Whether the current session is authenticated. `false` only in the pre-auth+ * window when a password is set but the user hasn't logged in (web/server only),+ * which the client uses to render the login screen. Omitted (treated as logged+ * in) for the regular authenticated payload.+ */+ loggedIn?: boolean;+ /** Login-screen configuration, present only alongside `loggedIn: false`. */+ login?: {+ /** Whether single sign-on (OpenID) is enabled — shows the SSO button instead of the password form. */+ ssoEnabled: boolean;+ ssoIssuerName?: string;+ ssoIssuerIcon?: string;+ /** Whether a TOTP second factor is required. */+ totpEnabled: boolean;+ /** One-shot SSO error from a failed OIDC round-trip ("wrong_account" / "not_enrolled"). */+ ssoError?: string | false;+ };baseApiUrl: string;assetPath: string;theme: string;