Compare commits

..

34 Commits

Author SHA1 Message Date
semantic-release-bot 7268fb919a chore(release): 0.0.2-develop.7 [skip ci]
## [0.0.2-develop.7](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.6...v0.0.2-develop.7) (2023-10-13)
2023-10-13 10:01:39 +00:00
Derrick Hammer 114280ec3e
Merge remote-tracking branch 'origin/develop' into develop 2023-10-13 06:00:24 -04:00
Derrick Hammer b2ee6ec1b7
dep: update kernel-peer-discovery-client 2023-10-13 06:00:19 -04:00
semantic-release-bot aeaa7daaf2 chore(release): 0.0.2-develop.6 [skip ci]
## [0.0.2-develop.6](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.5...v0.0.2-develop.6) (2023-09-04)
2023-09-04 09:23:14 +00:00
Derrick Hammer f86e9a2cc1
Merge remote-tracking branch 'origin/develop' into develop 2023-09-04 05:21:42 -04:00
Derrick Hammer d6a28334be
dep: update libkernel 2023-09-04 05:21:38 -04:00
semantic-release-bot b80f423cbd chore(release): 0.0.2-develop.5 [skip ci]
## [0.0.2-develop.5](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.4...v0.0.2-develop.5) (2023-09-03)
2023-09-03 06:15:30 +00:00
Derrick Hammer 72c0402ad4
Merge remote-tracking branch 'origin/develop' into develop 2023-09-03 02:14:29 -04:00
Derrick Hammer 17ad5056ce
dep: update kernel-peer-discovery-client 2023-09-03 02:14:24 -04:00
semantic-release-bot 8abb1f63c5 chore(release): 0.0.2-develop.4 [skip ci]
## [0.0.2-develop.4](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.3...v0.0.2-develop.4) (2023-09-03)

### Bug Fixes

* add try/catch to DiscoveryIRC ([6221a1a](6221a1a267))
2023-09-03 04:54:17 +00:00
Derrick Hammer a82f081c8a
dep: update kernel-peer-discovery-client and libkernel 2023-09-03 00:53:13 -04:00
Derrick Hammer fa421f5930
Merge remote-tracking branch 'origin/develop' into develop 2023-09-03 00:52:22 -04:00
Derrick Hammer 5ce5f288c5
dep: update kernel-peer-discovery-client and libkernel 2023-09-03 00:52:15 -04:00
Derrick Hammer b30addc7e8
dep: update kernel-peer-discovery-client and libkernel 2023-09-02 09:35:53 -04:00
Derrick Hammer 6221a1a267
fix: add try/catch to DiscoveryIRC 2023-07-20 12:56:05 -04:00
semantic-release-bot 53dfa81a9e chore(release): 0.0.2-develop.3 [skip ci]
## [0.0.2-develop.3](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.2...v0.0.2-develop.3) (2023-07-12)
2023-07-12 11:30:57 +00:00
Derrick Hammer 72bfcfa13d
dep: update peer-discovery-irc 2023-07-12 07:29:30 -04:00
Derrick Hammer 922d837713
ci: add alias for chardet fork 2023-07-12 07:05:14 -04:00
Derrick Hammer 8fe25e9cc1
Merge remote-tracking branch 'origin/develop' into develop 2023-07-12 06:19:45 -04:00
Derrick Hammer 2df8ee620e
dep update kernel-peer-discovery-client 2023-07-12 06:19:34 -04:00
Derrick Hammer c97ce30c2e
ci: add vite.config.js as an actual file 2023-07-12 04:46:26 -04:00
Derrick Hammer 4669a13c49
dep: update deps and add chardet fork @lumeweb/chardet 2023-07-12 04:45:48 -04:00
Derrick Hammer 0e310e4746
ci: add custom vite config 2023-07-12 03:31:02 -04:00
Derrick Hammer 4b36dcf891
ci: switch to vite 2023-07-12 03:29:57 -04:00
Derrick Hammer bf865c2c42
dep: update deps 2023-07-12 03:29:38 -04:00
semantic-release-bot 68e7165bb2 chore(release): 0.0.2-develop.2 [skip ci]
## [0.0.2-develop.2](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.1...v0.0.2-develop.2) (2023-07-04)

### Bug Fixes

* need to update build configuration, and use a custom rollup ([0f93183](0f9318306f))
2023-07-04 04:57:27 +00:00
Derrick Hammer 144474c621
Merge remote-tracking branch 'origin/develop' into develop 2023-07-04 00:56:13 -04:00
Derrick Hammer 0f9318306f
fix: need to update build configuration, and use a custom rollup 2023-07-04 00:56:03 -04:00
Derrick Hammer 7697a03722
dep: update deps 2023-07-04 00:54:47 -04:00
Derrick Hammer 589d6395db
dep: update deps 2023-07-02 18:15:08 -04:00
semantic-release-bot c29d215588 chore(release): 0.0.2-develop.1 [skip ci]
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.1...v0.0.2-develop.1) (2023-07-01)
2023-07-01 22:22:55 +00:00
Derrick Hammer b4db108103
refactor: move to new sdks and portal 2023-07-01 18:21:48 -04:00
Derrick Hammer 548fb9843d
*Update deps 2023-03-16 14:38:10 -04:00
Derrick Hammer 95428a77de
*Update deps 2023-03-16 14:36:46 -04:00
14 changed files with 21989 additions and 1827 deletions

13
.github/workflows/ci.yml vendored Normal file
View File

@ -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

15
.presetterrc.json Normal file
View File

@ -0,0 +1,15 @@
{
"preset": [
"@lumeweb/presetter-kernel-module-preset"
],
"config": {
"vite": {
"resolve": {
"alias": {
"tls": "./build/net.js",
"net": "./build/net.js"
}
}
}
}
}

23
CHANGELOG.md Normal file
View File

@ -0,0 +1,23 @@
## [0.0.2-develop.7](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.6...v0.0.2-develop.7) (2023-10-13)
## [0.0.2-develop.6](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.5...v0.0.2-develop.6) (2023-09-04)
## [0.0.2-develop.5](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.4...v0.0.2-develop.5) (2023-09-03)
## [0.0.2-develop.4](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.3...v0.0.2-develop.4) (2023-09-03)
### Bug Fixes
* add try/catch to DiscoveryIRC ([6221a1a](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/commit/6221a1a2671892df8a42a3c98057a8b5f1ea0597))
## [0.0.2-develop.3](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.2...v0.0.2-develop.3) (2023-07-12)
## [0.0.2-develop.2](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.2-develop.1...v0.0.2-develop.2) (2023-07-04)
### Bug Fixes
* need to update build configuration, and use a custom rollup ([0f93183](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/commit/0f9318306ffd52f4020391e39cd04545e7a42c72))
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/kernel-discovery-irc/compare/v0.0.1...v0.0.2-develop.1) (2023-07-01)

View File

@ -1,8 +0,0 @@
import esbuild from "esbuild";
esbuild.buildSync({
entryPoints: ["src/index.ts"],
outfile: "dist/index.js",
format: "iife",
bundle: true,
});

21878
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +1,25 @@
{ {
"name": "@lumeweb/kernel-discovery-irc", "name": "@lumeweb/kernel-discovery-irc",
"version": "0.1.0", "version": "0.0.2-develop.7",
"type": "module", "type": "module",
"scripts": { "scripts": {
"test": "jest", "prepare": "presetter bootstrap",
"build-script": "tsc && tsc --project tsconfig.build.json && mv dist-build/build.js dist-build/build.mjs", "build": "run build",
"compile": "pnpm run build-script && node build.js && rm -rf build/", "semantic-release": "semantic-release"
"build": "pnpm run compile && node ./dist-build/build.mjs dev"
},
"dependencies": {
"@ctrl/irc": "2.1.0",
"@lumeweb/kernel-peer-discovery-client": "git+https://git.lumeweb.com/LumeWeb/kernel-peer-discovery-client.git",
"@lumeweb/peer-discovery-irc": "git+https://git.lumeweb.com/LumeWeb/peer-discovery-irc.git",
"libkmodule": "^0.2.53",
"streamx": "^2.13.2"
}, },
"devDependencies": { "devDependencies": {
"@scure/bip39": "^1.1.0", "@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.43",
"@skynetlabs/skynet-nodejs": "^2.9.0", "presetter": "*"
"@types/node": "^18.11.18",
"@types/read": "^0.0.29",
"@types/streamx": "^2.9.1",
"buffer": "^6.0.3",
"cli-progress": "^3.11.2",
"crypto-browserify": "^3.12.0",
"esbuild": "^0.17.5",
"events": "^3.3.0",
"read": "^2.0.0",
"string_decoder": "^1.3.0",
"typescript": "^4.9.5"
}, },
"browser": { "readme": "ERROR: No README data found!",
"crypto": false, "dependencies": {
"net": "./build/net.js", "@lumeweb/chardet": "^1.6.1",
"tls": "./build/net.js" "@lumeweb/kernel-peer-discovery-client": "^0.0.2-develop.18",
"@lumeweb/libkernel": "^0.1.0-develop.44",
"@lumeweb/peer-discovery-irc": "^0.0.2-develop.7"
}, },
"pnpm": { "repository": {
"patchedDependencies": { "type": "git",
"@ctrl/irc@2.1.0": "patches/@ctrl__irc@2.1.0.patch", "url": "gitea@git.lumeweb.com:LumeWeb/kernel-discovery-irc.git"
"b4a@1.6.1": "patches/b4a@1.6.1.patch"
}
} }
} }

View File

@ -1,12 +0,0 @@
diff --git a/dist/src/irc.js b/dist/src/irc.js
index fd7a55d6bb09a961921e58e6bff1a7028c61bb47..c96cbca5e904b5ba0312d7ae273e537e66e22fb9 100644
--- a/dist/src/irc.js
+++ b/dist/src/irc.js
@@ -9,6 +9,7 @@ import defaultsdeep from 'lodash.defaultsdeep';
import { TypedEmitter } from 'tiny-typed-emitter';
import { CyclingPingTimer } from './cyclingPingTimer.js';
import { parseMessage } from './parseMessage.js';
+import { Buffer } from 'buffer';
const log = debug('irc');
const lineDelimiter = new RegExp(/\r\n|\r|\n/);
const defaultOptions = {

View File

@ -1,36 +0,0 @@
diff --git a/browser.js b/browser.js
index e07f78d17b7b4a2963e4f0062047cc96e6025f9e..a9f266a2644f3f8ebd0f6684b3e11a7519059851 100644
--- a/browser.js
+++ b/browser.js
@@ -3,6 +3,7 @@ const base64 = require('./lib/base64')
const hex = require('./lib/hex')
const utf8 = require('./lib/utf8')
const utf16le = require('./lib/utf16le')
+const Buffer = require('buffer').Buffer
const LE = new Uint8Array(Uint16Array.of(0xff).buffer)[0] === 0xff
diff --git a/index.js b/index.js
index a751d6b4d27c7dd903efbfdc87a98f61044a62b8..8bd32640afdcfbc475168d458c51f8b9162d1656 100644
--- a/index.js
+++ b/index.js
@@ -1,3 +1,5 @@
+const Buffer = require('buffer').Buffer
+
function isBuffer (value) {
return Buffer.isBuffer(value) || value instanceof Uint8Array
}
diff --git a/package.json b/package.json
index eb0f792709b27e66f26658054781b4099507b5ed..69c4ff39c48b0bdd5f0bc7ebbade517e7c5d76e4 100644
--- a/package.json
+++ b/package.json
@@ -8,9 +8,6 @@
"index.js",
"lib"
],
- "browser": {
- "./index.js": "./browser.js"
- },
"scripts": {
"test": "standard && brittle test/*.mjs"
},

File diff suppressed because it is too large Load Diff

View File

@ -1,218 +0,0 @@
// This is the standard build script for a kernel module.
import * as fs from "fs";
import read from "read";
import * as bip39 from "@scure/bip39";
import { wordlist } from "@scure/bip39/wordlists/english.js";
//@ts-ignore
import { SkynetClient } from "@skynetlabs/skynet-nodejs";
// Helper variables to make it easier to return empty values alongside errors.
const nu8 = new Uint8Array(0);
const nkp = {
publicKey: nu8,
secretKey: nu8,
};
// readFile is a wrapper for fs.readFileSync that handles the try-catch for the
// caller.
function readFile(fileName: string): [string, string | null] {
try {
let data = fs.readFileSync(fileName, "utf8");
return [data, null];
} catch (err) {
return ["", "unable to read file: " + JSON.stringify(err)];
}
}
// readFileBinary is a wrapper for fs.readFileSync that handles the try-catch
// for the caller.
function readFileBinary(fileName: string): [Uint8Array, string | null] {
try {
let data = fs.readFileSync(fileName, null);
return [data, null];
} catch (err) {
return [nu8, "unable to read file: " + JSON.stringify(err)];
}
}
// writeFile is a wrapper for fs.writeFileSync which handles the try-catch in a
// non-exception way.
function writeFile(fileName: string, fileData: string): string | null {
try {
fs.writeFileSync(fileName, fileData);
return null;
} catch (err) {
return "unable to write file: " + JSON.stringify(err);
}
}
// handlePass handles all portions of the script that occur after the password
// has been requested. If no password needs to be requested, handlePass will be
// called with a null input. We need to structure the code this way because the
// password reader is async and we can only access the password when using a
// callback.
function handlePass(password: string) {
try {
// If we are running prod and the seed file does not exist, we
// need to confirm the password and also warn the user to use a
// secure password.
if (!fs.existsSync(seedFile) && process.argv[2] === "prod") {
// The file does not exist, we need to confirm the
// password.
console.log();
console.log(
"No production entry found for module. Creating new production module..."
);
console.log(
"If someone can guess the password, they can push arbitrary changes to your module."
);
console.log("Please use a secure password.");
console.log();
read(
{ prompt: "Confirm Password: ", silent: true },
function (err: any, confirmPassword: string) {
if (err) {
console.error("unable to fetch password:", err);
process.exit(1);
}
if (password !== confirmPassword) {
console.error("passwords do not match");
process.exit(1);
}
handlePassConfirm(moduleSalt, password);
}
);
} else {
// If the seed file does exist, or if we are using dev,
// there's no need to confirm the password but we do
// need to pass the logic off to the handlePassConfirm
// callback.
handlePassConfirm(moduleSalt, password);
}
} catch (err) {
console.error("Unable to read seedFile:", err);
process.exit(1);
}
}
// handlePassConfirm handles the full script after the confirmation password
// has been provided. If not confirmation password is needed, this function
// will be called anyway using the unconfirmed password as input.
function handlePassConfirm(seed: string, password: string) {
// Create the seedFile if it does not exist. For dev we just save the
// seed to disk outright, because this is a dev build and therefore not
// security sensitive. Also the dev seed does not get pushed to the
// github repo.
//
// For prod, we use the seed to create a new seed (called the shield)
// which allows us to verify that the developer has provided the right
// password when deploying the module. The shield does get pushed to
// the github repo so that the production module is the same on all
// devices.
if (!fs.existsSync(seedFile) && process.argv[2] !== "prod") {
// Generate the seed phrase and write it to the file.
let seedPhrase = bip39.generateMnemonic(wordlist);
let errWF = writeFile(seedFile, seedPhrase);
if (errWF !== null) {
console.error("unable to write file:", errWF);
process.exit(1);
}
} else if (!fs.existsSync(seedFile) && process.argv[2] === "prod") {
// Generate the seed phrase.
let seedPhrase = bip39.generateMnemonic(wordlist);
// Write the registry link to the file.
}
// Load or verify the seed. If this is prod, the password is used to
// create and verify the seed. If this is dev, we just load the seed
// with no password.
let seedPhrase: string;
let registryLink: string;
if (process.argv[2] === "prod") {
// Generate the seed phrase from the password.
seedPhrase = bip39.generateMnemonic(wordlist);
} else {
let [sp, errRF] = readFile(seedFile);
if (errRF !== null) {
console.error("unable to read seed phrase for dev command from disk");
process.exit(1);
}
seedPhrase = sp;
}
let metadata = {
Filename: "index.js",
};
const client = new SkynetClient("https://web3portal.com");
client
.uploadFile("dist/index.js")
.then((result: any) => {
console.log("Immutable Link for module:", result);
})
.catch((err: any) => {
console.error("unable to upload file", err);
process.exit(1);
});
}
// Add a newline for readability.
console.log();
// Check for a 'dev' or 'prod' input to the script.
if (process.argv.length !== 3) {
console.error("need to provide either 'dev' or 'prod' as an input");
process.exit(1);
}
// Create the build folder if it does not exist.
if (!fs.existsSync("build")) {
fs.mkdirSync("build");
}
// Determine the seed file.
let seedFile: string;
if (process.argv[2] === "prod") {
seedFile = "module-skylink";
} else if (process.argv[2] === "dev") {
seedFile = "build/dev-seed";
} else {
console.error("need to provide either 'dev' or 'prod' as an input");
process.exit(1);
}
// If doing a prod deployment, check whether the salt file exists. If it does
// not, create it.
let moduleSalt: string;
if (!fs.existsSync(".module-salt")) {
moduleSalt = bip39.generateMnemonic(wordlist);
let errWF = writeFile(".module-salt", moduleSalt);
if (errWF !== null) {
console.error("unable to write module salt file:", errWF);
process.exit(1);
}
} else {
let [ms, errRF] = readFile(".module-salt");
if (errRF !== null) {
console.error("unable to read moduleSalt");
process.exit(1);
}
ms = ms.replace(/\n$/, "");
moduleSalt = ms;
}
// Need to get a password if this is a prod build.
if (process.argv[2] === "prod") {
read(
{ prompt: "Password: ", silent: true },
function (err: any, password: string) {
if (err) {
console.error("unable to fetch password:", err);
process.exit(1);
}
handlePass(password);
}
);
} else {
handlePass("");
}

View File

@ -1,7 +1,6 @@
import type { ActiveQuery } from "libkmodule"; import type { ActiveQuery } from "@lumeweb/libkernel/module";
import { addHandler, callModule } from "libkmodule"; import { addHandler, handleMessage } from "@lumeweb/libkernel/module";
import DiscoveryIRC from "@lumeweb/peer-discovery-irc"; import DiscoveryIRC from "@lumeweb/peer-discovery-irc";
import { handleMessage } from "libkmodule";
import { createClient } from "@lumeweb/kernel-peer-discovery-client"; import { createClient } from "@lumeweb/kernel-peer-discovery-client";
onmessage = handleMessage; onmessage = handleMessage;
@ -42,12 +41,16 @@ async function handleDiscover(aq: ActiveQuery): Promise<void> {
return; return;
} }
try {
const ret = await DiscoveryIRC(aq.callerInput.pubkey, { const ret = await DiscoveryIRC(aq.callerInput.pubkey, {
host: "liberta.casa", host: "liberta.casa",
...aq.callerInput?.options, ...aq.callerInput?.options,
}); });
aq.respond(ret); aq.respond(ret);
} catch (e) {
aq.reject(e);
}
} }
addHandler("register", handleRegister); addHandler("register", handleRegister);

View File

@ -1,14 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"declaration": true,
"outDir": "./dist-build",
"strict": true,
"esModuleInterop": true
},
"include": ["src-build"],
"exclude": ["node_modules", "**/__tests__/*"]
}

View File

@ -1,13 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"declaration": true,
"moduleResolution": "nodenext",
"outDir": "./build",
"strict": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"]
}

34
vite.config.js Normal file
View File

@ -0,0 +1,34 @@
import { defineConfig } from "vite";
import optimizer from "vite-plugin-optimizer";
import inject from "@rollup/plugin-inject";
export default defineConfig({
build: {
outDir: "lib",
lib: {
entry: "build/index.js",
name: "main",
formats: ["cjs"],
fileName: "index",
},
minify: false,
rollupOptions: { output: { inlineDynamicImports: true } },
},
resolve: {
dedupe: ["@lumeweb/libportal", "@lumeweb/libweb", "@lumeweb/libkernel"],
alias: {
tls: "./build/net.js",
net: "./build/net.js",
chardet: "@lumeweb/chardet",
},
},
plugins: [
optimizer({
"node-fetch":
"const e = undefined; export default e;export {e as Response, e as FormData, e as Blob};",
}),
inject({
Buffer: ["buffer", "Buffer"],
}),
],
});