Compare commits

..

93 Commits

Author SHA1 Message Date
semantic-release-bot 98c451cf36 chore(release): 0.1.0-develop.23 [skip ci]
# [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](483ac62f96))
* need to use dns friendly cids for IPNS ([861a822](861a8229d4))
* remove delegated routing again ([2b3b6dd](2b3b6dd0f3))
2023-10-18 19:23:37 +00:00
Derrick Hammer ff754773e6
Merge remote-tracking branch 'origin/develop' into develop 2023-10-18 15:22:11 -04:00
Derrick Hammer 3f3e581ce2
dep: update helia 2023-10-18 15:16:55 -04:00
Derrick Hammer 861a8229d4
fix: need to use dns friendly cids for IPNS 2023-10-18 15:08:34 -04:00
Derrick Hammer c29f2422a2
refactor: use our own temp ipfs gateway and use the trustless api 2023-10-18 13:49:02 -04:00
Derrick Hammer 2b3b6dd0f3
fix: remove delegated routing again 2023-10-18 13:48:13 -04:00
Derrick Hammer 483ac62f96
fix: add hypercoreTransport back 2023-10-15 16:20:13 -04:00
Derrick Hammer 1a544d7c2d
dep: update helia and add delegatedPeerRouting back 2023-10-15 15:56:43 -04:00
semantic-release-bot f0c19a7bb4 chore(release): 0.1.0-develop.22 [skip ci]
# [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](a07dc0d613))
2023-10-15 04:14:33 +00:00
Derrick Hammer d8899221d2
Merge remote-tracking branch 'origin/develop' into develop 2023-10-15 00:12:50 -04:00
Derrick Hammer a07dc0d613
fix: networkReady should start as false 2023-10-15 00:12:41 -04:00
semantic-release-bot 00fb3f5908 chore(release): 0.1.0-develop.21 [skip ci]
# [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)
2023-10-13 11:00:23 +00:00
Derrick Hammer 433a8f194b
Merge remote-tracking branch 'origin/develop' into develop 2023-10-13 06:58:40 -04:00
Derrick Hammer 4843067541
dep: update deps 2023-10-13 06:58:35 -04:00
semantic-release-bot 8f3e24be5c chore(release): 0.1.0-develop.20 [skip ci]
# [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)
2023-10-12 13:37:11 +00:00
Derrick Hammer bfe66cd3af
dep: update deps 2023-10-12 09:34:55 -04:00
semantic-release-bot ac7941af0a chore(release): 0.1.0-develop.19 [skip ci]
# [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)
2023-09-09 22:15:42 +00:00
Derrick Hammer 82e3500443
Merge remote-tracking branch 'origin/develop' into develop 2023-09-09 18:14:27 -04:00
Derrick Hammer 64df3c561e
dep: update deps 2023-09-09 18:14:22 -04:00
semantic-release-bot bbb3b3cb4c chore(release): 0.1.0-develop.18 [skip ci]
# [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)
2023-09-09 21:41:31 +00:00
Derrick Hammer baae8f7c00
Merge remote-tracking branch 'origin/develop' into develop 2023-09-09 17:40:16 -04:00
Derrick Hammer 8ee63d87b0
dep: update kernel-network-registry-client 2023-09-09 17:40:07 -04:00
Derrick Hammer 9d2d0b35cd
dep: update libkernel 2023-09-04 06:17:09 -04:00
semantic-release-bot 9be1126acd chore(release): 0.1.0-develop.17 [skip ci]
# [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)
2023-09-03 04:49:07 +00:00
Derrick Hammer 15915d9715
Merge remote-tracking branch 'origin/develop' into develop 2023-09-03 00:47:28 -04:00
Derrick Hammer 95f40957df
dep: update libkernel 2023-09-03 00:47:20 -04:00
semantic-release-bot e4c08af4af chore(release): 0.1.0-develop.16 [skip ci]
# [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)
2023-09-02 17:14:08 +00:00
Derrick Hammer 6bd3167f43
Merge remote-tracking branch 'origin/develop' into develop 2023-09-02 13:12:45 -04:00
Derrick Hammer 277ed207b9
dep: update deps 2023-09-02 13:12:41 -04:00
semantic-release-bot 998dfc0e75 chore(release): 0.1.0-develop.15 [skip ci]
# [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](6298d8e914))
2023-07-31 16:04:37 +00:00
Derrick Hammer a6187d2c0f
Merge remote-tracking branch 'origin/develop' into develop 2023-07-31 12:03:18 -04:00
Derrick Hammer 6298d8e914
fix: add delegatedContentRouting back for now 2023-07-31 12:03:06 -04:00
semantic-release-bot ba094e3ae8 chore(release): 0.1.0-develop.14 [skip ci]
# [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](a27aeb2ec8))
2023-07-31 01:38:21 +00:00
Derrick Hammer cb162f5135
Merge remote-tracking branch 'origin/develop' into develop 2023-07-30 21:36:46 -04:00
Derrick Hammer a27aeb2ec8
fix: if the network is ready then fetch the peer count 2023-07-30 21:36:39 -04:00
semantic-release-bot c8f3cc70da chore(release): 0.1.0-develop.13 [skip ci]
# [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](f1b8a603df))
2023-07-31 01:34:41 +00:00
Derrick Hammer d23c583cf5
Merge remote-tracking branch 'origin/develop' into develop 2023-07-30 21:33:03 -04:00
Derrick Hammer f1b8a603df
fix: add event listener on libp2p start for redundancy to ensure we max the events to read the peer count 2023-07-30 21:32:53 -04:00
Derrick Hammer 2b04fecc7c
refactor: switch to ipni/reframe content routing and deprecate delegated routing 2023-07-30 21:32:04 -04:00
semantic-release-bot e6555412b9 chore(release): 0.1.0-develop.12 [skip ci]
# [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)
2023-07-30 00:33:14 +00:00
Derrick Hammer dcc0499157
Merge remote-tracking branch 'origin/develop' into develop 2023-07-29 20:31:56 -04:00
Derrick Hammer 958699038f
dep: update kernel-network-registry-client 2023-07-29 20:31:46 -04:00
semantic-release-bot 3ba37bcf15 chore(release): 0.1.0-develop.11 [skip ci]
# [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](a61b0d4771))
2023-07-29 22:36:40 +00:00
Derrick Hammer 7e023efa87
Merge remote-tracking branch 'origin/develop' into develop 2023-07-29 18:35:25 -04:00
Derrick Hammer a61b0d4771
feat: add ipni fallback 2023-07-29 18:35:17 -04:00
Derrick Hammer 3befddd410
dep: update presetter-kernel-module-preset 2023-07-29 13:58:00 -04:00
semantic-release-bot a787f19b9d chore(release): 0.1.0-develop.10 [skip ci]
# [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)
2023-07-29 16:45:42 +00:00
Derrick Hammer 0b14f84954
Merge remote-tracking branch 'origin/develop' into develop 2023-07-29 12:44:04 -04:00
Derrick Hammer 26bbe2900c
dep: update libkernel and kernel-swarm-client 2023-07-29 12:44:01 -04:00
semantic-release-bot c3421ad6d6 chore(release): 0.1.0-develop.9 [skip ci]
# [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](005a128a2c))
2023-07-29 03:21:35 +00:00
Derrick Hammer 01e5afb7b2
Merge remote-tracking branch 'origin/develop' into develop 2023-07-28 23:19:51 -04:00
Derrick Hammer 005a128a2c
feat: add name api call 2023-07-28 23:19:43 -04:00
semantic-release-bot 62bb02a3d8 chore(release): 0.1.0-develop.8 [skip ci]
# [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](d739b0a286))
2023-07-24 22:52:30 +00:00
Derrick Hammer d739b0a286
fix: patch noble ed25519 to inject @peculiar/webcrypto 2023-07-24 18:50:46 -04:00
Derrick Hammer 9f8679773d
dep: update kernel-protomux-client, libkernel 2023-07-24 18:49:12 -04:00
Derrick Hammer ce237fc1a3
Merge remote-tracking branch 'origin/develop' into develop 2023-07-24 18:07:55 -04:00
Derrick Hammer fc823b0b60
dep: update kernel-protomux-client, libkernel, kernel-swarm-client 2023-07-24 18:07:46 -04:00
semantic-release-bot af1dce26e9 chore(release): 0.1.0-develop.7 [skip ci]
# [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)
2023-07-23 18:55:39 +00:00
Derrick Hammer cff181d2c7
Merge remote-tracking branch 'origin/develop' into develop 2023-07-23 14:53:55 -04:00
Derrick Hammer 2920d3b3ad
dep: update kernel-protomux-client and kernel-swarm-client 2023-07-23 14:53:51 -04:00
semantic-release-bot d87c589c3d chore(release): 0.1.0-develop.6 [skip ci]
# [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](16dcaafd78))
2023-07-23 13:55:22 +00:00
Derrick Hammer 653833d552
Merge remote-tracking branch 'origin/develop' into develop 2023-07-23 09:53:28 -04:00
Derrick Hammer 16dcaafd78
feat: add status api 2023-07-23 09:53:21 -04:00
semantic-release-bot 7147b9f8ba chore(release): 0.1.0-develop.5 [skip ci]
# [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)
2023-07-23 00:35:05 +00:00
Derrick Hammer 9683960782
Merge remote-tracking branch 'origin/develop' into develop 2023-07-22 20:33:23 -04:00
Derrick Hammer 49a599a782
dep: update kernel-swarm-client 2023-07-22 20:33:20 -04:00
semantic-release-bot 9000d05bc8 chore(release): 0.1.0-develop.4 [skip ci]
# [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](7c8490c6f5))
2023-07-23 00:25:44 +00:00
Derrick Hammer d0a808f74a
Merge remote-tracking branch 'origin/develop' into develop 2023-07-22 20:24:28 -04:00
Derrick Hammer 7c8490c6f5
fix: need to override protomux with our kernel-protomux-client 2023-07-22 20:24:21 -04:00
semantic-release-bot 48d48f21ea chore(release): 0.1.0-develop.3 [skip ci]
# [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)
2023-07-21 17:35:01 +00:00
Derrick Hammer a87adf0d75
Merge remote-tracking branch 'origin/develop' into develop 2023-07-21 13:33:21 -04:00
Derrick Hammer 8a11e4be21
dep: update kernel-network-registry-client 2023-07-21 13:33:18 -04:00
semantic-release-bot 4f3593a4f9 chore(release): 0.1.0-develop.2 [skip ci]
# [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)
2023-07-19 17:29:20 +00:00
Derrick Hammer f248df89b9
Merge remote-tracking branch 'origin/develop' into develop 2023-07-19 13:28:00 -04:00
Derrick Hammer 9475e18eaa
dep: update kernel-network-registry-client 2023-07-19 13:27:54 -04:00
semantic-release-bot 40e7eb7b6f chore(release): 0.1.0-develop.1 [skip ci]
# [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](663a67c7ba))
2023-07-19 17:00:27 +00:00
Derrick Hammer cb1608a4df
Merge remote-tracking branch 'origin/develop' into develop 2023-07-19 12:58:35 -04:00
Derrick Hammer 663a67c7ba
feat: add register method for network registry 2023-07-19 12:58:08 -04:00
Derrick Hammer 81f4fc2a0f
dep: update deps 2023-07-19 12:57:46 -04:00
semantic-release-bot 7486cf2034 chore(release): 0.0.2-develop.4 [skip ci]
## [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)
2023-07-12 10:44:49 +00:00
Derrick Hammer 8668a9b734
Merge remote-tracking branch 'origin/develop' into develop 2023-07-12 06:43:19 -04:00
Derrick Hammer 35c14bd3a6
dep: update deps 2023-07-12 06:43:15 -04:00
semantic-release-bot d8c2e12959 chore(release): 0.0.2-develop.3 [skip ci]
## [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)
2023-07-09 15:30:49 +00:00
Derrick Hammer b2dd0069f1
Merge remote-tracking branch 'origin/develop' into develop 2023-07-09 11:29:26 -04:00
Derrick Hammer 391ad98113
refactor: upgrade to latest version of helia and libp2p, and restructure libp2p config 2023-07-09 11:29:05 -04:00
semantic-release-bot b370e45b5b chore(release): 0.0.2-develop.2 [skip ci]
## [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)
2023-07-08 12:16:46 +00:00
Derrick Hammer 1ced0560ec
Merge remote-tracking branch 'origin/develop' into develop 2023-07-08 08:15:10 -04:00
Derrick Hammer f8a0c55340
refactor: move to vite build system and update deps 2023-07-08 08:14:37 -04:00
semantic-release-bot c2674c9df2 chore(release): 0.0.2-develop.1 [skip ci]
## [0.0.2-develop.1](https://git.lumeweb.com/LumeWeb/kernel-ipfs/compare/v0.0.1...v0.0.2-develop.1) (2023-07-06)
2023-07-06 08:07:09 +00:00
Derrick Hammer 04438ee02c
ci: add repository to package.json 2023-07-06 01:20:14 -04:00
Derrick Hammer 15df3a86d3
ci: setup 2023-07-06 01:15:26 -04:00
Derrick Hammer 659428c812
ci: add npm-shrinkwrap.json 2023-07-06 01:14:56 -04:00
Derrick Hammer 774aab1a21
refactor: move to new sdks and build system 2023-07-06 01:14:10 -04:00
18 changed files with 27144 additions and 596 deletions

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

@ -0,0 +1,13 @@
name: Build/Publish
on:
push:
branches:
- master
- develop
- develop-*
jobs:
main:
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
secrets: inherit

17
.presetterrc.json Normal file
View File

@ -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 = {};"
}
}
}
}

110
CHANGELOG.md Normal file
View File

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

View File

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

24969
npm-shrinkwrap.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,116 +1,59 @@
{
"name": "@lumeweb/kernel-ipfs",
"version": "0.1.0",
"version": "0.1.0-develop.23",
"type": "module",
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-ipfs.git"
},
"scripts": {
"test": "jest",
"build-script": "tsc --project tsconfig.build.json && mv dist-build/build.js dist-build/build.mjs",
"compile": "npm run build-script && node build.js",
"build": "npm run compile && node ./dist-build/build.mjs dev"
"prepare": "presetter bootstrap",
"build": "run build",
"semantic-release": "semantic-release",
"postinstall": "patch-package"
},
"dependencies": {
"@chainsafe/libp2p-gossipsub": "^6.3.0",
"@chainsafe/libp2p-noise": "^11.0.4",
"@chainsafe/libp2p-yamux": "^3.0.10",
"@dao-xyz/libp2p-noise": "^11.1.3",
"@helia/ipns": "^1.1.0",
"@helia/unixfs": "^1.2.2",
"@libp2p/bootstrap": "^6.0.3",
"@libp2p/crypto": "^1.0.15",
"@libp2p/delegated-content-routing": "^4.0.3",
"@libp2p/delegated-peer-routing": "^4.0.5",
"@libp2p/interface-metrics": "^4.0.6",
"@libp2p/interfaces": "^3.3.1",
"@libp2p/logger": "^2.0.7",
"@libp2p/mplex": "^7.1.7",
"@libp2p/tcp": "^6.2.1",
"@libp2p/utils": "^3.0.8",
"@lumeweb/kernel-protomux-client": "git+https://git.lumeweb.com/LumeWeb/kernel-protomux-client.git",
"@lumeweb/kernel-swarm-client": "git+https://git.lumeweb.com/LumeWeb/kernel-swarm-client.git",
"@lumeweb/libkernel-universal": "git+https://git.lumeweb.com/LumeWeb/libkernel-universal.git",
"@multiformats/mafmt": "^11.1.2",
"@peculiar/webcrypto": "git+https://git.lumeweb.com/LumeWeb/webcrypto.git",
"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",
"@helia/ipns": "^1.1.3",
"@helia/unixfs": "^1.4.0",
"@libp2p/delegated-content-routing": "^4.0.6",
"@libp2p/delegated-peer-routing": "^4.0.9",
"@libp2p/peer-id": "^2.0.4",
"@libp2p/reframe-content-routing": "^1.0.1",
"@libp2p/tcp": "7.0.3",
"@lumeweb/kernel-network-registry-client": "^0.1.0-develop.10",
"@lumeweb/kernel-protomux-client": "^0.0.2-develop.22",
"@lumeweb/kernel-swarm-client": "0.1.0-develop.12",
"@lumeweb/libhyperproxy": "^0.0.2-develop.4",
"@lumeweb/libkernel": "0.1.0-develop.66",
"@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.44",
"@peculiar/webcrypto": "^1.4.3",
"blockstore-idb": "^1.1.1",
"datastore-core": "^9.2.0",
"datastore-idb": "^2.1.2",
"helia": "^2.0.3-43932a5",
"ipfs-http-client": "^60.0.1",
"ipns": "^7.0.1",
"multiformats": "^12.0.1",
"p-defer": "^4.0.0",
"p-queue": "^7.3.4",
"private-ip": "^3.0.0",
"rewire": "^6.0.0",
"path-browserify": "^1.0.1",
"runes2": "^1.1.2",
"serialize-error": "^11.0.0",
"sodium-universal": "^4.0.0",
"streamx": "^2.13.2",
"timers-browserify": "^2.0.12"
},
"devDependencies": {
"@helia/interface": "^0.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",
"@rollup/plugin-alias": "^5.0.0",
"os-browserify": "^0.3.0",
"p-timeout": "^6.1.1",
"path-browserify": "^1.0.1",
"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"
"patch-package": "^7.0.0",
"rollup-plugin-ignore-import": "^1.3.2"
},
"browser": {
"libkernel": false,
"timers": "timers-browserify",
"path": "path-browserify",
"os": "os-browserify",
"net": "./src/net.ts",
"crypto": "crypto-browserify",
"stream": "stream-browserify"
},
"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"
}
"overrides": {
"libp2p": "^0.46.6",
"@libp2p/kad-dht": "^10.0.2",
"@chainsafe/libp2p-noise": "^12.0.0",
"@libp2p/mplex": "^9.0.2",
"@libp2p/bootstrap": "^9.0.2",
"@chainsafe/libp2p-gossipsub": "^10.0.0",
"@libp2p/interface-datastore": "^8.0.0",
"@libp2p/interface-blockstore": "^5.0.0"
}
}

View File

@ -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": {

View File

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

View File

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

View File

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

View File

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

59
src/bootstrap.ts Normal file
View File

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

84
src/config.ts Normal file
View File

@ -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,
},
}),
},
};
}

View File

@ -1,71 +1,64 @@
import { createLibp2p } from "libp2p";
import { createHelia } from "helia";
import { yamux } from "@chainsafe/libp2p-yamux";
// @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 { MultiSocketProxy } from "@lumeweb/libhyperproxy";
import { UnixFS, unixfs } from "@helia/unixfs";
// @ts-ignore
import { delegatedPeerRouting } from "@libp2p/delegated-peer-routing";
import { noise } from "@chainsafe/libp2p-noise";
import { create as createIpfsHttpClient } from "ipfs-http-client";
import { delegatedContentRouting } from "@libp2p/delegated-content-routing";
// @ts-ignore
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 { PROTOCOL } from "./constants.js";
import {
ActiveQuery,
addHandler,
handleMessage,
} from "@lumeweb/libkernel/module";
import { createClient } from "@lumeweb/kernel-swarm-client";
import { ipns, ipnsValidator, ipnsSelector, IPNS } from "@helia/ipns";
import { dht, pubsub } from "@helia/ipns/routing";
import { kadDHT } from "@libp2p/kad-dht";
import { ipns, IPNS } from "@helia/ipns";
import { dht } from "@helia/ipns/routing";
// @ts-ignore
import { gossipsub } from "@chainsafe/libp2p-gossipsub";
import { CID } from "multiformats/cid";
import { bases } from "multiformats/basics";
import { substr } from "runes2";
import { MultibaseDecoder } from "multiformats";
import { peerIdFromCID } from "@libp2p/peer-id";
import { bootstrap } from "@libp2p/bootstrap";
import { IDBBlockstore } from "blockstore-idb";
import { IDBDatastore } from "datastore-idb";
import defer from "p-defer";
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(
bases
bases,
).reduce((acc, curr) => {
// @ts-ignore
acc[bases[curr].prefix] = bases[curr];
return acc;
}, {});
const TYPES = ["content"];
onmessage = handleMessage;
const moduleDefer = defer();
let activeIpfsPeersDefer = defer();
let networkPeersAvailable = defer();
let networkReady = false;
const networkRegistry = createNetworkRegistryClient();
let swarm;
let proxy: MultiSocketProxy;
let fs: UnixFS;
let IPNS: IPNS;
let ipfs: Helia;
let ipfs: Helia<Libp2p<any>>;
// @ts-ignore
BigInt.prototype.toJSON = function () {
return this.toString();
};
addHandler("presentSeed", handlePresentSeed);
addHandler("presentKey", handlePresentKey);
addHandler("register", handleRegister);
addHandler("status", handleStatus, { receiveUpdates: true });
addHandler("name", handleName);
addHandler("ready", handleReady);
addHandler("stat", handleStat);
addHandler("ls", handleLs, { receiveUpdates: true });
@ -73,11 +66,9 @@ addHandler("cat", handleCat, { receiveUpdates: true });
addHandler("ipnsResolve", handleIpnsResolve);
addHandler("getActivePeers", handleGetActivePeers);
async function handlePresentSeed() {
async function handlePresentKey() {
swarm = createClient();
const client = createIpfsHttpClient(getDelegateConfig());
proxy = new MultiSocketProxy({
swarm,
listen: true,
@ -87,113 +78,25 @@ async function handlePresentSeed() {
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 datastore = new IDBDatastore("ipfs_data");
await blockstore.open();
await datastore.open();
// @ts-ignore
ipfs = await createHelia({
// @ts-ignore
blockstore,
// @ts-ignore
datastore,
libp2p,
libp2p: libp2pConfig(proxy),
start: false,
});
proxy.on("peerChannelOpen", async () => {
if (!ipfs.libp2p.isStarted()) {
await ipfs.libp2p.start();
await ipfs.start();
networkPeersAvailable.resolve();
networkReady = true;
}
});
@ -202,7 +105,7 @@ async function handlePresentSeed() {
await swarm.ready();
// @ts-ignore
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", () => {
if (ipfs.libp2p.getPeers().length > 0) {
@ -245,10 +148,10 @@ async function handleStat(aq: ActiveQuery) {
JSON.stringify(
await fs.stat(
getCID(aq.callerInput.cid),
aq.callerInput.options ?? {}
)
)
)
aq.callerInput.options ?? {},
),
),
),
);
} catch (e) {
aq.reject((e as Error).message);
@ -278,7 +181,7 @@ async function handleLs(aq: ActiveQuery) {
});
const iterable = fs.ls(
getCID(aq.callerInput.cid),
aq.callerInput.options ?? {}
aq.callerInput.options ?? {},
);
for await (const item of iterable) {
@ -318,7 +221,7 @@ async function handleCat(aq: ActiveQuery) {
const iterable = fs.cat(
getCID(aq.callerInput.cid),
aq.callerInput.options ?? {}
aq.callerInput.options ?? {},
);
for await (const chunk of iterable) {
@ -334,9 +237,22 @@ async function handleCat(aq: ActiveQuery) {
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) {
await ready();
/*
await activeIpfsPeersDefer.promise;
if (ipfs.libp2p.getPeers().length === 0) {
@ -344,6 +260,7 @@ async function handleIpnsResolve(aq: ActiveQuery) {
}
await activeIpfsPeersDefer.promise;
*/
if (!aq.callerInput || !("cid" in aq.callerInput)) {
aq.reject("cid required");
@ -351,14 +268,17 @@ async function handleIpnsResolve(aq: ActiveQuery) {
}
try {
return aq.respond(
(
await IPNS.resolve(
peerIdFromCID(getCID(aq.callerInput.cid)),
aq.callerInput?.options
)
).asCID.toString()
const cid = getCID(aq.callerInput.cid);
const ret = await fetch(
`${IPFS_GATEWAY}/ipns/${toDNSPrefix(cid)}?format=ipns-record`,
);
const buf = await ret.arrayBuffer();
const record = ipnsUnmarshal(new Uint8Array(buf));
return aq.respond(record.value);
} catch (e: any) {
aq.reject((e as Error).message);
}
@ -390,16 +310,70 @@ async function ready() {
await networkPeersAvailable.promise;
}
function getDelegateConfig(): Options {
const delegateString =
DELEGATE_LIST[Math.floor(Math.random() * DELEGATE_LIST.length)];
const delegateAddr = multiaddr(delegateString).toOptions();
async function handleRegister(aq: ActiveQuery) {
await networkRegistry.registerNetwork(TYPES);
return {
// @ts-ignore
host: delegateAddr.host,
// @ts-ignore
protocol: parseInt(delegateAddr.port) === 443 ? "https" : "http",
port: delegateAddr.port,
};
aq.respond();
}
async function handleStatus(aq: ActiveQuery) {
function sendUpdate() {
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");
}

View File

@ -50,6 +50,7 @@ class HypercoreTransport extends TCP {
const socket = await this._connect(ma, options);
// Avoid uncaught errors caused by unstable connections
// @ts-ignore
socket.on("error", (err: any) => {
log("socket error", err);
});
@ -82,6 +83,7 @@ class HypercoreTransport extends TCP {
throw new AbortError();
}
// @ts-ignore
return conn;
}
@ -113,9 +115,10 @@ class HypercoreTransport extends TCP {
const err = new CodeError(
`connection timeout after ${Date.now() - start}ms`,
"ERR_CONNECT_TIMEOUT"
"ERR_CONNECT_TIMEOUT",
);
// Note: this will result in onError() being called
// @ts-ignore
rawSocket?.emit("error", err);
};
@ -128,11 +131,13 @@ class HypercoreTransport extends TCP {
const onAbort = (): void => {
log("connection aborted %j", cOpts);
this.metrics?.dialerEvents.increment({ abort: true });
// @ts-ignore
rawSocket?.destroy();
done(new AbortError());
};
const done = (err?: any): void => {
// @ts-ignore
rawSocket?.removeListener("error", onError);
// @ts-ignore
rawSocket?.removeListener("timeout", onTimeout);
@ -199,7 +204,7 @@ class HypercoreTransport extends TCP {
}
export function hypercoreTransport(
init: HypercoreOptions = {}
init: HypercoreOptions = {},
): (components?: TCPComponents) => HypercoreTransport {
return (components: TCPComponents = {}) => {
return new HypercoreTransport(components, init);

View File

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

View File

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