// enforce-session-timeouts: the limits a session policy value must meet, shared by the Login Security tab and its BFF // route (services-system checks the same rules). 60 s: the portals check in once a minute. 43,200 s (12 h): // services-auth never renews a token past that (jwt.refresh.absolute-max-seconds). export const SESSION_TTL_MIN_SECONDS = 60; export const SESSION_TTL_MAX_SECONDS = 43200; /** The idle limit stops at the 1 h token lifetime: a token can only be renewed while a portal page is open. */ export const SESSION_IDLE_MAX_SECONDS = 3600; /** Message codes for a refused pair. */ export type SessionPairError = "LoginSecuritySessionRange" | "LoginSecuritySessionIdleOverCap"; const inRange = (v: unknown, max: number): v is number => typeof v === "number" && Number.isInteger(v) && v >= SESSION_TTL_MIN_SECONDS && v <= max; /** Null when the idle limit (60..3,600) and cap (60..43,200) are whole seconds and the idle limit is not above the cap. */ export function checkSessionPair(idle: unknown, cap: unknown): SessionPairError | null { if (!inRange(idle, SESSION_IDLE_MAX_SECONDS) || !inRange(cap, SESSION_TTL_MAX_SECONDS)) return "LoginSecuritySessionRange"; return idle > cap ? "LoginSecuritySessionIdleOverCap" : null; } /** A form value as whole seconds, or NaN for blank or non-numeric input. */ export function toSeconds(value: string): number { return value.trim() === "" ? NaN : Number(value); }