Compare commits
74 Commits
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | 7c90b7e7b3 | |
Derrick Hammer | 534a6accf1 | |
Derrick Hammer | 5227acb287 | |
semantic-release-bot | 481477cc05 | |
Derrick Hammer | eeb8e35bf9 | |
Derrick Hammer | a3cc5c1c71 | |
semantic-release-bot | 98c44d6ccc | |
Derrick Hammer | 8494313abd | |
Derrick Hammer | e8b3e03e7b | |
Derrick Hammer | 3eda1bbc37 | |
Derrick Hammer | f68656fabd | |
semantic-release-bot | d033360604 | |
Derrick Hammer | 1c2fc98799 | |
Derrick Hammer | 9844d8edae | |
semantic-release-bot | dc081553f3 | |
Derrick Hammer | a5818bc17d | |
Derrick Hammer | f0ecd5a3ba | |
Derrick Hammer | 0825f4c35d | |
Derrick Hammer | e9e05b4caf | |
Derrick Hammer | db24524f87 | |
Derrick Hammer | dc5e44eb14 | |
semantic-release-bot | 70069471d0 | |
Derrick Hammer | 23b10c1c1d | |
Derrick Hammer | 7d0d1b9b2b | |
Derrick Hammer | 3b70ba00af | |
Derrick Hammer | 5895485467 | |
semantic-release-bot | 8305d21af2 | |
Derrick Hammer | 15dc2382f0 | |
Derrick Hammer | bdbb090c7d | |
semantic-release-bot | d9f2221272 | |
Derrick Hammer | 98a91cc873 | |
Derrick Hammer | 39b0117e4f | |
semantic-release-bot | 49c2e1430f | |
Derrick Hammer | 704e78b421 | |
Derrick Hammer | c65a212e56 | |
semantic-release-bot | 5d79fed53a | |
Derrick Hammer | ab785eab9d | |
Derrick Hammer | b7caaa09da | |
semantic-release-bot | dfb3764a59 | |
Derrick Hammer | 6e84338ddc | |
Derrick Hammer | fd2ff5c556 | |
semantic-release-bot | cb3e0b54f2 | |
Derrick Hammer | a2f9e9aeff | |
Derrick Hammer | eceed29613 | |
semantic-release-bot | f46cc8f19e | |
Derrick Hammer | a5d211bd8e | |
Derrick Hammer | f65590e494 | |
semantic-release-bot | 8e6e62c5ae | |
Derrick Hammer | a522175336 | |
semantic-release-bot | 1284575571 | |
Derrick Hammer | 225e97f932 | |
Derrick Hammer | 0c556e4f79 | |
semantic-release-bot | 73fc94ca0c | |
Derrick Hammer | 774082b901 | |
semantic-release-bot | dba6bc4c10 | |
Derrick Hammer | 1ac101396a | |
Derrick Hammer | ab820fe346 | |
semantic-release-bot | fce3907be6 | |
Derrick Hammer | 934cff2aa8 | |
Derrick Hammer | c1d0857b35 | |
Derrick Hammer | 6782f649d6 | |
Derrick Hammer | 74674c91cb | |
semantic-release-bot | fbb0990c12 | |
Derrick Hammer | 43570de7c2 | |
Derrick Hammer | d8fe7cb912 | |
semantic-release-bot | b2127c9db8 | |
Derrick Hammer | 41f3204fee | |
Derrick Hammer | 0003b60184 | |
semantic-release-bot | e43062cf87 | |
Derrick Hammer | 09ba506c76 | |
Derrick Hammer | 233b989212 | |
semantic-release-bot | fceb7e1987 | |
Derrick Hammer | c914ed92d9 | |
Derrick Hammer | 65f3dcca6f |
|
@ -0,0 +1,13 @@
|
||||||
|
name: Build/Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- develop-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
|
||||||
|
secrets: inherit
|
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"preset": [
|
||||||
|
"@lumeweb/node-library-preset"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
# [0.1.0-develop.22](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.21...v0.1.0-develop.22) (2023-09-11)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* cid is a CID instance already ([5227acb](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/5227acb2876f97ccf041bfe6f4c63622294b003e))
|
||||||
|
|
||||||
|
# [0.1.0-develop.21](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.20...v0.1.0-develop.21) (2023-09-11)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* resolverCid needs to be in string format ([a3cc5c1](https://git.lumeweb.com/LumeWeb/publish-kernel-module/commit/a3cc5c1c71c6665d1b0af165b0e4395058a60ff0))
|
||||||
|
|
||||||
|
# [0.1.0-develop.20](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.19...v0.1.0-develop.20) (2023-09-11)
|
||||||
|
|
||||||
|
# [0.1.0-develop.19](https://git.lumeweb.com/LumeWeb/publish-kernel-module/compare/v0.1.0-develop.18...v0.1.0-develop.19) (2023-09-04)
|
||||||
|
|
||||||
|
# [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))
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) <year> <copyright holders>
|
Copyright (c) 2023 Hammer Technologies LLC
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"name": "@lumeweb/publish-kernel-module",
|
||||||
|
"version": "0.1.0-develop.22",
|
||||||
|
"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.58",
|
||||||
|
"@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"
|
||||||
|
}
|
|
@ -0,0 +1,212 @@
|
||||||
|
#! /usr/bin/env node
|
||||||
|
|
||||||
|
import prompts from "prompts";
|
||||||
|
import * as process from "process";
|
||||||
|
import fs from "fs/promises";
|
||||||
|
import path from "path";
|
||||||
|
import {
|
||||||
|
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,
|
||||||
|
CID,
|
||||||
|
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) {
|
||||||
|
const seedFile = path.join(process.cwd(), ".module-seed");
|
||||||
|
if (await fileExists(seedFile)) {
|
||||||
|
seed = await fs.readFile(seedFile, "utf8");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!seed) {
|
||||||
|
seed = bip39.generateMnemonic(wordlist);
|
||||||
|
await fs.writeFile(seedFile, seed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
let cid: CID;
|
||||||
|
|
||||||
|
try {
|
||||||
|
cid = await uploadObject(
|
||||||
|
fd.createReadStream(),
|
||||||
|
BigInt((await fd.stat()).size),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to publish: ", e.message);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
try {
|
||||||
|
newEntry = cid.toRegistryEntry();
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to publish: ", e.message);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
try {
|
||||||
|
resolverCid = CID.fromRegistryPublicKey(sre.pk).toString();
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Failed to publish: ", e.message);
|
||||||
|
process.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
util.format("%s: %s", chalk.green("Resolver entry"), resolverCid),
|
||||||
|
);
|
||||||
|
await node.stop();
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
import fs from "fs/promises";
|
||||||
|
|
||||||
|
export async function fileExists(path: string) {
|
||||||
|
try {
|
||||||
|
await fs.stat(path);
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
Loading…
Reference in New Issue