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

View File

@ -1,6 +1,6 @@
{ {
"name": "@lumeweb/kernel", "name": "@lumeweb/kernel",
"version": "0.1.0-develop.13", "version": "0.1.0-develop.14",
"type": "module", "type": "module",
"repository": { "repository": {
"type": "git", "type": "git",
@ -19,6 +19,6 @@
"semantic-release": "semantic-release" "semantic-release": "semantic-release"
}, },
"dependencies": { "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 { internalModuleCall, modules } from "./queries.js";
import { SignedRegistryEntry } from "@lumeweb/libs5"; import { SignedRegistryEntry, CID } from "@lumeweb/libs5";
import {
decodeRegistryValue,
encodeCid,
decodeRegistryCid,
} from "@lumeweb/libweb";
const CORE_MODULES = { const CORE_MODULES = {
swarm: "zdiLmwHCC15afFNLYzzT2DVV7m27SrBde7oXHdSzAe95GpFZXzdpatUN6b", swarm: "zdiLmwHCC15afFNLYzzT2DVV7m27SrBde7oXHdSzAe95GpFZXzdpatUN6b",
@ -35,7 +30,7 @@ function moduleLoaded(module: string) {
} }
export async function resolveModuleRegistryEntry(module: string) { export async function resolveModuleRegistryEntry(module: string) {
const [cid] = decodeRegistryCid(module); const cid = CID.decode(module);
const pubkey = cid.hash; const pubkey = cid.hash;
@ -45,18 +40,5 @@ export async function resolveModuleRegistryEntry(module: string) {
{ pubkey }, { pubkey },
)) as SignedRegistryEntry; )) as SignedRegistryEntry;
let [decodedRegistry, err] = decodeRegistryValue(signedEntry.data); const entry = CID.fromRegistry(signedEntry.data);
if (err) {
throw new Error(err);
}
let rawEncCid;
[rawEncCid, err] = encodeCid(decodedRegistry);
if (err) {
throw new Error(err);
}
return rawEncCid;
} }

View File

@ -28,10 +28,14 @@ log("init", "Lume Web Kernel v" + KERNEL_VERSION + "-" + KERNEL_DISTRO);
*/ */
setActivePortalMasterKey(activeKey); setActivePortalMasterKey(activeKey);
let [, portalLoadErr] = maybeInitDefaultPortals(); let portalLoadErr = false;
if (portalLoadErr) {
let err = addContextToErr(portalLoadErr, "unable to init portals"); try {
maybeInitDefaultPortals();
} catch (e) {
let err = addContextToErr(e, "unable to init portals");
logErr(err); logErr(err);
portalLoadErr = true;
} }
if (!portalLoadErr) { 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. // wLog is a wrapper for the log and logErr functions, to deduplicate code.
// //

View File

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