// The emailed invitation link, kept for this browser session until a signed-in dashboard asks about it. const TOKEN_KEY = "akashic.clinicianInvitationToken"; // The link last accepted in this session. Signing in after accepting re-renders the landing as signed in, // and that branch would otherwise keep the link for the dashboard to ask about again. const ANSWERED_KEY = "akashic.clinicianInvitationAnswered"; export const readInvitationToken = (): string | null => { try { return sessionStorage.getItem(TOKEN_KEY); } catch { return null; } }; export const forgetInvitationToken = () => { try { sessionStorage.removeItem(TOKEN_KEY); } catch { // Nothing kept, nothing to forget. } }; /** Accepted here: forgotten, and never kept again in this session. */ export const answerInvitationToken = (token: string) => { try { sessionStorage.setItem(ANSWERED_KEY, token); } catch { // Without storage nothing was kept either. } forgetInvitationToken(); }; export const rememberInvitationToken = (token: string) => { try { if (sessionStorage.getItem(ANSWERED_KEY) === token) return; sessionStorage.setItem(TOKEN_KEY, token); } catch { // Private browsing may refuse storage; the person can open the link again once signed in. } };