Compare commits
No commits in common. "v0.2.0-develop.7" and "v0.2.0-develop.6" have entirely different histories.
v0.2.0-dev
...
v0.2.0-dev
|
@ -1,11 +1,3 @@
|
||||||
# [0.2.0-develop.7](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.6...v0.2.0-develop.7) (2023-06-23)
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* add portal to exports ([8b7f708](https://git.lumeweb.com/LumeWeb/libweb/commit/8b7f7082e3af84d8963ec535804b8816a1a396dc))
|
|
||||||
* improve portal api ([ca43e88](https://git.lumeweb.com/LumeWeb/libweb/commit/ca43e883006a58d92eec519925a007c0c82c55c6))
|
|
||||||
|
|
||||||
# [0.2.0-develop.6](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.5...v0.2.0-develop.6) (2023-06-23)
|
# [0.2.0-develop.6](https://git.lumeweb.com/LumeWeb/libweb/compare/v0.2.0-develop.5...v0.2.0-develop.6) (2023-06-23)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libweb",
|
"name": "@lumeweb/libweb",
|
||||||
"version": "0.2.0-develop.7",
|
"version": "0.2.0-develop.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lumeweb/libweb",
|
"name": "@lumeweb/libweb",
|
||||||
"version": "0.2.0-develop.7",
|
"version": "0.2.0-develop.6",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lumeweb/libportal": "0.2.0-develop.5",
|
"@lumeweb/libportal": "0.2.0-develop.5",
|
||||||
"@noble/curves": "^1.1.0",
|
"@noble/curves": "^1.1.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/libweb",
|
"name": "@lumeweb/libweb",
|
||||||
"version": "0.2.0-develop.7",
|
"version": "0.2.0-develop.6",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -11,5 +11,4 @@ export * from "./cid.js";
|
||||||
export * from "./encoding.js";
|
export * from "./encoding.js";
|
||||||
export * from "./keys.js";
|
export * from "./keys.js";
|
||||||
export * from "./download.js";
|
export * from "./download.js";
|
||||||
export * from "./portal.js";
|
|
||||||
export { ed25519, sha512 };
|
export { ed25519, sha512 };
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const DEFAULT_PORTAL_LIST: Portal[] = [
|
||||||
{ id: "lumeweb", url: "https://web3portal.com", name: "web3portal.com" },
|
{ id: "lumeweb", url: "https://web3portal.com", name: "web3portal.com" },
|
||||||
];
|
];
|
||||||
|
|
||||||
let ACTIVE_PORTALS = new Set<Client>();
|
const ACTIVE_PORTALS = new Set<Client>();
|
||||||
|
|
||||||
type PortalSessionsStore = { [id: string]: string };
|
type PortalSessionsStore = { [id: string]: string };
|
||||||
|
|
||||||
|
@ -19,8 +19,31 @@ export function maybeInitDefaultPortals(): ErrTuple {
|
||||||
return [null, "activePortalMasterKey not set"];
|
return [null, "activePortalMasterKey not set"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let portalSessionsData = window.localStorage.getItem("portals");
|
||||||
|
let portalSessions: PortalSessionsStore = {};
|
||||||
|
if (portalSessions) {
|
||||||
|
portalSessions = JSON.parse(
|
||||||
|
portalSessionsData as string,
|
||||||
|
) as PortalSessionsStore;
|
||||||
|
}
|
||||||
|
|
||||||
for (const portal of DEFAULT_PORTAL_LIST) {
|
for (const portal of DEFAULT_PORTAL_LIST) {
|
||||||
initPortal(portal);
|
let jwt: string | null = null;
|
||||||
|
|
||||||
|
if (portalSessions) {
|
||||||
|
if (portal.id in portalSessions) {
|
||||||
|
jwt = portalSessions[portal.id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const client = new Client({
|
||||||
|
email: generatePortalEmail(portal),
|
||||||
|
portalUrl: portal.url,
|
||||||
|
privateKey: generatePortalKeyPair(portal).privateKey,
|
||||||
|
jwt: jwt as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
ACTIVE_PORTALS.add(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [null, null];
|
return [null, null];
|
||||||
|
@ -53,43 +76,3 @@ export function generatePortalKeyPair(portal: Portal): KeyPair {
|
||||||
export function getActivePortals(): Set<Client> {
|
export function getActivePortals(): Set<Client> {
|
||||||
return ACTIVE_PORTALS;
|
return ACTIVE_PORTALS;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addActivePortal(portal: Client) {
|
|
||||||
ACTIVE_PORTALS.add(portal);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initPortal(portal: Portal) {
|
|
||||||
const sessions = getPortalSessions();
|
|
||||||
let jwt: string | null = null;
|
|
||||||
if (sessions) {
|
|
||||||
if (portal.id in sessions) {
|
|
||||||
jwt = sessions[portal.id];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const client = new Client({
|
|
||||||
email: generatePortalEmail(portal),
|
|
||||||
portalUrl: portal.url,
|
|
||||||
privateKey: generatePortalKeyPair(portal).privateKey,
|
|
||||||
jwt: jwt as string,
|
|
||||||
});
|
|
||||||
|
|
||||||
addActivePortal(client);
|
|
||||||
}
|
|
||||||
export function getPortalSessions() {
|
|
||||||
let portalSessionsData = window.localStorage.getItem("portals");
|
|
||||||
let portalSessions: PortalSessionsStore = {};
|
|
||||||
if (portalSessions) {
|
|
||||||
portalSessions = JSON.parse(
|
|
||||||
portalSessionsData as string,
|
|
||||||
) as PortalSessionsStore;
|
|
||||||
|
|
||||||
return portalSessions;
|
|
||||||
}
|
|
||||||
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function setActivePortals(portals: Client[]) {
|
|
||||||
ACTIVE_PORTALS = new Set<Client>(portals);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue