feat: add loginActivePortals function

This commit is contained in:
Derrick Hammer 2023-08-15 04:30:09 -04:00
parent 872fab5455
commit a1b67e71cd
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 19 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import { deriveChildKey } from "#keys.js";
import { ed25519 } from "@noble/curves/ed25519"; import { ed25519 } from "@noble/curves/ed25519";
import { bytesToHex } from "@noble/hashes/utils"; import { bytesToHex } from "@noble/hashes/utils";
import COMMUNITY_PORTAL_LIST from "@lumeweb/community-portals"; import COMMUNITY_PORTAL_LIST from "@lumeweb/community-portals";
import { NO_PORTALS_ERROR } from "#err.js";
let activePortalMasterKey; let activePortalMasterKey;
@ -138,3 +139,21 @@ export function loadSavedPortals(): Portal[] | null {
return JSON.parse(portals); return JSON.parse(portals);
} }
export async function loginActivePortals() {
const activePortals = getActivePortals();
if (!activePortals.length) {
return;
}
for (const portal of activePortals) {
if (!(await portal.isLoggedIn())) {
try {
await portal.register();
} catch {}
await portal.login();
}
}
}