Compare commits
No commits in common. "v0.1.0-develop.14" and "v0.1.0-develop.13" have entirely different histories.
v0.1.0-dev
...
v0.1.0-dev
|
@ -1,5 +1,3 @@
|
|||
# [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)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
{
|
||||
"name": "@lumeweb/kernel",
|
||||
"version": "0.1.0-develop.14",
|
||||
"version": "0.1.0-develop.13",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@lumeweb/kernel",
|
||||
"version": "0.1.0-develop.14",
|
||||
"version": "0.1.0-develop.13",
|
||||
"dependencies": {
|
||||
"@lumeweb/libkernel": "0.1.0-develop.50"
|
||||
"@lumeweb/libkernel": "0.1.0-develop.45"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.43",
|
||||
|
@ -1690,11 +1690,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@lumeweb/libkernel": {
|
||||
"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==",
|
||||
"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==",
|
||||
"dependencies": {
|
||||
"@lumeweb/libweb": "0.2.0-develop.55",
|
||||
"@lumeweb/libweb": "0.2.0-develop.50",
|
||||
"emittery": "^1.0.1",
|
||||
"p-defer": "^4.0.0"
|
||||
}
|
||||
|
@ -1711,11 +1711,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@lumeweb/libportal": {
|
||||
"version": "0.2.0-develop.34",
|
||||
"resolved": "https://registry.npmjs.org/@lumeweb/libportal/-/libportal-0.2.0-develop.34.tgz",
|
||||
"integrity": "sha512-Lr0HpYzt89n7ZmPJBLXD4HrOX1D6325g2S5q0uZwx33o0gBeylUVMXp3PsN3fpaiMELyz06jFkOCtlYzVlFSDQ==",
|
||||
"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==",
|
||||
"dependencies": {
|
||||
"@lumeweb/libs5": "^0.1.0-develop.55",
|
||||
"@lumeweb/libs5": "^0.1.0-develop.45",
|
||||
"@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.55",
|
||||
"resolved": "https://registry.npmjs.org/@lumeweb/libs5/-/libs5-0.1.0-develop.55.tgz",
|
||||
"integrity": "sha512-bUhnmL6tW9XW7A5nSbBp4IZm0TU2Du3wPWecxiSXofXP3GprOxw6bylu7btgZVoh24qGeFVhmqkHBzR63dSEBQ==",
|
||||
"version": "0.1.0-develop.45",
|
||||
"resolved": "https://registry.npmjs.org/@lumeweb/libs5/-/libs5-0.1.0-develop.45.tgz",
|
||||
"integrity": "sha512-D2q8WhCrus/IWcvOmNE1BLPFCdwUzz0wp4hXzYggIRggui0tOBGKpLgo80ZLnjH9LUqaevAkwi9emJ6DrdDgyg==",
|
||||
"dependencies": {
|
||||
"@noble/curves": "^1.1.0",
|
||||
"@noble/hashes": "^1.3.1",
|
||||
|
@ -1742,23 +1742,22 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@lumeweb/libs5/node_modules/multiformats": {
|
||||
"version": "12.1.1",
|
||||
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.1.tgz",
|
||||
"integrity": "sha512-GBSToTmri2vJYs8wqcZQ8kB21dCaeTOzHTIAlr8J06C1eL6UbzqURXFZ5Fl0EYm9GAFz1IlYY8SxGOs9G9NJRg==",
|
||||
"version": "12.1.0",
|
||||
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.0.tgz",
|
||||
"integrity": "sha512-/qTOKKnU8nwcVURjRcS+UN0QYgdS5BPZzY10Aiciu2SqncyCVMGV8KtD83EBFmsuJDsSEmT4sGvzcTkCoMw0sQ==",
|
||||
"engines": {
|
||||
"node": ">=16.0.0",
|
||||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lumeweb/libweb": {
|
||||
"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==",
|
||||
"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==",
|
||||
"dependencies": {
|
||||
"@lumeweb/community-portals": "^0.1.0-develop.6",
|
||||
"@lumeweb/libportal": "0.2.0-develop.34",
|
||||
"@lumeweb/libportal": "0.2.0-develop.24",
|
||||
"@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"
|
||||
|
@ -1790,14 +1789,6 @@
|
|||
"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",
|
||||
|
@ -19609,9 +19600,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/ws": {
|
||||
"version": "8.14.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.1.tgz",
|
||||
"integrity": "sha512-4OOseMUq8AzRBI/7SLMUwO+FEDnguetSk7KMb1sHwvF2w2Wv5Hoj0nlifx8vtGsftE/jWHojPy8sMMzYLJ2G/A==",
|
||||
"version": "8.13.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
|
||||
"integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@lumeweb/kernel",
|
||||
"version": "0.1.0-develop.14",
|
||||
"version": "0.1.0-develop.13",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -19,6 +19,6 @@
|
|||
"semantic-release": "semantic-release"
|
||||
},
|
||||
"dependencies": {
|
||||
"@lumeweb/libkernel": "0.1.0-develop.50"
|
||||
"@lumeweb/libkernel": "0.1.0-develop.45"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
import { internalModuleCall, modules } from "./queries.js";
|
||||
import { SignedRegistryEntry, CID } from "@lumeweb/libs5";
|
||||
import { SignedRegistryEntry } from "@lumeweb/libs5";
|
||||
import {
|
||||
decodeRegistryValue,
|
||||
encodeCid,
|
||||
decodeRegistryCid,
|
||||
} from "@lumeweb/libweb";
|
||||
|
||||
const CORE_MODULES = {
|
||||
swarm: "zdiLmwHCC15afFNLYzzT2DVV7m27SrBde7oXHdSzAe95GpFZXzdpatUN6b",
|
||||
|
@ -30,7 +35,7 @@ function moduleLoaded(module: string) {
|
|||
}
|
||||
|
||||
export async function resolveModuleRegistryEntry(module: string) {
|
||||
const cid = CID.decode(module);
|
||||
const [cid] = decodeRegistryCid(module);
|
||||
|
||||
const pubkey = cid.hash;
|
||||
|
||||
|
@ -40,5 +45,18 @@ export async function resolveModuleRegistryEntry(module: string) {
|
|||
{ pubkey },
|
||||
)) as SignedRegistryEntry;
|
||||
|
||||
const entry = CID.fromRegistry(signedEntry.data);
|
||||
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;
|
||||
}
|
||||
|
|
10
src/index.ts
10
src/index.ts
|
@ -28,14 +28,10 @@ log("init", "Lume Web Kernel v" + KERNEL_VERSION + "-" + KERNEL_DISTRO);
|
|||
*/
|
||||
setActivePortalMasterKey(activeKey);
|
||||
|
||||
let portalLoadErr = false;
|
||||
|
||||
try {
|
||||
maybeInitDefaultPortals();
|
||||
} catch (e) {
|
||||
let err = addContextToErr(e, "unable to init portals");
|
||||
let [, portalLoadErr] = maybeInitDefaultPortals();
|
||||
if (portalLoadErr) {
|
||||
let err = addContextToErr(portalLoadErr, "unable to init portals");
|
||||
logErr(err);
|
||||
portalLoadErr = true;
|
||||
}
|
||||
|
||||
if (!portalLoadErr) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { objAsString } from "@lumeweb/libkernel";
|
||||
import { objAsString } from "@lumeweb/libweb";
|
||||
|
||||
// wLog is a wrapper for the log and logErr functions, to deduplicate code.
|
||||
//
|
||||
|
|
|
@ -10,12 +10,18 @@ import {
|
|||
objAsString,
|
||||
sha512,
|
||||
} from "@lumeweb/libkernel";
|
||||
import { deriveChildKey, downloadSmallObject } from "@lumeweb/libweb";
|
||||
import { CID, CID_TYPES } from "@lumeweb/libs5";
|
||||
import {
|
||||
CID,
|
||||
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 { 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
|
||||
|
@ -326,12 +332,18 @@ async function handleModuleCall(
|
|||
let isResolver = false;
|
||||
if (
|
||||
typeof event.data.data.module === "string" &&
|
||||
CID.verify(event.data.data.module)
|
||||
verifyCid(event.data.data.module)
|
||||
) {
|
||||
const cid = CID.decode(event.data.data.module);
|
||||
validCid = true;
|
||||
if (cid.type === CID_TYPES.RESOLVER) {
|
||||
isResolver = true;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -525,12 +537,10 @@ async function handleModuleCall(
|
|||
modulesLoading[moduleDomain] = new Promise(async (resolve) => {
|
||||
// TODO: Check localStorage for the module.
|
||||
|
||||
let moduleData;
|
||||
|
||||
try {
|
||||
moduleData = await downloadSmallObject(finalModule);
|
||||
} catch (e) {
|
||||
const err = addContextToErr(e, "unable to load module");
|
||||
// Download the code for the worker.
|
||||
const [moduleData, errDS] = await downloadSmallObject(finalModule);
|
||||
if (errDS !== null) {
|
||||
const err = addContextToErr(errDS, "unable to load module");
|
||||
respondErr(event, messagePortal, isWorker, isInternal, err);
|
||||
resolve(err);
|
||||
delete modulesLoading[moduleDomain];
|
||||
|
|
Loading…
Reference in New Issue