refactor: move away from the tuple pattern

This commit is contained in:
Derrick Hammer 2023-09-07 19:29:33 -04:00
parent 2300b07419
commit a8f2eb666b
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 3 additions and 8 deletions

View File

@ -15,5 +15,3 @@ function addContextToErr(err: any, context: string): string {
}
export { addContextToErr };
export const NO_PORTALS_ERROR = [null, "no active portals"] as ErrTuple;

View File

@ -1,10 +1,9 @@
import { ErrTuple, KeyPair, Portal } from "#types.js";
import { KeyPair, Portal } from "#types.js";
import { Client } from "@lumeweb/libportal";
import { deriveChildKey } from "#keys.js";
import { ed25519 } from "@noble/curves/ed25519";
import { bytesToHex } from "@noble/hashes/utils";
import COMMUNITY_PORTAL_LIST from "@lumeweb/community-portals";
import { NO_PORTALS_ERROR } from "#err.js";
let activePortalMasterKey;
@ -17,9 +16,9 @@ type PortalSessionsStore = { [id: string]: string };
const PORTAL_ID = Symbol.for("PORTAL_ID");
const PORTAL_NAME = Symbol.for("PORTAL_NAME");
export function maybeInitDefaultPortals(): ErrTuple {
export function maybeInitDefaultPortals() {
if (!activePortalMasterKey) {
return [null, "activePortalMasterKey not set"];
throw new Error("activePortalMasterKey not set");
}
let portalsToLoad = DEFAULT_PORTAL_LIST;
@ -33,8 +32,6 @@ export function maybeInitDefaultPortals(): ErrTuple {
for (const portal of portalsToLoad) {
addActivePortal(initPortal(portal));
}
return [null, null];
}
export function setActivePortalMasterKey(key: Uint8Array) {