Compare commits

..

No commits in common. "develop" and "master" have entirely different histories.

6 changed files with 1 additions and 19549 deletions

View File

@ -1,17 +0,0 @@
{
"preset": [
"@lumeweb/presetter-kernel-module-preset"
],
"config": {
"tsconfig": {
"compilerOptions": {
"module": "nodenext"
}
}
},
"scripts": {
"build": "cross-env NODE_ENV=production run-s clean build:typescript:* build:vite build:html",
"build:vite": "vite build && shx mv lib/*.cjs lib/worker.js",
"build:html": "shx cp src/index.html lib/index.html"
}
}

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Hammer Technologies LLC
Copyright (c) 2023 LumeWeb
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

19419
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +0,0 @@
{
"name": "@lumeweb/hosted-kernel-worker",
"version": "0.1.0",
"type": "module",
"readme": "ERROR: No README data found!",
"_id": "@lumeweb/hosted-kernel-worker@0.1.0",
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
},
"dependencies": {
"@lumeweb/libkernel": "^0.1.0-develop.63",
"@lumeweb/libs5": "^0.1.0-develop.60",
"multiformats": "^12.1.1"
},
"devDependencies": {
"@lumeweb/presetter-kernel-module-preset": "0.1.0-develop.44",
"multiformats": "^12.1.1",
"presetter": "*"
}
}

View File

@ -1,13 +0,0 @@
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript" src="./worker.js"></script>
</body>
</html>

View File

@ -1,77 +0,0 @@
import { CID } from "@lumeweb/libs5";
import { blake3 } from "@noble/hashes/blake3";
import { equalBytes } from "@noble/ciphers/utils";
import { defer } from "@lumeweb/libkernel/module";
document.title = "Hosted Lume Kernel Worker";
let header = document.createElement("h1");
header.textContent =
"Something went wrong! You should not be visiting this page, this page should only be accessed via an invisible iframe.";
document.body.appendChild(header);
const initDefer = defer<Uint8Array>();
let worker: Worker;
function boot() {
let workerCID = window.location.hostname.split(".")[0];
let cid = CID.decode(workerCID);
initDefer.promise.then((module) => {
if (!equalBytes(blake3(module), cid.hash.hashBytes)) {
sendError("invalid module");
return;
}
const moduleUrl = URL.createObjectURL(new Blob([module]));
worker = new Worker(moduleUrl);
worker.onmessage = function (event: MessageEvent) {
sendMessage("workerMessage", event.data);
};
worker.onerror = function (event: ErrorEvent) {
sendError(event.message, event.error);
};
sendMessage("workerInited", {});
});
}
function sendMessage(method: string, data: any) {
window.parent.postMessage(
{
method,
data,
},
"https://kernel.lumeweb.com",
);
}
function sendError(message: string, error = null) {
sendMessage("workerError", {
data: {
message,
error,
},
});
}
onmessage = function (event: MessageEvent) {
if (window === event.source) {
return;
}
if (event.origin !== "https://kernel.lumeweb.com") {
return;
}
if (event.data.method === "workerInit") {
initDefer.resolve(event.data.module);
return;
}
worker?.postMessage(event.data);
};
boot();