From 89d24393e5ec8c3d0846b00bec2912dd177e34a8 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 23 Jun 2023 19:30:48 -0400 Subject: [PATCH] fix: refactor initPortal to return the instance --- src/portal.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/portal.ts b/src/portal.ts index 308917e..aa411c9 100644 --- a/src/portal.ts +++ b/src/portal.ts @@ -20,7 +20,7 @@ export function maybeInitDefaultPortals(): ErrTuple { } for (const portal of DEFAULT_PORTAL_LIST) { - initPortal(portal); + addActivePortal(initPortal(portal)); } return [null, null]; @@ -58,7 +58,7 @@ export function addActivePortal(portal: Client) { ACTIVE_PORTALS.add(portal); } -export function initPortal(portal: Portal) { +export function initPortal(portal: Portal): Client { const sessions = getPortalSessions(); let jwt: string | null = null; if (sessions) { @@ -67,14 +67,12 @@ export function initPortal(portal: Portal) { } } - const client = new Client({ + return new Client({ email: generatePortalEmail(portal), portalUrl: portal.url, privateKey: generatePortalKeyPair(portal).privateKey, jwt: jwt as string, }); - - addActivePortal(client); } export function getPortalSessions() {