Compare commits

..

66 Commits

Author SHA1 Message Date
semantic-release-bot f39c0ad2e7 chore(release): 0.1.0-develop.12 [skip ci]
# [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-10-15)
2023-10-15 01:00:00 +00:00
Derrick Hammer cd637f4cbd
Merge remote-tracking branch 'origin/develop' into develop 2023-10-14 20:57:11 -04:00
Derrick Hammer 7c1a2132cf
dep: update deps 2023-10-14 20:57:06 -04:00
semantic-release-bot 2adee6d789 chore(release): 0.1.0-develop.11 [skip ci]
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-10-12)
2023-10-12 12:10:49 +00:00
Derrick Hammer d5417ede96
Merge remote-tracking branch 'origin/develop' into develop 2023-10-12 08:07:50 -04:00
Derrick Hammer f38d4fa661
dep: update kernel-protomux-client and kernel-swarm-client 2023-10-12 08:06:13 -04:00
Derrick Hammer 1522af9cdc
dep: update kernel-network-registry-client 2023-10-12 07:57:34 -04:00
semantic-release-bot ceafebc7c4 chore(release): 0.1.0-develop.10 [skip ci]
# [0.1.0-develop.10](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.9...v0.1.0-develop.10) (2023-09-16)

### Bug Fixes

* creating chainProgressListener event handler wrong ([e0d3a3d](e0d3a3de8f))
2023-09-16 22:02:32 +00:00
Derrick Hammer 10a3f87fcd
Merge remote-tracking branch 'origin/develop' into develop 2023-09-16 17:59:50 -04:00
Derrick Hammer e0d3a3de8f
fix: creating chainProgressListener event handler wrong 2023-09-16 17:59:44 -04:00
Derrick Hammer 1d0445c63b
dep: update hsd 2023-09-16 17:59:21 -04:00
semantic-release-bot 6a553a143f chore(release): 0.1.0-develop.9 [skip ci]
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-09-09)
2023-09-09 21:32:37 +00:00
Derrick Hammer a68a61569c
Merge remote-tracking branch 'origin/develop' into develop 2023-09-09 17:30:16 -04:00
Derrick Hammer 6685d4e028
dep: update kernel-network-registry-client 2023-09-09 17:30:12 -04:00
Derrick Hammer debfdcd1a5
dep: update deps 2023-09-03 01:23:43 -04:00
semantic-release-bot 96f043d240 chore(release): 0.1.0-develop.8 [skip ci]
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-09-02)
2023-09-02 17:37:57 +00:00
Derrick Hammer e8e618d731
Merge remote-tracking branch 'origin/develop' into develop 2023-09-02 13:35:25 -04:00
Derrick Hammer fc5677cd17
dep: update deps 2023-09-02 13:34:53 -04:00
semantic-release-bot 0c593b66be chore(release): 0.1.0-develop.7 [skip ci]
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-08-04)

### Bug Fixes

* we need flag ad and rd on the dns query. rd is to request recursive lookup and ad is to ensure we only get DNSSEC responses ([67025f0](67025f0f68))
* we need to override the tcp client on the NS icann resolver to pipe connections properly ([1a80319](1a803193e6))
2023-08-04 15:37:14 +00:00
Derrick Hammer f716f325e5
Merge remote-tracking branch 'origin/develop' into develop 2023-08-04 11:34:53 -04:00
Derrick Hammer 67025f0f68
fix: we need flag ad and rd on the dns query. rd is to request recursive lookup and ad is to ensure we only get DNSSEC responses 2023-08-04 11:34:42 -04:00
Derrick Hammer 1a803193e6
fix: we need to override the tcp client on the NS icann resolver to pipe connections properly 2023-08-04 11:33:40 -04:00
semantic-release-bot efd0eb6b81 chore(release): 0.1.0-develop.6 [skip ci]
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-08-03)

### Bug Fixes

* if the ad flag is not set (no dnssec) return an empty result for security ([cd571db](cd571dbceb))
2023-08-03 19:10:41 +00:00
Derrick Hammer 279de558d7
Merge remote-tracking branch 'origin/develop' into develop 2023-08-03 15:07:51 -04:00
Derrick Hammer cd571dbceb
fix: if the ad flag is not set (no dnssec) return an empty result for security 2023-08-03 15:07:43 -04:00
semantic-release-bot 217e81c795 chore(release): 0.1.0-develop.5 [skip ci]
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-08-02)

### Bug Fixes

* add a patch for bns to export TCPSocket ([aaee3ac](aaee3acb92))
* add b4a patch ([e31973b](e31973be70))
2023-08-02 21:34:23 +00:00
Derrick Hammer 574ba8afa3
Merge remote-tracking branch 'origin/develop' into develop 2023-08-02 17:32:11 -04:00
Derrick Hammer e31973be70
fix: add b4a patch 2023-08-02 17:32:05 -04:00
Derrick Hammer aaee3acb92
fix: add a patch for bns to export TCPSocket 2023-08-02 17:22:27 -04:00
semantic-release-bot 384ef16e22 chore(release): 0.1.0-develop.4 [skip ci]
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-08-02)

### Bug Fixes

* use removeListener ([2eef509](2eef5099c8))

### Features

* add dns query api that uses mock sockets and a dedicated hyper proxy for DNS (port 53) requests ([d675a44](d675a44b4e))
2023-08-02 21:06:17 +00:00
Derrick Hammer d675a44b4e
feat: add dns query api that uses mock sockets and a dedicated hyper proxy for DNS (port 53) requests 2023-08-02 17:03:06 -04:00
Derrick Hammer 8bcb788286
dep: update deps and add streamx 2023-08-02 17:01:43 -04:00
Derrick Hammer d1e1ce624d
Merge remote-tracking branch 'origin/develop' into develop 2023-07-31 14:33:31 -04:00
Derrick Hammer 2eef5099c8
fix: use removeListener 2023-07-31 14:33:05 -04:00
Derrick Hammer 9882489bd9
dep: update presetter-kernel-module-preset 2023-07-29 14:07:51 -04:00
semantic-release-bot e521dad5db chore(release): 0.1.0-develop.3 [skip ci]
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-07-29)

### Features

* add name api ([e612211](e6122110c5))
2023-07-29 16:51:37 +00:00
Derrick Hammer 57120d823e
dep: update kernel-swarm-client 2023-07-29 12:49:19 -04:00
Derrick Hammer e6122110c5
feat: add name api 2023-07-28 23:30:08 -04:00
Derrick Hammer 8c9ae3f97a
Merge remote-tracking branch 'origin/develop' into develop 2023-07-24 13:44:13 -04:00
Derrick Hammer 4dc3f531c4
dep: update kernel-protomux-client and kernel-swarm-client 2023-07-24 13:44:09 -04:00
semantic-release-bot 2b55be561e chore(release): 0.1.0-develop.2 [skip ci]
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-07-23)
2023-07-23 18:58:56 +00:00
Derrick Hammer 8035037e90
Merge remote-tracking branch 'origin/develop' into develop 2023-07-23 14:55:50 -04:00
Derrick Hammer 35fb34e750
dep: update kernel-protomux-client and kernel-swarm-client 2023-07-23 14:55:46 -04:00
semantic-release-bot 6c5bf40bd1 chore(release): 0.1.0-develop.1 [skip ci]
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.0.2-develop.1...v0.1.0-develop.1) (2023-07-23)

### Bug Fixes

* await swarm.join ([f08c87c](f08c87c184))
* need to override protomux with our kernel-protomux-client ([61050a5](61050a5a05))

### Features

* add registry api for use with network registry ([f5ce851](f5ce8518bb))
* add status api ([024c810](024c810edf))
2023-07-23 12:57:54 +00:00
Derrick Hammer 024c810edf
feat: add status api 2023-07-23 08:49:33 -04:00
Derrick Hammer cfeb769924
dep: update kernel-network-registry-client 2023-07-22 21:01:14 -04:00
Derrick Hammer ad4eaa4c0a
dep: update kernel-swarm-client 2023-07-22 20:18:03 -04:00
Derrick Hammer 61050a5a05
fix: need to override protomux with our kernel-protomux-client 2023-07-22 20:06:35 -04:00
Derrick Hammer f98b0c59f3
dep: update kernel-swarm-client 2023-07-22 08:36:10 -04:00
Derrick Hammer 139cd814d4
dep: update kernel-swarm-client 2023-07-22 07:18:47 -04:00
Derrick Hammer 95bcdeebb5
dep: kernel-swarm-client 2023-07-22 05:52:14 -04:00
Derrick Hammer c0b91f502a
dep: kernel-swarm-client 2023-07-21 20:36:59 -04:00
Derrick Hammer 7e919a39a8
dep: update kernel-network-registry-client 2023-07-21 13:30:31 -04:00
Derrick Hammer 4fbd78943a
dep: update kernel-network-registry-client 2023-07-19 13:39:21 -04:00
Derrick Hammer f5ce8518bb
feat: add registry api for use with network registry 2023-07-19 12:16:06 -04:00
Derrick Hammer 0a7ceecd9c
dep: update deps 2023-07-12 06:41:18 -04:00
Derrick Hammer 0b8718cf9a
dep: update deps 2023-07-08 07:54:14 -04:00
Derrick Hammer ccf70212f1
Merge remote-tracking branch 'origin/develop' into develop
# Conflicts:
#	npm-shrinkwrap.json
2023-07-08 03:07:21 -04:00
Derrick Hammer acb87c1531
refactor: move to vite bundler 2023-07-08 03:06:59 -04:00
Derrick Hammer f08c87c184
fix: await swarm.join 2023-07-08 00:58:40 -04:00
semantic-release-bot 1243d7c7d0 chore(release): 0.0.2-develop.1 [skip ci]
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.0.1...v0.0.2-develop.1) (2023-07-06)
2023-07-06 05:20:57 +00:00
Derrick Hammer 769f48e36b
ci: add repository to package.json 2023-07-06 01:19:08 -04:00
Derrick Hammer 5521968118
ci: setup 2023-07-05 11:39:23 -04:00
Derrick Hammer 54bcd90892
ci: add npm-shrinkwrap.json 2023-07-05 11:39:18 -04:00
Derrick Hammer ea1b4e876a
ci: use custom build config 2023-07-05 11:38:43 -04:00
Derrick Hammer 5cb573dbf7
refactor: switch to new sdks 2023-07-05 11:38:19 -04:00
16 changed files with 21049 additions and 394 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

18
.presetterrc.json Normal file
View File

@ -0,0 +1,18 @@
{
"preset": [
"@lumeweb/presetter-kernel-module-preset"
],
"config": {
"vite": {
"resolve": {
"alias": {
"timers": "timers-browserify",
"protomux": "@lumeweb/kernel-protomux-client"
}
},
"optimize": {
"node-fetch": "export default undefined;"
}
}
}
}

74
CHANGELOG.md Normal file
View File

@ -0,0 +1,74 @@
# [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-10-15)
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-10-12)
# [0.1.0-develop.10](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.9...v0.1.0-develop.10) (2023-09-16)
### Bug Fixes
* creating chainProgressListener event handler wrong ([e0d3a3d](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/e0d3a3de8f687b560a18a5a52425547de0bed79e))
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-09-09)
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-09-02)
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-08-04)
### Bug Fixes
* we need flag ad and rd on the dns query. rd is to request recursive lookup and ad is to ensure we only get DNSSEC responses ([67025f0](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/67025f0f687fe566a3751e52d3cd11441dcd93a9))
* we need to override the tcp client on the NS icann resolver to pipe connections properly ([1a80319](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/1a803193e6b6b18b1433360c2e26118ef8011094))
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-08-03)
### Bug Fixes
* if the ad flag is not set (no dnssec) return an empty result for security ([cd571db](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/cd571dbceb440be25e697c05d1186ed3675163a8))
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-08-02)
### Bug Fixes
* add a patch for bns to export TCPSocket ([aaee3ac](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/aaee3acb929089472ca82215cda0ebb39bb00780))
* add b4a patch ([e31973b](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/e31973be7056efcacdfa32f82f068b3075bbe5cb))
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-08-02)
### Bug Fixes
* use removeListener ([2eef509](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/2eef5099c8277624e88b9a310aed14adf78e4b3f))
### Features
* add dns query api that uses mock sockets and a dedicated hyper proxy for DNS (port 53) requests ([d675a44](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/d675a44b4e77a1c0aa2210f5bea3d538476f63ac))
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-07-29)
### Features
* add name api ([e612211](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/e6122110c5e9d42773aeb57e0bfee2cee0e6febf))
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-07-23)
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.0.2-develop.1...v0.1.0-develop.1) (2023-07-23)
### Bug Fixes
* await swarm.join ([f08c87c](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/f08c87c1845b7561c9aea1f7c21cf1f5528f92b7))
* need to override protomux with our kernel-protomux-client ([61050a5](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/61050a5a054686c65a4e1e58035e39b6e37c25d6))
### Features
* add registry api for use with network registry ([f5ce851](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/f5ce8518bb5261fbf25d5281c9f31ead99d735fd))
* add status api ([024c810](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/commit/024c810edf8a9f57693d89d44c785306d3edee89))
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/kernel-handshake-node/compare/v0.0.1...v0.0.2-develop.1) (2023-07-06)

View File

@ -1,2 +0,0 @@
# kernel-handshake-node

View File

@ -1,14 +0,0 @@
import esbuild from "esbuild";
esbuild.buildSync({
entryPoints: ["src/index.ts"],
outfile: "dist/index.js",
format: "iife",
bundle: true,
legalComments: "external",
// minify: true
define: {
global: "self",
},
external: ['dns']
});

20652
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,65 +1,41 @@
{ {
"name": "@lumeweb/kernel-handshake-node", "name": "@lumeweb/kernel-handshake-node",
"types": "module", "types": "module",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-handshake-node.git"
},
"author": { "author": {
"name": "Hammer Technologies LLC", "name": "Hammer Technologies LLC",
"email": "contact@lumeweb.com" "email": "contact@lumeweb.com"
}, },
"scripts": {
"test": "jest",
"format": "prettier -w src",
"build-script": "tsc --project tsconfig.build.json && mv dist-build/build.js dist-build/build.mjs",
"compile": "npm run build-script && tsc && rollup -c rollup.config.js",
"build": "npm run compile && node ./dist-build/build.mjs dev"
},
"type": "module", "type": "module",
"dependencies": { "version": "0.1.0-develop.12",
"@lumeweb/kernel-swarm-client": "git+https://git.lumeweb.com/LumeWeb/kernel-swarm-client.git", "readme": "ERROR: No README data found!",
"@lumeweb/libhyperproxy": "git+https://git.lumeweb.com/LumeWeb/libhyperproxy.git", "scripts": {
"hsd": "github:handshake-org/hsd", "prepare": "presetter bootstrap",
"libkmodule": "^0.2.53", "build": "run build",
"p-defer": "^4.0.0" "semantic-release": "semantic-release",
"postinstall": "patch-package"
}, },
"devDependencies": { "devDependencies": {
"@i2labs/dns": "^1.0.1", "@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.44",
"@rollup/plugin-alias": "^4.0.4",
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-inject": "^5.0.3",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.2",
"@rollup/plugin-typescript": "^11.1.0",
"@screamingvoid/sodium-universal": "^0.1.1",
"@scure/bip39": "^1.2.0",
"@skynetlabs/skynet-nodejs": "^2.9.0",
"@types/node": "^18.15.11",
"@types/read": "^0.0.29",
"@types/streamx": "^2.9.1", "@types/streamx": "^2.9.1",
"cli-progress": "^3.12.0", "patch-package": "^7.0.2",
"esbuild": "^0.17.17", "presetter": "*",
"eventemitter3": "^5.0.0", "timers-browserify": "^2.0.12",
"node-stdlib-browser": "^1.2.0", "vite": "^4.4.0"
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"prettier": "^2.8.7",
"read": "^2.1.0",
"rollup": "^3.20.3",
"rollup-plugin-polyfill": "^4.0.0",
"rollup-plugin-polyfill-inject": "^1.0.4",
"rollup-plugin-polyfill-node": "^0.12.0",
"setimmediate": "^1.0.5",
"tslib": "^2.5.0",
"typescript": "^4.9.5",
"util": "^0.12.5",
"vite": "^4.2.1",
"vite-plugin-node-polyfills": "^0.7.0",
"vite-plugin-node-stdlib-browser": "^0.1.1"
}, },
"pnpm": { "dependencies": {
"overrides": { "@i2labs/dns": "^1.0.1",
"protomux": "git+https://git.lumeweb.com/LumeWeb/kernel-protomux-client.git" "@lumeweb/kernel-network-registry-client": "^0.1.0-develop.10",
}, "@lumeweb/kernel-protomux-client": "^0.0.2-develop.22",
"patchedDependencies": { "@lumeweb/kernel-swarm-client": "^0.1.0-develop.12",
"b4a@1.6.3": "patches/b4a@1.6.3.patch" "@lumeweb/libhyperproxy": "^0.0.2-develop.1",
} "@lumeweb/libkernel": "^0.1.0-develop.66",
"assert": "^2.0.0",
"hsd": "^6.1.0",
"p-defer": "^4.0.0",
"streamx": "^2.15.0"
} }
} }

14
patches/b4a+1.6.4.patch Normal file
View File

@ -0,0 +1,14 @@
diff --git a/node_modules/b4a/package.json b/node_modules/b4a/package.json
index fed0957..a4b08a5 100644
--- a/node_modules/b4a/package.json
+++ b/node_modules/b4a/package.json
@@ -8,9 +8,6 @@
"index.js",
"lib"
],
- "browser": {
- "./index.js": "./browser.js"
- },
"scripts": {
"test": "standard && brittle test/*.mjs"
},

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"
},

9
patches/bns+0.15.0.patch Normal file
View File

@ -0,0 +1,9 @@
diff --git a/node_modules/bns/lib/internal/net.js b/node_modules/bns/lib/internal/net.js
index 4ad5ee0..beaf186 100644
--- a/node_modules/bns/lib/internal/net.js
+++ b/node_modules/bns/lib/internal/net.js
@@ -646,3 +646,4 @@ function normalize(options) {
exports.Client = Client;
exports.Server = Server;
+exports.TCPSocket = TCPSocket;

View File

@ -1,37 +0,0 @@
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import stdLibBrowser from "node-stdlib-browser";
import { handleCircularDependancyWarning } from "node-stdlib-browser/helpers/rollup/plugin";
import alias from "@rollup/plugin-alias";
import inject from "@rollup/plugin-inject";
import { defineConfig } from "rollup";
import * as fs from "fs";
import path from "path";
export default defineConfig({
input: "build/index.js",
output: {
file: "dist/index.js",
format: "iife",
inlineDynamicImports: true,
banner: fs.readFileSync(
path.resolve("node_modules/setimmediate/setImmediate.js")
),
},
plugins: [
json(),
alias({
entries: stdLibBrowser,
}),
resolve({ browser: true, preferBuiltins: true, dedupe: ["libkmodule"] }),
commonjs({ transformMixedEsModules: true }),
inject({
process: stdLibBrowser.process,
Buffer: [stdLibBrowser.buffer, "Buffer"],
}),
],
onwarn: (warning, rollupWarn) => {
handleCircularDependancyWarning(warning, rollupWarn);
},
});

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 kernel:", 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("");
}

132
src/dns/tcpClient.ts Normal file
View File

@ -0,0 +1,132 @@
import { Client as Base, TCPSocket } from "bns/lib/internal/net.js";
import IP from "binet";
import { Duplex } from "streamx";
import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
import defer from "p-defer";
class Stream extends Duplex {
public remoteAddress = "127.0.0.1";
public family = "IPv4";
public port = 0;
public remotePort = 0;
public parent: any;
constructor(options) {
super(options);
this.parent = options.parent;
}
setNoDelay() {}
connect() {
setTimeout(() => {
// @ts-ignore
this.emit("connect");
}, 1);
}
unref() {}
}
const PROTOCOL = "lumeweb.proxy.handshake.dns";
export default class TCPClient extends Base {
private node: any;
private proxy: MultiSocketProxy;
private peerConnected = defer();
constructor(options) {
super(options);
this.node = options.node;
this.proxy = new MultiSocketProxy({
protocol: PROTOCOL,
swarm: options.swarm,
server: false,
autostart: true,
listen: true,
});
this.proxy.on("peerChannelOpen", () => {
this.peerConnected.resolve();
});
}
protected declare sockets: Map<any, any>;
async write(msg, port, host) {
const local = host === "127.0.0.1";
const key = IP.toHost(host, port);
const cache = this.sockets.get(key);
if (cache) {
cache.write(msg);
return;
}
let socket: any = null;
try {
if (local) {
socket = await this.createLocalSocket();
} else {
await this.peerConnected.promise;
socket = new TCPSocket(this);
socket.socket = this.proxy.createSocket({
host,
port,
});
socket.socket.remoteAddress = host;
socket.socket.remotePort = port;
await socket.connect();
}
} catch (e) {
return;
}
if (this.sockets.has(key)) {
socket.destroy();
socket = this.sockets.get(key);
} else {
socket.parent = this;
this.sockets.set(key, socket);
}
socket.write(msg);
}
async createLocalSocket() {
const socket = new TCPSocket(this);
const remoteSocket = new Stream({
parent: this,
write: (data, cb) => {
// @ts-ignore
socket.socket.push(data);
cb?.(null);
},
});
// @ts-ignore
socket.socket = new Stream({
parent: this,
write: (data, cb) => {
// @ts-ignore
remoteSocket.push(data);
cb?.(null);
},
});
const port = this.node.rs.hns.getAuthority().servers.slice().pop().port;
remoteSocket.port = port;
remoteSocket.remotePort = port;
// @ts-ignore
socket.socket.port = port;
// @ts-ignore
socket.socket.remotePort = port;
await socket.connect();
this.node.ns.server.server.emit("connection", remoteSocket);
return socket;
}
}

View File

@ -1,6 +1,7 @@
import type { ActiveQuery } from "libkmodule"; import type { ActiveQuery } from "@lumeweb/libkernel/module";
import { addHandler, handleMessage } from "libkmodule"; import { addHandler, handleMessage } from "@lumeweb/libkernel/module";
import { createClient } from "@lumeweb/kernel-swarm-client"; import { createClient as createSwarmClient } from "@lumeweb/kernel-swarm-client";
import { createClient as createNetworkRegistryClient } from "@lumeweb/kernel-network-registry-client";
import { import {
createServer, createServer,
DummySocket, DummySocket,
@ -11,8 +12,11 @@ import { SPVNode } from "hsd/lib/node";
import defer from "p-defer"; import defer from "p-defer";
import dns from "@i2labs/dns"; import dns from "@i2labs/dns";
import assert from "assert"; import assert from "assert";
import { wire } from "bns";
import TCPClient from "./dns/tcpClient.js";
const PROTOCOL = "lumeweb.proxy.handshake"; const PROTOCOL = "lumeweb.proxy.handshake";
const TYPES = ["blockchain"];
onmessage = handleMessage; onmessage = handleMessage;
@ -21,14 +25,20 @@ let moduleLoaded: Promise<void> = new Promise((resolve) => {
moduleLoadedResolve = resolve; moduleLoadedResolve = resolve;
}); });
addHandler("presentSeed", handlePresentSeed); addHandler("presentKey", handlePresentKey);
addHandler("register", handleRegister);
addHandler("status", handleStatus, { receiveUpdates: true });
addHandler("name", handleName);
addHandler("ready", handleReady); addHandler("ready", handleReady);
addHandler("query", handleQuery); addHandler("query", handleQuery);
addHandler("dnsQuery", handleDnsQuery);
let swarm; let swarm;
let proxy: MultiSocketProxy; let proxy: MultiSocketProxy;
let node: SPVNode; let node: SPVNode;
const networkRegistry = createNetworkRegistryClient();
function resolveWithPeers(resolve: Function) { function resolveWithPeers(resolve: Function) {
if (!node.pool.peers.head()) { if (!node.pool.peers.head()) {
node.pool.on("peer", () => { node.pool.on("peer", () => {
@ -60,15 +70,14 @@ function resolveWithPeers(resolve: Function) {
return resolve(null); return resolve(null);
} }
async function handlePresentSeed(aq: ActiveQuery) { async function handlePresentKey(aq: ActiveQuery) {
swarm = createClient(); swarm = createSwarmClient();
const peerConnected = defer(); const peerConnected = defer();
node = new SPVNode({ node = new SPVNode({
config: false, config: false,
argv: false, argv: false,
env: false, env: false,
noDns: true,
memory: false, memory: false,
logFile: false, logFile: false,
logConsole: true, logConsole: true,
@ -107,8 +116,8 @@ async function handlePresentSeed(aq: ActiveQuery) {
"208.67.220.222", "208.67.220.222",
]); ]);
const out = []; const out: string[] = [];
const types = []; const types: string[] = [];
if (family == null || family === 4) types.push("A"); if (family == null || family === 4) types.push("A");
@ -136,6 +145,15 @@ async function handlePresentSeed(aq: ActiveQuery) {
node.http.http.listen = (port: number, host: string, cb: Function) => cb(); node.http.http.listen = (port: number, host: string, cb: Function) => cb();
} }
const tcpClient = new TCPClient({ node, swarm });
node.rs.hns.forceTCP = true;
node.rs.hns.socket = tcpClient;
node.ns.icann.forceTCP = true;
node.ns.icann.socket = tcpClient;
node.rs.hns.init();
node.ns.icann.init();
proxy = new MultiSocketProxy({ proxy = new MultiSocketProxy({
protocol: PROTOCOL, protocol: PROTOCOL,
swarm, swarm,
@ -148,7 +166,7 @@ async function handlePresentSeed(aq: ActiveQuery) {
peerConnected.resolve(); peerConnected.resolve();
}); });
swarm.join(PROTOCOL); await swarm.join(PROTOCOL);
await swarm.start(); await swarm.start();
await peerConnected.promise; await peerConnected.promise;
@ -188,3 +206,85 @@ async function handleQuery(aq: ActiveQuery) {
aq.reject((e as Error).message); aq.reject((e as Error).message);
} }
} }
async function handleDnsQuery(aq: ActiveQuery) {
if (!node.chain.synced || !node.pool.peers.head()) {
aq.reject("not ready");
return;
}
if (!("fqdn" in aq.callerInput)) {
aq.reject("fqdn required");
return;
}
if (!("type" in aq.callerInput)) {
aq.reject("type required");
return;
}
const msg = new wire.Message();
const q = new wire.Question(aq.callerInput.fqdn, aq.callerInput.type);
msg.question.push(q);
msg.rd = true;
msg.ad = true;
const ret = await node.rs.answer(msg);
if (!ret.ad) {
aq.respond([]);
return;
}
aq.respond(
ret.collect(aq.callerInput.fqdn, wire.stringToType(aq.callerInput.type)),
);
}
async function handleRegister(aq: ActiveQuery) {
await networkRegistry.registerNetwork(TYPES);
aq.respond();
}
async function handleStatus(aq: ActiveQuery) {
let chainProgress = node.chain.getProgress();
let chainPeers = node.pool.peers.size();
const chainProgressListener = () => {
chainProgress = node.chain.getProgress();
sendUpdate();
};
function peersListener() {
chainPeers = node.pool.peers.size();
sendUpdate();
}
node.pool.on("peer", peersListener);
node.pool.on("peer close", peersListener);
node.chain.on("tip", chainProgressListener);
function sendUpdate() {
aq.sendUpdate({
sync: chainProgress * 100,
peers: chainPeers,
ready: node.chain.synced,
});
}
aq.setReceiveUpdate?.(() => {
node.chain.removeListener("tip", chainProgressListener);
node.pool.off("peer", peersListener);
node.pool.off("peer close", peersListener);
aq.respond();
});
sendUpdate();
}
function handleName(aq: ActiveQuery) {
aq.respond("Handshake");
}

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,12 +0,0 @@
{
"compilerOptions": {
"target": "esnext",
"declaration": true,
"moduleResolution": "node",
"outDir": "./build",
"strict": true,
"allowSyntheticDefaultImports": true
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"]
}