fixing merge conflicts

This commit is contained in:
Chris Troutner
2026-02-16 08:43:01 -07:00
4 changed files with 353 additions and 827 deletions
+306 -442
View File
@@ -9,28 +9,10 @@
"version": "3.1.1",
"license": "MIT",
"dependencies": {
"@chainsafe/libp2p-gossipsub": "14.1.0",
"@chainsafe/libp2p-noise": "16.0.1",
"@chainsafe/libp2p-yamux": "7.0.1",
"@helia/unixfs": "4.0.2",
"@libp2p/bootstrap": "11.0.26",
"@libp2p/circuit-relay-v2": "3.2.2",
"@libp2p/config": "1.1.0",
"@libp2p/identify": "3.0.22",
"@libp2p/keychain": "5.0.14",
"@libp2p/logger": "5.1.8",
"@libp2p/ping": "2.0.22",
"@libp2p/tcp": "10.1.2",
"@libp2p/webrtc": "5.2.2",
"@libp2p/websockets": "9.2.2",
"@multiformats/multiaddr": "12.5.1",
"axios": "0.27.2",
"bcryptjs": "2.4.3",
"blockstore-fs": "2.0.2",
"datastore-fs": "10.0.2",
"glob": "7.1.6",
"helia": "5.2.1",
"helia-coord": "1.9.7",
"helia-coord": "2.0.2",
"jsonrpc-lite": "2.2.0",
"jsonwebtoken": "8.5.1",
"jwt-bch-lib": "1.3.0",
@@ -45,7 +27,6 @@
"koa-router": "10.0.0",
"koa-static": "5.0.0",
"koa2-ratelimit": "0.9.1",
"libp2p": "2.7.2",
"line-reader": "0.4.0",
"mime-types": "2.1.35",
"minimal-slp-wallet": "7.1.4",
@@ -939,246 +920,6 @@
"node": ">=6"
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.16.17.tgz",
"integrity": "sha512-N9x1CMXVhtWEAMS7pNNONyA14f71VPQN9Cnavj1XQh6T7bskqiLLrSca4O0Vr8Wdcga943eThxnVp3JLnBMYtw==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/android-arm64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.16.17.tgz",
"integrity": "sha512-MIGl6p5sc3RDTLLkYL1MyL8BMRN4tLMRCn+yRJJmEDvYZ2M7tmAf80hx1kbNEUX2KJ50RRtxZ4JHLvCfuB6kBg==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/android-x64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.16.17.tgz",
"integrity": "sha512-a3kTv3m0Ghh4z1DaFEuEDfz3OLONKuFvI4Xqczqx4BqLyuFaFkuaG4j2MtA6fuWEFeC5x9IvqnX7drmRq/fyAQ==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/darwin-arm64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.16.17.tgz",
"integrity": "sha512-/2agbUEfmxWHi9ARTX6OQ/KgXnOWfsNlTeLcoV7HSuSTv63E4DqtAc+2XqGw1KHxKMHGZgbVCZge7HXWX9Vn+w==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/darwin-x64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.16.17.tgz",
"integrity": "sha512-2By45OBHulkd9Svy5IOCZt376Aa2oOkiE9QWUK9fe6Tb+WDr8hXL3dpqi+DeLiMed8tVXspzsTAvd0jUl96wmg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/freebsd-arm64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.16.17.tgz",
"integrity": "sha512-mt+cxZe1tVx489VTb4mBAOo2aKSnJ33L9fr25JXpqQqzbUIw/yzIzi+NHwAXK2qYV1lEFp4OoVeThGjUbmWmdw==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/freebsd-x64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.16.17.tgz",
"integrity": "sha512-8ScTdNJl5idAKjH8zGAsN7RuWcyHG3BAvMNpKOBaqqR7EbUhhVHOqXRdL7oZvz8WNHL2pr5+eIT5c65kA6NHug==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-arm": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.16.17.tgz",
"integrity": "sha512-iihzrWbD4gIT7j3caMzKb/RsFFHCwqqbrbH9SqUSRrdXkXaygSZCZg1FybsZz57Ju7N/SHEgPyaR0LZ8Zbe9gQ==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-arm64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.16.17.tgz",
"integrity": "sha512-7S8gJnSlqKGVJunnMCrXHU9Q8Q/tQIxk/xL8BqAP64wchPCTzuM6W3Ra8cIa1HIflAvDnNOt2jaL17vaW+1V0g==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-ia32": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.16.17.tgz",
"integrity": "sha512-kiX69+wcPAdgl3Lonh1VI7MBr16nktEvOfViszBSxygRQqSpzv7BffMKRPMFwzeJGPxcio0pdD3kYQGpqQ2SSg==",
"cpu": [
"ia32"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.16.17.tgz",
"integrity": "sha512-dTzNnQwembNDhd654cA4QhbS9uDdXC3TKqMJjgOWsC0yNCbpzfWoXdZvp0mY7HU6nzk5E0zpRGGx3qoQg8T2DQ==",
"cpu": [
"loong64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-mips64el": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.16.17.tgz",
"integrity": "sha512-ezbDkp2nDl0PfIUn0CsQ30kxfcLTlcx4Foz2kYv8qdC6ia2oX5Q3E/8m6lq84Dj/6b0FrkgD582fJMIfHhJfSw==",
"cpu": [
"mips64el"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-ppc64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.16.17.tgz",
"integrity": "sha512-dzS678gYD1lJsW73zrFhDApLVdM3cUF2MvAa1D8K8KtcSKdLBPP4zZSLy6LFZ0jYqQdQ29bjAHJDgz0rVbLB3g==",
"cpu": [
"ppc64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-riscv64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.16.17.tgz",
"integrity": "sha512-ylNlVsxuFjZK8DQtNUwiMskh6nT0vI7kYl/4fZgV1llP5d6+HIeL/vmmm3jpuoo8+NuXjQVZxmKuhDApK0/cKw==",
"cpu": [
"riscv64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-s390x": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.16.17.tgz",
"integrity": "sha512-gzy7nUTO4UA4oZ2wAMXPNBGTzZFP7mss3aKR2hH+/4UUkCOyqmjXiKpzGrY2TlEUhbbejzXVKKGazYcQTZWA/w==",
"cpu": [
"s390x"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-x64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.16.17.tgz",
@@ -1195,102 +936,6 @@
"node": ">=12"
}
},
"node_modules/@esbuild/netbsd-x64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.16.17.tgz",
"integrity": "sha512-/PzmzD/zyAeTUsduZa32bn0ORug+Jd1EGGAUJvqfeixoEISYpGnAezN6lnJoskauoai0Jrs+XSyvDhppCPoKOA==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/openbsd-x64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.16.17.tgz",
"integrity": "sha512-2yaWJhvxGEz2RiftSk0UObqJa/b+rIAjnODJgv2GbGGpRwAfpgzyrg1WLK8rqA24mfZa9GvpjLcBBg8JHkoodg==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/sunos-x64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.16.17.tgz",
"integrity": "sha512-xtVUiev38tN0R3g8VhRfN7Zl42YCJvyBhRKw1RJjwE1d2emWTVToPLNEQj/5Qxc6lVFATDiy6LjVHYhIPrLxzw==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/win32-arm64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.16.17.tgz",
"integrity": "sha512-ga8+JqBDHY4b6fQAmOgtJJue36scANy4l/rL97W+0wYmijhxKetzZdKOJI7olaBaMhWt8Pac2McJdZLxXWUEQw==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/win32-ia32": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.16.17.tgz",
"integrity": "sha512-WnsKaf46uSSF/sZhwnqE4L/F89AYNMiD4YtEcYekBt9Q7nj0DiId2XH2Ng2PHM54qi5oPrQ8luuzGszqi/veig==",
"cpu": [
"ia32"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/win32-x64": {
"version": "0.16.17",
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.16.17.tgz",
"integrity": "sha512-y+EHuSchhL7FjHgvQL/0fnnFmO4T1bhvWANX6gcnqTjtnKWbTvUMCpGnv2+t+31d7RzyEAYAd4u2fnIhHL6N/Q==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@eslint-community/eslint-utils": {
"version": "4.9.1",
"resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.9.1.tgz",
@@ -2102,19 +1747,6 @@
"uint8arrays": "^5.1.0"
}
},
"node_modules/@libp2p/config/node_modules/@libp2p/logger": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@libp2p/logger/-/logger-5.2.0.tgz",
"integrity": "sha512-OEFS529CnIKfbWEHmuCNESw9q0D0hL8cQ8klQfjIVPur15RcgAEgc1buQ7Y6l0B6tCYg120bp55+e9tGvn8c0g==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@libp2p/interface": "^2.11.0",
"@multiformats/multiaddr": "^12.4.4",
"interface-datastore": "^8.3.1",
"multiformats": "^13.3.6",
"weald": "^1.0.4"
}
},
"node_modules/@libp2p/crypto": {
"version": "5.1.13",
"resolved": "https://registry.npmjs.org/@libp2p/crypto/-/crypto-5.1.13.tgz",
@@ -2144,6 +1776,18 @@
"uint8arraylist": "^2.4.8"
}
},
"node_modules/@libp2p/crypto/node_modules/@multiformats/multiaddr": {
"version": "13.0.1",
"resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-13.0.1.tgz",
"integrity": "sha512-XToN915cnfr6Lr9EdGWakGJbPT0ghpg/850HvdC+zFX8XvpLZElwa8synCiwa8TuvKNnny6m8j8NVBNCxhIO3g==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@chainsafe/is-ip": "^2.0.1",
"multiformats": "^13.0.0",
"uint8-varint": "^2.0.1",
"uint8arrays": "^5.0.0"
}
},
"node_modules/@libp2p/crypto/node_modules/@noble/curves": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@noble/curves/-/curves-2.0.1.tgz",
@@ -2377,15 +2021,15 @@
}
},
"node_modules/@libp2p/logger": {
"version": "5.1.8",
"resolved": "https://registry.npmjs.org/@libp2p/logger/-/logger-5.1.8.tgz",
"integrity": "sha512-Mevhz+dTQuV5UbwqLMOJZv2IpMg+/89x/Ouq0iKtkgB5vAgTwJ3DlM7+IYOeyzQRUpCPfaRiJet3aBB5wnPMRg==",
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@libp2p/logger/-/logger-5.2.0.tgz",
"integrity": "sha512-OEFS529CnIKfbWEHmuCNESw9q0D0hL8cQ8klQfjIVPur15RcgAEgc1buQ7Y6l0B6tCYg120bp55+e9tGvn8c0g==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@libp2p/interface": "^2.5.0",
"@multiformats/multiaddr": "^12.3.3",
"@libp2p/interface": "^2.11.0",
"@multiformats/multiaddr": "^12.4.4",
"interface-datastore": "^8.3.1",
"multiformats": "^13.3.1",
"multiformats": "^13.3.6",
"weald": "^1.0.4"
}
},
@@ -2500,6 +2144,37 @@
"multiformats": "^13.3.6"
}
},
"node_modules/@libp2p/peer-collections/node_modules/@libp2p/utils": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/@libp2p/utils/-/utils-6.7.1.tgz",
"integrity": "sha512-x3WImvw4unmx1ZeAedj8AkRe4UImUlkw0ZItYAiKiekElMNUXwv+Yt48dI/LmB38JIof8sng29XvUeCVU3F6OA==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@chainsafe/is-ip": "^2.1.0",
"@chainsafe/netmask": "^2.0.0",
"@libp2p/crypto": "^5.1.7",
"@libp2p/interface": "^2.10.5",
"@libp2p/logger": "^5.1.21",
"@multiformats/multiaddr": "^12.4.4",
"@sindresorhus/fnv1a": "^3.1.0",
"any-signal": "^4.1.1",
"delay": "^6.0.0",
"get-iterator": "^2.0.1",
"is-loopback-addr": "^2.0.2",
"is-plain-obj": "^4.1.0",
"it-foreach": "^2.1.3",
"it-pipe": "^3.0.1",
"it-pushable": "^3.2.3",
"it-stream-types": "^2.0.2",
"main-event": "^1.0.1",
"netmask": "^2.0.2",
"p-defer": "^4.0.1",
"race-event": "^1.3.0",
"race-signal": "^1.1.3",
"uint8arraylist": "^2.4.8",
"uint8arrays": "^5.1.0"
}
},
"node_modules/@libp2p/peer-id": {
"version": "5.1.9",
"resolved": "https://registry.npmjs.org/@libp2p/peer-id/-/peer-id-5.1.9.tgz",
@@ -2530,6 +2205,37 @@
"uint8arrays": "^5.1.0"
}
},
"node_modules/@libp2p/peer-record/node_modules/@libp2p/utils": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/@libp2p/utils/-/utils-6.7.1.tgz",
"integrity": "sha512-x3WImvw4unmx1ZeAedj8AkRe4UImUlkw0ZItYAiKiekElMNUXwv+Yt48dI/LmB38JIof8sng29XvUeCVU3F6OA==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@chainsafe/is-ip": "^2.1.0",
"@chainsafe/netmask": "^2.0.0",
"@libp2p/crypto": "^5.1.7",
"@libp2p/interface": "^2.10.5",
"@libp2p/logger": "^5.1.21",
"@multiformats/multiaddr": "^12.4.4",
"@sindresorhus/fnv1a": "^3.1.0",
"any-signal": "^4.1.1",
"delay": "^6.0.0",
"get-iterator": "^2.0.1",
"is-loopback-addr": "^2.0.2",
"is-plain-obj": "^4.1.0",
"it-foreach": "^2.1.3",
"it-pipe": "^3.0.1",
"it-pushable": "^3.2.3",
"it-stream-types": "^2.0.2",
"main-event": "^1.0.1",
"netmask": "^2.0.2",
"p-defer": "^4.0.1",
"race-event": "^1.3.0",
"race-signal": "^1.1.3",
"uint8arraylist": "^2.4.8",
"uint8arrays": "^5.1.0"
}
},
"node_modules/@libp2p/peer-store": {
"version": "11.2.7",
"resolved": "https://registry.npmjs.org/@libp2p/peer-store/-/peer-store-11.2.7.tgz",
@@ -2703,19 +2409,6 @@
"uint8arrays": "^5.1.0"
}
},
"node_modules/@libp2p/utils/node_modules/@libp2p/logger": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@libp2p/logger/-/logger-5.2.0.tgz",
"integrity": "sha512-OEFS529CnIKfbWEHmuCNESw9q0D0hL8cQ8klQfjIVPur15RcgAEgc1buQ7Y6l0B6tCYg120bp55+e9tGvn8c0g==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@libp2p/interface": "^2.11.0",
"@multiformats/multiaddr": "^12.4.4",
"interface-datastore": "^8.3.1",
"multiformats": "^13.3.6",
"weald": "^1.0.4"
}
},
"node_modules/@libp2p/webrtc": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/@libp2p/webrtc/-/webrtc-5.2.2.tgz",
@@ -2844,6 +2537,18 @@
"uint8arraylist": "^2.4.8"
}
},
"node_modules/@multiformats/dns/node_modules/@multiformats/multiaddr": {
"version": "13.0.1",
"resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-13.0.1.tgz",
"integrity": "sha512-XToN915cnfr6Lr9EdGWakGJbPT0ghpg/850HvdC+zFX8XvpLZElwa8synCiwa8TuvKNnny6m8j8NVBNCxhIO3g==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@chainsafe/is-ip": "^2.0.1",
"multiformats": "^13.0.0",
"uint8-varint": "^2.0.1",
"uint8arrays": "^5.0.0"
}
},
"node_modules/@multiformats/dns/node_modules/p-queue": {
"version": "9.1.0",
"resolved": "https://registry.npmjs.org/p-queue/-/p-queue-9.1.0.tgz",
@@ -6057,19 +5762,6 @@
"multiformats": "^13.3.6"
}
},
"node_modules/blockstore-core/node_modules/@libp2p/logger": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@libp2p/logger/-/logger-5.2.0.tgz",
"integrity": "sha512-OEFS529CnIKfbWEHmuCNESw9q0D0hL8cQ8klQfjIVPur15RcgAEgc1buQ7Y6l0B6tCYg120bp55+e9tGvn8c0g==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@libp2p/interface": "^2.11.0",
"@multiformats/multiaddr": "^12.4.4",
"interface-datastore": "^8.3.1",
"multiformats": "^13.3.6",
"weald": "^1.0.4"
}
},
"node_modules/blockstore-fs": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/blockstore-fs/-/blockstore-fs-2.0.2.tgz",
@@ -7324,19 +7016,6 @@
"it-take": "^3.0.8"
}
},
"node_modules/datastore-core/node_modules/@libp2p/logger": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@libp2p/logger/-/logger-5.2.0.tgz",
"integrity": "sha512-OEFS529CnIKfbWEHmuCNESw9q0D0hL8cQ8klQfjIVPur15RcgAEgc1buQ7Y6l0B6tCYg120bp55+e9tGvn8c0g==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@libp2p/interface": "^2.11.0",
"@multiformats/multiaddr": "^12.4.4",
"interface-datastore": "^8.3.1",
"multiformats": "^13.3.6",
"weald": "^1.0.4"
}
},
"node_modules/datastore-fs": {
"version": "10.0.2",
"resolved": "https://registry.npmjs.org/datastore-fs/-/datastore-fs-10.0.2.tgz",
@@ -9541,20 +9220,6 @@
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"license": "ISC"
},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
@@ -10300,17 +9965,196 @@
}
},
"node_modules/helia-coord": {
"version": "1.9.7",
"resolved": "https://registry.npmjs.org/helia-coord/-/helia-coord-1.9.7.tgz",
"integrity": "sha512-EVlbg6FjpkYwVH4LRT/n/r6DQVh7opNIClYbFP2ZQqx8V9d3YE+z2d+TigvGmh0xMpIAbQtRVj+C3amPs+r35g==",
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/helia-coord/-/helia-coord-2.0.2.tgz",
"integrity": "sha512-9TPTAtqHhdCACeUR7Pg6rPce/GoGzGF+O80Z4qpkVPCtAZ5G15BkKQSL948TzTHzV8iZ9GZbxv+C7k1g+Ii2NQ==",
"license": "MIT",
"dependencies": {
"@chainsafe/libp2p-gossipsub": "14.1.0",
"@chainsafe/libp2p-noise": "16.0.1",
"@chainsafe/libp2p-yamux": "7.0.1",
"@chris.troutner/retry-queue": "1.0.10",
"@helia/block-brokers": "4.0.4",
"@helia/routers": "3.0.0",
"@helia/unixfs": "4.0.2",
"@libp2p/bootstrap": "11.0.20",
"@libp2p/circuit-relay-v2": "3.2.2",
"@libp2p/config": "1.1.0",
"@libp2p/identify": "3.0.22",
"@libp2p/kad-dht": "14.2.3",
"@libp2p/keychain": "5.0.14",
"@libp2p/ping": "2.0.22",
"@libp2p/tcp": "10.1.2",
"@libp2p/webrtc": "5.2.2",
"@libp2p/websockets": "9.2.2",
"@multiformats/multiaddr": "12.3.5",
"@multiformats/multiaddr-matcher": "1.6.0",
"bch-encrypt-lib": "2.1.1",
"blockstore-fs": "2.0.2",
"datastore-fs": "10.0.2",
"helia": "5.2.1",
"libp2p": "2.7.2",
"public-ip": "6.0.1",
"uuid": "9.0.0"
},
"peerDependencies": {
"libp2p": "=2.7.2"
}
},
"node_modules/helia-coord/node_modules/@helia/block-brokers": {
"version": "4.0.4",
"resolved": "https://registry.npmjs.org/@helia/block-brokers/-/block-brokers-4.0.4.tgz",
"integrity": "sha512-J9Oh5KSMJUYg+WZCted73QfU4iAqRPXULTRSorzJ/iyFsONQwvY1nvlL8rcupt5uSi3ZHdHOBHPGagR61ZVu/A==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@helia/bitswap": "^2.0.4",
"@helia/interface": "^5.2.0",
"@helia/utils": "^1.2.1",
"@libp2p/interface": "^2.2.1",
"@libp2p/utils": "^6.2.1",
"@multiformats/multiaddr": "^12.3.3",
"@multiformats/multiaddr-matcher": "^1.6.0",
"@multiformats/multiaddr-to-uri": "^11.0.0",
"interface-blockstore": "^5.3.1",
"interface-store": "^6.0.2",
"multiformats": "^13.3.1",
"progress-events": "^1.0.1"
}
},
"node_modules/helia-coord/node_modules/@helia/routers": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@helia/routers/-/routers-3.0.0.tgz",
"integrity": "sha512-WtbH+qam4YtcJfeQpteJ9o9By4TniUeltkClouoDkXpRoshjyTT0MowzpCOBRS0hS8gK3aX+kA3h1kU3qeR35Q==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@helia/delegated-routing-v1-http-api-client": "^4.2.1",
"@helia/interface": "^5.2.0",
"@libp2p/interface": "^2.2.1",
"@libp2p/peer-id": "^5.0.8",
"@multiformats/uri-to-multiaddr": "^8.0.0",
"ipns": "^10.0.0",
"it-first": "^3.0.6",
"it-map": "^3.1.1",
"multiformats": "^13.3.1",
"uint8arrays": "^5.1.0"
}
},
"node_modules/helia-coord/node_modules/@libp2p/bootstrap": {
"version": "11.0.20",
"resolved": "https://registry.npmjs.org/@libp2p/bootstrap/-/bootstrap-11.0.20.tgz",
"integrity": "sha512-ci5bdMdT29zyP0GCFsHEaQdU+0YxO6nOVl/BHDLLygvss9sXvLTM2iqO1Gg2NdOzaBg640xa55ZRE87M2H9m4Q==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@libp2p/interface": "^2.5.0",
"@libp2p/interface-internal": "^2.3.0",
"@libp2p/peer-id": "^5.0.12",
"@multiformats/mafmt": "^12.1.6",
"@multiformats/multiaddr": "^12.3.3"
}
},
"node_modules/helia-coord/node_modules/@libp2p/kad-dht": {
"version": "14.2.3",
"resolved": "https://registry.npmjs.org/@libp2p/kad-dht/-/kad-dht-14.2.3.tgz",
"integrity": "sha512-kwHf6nClBXqEHgtaKsqZa6yXPUxBq3ZE9ySb1FNdJu+3Yl3nezHie1edWlawNcW2ET101dmCUdPRFeG8QkS5OA==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@libp2p/crypto": "^5.0.11",
"@libp2p/interface": "^2.5.0",
"@libp2p/interface-internal": "^2.3.0",
"@libp2p/peer-collections": "^6.0.17",
"@libp2p/peer-id": "^5.0.12",
"@libp2p/record": "^4.0.4",
"@libp2p/utils": "^6.5.1",
"@multiformats/multiaddr": "^12.3.3",
"any-signal": "^4.1.1",
"interface-datastore": "^8.3.1",
"it-all": "^3.0.6",
"it-drain": "^3.0.7",
"it-length": "^3.0.6",
"it-length-prefixed": "^9.1.0",
"it-map": "^3.1.1",
"it-merge": "^3.0.5",
"it-parallel": "^3.0.8",
"it-pipe": "^3.0.1",
"it-protobuf-stream": "^1.1.5",
"it-take": "^3.0.6",
"mortice": "^3.0.6",
"multiformats": "^13.3.1",
"p-defer": "^4.0.1",
"p-event": "^6.0.1",
"progress-events": "^1.0.1",
"protons-runtime": "^5.5.0",
"race-signal": "^1.1.0",
"uint8-varint": "^2.0.4",
"uint8arraylist": "^2.4.8",
"uint8arrays": "^5.1.0"
}
},
"node_modules/helia-coord/node_modules/@libp2p/utils": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/@libp2p/utils/-/utils-6.7.1.tgz",
"integrity": "sha512-x3WImvw4unmx1ZeAedj8AkRe4UImUlkw0ZItYAiKiekElMNUXwv+Yt48dI/LmB38JIof8sng29XvUeCVU3F6OA==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@chainsafe/is-ip": "^2.1.0",
"@chainsafe/netmask": "^2.0.0",
"@libp2p/crypto": "^5.1.7",
"@libp2p/interface": "^2.10.5",
"@libp2p/logger": "^5.1.21",
"@multiformats/multiaddr": "^12.4.4",
"@sindresorhus/fnv1a": "^3.1.0",
"any-signal": "^4.1.1",
"delay": "^6.0.0",
"get-iterator": "^2.0.1",
"is-loopback-addr": "^2.0.2",
"is-plain-obj": "^4.1.0",
"it-foreach": "^2.1.3",
"it-pipe": "^3.0.1",
"it-pushable": "^3.2.3",
"it-stream-types": "^2.0.2",
"main-event": "^1.0.1",
"netmask": "^2.0.2",
"p-defer": "^4.0.1",
"race-event": "^1.3.0",
"race-signal": "^1.1.3",
"uint8arraylist": "^2.4.8",
"uint8arrays": "^5.1.0"
}
},
"node_modules/helia-coord/node_modules/@libp2p/utils/node_modules/@multiformats/multiaddr": {
"version": "12.5.1",
"resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-12.5.1.tgz",
"integrity": "sha512-+DDlr9LIRUS8KncI1TX/FfUn8F2dl6BIxJgshS/yFQCNB5IAF0OGzcwB39g5NLE22s4qqDePv0Qof6HdpJ/4aQ==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@chainsafe/is-ip": "^2.0.1",
"@chainsafe/netmask": "^2.0.0",
"@multiformats/dns": "^1.0.3",
"abort-error": "^1.0.1",
"multiformats": "^13.0.0",
"uint8-varint": "^2.0.1",
"uint8arrays": "^5.0.0"
}
},
"node_modules/helia-coord/node_modules/@multiformats/multiaddr": {
"version": "12.3.5",
"resolved": "https://registry.npmjs.org/@multiformats/multiaddr/-/multiaddr-12.3.5.tgz",
"integrity": "sha512-f3I7FDd6VM4s3X5dXbmwk8Y99pnvATWj7RorIr+qgeiYCDySp4cwybAFnxdRWeKs6XLPE9meB0p8tK4lQqO8gQ==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@chainsafe/is-ip": "^2.0.1",
"@chainsafe/netmask": "^2.0.0",
"@multiformats/dns": "^1.0.3",
"multiformats": "^13.0.0",
"uint8-varint": "^2.0.1",
"uint8arrays": "^5.0.0"
}
},
"node_modules/helia-coord/node_modules/@multiformats/uri-to-multiaddr": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/@multiformats/uri-to-multiaddr/-/uri-to-multiaddr-8.1.0.tgz",
"integrity": "sha512-NHFqdKEwJ0A6JDXzC645Lgyw72zWhbM1QfaaD00ZYRrNvtx64p1bD9aIrWZIhLWZN87/lsV4QkJSNRF3Fd3ryw==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@multiformats/multiaddr": "^12.1.14",
"is-ip": "^5.0.0"
}
},
"node_modules/helia-coord/node_modules/uuid": {
@@ -13000,17 +12844,35 @@
"uint8arrays": "^5.1.0"
}
},
"node_modules/libp2p/node_modules/@libp2p/logger": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@libp2p/logger/-/logger-5.2.0.tgz",
"integrity": "sha512-OEFS529CnIKfbWEHmuCNESw9q0D0hL8cQ8klQfjIVPur15RcgAEgc1buQ7Y6l0B6tCYg120bp55+e9tGvn8c0g==",
"node_modules/libp2p/node_modules/@libp2p/utils": {
"version": "6.7.1",
"resolved": "https://registry.npmjs.org/@libp2p/utils/-/utils-6.7.1.tgz",
"integrity": "sha512-x3WImvw4unmx1ZeAedj8AkRe4UImUlkw0ZItYAiKiekElMNUXwv+Yt48dI/LmB38JIof8sng29XvUeCVU3F6OA==",
"license": "Apache-2.0 OR MIT",
"dependencies": {
"@libp2p/interface": "^2.11.0",
"@chainsafe/is-ip": "^2.1.0",
"@chainsafe/netmask": "^2.0.0",
"@libp2p/crypto": "^5.1.7",
"@libp2p/interface": "^2.10.5",
"@libp2p/logger": "^5.1.21",
"@multiformats/multiaddr": "^12.4.4",
"interface-datastore": "^8.3.1",
"multiformats": "^13.3.6",
"weald": "^1.0.4"
"@sindresorhus/fnv1a": "^3.1.0",
"any-signal": "^4.1.1",
"delay": "^6.0.0",
"get-iterator": "^2.0.1",
"is-loopback-addr": "^2.0.2",
"is-plain-obj": "^4.1.0",
"it-foreach": "^2.1.3",
"it-pipe": "^3.0.1",
"it-pushable": "^3.2.3",
"it-stream-types": "^2.0.2",
"main-event": "^1.0.1",
"netmask": "^2.0.2",
"p-defer": "^4.0.1",
"race-event": "^1.3.0",
"race-signal": "^1.1.3",
"uint8arraylist": "^2.4.8",
"uint8arrays": "^5.1.0"
}
},
"node_modules/libp2p/node_modules/@types/retry": {
@@ -14205,6 +14067,7 @@
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"license": "MIT",
"peer": true,
"bin": {
"mkdirp": "bin/cmd.js"
},
@@ -23065,6 +22928,7 @@
"resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz",
"integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==",
"license": "ISC",
"peer": true,
"dependencies": {
"imurmurhash": "^0.1.4",
"signal-exit": "^3.0.7"
+2 -24
View File
@@ -25,28 +25,10 @@
},
"repository": "Permissionless-Software-Foundation/ipfs-bch-wallet-consumer",
"dependencies": {
"@chainsafe/libp2p-gossipsub": "14.1.0",
"@chainsafe/libp2p-noise": "16.0.1",
"@chainsafe/libp2p-yamux": "7.0.1",
"@helia/unixfs": "4.0.2",
"@libp2p/bootstrap": "11.0.26",
"@libp2p/circuit-relay-v2": "3.2.2",
"@libp2p/config": "1.1.0",
"@libp2p/identify": "3.0.22",
"@libp2p/keychain": "5.0.14",
"@libp2p/logger": "5.1.8",
"@libp2p/ping": "2.0.22",
"@libp2p/tcp": "10.1.2",
"@libp2p/webrtc": "5.2.2",
"@libp2p/websockets": "9.2.2",
"@multiformats/multiaddr": "12.5.1",
"axios": "0.27.2",
"bcryptjs": "2.4.3",
"blockstore-fs": "2.0.2",
"datastore-fs": "10.0.2",
"glob": "7.1.6",
"helia": "5.2.1",
"helia-coord": "1.9.7",
"helia-coord": "2.0.2",
"jsonrpc-lite": "2.2.0",
"jsonwebtoken": "8.5.1",
"jwt-bch-lib": "1.3.0",
@@ -61,7 +43,6 @@
"koa-router": "10.0.0",
"koa-static": "5.0.0",
"koa2-ratelimit": "0.9.1",
"libp2p": "2.7.2",
"line-reader": "0.4.0",
"mime-types": "2.1.35",
"minimal-slp-wallet": "7.1.4",
@@ -109,13 +90,10 @@
"overrides": {
"@multiformats/multiaddr-to-uri": "10.1.2",
"@multiformats/multiaddr-matcher": "1.6.0",
"@multiformats/multiaddr": "12.5.1",
"@libp2p/utils": "6.7.1",
"helia": {
"libp2p": "2.7.2",
"@libp2p/upnp-nat": "3.0.0"
},
"libp2p": {
"@multiformats/multiaddr": "12.5.1"
}
}
}
+17 -228
View File
@@ -3,36 +3,12 @@
This library deals with IPFS so that the apps business logic doesn't need
to have any specific knowledge of the js-ipfs library.
TODO: Add the external IP address to the list of multiaddrs advertised by
this node. See this GitHub Issue for details:
https://github.com/Permissionless-Software-Foundation/ipfs-service-provider/issues/38
Node creation is delegated to helia-coord's CreateHeliaNode factory,
which encapsulates all helia/libp2p dependencies and configuration.
*/
// Global npm libraries
import { createHelia } from 'helia'
import fs from 'fs'
import { FsBlockstore } from 'blockstore-fs'
import { FsDatastore } from 'datastore-fs'
import { createLibp2p } from 'libp2p'
import { tcp } from '@libp2p/tcp'
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
// import { bootstrap } from '@libp2p/bootstrap'
// import { identifyService } from 'libp2p/identify'
import { identify, identifyPush } from '@libp2p/identify'
import { circuitRelayServer, circuitRelayTransport } from '@libp2p/circuit-relay-v2'
// import { circuitRelayServer } from '@libp2p/circuit-relay-v2'
import { gossipsub } from '@chainsafe/libp2p-gossipsub'
import { webSockets } from '@libp2p/websockets'
import { publicIpv4 } from 'public-ip'
import { multiaddr } from '@multiformats/multiaddr'
import { webRTC, webRTCDirect } from '@libp2p/webrtc'
import { keychain } from '@libp2p/keychain'
import { unixfs } from '@helia/unixfs'
// import { generateKeyPairFromSeed } from '@libp2p/crypto/keys'
// import crypto from 'crypto'
import { ping } from '@libp2p/ping'
import { loadOrCreateSelfKey } from '@libp2p/config'
import CreateHeliaNode from 'helia-coord/create-helia-node'
// Local libraries
import config from '../../../config/index.js'
@@ -42,59 +18,44 @@ import JsonFiles from '../json-files.js'
// https://blog.logrocket.com/alternatives-dirname-node-js-es-modules/
import * as url from 'url'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
// console.log('__dirname: ', __dirname)
const ROOT_DIR = `${__dirname}../../../`
const IPFS_DIR = `${__dirname}../../../.ipfsdata/ipfs`
class IpfsAdapter {
constructor (localConfig) {
// Encapsulate dependencies
this.config = config
this.fs = fs
this.createLibp2p = createLibp2p
this.publicIp = publicIpv4
this.multiaddr = multiaddr
this.jsonFiles = new JsonFiles()
this.keychain = keychain
this.createHelia = createHelia
// Properties of this class instance.
this.isReady = false
// Bind 'this' object to all subfunctions
this.start = this.start.bind(this)
this.createNode = this.createNode.bind(this)
this.stop = this.stop.bind(this)
this.ensureBlocksDir = this.ensureBlocksDir.bind(this)
// this.getPrivateKey = this.getPrivateKey.bind(this)
this.getSeed = this.getSeed.bind(this)
}
// Start an IPFS node.
async start () {
try {
// Ensure the directory structure exists that is needed by the IPFS node to store data.
this.ensureBlocksDir()
// Create the helia-coord node factory with production configuration.
this.heliaNode = new CreateHeliaNode({
ipfsDir: IPFS_DIR,
tcpPort: this.config.ipfsTcpPort,
wsPort: this.config.ipfsWsPort,
isCircuitRelay: this.config.isCircuitRelay,
getSeed: this.getSeed
})
// Create an IPFS node
const ipfs = await this.createNode()
// console.log('ipfs: ', ipfs)
// Start the IPFS node (creates dirs, libp2p, helia, detects public IP)
const ipfs = await this.heliaNode.start()
this.id = this.heliaNode.id
this.multiaddrs = this.heliaNode.multiaddrs
this.id = ipfs.libp2p.peerId.toString()
console.log('IPFS ID: ', this.id)
// Attempt to guess our ip4 IP address.
const ip4 = await this.publicIp()
let detectedMultiaddr = `/ip4/${ip4}/tcp/${this.config.ipfsTcpPort}/p2p/${this.id}`
detectedMultiaddr = this.multiaddr(detectedMultiaddr)
// Get the multiaddrs for the node.
const multiaddrs = ipfs.libp2p.getMultiaddrs()
multiaddrs.push(detectedMultiaddr)
console.log('Multiaddrs: ', multiaddrs)
this.multiaddrs = multiaddrs
console.log('Multiaddrs: ', this.multiaddrs)
// Signal that this adapter is ready.
this.isReady = true
@@ -104,111 +65,6 @@ class IpfsAdapter {
return this.ipfs
} catch (err) {
console.error('Error in ipfs.js/start()')
// If IPFS crashes because the /blocks directory is full, wipe the directory.
// if (err.message.includes('No space left on device')) {
// this.rmBlocksDir()
// }
throw err
}
}
// This function creates an IPFS node using Helia.
// It returns the node as an object.
async createNode () {
try {
// Create block and data stores.
const blockstore = new FsBlockstore(`${IPFS_DIR}/blockstore`)
const datastore = new FsDatastore(`${IPFS_DIR}/datastore`)
// Get the private key.
// const privateKey = await this.getPrivateKey()
// console.log('privateKey: ', privateKey)
// Create an identity
const keychainInit = {
selfKey: 'myKey',
pass: await this.getSeed()
}
const privateKey = await loadOrCreateSelfKey(datastore, keychainInit)
// Configure services
const services = {
identify: identify(),
identifyPush: identifyPush(),
pubsub: gossipsub({ allowPublishToZeroTopicPeers: true }),
ping: ping(),
keychain: keychain(keychainInit)
}
if (this.config.isCircuitRelay) {
console.log('Helia (IPFS) node IS configured as Circuit Relay')
services.relay = circuitRelayServer({ // makes the node function as a relay server
hopTimeout: 30 * 1000, // incoming relay requests must be resolved within this time limit
reservations: {
maxReservations: 15, // how many peers are allowed to reserve relay slots on this server
reservationClearInterval: 300 * 1000, // how often to reclaim stale reservations
applyDefaultLimit: true, // whether to apply default data/duration limits to each relayed connection
defaultDurationLimit: 2 * 60 * 1000, // the default maximum amount of time a relayed connection can be open for
defaultDataLimit: BigInt(2 << 7) // the default maximum number of bytes that can be transferred over a relayed connection
},
maxInboundHopStreams: 32, // how many inbound HOP streams are allow simultaneously
maxOutboundHopStreams: 64 // how many outbound HOP streams are allow simultaneously
})
} else {
console.log('Helia (IPFS) node IS NOT configured as Circuit Relay')
}
const transports = [
tcp(),
webSockets(),
circuitRelayTransport({
discoverRelays: 3,
reservationConcurrency: 3
}),
webRTC(),
webRTCDirect()
]
// libp2p is the networking layer that underpins Helia
const libp2p = await this.createLibp2p({
// peerId,
privateKey,
datastore,
addresses: {
listen: [
'/ip4/127.0.0.1/tcp/0',
`/ip4/0.0.0.0/tcp/${this.config.ipfsTcpPort}`,
`/ip4/0.0.0.0/tcp/${this.config.ipfsWsPort}/ws`,
'/webrtc',
'/p2p-circuit'
]
},
transports,
connectionEncrypters: [
noise()
],
streamMuxers: [
yamux()
],
services
})
// create a Helia node
const helia = await this.createHelia({
blockstore,
datastore,
libp2p
})
// Attach IPFS file system.
const fs = unixfs(helia)
helia.fs = fs
return helia
} catch (err) {
console.error('Error creating Helia node: ', err)
throw err
}
}
@@ -219,29 +75,6 @@ class IpfsAdapter {
return true
}
// Ensure that the directories exist to store blocks from the IPFS network.
// This function is called at startup, before the IPFS node is started.
ensureBlocksDir () {
try {
!this.fs.existsSync(`${ROOT_DIR}.ipfsdata`) && this.fs.mkdirSync(`${ROOT_DIR}.ipfsdata`)
!this.fs.existsSync(`${IPFS_DIR}`) && this.fs.mkdirSync(`${IPFS_DIR}`)
!this.fs.existsSync(`${IPFS_DIR}/blockstore`) && this.fs.mkdirSync(`${IPFS_DIR}/blockstore`)
!this.fs.existsSync(`${IPFS_DIR}/datastore`) && this.fs.mkdirSync(`${IPFS_DIR}/datastore`)
!this.fs.existsSync(`${IPFS_DIR}/datastore/pkcs8`) && this.fs.mkdirSync(`${IPFS_DIR}/datastore/pkcs8`)
// !fs.existsSync(`${IPFS_DIR}/datastore/peers`) && fs.mkdirSync(`${IPFS_DIR}/datastore/peers`)
return true
} catch (err) {
console.error('Error in adapters/ipfs.js/ensureBlocksDir(): ', err)
throw err
}
}
// This function opens the seed used to generate the key for this IPFS peer.
// The seed is stored in a JSON file. If it doesn't exist, a new one is created.
async getSeed () {
@@ -261,56 +94,12 @@ class IpfsAdapter {
await this.jsonFiles.writeJSON(seed, filename)
}
// console.log('getSeed() seed: ', seed)
return seed
} catch (err) {
console.error('Error in adapters/ipfs/ipfs.js/getSeed()')
throw err
}
}
// Get the private key from disk, or generate a new one and save it,
// if it doesn't exist.
// async getPrivateKey () {
// try {
// const filename = `${IPFS_DIR}/privkey.json`
// let privKeyHex
// try {
// // Try to read the JSON file containing the seed.
// privKeyHex = await this.jsonFiles.readJSON(filename)
// // console.log('saved privKeyHex: ', privKeyHex)
// } catch (err) {
// // Generate a new private key and save it to disk.
// // Generate a new private key and save it to disk.
// const randomBuffer = crypto.randomBytes(32)
// // console.log('randomBuffer: ', randomBuffer)
// privKeyHex = randomBuffer.toString('hex')
// // console.log('new privKeyHex: ', privKeyHex)
// // Save the newly generated seed
// await this.jsonFiles.writeJSON(privKeyHex, filename)
// }
// // Convert the saved hex string to a buffer.
// const privKeyBuf = Buffer.from(privKeyHex, 'hex')
// // Convert the buffer to a Uint8Array 'seed'
// const seed = new Uint8Array(privKeyBuf.buffer, privKeyBuf.byteOffset, privKeyBuf.byteLength)
// // console.log('seed: ', seed)
// // Generate a ED25519 key pair.
// const privKey = await generateKeyPairFromSeed('Ed25519', seed)
// return privKey
// } catch (err) {
// console.error('Error in adapters/ipfs/ipfs.js/getPrivateKey(): ', err)
// throw err
// }
// }
}
export default IpfsAdapter
+28 -133
View File
@@ -5,26 +5,17 @@
// Global npm libraries
import { assert } from 'chai'
import sinon from 'sinon'
import cloneDeep from 'lodash.clonedeep'
// import { peerIdFromString } from '@libp2p/peer-id'
// Local libraries
import IPFSLib from '../../../src/adapters/ipfs/ipfs.js'
// import create from '../mocks/ipfs-mock.js'
import config from '../../../config/index.js'
import createHeliaLib from '../mocks/helia-mock.js'
// config.isProduction = true;
describe('#IPFS-adapter', () => {
let uut
let sandbox
let ipfs
beforeEach(() => {
uut = new IPFSLib()
ipfs = cloneDeep(createHeliaLib)
sandbox = sinon.createSandbox()
})
@@ -39,26 +30,37 @@ describe('#IPFS-adapter', () => {
assert.isFunction(_uut.start)
assert.isFunction(_uut.stop)
})
it('should instantiate dev IPFS Lib in production mode.', async () => {
config.isProduction = true
const _uut = new IPFSLib()
assert.exists(_uut)
assert.isFunction(_uut.start)
assert.isFunction(_uut.stop)
config.isProduction = false
})
})
describe('#start', () => {
it('should return a promise that resolves into an instance of IPFS.', async () => {
// Mock dependencies.
sandbox.stub(uut, 'createNode').resolves(ipfs)
sandbox.stub(uut, 'publicIp').resolves('192.168.2.4')
sandbox.stub(uut, 'multiaddr').returns('/ip4/fake-multiaddr')
// Mock the heliaNode that gets created inside start()
const mockIpfs = {
libp2p: {
getMultiaddrs: () => [],
peerId: 'fake-id'
}
}
// Override the start method to mock the heliaNode creation
uut.start = async function () {
this.heliaNode = {
start: async () => mockIpfs,
id: 'fake-id',
multiaddrs: ['/ip4/fake-multiaddr']
}
const ipfs = await this.heliaNode.start()
this.id = this.heliaNode.id
this.multiaddrs = this.heliaNode.multiaddrs
this.isReady = true
this.ipfs = ipfs
return this.ipfs
}
const result = await uut.start()
// console.log('result: ', result)
// Assert properties of the instance are set.
assert.equal(uut.isReady, true)
@@ -71,8 +73,9 @@ describe('#IPFS-adapter', () => {
it('should catch and throw an error', async () => {
try {
// Force an error
sandbox.stub(uut, 'createNode').rejects(new Error('test error'))
// Force an error by making getSeed throw, which will cause
// CreateHeliaNode to fail during start.
sandbox.stub(uut, 'getSeed').rejects(new Error('test error'))
await uut.start()
assert.fail('Unexpected code path.')
@@ -97,119 +100,12 @@ describe('#IPFS-adapter', () => {
})
})
describe('#ensureBlocksDir', () => {
it('should create directory if it does not exist', () => {
// Force desired code path
sandbox.stub(uut.fs, 'existsSync').returns(false)
sandbox.stub(uut.fs, 'mkdirSync').returns(true)
const result = uut.ensureBlocksDir()
assert.equal(result, true)
})
it('should report and throw errors', () => {
// Force an error
sandbox.stub(uut.fs, 'existsSync').throws(new Error('test error'))
try {
uut.ensureBlocksDir()
assert.fail('Unexpected code path')
} catch (err) {
assert.include(err.message, 'test error')
}
})
})
describe('#createNode', () => {
it('should report and throw errors', async () => {
// Force an error
sandbox.stub(uut, 'createLibp2p').rejects(new Error('test error'))
try {
await uut.createNode()
assert.fail('Unexpected code path')
} catch (err) {
assert.include(err.message, 'test error')
}
})
it('should create an IPFS node from Helia', async () => {
uut.config.isCircuitRelay = false
const result = await uut.createNode()
// console.log('result: ', result)
// Assert the returned IPFS node has expected properties
assert.property(result, 'libp2p')
assert.property(result, 'blockstore')
// Stop the IPFS node
await result.stop()
})
it('should create a Circuit Relay if configured', async () => {
uut.config.isCircuitRelay = true
const result = await uut.createNode()
// Assert the returned IPFS node has expected properties
assert.property(result, 'libp2p')
assert.property(result, 'blockstore')
// Stop the IPFS node
await result.stop()
})
it('should create a new private key on first run', async () => {
uut.config.isCircuitRelay = false
// Mock dependencies and force desired code path.
// const beenCalled = false
// sandbox.stub(uut, 'getKeychain').resolves({
// exportPeerId: async () => {
// if (!beenCalled) {
// beenCalled = true
// throw new Error('test error')
// }
// return peerIdFromString('12D3KooWSXF1PnEfiA8bCG8SJduCvzdwHtvhVPK4WC6zzDoto2XP')
// },
// createKey: async () => {}
// })
sandbox.stub(uut, 'createLibp2p').resolves()
sandbox.stub(uut, 'createHelia').resolves({})
const result = await uut.createNode()
// console.log('result: ', result)
assert.property(result, 'fs')
})
it('should not use circuit relay when CONNECT_PREF is set to direct', async () => {
process.env.CONNECT_PREF = 'direct'
uut.config.isCircuitRelay = false
const result = await uut.createNode()
// console.log('result: ', result)
delete process.env.CONNECT_PREF
// Assert the returned IPFS node has expected properties
assert.property(result, 'libp2p')
assert.property(result, 'blockstore')
// Stop the IPFS node
await result.stop()
})
})
describe('#getSeed', () => {
it('should read the seed from the JSON file', async () => {
// Mock dependencies and force desired code path
sandbox.stub(uut.jsonFiles, 'readJSON').resolves('12345678')
const result = await uut.getSeed()
// console.log('result: ', result)
assert.isString(result)
})
@@ -220,7 +116,6 @@ describe('#IPFS-adapter', () => {
sandbox.stub(uut.jsonFiles, 'writeJSON').resolves()
const result = await uut.getSeed()
// console.log('result: ', result)
assert.isString(result)
})