Compare commits

..

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

7 changed files with 1 additions and 19901 deletions

View File

@ -1,13 +0,0 @@
name: Build/Publish
on:
push:
branches:
- master
- develop
- develop-*
jobs:
main:
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
secrets: inherit

View File

@ -1,27 +0,0 @@
{
"preset": [
"@lumeweb/presetter-kernel-module-preset"
],
"config": {
"official": true,
"vite": {
"resolve": {
"alias": {
"protomux": "@lumeweb/kernel-protomux-client",
"url": "whatwg-url"
}
},
"polyfill": {
"exclude": [
"fs",
"url"
]
}
},
"tsconfig": {
"compilerOptions": {
"module": "nodenext"
}
}
}
}

View File

@ -1,79 +0,0 @@
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.14...v0.1.0-develop.15) (2023-11-18)
### Bug Fixes
* need to pass CID object ([003d42a](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/003d42ac09e2833f23f8b0e6d1268424cbfd2f9d))
# [0.1.0-develop.14](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-11-17)
# [0.1.0-develop.13](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.12...v0.1.0-develop.13) (2023-11-17)
### Features
* add stat api ([2db701f](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/2db701fb92cab25c01ac25d1da5ad8839125545c))
# [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-11-17)
### Features
* add cat api ([024cb50](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/024cb507d14ca9cf722dbebc428e56b5ea63cbac))
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-10-13)
# [0.1.0-develop.10](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.9...v0.1.0-develop.10) (2023-09-20)
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-09-04)
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-09-04)
### Bug Fixes
* have peerConnectedDefer resolve when we have a connected peer via peerConnected ([beb4215](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/beb42152b829196af26fc70f3189e8ade651c717))
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-09-03)
### Bug Fixes
* need to prefix the key type byte ([cabb498](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/cabb498ac0e0f3322dc69a02b242bf5e498e843a))
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-09-02)
### Bug Fixes
* have setup hang until we have a connected peer ([dcc72b9](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/dcc72b9cec9e7e97d3bdbcc1449fae2ae9b04552))
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-09-02)
### Bug Fixes
* use CID_HASH_TYPES.ED25519 over mkeyEd25519 ([6c76768](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/6c76768fe0f735d49f13cbd13b5682dd990e088c))
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-09-01)
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-09-01)
### Features
* add getRegistryEntry, setRegistryEntry, registrySubscription ([fa04bb5](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/fa04bb5e3066ed8efba083db55f31145c21f41ee))
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-09-01)
### Bug Fixes
* ready needs to call respond ([840383d](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/840383d7c87037134bdc5603891c468960282fc5))
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/kernel-s5/compare/v0.0.1...v0.1.0-develop.1) (2023-09-01)
### Features
* initial version ([904abe6](https://git.lumeweb.com/LumeWeb/kernel-s5/commit/904abe6abd8ba91f42d77722cdfae168629cf5db))

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:

19543
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
{
"name": "@lumeweb/kernel-s5",
"version": "0.1.0-develop.15",
"type": "module",
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-s5.git"
},
"scripts": {
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release"
},
"dependencies": {
"@lumeweb/kernel-protomux-client": "^0.0.2-develop.23",
"@lumeweb/kernel-swarm-client": "^0.1.0-develop.13",
"@lumeweb/libs5": "^0.1.0-develop.77",
"@lumeweb/libs5-transport-hyper": "^0.1.0-develop.21",
"whatwg-url": "^13.0.0"
},
"devDependencies": {
"@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.44"
}
}

View File

@ -1,213 +0,0 @@
import { concatBytes, ensureBytes } from "@lumeweb/libkernel";
import {
addHandler,
defer,
getKey,
handlePresentKey as handlePresentKeyModule,
} from "@lumeweb/libkernel/module";
import type { ActiveQuery } from "@lumeweb/libkernel/module";
import {
createClient as createSwarmClient,
SwarmClient,
} from "@lumeweb/kernel-swarm-client";
import Protomux from "@lumeweb/kernel-protomux-client";
import {
CID,
CID_HASH_TYPES,
createKeyPair,
createNode,
NodeId,
S5NodeConfig,
} from "@lumeweb/libs5";
import type { S5Node } from "@lumeweb/libs5";
import KeyPairEd25519 from "@lumeweb/libs5/lib/ed25519.js";
import { Level } from "level";
import HyperTransportPeer from "@lumeweb/libs5-transport-hyper";
const PROTOCOL = "lumeweb.service.s5";
const moduleReadyDefer = defer();
let swarm: SwarmClient;
let node: S5Node;
addHandler("presentKey", handlePresentKey);
addHandler("ready", ready);
addHandler("getRegistryEntry", handleGetRegistryEntry);
addHandler("setRegistryEntry", handleSetRegistryEntry);
addHandler("registrySubscription", handleRegistrySubscription, {
receiveUpdates: true,
});
addHandler("cat", handleCat);
addHandler("stat", handleStat);
async function handlePresentKey(aq: ActiveQuery) {
handlePresentKeyModule({
callerInput: {
key: aq.callerInput.rootKey,
},
} as ActiveQuery);
await setup();
moduleReadyDefer.resolve();
}
async function setup() {
swarm = createSwarmClient();
const peerConnectedDefer = defer();
const db = new Level<string, Uint8Array>("s5");
await db.open();
let config = {
keyPair: createKeyPair(await getKey()),
db,
p2p: {
peers: {
initial: [],
},
},
} as S5NodeConfig;
swarm.join(PROTOCOL);
await swarm.start();
await swarm.ready();
node = createNode(config);
await node.start();
swarm.on("connection", async (peer: any) => {
const muxer = Protomux.from(peer);
const s5peer = new HyperTransportPeer({
muxer,
peer,
protocol: PROTOCOL,
});
s5peer.id = new NodeId(
concatBytes(
Uint8Array.from([CID_HASH_TYPES.ED25519]),
peer.remotePublicKey,
),
);
await s5peer.init();
node.services.p2p.onNewPeer(s5peer, true);
node.services.p2p.once("peerConnected", peerConnectedDefer.resolve);
});
return peerConnectedDefer.promise;
}
async function ready(aq: ActiveQuery) {
await moduleReadyDefer.promise;
aq.respond();
}
async function handleGetRegistryEntry(aq: ActiveQuery) {
if (!("pubkey" in aq.callerInput)) {
aq.reject("pubkey required");
}
await moduleReadyDefer.promise;
let { pubkey } = aq.callerInput;
pubkey = ensureBytes("registry entry", pubkey, 33);
const ret = await node.services.registry.get(pubkey);
if (!ret) {
aq.reject("could not find registry entry");
return;
}
aq.respond(ret);
}
async function handleSetRegistryEntry(aq: ActiveQuery) {
for (const field of ["key", "data", "revision"]) {
if (!(field in aq.callerInput)) {
aq.reject(`${field} required`);
return;
}
}
await moduleReadyDefer.promise;
let { key, data, revision } = aq.callerInput;
key = ensureBytes("registry entry private key", key, 32);
const sre = node.services.registry.signRegistryEntry({
kp: new KeyPairEd25519(key),
data,
revision,
});
try {
await node.services.registry.set(sre);
aq.respond(sre);
} catch (e) {
aq.reject(e);
}
}
async function handleRegistrySubscription(aq: ActiveQuery) {
if (!("pubkey" in aq.callerInput)) {
aq.reject("pubkey required");
}
await moduleReadyDefer.promise;
let { pubkey } = aq.callerInput;
pubkey = ensureBytes("registry entry ", pubkey, 32);
const wait = defer();
const done = node.services.registry.listen(pubkey, (sre) => {
aq.sendUpdate(sre);
});
aq.setReceiveUpdate?.(() => {
done();
wait.resolve();
});
await wait.promise;
aq.respond();
}
async function handleCat(aq: ActiveQuery) {
if (!("cid" in aq.callerInput)) {
aq.reject("cid required");
return;
}
try {
const ret = await node.downloadBytesByHash(
CID.decode(aq.callerInput.cid as string).hash,
);
aq.respond(ret);
} catch (e) {
aq.reject(e);
}
}
async function handleStat(aq: ActiveQuery) {
if (!("cid" in aq.callerInput)) {
aq.reject("cid required");
return;
}
try {
const ret = await node.getMetadataByCID(CID.decode(aq.callerInput.cid));
aq.respond(ret.toJson());
} catch (e) {
aq.reject(e);
}
}