From 2bc233c6b4a8abf5895014a4b8bc819113d763b5 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 19 Oct 2023 17:04:15 -0400 Subject: [PATCH] feat: add savePortalSessions function --- src/portal.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/portal.ts b/src/portal.ts index dfbdb8c..1addbe9 100644 --- a/src/portal.ts +++ b/src/portal.ts @@ -121,6 +121,24 @@ export function savePortals() { } } +export function savePortalSessions() { + const portalSessions = {}; + + for (const portal of ACTIVE_PORTALS) { + const jwt = portal.jwt; + if (jwt) { + portalSessions[portal[PORTAL_ID]] = jwt; + } + } + + if (typeof globalThis.localStorage !== "undefined") { + globalThis.localStorage.setItem( + "portal_sessions", + JSON.stringify(portalSessions), + ); + } +} + export function loadSavedPortals(): Portal[] | null { let portals: string | null = null;