Compare commits

..

No commits in common. "v0.1.0-develop.18" and "master" have entirely different histories.

8 changed files with 1 additions and 19573 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,5 +0,0 @@
{
"preset": [
"@lumeweb/node-library-preset"
]
}

View File

@ -1,80 +0,0 @@
# [0.1.0-develop.18](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.17...v0.1.0-develop.18) (2023-09-04)
# [0.1.0-develop.17](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.16...v0.1.0-develop.17) (2023-09-03)
### Bug Fixes
* need to slice out the key type byte ([7d0d1b9](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/7d0d1b9b2bec62d369a255cb3a7545febfb4ad56))
# [0.1.0-develop.16](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.15...v0.1.0-develop.16) (2023-09-02)
### Bug Fixes
* if seed is false or 0 as a string, set it to false ([bdbb090](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/bdbb090c7d2764d178f2578c8a1eb792e0a180e9))
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.14...v0.1.0-develop.15) (2023-09-02)
### Bug Fixes
* only submit a new registry entry if the data has changed ([39b0117](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/39b0117e4f02550c9ac7b58961e83b2e82757b41))
# [0.1.0-develop.14](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-09-02)
### Bug Fixes
* need to use the sre.pk not cidBytes ([c65a212](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/c65a212e567e6a9695b9525db70cd09256342293))
# [0.1.0-develop.13](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.12...v0.1.0-develop.13) (2023-09-02)
### Bug Fixes
* restore bootstrap nodes list ([b7caaa0](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/b7caaa09da49dd5a3793711ca5ad24878c9502d8))
# [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-09-02)
### Features
* add support for creating a resolver CID for the module if MODULE_SEED is not false ([fd2ff5c](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/fd2ff5c556c0823ec4d7d91d31146f812f8d508a))
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-08-10)
# [0.1.0-develop.10](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.9...v0.1.0-develop.10) (2023-08-10)
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-06-29)
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-06-29)
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-06-29)
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-06-26)
### Bug Fixes
* fix util import ([ab820fe](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/ab820fe346e4364722d22d83fadaed65d329e3b2))
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-06-26)
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-06-26)
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-06-26)
### Bug Fixes
* check if presetter exists before running bootstrap ([0003b60](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/0003b601847c6e1e29f59bce600c2ccf16c4166b))
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-06-26)
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.0.1...v0.1.0-develop.1) (2023-06-26)
### Features
* initial version ([65f3dcc](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/65f3dcca6fe2cb3d65be7e4dc11e529f1bf06370))

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 Hammer Technologies LLC
Copyright (c) <year> <copyright holders>
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:

19224
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +0,0 @@
{
"name": "@lumeweb/publish-kernel-module",
"version": "0.1.0-develop.18",
"type": "module",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/publish-kernel-module.git"
},
"devDependencies": {
"@lumeweb/node-library-preset": "^0.2.7",
"@types/prompts": "^2.4.4",
"presetter": "*"
},
"readme": "ERROR: No README data found!",
"scripts": {
"prepare": "bash -c 'if command -v presetter &> /dev/null; then presetter bootstrap; fi'",
"build": "run build",
"semantic-release": "semantic-release"
},
"publishConfig": {
"access": "public"
},
"files": [
"lib/**"
],
"dependencies": {
"@lumeweb/libweb": "0.2.0-develop.48",
"@scure/bip39": "^1.2.1",
"chalk": "^5.2.0",
"ed25519-keygen": "^0.4.8",
"memory-level": "^1.0.0",
"p-defer": "^4.0.0",
"prompts": "^2.4.2"
},
"bin": "./lib/index.js"
}

View File

@ -1,203 +0,0 @@
#! /usr/bin/env node
import prompts from "prompts";
import * as process from "process";
import fs from "fs/promises";
import path from "path";
import {
encodeRegistryCid,
encodeRegistryValue,
equalBytes,
hexToBytes,
maybeInitDefaultPortals,
setActivePortalMasterKey,
uploadObject,
} from "@lumeweb/libweb";
import chalk from "chalk";
import * as util from "util";
import { fileExists } from "./utils.js";
import * as bip39 from "@scure/bip39";
import { wordlist } from "@scure/bip39/wordlists/english";
import { HDKey } from "ed25519-keygen/hdkey";
import {
BOOTSTRAP_NODES,
createKeyPair,
createNode,
S5NodeConfig,
SignedRegistryEntry,
} from "@lumeweb/libs5";
import { MemoryLevel } from "memory-level";
import KeyPairEd25519 from "@lumeweb/libs5/lib/ed25519.js";
import defer from "p-defer";
const BIP44_PATH = "m/44'/1627'/0'/0'/0'";
let key = process.env.PORTAL_PRIVATE_KEY;
if (!key) {
// @ts-ignore
key = await prompts.prompts.password({
name: "private_key",
message: "Enter your portal private key",
validate: (prev) => prev && prev.length === 64,
});
}
let seed = process.env.MODULE_SEED;
if (["0", "false"].includes(seed as string)) {
seed = false as any;
}
if (!seed && seed === undefined) {
// @ts-ignore
seed = await prompts.prompts.password({
name: "module_seed",
message: "Enter your module seed",
validate: (prev) => prev && bip39.validateMnemonic(prev, wordlist),
});
}
const hdKey = seed
? HDKey.fromMasterSeed(await bip39.mnemonicToSeed(seed as string)).derive(
BIP44_PATH,
)
: false;
let file = process.env.MODULE_FILE;
if (!file || !(await fileExists(file))) {
const cwd = process.cwd();
const locations = [
"dist/module.js",
"dist/index.js",
"lib/module.js",
"lib/index.js",
];
const promises = locations.map((item) => {
item = path.join(cwd, item);
return [item, fileExists(item)];
});
const pResults: boolean[] = await Promise.all(
promises.map((item) => item[1] as Promise<boolean>),
);
const results = pResults.reduce((prev, cur, index) => {
if (cur) {
prev.push(locations[index]);
}
return prev;
}, [] as any);
if (!results.length) {
console.error("Kernel module could not be found");
process.exit(1);
}
file = results[0];
}
setActivePortalMasterKey(hexToBytes(key as string));
maybeInitDefaultPortals();
const fd = await fs.open(file as string);
const [cid, err] = await uploadObject(
fd.createReadStream(),
BigInt((await fd.stat()).size),
);
if (err) {
console.error("Failed to publish: ", err);
}
console.log(
util.format(
"%s: %s",
chalk.green("Kernel module successfully published"),
cid,
),
);
if (!hdKey) {
process.exit(0);
}
const db = new MemoryLevel<string, Uint8Array>({
storeEncoding: "view",
valueEncoding: "buffer",
});
await db.open();
let config = {
keyPair: createKeyPair(),
db,
p2p: {
peers: {
initial: [...BOOTSTRAP_NODES],
},
},
logger: {
info: (s: string) => {},
verbose: (s: string) => {},
warn: (s: string) => {},
error: (s: string) => {},
catched: (e: any, context?: string | null) => {},
},
} as S5NodeConfig;
const node = createNode(config);
await node.start();
const peerDefer = defer();
node.services.p2p.once("peerConnected", peerDefer.resolve);
await peerDefer.promise;
{
const key = hdKey as HDKey;
let revision = 0;
let sre: SignedRegistryEntry;
const ret = await node.services.registry.get(
new KeyPairEd25519(key.privateKey).publicKey,
);
if (ret) {
revision = ret.revision + 1;
}
let [newEntry, err] = encodeRegistryValue(cid);
if (err) {
throw new Error(err);
}
if (!equalBytes(ret?.data ?? new Uint8Array(), newEntry)) {
sre = node.services.registry.signRegistryEntry({
kp: new KeyPairEd25519((hdKey as HDKey).privateKey),
data: newEntry,
revision,
});
await node.services.registry.set(sre);
} else {
sre = ret as SignedRegistryEntry;
}
let resolverCid;
[resolverCid, err] = encodeRegistryCid(sre.pk);
if (err) {
throw new Error(err);
}
console.log(
util.format("%s: %s", chalk.green("Resolver entry"), resolverCid),
);
await node.stop();
}

View File

@ -1,11 +0,0 @@
import fs from "fs/promises";
export async function fileExists(path: string) {
try {
await fs.stat(path);
} catch {
return false;
}
return true;
}