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.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)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/kernel",
|
"name": "@lumeweb/kernel",
|
||||||
"version": "0.1.0-develop.14",
|
"version": "0.1.0-develop.13",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@lumeweb/kernel",
|
"name": "@lumeweb/kernel",
|
||||||
"version": "0.1.0-develop.14",
|
"version": "0.1.0-develop.13",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lumeweb/libkernel": "0.1.0-develop.50"
|
"@lumeweb/libkernel": "0.1.0-develop.45"
|
||||||
},
|
},
|
||||||
"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.50",
|
"version": "0.1.0-develop.45",
|
||||||
"resolved": "https://registry.npmjs.org/@lumeweb/libkernel/-/libkernel-0.1.0-develop.50.tgz",
|
"resolved": "https://registry.npmjs.org/@lumeweb/libkernel/-/libkernel-0.1.0-develop.45.tgz",
|
||||||
"integrity": "sha512-KfJSdJ/nNIQmx1GenH92JEF80Fz/KzNvQV07wO7VZ2jQGwJhB1tR+ufX9foLxt+ydmVLKbE6A6XaPwrlU+DGVg==",
|
"integrity": "sha512-TqC+FFHdaUlbT25+VLpeH8faxhPHG0lCTqDcClyYiRbFFtiSQZ66ZEQ6M8decVrickbKhgc5UZQr9Tl1mkoqoQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lumeweb/libweb": "0.2.0-develop.55",
|
"@lumeweb/libweb": "0.2.0-develop.50",
|
||||||
"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.34",
|
"version": "0.2.0-develop.24",
|
||||||
"resolved": "https://registry.npmjs.org/@lumeweb/libportal/-/libportal-0.2.0-develop.34.tgz",
|
"resolved": "https://registry.npmjs.org/@lumeweb/libportal/-/libportal-0.2.0-develop.24.tgz",
|
||||||
"integrity": "sha512-Lr0HpYzt89n7ZmPJBLXD4HrOX1D6325g2S5q0uZwx33o0gBeylUVMXp3PsN3fpaiMELyz06jFkOCtlYzVlFSDQ==",
|
"integrity": "sha512-EEsHjgmQOkzpU16mXXB6+O4Xv/4aQ+ApcWaShlCJQnHi4EFxuPDPJP6uIoBPhIcgXMm05ZF1YSs10ognAEXlcw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lumeweb/libs5": "^0.1.0-develop.55",
|
"@lumeweb/libs5": "^0.1.0-develop.45",
|
||||||
"@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.55",
|
"version": "0.1.0-develop.45",
|
||||||
"resolved": "https://registry.npmjs.org/@lumeweb/libs5/-/libs5-0.1.0-develop.55.tgz",
|
"resolved": "https://registry.npmjs.org/@lumeweb/libs5/-/libs5-0.1.0-develop.45.tgz",
|
||||||
"integrity": "sha512-bUhnmL6tW9XW7A5nSbBp4IZm0TU2Du3wPWecxiSXofXP3GprOxw6bylu7btgZVoh24qGeFVhmqkHBzR63dSEBQ==",
|
"integrity": "sha512-D2q8WhCrus/IWcvOmNE1BLPFCdwUzz0wp4hXzYggIRggui0tOBGKpLgo80ZLnjH9LUqaevAkwi9emJ6DrdDgyg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/curves": "^1.1.0",
|
"@noble/curves": "^1.1.0",
|
||||||
"@noble/hashes": "^1.3.1",
|
"@noble/hashes": "^1.3.1",
|
||||||
|
@ -1742,23 +1742,22 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@lumeweb/libs5/node_modules/multiformats": {
|
"node_modules/@lumeweb/libs5/node_modules/multiformats": {
|
||||||
"version": "12.1.1",
|
"version": "12.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/multiformats/-/multiformats-12.1.0.tgz",
|
||||||
"integrity": "sha512-GBSToTmri2vJYs8wqcZQ8kB21dCaeTOzHTIAlr8J06C1eL6UbzqURXFZ5Fl0EYm9GAFz1IlYY8SxGOs9G9NJRg==",
|
"integrity": "sha512-/qTOKKnU8nwcVURjRcS+UN0QYgdS5BPZzY10Aiciu2SqncyCVMGV8KtD83EBFmsuJDsSEmT4sGvzcTkCoMw0sQ==",
|
||||||
"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.55",
|
"version": "0.2.0-develop.50",
|
||||||
"resolved": "https://registry.npmjs.org/@lumeweb/libweb/-/libweb-0.2.0-develop.55.tgz",
|
"resolved": "https://registry.npmjs.org/@lumeweb/libweb/-/libweb-0.2.0-develop.50.tgz",
|
||||||
"integrity": "sha512-5CqsU2KjkNovRj92N9M/dGNu9Z5Tyu6pr8XwrFZQOLPseDebbFY3d+Wp+PV5Z3TqtuXaQ/+j7buR3K3175d37A==",
|
"integrity": "sha512-1i9/0Oob5l4Jqd/DcFhVy0afLFuUBMNtzBRVLecKOJdkJDdbuJUev9Tmo30BccnxOa9h5D0inPlkiVr0giPfeg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@lumeweb/community-portals": "^0.1.0-develop.6",
|
"@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",
|
"@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"
|
||||||
|
@ -1790,14 +1789,6 @@
|
||||||
"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",
|
||||||
|
@ -19609,9 +19600,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ws": {
|
"node_modules/ws": {
|
||||||
"version": "8.14.1",
|
"version": "8.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.1.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
|
||||||
"integrity": "sha512-4OOseMUq8AzRBI/7SLMUwO+FEDnguetSk7KMb1sHwvF2w2Wv5Hoj0nlifx8vtGsftE/jWHojPy8sMMzYLJ2G/A==",
|
"integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/kernel",
|
"name": "@lumeweb/kernel",
|
||||||
"version": "0.1.0-develop.14",
|
"version": "0.1.0-develop.13",
|
||||||
"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.50"
|
"@lumeweb/libkernel": "0.1.0-develop.45"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
import { internalModuleCall, modules } from "./queries.js";
|
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 = {
|
const CORE_MODULES = {
|
||||||
swarm: "zdiLmwHCC15afFNLYzzT2DVV7m27SrBde7oXHdSzAe95GpFZXzdpatUN6b",
|
swarm: "zdiLmwHCC15afFNLYzzT2DVV7m27SrBde7oXHdSzAe95GpFZXzdpatUN6b",
|
||||||
|
@ -30,7 +35,7 @@ function moduleLoaded(module: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function resolveModuleRegistryEntry(module: string) {
|
export async function resolveModuleRegistryEntry(module: string) {
|
||||||
const cid = CID.decode(module);
|
const [cid] = decodeRegistryCid(module);
|
||||||
|
|
||||||
const pubkey = cid.hash;
|
const pubkey = cid.hash;
|
||||||
|
|
||||||
|
@ -40,5 +45,18 @@ export async function resolveModuleRegistryEntry(module: string) {
|
||||||
{ pubkey },
|
{ pubkey },
|
||||||
)) as SignedRegistryEntry;
|
)) 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);
|
setActivePortalMasterKey(activeKey);
|
||||||
|
|
||||||
let portalLoadErr = false;
|
let [, portalLoadErr] = maybeInitDefaultPortals();
|
||||||
|
if (portalLoadErr) {
|
||||||
try {
|
let err = addContextToErr(portalLoadErr, "unable to init portals");
|
||||||
maybeInitDefaultPortals();
|
|
||||||
} catch (e) {
|
|
||||||
let err = addContextToErr(e, "unable to init portals");
|
|
||||||
logErr(err);
|
logErr(err);
|
||||||
portalLoadErr = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!portalLoadErr) {
|
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.
|
// wLog is a wrapper for the log and logErr functions, to deduplicate code.
|
||||||
//
|
//
|
||||||
|
|
|
@ -10,12 +10,18 @@ import {
|
||||||
objAsString,
|
objAsString,
|
||||||
sha512,
|
sha512,
|
||||||
} from "@lumeweb/libkernel";
|
} from "@lumeweb/libkernel";
|
||||||
import { deriveChildKey, downloadSmallObject } from "@lumeweb/libweb";
|
import {
|
||||||
import { CID, CID_TYPES } from "@lumeweb/libs5";
|
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 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
|
||||||
|
@ -326,14 +332,20 @@ async function handleModuleCall(
|
||||||
let isResolver = false;
|
let isResolver = false;
|
||||||
if (
|
if (
|
||||||
typeof event.data.data.module === "string" &&
|
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);
|
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;
|
validCid = true;
|
||||||
if (cid.type === CID_TYPES.RESOLVER) {
|
|
||||||
isResolver = true;
|
isResolver = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!validCid) {
|
if (!validCid) {
|
||||||
logErr("moduleCall", "received moduleCall with malformed module");
|
logErr("moduleCall", "received moduleCall with malformed module");
|
||||||
|
@ -525,12 +537,10 @@ 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.
|
||||||
|
|
||||||
let moduleData;
|
// Download the code for the worker.
|
||||||
|
const [moduleData, errDS] = await downloadSmallObject(finalModule);
|
||||||
try {
|
if (errDS !== null) {
|
||||||
moduleData = await downloadSmallObject(finalModule);
|
const err = addContextToErr(errDS, "unable to load module");
|
||||||
} 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];
|
||||||
|
|
Loading…
Reference in New Issue