Compare commits
93 Commits
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | 98c451cf36 | |
Derrick Hammer | ff754773e6 | |
Derrick Hammer | 3f3e581ce2 | |
Derrick Hammer | 861a8229d4 | |
Derrick Hammer | c29f2422a2 | |
Derrick Hammer | 2b3b6dd0f3 | |
Derrick Hammer | 483ac62f96 | |
Derrick Hammer | 1a544d7c2d | |
semantic-release-bot | f0c19a7bb4 | |
Derrick Hammer | d8899221d2 | |
Derrick Hammer | a07dc0d613 | |
semantic-release-bot | 00fb3f5908 | |
Derrick Hammer | 433a8f194b | |
Derrick Hammer | 4843067541 | |
semantic-release-bot | 8f3e24be5c | |
Derrick Hammer | bfe66cd3af | |
semantic-release-bot | ac7941af0a | |
Derrick Hammer | 82e3500443 | |
Derrick Hammer | 64df3c561e | |
semantic-release-bot | bbb3b3cb4c | |
Derrick Hammer | baae8f7c00 | |
Derrick Hammer | 8ee63d87b0 | |
Derrick Hammer | 9d2d0b35cd | |
semantic-release-bot | 9be1126acd | |
Derrick Hammer | 15915d9715 | |
Derrick Hammer | 95f40957df | |
semantic-release-bot | e4c08af4af | |
Derrick Hammer | 6bd3167f43 | |
Derrick Hammer | 277ed207b9 | |
semantic-release-bot | 998dfc0e75 | |
Derrick Hammer | a6187d2c0f | |
Derrick Hammer | 6298d8e914 | |
semantic-release-bot | ba094e3ae8 | |
Derrick Hammer | cb162f5135 | |
Derrick Hammer | a27aeb2ec8 | |
semantic-release-bot | c8f3cc70da | |
Derrick Hammer | d23c583cf5 | |
Derrick Hammer | f1b8a603df | |
Derrick Hammer | 2b04fecc7c | |
semantic-release-bot | e6555412b9 | |
Derrick Hammer | dcc0499157 | |
Derrick Hammer | 958699038f | |
semantic-release-bot | 3ba37bcf15 | |
Derrick Hammer | 7e023efa87 | |
Derrick Hammer | a61b0d4771 | |
Derrick Hammer | 3befddd410 | |
semantic-release-bot | a787f19b9d | |
Derrick Hammer | 0b14f84954 | |
Derrick Hammer | 26bbe2900c | |
semantic-release-bot | c3421ad6d6 | |
Derrick Hammer | 01e5afb7b2 | |
Derrick Hammer | 005a128a2c | |
semantic-release-bot | 62bb02a3d8 | |
Derrick Hammer | d739b0a286 | |
Derrick Hammer | 9f8679773d | |
Derrick Hammer | ce237fc1a3 | |
Derrick Hammer | fc823b0b60 | |
semantic-release-bot | af1dce26e9 | |
Derrick Hammer | cff181d2c7 | |
Derrick Hammer | 2920d3b3ad | |
semantic-release-bot | d87c589c3d | |
Derrick Hammer | 653833d552 | |
Derrick Hammer | 16dcaafd78 | |
semantic-release-bot | 7147b9f8ba | |
Derrick Hammer | 9683960782 | |
Derrick Hammer | 49a599a782 | |
semantic-release-bot | 9000d05bc8 | |
Derrick Hammer | d0a808f74a | |
Derrick Hammer | 7c8490c6f5 | |
semantic-release-bot | 48d48f21ea | |
Derrick Hammer | a87adf0d75 | |
Derrick Hammer | 8a11e4be21 | |
semantic-release-bot | 4f3593a4f9 | |
Derrick Hammer | f248df89b9 | |
Derrick Hammer | 9475e18eaa | |
semantic-release-bot | 40e7eb7b6f | |
Derrick Hammer | cb1608a4df | |
Derrick Hammer | 663a67c7ba | |
Derrick Hammer | 81f4fc2a0f | |
semantic-release-bot | 7486cf2034 | |
Derrick Hammer | 8668a9b734 | |
Derrick Hammer | 35c14bd3a6 | |
semantic-release-bot | d8c2e12959 | |
Derrick Hammer | b2dd0069f1 | |
Derrick Hammer | 391ad98113 | |
semantic-release-bot | b370e45b5b | |
Derrick Hammer | 1ced0560ec | |
Derrick Hammer | f8a0c55340 | |
semantic-release-bot | c2674c9df2 | |
Derrick Hammer | 04438ee02c | |
Derrick Hammer | 15df3a86d3 | |
Derrick Hammer | 659428c812 | |
Derrick Hammer | 774aab1a21 |
|
@ -0,0 +1,13 @@
|
||||||
|
name: Build/Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- develop-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
|
||||||
|
secrets: inherit
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"preset": [
|
||||||
|
"@lumeweb/presetter-kernel-module-preset"
|
||||||
|
],
|
||||||
|
"config": {
|
||||||
|
"vite": {
|
||||||
|
"resolve": {
|
||||||
|
"alias": {
|
||||||
|
"protomux": "@lumeweb/kernel-protomux-client"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"optimize": {
|
||||||
|
"@achingbrain/nat-port-mapper": "export default {}; export const upnpNat = {};"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,110 @@
|
||||||
|
# [0.1.0-develop.23](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.22...v0.1.0-develop.23) (2023-10-18)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add hypercoreTransport back ([483ac62](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/483ac62f96d5a968666661468bd108a7ca57a8bb))
|
||||||
|
* need to use dns friendly cids for IPNS ([861a822](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/861a8229d49da93158c2ec1e41747a2d9c14b13f))
|
||||||
|
* remove delegated routing again ([2b3b6dd](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/2b3b6dd0f396875b030a9dd81cad52cac3ac284f))
|
||||||
|
|
||||||
|
# [0.1.0-develop.22](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.21...v0.1.0-develop.22) (2023-10-15)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* networkReady should start as false ([a07dc0d](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/a07dc0d613ee0ba79acf6c01df8eb34c58512939))
|
||||||
|
|
||||||
|
# [0.1.0-develop.21](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.20...v0.1.0-develop.21) (2023-10-13)
|
||||||
|
|
||||||
|
# [0.1.0-develop.20](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.19...v0.1.0-develop.20) (2023-10-12)
|
||||||
|
|
||||||
|
# [0.1.0-develop.19](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.18...v0.1.0-develop.19) (2023-09-09)
|
||||||
|
|
||||||
|
# [0.1.0-develop.18](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.17...v0.1.0-develop.18) (2023-09-09)
|
||||||
|
|
||||||
|
# [0.1.0-develop.17](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.16...v0.1.0-develop.17) (2023-09-03)
|
||||||
|
|
||||||
|
# [0.1.0-develop.16](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.15...v0.1.0-develop.16) (2023-09-02)
|
||||||
|
|
||||||
|
# [0.1.0-develop.15](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.14...v0.1.0-develop.15) (2023-07-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add delegatedContentRouting back for now ([6298d8e](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/6298d8e914eafdc62a23b0bad548902545489c4e))
|
||||||
|
|
||||||
|
# [0.1.0-develop.14](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.13...v0.1.0-develop.14) (2023-07-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* if the network is ready then fetch the peer count ([a27aeb2](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/a27aeb2ec8493b933b3305b2b14e3c960d7c1d0c))
|
||||||
|
|
||||||
|
# [0.1.0-develop.13](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.12...v0.1.0-develop.13) (2023-07-31)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add event listener on libp2p start for redundancy to ensure we max the events to read the peer count ([f1b8a60](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/f1b8a603dfdca93e08692e7ad29fd2466c76d6d0))
|
||||||
|
|
||||||
|
# [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-07-30)
|
||||||
|
|
||||||
|
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-07-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add ipni fallback ([a61b0d4](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/a61b0d4771e885092bb47216f5fd525fa27caf4b))
|
||||||
|
|
||||||
|
# [0.1.0-develop.10](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.9...v0.1.0-develop.10) (2023-07-29)
|
||||||
|
|
||||||
|
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-07-29)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add name api call ([005a128](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/005a128a2c159ca88199bb85598a24fd0c9b2da6))
|
||||||
|
|
||||||
|
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-07-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* patch noble ed25519 to inject @peculiar/webcrypto ([d739b0a](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/d739b0a28697450e7fe46e96e43edfa5446d8885))
|
||||||
|
|
||||||
|
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-07-23)
|
||||||
|
|
||||||
|
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-07-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add status api ([16dcaaf](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/16dcaafd781ee3957a489c73b8027b2eabca648f))
|
||||||
|
|
||||||
|
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-07-23)
|
||||||
|
|
||||||
|
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-07-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* need to override protomux with our kernel-protomux-client ([7c8490c](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/7c8490c6f50d2b91880b1aea20f69ce4492dfb01))
|
||||||
|
|
||||||
|
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-07-21)
|
||||||
|
|
||||||
|
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-07-19)
|
||||||
|
|
||||||
|
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.0.2-develop.4...v0.1.0-develop.1) (2023-07-19)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add register method for network registry ([663a67c](https://git.lumeweb.com/LumeWeb/kernel-ipfs/commit/663a67c7ba9450c6a499f6ce3dcb06d0245476d3))
|
||||||
|
|
||||||
|
## [0.0.2-develop.4](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.0.2-develop.3...v0.0.2-develop.4) (2023-07-12)
|
||||||
|
|
||||||
|
## [0.0.2-develop.3](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.0.2-develop.2...v0.0.2-develop.3) (2023-07-09)
|
||||||
|
|
||||||
|
## [0.0.2-develop.2](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.0.2-develop.1...v0.0.2-develop.2) (2023-07-08)
|
||||||
|
|
||||||
|
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.0.1...v0.0.2-develop.1) (2023-07-06)
|
14
build.js
14
build.js
|
@ -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",
|
|
||||||
},
|
|
||||||
inject: ["polyfill.js"],
|
|
||||||
});
|
|
File diff suppressed because it is too large
Load Diff
145
package.json
145
package.json
|
@ -1,116 +1,59 @@
|
||||||
{
|
{
|
||||||
"name": "@lumeweb/kernel-ipfs",
|
"name": "@lumeweb/kernel-ipfs",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0-develop.23",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"readme": "ERROR: No README data found!",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-ipfs.git"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest",
|
"prepare": "presetter bootstrap",
|
||||||
"build-script": "tsc --project tsconfig.build.json && mv dist-build/build.js dist-build/build.mjs",
|
"build": "run build",
|
||||||
"compile": "npm run build-script && node build.js",
|
"semantic-release": "semantic-release",
|
||||||
"build": "npm run compile && node ./dist-build/build.mjs dev"
|
"postinstall": "patch-package"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chainsafe/libp2p-gossipsub": "^6.3.0",
|
"@helia/ipns": "^1.1.3",
|
||||||
"@chainsafe/libp2p-noise": "^11.0.4",
|
"@helia/unixfs": "^1.4.0",
|
||||||
"@chainsafe/libp2p-yamux": "^3.0.10",
|
"@libp2p/delegated-content-routing": "^4.0.6",
|
||||||
"@dao-xyz/libp2p-noise": "^11.1.3",
|
"@libp2p/delegated-peer-routing": "^4.0.9",
|
||||||
"@helia/ipns": "^1.1.0",
|
"@libp2p/peer-id": "^2.0.4",
|
||||||
"@helia/unixfs": "^1.2.2",
|
"@libp2p/reframe-content-routing": "^1.0.1",
|
||||||
"@libp2p/bootstrap": "^6.0.3",
|
"@libp2p/tcp": "7.0.3",
|
||||||
"@libp2p/crypto": "^1.0.15",
|
"@lumeweb/kernel-network-registry-client": "^0.1.0-develop.10",
|
||||||
"@libp2p/delegated-content-routing": "^4.0.3",
|
"@lumeweb/kernel-protomux-client": "^0.0.2-develop.22",
|
||||||
"@libp2p/delegated-peer-routing": "^4.0.5",
|
"@lumeweb/kernel-swarm-client": "0.1.0-develop.12",
|
||||||
"@libp2p/interface-metrics": "^4.0.6",
|
"@lumeweb/libhyperproxy": "^0.0.2-develop.4",
|
||||||
"@libp2p/interfaces": "^3.3.1",
|
"@lumeweb/libkernel": "0.1.0-develop.66",
|
||||||
"@libp2p/logger": "^2.0.7",
|
"@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.44",
|
||||||
"@libp2p/mplex": "^7.1.7",
|
"@peculiar/webcrypto": "^1.4.3",
|
||||||
"@libp2p/tcp": "^6.2.1",
|
"blockstore-idb": "^1.1.1",
|
||||||
"@libp2p/utils": "^3.0.8",
|
"datastore-core": "^9.2.0",
|
||||||
"@lumeweb/kernel-protomux-client": "git+https://git.lumeweb.com/LumeWeb/kernel-protomux-client.git",
|
"datastore-idb": "^2.1.2",
|
||||||
"@lumeweb/kernel-swarm-client": "git+https://git.lumeweb.com/LumeWeb/kernel-swarm-client.git",
|
"helia": "^2.0.3-43932a5",
|
||||||
"@lumeweb/libkernel-universal": "git+https://git.lumeweb.com/LumeWeb/libkernel-universal.git",
|
"ipfs-http-client": "^60.0.1",
|
||||||
"@multiformats/mafmt": "^11.1.2",
|
"ipns": "^7.0.1",
|
||||||
"@peculiar/webcrypto": "git+https://git.lumeweb.com/LumeWeb/webcrypto.git",
|
"multiformats": "^12.0.1",
|
||||||
"b4a": "^1.6.3",
|
|
||||||
"blockstore-idb": "^1.1.0",
|
|
||||||
"buffer": "^6.0.3",
|
|
||||||
"compact-encoding": "^2.11.0",
|
|
||||||
"datastore-core": "^8.0.4",
|
|
||||||
"datastore-idb": "^2.1.1",
|
|
||||||
"helia": "^0.0.1",
|
|
||||||
"ipfs-http-client": "^60.0.0",
|
|
||||||
"ipfs-in-memory-repo": "^0.1.0",
|
|
||||||
"libkmodule": "^0.2.53",
|
|
||||||
"libp2p": "^0.42.2",
|
|
||||||
"multiformats": "^11.0.2",
|
|
||||||
"p-defer": "^4.0.0",
|
"p-defer": "^4.0.0",
|
||||||
"p-queue": "^7.3.4",
|
"path-browserify": "^1.0.1",
|
||||||
"private-ip": "^3.0.0",
|
|
||||||
"rewire": "^6.0.0",
|
|
||||||
"runes2": "^1.1.2",
|
"runes2": "^1.1.2",
|
||||||
"serialize-error": "^11.0.0",
|
|
||||||
"sodium-universal": "^4.0.0",
|
|
||||||
"streamx": "^2.13.2",
|
|
||||||
"timers-browserify": "^2.0.12"
|
"timers-browserify": "^2.0.12"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@helia/interface": "^0.0.0",
|
"@rollup/plugin-alias": "^5.0.0",
|
||||||
"@libp2p/interface-connection": "^3.1.1",
|
|
||||||
"@libp2p/interface-peer-info": "^1.0.9",
|
|
||||||
"@libp2p/interface-transport": "^2.1.3",
|
|
||||||
"@libp2p/kad-dht": "^7.0.3",
|
|
||||||
"@libp2p/peer-id": "^2.0.3",
|
|
||||||
"@libp2p/peer-id-factory": "^2.0.3",
|
|
||||||
"@libp2p/websockets": "^5.0.10",
|
|
||||||
"@lumeweb/libhyperproxy": "git+https://git.lumeweb.com/LumeWeb/libhyperproxy.git",
|
|
||||||
"@multiformats/multiaddr": "^11.6.1",
|
|
||||||
"@scure/bip39": "^1.2.0",
|
|
||||||
"@skynetlabs/skynet-nodejs": "^2.9.0",
|
|
||||||
"@types/b4a": "^1.6.0",
|
|
||||||
"@types/events": "^3.0.0",
|
|
||||||
"@types/node": "^18.15.11",
|
|
||||||
"@types/read": "^0.0.29",
|
|
||||||
"@types/rewire": "^2.5.28",
|
|
||||||
"@types/streamx": "^2.9.1",
|
|
||||||
"@types/ws": "^8.5.4",
|
|
||||||
"cli-progress": "^3.12.0",
|
|
||||||
"crypto-browserify": "^3.12.0",
|
|
||||||
"esbuild": "^0.14.54",
|
|
||||||
"http-browserify": "^1.7.0",
|
|
||||||
"hyperswarm": "^4.4.0",
|
|
||||||
"interface-store": "^3.0.4",
|
|
||||||
"it-all": "^2.0.1",
|
|
||||||
"it-ws": "^5.0.6",
|
|
||||||
"libskynet": "^0.1.9",
|
|
||||||
"libskynetnode": "^0.1.4",
|
|
||||||
"net-browserify": "^0.2.4",
|
|
||||||
"os-browserify": "^0.3.0",
|
"os-browserify": "^0.3.0",
|
||||||
"p-timeout": "^6.1.1",
|
"patch-package": "^7.0.0",
|
||||||
"path-browserify": "^1.0.1",
|
"rollup-plugin-ignore-import": "^1.3.2"
|
||||||
"prettier": "^2.8.7",
|
|
||||||
"prom-client": "^14.2.0",
|
|
||||||
"read": "^1.0.7",
|
|
||||||
"stream-browserify": "^3.0.0",
|
|
||||||
"tslib": "^2.5.0",
|
|
||||||
"typescript": "^4.9.5",
|
|
||||||
"url-browser": "^0.1.7",
|
|
||||||
"util-browser": "^0.0.2"
|
|
||||||
},
|
},
|
||||||
"browser": {
|
"overrides": {
|
||||||
"libkernel": false,
|
"libp2p": "^0.46.6",
|
||||||
"timers": "timers-browserify",
|
"@libp2p/kad-dht": "^10.0.2",
|
||||||
"path": "path-browserify",
|
"@chainsafe/libp2p-noise": "^12.0.0",
|
||||||
"os": "os-browserify",
|
"@libp2p/mplex": "^9.0.2",
|
||||||
"net": "./src/net.ts",
|
"@libp2p/bootstrap": "^9.0.2",
|
||||||
"crypto": "crypto-browserify",
|
"@chainsafe/libp2p-gossipsub": "^10.0.0",
|
||||||
"stream": "stream-browserify"
|
"@libp2p/interface-datastore": "^8.0.0",
|
||||||
},
|
"@libp2p/interface-blockstore": "^5.0.0"
|
||||||
"pnpm": {
|
|
||||||
"overrides": {
|
|
||||||
"protomux": "git+https://git.lumeweb.com/LumeWeb/kernel-protomux-client.git"
|
|
||||||
},
|
|
||||||
"patchedDependencies": {
|
|
||||||
"@libp2p/tcp@6.2.1": "patches/@libp2p__tcp@6.2.1.patch",
|
|
||||||
"b4a@1.6.3": "patches/b4a@1.6.3.patch"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
diff --git a/node_modules/@libp2p/tcp/dist/src/index.js b/node_modules/@libp2p/tcp/dist/src/index.js
|
||||||
|
index fe47701..d239a6a 100644
|
||||||
|
--- a/node_modules/@libp2p/tcp/dist/src/index.js
|
||||||
|
+++ b/node_modules/@libp2p/tcp/dist/src/index.js
|
||||||
|
@@ -8,7 +8,7 @@ import { TCPListener } from './listener.js';
|
||||||
|
import { toMultiaddrConnection } from './socket-to-conn.js';
|
||||||
|
import { multiaddrToNetConfig } from './utils.js';
|
||||||
|
const log = logger('libp2p:tcp');
|
||||||
|
-class TCP {
|
||||||
|
+export class TCP {
|
||||||
|
opts;
|
||||||
|
metrics;
|
||||||
|
components;
|
||||||
|
diff --git a/node_modules/@libp2p/tcp/package.json b/node_modules/@libp2p/tcp/package.json
|
||||||
|
index e4524a9..74fa657 100644
|
||||||
|
--- a/node_modules/@libp2p/tcp/package.json
|
||||||
|
+++ b/node_modules/@libp2p/tcp/package.json
|
||||||
|
@@ -32,12 +32,20 @@
|
||||||
|
"!dist/test",
|
||||||
|
"!**/*.tsbuildinfo"
|
||||||
|
],
|
||||||
|
- "exports": {
|
||||||
|
- ".": {
|
||||||
|
- "types": "./dist/src/index.d.ts",
|
||||||
|
- "import": "./dist/src/index.js"
|
||||||
|
- }
|
||||||
|
- },
|
||||||
|
+ "exports": {
|
||||||
|
+ ".": {
|
||||||
|
+ "types": "./dist/src/index.d.ts",
|
||||||
|
+ "import": "./dist/src/index.js"
|
||||||
|
+ },
|
||||||
|
+ "./socket-to-conn": {
|
||||||
|
+ "types": "./dist/src/socket-to-conn.d.ts",
|
||||||
|
+ "import": "./dist/src/socket-to-conn.js"
|
||||||
|
+ },
|
||||||
|
+ "./utils": {
|
||||||
|
+ "types": "./dist/src/utils.d.ts",
|
||||||
|
+ "import": "./dist/src/utils.js"
|
||||||
|
+ }
|
||||||
|
+ },
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": "ipfs",
|
||||||
|
"parserOptions": {
|
|
@ -1,32 +0,0 @@
|
||||||
diff --git a/dist/src/index.js b/dist/src/index.js
|
|
||||||
index dab2ad35e64981f00c59a48ccbcbe407eb7749e6..7179d4ad8137be05e5f080ca67ea433c9dfaeeb0 100644
|
|
||||||
--- a/dist/src/index.js
|
|
||||||
+++ b/dist/src/index.js
|
|
||||||
@@ -8,7 +8,7 @@ import { AbortError, CodeError } from '@libp2p/interfaces/errors';
|
|
||||||
import { CODE_CIRCUIT, CODE_P2P, CODE_UNIX } from './constants.js';
|
|
||||||
import { symbol } from '@libp2p/interface-transport';
|
|
||||||
const log = logger('libp2p:tcp');
|
|
||||||
-class TCP {
|
|
||||||
+export class TCP {
|
|
||||||
constructor(components, options = {}) {
|
|
||||||
this.opts = options;
|
|
||||||
this.components = components;
|
|
||||||
diff --git a/package.json b/package.json
|
|
||||||
index 2e38ab0bdeef25a898770aedd0459e8c0cd79a9b..9ec4c16e10347e5f9717998725387b30d5b59907 100644
|
|
||||||
--- a/package.json
|
|
||||||
+++ b/package.json
|
|
||||||
@@ -36,6 +36,14 @@
|
|
||||||
".": {
|
|
||||||
"types": "./dist/src/index.d.ts",
|
|
||||||
"import": "./dist/src/index.js"
|
|
||||||
+ },
|
|
||||||
+ "./socket-to-conn": {
|
|
||||||
+ "types": "./dist/src/socket-to-conn.d.ts",
|
|
||||||
+ "import": "./dist/src/socket-to-conn.js"
|
|
||||||
+ },
|
|
||||||
+ "./utils": {
|
|
||||||
+ "types": "./dist/src/utils.d.ts",
|
|
||||||
+ "import": "./dist/src/utils.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"eslintConfig": {
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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"
|
|
||||||
},
|
|
13
polyfill.js
13
polyfill.js
|
@ -1,13 +0,0 @@
|
||||||
import { Crypto } from "@peculiar/webcrypto";
|
|
||||||
import { Buffer } from "buffer";
|
|
||||||
|
|
||||||
let globalCrypto = self.crypto;
|
|
||||||
if (!globalCrypto.subtle) {
|
|
||||||
let subtleCrypto = new Crypto().subtle;
|
|
||||||
Object.defineProperty(globalCrypto, "subtle", {
|
|
||||||
get() {
|
|
||||||
return subtleCrypto;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
export { Buffer };
|
|
|
@ -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("");
|
|
||||||
}
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
import type { BootstrapInit } from "@libp2p/bootstrap";
|
||||||
|
|
||||||
|
export const bootstrapConfig = {
|
||||||
|
list: [
|
||||||
|
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
|
||||||
|
"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
|
||||||
|
"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
|
||||||
|
"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
|
||||||
|
"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
|
||||||
|
// Cloudflare
|
||||||
|
"/dnsaddr/node-1.ingress.cloudflare-ipfs.com/p2p/QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE",
|
||||||
|
"/dnsaddr/node-2.ingress.cloudflare-ipfs.com/p2p/QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z",
|
||||||
|
"/dnsaddr/node-3.ingress.cloudflare-ipfs.com/p2p/QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa",
|
||||||
|
"/dnsaddr/node-4.ingress.cloudflare-ipfs.com/p2p/QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx",
|
||||||
|
"/dnsaddr/node-5.ingress.cloudflare-ipfs.com/p2p/QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ",
|
||||||
|
"/dnsaddr/node-6.ingress.cloudflare-ipfs.com/p2p/QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G",
|
||||||
|
"/dnsaddr/node-7.ingress.cloudflare-ipfs.com/p2p/QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3",
|
||||||
|
"/dnsaddr/node-8.ingress.cloudflare-ipfs.com/p2p/QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP",
|
||||||
|
"/dnsaddr/node-9.ingress.cloudflare-ipfs.com/p2p/Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi",
|
||||||
|
"/dnsaddr/node-10.ingress.cloudflare-ipfs.com/p2p/QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx",
|
||||||
|
"/dnsaddr/node-11.ingress.cloudflare-ipfs.com/p2p/Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5",
|
||||||
|
"/dnsaddr/node-12.ingress.cloudflare-ipfs.com/p2p/QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev",
|
||||||
|
// Estuary
|
||||||
|
"/ip4/139.178.68.217/tcp/6744/p2p/12D3KooWCVXs8P7iq6ao4XhfAmKWrEeuKFWCJgqe9jGDMTqHYBjw",
|
||||||
|
"/ip4/147.75.49.71/tcp/6745/p2p/12D3KooWGBWx9gyUFTVQcKMTenQMSyE2ad9m7c9fpjS4NMjoDien",
|
||||||
|
"/ip4/147.75.86.255/tcp/6745/p2p/12D3KooWFrnuj5o3tx4fGD2ZVJRyDqTdzGnU3XYXmBbWbc8Hs8Nd",
|
||||||
|
"/ip4/3.134.223.177/tcp/6745/p2p/12D3KooWN8vAoGd6eurUSidcpLYguQiGZwt4eVgDvbgaS7kiGTup",
|
||||||
|
"/ip4/35.74.45.12/udp/6746/quic/p2p/12D3KooWLV128pddyvoG6NBvoZw7sSrgpMTPtjnpu3mSmENqhtL7",
|
||||||
|
|
||||||
|
// Pinata
|
||||||
|
"/dnsaddr/fra1-1.hostnodes.pinata.cloud/p2p/QmWaik1eJcGHq1ybTWe7sezRfqKNcDRNkeBaLnGwQJz1Cj",
|
||||||
|
"/dnsaddr/fra1-2.hostnodes.pinata.cloud/p2p/QmNfpLrQQZr5Ns9FAJKpyzgnDL2GgC6xBug1yUZozKFgu4",
|
||||||
|
"/dnsaddr/fra1-3.hostnodes.pinata.cloud/p2p/QmPo1ygpngghu5it8u4Mr3ym6SEU2Wp2wA66Z91Y1S1g29",
|
||||||
|
"/dnsaddr/nyc1-1.hostnodes.pinata.cloud/p2p/QmRjLSisUCHVpFa5ELVvX3qVPfdxajxWJEHs9kN3EcxAW6",
|
||||||
|
"/dnsaddr/nyc1-2.hostnodes.pinata.cloud/p2p/QmPySsdmbczdZYBpbi2oq2WMJ8ErbfxtkG8Mo192UHkfGP",
|
||||||
|
"/dnsaddr/nyc1-3.hostnodes.pinata.cloud/p2p/QmSarArpxemsPESa6FNkmuu9iSE1QWqPX2R3Aw6f5jq4D5",
|
||||||
|
// Eternum
|
||||||
|
"/dns4/door.eternum.io/tcp/4001/ipfs/QmVBxJ5GekATHi89H8jbXjaU6CosCnteomjNR5xar2aH3q",
|
||||||
|
// Textile
|
||||||
|
"/ip4/104.210.43.77/p2p/QmR69wtWUMm1TWnmuD4JqC1TWLZcc8iR2KrTenfZZbiztd",
|
||||||
|
// 8api.sh
|
||||||
|
"/ip4/78.46.108.24/p2p/12D3KooWGASC2jm3pmohEJXUhuStkxDitPgzvs4qMuFPaiD9x1BA",
|
||||||
|
"/ip4/65.109.19.136/p2p/12D3KooWRbWZN3GvLf9CHmozq4vnTzDD4EEoiqtRJxg5FV6Gfjmm",
|
||||||
|
|
||||||
|
// Storj
|
||||||
|
"/ip4/5.161.92.43/tcp/4001/p2p/12D3KooWFFhc8fPYnQXdWBCowxSV21EFYin3rU27p3NVgSMjN41k",
|
||||||
|
"/ip4/5.161.92.43/udp/4001/quic/p2p/12D3KooWFFhc8fPYnQXdWBCowxSV21EFYin3rU27p3NVgSMjN41k",
|
||||||
|
"/ip6/2a01:4ff:f0:3b1e::1/tcp/4001/p2p/12D3KooWFFhc8fPYnQXdWBCowxSV21EFYin3rU27p3NVgSMjN41k",
|
||||||
|
"/ip6/2a01:4ff:f0:3b1e::1/udp/4001/quic/p2p/12D3KooWFFhc8fPYnQXdWBCowxSV21EFYin3rU27p3NVgSMjN41k",
|
||||||
|
"/ip4/5.161.55.227/tcp/4001/p2p/12D3KooWSW4hoHmDXmY5rW7nCi9XmGTy3foFt72u86jNP53LTNBJ",
|
||||||
|
"/ip4/5.161.55.227/udp/4001/quic/p2p/12D3KooWSW4hoHmDXmY5rW7nCi9XmGTy3foFt72u86jNP53LTNBJ",
|
||||||
|
"/ip6/2a01:4ff:f0:1e5a::1/tcp/4001/p2p/12D3KooWSW4hoHmDXmY5rW7nCi9XmGTy3foFt72u86jNP53LTNBJ",
|
||||||
|
"/ip6/2a01:4ff:f0:1e5a::1/udp/4001/quic/p2p/12D3KooWSW4hoHmDXmY5rW7nCi9XmGTy3foFt72u86jNP53LTNBJ",
|
||||||
|
"/ip4/5.161.92.36/tcp/4001/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
||||||
|
"/ip4/5.161.92.36/udp/4001/quic/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
||||||
|
"/ip6/2a01:4ff:f0:3764::1/tcp/4001/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
||||||
|
"/ip6/2a01:4ff:f0:3764::1/udp/4001/quic/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
||||||
|
],
|
||||||
|
} as BootstrapInit;
|
|
@ -0,0 +1,84 @@
|
||||||
|
import { gossipsub } from "@chainsafe/libp2p-gossipsub";
|
||||||
|
import { noise } from "@chainsafe/libp2p-noise";
|
||||||
|
import { yamux } from "@chainsafe/libp2p-yamux";
|
||||||
|
import { bootstrap } from "@libp2p/bootstrap";
|
||||||
|
import { type DualKadDHT, kadDHT } from "@libp2p/kad-dht";
|
||||||
|
import { mplex } from "@libp2p/mplex";
|
||||||
|
import { ipnsSelector } from "ipns/selector";
|
||||||
|
import { ipnsValidator } from "ipns/validator";
|
||||||
|
import { autoNATService } from "libp2p/autonat";
|
||||||
|
import { identifyService } from "libp2p/identify";
|
||||||
|
import { bootstrapConfig } from "./bootstrap.js";
|
||||||
|
import type { PubSub } from "@libp2p/interface-pubsub";
|
||||||
|
import type { Libp2pOptions } from "libp2p";
|
||||||
|
import { hypercoreTransport } from "./libp2p/transport.js";
|
||||||
|
import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
|
||||||
|
import { ipniContentRouting } from "@libp2p/ipni-content-routing";
|
||||||
|
import { reframeContentRouting } from "@libp2p/reframe-content-routing";
|
||||||
|
import { multiaddr } from "@multiformats/multiaddr";
|
||||||
|
import { create as createIpfsHttpClient } from "ipfs-http-client";
|
||||||
|
import { delegatedContentRouting } from "@libp2p/delegated-content-routing";
|
||||||
|
import { delegatedPeerRouting } from "@libp2p/delegated-peer-routing";
|
||||||
|
import { circuitRelayTransport } from "libp2p/circuit-relay";
|
||||||
|
import { DELEGATE_LIST } from "./constants.js";
|
||||||
|
import { webSockets } from "@libp2p/websockets";
|
||||||
|
import { webTransport } from "@libp2p/webtransport";
|
||||||
|
import { dcutrService } from "libp2p/dcutr";
|
||||||
|
// @ts-ignore
|
||||||
|
import type { DefaultLibp2pServices } from "helia/dist/src/utils/libp2p-defaults.browser.js";
|
||||||
|
|
||||||
|
function getDelegateConfig(): any {
|
||||||
|
const delegateString =
|
||||||
|
DELEGATE_LIST[Math.floor(Math.random() * DELEGATE_LIST.length)];
|
||||||
|
const delegateAddr = multiaddr(delegateString).toOptions();
|
||||||
|
|
||||||
|
return {
|
||||||
|
// @ts-ignore
|
||||||
|
host: delegateAddr.host,
|
||||||
|
// @ts-ignore
|
||||||
|
protocol: parseInt(delegateAddr.port) === 443 ? "https" : "http",
|
||||||
|
port: delegateAddr.port,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function libp2pConfig(
|
||||||
|
proxy: MultiSocketProxy,
|
||||||
|
): Libp2pOptions<DefaultLibp2pServices> {
|
||||||
|
const client = createIpfsHttpClient(getDelegateConfig());
|
||||||
|
|
||||||
|
return {
|
||||||
|
addresses: {
|
||||||
|
listen: [],
|
||||||
|
},
|
||||||
|
transports: [
|
||||||
|
hypercoreTransport({ proxy }),
|
||||||
|
circuitRelayTransport({
|
||||||
|
discoverRelays: 1,
|
||||||
|
}),
|
||||||
|
webTransport(),
|
||||||
|
webSockets(),
|
||||||
|
],
|
||||||
|
connectionEncryption: [noise()],
|
||||||
|
streamMuxers: [yamux(), mplex()],
|
||||||
|
peerDiscovery: [bootstrap(bootstrapConfig)],
|
||||||
|
contentRouters: [
|
||||||
|
ipniContentRouting("https://cid.contact"),
|
||||||
|
reframeContentRouting("https://cid.contact/reframe"),
|
||||||
|
],
|
||||||
|
services: {
|
||||||
|
identify: identifyService(),
|
||||||
|
autoNAT: autoNATService(),
|
||||||
|
pubsub: gossipsub(),
|
||||||
|
dcutr: dcutrService(),
|
||||||
|
dht: kadDHT({
|
||||||
|
clientMode: true,
|
||||||
|
validators: {
|
||||||
|
ipns: ipnsValidator,
|
||||||
|
},
|
||||||
|
selectors: {
|
||||||
|
ipns: ipnsSelector,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
280
src/index.ts
280
src/index.ts
|
@ -1,71 +1,64 @@
|
||||||
import { createLibp2p } from "libp2p";
|
|
||||||
import { createHelia } from "helia";
|
import { createHelia } from "helia";
|
||||||
import { yamux } from "@chainsafe/libp2p-yamux";
|
import { MultiSocketProxy } from "@lumeweb/libhyperproxy";
|
||||||
// @ts-ignore
|
|
||||||
import Hyperswarm from "hyperswarm";
|
|
||||||
import { Peer, MultiSocketProxy } from "@lumeweb/libhyperproxy";
|
|
||||||
// @ts-ignore
|
|
||||||
import sodium from "sodium-universal";
|
|
||||||
// @ts-ignore
|
|
||||||
import { CustomEvent } from "@libp2p/interfaces/events";
|
|
||||||
// @ts-ignore
|
|
||||||
import { fixed32, raw } from "compact-encoding";
|
|
||||||
import { mplex } from "@libp2p/mplex";
|
|
||||||
import { hypercoreTransport } from "./libp2p/transport.js";
|
|
||||||
import { UnixFS, unixfs } from "@helia/unixfs";
|
import { UnixFS, unixfs } from "@helia/unixfs";
|
||||||
// @ts-ignore
|
import { PROTOCOL } from "./constants.js";
|
||||||
import { delegatedPeerRouting } from "@libp2p/delegated-peer-routing";
|
import {
|
||||||
import { noise } from "@chainsafe/libp2p-noise";
|
ActiveQuery,
|
||||||
import { create as createIpfsHttpClient } from "ipfs-http-client";
|
addHandler,
|
||||||
import { delegatedContentRouting } from "@libp2p/delegated-content-routing";
|
handleMessage,
|
||||||
// @ts-ignore
|
} from "@lumeweb/libkernel/module";
|
||||||
import type { Options } from "ipfs-core";
|
|
||||||
import { multiaddr } from "@multiformats/multiaddr";
|
|
||||||
import { DELEGATE_LIST, PROTOCOL } from "./constants.js";
|
|
||||||
import { ActiveQuery, addHandler, handleMessage } from "libkmodule";
|
|
||||||
import { createClient } from "@lumeweb/kernel-swarm-client";
|
import { createClient } from "@lumeweb/kernel-swarm-client";
|
||||||
import { ipns, ipnsValidator, ipnsSelector, IPNS } from "@helia/ipns";
|
import { ipns, IPNS } from "@helia/ipns";
|
||||||
import { dht, pubsub } from "@helia/ipns/routing";
|
import { dht } from "@helia/ipns/routing";
|
||||||
import { kadDHT } from "@libp2p/kad-dht";
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { gossipsub } from "@chainsafe/libp2p-gossipsub";
|
|
||||||
import { CID } from "multiformats/cid";
|
import { CID } from "multiformats/cid";
|
||||||
import { bases } from "multiformats/basics";
|
import { bases } from "multiformats/basics";
|
||||||
import { substr } from "runes2";
|
import { substr } from "runes2";
|
||||||
import { MultibaseDecoder } from "multiformats";
|
import { MultibaseDecoder } from "multiformats";
|
||||||
import { peerIdFromCID } from "@libp2p/peer-id";
|
|
||||||
import { bootstrap } from "@libp2p/bootstrap";
|
|
||||||
import { IDBBlockstore } from "blockstore-idb";
|
import { IDBBlockstore } from "blockstore-idb";
|
||||||
import { IDBDatastore } from "datastore-idb";
|
import { IDBDatastore } from "datastore-idb";
|
||||||
import defer from "p-defer";
|
import defer from "p-defer";
|
||||||
import { Helia } from "@helia/interface";
|
import { Helia } from "@helia/interface";
|
||||||
|
import { libp2pConfig } from "./config.js";
|
||||||
|
import { createClient as createNetworkRegistryClient } from "@lumeweb/kernel-network-registry-client";
|
||||||
|
import { Libp2p } from "@libp2p/interface";
|
||||||
|
import { unmarshal as ipnsUnmarshal } from "ipns";
|
||||||
|
|
||||||
|
const IPFS_GATEWAY = "https://ipfs.lumeweb.com";
|
||||||
|
|
||||||
const basesByPrefix: { [prefix: string]: MultibaseDecoder<any> } = Object.keys(
|
const basesByPrefix: { [prefix: string]: MultibaseDecoder<any> } = Object.keys(
|
||||||
bases
|
bases,
|
||||||
).reduce((acc, curr) => {
|
).reduce((acc, curr) => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
acc[bases[curr].prefix] = bases[curr];
|
acc[bases[curr].prefix] = bases[curr];
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
|
const TYPES = ["content"];
|
||||||
|
|
||||||
onmessage = handleMessage;
|
onmessage = handleMessage;
|
||||||
|
|
||||||
const moduleDefer = defer();
|
const moduleDefer = defer();
|
||||||
let activeIpfsPeersDefer = defer();
|
let activeIpfsPeersDefer = defer();
|
||||||
let networkPeersAvailable = defer();
|
let networkPeersAvailable = defer();
|
||||||
|
let networkReady = false;
|
||||||
|
const networkRegistry = createNetworkRegistryClient();
|
||||||
|
|
||||||
let swarm;
|
let swarm;
|
||||||
let proxy: MultiSocketProxy;
|
let proxy: MultiSocketProxy;
|
||||||
let fs: UnixFS;
|
let fs: UnixFS;
|
||||||
let IPNS: IPNS;
|
let IPNS: IPNS;
|
||||||
let ipfs: Helia;
|
let ipfs: Helia<Libp2p<any>>;
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
BigInt.prototype.toJSON = function () {
|
BigInt.prototype.toJSON = function () {
|
||||||
return this.toString();
|
return this.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
addHandler("presentSeed", handlePresentSeed);
|
addHandler("presentKey", handlePresentKey);
|
||||||
|
addHandler("register", handleRegister);
|
||||||
|
addHandler("status", handleStatus, { receiveUpdates: true });
|
||||||
|
addHandler("name", handleName);
|
||||||
addHandler("ready", handleReady);
|
addHandler("ready", handleReady);
|
||||||
addHandler("stat", handleStat);
|
addHandler("stat", handleStat);
|
||||||
addHandler("ls", handleLs, { receiveUpdates: true });
|
addHandler("ls", handleLs, { receiveUpdates: true });
|
||||||
|
@ -73,11 +66,9 @@ addHandler("cat", handleCat, { receiveUpdates: true });
|
||||||
addHandler("ipnsResolve", handleIpnsResolve);
|
addHandler("ipnsResolve", handleIpnsResolve);
|
||||||
addHandler("getActivePeers", handleGetActivePeers);
|
addHandler("getActivePeers", handleGetActivePeers);
|
||||||
|
|
||||||
async function handlePresentSeed() {
|
async function handlePresentKey() {
|
||||||
swarm = createClient();
|
swarm = createClient();
|
||||||
|
|
||||||
const client = createIpfsHttpClient(getDelegateConfig());
|
|
||||||
|
|
||||||
proxy = new MultiSocketProxy({
|
proxy = new MultiSocketProxy({
|
||||||
swarm,
|
swarm,
|
||||||
listen: true,
|
listen: true,
|
||||||
|
@ -87,113 +78,25 @@ async function handlePresentSeed() {
|
||||||
server: false,
|
server: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const libp2p = await createLibp2p({
|
|
||||||
peerDiscovery: [
|
|
||||||
bootstrap({
|
|
||||||
list: [
|
|
||||||
// Default Bootstrap
|
|
||||||
"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN",
|
|
||||||
"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
|
|
||||||
"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
|
|
||||||
"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
|
|
||||||
"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
|
|
||||||
// Cloudflare
|
|
||||||
"/dnsaddr/node-1.ingress.cloudflare-ipfs.com/p2p/QmcFf2FH3CEgTNHeMRGhN7HNHU1EXAxoEk6EFuSyXCsvRE",
|
|
||||||
"/dnsaddr/node-2.ingress.cloudflare-ipfs.com/p2p/QmcFmLd5ySfk2WZuJ1mfSWLDjdmHZq7rSAua4GoeSQfs1z",
|
|
||||||
"/dnsaddr/node-3.ingress.cloudflare-ipfs.com/p2p/QmcfFmzSDVbwexQ9Au2pt5YEXHK5xajwgaU6PpkbLWerMa",
|
|
||||||
"/dnsaddr/node-4.ingress.cloudflare-ipfs.com/p2p/QmcfJeB3Js1FG7T8YaZATEiaHqNKVdQfybYYkbT1knUswx",
|
|
||||||
"/dnsaddr/node-5.ingress.cloudflare-ipfs.com/p2p/QmcfVvzK4tMdFmpJjEKDUoqRgP4W9FnmJoziYX5GXJJ8eZ",
|
|
||||||
"/dnsaddr/node-6.ingress.cloudflare-ipfs.com/p2p/QmcfZD3VKrUxyP9BbyUnZDpbqDnT7cQ4WjPP8TRLXaoE7G",
|
|
||||||
"/dnsaddr/node-7.ingress.cloudflare-ipfs.com/p2p/QmcfZP2LuW4jxviTeG8fi28qjnZScACb8PEgHAc17ZEri3",
|
|
||||||
"/dnsaddr/node-8.ingress.cloudflare-ipfs.com/p2p/QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP",
|
|
||||||
"/dnsaddr/node-9.ingress.cloudflare-ipfs.com/p2p/Qmcfr2FC7pFzJbTSDfYaSy1J8Uuy8ccGLeLyqJCKJvTHMi",
|
|
||||||
"/dnsaddr/node-10.ingress.cloudflare-ipfs.com/p2p/QmcfR3V5YAtHBzxVACWCzXTt26SyEkxdwhGJ6875A8BuWx",
|
|
||||||
"/dnsaddr/node-11.ingress.cloudflare-ipfs.com/p2p/Qmcfuo1TM9uUiJp6dTbm915Rf1aTqm3a3dnmCdDQLHgvL5",
|
|
||||||
"/dnsaddr/node-12.ingress.cloudflare-ipfs.com/p2p/QmcfV2sg9zaq7UUHVCGuSvT2M2rnLBAPsiE79vVyK3Cuev",
|
|
||||||
// Estuary
|
|
||||||
"/ip4/139.178.68.217/tcp/6744/p2p/12D3KooWCVXs8P7iq6ao4XhfAmKWrEeuKFWCJgqe9jGDMTqHYBjw",
|
|
||||||
"/ip4/147.75.49.71/tcp/6745/p2p/12D3KooWGBWx9gyUFTVQcKMTenQMSyE2ad9m7c9fpjS4NMjoDien",
|
|
||||||
"/ip4/147.75.86.255/tcp/6745/p2p/12D3KooWFrnuj5o3tx4fGD2ZVJRyDqTdzGnU3XYXmBbWbc8Hs8Nd",
|
|
||||||
"/ip4/3.134.223.177/tcp/6745/p2p/12D3KooWN8vAoGd6eurUSidcpLYguQiGZwt4eVgDvbgaS7kiGTup",
|
|
||||||
"/ip4/35.74.45.12/udp/6746/quic/p2p/12D3KooWLV128pddyvoG6NBvoZw7sSrgpMTPtjnpu3mSmENqhtL7",
|
|
||||||
|
|
||||||
// Pinata
|
|
||||||
"/dnsaddr/fra1-1.hostnodes.pinata.cloud/p2p/QmWaik1eJcGHq1ybTWe7sezRfqKNcDRNkeBaLnGwQJz1Cj",
|
|
||||||
"/dnsaddr/fra1-2.hostnodes.pinata.cloud/p2p/QmNfpLrQQZr5Ns9FAJKpyzgnDL2GgC6xBug1yUZozKFgu4",
|
|
||||||
"/dnsaddr/fra1-3.hostnodes.pinata.cloud/p2p/QmPo1ygpngghu5it8u4Mr3ym6SEU2Wp2wA66Z91Y1S1g29",
|
|
||||||
"/dnsaddr/nyc1-1.hostnodes.pinata.cloud/p2p/QmRjLSisUCHVpFa5ELVvX3qVPfdxajxWJEHs9kN3EcxAW6",
|
|
||||||
"/dnsaddr/nyc1-2.hostnodes.pinata.cloud/p2p/QmPySsdmbczdZYBpbi2oq2WMJ8ErbfxtkG8Mo192UHkfGP",
|
|
||||||
"/dnsaddr/nyc1-3.hostnodes.pinata.cloud/p2p/QmSarArpxemsPESa6FNkmuu9iSE1QWqPX2R3Aw6f5jq4D5",
|
|
||||||
// Eternum
|
|
||||||
"/dns4/door.eternum.io/tcp/4001/ipfs/QmVBxJ5GekATHi89H8jbXjaU6CosCnteomjNR5xar2aH3q",
|
|
||||||
// Textile
|
|
||||||
"/ip4/104.210.43.77/p2p/QmR69wtWUMm1TWnmuD4JqC1TWLZcc8iR2KrTenfZZbiztd",
|
|
||||||
// 8api.sh
|
|
||||||
"/ip4/78.46.108.24/p2p/12D3KooWGASC2jm3pmohEJXUhuStkxDitPgzvs4qMuFPaiD9x1BA",
|
|
||||||
"/ip4/65.109.19.136/p2p/12D3KooWRbWZN3GvLf9CHmozq4vnTzDD4EEoiqtRJxg5FV6Gfjmm",
|
|
||||||
|
|
||||||
// Storj
|
|
||||||
"/ip4/5.161.92.43/tcp/4001/p2p/12D3KooWFFhc8fPYnQXdWBCowxSV21EFYin3rU27p3NVgSMjN41k",
|
|
||||||
"/ip4/5.161.92.43/udp/4001/quic/p2p/12D3KooWFFhc8fPYnQXdWBCowxSV21EFYin3rU27p3NVgSMjN41k",
|
|
||||||
"/ip6/2a01:4ff:f0:3b1e::1/tcp/4001/p2p/12D3KooWFFhc8fPYnQXdWBCowxSV21EFYin3rU27p3NVgSMjN41k",
|
|
||||||
"/ip6/2a01:4ff:f0:3b1e::1/udp/4001/quic/p2p/12D3KooWFFhc8fPYnQXdWBCowxSV21EFYin3rU27p3NVgSMjN41k",
|
|
||||||
"/ip4/5.161.55.227/tcp/4001/p2p/12D3KooWSW4hoHmDXmY5rW7nCi9XmGTy3foFt72u86jNP53LTNBJ",
|
|
||||||
"/ip4/5.161.55.227/udp/4001/quic/p2p/12D3KooWSW4hoHmDXmY5rW7nCi9XmGTy3foFt72u86jNP53LTNBJ",
|
|
||||||
"/ip6/2a01:4ff:f0:1e5a::1/tcp/4001/p2p/12D3KooWSW4hoHmDXmY5rW7nCi9XmGTy3foFt72u86jNP53LTNBJ",
|
|
||||||
"/ip6/2a01:4ff:f0:1e5a::1/udp/4001/quic/p2p/12D3KooWSW4hoHmDXmY5rW7nCi9XmGTy3foFt72u86jNP53LTNBJ",
|
|
||||||
"/ip4/5.161.92.36/tcp/4001/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
|
||||||
"/ip4/5.161.92.36/udp/4001/quic/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
|
||||||
"/ip6/2a01:4ff:f0:3764::1/tcp/4001/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
|
||||||
"/ip6/2a01:4ff:f0:3764::1/udp/4001/quic/p2p/12D3KooWSDj6JM2JmoHwE9AUUwqAFUEg9ndd3pMA8aF2bkYckZfo",
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
transports: [hypercoreTransport({ proxy })],
|
|
||||||
connectionEncryption: [noise()],
|
|
||||||
connectionManager: {
|
|
||||||
autoDial: true,
|
|
||||||
minConnections: 5,
|
|
||||||
maxConnections: 20,
|
|
||||||
},
|
|
||||||
streamMuxers: [yamux(), mplex()],
|
|
||||||
start: false,
|
|
||||||
contentRouters: [delegatedContentRouting(client)],
|
|
||||||
peerRouters: [delegatedPeerRouting(client)],
|
|
||||||
relay: {
|
|
||||||
enabled: true,
|
|
||||||
advertise: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
dht: kadDHT({
|
|
||||||
validators: {
|
|
||||||
ipns: ipnsValidator,
|
|
||||||
},
|
|
||||||
selectors: {
|
|
||||||
ipns: ipnsSelector,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
pubsub: gossipsub(),
|
|
||||||
});
|
|
||||||
|
|
||||||
const blockstore = new IDBBlockstore("ipfs_blocks");
|
const blockstore = new IDBBlockstore("ipfs_blocks");
|
||||||
const datastore = new IDBDatastore("ipfs_data");
|
const datastore = new IDBDatastore("ipfs_data");
|
||||||
|
|
||||||
await blockstore.open();
|
await blockstore.open();
|
||||||
await datastore.open();
|
await datastore.open();
|
||||||
|
// @ts-ignore
|
||||||
ipfs = await createHelia({
|
ipfs = await createHelia({
|
||||||
// @ts-ignore
|
|
||||||
blockstore,
|
blockstore,
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
datastore,
|
datastore,
|
||||||
libp2p,
|
libp2p: libp2pConfig(proxy),
|
||||||
|
start: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
proxy.on("peerChannelOpen", async () => {
|
proxy.on("peerChannelOpen", async () => {
|
||||||
if (!ipfs.libp2p.isStarted()) {
|
if (!ipfs.libp2p.isStarted()) {
|
||||||
await ipfs.libp2p.start();
|
await ipfs.start();
|
||||||
networkPeersAvailable.resolve();
|
networkPeersAvailable.resolve();
|
||||||
|
networkReady = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -202,7 +105,7 @@ async function handlePresentSeed() {
|
||||||
await swarm.ready();
|
await swarm.ready();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
fs = unixfs(ipfs);
|
fs = unixfs(ipfs);
|
||||||
IPNS = ipns(ipfs as any, [dht(ipfs), pubsub(ipfs as any)]);
|
IPNS = ipns(ipfs as any, [dht(ipfs)]);
|
||||||
|
|
||||||
ipfs.libp2p.addEventListener("peer:connect", () => {
|
ipfs.libp2p.addEventListener("peer:connect", () => {
|
||||||
if (ipfs.libp2p.getPeers().length > 0) {
|
if (ipfs.libp2p.getPeers().length > 0) {
|
||||||
|
@ -245,10 +148,10 @@ async function handleStat(aq: ActiveQuery) {
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
await fs.stat(
|
await fs.stat(
|
||||||
getCID(aq.callerInput.cid),
|
getCID(aq.callerInput.cid),
|
||||||
aq.callerInput.options ?? {}
|
aq.callerInput.options ?? {},
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
aq.reject((e as Error).message);
|
aq.reject((e as Error).message);
|
||||||
|
@ -278,7 +181,7 @@ async function handleLs(aq: ActiveQuery) {
|
||||||
});
|
});
|
||||||
const iterable = fs.ls(
|
const iterable = fs.ls(
|
||||||
getCID(aq.callerInput.cid),
|
getCID(aq.callerInput.cid),
|
||||||
aq.callerInput.options ?? {}
|
aq.callerInput.options ?? {},
|
||||||
);
|
);
|
||||||
|
|
||||||
for await (const item of iterable) {
|
for await (const item of iterable) {
|
||||||
|
@ -318,7 +221,7 @@ async function handleCat(aq: ActiveQuery) {
|
||||||
|
|
||||||
const iterable = fs.cat(
|
const iterable = fs.cat(
|
||||||
getCID(aq.callerInput.cid),
|
getCID(aq.callerInput.cid),
|
||||||
aq.callerInput.options ?? {}
|
aq.callerInput.options ?? {},
|
||||||
);
|
);
|
||||||
|
|
||||||
for await (const chunk of iterable) {
|
for await (const chunk of iterable) {
|
||||||
|
@ -334,9 +237,22 @@ async function handleCat(aq: ActiveQuery) {
|
||||||
aq.respond();
|
aq.respond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toDNSPrefix(cid: CID) {
|
||||||
|
const cidb32 = cid.toV1().toString(bases.base32);
|
||||||
|
if (cidb32.length <= 63) {
|
||||||
|
return cidb32;
|
||||||
|
}
|
||||||
|
const cidb36 = cid.toV1().toString(bases.base36);
|
||||||
|
if (cidb36.length <= 63) {
|
||||||
|
return cidb36;
|
||||||
|
}
|
||||||
|
throw new Error("CID incompatible with DNS label length limit of 63");
|
||||||
|
}
|
||||||
|
|
||||||
async function handleIpnsResolve(aq: ActiveQuery) {
|
async function handleIpnsResolve(aq: ActiveQuery) {
|
||||||
await ready();
|
await ready();
|
||||||
|
|
||||||
|
/*
|
||||||
await activeIpfsPeersDefer.promise;
|
await activeIpfsPeersDefer.promise;
|
||||||
|
|
||||||
if (ipfs.libp2p.getPeers().length === 0) {
|
if (ipfs.libp2p.getPeers().length === 0) {
|
||||||
|
@ -344,6 +260,7 @@ async function handleIpnsResolve(aq: ActiveQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
await activeIpfsPeersDefer.promise;
|
await activeIpfsPeersDefer.promise;
|
||||||
|
*/
|
||||||
|
|
||||||
if (!aq.callerInput || !("cid" in aq.callerInput)) {
|
if (!aq.callerInput || !("cid" in aq.callerInput)) {
|
||||||
aq.reject("cid required");
|
aq.reject("cid required");
|
||||||
|
@ -351,14 +268,17 @@ async function handleIpnsResolve(aq: ActiveQuery) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return aq.respond(
|
const cid = getCID(aq.callerInput.cid);
|
||||||
(
|
|
||||||
await IPNS.resolve(
|
const ret = await fetch(
|
||||||
peerIdFromCID(getCID(aq.callerInput.cid)),
|
`${IPFS_GATEWAY}/ipns/${toDNSPrefix(cid)}?format=ipns-record`,
|
||||||
aq.callerInput?.options
|
|
||||||
)
|
|
||||||
).asCID.toString()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const buf = await ret.arrayBuffer();
|
||||||
|
|
||||||
|
const record = ipnsUnmarshal(new Uint8Array(buf));
|
||||||
|
|
||||||
|
return aq.respond(record.value);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
aq.reject((e as Error).message);
|
aq.reject((e as Error).message);
|
||||||
}
|
}
|
||||||
|
@ -390,16 +310,70 @@ async function ready() {
|
||||||
await networkPeersAvailable.promise;
|
await networkPeersAvailable.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDelegateConfig(): Options {
|
async function handleRegister(aq: ActiveQuery) {
|
||||||
const delegateString =
|
await networkRegistry.registerNetwork(TYPES);
|
||||||
DELEGATE_LIST[Math.floor(Math.random() * DELEGATE_LIST.length)];
|
|
||||||
const delegateAddr = multiaddr(delegateString).toOptions();
|
|
||||||
|
|
||||||
return {
|
aq.respond();
|
||||||
// @ts-ignore
|
}
|
||||||
host: delegateAddr.host,
|
|
||||||
// @ts-ignore
|
async function handleStatus(aq: ActiveQuery) {
|
||||||
protocol: parseInt(delegateAddr.port) === 443 ? "https" : "http",
|
function sendUpdate() {
|
||||||
port: delegateAddr.port,
|
aq.sendUpdate({
|
||||||
};
|
peers: netPeers,
|
||||||
|
ready: netPeers > 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let netPeers = 0;
|
||||||
|
if (!networkReady) {
|
||||||
|
sendUpdate();
|
||||||
|
await ready();
|
||||||
|
getPeers();
|
||||||
|
} else {
|
||||||
|
getPeers();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPeers() {
|
||||||
|
netPeers = ipfs.libp2p.getPeers().length;
|
||||||
|
}
|
||||||
|
|
||||||
|
function peersListener() {
|
||||||
|
getPeers();
|
||||||
|
sendUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
const peerEvents = ["connection:prune", "peer:connect", "peer:disconnect"];
|
||||||
|
peerEvents.forEach((ev) => {
|
||||||
|
// @ts-ignore
|
||||||
|
ipfs.libp2p.components.connectionManager.events.addEventListener(
|
||||||
|
ev,
|
||||||
|
peersListener,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
|
ipfs.libp2p.components.connectionManager.events.addEventListener(
|
||||||
|
"peer:disconnect",
|
||||||
|
peersListener,
|
||||||
|
);
|
||||||
|
|
||||||
|
ipfs.libp2p.addEventListener("start", peersListener);
|
||||||
|
|
||||||
|
aq.setReceiveUpdate?.(() => {
|
||||||
|
peerEvents.forEach((ev) => {
|
||||||
|
// @ts-ignore
|
||||||
|
ipfs.libp2p.components.connectionManager.events.removeEventListener(
|
||||||
|
ev,
|
||||||
|
peersListener,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
ipfs.libp2p.removeEventListener("start", peersListener);
|
||||||
|
aq.respond();
|
||||||
|
});
|
||||||
|
|
||||||
|
sendUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleName(aq: ActiveQuery) {
|
||||||
|
aq.respond("IPFS");
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ class HypercoreTransport extends TCP {
|
||||||
const socket = await this._connect(ma, options);
|
const socket = await this._connect(ma, options);
|
||||||
|
|
||||||
// Avoid uncaught errors caused by unstable connections
|
// Avoid uncaught errors caused by unstable connections
|
||||||
|
// @ts-ignore
|
||||||
socket.on("error", (err: any) => {
|
socket.on("error", (err: any) => {
|
||||||
log("socket error", err);
|
log("socket error", err);
|
||||||
});
|
});
|
||||||
|
@ -82,6 +83,7 @@ class HypercoreTransport extends TCP {
|
||||||
throw new AbortError();
|
throw new AbortError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,9 +115,10 @@ class HypercoreTransport extends TCP {
|
||||||
|
|
||||||
const err = new CodeError(
|
const err = new CodeError(
|
||||||
`connection timeout after ${Date.now() - start}ms`,
|
`connection timeout after ${Date.now() - start}ms`,
|
||||||
"ERR_CONNECT_TIMEOUT"
|
"ERR_CONNECT_TIMEOUT",
|
||||||
);
|
);
|
||||||
// Note: this will result in onError() being called
|
// Note: this will result in onError() being called
|
||||||
|
// @ts-ignore
|
||||||
rawSocket?.emit("error", err);
|
rawSocket?.emit("error", err);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,11 +131,13 @@ class HypercoreTransport extends TCP {
|
||||||
const onAbort = (): void => {
|
const onAbort = (): void => {
|
||||||
log("connection aborted %j", cOpts);
|
log("connection aborted %j", cOpts);
|
||||||
this.metrics?.dialerEvents.increment({ abort: true });
|
this.metrics?.dialerEvents.increment({ abort: true });
|
||||||
|
// @ts-ignore
|
||||||
rawSocket?.destroy();
|
rawSocket?.destroy();
|
||||||
done(new AbortError());
|
done(new AbortError());
|
||||||
};
|
};
|
||||||
|
|
||||||
const done = (err?: any): void => {
|
const done = (err?: any): void => {
|
||||||
|
// @ts-ignore
|
||||||
rawSocket?.removeListener("error", onError);
|
rawSocket?.removeListener("error", onError);
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
rawSocket?.removeListener("timeout", onTimeout);
|
rawSocket?.removeListener("timeout", onTimeout);
|
||||||
|
@ -199,7 +204,7 @@ class HypercoreTransport extends TCP {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hypercoreTransport(
|
export function hypercoreTransport(
|
||||||
init: HypercoreOptions = {}
|
init: HypercoreOptions = {},
|
||||||
): (components?: TCPComponents) => HypercoreTransport {
|
): (components?: TCPComponents) => HypercoreTransport {
|
||||||
return (components: TCPComponents = {}) => {
|
return (components: TCPComponents = {}) => {
|
||||||
return new HypercoreTransport(components, init);
|
return new HypercoreTransport(components, init);
|
||||||
|
|
|
@ -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__/*"]
|
|
||||||
}
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "esnext",
|
|
||||||
"declaration": true,
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"outDir": "./build",
|
|
||||||
"strict": true,
|
|
||||||
"allowSyntheticDefaultImports": true,
|
|
||||||
"esModuleInterop": true
|
|
||||||
},
|
|
||||||
"include": ["src"],
|
|
||||||
"exclude": ["node_modules", "**/__tests__/*"]
|
|
||||||
}
|
|
Loading…
Reference in New Issue