Compare commits

...

10 Commits

7 changed files with 62 additions and 75 deletions

View File

@ -1,3 +1,5 @@
# [0.1.0-develop.14](https://git.lumeweb.com/LumeWeb/kernel/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-09-08)
# [0.1.0-develop.13](https://git.lumeweb.com/LumeWeb/kernel/compare/v0.1.0-develop.12...v0.1.0-develop.13) (2023-09-04)
# [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/kernel/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-09-04)

57
npm-shrinkwrap.json generated
View File

@ -1,14 +1,14 @@
{
"name": "@lumeweb/kernel",
"version": "0.1.0-develop.13",
"version": "0.1.0-develop.14",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@lumeweb/kernel",
"version": "0.1.0-develop.13",
"version": "0.1.0-develop.14",
"dependencies": {
"@lumeweb/libkernel": "0.1.0-develop.45"
"@lumeweb/libkernel": "0.1.0-develop.50"
},
"devDependencies": {
"@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.43",
@ -1690,11 +1690,11 @@
}
},
"node_modules/@lumeweb/libkernel": {
"version": "0.1.0-develop.45",
"resolved": "https://registry.npmjs.org/@lumeweb/libkernel/-/libkernel-0.1.0-develop.45.tgz",
"integrity": "sha512-TqC+FFHdaUlbT25+VLpeH8faxhPHG0lCTqDcClyYiRbFFtiSQZ66ZEQ6M8decVrickbKhgc5UZQr9Tl1mkoqoQ==",
"version": "0.1.0-develop.50",
"resolved": "https://registry.npmjs.org/@lumeweb/libkernel/-/libkernel-0.1.0-develop.50.tgz",
"integrity": "sha512-KfJSdJ/nNIQmx1GenH92JEF80Fz/KzNvQV07wO7VZ2jQGwJhB1tR+ufX9foLxt+ydmVLKbE6A6XaPwrlU+DGVg==",
"dependencies": {
"@lumeweb/libweb": "0.2.0-develop.50",
"@lumeweb/libweb": "0.2.0-develop.55",
"emittery": "^1.0.1",
"p-defer": "^4.0.0"
}
@ -1711,11 +1711,11 @@
}
},
"node_modules/@lumeweb/libportal": {
"version": "0.2.0-develop.24",
"resolved": "https://registry.npmjs.org/@lumeweb/libportal/-/libportal-0.2.0-develop.24.tgz",
"integrity": "sha512-EEsHjgmQOkzpU16mXXB6+O4Xv/4aQ+ApcWaShlCJQnHi4EFxuPDPJP6uIoBPhIcgXMm05ZF1YSs10ognAEXlcw==",
"version": "0.2.0-develop.34",
"resolved": "https://registry.npmjs.org/@lumeweb/libportal/-/libportal-0.2.0-develop.34.tgz",
"integrity": "sha512-Lr0HpYzt89n7ZmPJBLXD4HrOX1D6325g2S5q0uZwx33o0gBeylUVMXp3PsN3fpaiMELyz06jFkOCtlYzVlFSDQ==",
"dependencies": {
"@lumeweb/libs5": "^0.1.0-develop.45",
"@lumeweb/libs5": "^0.1.0-develop.55",
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1",
"detect-node": "^2.1.0",
@ -1728,9 +1728,9 @@
}
},
"node_modules/@lumeweb/libs5": {
"version": "0.1.0-develop.45",
"resolved": "https://registry.npmjs.org/@lumeweb/libs5/-/libs5-0.1.0-develop.45.tgz",
"integrity": "sha512-D2q8WhCrus/IWcvOmNE1BLPFCdwUzz0wp4hXzYggIRggui0tOBGKpLgo80ZLnjH9LUqaevAkwi9emJ6DrdDgyg==",
"version": "0.1.0-develop.55",
"resolved": "https://registry.npmjs.org/@lumeweb/libs5/-/libs5-0.1.0-develop.55.tgz",
"integrity": "sha512-bUhnmL6tW9XW7A5nSbBp4IZm0TU2Du3wPWecxiSXofXP3GprOxw6bylu7btgZVoh24qGeFVhmqkHBzR63dSEBQ==",
"dependencies": {
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1",
@ -1742,22 +1742,23 @@
}
},
"node_modules/@lumeweb/libs5/node_modules/multiformats": {
"version": "12.1.0",
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.0.tgz",
"integrity": "sha512-/qTOKKnU8nwcVURjRcS+UN0QYgdS5BPZzY10Aiciu2SqncyCVMGV8KtD83EBFmsuJDsSEmT4sGvzcTkCoMw0sQ==",
"version": "12.1.1",
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.1.tgz",
"integrity": "sha512-GBSToTmri2vJYs8wqcZQ8kB21dCaeTOzHTIAlr8J06C1eL6UbzqURXFZ5Fl0EYm9GAFz1IlYY8SxGOs9G9NJRg==",
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
}
},
"node_modules/@lumeweb/libweb": {
"version": "0.2.0-develop.50",
"resolved": "https://registry.npmjs.org/@lumeweb/libweb/-/libweb-0.2.0-develop.50.tgz",
"integrity": "sha512-1i9/0Oob5l4Jqd/DcFhVy0afLFuUBMNtzBRVLecKOJdkJDdbuJUev9Tmo30BccnxOa9h5D0inPlkiVr0giPfeg==",
"version": "0.2.0-develop.55",
"resolved": "https://registry.npmjs.org/@lumeweb/libweb/-/libweb-0.2.0-develop.55.tgz",
"integrity": "sha512-5CqsU2KjkNovRj92N9M/dGNu9Z5Tyu6pr8XwrFZQOLPseDebbFY3d+Wp+PV5Z3TqtuXaQ/+j7buR3K3175d37A==",
"dependencies": {
"@lumeweb/community-portals": "^0.1.0-develop.6",
"@lumeweb/libportal": "0.2.0-develop.24",
"@lumeweb/libportal": "0.2.0-develop.34",
"@lumeweb/node-library-preset": "0.2.7",
"@noble/ciphers": "^0.3.0",
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1",
"binconv": "^0.2.0"
@ -1789,6 +1790,14 @@
"vite-plugin-optimizer": "^1.4.2"
}
},
"node_modules/@noble/ciphers": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-0.3.0.tgz",
"integrity": "sha512-ldbrnOjmNRwFdXcTM6uXDcxpMIFrbzAWNnpBPp4oTJTFF0XByGD6vf45WrehZGXRQTRVV+Zm8YP+EgEf+e4cWA==",
"funding": {
"url": "https://paulmillr.com/funding/"
}
},
"node_modules/@noble/curves": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
@ -19600,9 +19609,9 @@
}
},
"node_modules/ws": {
"version": "8.13.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
"integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
"version": "8.14.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.1.tgz",
"integrity": "sha512-4OOseMUq8AzRBI/7SLMUwO+FEDnguetSk7KMb1sHwvF2w2Wv5Hoj0nlifx8vtGsftE/jWHojPy8sMMzYLJ2G/A==",
"engines": {
"node": ">=10.0.0"
},

View File

@ -1,6 +1,6 @@
{
"name": "@lumeweb/kernel",
"version": "0.1.0-develop.13",
"version": "0.1.0-develop.14",
"type": "module",
"repository": {
"type": "git",
@ -19,6 +19,6 @@
"semantic-release": "semantic-release"
},
"dependencies": {
"@lumeweb/libkernel": "0.1.0-develop.45"
"@lumeweb/libkernel": "0.1.0-develop.50"
}
}

View File

@ -1,10 +1,5 @@
import { internalModuleCall, modules } from "./queries.js";
import { SignedRegistryEntry } from "@lumeweb/libs5";
import {
decodeRegistryValue,
encodeCid,
decodeRegistryCid,
} from "@lumeweb/libweb";
import { SignedRegistryEntry, CID } from "@lumeweb/libs5";
const CORE_MODULES = {
swarm: "zdiLmwHCC15afFNLYzzT2DVV7m27SrBde7oXHdSzAe95GpFZXzdpatUN6b",
@ -35,7 +30,7 @@ function moduleLoaded(module: string) {
}
export async function resolveModuleRegistryEntry(module: string) {
const [cid] = decodeRegistryCid(module);
const cid = CID.decode(module);
const pubkey = cid.hash;
@ -45,18 +40,5 @@ export async function resolveModuleRegistryEntry(module: string) {
{ pubkey },
)) as SignedRegistryEntry;
let [decodedRegistry, err] = decodeRegistryValue(signedEntry.data);
if (err) {
throw new Error(err);
}
let rawEncCid;
[rawEncCid, err] = encodeCid(decodedRegistry);
if (err) {
throw new Error(err);
}
return rawEncCid;
const entry = CID.fromRegistry(signedEntry.data);
}

View File

@ -28,10 +28,14 @@ log("init", "Lume Web Kernel v" + KERNEL_VERSION + "-" + KERNEL_DISTRO);
*/
setActivePortalMasterKey(activeKey);
let [, portalLoadErr] = maybeInitDefaultPortals();
if (portalLoadErr) {
let err = addContextToErr(portalLoadErr, "unable to init portals");
let portalLoadErr = false;
try {
maybeInitDefaultPortals();
} catch (e) {
let err = addContextToErr(e, "unable to init portals");
logErr(err);
portalLoadErr = true;
}
if (!portalLoadErr) {

View File

@ -1,4 +1,4 @@
import { objAsString } from "@lumeweb/libweb";
import { objAsString } from "@lumeweb/libkernel";
// wLog is a wrapper for the log and logErr functions, to deduplicate code.
//

View File

@ -10,18 +10,12 @@ import {
objAsString,
sha512,
} from "@lumeweb/libkernel";
import {
CID,
decodeCid,
deriveChildKey,
downloadSmallObject,
verifyCid,
} from "@lumeweb/libweb";
import { CID_TYPES, CID_HASH_TYPES } from "@lumeweb/libs5";
import { deriveChildKey, downloadSmallObject } from "@lumeweb/libweb";
import { CID, CID_TYPES } from "@lumeweb/libs5";
import type { moduleQuery, presentKeyData } from "@lumeweb/libkernel/module";
import { defer } from "@lumeweb/libkernel/module";
import { readableStreamToUint8Array } from "binconv";
import { getSavedRegistryEntry } from "./registry.js";
import { defer } from "@lumeweb/libkernel/module";
import { networkReady, resolveModuleRegistryEntry } from "./coreModules.js";
// WorkerLaunchFn is the type signature of the function that launches the
@ -332,18 +326,12 @@ async function handleModuleCall(
let isResolver = false;
if (
typeof event.data.data.module === "string" &&
verifyCid(event.data.data.module)
CID.verify(event.data.data.module)
) {
const decodedCid = decodeCid(event.data.data.module);
if (!decodedCid[1]) {
const { type, hashType } = decodedCid[0];
if (type === CID_TYPES.RAW && hashType === CID_HASH_TYPES.BLAKE3) {
validCid = true;
}
if (type === CID_TYPES.RESOLVER && hashType === CID_HASH_TYPES.ED25519) {
validCid = true;
isResolver = true;
}
const cid = CID.decode(event.data.data.module);
validCid = true;
if (cid.type === CID_TYPES.RESOLVER) {
isResolver = true;
}
}
@ -537,10 +525,12 @@ async function handleModuleCall(
modulesLoading[moduleDomain] = new Promise(async (resolve) => {
// TODO: Check localStorage for the module.
// Download the code for the worker.
const [moduleData, errDS] = await downloadSmallObject(finalModule);
if (errDS !== null) {
const err = addContextToErr(errDS, "unable to load module");
let moduleData;
try {
moduleData = await downloadSmallObject(finalModule);
} catch (e) {
const err = addContextToErr(e, "unable to load module");
respondErr(event, messagePortal, isWorker, isInternal, err);
resolve(err);
delete modulesLoading[moduleDomain];