Backend modules from tastefully 8bd93d15: core-libs, core-session, api-gateway, mobile-api, services-auth, services-system, services-counter, services-member, services-log, services-email. solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal from tastefully 8bd93d15. Copied as tracked files only. Literal secrets replaced with environment placeholders: - services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY, MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default) - services-system: JUMIO_TOKEN, JUMIO_SECRET (optional) - services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed - core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default removed, ipgeolocation key read from IPGEOLOCATION_API_KEY - services-system EkycAppConfig: commented Jumio credentials removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
25 lines
1.4 KiB
TypeScript
25 lines
1.4 KiB
TypeScript
// 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);
|
|
}
|