libp2p 0.36.2 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -21
- package/README.md +13 -10
- package/dist/src/address-manager/index.d.ts +34 -52
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +81 -0
- package/dist/src/address-manager/index.js.map +1 -0
- package/dist/src/circuit/auto-relay.d.ts +24 -85
- package/dist/src/circuit/auto-relay.d.ts.map +1 -1
- package/dist/src/circuit/auto-relay.js +216 -0
- package/dist/src/circuit/auto-relay.js.map +1 -0
- package/dist/src/circuit/circuit/hop.d.ts +26 -53
- package/dist/src/circuit/circuit/hop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/hop.js +138 -0
- package/dist/src/circuit/circuit/hop.js.map +1 -0
- package/dist/src/circuit/circuit/stop.d.ts +18 -10
- package/dist/src/circuit/circuit/stop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stop.js +49 -0
- package/dist/src/circuit/circuit/stop.js.map +1 -0
- package/dist/src/circuit/circuit/stream-handler.d.ts +19 -38
- package/dist/src/circuit/circuit/stream-handler.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stream-handler.js +59 -0
- package/dist/src/circuit/circuit/stream-handler.js.map +1 -0
- package/dist/src/circuit/circuit/utils.d.ts +3 -6
- package/dist/src/circuit/circuit/utils.d.ts.map +1 -1
- package/dist/src/circuit/circuit/utils.js +43 -0
- package/dist/src/circuit/circuit/utils.js.map +1 -0
- package/dist/src/circuit/constants.d.ts +24 -6
- package/dist/src/circuit/constants.d.ts.map +1 -1
- package/dist/src/circuit/constants.js +26 -0
- package/dist/src/circuit/constants.js.map +1 -0
- package/dist/src/circuit/index.d.ts +41 -74
- package/dist/src/circuit/index.d.ts.map +1 -1
- package/dist/src/circuit/index.js +69 -0
- package/dist/src/circuit/index.js.map +1 -0
- package/dist/src/circuit/listener.d.ts +8 -3
- package/dist/src/circuit/listener.d.ts.map +1 -1
- package/dist/src/circuit/listener.js +62 -0
- package/dist/src/circuit/listener.js.map +1 -0
- package/dist/src/circuit/multicodec.d.ts +1 -1
- package/dist/src/circuit/multicodec.d.ts.map +1 -1
- package/dist/src/circuit/multicodec.js +2 -0
- package/dist/src/circuit/multicodec.js.map +1 -0
- package/dist/src/circuit/pb/index.d.ts +52 -0
- package/dist/src/circuit/pb/index.d.ts.map +1 -0
- package/dist/src/circuit/pb/index.js +98 -0
- package/dist/src/circuit/pb/index.js.map +1 -0
- package/dist/src/circuit/transport.d.ts +18 -78
- package/dist/src/circuit/transport.d.ts.map +1 -1
- package/dist/src/circuit/transport.js +192 -0
- package/dist/src/circuit/transport.js.map +1 -0
- package/dist/src/circuit/utils.d.ts +5 -2
- package/dist/src/circuit/utils.d.ts.map +1 -1
- package/dist/src/circuit/utils.js +11 -0
- package/dist/src/circuit/utils.js.map +1 -0
- package/dist/src/config.d.ts +3 -85
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +91 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/connection-manager/auto-dialler.d.ts +24 -41
- package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dialler.js +105 -0
- package/dist/src/connection-manager/auto-dialler.js.map +1 -0
- package/dist/src/connection-manager/dialer/auto-dialer.d.ts +16 -0
- package/dist/src/connection-manager/dialer/auto-dialer.d.ts.map +1 -0
- package/dist/src/connection-manager/dialer/auto-dialer.js +37 -0
- package/dist/src/connection-manager/dialer/auto-dialer.js.map +1 -0
- package/dist/src/connection-manager/dialer/dial-request.d.ts +27 -0
- package/dist/src/connection-manager/dialer/dial-request.d.ts.map +1 -0
- package/dist/src/connection-manager/dialer/dial-request.js +83 -0
- package/dist/src/connection-manager/dialer/dial-request.js.map +1 -0
- package/dist/src/connection-manager/dialer/index.d.ts +104 -0
- package/dist/src/connection-manager/dialer/index.d.ts.map +1 -0
- package/dist/src/connection-manager/dialer/index.js +267 -0
- package/dist/src/connection-manager/dialer/index.js.map +1 -0
- package/dist/src/connection-manager/index.d.ts +102 -136
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +333 -0
- package/dist/src/connection-manager/index.js.map +1 -0
- package/dist/src/connection-manager/latency-monitor.d.ts +72 -97
- package/dist/src/connection-manager/latency-monitor.d.ts.map +1 -1
- package/dist/src/connection-manager/latency-monitor.js +220 -0
- package/dist/src/connection-manager/latency-monitor.js.map +1 -0
- package/dist/src/connection-manager/visibility-change-emitter.d.ts +15 -16
- package/dist/src/connection-manager/visibility-change-emitter.d.ts.map +1 -1
- package/dist/src/connection-manager/visibility-change-emitter.js +118 -0
- package/dist/src/connection-manager/visibility-change-emitter.js.map +1 -0
- package/dist/src/constants.d.ts +22 -10
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +27 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/content-routing/index.d.ts +27 -81
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +99 -0
- package/dist/src/content-routing/index.js.map +1 -0
- package/dist/src/content-routing/utils.d.ts +6 -49
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/content-routing/utils.js +42 -0
- package/dist/src/content-routing/utils.js.map +1 -0
- package/dist/src/dht/dht-content-routing.d.ts +10 -24
- package/dist/src/dht/dht-content-routing.d.ts.map +1 -1
- package/dist/src/dht/dht-content-routing.js +32 -0
- package/dist/src/dht/dht-content-routing.js.map +1 -0
- package/dist/src/dht/dht-peer-routing.d.ts +9 -24
- package/dist/src/dht/dht-peer-routing.d.ts.map +1 -1
- package/dist/src/dht/dht-peer-routing.js +26 -0
- package/dist/src/dht/dht-peer-routing.js.map +1 -0
- package/dist/src/dht/dummy-dht.d.ts +20 -0
- package/dist/src/dht/dummy-dht.d.ts.map +1 -0
- package/dist/src/dht/dummy-dht.js +46 -0
- package/dist/src/dht/dummy-dht.js.map +1 -0
- package/dist/src/errors.d.ts +70 -63
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +75 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/fetch/constants.d.ts +1 -1
- package/dist/src/fetch/constants.d.ts.map +1 -1
- package/dist/src/fetch/constants.js +3 -0
- package/dist/src/fetch/constants.js.map +1 -0
- package/dist/src/fetch/index.d.ts +30 -49
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +129 -0
- package/dist/src/fetch/index.js.map +1 -0
- package/dist/src/fetch/pb/proto.d.ts +27 -0
- package/dist/src/fetch/pb/proto.d.ts.map +1 -0
- package/dist/src/fetch/pb/proto.js +50 -0
- package/dist/src/fetch/pb/proto.js.map +1 -0
- package/dist/src/get-peer.d.ts +4 -11
- package/dist/src/get-peer.d.ts.map +1 -1
- package/dist/src/get-peer.js +43 -0
- package/dist/src/get-peer.js.map +1 -0
- package/dist/src/identify/consts.d.ts +9 -9
- package/dist/src/identify/consts.d.ts.map +1 -1
- package/dist/src/identify/consts.js +11 -0
- package/dist/src/identify/consts.js.map +1 -0
- package/dist/src/identify/index.d.ts +42 -96
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +322 -0
- package/dist/src/identify/index.js.map +1 -0
- package/dist/src/identify/pb/message.d.ts +16 -0
- package/dist/src/identify/pb/message.d.ts.map +1 -0
- package/dist/src/identify/pb/message.js +24 -0
- package/dist/src/identify/pb/message.js.map +1 -0
- package/dist/src/index.d.ts +150 -496
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/insecure/index.d.ts +9 -0
- package/dist/src/insecure/index.d.ts.map +1 -0
- package/dist/src/insecure/index.js +81 -0
- package/dist/src/insecure/index.js.map +1 -0
- package/dist/src/insecure/pb/proto.d.ts +29 -0
- package/dist/src/insecure/pb/proto.d.ts.map +1 -0
- package/dist/src/insecure/pb/proto.js +53 -0
- package/dist/src/insecure/pb/proto.js.map +1 -0
- package/dist/src/keychain/cms.d.ts +6 -14
- package/dist/src/keychain/cms.d.ts.map +1 -1
- package/dist/src/keychain/cms.js +129 -0
- package/dist/src/keychain/cms.js.map +1 -0
- package/dist/src/keychain/index.d.ts +60 -81
- package/dist/src/keychain/index.d.ts.map +1 -1
- package/dist/src/keychain/index.js +492 -0
- package/dist/src/keychain/index.js.map +1 -0
- package/dist/src/keychain/util.d.ts +3 -6
- package/dist/src/keychain/util.d.ts.map +1 -1
- package/dist/src/keychain/util.js +79 -0
- package/dist/src/keychain/util.js.map +1 -0
- package/dist/src/libp2p.d.ts +80 -0
- package/dist/src/libp2p.d.ts.map +1 -0
- package/dist/src/libp2p.js +397 -0
- package/dist/src/libp2p.js.map +1 -0
- package/dist/src/metrics/index.d.ts +47 -104
- package/dist/src/metrics/index.d.ts.map +1 -1
- package/dist/src/metrics/index.js +231 -0
- package/dist/src/metrics/index.js.map +1 -0
- package/dist/src/metrics/moving-average.d.ts +14 -0
- package/dist/src/metrics/moving-average.d.ts.map +1 -0
- package/dist/src/metrics/moving-average.js +40 -0
- package/dist/src/metrics/moving-average.js.map +1 -0
- package/dist/src/metrics/stats.d.ts +41 -93
- package/dist/src/metrics/stats.d.ts.map +1 -1
- package/dist/src/metrics/stats.js +183 -0
- package/dist/src/metrics/stats.js.map +1 -0
- package/dist/src/nat-manager.d.ts +42 -99
- package/dist/src/nat-manager.d.ts.map +1 -1
- package/dist/src/nat-manager.js +114 -0
- package/dist/src/nat-manager.js.map +1 -0
- package/dist/src/peer-record-updater.d.ts +15 -0
- package/dist/src/peer-record-updater.d.ts.map +1 -0
- package/dist/src/peer-record-updater.js +44 -0
- package/dist/src/peer-record-updater.js.map +1 -0
- package/dist/src/peer-routing.d.ts +40 -84
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +108 -0
- package/dist/src/peer-routing.js.map +1 -0
- package/dist/src/ping/constants.d.ts +4 -4
- package/dist/src/ping/constants.d.ts.map +1 -1
- package/dist/src/ping/constants.js +5 -0
- package/dist/src/ping/constants.js.map +1 -0
- package/dist/src/ping/index.d.ts +17 -31
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +57 -0
- package/dist/src/ping/index.js.map +1 -0
- package/dist/src/pnet/crypto.d.ts +15 -5
- package/dist/src/pnet/crypto.d.ts.map +1 -1
- package/dist/src/pnet/crypto.js +60 -0
- package/dist/src/pnet/crypto.js.map +1 -0
- package/dist/src/pnet/errors.d.ts +5 -5
- package/dist/src/pnet/errors.d.ts.map +1 -1
- package/dist/src/pnet/errors.js +6 -0
- package/dist/src/pnet/errors.js.map +1 -0
- package/dist/src/pnet/index.d.ts +12 -20
- package/dist/src/pnet/index.d.ts.map +1 -1
- package/dist/src/pnet/index.js +67 -0
- package/dist/src/pnet/index.js.map +1 -0
- package/dist/src/pnet/key-generator.d.ts +3 -7
- package/dist/src/pnet/key-generator.d.ts.map +1 -1
- package/dist/src/pnet/key-generator.js +25 -0
- package/dist/src/pnet/key-generator.js.map +1 -0
- package/dist/src/pubsub/dummy-pubsub.d.ts +17 -0
- package/dist/src/pubsub/dummy-pubsub.d.ts.map +1 -0
- package/dist/src/pubsub/dummy-pubsub.js +37 -0
- package/dist/src/pubsub/dummy-pubsub.js.map +1 -0
- package/dist/src/registrar.d.ts +26 -65
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +144 -0
- package/dist/src/registrar.js.map +1 -0
- package/dist/src/transport-manager.d.ts +36 -82
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +223 -0
- package/dist/src/transport-manager.js.map +1 -0
- package/dist/src/upgrader.d.ts +49 -129
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +402 -0
- package/dist/src/upgrader.js.map +1 -0
- package/dist/src/version.d.ts +3 -0
- package/dist/src/version.d.ts.map +1 -0
- package/dist/src/version.js +3 -0
- package/dist/src/version.js.map +1 -0
- package/package.json +144 -201
- package/src/address-manager/index.ts +130 -0
- package/src/circuit/README.md +16 -11
- package/src/circuit/auto-relay.ts +286 -0
- package/src/circuit/circuit/hop.ts +211 -0
- package/src/circuit/circuit/stop.ts +78 -0
- package/src/circuit/circuit/stream-handler.ts +86 -0
- package/src/circuit/circuit/{utils.js → utils.ts} +9 -25
- package/src/circuit/constants.ts +31 -0
- package/src/circuit/index.ts +120 -0
- package/src/circuit/listener.ts +82 -0
- package/src/circuit/multicodec.ts +2 -0
- package/src/circuit/{protocol → pb}/index.proto +1 -1
- package/src/circuit/pb/index.ts +117 -0
- package/src/circuit/transport.ts +219 -0
- package/src/circuit/utils.ts +12 -0
- package/src/config.ts +99 -0
- package/src/connection-manager/auto-dialler.ts +154 -0
- package/src/connection-manager/dialer/auto-dialer.ts +59 -0
- package/src/{dialer/dial-request.js → connection-manager/dialer/dial-request.ts} +60 -51
- package/src/connection-manager/dialer/index.ts +382 -0
- package/src/connection-manager/index.ts +508 -0
- package/src/connection-manager/latency-monitor.ts +319 -0
- package/src/connection-manager/{visibility-change-emitter.js → visibility-change-emitter.ts} +48 -38
- package/src/constants.ts +31 -0
- package/src/content-routing/index.ts +144 -0
- package/src/content-routing/utils.ts +54 -0
- package/src/dht/dht-content-routing.ts +43 -0
- package/src/dht/dht-peer-routing.ts +35 -0
- package/src/dht/dummy-dht.ts +60 -0
- package/src/errors.ts +73 -0
- package/src/fetch/README.md +1 -1
- package/src/fetch/constants.ts +3 -0
- package/src/fetch/index.ts +167 -0
- package/src/fetch/{proto.proto → pb/proto.proto} +0 -0
- package/src/fetch/pb/proto.ts +65 -0
- package/src/get-peer.ts +57 -0
- package/src/identify/consts.ts +13 -0
- package/src/identify/index.ts +445 -0
- package/src/identify/{message.proto → pb/message.proto} +0 -0
- package/src/identify/pb/message.ts +37 -0
- package/src/index.ts +220 -0
- package/src/insecure/index.ts +101 -0
- package/src/insecure/{proto.proto → pb/proto.proto} +0 -0
- package/src/insecure/pb/proto.ts +68 -0
- package/src/keychain/{cms.js → cms.ts} +62 -58
- package/src/keychain/index.ts +587 -0
- package/src/keychain/{util.js → util.ts} +7 -17
- package/src/libp2p.ts +538 -0
- package/src/metrics/index.ts +310 -0
- package/src/metrics/moving-average.ts +53 -0
- package/src/metrics/stats.ts +238 -0
- package/src/nat-manager.ts +194 -0
- package/src/peer-record-updater.ts +55 -0
- package/src/peer-routing.ts +186 -0
- package/src/ping/README.md +1 -1
- package/src/ping/constants.ts +5 -0
- package/src/ping/index.ts +84 -0
- package/src/pnet/README.md +2 -2
- package/src/pnet/crypto.ts +67 -0
- package/src/pnet/errors.ts +5 -0
- package/src/pnet/index.ts +97 -0
- package/src/pnet/key-generator.ts +28 -0
- package/src/pubsub/dummy-pubsub.ts +51 -0
- package/src/registrar.ts +189 -0
- package/src/transport-manager.ts +281 -0
- package/src/upgrader.ts +499 -0
- package/src/version.ts +3 -0
- package/dist/index.min.js +0 -55
- package/dist/src/circuit/protocol/index.d.ts +0 -173
- package/dist/src/dialer/dial-request.d.ts +0 -55
- package/dist/src/dialer/dial-request.d.ts.map +0 -1
- package/dist/src/dialer/index.d.ts +0 -182
- package/dist/src/dialer/index.d.ts.map +0 -1
- package/dist/src/fetch/proto.d.ts +0 -134
- package/dist/src/identify/message.d.ts +0 -95
- package/dist/src/insecure/plaintext.d.ts +0 -12
- package/dist/src/insecure/plaintext.d.ts.map +0 -1
- package/dist/src/insecure/proto.d.ts +0 -128
- package/dist/src/metrics/old-peers.d.ts +0 -3
- package/dist/src/metrics/old-peers.d.ts.map +0 -1
- package/dist/src/metrics/tracked-map.d.ts +0 -8
- package/dist/src/metrics/tracked-map.d.ts.map +0 -1
- package/dist/src/peer-store/address-book.d.ts +0 -67
- package/dist/src/peer-store/address-book.d.ts.map +0 -1
- package/dist/src/peer-store/index.d.ts +0 -58
- package/dist/src/peer-store/index.d.ts.map +0 -1
- package/dist/src/peer-store/key-book.d.ts +0 -40
- package/dist/src/peer-store/key-book.d.ts.map +0 -1
- package/dist/src/peer-store/metadata-book.d.ts +0 -58
- package/dist/src/peer-store/metadata-book.d.ts.map +0 -1
- package/dist/src/peer-store/pb/peer.d.ts +0 -222
- package/dist/src/peer-store/proto-book.d.ts +0 -43
- package/dist/src/peer-store/proto-book.d.ts.map +0 -1
- package/dist/src/peer-store/store.d.ts +0 -73
- package/dist/src/peer-store/store.d.ts.map +0 -1
- package/dist/src/peer-store/types.d.ts +0 -202
- package/dist/src/peer-store/types.d.ts.map +0 -1
- package/dist/src/ping/util.d.ts +0 -5
- package/dist/src/ping/util.d.ts.map +0 -1
- package/dist/src/pubsub-adapter.d.ts +0 -22
- package/dist/src/pubsub-adapter.d.ts.map +0 -1
- package/dist/src/record/envelope/envelope.d.ts +0 -77
- package/dist/src/record/envelope/index.d.ts +0 -80
- package/dist/src/record/envelope/index.d.ts.map +0 -1
- package/dist/src/record/peer-record/consts.d.ts +0 -4
- package/dist/src/record/peer-record/consts.d.ts.map +0 -1
- package/dist/src/record/peer-record/index.d.ts +0 -60
- package/dist/src/record/peer-record/index.d.ts.map +0 -1
- package/dist/src/record/peer-record/peer-record.d.ts +0 -133
- package/dist/src/record/utils.d.ts +0 -12
- package/dist/src/record/utils.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -90
- package/dist/src/types.d.ts.map +0 -1
- package/src/address-manager/index.js +0 -96
- package/src/circuit/auto-relay.js +0 -302
- package/src/circuit/circuit/hop.js +0 -205
- package/src/circuit/circuit/stop.js +0 -81
- package/src/circuit/circuit/stream-handler.js +0 -94
- package/src/circuit/constants.js +0 -12
- package/src/circuit/index.js +0 -102
- package/src/circuit/listener.js +0 -75
- package/src/circuit/multicodec.js +0 -5
- package/src/circuit/protocol/index.d.ts +0 -173
- package/src/circuit/protocol/index.js +0 -530
- package/src/circuit/transport.js +0 -229
- package/src/circuit/utils.js +0 -17
- package/src/config.js +0 -114
- package/src/connection-manager/auto-dialler.js +0 -132
- package/src/connection-manager/index.js +0 -374
- package/src/connection-manager/latency-monitor.js +0 -264
- package/src/constants.js +0 -18
- package/src/content-routing/index.js +0 -163
- package/src/content-routing/utils.js +0 -89
- package/src/dht/dht-content-routing.js +0 -44
- package/src/dht/dht-peer-routing.js +0 -51
- package/src/dialer/index.js +0 -376
- package/src/errors.js +0 -66
- package/src/fetch/constants.js +0 -6
- package/src/fetch/index.js +0 -159
- package/src/fetch/proto.d.ts +0 -134
- package/src/fetch/proto.js +0 -333
- package/src/get-peer.js +0 -49
- package/src/identify/consts.js +0 -15
- package/src/identify/index.js +0 -384
- package/src/identify/message.d.ts +0 -95
- package/src/identify/message.js +0 -328
- package/src/index.js +0 -813
- package/src/insecure/plaintext.js +0 -95
- package/src/insecure/proto.d.ts +0 -128
- package/src/insecure/proto.js +0 -371
- package/src/keychain/index.js +0 -561
- package/src/metrics/index.js +0 -290
- package/src/metrics/old-peers.js +0 -16
- package/src/metrics/stats.js +0 -270
- package/src/metrics/tracked-map.js +0 -94
- package/src/nat-manager.js +0 -197
- package/src/peer-routing.js +0 -176
- package/src/peer-store/README.md +0 -145
- package/src/peer-store/address-book.js +0 -382
- package/src/peer-store/index.js +0 -121
- package/src/peer-store/key-book.js +0 -141
- package/src/peer-store/metadata-book.js +0 -250
- package/src/peer-store/pb/peer.d.ts +0 -222
- package/src/peer-store/pb/peer.js +0 -643
- package/src/peer-store/pb/peer.proto +0 -31
- package/src/peer-store/proto-book.js +0 -237
- package/src/peer-store/store.js +0 -263
- package/src/peer-store/types.ts +0 -245
- package/src/ping/constants.js +0 -8
- package/src/ping/index.js +0 -84
- package/src/ping/util.js +0 -18
- package/src/pnet/crypto.js +0 -84
- package/src/pnet/errors.js +0 -7
- package/src/pnet/index.js +0 -86
- package/src/pnet/key-generator.js +0 -33
- package/src/pubsub-adapter.js +0 -61
- package/src/record/README.md +0 -130
- package/src/record/envelope/envelope.d.ts +0 -77
- package/src/record/envelope/envelope.js +0 -243
- package/src/record/envelope/envelope.proto +0 -19
- package/src/record/envelope/index.js +0 -183
- package/src/record/peer-record/consts.js +0 -14
- package/src/record/peer-record/index.js +0 -113
- package/src/record/peer-record/peer-record.d.ts +0 -133
- package/src/record/peer-record/peer-record.js +0 -367
- package/src/record/peer-record/peer-record.proto +0 -18
- package/src/record/utils.js +0 -25
- package/src/registrar.js +0 -127
- package/src/transport-manager.js +0 -269
- package/src/types.ts +0 -98
- package/src/upgrader.js +0 -492
package/package.json
CHANGED
|
@@ -1,253 +1,196 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libp2p",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"types": "dist/src/index.d.ts",
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
"*": {
|
|
10
|
-
"src/*": [
|
|
11
|
-
"dist/src/*",
|
|
12
|
-
"dist/src/*/index"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist",
|
|
18
|
-
"src"
|
|
19
|
-
],
|
|
20
|
-
"scripts": {
|
|
21
|
-
"lint": "aegir lint",
|
|
22
|
-
"build": "aegir build",
|
|
23
|
-
"build:proto": "npm run build:proto:circuit && npm run build:proto:fetch && npm run build:proto:identify && npm run build:proto:plaintext && npm run build:proto:address-book && npm run build:proto:proto-book && npm run build:proto:peer && npm run build:proto:peer-record && npm run build:proto:envelope",
|
|
24
|
-
"build:proto:circuit": "pbjs -t static-module -w commonjs -r libp2p-circuit --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/circuit/protocol/index.js ./src/circuit/protocol/index.proto",
|
|
25
|
-
"build:proto:fetch": "pbjs -t static-module -w commonjs -r libp2p-fetch --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/fetch/proto.js ./src/fetch/proto.proto",
|
|
26
|
-
"build:proto:identify": "pbjs -t static-module -w commonjs -r libp2p-identify --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/identify/message.js ./src/identify/message.proto",
|
|
27
|
-
"build:proto:plaintext": "pbjs -t static-module -w commonjs -r libp2p-plaintext --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/insecure/proto.js ./src/insecure/proto.proto",
|
|
28
|
-
"build:proto:peer": "pbjs -t static-module -w commonjs -r libp2p-peer --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/peer-store/pb/peer.js ./src/peer-store/pb/peer.proto",
|
|
29
|
-
"build:proto:peer-record": "pbjs -t static-module -w commonjs -r libp2p-peer-record --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/peer-record/peer-record.js ./src/record/peer-record/peer-record.proto",
|
|
30
|
-
"build:proto:envelope": "pbjs -t static-module -w commonjs -r libp2p-envelope --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/record/envelope/envelope.js ./src/record/envelope/envelope.proto",
|
|
31
|
-
"build:proto-types": "npm run build:proto-types:circuit && npm run build:proto-types:fetch && npm run build:proto-types:identify && npm run build:proto-types:plaintext && npm run build:proto-types:address-book && npm run build:proto-types:proto-book && npm run build:proto-types:peer && npm run build:proto-types:peer-record && npm run build:proto-types:envelope",
|
|
32
|
-
"build:proto-types:circuit": "pbts -o src/circuit/protocol/index.d.ts src/circuit/protocol/index.js",
|
|
33
|
-
"build:proto-types:fetch": "pbts -o src/fetch/proto.d.ts src/fetch/proto.js",
|
|
34
|
-
"build:proto-types:identify": "pbts -o src/identify/message.d.ts src/identify/message.js",
|
|
35
|
-
"build:proto-types:plaintext": "pbts -o src/insecure/proto.d.ts src/insecure/proto.js",
|
|
36
|
-
"build:proto-types:peer": "pbts -o src/peer-store/pb/peer.d.ts src/peer-store/pb/peer.js",
|
|
37
|
-
"build:proto-types:peer-record": "pbts -o src/record/peer-record/peer-record.d.ts src/record/peer-record/peer-record.js",
|
|
38
|
-
"build:proto-types:envelope": "pbts -o src/record/envelope/envelope.d.ts src/record/envelope/envelope.js",
|
|
39
|
-
"test": "aegir test",
|
|
40
|
-
"test:ts": "aegir build --no-bundle && npm run test --prefix test/ts-use",
|
|
41
|
-
"test:node": "aegir test -t node -f \"./test/**/*.{node,spec}.js\"",
|
|
42
|
-
"test:browser": "aegir test -t browser",
|
|
43
|
-
"test:examples": "cd examples && npm run test:all",
|
|
44
|
-
"test:interop": "LIBP2P_JS=$PWD npx aegir test -t node -f ./node_modules/libp2p-interop/test/*",
|
|
45
|
-
"prepare": "npm run build",
|
|
46
|
-
"coverage": "nyc --reporter=text --reporter=lcov npm run test:node"
|
|
47
|
-
},
|
|
5
|
+
"license": "Apache-2.0 OR MIT",
|
|
6
|
+
"homepage": "https://github.com/libp2p/js-libp2p#readme",
|
|
48
7
|
"repository": {
|
|
49
8
|
"type": "git",
|
|
50
|
-
"url": "https://github.com/libp2p/js-libp2p.git"
|
|
9
|
+
"url": "git+https://github.com/libp2p/js-libp2p.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/libp2p/js-libp2p/issues"
|
|
51
13
|
},
|
|
52
14
|
"keywords": [
|
|
15
|
+
"IPFS",
|
|
53
16
|
"libp2p",
|
|
54
17
|
"network",
|
|
55
18
|
"p2p",
|
|
56
19
|
"peer",
|
|
57
|
-
"peer-to-peer"
|
|
58
|
-
"IPFS"
|
|
20
|
+
"peer-to-peer"
|
|
59
21
|
],
|
|
60
|
-
"bugs": {
|
|
61
|
-
"url": "https://github.com/libp2p/js-libp2p/issues"
|
|
62
|
-
},
|
|
63
|
-
"homepage": "https://libp2p.io",
|
|
64
|
-
"license": "MIT",
|
|
65
22
|
"engines": {
|
|
66
|
-
"node": ">=
|
|
23
|
+
"node": ">=16.0.0",
|
|
24
|
+
"npm": ">=7.0.0"
|
|
67
25
|
},
|
|
68
|
-
"
|
|
69
|
-
|
|
26
|
+
"type": "module",
|
|
27
|
+
"types": "./dist/src/index.d.ts",
|
|
28
|
+
"typesVersions": {
|
|
29
|
+
"*": {
|
|
30
|
+
"*": [
|
|
31
|
+
"*",
|
|
32
|
+
"dist/*",
|
|
33
|
+
"dist/src/*",
|
|
34
|
+
"dist/src/*/index"
|
|
35
|
+
],
|
|
36
|
+
"src/*": [
|
|
37
|
+
"*",
|
|
38
|
+
"dist/*",
|
|
39
|
+
"dist/src/*",
|
|
40
|
+
"dist/src/*/index"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"src",
|
|
46
|
+
"dist/src",
|
|
47
|
+
"!dist/test",
|
|
48
|
+
"!**/*.tsbuildinfo"
|
|
49
|
+
],
|
|
50
|
+
"exports": {
|
|
51
|
+
".": {
|
|
52
|
+
"import": "./dist/src/index.js"
|
|
53
|
+
},
|
|
54
|
+
"./insecure": {
|
|
55
|
+
"import": "./dist/src/insecure/index.js"
|
|
56
|
+
},
|
|
57
|
+
"./pnet": {
|
|
58
|
+
"import": "./dist/src/pnet/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./transport-manager": {
|
|
61
|
+
"import": "./dist/src/transport-manager.js"
|
|
62
|
+
}
|
|
70
63
|
},
|
|
71
64
|
"eslintConfig": {
|
|
72
65
|
"extends": "ipfs",
|
|
66
|
+
"parserOptions": {
|
|
67
|
+
"sourceType": "module"
|
|
68
|
+
},
|
|
73
69
|
"ignorePatterns": [
|
|
74
70
|
"!.aegir.js",
|
|
75
71
|
"test/ts-use",
|
|
76
72
|
"*.d.ts"
|
|
77
73
|
]
|
|
78
74
|
},
|
|
75
|
+
"scripts": {
|
|
76
|
+
"clean": "aegir clean",
|
|
77
|
+
"lint": "aegir lint",
|
|
78
|
+
"dep-check": "aegir dep-check",
|
|
79
|
+
"build": "aegir build",
|
|
80
|
+
"generate": "run-s generate:proto:*",
|
|
81
|
+
"generate:proto:circuit": "protons ./src/circuit/pb/index.proto",
|
|
82
|
+
"generate:proto:fetch": "protons ./src/fetch/pb/proto.proto",
|
|
83
|
+
"generate:proto:identify": "protons ./src/identify/pb/message.proto",
|
|
84
|
+
"generate:proto:plaintext": "protons ./src/insecure/pb/proto.proto",
|
|
85
|
+
"test": "aegir test",
|
|
86
|
+
"test:node": "aegir test -t node -f \"./dist/test/**/*.{node,spec}.js\" --cov",
|
|
87
|
+
"test:chrome": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" --cov",
|
|
88
|
+
"test:chrome-webworker": "aegir test -t webworker -f \"./dist/test/**/*.spec.js\"",
|
|
89
|
+
"test:firefox": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" -- --browser firefox",
|
|
90
|
+
"test:firefox-webworker": "aegir test -t webworker -f \"./dist/test/**/*.spec.js\" -- --browser firefox",
|
|
91
|
+
"test:examples": "cd examples && npm run test:all",
|
|
92
|
+
"test:interop": "aegir test -t node -f dist/test/interop.js"
|
|
93
|
+
},
|
|
79
94
|
"dependencies": {
|
|
80
|
-
"@
|
|
81
|
-
"
|
|
82
|
-
"
|
|
95
|
+
"@achingbrain/nat-port-mapper": "^1.0.0",
|
|
96
|
+
"@libp2p/connection": "^1.1.5",
|
|
97
|
+
"@libp2p/crypto": "^0.22.11",
|
|
98
|
+
"@libp2p/interfaces": "^1.3.31",
|
|
99
|
+
"@libp2p/logger": "^1.1.4",
|
|
100
|
+
"@libp2p/multistream-select": "^1.0.4",
|
|
101
|
+
"@libp2p/peer-collections": "^1.0.2",
|
|
102
|
+
"@libp2p/peer-id": "^1.1.10",
|
|
103
|
+
"@libp2p/peer-id-factory": "^1.0.9",
|
|
104
|
+
"@libp2p/peer-record": "^1.0.8",
|
|
105
|
+
"@libp2p/peer-store": "^1.0.10",
|
|
106
|
+
"@libp2p/tracked-map": "^1.0.5",
|
|
107
|
+
"@libp2p/utils": "^1.0.10",
|
|
108
|
+
"@multiformats/mafmt": "^11.0.2",
|
|
109
|
+
"@multiformats/multiaddr": "^10.1.8",
|
|
110
|
+
"abortable-iterator": "^4.0.2",
|
|
83
111
|
"any-signal": "^3.0.0",
|
|
84
|
-
"bignumber.js": "^9.0.1",
|
|
85
|
-
"class-is": "^1.1.0",
|
|
86
112
|
"datastore-core": "^7.0.0",
|
|
87
|
-
"
|
|
88
|
-
"err-code": "^3.0.0",
|
|
89
|
-
"es6-promisify": "^7.0.0",
|
|
113
|
+
"err-code": "^3.0.1",
|
|
90
114
|
"events": "^3.3.0",
|
|
91
115
|
"hashlru": "^2.3.0",
|
|
92
|
-
"interface-datastore": "^6.0
|
|
93
|
-
"it-all": "^1.0.
|
|
94
|
-
"it-
|
|
95
|
-
"it-
|
|
96
|
-
"it-
|
|
97
|
-
"it-first": "^1.0.4",
|
|
116
|
+
"interface-datastore": "^6.1.0",
|
|
117
|
+
"it-all": "^1.0.6",
|
|
118
|
+
"it-drain": "^1.0.5",
|
|
119
|
+
"it-filter": "^1.0.3",
|
|
120
|
+
"it-first": "^1.0.6",
|
|
98
121
|
"it-foreach": "^0.1.1",
|
|
99
|
-
"it-handshake": "^
|
|
100
|
-
"it-length-prefixed": "^
|
|
101
|
-
"it-map": "^1.0.
|
|
102
|
-
"it-merge": "^1.0.
|
|
103
|
-
"it-
|
|
122
|
+
"it-handshake": "^3.0.1",
|
|
123
|
+
"it-length-prefixed": "^7.0.1",
|
|
124
|
+
"it-map": "^1.0.6",
|
|
125
|
+
"it-merge": "^1.0.3",
|
|
126
|
+
"it-pair": "^2.0.2",
|
|
127
|
+
"it-pipe": "^2.0.3",
|
|
104
128
|
"it-sort": "^1.0.1",
|
|
105
|
-
"it-
|
|
106
|
-
"
|
|
107
|
-
"libp2p-interfaces": "^4.0.0",
|
|
108
|
-
"libp2p-utils": "^0.4.0",
|
|
109
|
-
"mafmt": "^10.0.0",
|
|
129
|
+
"it-stream-types": "^1.0.4",
|
|
130
|
+
"it-take": "^1.0.2",
|
|
110
131
|
"merge-options": "^3.0.4",
|
|
111
|
-
"
|
|
112
|
-
"multiaddr": "^10.0.0",
|
|
113
|
-
"multiformats": "^9.0.0",
|
|
114
|
-
"multistream-select": "^3.0.0",
|
|
132
|
+
"multiformats": "^9.6.3",
|
|
115
133
|
"mutable-proxy": "^1.0.0",
|
|
116
|
-
"nat-api": "^0.3.1",
|
|
117
134
|
"node-forge": "^1.2.1",
|
|
118
|
-
"p-any": "^3.0.0",
|
|
119
135
|
"p-fifo": "^1.0.0",
|
|
120
|
-
"p-retry": "^
|
|
121
|
-
"p-settle": "^
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"protobufjs": "^6.10.2",
|
|
136
|
+
"p-retry": "^5.0.0",
|
|
137
|
+
"p-settle": "^5.0.0",
|
|
138
|
+
"private-ip": "^2.3.3",
|
|
139
|
+
"protons-runtime": "^1.0.4",
|
|
125
140
|
"retimer": "^3.0.0",
|
|
126
141
|
"sanitize-filename": "^1.6.3",
|
|
127
142
|
"set-delayed-interval": "^1.0.0",
|
|
128
|
-
"streaming-iterables": "^6.0.0",
|
|
129
143
|
"timeout-abort-controller": "^3.0.0",
|
|
130
144
|
"uint8arrays": "^3.0.0",
|
|
131
|
-
"varint": "^6.0.0",
|
|
132
145
|
"wherearewe": "^1.0.0",
|
|
133
146
|
"xsalsa20": "^1.1.0"
|
|
134
147
|
},
|
|
135
148
|
"devDependencies": {
|
|
136
|
-
"@chainsafe/libp2p-noise": "^
|
|
149
|
+
"@chainsafe/libp2p-noise": "^6.1.1",
|
|
150
|
+
"@libp2p/bootstrap": "^1.0.4",
|
|
151
|
+
"@libp2p/daemon-client": "^1.0.2",
|
|
152
|
+
"@libp2p/daemon-server": "^1.0.2",
|
|
153
|
+
"@libp2p/delegated-content-routing": "^1.0.2",
|
|
154
|
+
"@libp2p/delegated-peer-routing": "^1.0.2",
|
|
155
|
+
"@libp2p/floodsub": "^1.0.6",
|
|
156
|
+
"@libp2p/interface-compliance-tests": "^1.1.32",
|
|
157
|
+
"@libp2p/interop": "^1.0.3",
|
|
158
|
+
"@libp2p/kad-dht": "^1.0.9",
|
|
159
|
+
"@libp2p/mdns": "^1.0.5",
|
|
160
|
+
"@libp2p/mplex": "^1.0.4",
|
|
161
|
+
"@libp2p/pubsub": "^1.2.18",
|
|
162
|
+
"@libp2p/tcp": "^1.0.9",
|
|
163
|
+
"@libp2p/topology": "^1.1.7",
|
|
164
|
+
"@libp2p/webrtc-star": "^1.0.8",
|
|
165
|
+
"@libp2p/websockets": "^1.0.7",
|
|
137
166
|
"@nodeutils/defaults-deep": "^1.1.0",
|
|
138
|
-
"@types/
|
|
139
|
-
"@types/node": "^16.0.1",
|
|
167
|
+
"@types/node": "^16.11.26",
|
|
140
168
|
"@types/node-forge": "^1.0.0",
|
|
169
|
+
"@types/p-fifo": "^1.0.0",
|
|
141
170
|
"@types/varint": "^6.0.0",
|
|
142
|
-
"
|
|
171
|
+
"@types/xsalsa20": "^1.1.0",
|
|
172
|
+
"aegir": "^37.0.9",
|
|
143
173
|
"buffer": "^6.0.3",
|
|
174
|
+
"cborg": "^1.8.1",
|
|
144
175
|
"delay": "^5.0.0",
|
|
145
|
-
"
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"it-pushable": "^
|
|
150
|
-
"
|
|
151
|
-
"libp2p-bootstrap": "^0.14.0",
|
|
152
|
-
"libp2p-delegated-content-routing": "^0.11.0",
|
|
153
|
-
"libp2p-delegated-peer-routing": "^0.11.1",
|
|
154
|
-
"libp2p-interfaces-compliance-tests": "^4.0.8",
|
|
155
|
-
"libp2p-interop": "^0.7.1",
|
|
156
|
-
"libp2p-kad-dht": "^0.28.6",
|
|
157
|
-
"libp2p-mdns": "^0.18.0",
|
|
158
|
-
"libp2p-mplex": "^0.10.4",
|
|
159
|
-
"libp2p-tcp": "^0.17.0",
|
|
160
|
-
"libp2p-webrtc-star": "^0.25.0",
|
|
161
|
-
"libp2p-websockets": "^0.16.0",
|
|
176
|
+
"execa": "^6.1.0",
|
|
177
|
+
"go-libp2p": "^0.0.6",
|
|
178
|
+
"into-stream": "^7.0.0",
|
|
179
|
+
"ipfs-http-client": "^56.0.1",
|
|
180
|
+
"it-pushable": "^2.0.1",
|
|
181
|
+
"it-to-buffer": "^2.0.2",
|
|
162
182
|
"nock": "^13.0.3",
|
|
163
|
-
"
|
|
164
|
-
"p-
|
|
165
|
-
"p-
|
|
183
|
+
"npm-run-all": "^4.1.5",
|
|
184
|
+
"p-defer": "^4.0.0",
|
|
185
|
+
"p-event": "^5.0.1",
|
|
186
|
+
"p-times": "^4.0.0",
|
|
187
|
+
"p-wait-for": "^4.1.0",
|
|
188
|
+
"protons": "^3.0.4",
|
|
166
189
|
"rimraf": "^3.0.2",
|
|
167
|
-
"sinon": "^
|
|
168
|
-
"
|
|
190
|
+
"sinon": "^13.0.1",
|
|
191
|
+
"ts-sinon": "^2.0.2"
|
|
169
192
|
},
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
|
|
173
|
-
"Jacob Heun <jacobheun@gmail.com>",
|
|
174
|
-
"Alex Potsides <alex@achingbrain.net>",
|
|
175
|
-
"Alan Shaw <alan@tableflip.io>",
|
|
176
|
-
"Cayman <caymannava@gmail.com>",
|
|
177
|
-
"Pedro Teixeira <i@pgte.me>",
|
|
178
|
-
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
|
|
179
|
-
"Maciej Krüger <mkg20001@gmail.com>",
|
|
180
|
-
"Hugo Dias <mail@hugodias.me>",
|
|
181
|
-
"dirkmc <dirkmdev@gmail.com>",
|
|
182
|
-
"Volker Mische <volker.mische@gmail.com>",
|
|
183
|
-
"Chris Dostert <chrisdostert@users.noreply.github.com>",
|
|
184
|
-
"zeim839 <50573884+zeim839@users.noreply.github.com>",
|
|
185
|
-
"Robert Kiel <robert.kiel@hoprnet.org>",
|
|
186
|
-
"Richard Littauer <richard.littauer@gmail.com>",
|
|
187
|
-
"a1300 <matthias-knopp@gmx.net>",
|
|
188
|
-
"Ryan Bell <ryan@piing.net>",
|
|
189
|
-
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>",
|
|
190
|
-
"Andrew Nesbitt <andrewnez@gmail.com>",
|
|
191
|
-
"Franck Royer <franck@royer.one>",
|
|
192
|
-
"Thomas Eizinger <thomas@eizinger.io>",
|
|
193
|
-
"Vít Habada <vithabada93@gmail.com>",
|
|
194
|
-
"Giovanni T. Parra <fiatjaf@gmail.com>",
|
|
195
|
-
"acolytec3 <17355484+acolytec3@users.noreply.github.com>",
|
|
196
|
-
"Alan Smithee <ggnore.alan.smithee@gmail.com>",
|
|
197
|
-
"Elven <mon.samuel@qq.com>",
|
|
198
|
-
"Samlior <samlior@foxmail.com>",
|
|
199
|
-
"Didrik Nordström <didrik.nordstrom@gmail.com>",
|
|
200
|
-
"Aditya Bose <13054902+adbose@users.noreply.github.com>",
|
|
201
|
-
"TJKoury <TJKoury@gmail.com>",
|
|
202
|
-
"TheStarBoys <41286328+TheStarBoys@users.noreply.github.com>",
|
|
203
|
-
"Tiago Alves <alvesjtiago@gmail.com>",
|
|
204
|
-
"Tim Daubenschütz <tim@daubenschuetz.de>",
|
|
205
|
-
"XiaoZhang <zxinmyth@gmail.com>",
|
|
206
|
-
"Yusef Napora <yusef@napora.org>",
|
|
207
|
-
"Zane Starr <zcstarr@gmail.com>",
|
|
208
|
-
"ebinks <elizabethjbinks@gmail.com>",
|
|
209
|
-
"greenSnot <greenSnot@users.noreply.github.com>",
|
|
210
|
-
"isan_rivkin <isanrivkin@gmail.com>",
|
|
211
|
-
"mayerwin <mayerwin@users.noreply.github.com>",
|
|
212
|
-
"mcclure <andi.m.mcclure@gmail.com>",
|
|
213
|
-
"patrickwoodhead <91056047+patrickwoodhead@users.noreply.github.com>",
|
|
214
|
-
"phillmac <phillmac@users.noreply.github.com>",
|
|
215
|
-
"robertkiel <robert.kiel@validitylabs.org>",
|
|
216
|
-
"shresthagrawal <34920931+shresthagrawal@users.noreply.github.com>",
|
|
217
|
-
"swedneck <40505480+swedneck@users.noreply.github.com>",
|
|
218
|
-
"tuyennhv <vutuyen2636@gmail.com>",
|
|
219
|
-
"Sönke Hahn <soenkehahn@gmail.com>",
|
|
220
|
-
"Aleksei <vozhdb@gmail.com>",
|
|
221
|
-
"Bernd Strehl <bernd.strehl@gmail.com>",
|
|
222
|
-
"Chris Bratlien <chrisbratlien@gmail.com>",
|
|
223
|
-
"Cindy Wu <ciindy.wu@gmail.com>",
|
|
224
|
-
"Daijiro Wachi <daijiro.wachi@gmail.com>",
|
|
225
|
-
"Diogo Silva <fsdiogo@gmail.com>",
|
|
226
|
-
"Dmitriy Ryajov <dryajov@gmail.com>",
|
|
227
|
-
"Ethan Lam <elmemphis2000@gmail.com>",
|
|
228
|
-
"Fei Liu <liu.feiwood@gmail.com>",
|
|
229
|
-
"Felipe Martins <felipebrasil93@gmail.com>",
|
|
230
|
-
"Florian-Merle <florian.david.merle@gmail.com>",
|
|
231
|
-
"Francis Gulotta <wizard@roborooter.com>",
|
|
232
|
-
"Guy Sviry <32539816+guysv@users.noreply.github.com>",
|
|
233
|
-
"Henrique Dias <hacdias@gmail.com>",
|
|
234
|
-
"Irakli Gozalishvili <rfobic@gmail.com>",
|
|
235
|
-
"Joel Gustafson <joelg@mit.edu>",
|
|
236
|
-
"John Rees <johnrees@users.noreply.github.com>",
|
|
237
|
-
"João Santos <joaosantos15@users.noreply.github.com>",
|
|
238
|
-
"Julien Bouquillon <contact@revolunet.com>",
|
|
239
|
-
"Kevin Kwok <antimatter15@gmail.com>",
|
|
240
|
-
"Kevin Lacker <lacker@gmail.com>",
|
|
241
|
-
"Lars Gierth <lgierth@users.noreply.github.com>",
|
|
242
|
-
"Leask Wong <i@leaskh.com>",
|
|
243
|
-
"Marcin Tojek <mtojek@users.noreply.github.com>",
|
|
244
|
-
"Marston Connell <34043723+TheMarstonConnell@users.noreply.github.com>",
|
|
245
|
-
"Michael Burns <5170+mburns@users.noreply.github.com>",
|
|
246
|
-
"Miguel Mota <miguelmota2@gmail.com>",
|
|
247
|
-
"Nuno Nogueira <nunofmn@gmail.com>",
|
|
248
|
-
"Philipp Muens <raute1337@gmx.de>",
|
|
249
|
-
"RasmusErik Voel Jensen <github@solsort.com>",
|
|
250
|
-
"Smite Chow <xiaopengyou@live.com>",
|
|
251
|
-
"Soeren <nikorpoulsen@gmail.com>"
|
|
252
|
-
]
|
|
193
|
+
"browser": {
|
|
194
|
+
"nat-api": false
|
|
195
|
+
}
|
|
253
196
|
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { AddressManagerEvents } from '@libp2p/interfaces/address-manager'
|
|
2
|
+
import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events'
|
|
3
|
+
import { Multiaddr } from '@multiformats/multiaddr'
|
|
4
|
+
import { peerIdFromString } from '@libp2p/peer-id'
|
|
5
|
+
import type { Components } from '@libp2p/interfaces/components'
|
|
6
|
+
|
|
7
|
+
export interface AddressManagerInit {
|
|
8
|
+
announceFilter?: AddressFilter
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* list of multiaddrs string representation to listen
|
|
12
|
+
*/
|
|
13
|
+
listen?: string[]
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* list of multiaddrs string representation to announce
|
|
17
|
+
*/
|
|
18
|
+
announce?: string[]
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* list of multiaddrs string representation to never announce
|
|
22
|
+
*/
|
|
23
|
+
noAnnounce?: string[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface AddressFilter {
|
|
27
|
+
(addrs: Multiaddr[]): Multiaddr[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const defaultAddressFilter = (addrs: Multiaddr[]): Multiaddr[] => addrs
|
|
31
|
+
|
|
32
|
+
export class DefaultAddressManager extends EventEmitter<AddressManagerEvents> {
|
|
33
|
+
private readonly components: Components
|
|
34
|
+
private readonly listen: Set<string>
|
|
35
|
+
private readonly announce: Set<string>
|
|
36
|
+
private readonly observed: Set<string>
|
|
37
|
+
private readonly announceFilter: AddressFilter
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Responsible for managing the peer addresses.
|
|
41
|
+
* Peers can specify their listen and announce addresses.
|
|
42
|
+
* The listen addresses will be used by the libp2p transports to listen for new connections,
|
|
43
|
+
* while the announce addresses will be used for the peer addresses' to other peers in the network.
|
|
44
|
+
*/
|
|
45
|
+
constructor (components: Components, init: AddressManagerInit) {
|
|
46
|
+
super()
|
|
47
|
+
|
|
48
|
+
const { listen = [], announce = [] } = init
|
|
49
|
+
|
|
50
|
+
this.components = components
|
|
51
|
+
this.listen = new Set(listen.map(ma => ma.toString()))
|
|
52
|
+
this.announce = new Set(announce.map(ma => ma.toString()))
|
|
53
|
+
this.observed = new Set()
|
|
54
|
+
this.announceFilter = init.announceFilter ?? defaultAddressFilter
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get peer listen multiaddrs
|
|
59
|
+
*/
|
|
60
|
+
getListenAddrs (): Multiaddr[] {
|
|
61
|
+
return Array.from(this.listen).map((a) => new Multiaddr(a))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get peer announcing multiaddrs
|
|
66
|
+
*/
|
|
67
|
+
getAnnounceAddrs (): Multiaddr[] {
|
|
68
|
+
return Array.from(this.announce).map((a) => new Multiaddr(a))
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get observed multiaddrs
|
|
73
|
+
*/
|
|
74
|
+
getObservedAddrs (): Multiaddr[] {
|
|
75
|
+
return Array.from(this.observed).map((a) => new Multiaddr(a))
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Add peer observed addresses
|
|
80
|
+
*/
|
|
81
|
+
addObservedAddr (addr: string | Multiaddr): void {
|
|
82
|
+
let ma = new Multiaddr(addr)
|
|
83
|
+
const remotePeer = ma.getPeerId()
|
|
84
|
+
|
|
85
|
+
// strip our peer id if it has been passed
|
|
86
|
+
if (remotePeer != null) {
|
|
87
|
+
const remotePeerId = peerIdFromString(remotePeer)
|
|
88
|
+
|
|
89
|
+
// use same encoding for comparison
|
|
90
|
+
if (remotePeerId.equals(this.components.getPeerId())) {
|
|
91
|
+
ma = ma.decapsulate(new Multiaddr(`/p2p/${this.components.getPeerId().toString()}`))
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const addrString = ma.toString()
|
|
96
|
+
|
|
97
|
+
// do not trigger the change:addresses event if we already know about this address
|
|
98
|
+
if (this.observed.has(addrString)) {
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
this.observed.add(addrString)
|
|
103
|
+
this.dispatchEvent(new CustomEvent('change:addresses'))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
getAddresses (): Multiaddr[] {
|
|
107
|
+
let addrs = this.getAnnounceAddrs().map(ma => ma.toString())
|
|
108
|
+
|
|
109
|
+
if (addrs.length === 0) {
|
|
110
|
+
// no configured announce addrs, add configured listen addresses
|
|
111
|
+
addrs = this.components.getTransportManager().getAddrs().map(ma => ma.toString())
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
addrs = addrs.concat(this.getObservedAddrs().map(ma => ma.toString()))
|
|
115
|
+
|
|
116
|
+
// dedupe multiaddrs
|
|
117
|
+
const addrSet = new Set(addrs)
|
|
118
|
+
|
|
119
|
+
// Create advertising list
|
|
120
|
+
return this.announceFilter(Array.from(addrSet)
|
|
121
|
+
.map(str => new Multiaddr(str)))
|
|
122
|
+
.map(ma => {
|
|
123
|
+
if (ma.getPeerId() === this.components.getPeerId().toString()) {
|
|
124
|
+
return ma
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return ma.encapsulate(`/p2p/${this.components.getPeerId().toString()}`)
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
}
|
package/src/circuit/README.md
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
## Table of Contents
|
|
10
10
|
|
|
11
11
|
- [js-libp2p-circuit](#js-libp2p-circuit)
|
|
12
|
+
- [Table of Contents](#table-of-contents)
|
|
12
13
|
- [Why?](#why)
|
|
13
14
|
- [libp2p-circuit and IPFS](#libp2p-circuit-and-ipfs)
|
|
14
|
-
- [Table of Contents](#table-of-contents)
|
|
15
15
|
- [Usage](#usage)
|
|
16
16
|
- [API](#api)
|
|
17
17
|
- [Implementation rational](#implementation-rational)
|
|
@@ -37,22 +37,27 @@ Libp2p circuit configuration can be seen at [Setup with Relay](../../doc/CONFIGU
|
|
|
37
37
|
Once you have a circuit relay node running, you can configure other nodes to use it as a relay as follows:
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
import { Multiaddr } from '@multiformats/multiaddr'
|
|
41
|
+
import Libp2p from 'libp2p'
|
|
42
|
+
import { TCP } from '@libp2p/tcp'
|
|
43
|
+
import { Mplex } from '@libp2p/mplex'
|
|
44
|
+
import { NOISE } from '@chainsafe/libp2p-noise'
|
|
45
45
|
|
|
46
46
|
const relayAddr = ...
|
|
47
47
|
|
|
48
|
-
const node = await
|
|
48
|
+
const node = await createLibp2p({
|
|
49
49
|
addresses: {
|
|
50
50
|
listen: [new Multiaddr(`${relayAddr}/p2p-circuit`)]
|
|
51
51
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
transports: [
|
|
53
|
+
new TCP()
|
|
54
|
+
],
|
|
55
|
+
streamMuxers: [
|
|
56
|
+
new Mplex()
|
|
57
|
+
],
|
|
58
|
+
connectionEncryption: [
|
|
59
|
+
NOISE
|
|
60
|
+
]
|
|
56
61
|
},
|
|
57
62
|
config: {
|
|
58
63
|
relay: { // Circuit Relay options (this config is part of libp2p core configurations)
|