refactor: move away from the tuple pattern
This commit is contained in:
parent
2300b07419
commit
a8f2eb666b
|
@ -15,5 +15,3 @@ function addContextToErr(err: any, context: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export { addContextToErr };
|
export { addContextToErr };
|
||||||
|
|
||||||
export const NO_PORTALS_ERROR = [null, "no active portals"] as ErrTuple;
|
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { ErrTuple, KeyPair, Portal } from "#types.js";
|
import { KeyPair, Portal } from "#types.js";
|
||||||
import { Client } from "@lumeweb/libportal";
|
import { Client } from "@lumeweb/libportal";
|
||||||
import { deriveChildKey } from "#keys.js";
|
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;
|
||||||
|
|
||||||
|
@ -17,9 +16,9 @@ type PortalSessionsStore = { [id: string]: string };
|
||||||
const PORTAL_ID = Symbol.for("PORTAL_ID");
|
const PORTAL_ID = Symbol.for("PORTAL_ID");
|
||||||
const PORTAL_NAME = Symbol.for("PORTAL_NAME");
|
const PORTAL_NAME = Symbol.for("PORTAL_NAME");
|
||||||
|
|
||||||
export function maybeInitDefaultPortals(): ErrTuple {
|
export function maybeInitDefaultPortals() {
|
||||||
if (!activePortalMasterKey) {
|
if (!activePortalMasterKey) {
|
||||||
return [null, "activePortalMasterKey not set"];
|
throw new Error("activePortalMasterKey not set");
|
||||||
}
|
}
|
||||||
|
|
||||||
let portalsToLoad = DEFAULT_PORTAL_LIST;
|
let portalsToLoad = DEFAULT_PORTAL_LIST;
|
||||||
|
@ -33,8 +32,6 @@ export function maybeInitDefaultPortals(): ErrTuple {
|
||||||
for (const portal of portalsToLoad) {
|
for (const portal of portalsToLoad) {
|
||||||
addActivePortal(initPortal(portal));
|
addActivePortal(initPortal(portal));
|
||||||
}
|
}
|
||||||
|
|
||||||
return [null, null];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setActivePortalMasterKey(key: Uint8Array) {
|
export function setActivePortalMasterKey(key: Uint8Array) {
|
||||||
|
|
Loading…
Reference in New Issue