Implement approved specification #32 and tickets #33-#37. Keep host authentication server-verified and pin session interaction language. Compile scoped base selectors for browser compatibility and retain full gutters during CSS pruning.
19 lines
707 B
TypeScript
19 lines
707 B
TypeScript
import type { AuthenticatedUser } from "../../api/types";
|
|
|
|
type Principal = Pick<AuthenticatedUser, "issuer" | "subject">;
|
|
|
|
function key(user: Principal) {
|
|
return `thothii:selected-session:${JSON.stringify([window.location.pathname, user.issuer, user.subject])}`;
|
|
}
|
|
|
|
export function readRememberedSession(user: Principal): string | null {
|
|
try { return sessionStorage.getItem(key(user)); } catch { return null; }
|
|
}
|
|
|
|
export function rememberSession(user: Principal, sessionId: string | null): void {
|
|
try {
|
|
if (sessionId) sessionStorage.setItem(key(user), sessionId);
|
|
else sessionStorage.removeItem(key(user));
|
|
} catch { /* Reload continuity is optional when browser storage is blocked. */ }
|
|
}
|