From 656b14914d09036bebd3bbff2aaf8ade971bb0eb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 28 Nov 2023 16:37:03 +0000 Subject: [PATCH] chore: release main (#2240) * chore: add contents permission to gh token * chore: update token perms * chore: update token perms * chore: release main --------- Co-authored-by: achingbrain Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .github/workflows/main.yml | 1 + .release-please-manifest.json | 2 +- doc/migrations/v0.46-v1.0.0.md | 153 ++++++++++++------ doc/package.json | 10 +- interop/CHANGELOG.md | 32 +++- interop/package.json | 20 +-- interop/test/ping.spec.ts | 4 + .../CHANGELOG.md | 38 +++++ .../package.json | 12 +- .../src/index.ts | 7 +- .../test/index.spec.ts | 5 +- packages/crypto/CHANGELOG.md | 30 +++- packages/crypto/package.json | 4 +- packages/crypto/src/aes/cipher-mode.ts | 2 +- packages/crypto/src/keys/ecdh-browser.ts | 2 +- packages/crypto/src/keys/ecdh.ts | 2 +- packages/crypto/src/keys/ed25519-class.ts | 2 +- packages/crypto/src/keys/index.ts | 4 +- packages/crypto/src/keys/key-stretcher.ts | 2 +- packages/crypto/src/keys/rsa-browser.ts | 2 +- packages/crypto/src/keys/rsa-class.ts | 2 +- packages/crypto/src/keys/rsa-utils.ts | 2 +- packages/crypto/src/keys/rsa.ts | 2 +- packages/crypto/src/keys/secp256k1-browser.ts | 2 +- packages/crypto/src/keys/secp256k1-class.ts | 2 +- packages/crypto/src/keys/secp256k1.ts | 2 +- packages/crypto/src/pbkdf2.ts | 2 +- packages/crypto/src/random-bytes.ts | 2 +- packages/integration-tests/package.json | 32 ++-- .../test/circuit-relay-discovery.node.ts | 3 + .../test/circuit-relay.node.ts | 7 +- .../test/circuit-relay.spec.ts | 6 +- packages/integration-tests/test/fetch.spec.ts | 2 +- .../integration-tests/test/fixtures/utils.ts | 7 +- .../interface-compliance-tests/CHANGELOG.md | 41 ++++- .../interface-compliance-tests/package.json | 18 +-- .../src/connection-encryption/index.ts | 5 +- .../src/connection-encryption/utils/index.ts | 2 +- .../src/connection/index.ts | 2 +- .../src/mocks/connection-gater.ts | 2 +- .../src/mocks/connection-manager.ts | 12 +- .../src/mocks/connection.ts | 9 +- .../src/mocks/metrics.ts | 3 +- .../src/mocks/multiaddr-connection.ts | 3 +- .../src/mocks/muxer.ts | 4 +- .../src/mocks/peer-discovery.ts | 8 +- .../src/mocks/registrar.ts | 6 +- .../src/mocks/upgrader.ts | 7 +- .../src/peer-discovery/index.ts | 4 +- .../src/pubsub/api.ts | 4 +- .../src/pubsub/connection-handlers.ts | 4 +- .../src/pubsub/emit-self.ts | 4 +- .../src/pubsub/index.ts | 7 +- .../src/pubsub/messages.ts | 4 +- .../src/pubsub/multiple-nodes.ts | 4 +- .../src/pubsub/two-nodes.ts | 5 +- .../src/pubsub/utils.ts | 5 +- .../src/stream-muxer/base-test.ts | 3 +- .../src/stream-muxer/close-test.ts | 2 +- .../src/stream-muxer/index.ts | 2 +- .../src/stream-muxer/mega-stress-test.ts | 2 +- .../src/stream-muxer/spawner.ts | 2 +- .../src/stream-muxer/stress-test.ts | 2 +- .../src/transport/dial-test.ts | 7 +- .../src/transport/filter-test.ts | 2 +- .../src/transport/index.ts | 2 +- .../src/transport/listen-test.ts | 7 +- .../test/mocks/connection.spec.ts | 2 +- packages/interface-internal/CHANGELOG.md | 10 ++ packages/interface-internal/package.json | 26 +-- .../src/connection-manager/index.ts | 4 +- packages/interface-internal/src/index.ts | 6 +- .../interface-internal/src/record/index.ts | 2 +- .../interface-internal/src/registrar/index.ts | 3 +- .../src/transport-manager/index.ts | 3 +- packages/interface-internal/typedoc.json | 7 +- packages/interface/CHANGELOG.md | 39 +++++ packages/interface/README.md | 14 ++ packages/interface/package.json | 16 +- packages/interface/src/connection/index.ts | 4 +- .../interface/src/content-routing/index.ts | 2 +- packages/interface/src/errors.ts | 32 ++-- packages/interface/src/index.ts | 22 +++ .../interface/src/peer-discovery/index.ts | 2 +- packages/interface/src/peer-id/index.ts | 4 +- packages/interface/src/peer-routing/index.ts | 2 +- packages/interface/src/startable.ts | 8 + packages/interface/src/transport/index.ts | 6 +- packages/interface/typedoc.json | 25 +-- packages/kad-dht/CHANGELOG.md | 30 +++- packages/kad-dht/package.json | 22 +-- .../kad-dht/src/content-fetching/index.ts | 2 +- packages/kad-dht/src/content-routing/index.ts | 3 +- packages/kad-dht/src/dual-kad-dht.ts | 16 +- packages/kad-dht/src/index.ts | 11 +- packages/kad-dht/src/kad-dht.ts | 7 +- packages/kad-dht/src/message/index.ts | 2 +- packages/kad-dht/src/network.ts | 8 +- packages/kad-dht/src/peer-list/index.ts | 2 +- .../src/peer-list/peer-distance-list.ts | 2 +- packages/kad-dht/src/peer-routing/index.ts | 6 +- packages/kad-dht/src/providers.ts | 4 +- packages/kad-dht/src/query-self.ts | 6 +- packages/kad-dht/src/query/events.ts | 5 +- packages/kad-dht/src/query/manager.ts | 8 +- packages/kad-dht/src/query/query-path.ts | 4 +- packages/kad-dht/src/query/types.ts | 2 +- packages/kad-dht/src/query/utils.ts | 5 +- packages/kad-dht/src/record/selectors.ts | 2 +- packages/kad-dht/src/record/validators.ts | 2 +- packages/kad-dht/src/routing-table/index.ts | 10 +- .../kad-dht/src/routing-table/k-bucket.ts | 4 +- packages/kad-dht/src/routing-table/refresh.ts | 3 +- .../kad-dht/src/rpc/handlers/add-provider.ts | 5 +- .../kad-dht/src/rpc/handlers/find-node.ts | 6 +- .../kad-dht/src/rpc/handlers/get-providers.ts | 7 +- .../kad-dht/src/rpc/handlers/get-value.ts | 6 +- packages/kad-dht/src/rpc/handlers/ping.ts | 3 +- .../kad-dht/src/rpc/handlers/put-value.ts | 5 +- packages/kad-dht/src/rpc/index.ts | 5 +- packages/kad-dht/src/topology-listener.ts | 6 +- packages/kad-dht/src/utils.ts | 3 +- .../generate-peers/generate-peers.node.ts | 6 +- packages/kad-dht/test/kad-dht.spec.ts | 4 +- packages/kad-dht/test/message.node.ts | 2 +- packages/kad-dht/test/network.spec.ts | 3 +- packages/kad-dht/test/peer-list.spec.ts | 2 +- packages/kad-dht/test/providers.spec.ts | 2 +- packages/kad-dht/test/query-self.spec.ts | 6 +- packages/kad-dht/test/query.spec.ts | 4 +- packages/kad-dht/test/query/utils.spec.ts | 2 +- packages/kad-dht/test/routing-table.spec.ts | 11 +- .../test/rpc/handlers/add-provider.spec.ts | 2 +- .../test/rpc/handlers/find-node.spec.ts | 8 +- .../test/rpc/handlers/get-providers.spec.ts | 7 +- .../test/rpc/handlers/get-value.spec.ts | 6 +- .../kad-dht/test/rpc/handlers/ping.spec.ts | 2 +- .../test/rpc/handlers/put-value.spec.ts | 2 +- packages/kad-dht/test/rpc/index.node.ts | 12 +- packages/kad-dht/test/utils/create-peer-id.ts | 2 +- packages/kad-dht/test/utils/index.ts | 2 +- .../kad-dht/test/utils/sort-closest-peers.ts | 2 +- packages/kad-dht/test/utils/test-dht.ts | 13 +- packages/keychain/CHANGELOG.md | 30 +++- packages/keychain/package.json | 12 +- packages/keychain/src/index.ts | 4 +- packages/keychain/src/keychain.ts | 6 +- packages/keychain/test/keychain.spec.ts | 2 +- packages/keychain/test/peerid.spec.ts | 2 +- packages/libp2p/CHANGELOG.md | 78 ++++++++- packages/libp2p/README.md | 87 +++++----- packages/libp2p/package.json | 44 ++--- packages/libp2p/src/address-manager/index.ts | 7 +- packages/libp2p/src/components.ts | 19 +-- packages/libp2p/src/config.ts | 3 +- .../src/config/connection-gater.browser.ts | 2 +- .../libp2p/src/config/connection-gater.ts | 2 +- .../src/connection-manager/auto-dial.ts | 7 +- .../connection-manager/connection-pruner.ts | 6 +- .../src/connection-manager/dial-queue.ts | 12 +- .../libp2p/src/connection-manager/index.ts | 14 +- .../libp2p/src/connection-manager/utils.ts | 2 +- packages/libp2p/src/connection/index.ts | 10 +- packages/libp2p/src/content-routing/index.ts | 8 +- packages/libp2p/src/content-routing/utils.ts | 5 +- packages/libp2p/src/get-peer.ts | 5 +- packages/libp2p/src/index.ts | 12 +- packages/libp2p/src/libp2p.ts | 28 ++-- packages/libp2p/src/peer-routing.ts | 8 +- packages/libp2p/src/registrar.ts | 11 +- packages/libp2p/src/transport-manager.ts | 15 +- packages/libp2p/src/upgrader.ts | 17 +- .../test/addresses/address-manager.spec.ts | 7 +- .../test/connection-manager/auto-dial.spec.ts | 8 +- .../connection-manager/dial-queue.spec.ts | 9 +- .../test/connection-manager/direct.node.ts | 19 ++- .../test/connection-manager/direct.spec.ts | 14 +- .../test/connection-manager/index.node.ts | 9 +- .../test/connection-manager/index.spec.ts | 10 +- .../test/connection-manager/resolver.spec.ts | 5 +- .../libp2p/test/connection/compliance.spec.ts | 2 +- .../content-routing/content-routing.node.ts | 3 +- .../content-routing/dht/operation.node.ts | 5 +- packages/libp2p/test/core/encryption.spec.ts | 2 +- packages/libp2p/test/core/listening.node.ts | 2 +- packages/libp2p/test/fixtures/base-options.ts | 1 + .../libp2p/test/fixtures/creators/peer.ts | 3 +- packages/libp2p/test/fixtures/echo-service.ts | 4 +- .../libp2p/test/fixtures/match-peer-id.ts | 2 +- packages/libp2p/test/interop.ts | 21 ++- .../libp2p/test/peer-discovery/index.node.ts | 9 +- .../libp2p/test/peer-discovery/index.spec.ts | 4 +- .../test/peer-routing/peer-routing.node.ts | 5 +- .../libp2p/test/registrar/registrar.spec.ts | 12 +- .../test/transports/transport-manager.node.ts | 6 +- .../test/transports/transport-manager.spec.ts | 7 +- .../libp2p/test/upgrading/upgrader.spec.ts | 23 ++- packages/logger/CHANGELOG.md | 22 +++ packages/logger/package.json | 6 +- packages/logger/src/index.ts | 2 +- packages/logger/src/utils.ts | 2 +- packages/metrics-prometheus/CHANGELOG.md | 29 +++- packages/metrics-prometheus/package.json | 10 +- .../metrics-prometheus/src/counter-group.ts | 2 +- packages/metrics-prometheus/src/counter.ts | 2 +- packages/metrics-prometheus/src/index.ts | 4 +- .../metrics-prometheus/src/metric-group.ts | 2 +- packages/metrics-prometheus/src/metric.ts | 2 +- packages/metrics-prometheus/src/utils.ts | 2 +- .../metrics-prometheus/test/streams.spec.ts | 2 +- packages/multistream-select/CHANGELOG.md | 20 ++- packages/multistream-select/package.json | 6 +- .../multistream-select/src/multistream.ts | 2 +- packages/multistream-select/src/select.ts | 2 +- packages/peer-collections/CHANGELOG.md | 12 ++ packages/peer-collections/package.json | 8 +- packages/peer-collections/src/list.ts | 2 +- packages/peer-collections/src/map.ts | 2 +- packages/peer-collections/src/set.ts | 2 +- packages/peer-collections/test/set.spec.ts | 2 +- .../peer-discovery-bootstrap/CHANGELOG.md | 25 ++- .../peer-discovery-bootstrap/package.json | 10 +- .../peer-discovery-bootstrap/src/index.ts | 13 +- .../test/bootstrap.spec.ts | 5 +- .../test/compliance.spec.ts | 2 +- packages/peer-discovery-mdns/CHANGELOG.md | 36 ++++- packages/peer-discovery-mdns/package.json | 18 +-- packages/peer-discovery-mdns/src/index.ts | 19 ++- packages/peer-discovery-mdns/src/mdns.ts | 25 +-- packages/peer-discovery-mdns/src/query.ts | 3 +- .../test/compliance.spec.ts | 6 +- .../test/multicast-dns.spec.ts | 11 +- packages/peer-id-factory/CHANGELOG.md | 11 ++ packages/peer-id-factory/package.json | 8 +- packages/peer-id-factory/src/index.ts | 3 +- packages/peer-id/CHANGELOG.md | 20 ++- packages/peer-id/package.json | 4 +- packages/peer-id/src/index.ts | 10 +- packages/peer-record/CHANGELOG.md | 14 ++ packages/peer-record/package.json | 12 +- packages/peer-record/src/envelope/index.ts | 5 +- packages/peer-record/src/peer-record/index.ts | 2 +- packages/peer-record/test/envelope.spec.ts | 3 +- packages/peer-record/test/peer-record.spec.ts | 2 +- packages/peer-store/CHANGELOG.md | 22 ++- packages/peer-store/package.json | 14 +- packages/peer-store/src/index.ts | 5 +- packages/peer-store/src/store.ts | 6 +- .../peer-store/src/utils/bytes-to-peer.ts | 3 +- .../peer-store/src/utils/dedupe-addresses.ts | 5 +- .../src/utils/peer-data-to-datastore-peer.ts | 5 +- .../src/utils/peer-id-to-datastore-key.ts | 4 +- packages/peer-store/src/utils/to-peer-pb.ts | 5 +- packages/peer-store/test/index.spec.ts | 4 +- packages/peer-store/test/merge.spec.ts | 5 +- packages/peer-store/test/patch.spec.ts | 5 +- packages/peer-store/test/save.spec.ts | 5 +- .../test/utils/dedupe-addresses.spec.ts | 2 +- packages/pnet/package.json | 10 +- packages/pnet/src/index.ts | 5 +- packages/protocol-autonat/CHANGELOG.md | 32 ++++ packages/protocol-autonat/package.json | 12 +- packages/protocol-autonat/src/autonat.ts | 11 +- packages/protocol-autonat/src/index.ts | 9 +- packages/protocol-autonat/test/index.spec.ts | 13 +- packages/protocol-dcutr/CHANGELOG.md | 28 ++++ packages/protocol-dcutr/package.json | 6 +- packages/protocol-dcutr/src/dcutr.ts | 12 +- packages/protocol-dcutr/src/index.ts | 8 +- packages/protocol-dcutr/src/utils.ts | 2 +- packages/protocol-dcutr/test/utils.spec.ts | 4 +- packages/protocol-fetch/CHANGELOG.md | 29 ++++ packages/protocol-fetch/package.json | 10 +- packages/protocol-fetch/src/fetch.ts | 10 +- packages/protocol-fetch/src/index.ts | 6 +- packages/protocol-fetch/test/index.spec.ts | 10 +- packages/protocol-identify/CHANGELOG.md | 33 ++++ packages/protocol-identify/package.json | 14 +- packages/protocol-identify/src/identify.ts | 14 +- packages/protocol-identify/src/index.ts | 9 +- .../protocol-identify/test/fixtures/index.ts | 9 +- packages/protocol-identify/test/index.spec.ts | 10 +- packages/protocol-identify/test/push.spec.ts | 10 +- packages/protocol-perf/CHANGELOG.md | 29 ++++ packages/protocol-perf/package.json | 10 +- packages/protocol-perf/src/index.ts | 3 +- packages/protocol-perf/src/perf-service.ts | 5 +- packages/protocol-perf/test/index.spec.ts | 8 +- packages/protocol-ping/CHANGELOG.md | 34 ++++ packages/protocol-ping/package.json | 12 +- packages/protocol-ping/src/index.ts | 6 +- packages/protocol-ping/src/ping.ts | 9 +- packages/protocol-ping/test/index.spec.ts | 9 +- packages/pubsub-floodsub/CHANGELOG.md | 22 ++- packages/pubsub-floodsub/package.json | 14 +- packages/pubsub-floodsub/src/index.ts | 5 +- .../pubsub-floodsub/test/floodsub.spec.ts | 2 +- packages/pubsub/CHANGELOG.md | 24 ++- packages/pubsub/package.json | 18 +-- packages/pubsub/src/index.ts | 10 +- packages/pubsub/src/peer-streams.ts | 7 +- packages/pubsub/src/sign.ts | 3 +- packages/pubsub/src/utils.ts | 4 +- packages/pubsub/test/instance.spec.ts | 2 +- packages/pubsub/test/lifecycle.spec.ts | 5 +- packages/pubsub/test/message.spec.ts | 3 +- packages/pubsub/test/pubsub.spec.ts | 3 +- packages/pubsub/test/sign.spec.ts | 3 +- packages/pubsub/test/topic-validators.spec.ts | 3 +- packages/pubsub/test/utils.spec.ts | 2 +- packages/pubsub/test/utils/index.ts | 7 +- .../stream-multiplexer-mplex/CHANGELOG.md | 29 +++- .../stream-multiplexer-mplex/package.json | 10 +- .../stream-multiplexer-mplex/src/index.ts | 8 +- .../stream-multiplexer-mplex/src/mplex.ts | 14 +- .../transport-circuit-relay-v2/CHANGELOG.md | 35 ++++ .../transport-circuit-relay-v2/package.json | 20 +-- .../transport-circuit-relay-v2/src/index.ts | 6 +- .../src/server/advert-service.ts | 6 +- .../src/server/index.ts | 13 +- .../src/server/reservation-store.ts | 4 +- .../src/server/reservation-voucher.ts | 3 +- .../src/transport/discovery.ts | 12 +- .../src/transport/index.ts | 12 +- .../src/transport/listener.ts | 9 +- .../src/transport/reservation-store.ts | 10 +- .../src/transport/transport.ts | 16 +- .../transport-circuit-relay-v2/src/utils.ts | 5 +- .../test/hop.spec.ts | 16 +- .../test/stop.spec.ts | 16 +- .../transport-circuit-relay-v2/test/utils.ts | 7 +- packages/transport-tcp/CHANGELOG.md | 28 ++++ packages/transport-tcp/package.json | 10 +- packages/transport-tcp/src/index.ts | 15 +- packages/transport-tcp/src/listener.ts | 8 +- packages/transport-tcp/src/socket-to-conn.ts | 6 +- .../test/connection-limits.spec.ts | 2 +- .../transport-tcp/test/connection.spec.ts | 5 +- packages/transport-tcp/test/filter.spec.ts | 2 +- .../transport-tcp/test/listen-dial.spec.ts | 5 +- .../test/max-connections.spec.ts | 2 +- packages/transport-webrtc/CHANGELOG.md | 42 ++++- packages/transport-webrtc/package.json | 22 +-- packages/transport-webrtc/src/error.ts | 4 +- packages/transport-webrtc/src/index.ts | 37 ++++- packages/transport-webrtc/src/maconn.ts | 4 +- packages/transport-webrtc/src/muxer.ts | 5 +- .../private-to-private/initiate-connection.ts | 9 +- .../src/private-to-private/listener.ts | 7 +- .../signaling-stream-handler.ts | 4 +- .../src/private-to-private/transport.ts | 38 +---- .../src/private-to-private/util.ts | 5 +- .../src/private-to-public/options.ts | 2 +- .../src/private-to-public/transport.ts | 34 ++-- packages/transport-webrtc/src/stream.ts | 5 +- packages/transport-webrtc/test/basics.spec.ts | 6 +- .../transport-webrtc/test/listener.spec.ts | 4 +- packages/transport-webrtc/test/maconn.spec.ts | 2 +- packages/transport-webrtc/test/peer.spec.ts | 6 +- packages/transport-webrtc/test/stream.spec.ts | 2 +- .../transport-webrtc/test/transport.spec.ts | 8 +- packages/transport-websockets/CHANGELOG.md | 27 ++++ packages/transport-websockets/package.json | 10 +- packages/transport-websockets/src/index.ts | 10 +- .../src/listener.browser.ts | 2 +- packages/transport-websockets/src/listener.ts | 6 +- .../src/socket-to-conn.ts | 5 +- packages/transport-websockets/test/browser.ts | 5 +- .../test/compliance.node.ts | 2 +- packages/transport-websockets/test/node.ts | 4 +- packages/transport-webtransport/CHANGELOG.md | 30 +++- packages/transport-webtransport/package.json | 12 +- packages/transport-webtransport/src/index.ts | 12 +- packages/transport-webtransport/src/stream.ts | 3 +- .../src/utils/parse-multiaddr.ts | 4 +- .../transport-webtransport/test/browser.ts | 1 + packages/upnp-nat/CHANGELOG.md | 32 ++++ packages/upnp-nat/package.json | 12 +- packages/upnp-nat/src/index.ts | 6 +- packages/upnp-nat/src/upnp-nat.ts | 5 +- packages/upnp-nat/test/index.spec.ts | 9 +- packages/utils/CHANGELOG.md | 36 ++++- packages/utils/package.json | 12 +- packages/utils/src/abstract-stream.ts | 5 +- packages/utils/src/address-sort.ts | 2 +- packages/utils/src/ip-port-to-multiaddr.ts | 2 +- packages/utils/src/peer-job-queue.ts | 4 +- packages/utils/src/stream-to-ma-conn.ts | 3 +- .../src/metrics => utils/src}/tracked-map.ts | 2 +- packages/utils/test/stream-to-ma-conn.spec.ts | 2 +- .../test}/tracked-map.spec.ts | 4 +- run-client.ts | 61 ------- run-server.ts | 39 ----- run.ts | 147 ----------------- 394 files changed, 2152 insertions(+), 1826 deletions(-) create mode 100644 packages/connection-encrypter-plaintext/CHANGELOG.md create mode 100644 packages/protocol-autonat/CHANGELOG.md create mode 100644 packages/protocol-dcutr/CHANGELOG.md create mode 100644 packages/protocol-fetch/CHANGELOG.md create mode 100644 packages/protocol-identify/CHANGELOG.md create mode 100644 packages/protocol-ping/CHANGELOG.md create mode 100644 packages/transport-circuit-relay-v2/CHANGELOG.md create mode 100644 packages/upnp-nat/CHANGELOG.md rename packages/{interface/src/metrics => utils/src}/tracked-map.ts (95%) rename packages/{interface/test/metrics => utils/test}/tracked-map.spec.ts (94%) delete mode 100644 run-client.ts delete mode 100644 run-server.ts delete mode 100644 run.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 813783eb23..651a9c1b9f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -222,6 +222,7 @@ jobs: permissions: id-token: write contents: write + pull-requests: write steps: - uses: GoogleCloudPlatform/release-please-action@v2 id: release diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e0d71509d9..3d18c14d7f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{"interop":"1.0.14","packages/crypto":"2.0.8","packages/interface":"0.1.6","packages/interface-compliance-tests":"4.1.5","packages/interface-internal":"0.1.9","packages/kad-dht":"10.0.15","packages/keychain":"3.0.8","packages/libp2p":"0.46.21","packages/logger":"3.1.0","packages/metrics-prometheus":"2.0.12","packages/multistream-select":"4.0.6","packages/peer-collections":"4.0.8","packages/peer-discovery-bootstrap":"9.0.12","packages/peer-discovery-mdns":"9.0.14","packages/peer-id":"3.0.6","packages/peer-id-factory":"3.0.8","packages/peer-record":"6.0.9","packages/peer-store":"9.0.9","packages/protocol-perf":"2.0.1","packages/pubsub":"8.0.10","packages/pubsub-floodsub":"8.0.13","packages/stream-multiplexer-mplex":"9.0.12","packages/transport-tcp":"8.0.13","packages/transport-webrtc":"3.2.11","packages/transport-websockets":"7.0.13","packages/transport-webtransport":"3.1.10","packages/utils":"4.0.7"} \ No newline at end of file +{"interop":"2.0.0","packages/connection-encrypter-plaintext":"1.0.0","packages/crypto":"3.0.0","packages/interface":"1.0.0","packages/interface-compliance-tests":"5.0.0","packages/interface-internal":"0.1.10","packages/kad-dht":"11.0.0","packages/keychain":"4.0.0","packages/libp2p":"1.0.0","packages/logger":"4.0.0","packages/metrics-prometheus":"3.0.0","packages/multistream-select":"4.0.7","packages/peer-collections":"4.0.9","packages/peer-discovery-bootstrap":"10.0.0","packages/peer-discovery-mdns":"10.0.0","packages/peer-id":"4.0.0","packages/peer-id-factory":"3.0.9","packages/peer-record":"6.0.10","packages/peer-store":"9.0.10","packages/protocol-autonat":"1.0.0","packages/protocol-dcutr":"1.0.0","packages/protocol-fetch":"1.0.0","packages/protocol-identify":"1.0.0","packages/protocol-perf":"3.0.0","packages/protocol-ping":"1.0.0","packages/pubsub":"8.0.11","packages/pubsub-floodsub":"8.0.14","packages/stream-multiplexer-mplex":"10.0.0","packages/transport-circuit-relay-v2":"1.0.0","packages/transport-tcp":"9.0.0","packages/transport-webrtc":"4.0.0","packages/transport-websockets":"8.0.0","packages/transport-webtransport":"4.0.0","packages/upnp-nat":"1.0.0","packages/utils":"5.0.0"} \ No newline at end of file diff --git a/doc/migrations/v0.46-v1.0.0.md b/doc/migrations/v0.46-v1.0.0.md index 021e33afb1..d8070d49b9 100644 --- a/doc/migrations/v0.46-v1.0.0.md +++ b/doc/migrations/v0.46-v1.0.0.md @@ -5,20 +5,56 @@ A migration guide for refactoring your application code from libp2p `v0.46` to ` ## Table of Contents -- [AutoNAT](#autonat) -- [Ping](#ping) -- [Identify](#identify) -- [DCUtR](#dcutr) -- [Fetch](#fetch) -- [KeyChain](#keychain) -- [UPnPNat](#upnpnat) -- [Perf](#perf) -- [Plaintext](#plaintext) -- [Pnet](#pnet) +- [Type imports](#type-imports) +- [Extracted modules](#extracted-modules) + - [Services](#services) + - [AutoNAT](#autonat) + - [Ping](#ping) + - [Identify](#identify) + - [DCUtR](#dcutr) + - [Fetch](#fetch) + - [UPnPNat](#upnpnat) + - [Perf](#perf) + - [Connection encryption](#connection-encryption) + - [Plaintext](#plaintext) + - [Misc](#misc) + - [KeyChain](#keychain) + - [Pnet](#pnet) - [Metrics](#metrics) - [Connection Manager](#connection-manager) -## AutoNAT +## Type imports + +All exports from `@libp2p/interface` and `@libp2p/interface-internal` are +now exported from the root of the module, no more having to work out which +subpath to import from. + +**Before** + +```ts +import type { PeerId } from '@libp2p/interface/peer-id' +import type { Connection } from '@libp2p/interface/connection' +import type { Stream } from '@libp2p/interface/stream-muxer' +``` + +**After** + +```ts +import type { Connection, PeerId, Stream } from '@libp2p/interface' +``` + +## Extracted modules + +`js-libp2p` has always had a focus on being a modular, composable ecosystem of +modules. `v1.x.x` takes this further and extracts all of the optional +functionality out of the core and into modules that you can include in your app +if you need them, or omit them if you don't. + +### Services + +These modules can be configured as services to enable optional functionality. + +#### AutoNAT The AutoNAT service is now published in its own package. @@ -48,7 +84,7 @@ const node = await createLibp2p({ }) ``` -## Ping +#### Ping The Ping service is now published in its own package. @@ -78,7 +114,7 @@ const node = await createLibp2p({ }) ``` -## Identify +#### Identify The Identify service is now published in its own package. @@ -108,7 +144,7 @@ const node = await createLibp2p({ }) ``` -## DCUtR +#### DCUtR The DCUtR service is now published in its own package. @@ -138,7 +174,7 @@ const node = await createLibp2p({ }) ``` -## Fetch +#### Fetch The Fetch service is now published in its own package. @@ -168,36 +204,8 @@ const node = await createLibp2p({ }) ``` -## KeyChain - -The KeyChain object is no longer included on Libp2p and must be instantiated explicitly if desired. - -**Before** - -```ts -import type { KeyChain } from '@libp2p/interface/keychain' - -const libp2p = await createLibp2p(...) - -const keychain: KeyChain = libp2p.keychain -``` - -**After** - -```ts -import { keychain, type Keychain } from '@libp2p/keychain' - -const libp2p = await createLibp2p({ - ... - services: { - keychain: keychain() - } -}) - -const keychain: Keychain = libp2p.services.keychain -``` -## UPnPNat +#### UPnPNat The UPnPNat service module is now published in its own package. @@ -227,7 +235,7 @@ const node = await createLibp2p({ }) ``` -## Perf +#### Perf The Perf service module exports have been renamed in line with the other changes here. @@ -258,7 +266,9 @@ const node = await createLibp2p({ }) ``` -## Plaintext +### Connection encryption + +#### Plaintext The Plaintext connection encrypter module is now published in its own package. @@ -290,20 +300,69 @@ const node = await createLibp2p({ }) ``` -## Pnet + +### Misc + +#### KeyChain + +The KeyChain object is no longer included on Libp2p and must be instantiated +explicitly if desired. + +**Before** + +```ts +import type { KeyChain } from '@libp2p/interface/keychain' + +const libp2p = await createLibp2p(...) + +const keychain: KeyChain = libp2p.keychain +``` + +**After** + +```ts +import { keychain, type Keychain } from '@libp2p/keychain' + +const libp2p = await createLibp2p({ + ... + services: { + keychain: keychain() + } +}) + +const keychain: Keychain = libp2p.services.keychain +``` + +### Pnet The pnet module is now published in its own package. **Before** ```ts +import { createLibp2p } from 'libp2p' import { preSharedKey, generateKey } from 'libp2p/pnet' + +const node = await createLibp2p({ + // ...other options + connectionProtector: preSharedKey({ + psk: generateKey(new Uint8Array(95)) + }) +}) ``` **After** ```ts +import { createLibp2p } from 'libp2p' import { preSharedKey, generateKey } from '@libp2p/pnet' + +const node = await createLibp2p({ + // ...other options + connectionProtector: preSharedKey({ + psk: generateKey(new Uint8Array(95)) + }) +}) ``` ## Metrics diff --git a/doc/package.json b/doc/package.json index 3fc895b92d..058f2c6dac 100644 --- a/doc/package.json +++ b/doc/package.json @@ -24,12 +24,12 @@ }, "dependencies": { "@chainsafe/libp2p-yamux": "^5.0.0", - "@libp2p/interface": "^0.1.0", - "@libp2p/mplex": "^9.0.0", - "@libp2p/prometheus-metrics": "^2.0.0", - "@libp2p/tcp": "^8.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/mplex": "^10.0.0", + "@libp2p/prometheus-metrics": "^3.0.0", + "@libp2p/tcp": "^9.0.0", "aegir": "^41.0.2", - "libp2p": "^0.46.0", + "libp2p": "^1.0.0", "prom-client": "^15.0.0" }, "private": true diff --git a/interop/CHANGELOG.md b/interop/CHANGELOG.md index 303f416348..98eb776435 100644 --- a/interop/CHANGELOG.md +++ b/interop/CHANGELOG.md @@ -1,5 +1,35 @@ # Changelog +## [2.0.0](https://www.github.com/libp2p/js-libp2p/compare/multidim-interop-v1.0.14...multidim-interop-v2.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/circuit-relay` should be updated to `@libp2p/circuit-relay-v2` +* imports from `libp2p/identify` need to change to `@libp2p/identify` +* imports from `libp2p/ping` must be updated to `@libp2p/ping` + +### Code Refactoring + +* extract circuit relay v2 to separate module ([#2222](https://www.github.com/libp2p/js-libp2p/issues/2222)) ([24afba3](https://www.github.com/libp2p/js-libp2p/commit/24afba30004fb7f24af1f0180229bb164340f00b)) +* extract identify service into separate module ([#2219](https://www.github.com/libp2p/js-libp2p/issues/2219)) ([72c2f77](https://www.github.com/libp2p/js-libp2p/commit/72c2f775bd85bd4928048dda0fd14740d6fb6a69)) +* extract ping service into separate module ([#2218](https://www.github.com/libp2p/js-libp2p/issues/2218)) ([556282a](https://www.github.com/libp2p/js-libp2p/commit/556282afdc9b328fd58df1045dc7c792199be932)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/circuit-relay-v2 bumped from ^0.0.0 to ^1.0.0 + * @libp2p/identify bumped from ^0.0.0 to ^1.0.0 + * @libp2p/mplex bumped from ^9.0.12 to ^10.0.0 + * @libp2p/ping bumped from ^0.0.0 to ^1.0.0 + * @libp2p/tcp bumped from ^8.0.13 to ^9.0.0 + * @libp2p/webrtc bumped from ^3.2.11 to ^4.0.0 + * @libp2p/websockets bumped from ^7.0.13 to ^8.0.0 + * @libp2p/webtransport bumped from ^3.1.10 to ^4.0.0 + * libp2p bumped from ^0.46.21 to ^1.0.0 + ### [1.0.14](https://www.github.com/libp2p/js-libp2p/compare/multidim-interop-v1.0.13...multidim-interop-v1.0.14) (2023-11-10) @@ -172,4 +202,4 @@ * @libp2p/webrtc bumped from ^3.0.0 to ^3.1.10 * @libp2p/websockets bumped from ^7.0.0 to ^7.0.6 * @libp2p/webtransport bumped from ^3.0.0 to ^3.0.10 - * libp2p bumped from ^0.46.0 to ^0.46.10 + * libp2p bumped from ^0.46.0 to ^0.46.10 \ No newline at end of file diff --git a/interop/package.json b/interop/package.json index ceed4a558e..7b78526b48 100644 --- a/interop/package.json +++ b/interop/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/multidim-interop", - "version": "1.0.14", + "version": "2.0.0", "description": "Multidimensional interop tests", "author": "Glen De Cauwsemaecker / @marcopolo", "license": "Apache-2.0 OR MIT", @@ -53,18 +53,18 @@ "dependencies": { "@chainsafe/libp2p-noise": "^13.0.0", "@chainsafe/libp2p-yamux": "^5.0.0", - "@libp2p/circuit-relay-v2": "^0.0.0", - "@libp2p/identify": "^0.0.0", - "@libp2p/mplex": "^9.0.12", - "@libp2p/ping": "^0.0.0", - "@libp2p/tcp": "^8.0.13", - "@libp2p/webrtc": "^3.2.11", - "@libp2p/websockets": "^7.0.13", - "@libp2p/webtransport": "^3.1.10", + "@libp2p/circuit-relay-v2": "^1.0.0", + "@libp2p/identify": "^1.0.0", + "@libp2p/mplex": "^10.0.0", + "@libp2p/ping": "^1.0.0", + "@libp2p/tcp": "^9.0.0", + "@libp2p/webrtc": "^4.0.0", + "@libp2p/websockets": "^8.0.0", + "@libp2p/webtransport": "^4.0.0", "@multiformats/mafmt": "^12.1.6", "@multiformats/multiaddr": "^12.1.10", "aegir": "^41.0.2", - "libp2p": "^0.46.21", + "libp2p": "^1.0.0", "redis": "^4.5.1" }, "browser": { diff --git a/interop/test/ping.spec.ts b/interop/test/ping.spec.ts index daa871ddc7..f8dcc7448e 100644 --- a/interop/test/ping.spec.ts +++ b/interop/test/ping.spec.ts @@ -122,7 +122,9 @@ describe('ping test', function () { skipSecureChannel = true skipMuxer = true // Setup yamux and noise to connect to the relay node + // @ts-expect-error TODO: yamux needs to be upgraded options.streamMuxers = [yamux()] + // @ts-expect-error TODO: noise needs to be upgraded options.connectionEncryption = [noise()] break default: @@ -132,6 +134,7 @@ describe('ping test', function () { if (!skipSecureChannel) { switch (SECURE_CHANNEL) { case 'noise': + // @ts-expect-error TODO: noise needs to be upgraded options.connectionEncryption = [noise()] break default: @@ -145,6 +148,7 @@ describe('ping test', function () { options.streamMuxers = [mplex()] break case 'yamux': + // @ts-expect-error TODO: yamux needs to be upgraded options.streamMuxers = [yamux()] break default: diff --git a/packages/connection-encrypter-plaintext/CHANGELOG.md b/packages/connection-encrypter-plaintext/CHANGELOG.md new file mode 100644 index 0000000000..6d7211f796 --- /dev/null +++ b/packages/connection-encrypter-plaintext/CHANGELOG.md @@ -0,0 +1,38 @@ +# Changelog + +## 1.0.0 (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data +* imports from `libp2p/circuit-relay` should be updated to `@libp2p/circuit-relay-v2` +* imports from `libp2p/plaintext` should be changed to `@libp2p/plaintext` + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* extract circuit relay v2 to separate module ([#2222](https://www.github.com/libp2p/js-libp2p/issues/2222)) ([24afba3](https://www.github.com/libp2p/js-libp2p/commit/24afba30004fb7f24af1f0180229bb164340f00b)) +* extract plaintext into separate module ([#2221](https://www.github.com/libp2p/js-libp2p/issues/2221)) ([a364d95](https://www.github.com/libp2p/js-libp2p/commit/a364d95bbd7b15a5ce6ce508321e7ff2fa40a5e5)) + + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.2 to ^1.0.0 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 \ No newline at end of file diff --git a/packages/connection-encrypter-plaintext/package.json b/packages/connection-encrypter-plaintext/package.json index 3431dec673..66175642d0 100644 --- a/packages/connection-encrypter-plaintext/package.json +++ b/packages/connection-encrypter-plaintext/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/plaintext", - "version": "0.0.0", + "version": "1.0.0", "description": "An insecure connection encrypter", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext#readme", @@ -51,8 +51,8 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "@libp2p/interface": "^0.1.2", - "@libp2p/peer-id": "^3.0.6", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-id": "^4.0.0", "@multiformats/multiaddr": "^12.1.10", "it-protobuf-stream": "^1.1.1", "it-stream-types": "^2.0.1", @@ -60,9 +60,9 @@ "uint8arraylist": "^2.4.3" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "protons": "^7.3.0", "sinon": "^17.0.0" diff --git a/packages/connection-encrypter-plaintext/src/index.ts b/packages/connection-encrypter-plaintext/src/index.ts index bdfe66a26a..7071fe624f 100644 --- a/packages/connection-encrypter-plaintext/src/index.ts +++ b/packages/connection-encrypter-plaintext/src/index.ts @@ -20,14 +20,11 @@ * ``` */ -import { UnexpectedPeerError, InvalidCryptoExchangeError } from '@libp2p/interface/errors' +import { UnexpectedPeerError, InvalidCryptoExchangeError } from '@libp2p/interface' import { peerIdFromBytes, peerIdFromKeys } from '@libp2p/peer-id' import { pbStream } from 'it-protobuf-stream' import { Exchange, KeyType } from './pb/proto.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { MultiaddrConnection } from '@libp2p/interface/connection' -import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface/connection-encrypter' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { ComponentLogger, Logger, MultiaddrConnection, ConnectionEncrypter, SecuredConnection, PeerId } from '@libp2p/interface' import type { Duplex } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/connection-encrypter-plaintext/test/index.spec.ts b/packages/connection-encrypter-plaintext/test/index.spec.ts index 4619ea1e92..e564e64e87 100644 --- a/packages/connection-encrypter-plaintext/test/index.spec.ts +++ b/packages/connection-encrypter-plaintext/test/index.spec.ts @@ -3,7 +3,7 @@ import { InvalidCryptoExchangeError, UnexpectedPeerError -} from '@libp2p/interface/errors' +} from '@libp2p/interface' import { mockMultiaddrConnPair } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { peerIdFromBytes } from '@libp2p/peer-id' @@ -12,8 +12,7 @@ import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import sinon from 'sinon' import { plaintext } from '../src/index.js' -import type { ConnectionEncrypter } from '@libp2p/interface/connection-encrypter' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { ConnectionEncrypter, PeerId } from '@libp2p/interface' describe('plaintext', () => { let localPeer: PeerId diff --git a/packages/crypto/CHANGELOG.md b/packages/crypto/CHANGELOG.md index cbf0ef2637..fb3b48fc51 100644 --- a/packages/crypto/CHANGELOG.md +++ b/packages/crypto/CHANGELOG.md @@ -5,6 +5,34 @@ * **dev:** bump aegir from 38.1.8 to 39.0.5 ([#320](https://github.com/libp2p/js-libp2p-crypto/issues/320)) ([f0b4c06](https://github.com/libp2p/js-libp2p-crypto/commit/f0b4c068a23d78b1376865c6adf6cce21ab91196)) +## [3.0.0](https://www.github.com/libp2p/js-libp2p/compare/crypto-v2.0.8...crypto-v3.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* remove unnecessary async from crypto methods (#1963) + +### Features + +* support streaming hashes for key sign/verify ([#2255](https://www.github.com/libp2p/js-libp2p/issues/2255)) ([ac7bc38](https://www.github.com/libp2p/js-libp2p/commit/ac7bc3839ae3d8253e9141c52be2c7c0c66a1d60)) + + +### Bug Fixes + +* allow keys to do sync sign/verify ([#2258](https://www.github.com/libp2p/js-libp2p/issues/2258)) ([dd7d17c](https://www.github.com/libp2p/js-libp2p/commit/dd7d17cc478dfcba02211a47789439b7d7ab9627)) + + +### Code Refactoring + +* remove unnecessary async from crypto methods ([#1963](https://www.github.com/libp2p/js-libp2p/issues/1963)) ([e2267d4](https://www.github.com/libp2p/js-libp2p/commit/e2267d437eeda3d964c77874ec757768d838981a)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + ### [2.0.8](https://www.github.com/libp2p/js-libp2p/compare/crypto-v2.0.7...crypto-v2.0.8) (2023-11-07) @@ -832,4 +860,4 @@ chore: update deps ### Features -* **keys:** implement generateKeyPairFromSeed for ed25519 ([e5b7c1f](https://github.com/libp2p/js-libp2p-crypto/commit/e5b7c1f)) +* **keys:** implement generateKeyPairFromSeed for ed25519 ([e5b7c1f](https://github.com/libp2p/js-libp2p-crypto/commit/e5b7c1f)) \ No newline at end of file diff --git a/packages/crypto/package.json b/packages/crypto/package.json index 9b5052ab8c..047a9d22d4 100644 --- a/packages/crypto/package.json +++ b/packages/crypto/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/crypto", - "version": "2.0.8", + "version": "3.0.0", "description": "Crypto primitives for libp2p", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/crypto#readme", @@ -90,7 +90,7 @@ "generate": "protons ./src/keys/keys.proto" }, "dependencies": { - "@libp2p/interface": "^0.1.6", + "@libp2p/interface": "^1.0.0", "@noble/curves": "^1.1.0", "@noble/hashes": "^1.3.1", "multiformats": "^12.1.3", diff --git a/packages/crypto/src/aes/cipher-mode.ts b/packages/crypto/src/aes/cipher-mode.ts index 95eefd8cf0..7aabcabe9c 100644 --- a/packages/crypto/src/aes/cipher-mode.ts +++ b/packages/crypto/src/aes/cipher-mode.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' const CIPHER_MODES = { 16: 'aes-128-ctr', diff --git a/packages/crypto/src/keys/ecdh-browser.ts b/packages/crypto/src/keys/ecdh-browser.ts index e5c8c72edb..c26a14375d 100644 --- a/packages/crypto/src/keys/ecdh-browser.ts +++ b/packages/crypto/src/keys/ecdh-browser.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' diff --git a/packages/crypto/src/keys/ecdh.ts b/packages/crypto/src/keys/ecdh.ts index 992ee4777b..cde5ff62b5 100644 --- a/packages/crypto/src/keys/ecdh.ts +++ b/packages/crypto/src/keys/ecdh.ts @@ -1,5 +1,5 @@ import crypto from 'crypto' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import type { ECDHKey, ECDHKeyPair } from './interface.js' const curves = { diff --git a/packages/crypto/src/keys/ed25519-class.ts b/packages/crypto/src/keys/ed25519-class.ts index 5957783156..3591f0d11d 100644 --- a/packages/crypto/src/keys/ed25519-class.ts +++ b/packages/crypto/src/keys/ed25519-class.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { base58btc } from 'multiformats/bases/base58' import { identity } from 'multiformats/hashes/identity' import { sha256 } from 'multiformats/hashes/sha2' diff --git a/packages/crypto/src/keys/index.ts b/packages/crypto/src/keys/index.ts index f805d81afa..766c553bc5 100644 --- a/packages/crypto/src/keys/index.ts +++ b/packages/crypto/src/keys/index.ts @@ -12,7 +12,7 @@ import 'node-forge/lib/asn1.js' import 'node-forge/lib/pbe.js' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' // @ts-expect-error types are missing import forge from 'node-forge/lib/forge.js' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' @@ -23,7 +23,7 @@ import { keyStretcher } from './key-stretcher.js' import * as keysPBM from './keys.js' import * as RSA from './rsa-class.js' import * as Secp256k1 from './secp256k1-class.js' -import type { PrivateKey, PublicKey } from '@libp2p/interface/keys' +import type { PrivateKey, PublicKey } from '@libp2p/interface' export { keyStretcher } export { generateEphemeralKeyPair } diff --git a/packages/crypto/src/keys/key-stretcher.ts b/packages/crypto/src/keys/key-stretcher.ts index 3b04f9c57e..d6159e1b5a 100644 --- a/packages/crypto/src/keys/key-stretcher.ts +++ b/packages/crypto/src/keys/key-stretcher.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import * as hmac from '../hmac/index.js' diff --git a/packages/crypto/src/keys/rsa-browser.ts b/packages/crypto/src/keys/rsa-browser.ts index 854c4abf43..bbef72a47c 100644 --- a/packages/crypto/src/keys/rsa-browser.ts +++ b/packages/crypto/src/keys/rsa-browser.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import randomBytes from '../random-bytes.js' diff --git a/packages/crypto/src/keys/rsa-class.ts b/packages/crypto/src/keys/rsa-class.ts index 6b6e51cd3e..9a5039531b 100644 --- a/packages/crypto/src/keys/rsa-class.ts +++ b/packages/crypto/src/keys/rsa-class.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { sha256 } from 'multiformats/hashes/sha2' // @ts-expect-error types are missing import forge from 'node-forge/lib/forge.js' diff --git a/packages/crypto/src/keys/rsa-utils.ts b/packages/crypto/src/keys/rsa-utils.ts index 70b97c7401..8b83696c8b 100644 --- a/packages/crypto/src/keys/rsa-utils.ts +++ b/packages/crypto/src/keys/rsa-utils.ts @@ -1,6 +1,6 @@ import 'node-forge/lib/asn1.js' import 'node-forge/lib/rsa.js' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' // @ts-expect-error types are missing import forge from 'node-forge/lib/forge.js' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' diff --git a/packages/crypto/src/keys/rsa.ts b/packages/crypto/src/keys/rsa.ts index b57c314da2..e0e8f9b093 100644 --- a/packages/crypto/src/keys/rsa.ts +++ b/packages/crypto/src/keys/rsa.ts @@ -1,6 +1,6 @@ import crypto from 'crypto' import { promisify } from 'util' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import randomBytes from '../random-bytes.js' import * as utils from './rsa-utils.js' import type { JWKKeyPair } from './interface.js' diff --git a/packages/crypto/src/keys/secp256k1-browser.ts b/packages/crypto/src/keys/secp256k1-browser.ts index 499f340a37..c12f3f2261 100644 --- a/packages/crypto/src/keys/secp256k1-browser.ts +++ b/packages/crypto/src/keys/secp256k1-browser.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { secp256k1 as secp } from '@noble/curves/secp256k1' import { sha256 } from 'multiformats/hashes/sha2' import { isPromise } from '../util.js' diff --git a/packages/crypto/src/keys/secp256k1-class.ts b/packages/crypto/src/keys/secp256k1-class.ts index b6531b0562..2b05ee1cbf 100644 --- a/packages/crypto/src/keys/secp256k1-class.ts +++ b/packages/crypto/src/keys/secp256k1-class.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { sha256 } from 'multiformats/hashes/sha2' import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' diff --git a/packages/crypto/src/keys/secp256k1.ts b/packages/crypto/src/keys/secp256k1.ts index 0be19e4512..a0f297db45 100644 --- a/packages/crypto/src/keys/secp256k1.ts +++ b/packages/crypto/src/keys/secp256k1.ts @@ -1,5 +1,5 @@ import crypto from 'node:crypto' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { secp256k1 as secp } from '@noble/curves/secp256k1' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/crypto/src/pbkdf2.ts b/packages/crypto/src/pbkdf2.ts index c7b6a5702f..329c58339e 100644 --- a/packages/crypto/src/pbkdf2.ts +++ b/packages/crypto/src/pbkdf2.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' // @ts-expect-error types are missing import forgePbkdf2 from 'node-forge/lib/pbkdf2.js' // @ts-expect-error types are missing diff --git a/packages/crypto/src/random-bytes.ts b/packages/crypto/src/random-bytes.ts index 5de614474b..9260fe7212 100644 --- a/packages/crypto/src/random-bytes.ts +++ b/packages/crypto/src/random-bytes.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { randomBytes as randB } from '@noble/hashes/utils' /** diff --git a/packages/integration-tests/package.json b/packages/integration-tests/package.json index 7344ef6ab3..c09b72b654 100644 --- a/packages/integration-tests/package.json +++ b/packages/integration-tests/package.json @@ -34,28 +34,28 @@ "devDependencies": { "@chainsafe/libp2p-noise": "^13.0.2", "@chainsafe/libp2p-yamux": "^5.0.0", - "@libp2p/circuit-relay-v2": "^0.0.0", - "@libp2p/dcutr": "^0.0.0", - "@libp2p/fetch": "^0.0.0", - "@libp2p/identify": "^0.0.0", - "@libp2p/interface": "^0.1.6", - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/interface-internal": "^0.1.9", - "@libp2p/mplex": "^9.0.12", - "@libp2p/peer-id": "^3.0.6", - "@libp2p/peer-id-factory": "^3.0.8", - "@libp2p/ping": "^0.0.0", - "@libp2p/plaintext": "^0.0.0", - "@libp2p/tcp": "^8.0.13", - "@libp2p/webrtc": "^3.2.10", - "@libp2p/websockets": "^7.0.13", + "@libp2p/circuit-relay-v2": "^1.0.0", + "@libp2p/dcutr": "^1.0.0", + "@libp2p/fetch": "^1.0.0", + "@libp2p/identify": "^1.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/mplex": "^10.0.0", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", + "@libp2p/ping": "^1.0.0", + "@libp2p/plaintext": "^1.0.0", + "@libp2p/tcp": "^9.0.0", + "@libp2p/webrtc": "^4.0.0", + "@libp2p/websockets": "^8.0.0", "@multiformats/mafmt": "^12.1.6", "@multiformats/multiaddr": "^12.1.10", "aegir": "^41.0.2", "delay": "^6.0.0", "it-all": "^3.0.3", "it-pipe": "^3.0.1", - "libp2p": "^0.46.20", + "libp2p": "^1.0.0", "merge-options": "^3.0.4", "multiformats": "^12.1.3", "p-defer": "^4.0.0", diff --git a/packages/integration-tests/test/circuit-relay-discovery.node.ts b/packages/integration-tests/test/circuit-relay-discovery.node.ts index 41f6490e80..4467c84150 100644 --- a/packages/integration-tests/test/circuit-relay-discovery.node.ts +++ b/packages/integration-tests/test/circuit-relay-discovery.node.ts @@ -25,6 +25,7 @@ describe('circuit-relay discovery', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux() ], connectionEncryption: [ @@ -58,6 +59,7 @@ describe('circuit-relay discovery', () => { }) ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux() ], connectionEncryption: [ @@ -78,6 +80,7 @@ describe('circuit-relay discovery', () => { }) ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux() ], connectionEncryption: [ diff --git a/packages/integration-tests/test/circuit-relay.node.ts b/packages/integration-tests/test/circuit-relay.node.ts index 3752774ba4..56e16f688a 100644 --- a/packages/integration-tests/test/circuit-relay.node.ts +++ b/packages/integration-tests/test/circuit-relay.node.ts @@ -21,9 +21,8 @@ import pWaitFor from 'p-wait-for' import sinon from 'sinon' import { Uint8ArrayList } from 'uint8arraylist' import { discoveredRelayConfig, doesNotHaveRelay, getRelayAddress, hasRelay, notUsingAsRelay, usingAsRelay, usingAsRelayCount } from './fixtures/utils.js' -import type { Libp2p } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { Libp2p, Connection } from '@libp2p/interface' +import type { Registrar } from '@libp2p/interface-internal' const DEFAULT_DATA_LIMIT = BigInt(1 << 17) @@ -37,6 +36,7 @@ async function createClient (options: Libp2pOptions = {}): Promise { circuitRelayTransport() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -63,6 +63,7 @@ async function createRelay (options: Libp2pOptions = {}): Promise { let local: Libp2p @@ -31,6 +29,7 @@ describe('circuit-relay', () => { circuitRelayTransport() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -57,6 +56,7 @@ describe('circuit-relay', () => { circuitRelayTransport() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], diff --git a/packages/integration-tests/test/fetch.spec.ts b/packages/integration-tests/test/fetch.spec.ts index 5c98caf24d..f4fc888223 100644 --- a/packages/integration-tests/test/fetch.spec.ts +++ b/packages/integration-tests/test/fetch.spec.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ import { type Fetch, fetch } from '@libp2p/fetch' -import { ERR_INVALID_PARAMETERS } from '@libp2p/interface/errors' +import { ERR_INVALID_PARAMETERS } from '@libp2p/interface' import { expect } from 'aegir/chai' import { createLibp2p } from 'libp2p' import { isWebWorker } from 'wherearewe' diff --git a/packages/integration-tests/test/fixtures/utils.ts b/packages/integration-tests/test/fixtures/utils.ts index 86fe9e43f8..ddc7b7b822 100644 --- a/packages/integration-tests/test/fixtures/utils.ts +++ b/packages/integration-tests/test/fixtures/utils.ts @@ -2,11 +2,8 @@ import { RELAY_V2_HOP_CODEC } from '@libp2p/circuit-relay-v2' import { peerIdFromString } from '@libp2p/peer-id' import pWaitFor from 'p-wait-for' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' -import type { Libp2p, AbortOptions } from '@libp2p/interface' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' +import type { Libp2p, AbortOptions, ContentRouting, PeerId, PeerInfo } from '@libp2p/interface' +import type { AddressManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' import type { CID, Version } from 'multiformats' import type { Options as PWaitForOptions } from 'p-wait-for' diff --git a/packages/interface-compliance-tests/CHANGELOG.md b/packages/interface-compliance-tests/CHANGELOG.md index d46b75fbb4..d41188253e 100644 --- a/packages/interface-compliance-tests/CHANGELOG.md +++ b/packages/interface-compliance-tests/CHANGELOG.md @@ -5,6 +5,45 @@ * bump aegir from 38.1.8 to 39.0.5 ([#393](https://github.com/libp2p/js-libp2p-interfaces/issues/393)) ([31f3797](https://github.com/libp2p/js-libp2p-interfaces/commit/31f3797b24f7c23f3f16e9db3a230bd5f7cd5175)) +## [5.0.0](https://www.github.com/libp2p/js-libp2p/compare/interface-compliance-tests-v4.1.5...interface-compliance-tests-v5.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data +* the `isStarted` method has been removed from the `Startable` interface +* the `.protocols` property has been removed from the `PeerInfo` interface + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* remove protocols from PeerInfo ([#2166](https://www.github.com/libp2p/js-libp2p/issues/2166)) ([5468cd1](https://www.github.com/libp2p/js-libp2p/commit/5468cd13a76281e46b221fdbd7d4005c0d3f2252)) +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) +* use optimistic protocol negotation ([#2253](https://www.github.com/libp2p/js-libp2p/issues/2253)) ([0b4a2ee](https://www.github.com/libp2p/js-libp2p/commit/0b4a2ee7983b4dc9dc0a7b705a202a4c550e7017)) + + +### Code Refactoring + +* remove isStarted method from Startable ([#2145](https://www.github.com/libp2p/js-libp2p/issues/2145)) ([fca208f](https://www.github.com/libp2p/js-libp2p/commit/fca208f3763af041aa37b1cb915d2bc777acb96d)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.9 to ^0.1.10 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/multistream-select bumped from ^4.0.6 to ^4.0.7 + * @libp2p/peer-collections bumped from ^4.0.8 to ^4.0.9 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + ### [4.1.5](https://www.github.com/libp2p/js-libp2p/compare/interface-compliance-tests-v4.1.4...interface-compliance-tests-v4.1.5) (2023-11-07) @@ -714,4 +753,4 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### BREAKING CHANGES -* the tests now live in the libp2p-interfaces-compliance-tests module +* the tests now live in the libp2p-interfaces-compliance-tests module \ No newline at end of file diff --git a/packages/interface-compliance-tests/package.json b/packages/interface-compliance-tests/package.json index 909415830b..0a191e855b 100644 --- a/packages/interface-compliance-tests/package.json +++ b/packages/interface-compliance-tests/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/interface-compliance-tests", - "version": "4.1.5", + "version": "5.0.0", "description": "Compliance tests for JS libp2p interfaces", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface-compliance-tests#readme", @@ -103,14 +103,14 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/interface-internal": "^0.1.9", - "@libp2p/logger": "^3.1.0", - "@libp2p/multistream-select": "^4.0.6", - "@libp2p/peer-collections": "^4.0.8", - "@libp2p/peer-id": "^3.0.6", - "@libp2p/peer-id-factory": "^3.0.8", - "@libp2p/utils": "^4.0.7", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/logger": "^4.0.0", + "@libp2p/multistream-select": "^4.0.7", + "@libp2p/peer-collections": "^4.0.9", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", + "@libp2p/utils": "^5.0.0", "@multiformats/multiaddr": "^12.1.10", "abortable-iterator": "^5.0.1", "aegir": "^41.0.2", diff --git a/packages/interface-compliance-tests/src/connection-encryption/index.ts b/packages/interface-compliance-tests/src/connection-encryption/index.ts index 60b8d91bd2..625cfb6c1d 100644 --- a/packages/interface-compliance-tests/src/connection-encryption/index.ts +++ b/packages/interface-compliance-tests/src/connection-encryption/index.ts @@ -1,4 +1,4 @@ -import { UnexpectedPeerError } from '@libp2p/interface/errors' +import { UnexpectedPeerError } from '@libp2p/interface' import * as PeerIdFactory from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' import all from 'it-all' @@ -7,8 +7,7 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import peers from '../peers.js' import { createMaConnPair } from './utils/index.js' import type { TestSetup } from '../index.js' -import type { ConnectionEncrypter } from '@libp2p/interface/connection-encrypter' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { ConnectionEncrypter, PeerId } from '@libp2p/interface' export default (common: TestSetup): void => { describe('interface-connection-encrypter compliance tests', () => { diff --git a/packages/interface-compliance-tests/src/connection-encryption/utils/index.ts b/packages/interface-compliance-tests/src/connection-encryption/utils/index.ts index 97391a8724..f5258a1b6b 100644 --- a/packages/interface-compliance-tests/src/connection-encryption/utils/index.ts +++ b/packages/interface-compliance-tests/src/connection-encryption/utils/index.ts @@ -1,7 +1,7 @@ import { logger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' import { duplexPair } from 'it-pair/duplex' -import type { MultiaddrConnection } from '@libp2p/interface/connection' +import type { MultiaddrConnection } from '@libp2p/interface' import type { Duplex, Source } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/interface-compliance-tests/src/connection/index.ts b/packages/interface-compliance-tests/src/connection/index.ts index cbce6f491a..559733d67e 100644 --- a/packages/interface-compliance-tests/src/connection/index.ts +++ b/packages/interface-compliance-tests/src/connection/index.ts @@ -1,7 +1,7 @@ import { expect } from 'aegir/chai' import sinon from 'sinon' import type { TestSetup } from '../index.js' -import type { Connection } from '@libp2p/interface/connection' +import type { Connection } from '@libp2p/interface' export default (test: TestSetup): void => { describe('connection', () => { diff --git a/packages/interface-compliance-tests/src/mocks/connection-gater.ts b/packages/interface-compliance-tests/src/mocks/connection-gater.ts index 3c62e7c30b..eaaf62038b 100644 --- a/packages/interface-compliance-tests/src/mocks/connection-gater.ts +++ b/packages/interface-compliance-tests/src/mocks/connection-gater.ts @@ -1,4 +1,4 @@ -import type { ConnectionGater } from '@libp2p/interface/connection-gater' +import type { ConnectionGater } from '@libp2p/interface' export function mockConnectionGater (): ConnectionGater { return { diff --git a/packages/interface-compliance-tests/src/mocks/connection-manager.ts b/packages/interface-compliance-tests/src/mocks/connection-manager.ts index f168282b50..5d0b4297d4 100644 --- a/packages/interface-compliance-tests/src/mocks/connection-manager.ts +++ b/packages/interface-compliance-tests/src/mocks/connection-manager.ts @@ -1,16 +1,10 @@ -import { CodeError } from '@libp2p/interface/errors' -import { isPeerId, type PeerId } from '@libp2p/interface/peer-id' +import { CodeError } from '@libp2p/interface' +import { isPeerId, type PeerId, type ComponentLogger, type Libp2pEvents, type PendingDial, type Connection, type TypedEventTarget, type PubSub, type Startable } from '@libp2p/interface' import { PeerMap } from '@libp2p/peer-collections' import { peerIdFromString } from '@libp2p/peer-id' import { isMultiaddr, type Multiaddr } from '@multiformats/multiaddr' import { connectionPair } from './connection.js' -import type { ComponentLogger, Libp2pEvents, PendingDial } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PubSub } from '@libp2p/interface/pubsub' -import type { Startable } from '@libp2p/interface/startable' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' export interface MockNetworkComponents { peerId: PeerId diff --git a/packages/interface-compliance-tests/src/mocks/connection.ts b/packages/interface-compliance-tests/src/mocks/connection.ts index 842f0a920f..704712ce99 100644 --- a/packages/interface-compliance-tests/src/mocks/connection.ts +++ b/packages/interface-compliance-tests/src/mocks/connection.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { defaultLogger, logger } from '@libp2p/logger' import * as mss from '@libp2p/multistream-select' import { peerIdFromString } from '@libp2p/peer-id' @@ -9,11 +9,8 @@ import { Uint8ArrayList } from 'uint8arraylist' import { mockMultiaddrConnection } from './multiaddr-connection.js' import { mockMuxer } from './muxer.js' import { mockRegistrar } from './registrar.js' -import type { AbortOptions, ComponentLogger, Logger } from '@libp2p/interface' -import type { MultiaddrConnection, Connection, Stream, Direction, ConnectionTimeline, ConnectionStatus } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { StreamMuxer, StreamMuxerFactory } from '@libp2p/interface/stream-muxer' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { AbortOptions, ComponentLogger, Logger, MultiaddrConnection, Connection, Stream, Direction, ConnectionTimeline, ConnectionStatus, PeerId, StreamMuxer, StreamMuxerFactory } from '@libp2p/interface' +import type { Registrar } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' import type { Duplex, Source } from 'it-stream-types' diff --git a/packages/interface-compliance-tests/src/mocks/metrics.ts b/packages/interface-compliance-tests/src/mocks/metrics.ts index 3129cfecd1..6f238d112e 100644 --- a/packages/interface-compliance-tests/src/mocks/metrics.ts +++ b/packages/interface-compliance-tests/src/mocks/metrics.ts @@ -1,5 +1,4 @@ -import type { MultiaddrConnection, Stream, Connection } from '@libp2p/interface/connection' -import type { Metric, MetricGroup, StopTimer, Metrics, CalculatedMetricOptions, MetricOptions } from '@libp2p/interface/metrics' +import type { MultiaddrConnection, Stream, Connection, Metric, MetricGroup, StopTimer, Metrics, CalculatedMetricOptions, MetricOptions } from '@libp2p/interface' class DefaultMetric implements Metric { public value: number = 0 diff --git a/packages/interface-compliance-tests/src/mocks/multiaddr-connection.ts b/packages/interface-compliance-tests/src/mocks/multiaddr-connection.ts index 01db6a496d..d43237c8e8 100644 --- a/packages/interface-compliance-tests/src/mocks/multiaddr-connection.ts +++ b/packages/interface-compliance-tests/src/mocks/multiaddr-connection.ts @@ -2,8 +2,7 @@ import { logger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' import { abortableSource } from 'abortable-iterator' import { duplexPair } from 'it-pair/duplex' -import type { MultiaddrConnection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { MultiaddrConnection, PeerId } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' import type { Duplex } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/interface-compliance-tests/src/mocks/muxer.ts b/packages/interface-compliance-tests/src/mocks/muxer.ts index 27a2594231..e71bb6c9ae 100644 --- a/packages/interface-compliance-tests/src/mocks/muxer.ts +++ b/packages/interface-compliance-tests/src/mocks/muxer.ts @@ -8,9 +8,7 @@ import { type Pushable, pushable } from 'it-pushable' import { Uint8ArrayList } from 'uint8arraylist' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' -import type { AbortOptions } from '@libp2p/interface' -import type { Direction, Stream } from '@libp2p/interface/connection' -import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface/stream-muxer' +import type { AbortOptions, Direction, Stream, StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface' import type { Source } from 'it-stream-types' let muxers = 0 diff --git a/packages/interface-compliance-tests/src/mocks/peer-discovery.ts b/packages/interface-compliance-tests/src/mocks/peer-discovery.ts index 7fa6abedc1..fdeea22338 100644 --- a/packages/interface-compliance-tests/src/mocks/peer-discovery.ts +++ b/packages/interface-compliance-tests/src/mocks/peer-discovery.ts @@ -1,9 +1,7 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' -import { peerDiscovery } from '@libp2p/interface/peer-discovery' +import { TypedEventEmitter, peerDiscoverySymbol } from '@libp2p/interface' import * as PeerIdFactory from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' -import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interface/peer-discovery' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { PeerDiscovery, PeerDiscoveryEvents, PeerInfo } from '@libp2p/interface' interface MockDiscoveryInit { discoveryDelay?: number @@ -24,7 +22,7 @@ export class MockDiscovery extends TypedEventEmitter implem this._isRunning = false } - readonly [peerDiscovery] = this + readonly [peerDiscoverySymbol] = this start (): void { this._isRunning = true diff --git a/packages/interface-compliance-tests/src/mocks/registrar.ts b/packages/interface-compliance-tests/src/mocks/registrar.ts index a130224b2c..fe22e1a219 100644 --- a/packages/interface-compliance-tests/src/mocks/registrar.ts +++ b/packages/interface-compliance-tests/src/mocks/registrar.ts @@ -1,8 +1,6 @@ import merge from 'merge-options' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Topology } from '@libp2p/interface/topology' -import type { IncomingStreamData, Registrar, StreamHandler, StreamHandlerOptions, StreamHandlerRecord } from '@libp2p/interface-internal/registrar' +import type { Connection, PeerId, Topology } from '@libp2p/interface' +import type { IncomingStreamData, Registrar, StreamHandler, StreamHandlerOptions, StreamHandlerRecord } from '@libp2p/interface-internal' export class MockRegistrar implements Registrar { private readonly topologies = new Map>() diff --git a/packages/interface-compliance-tests/src/mocks/upgrader.ts b/packages/interface-compliance-tests/src/mocks/upgrader.ts index 4f69268071..84d22214ce 100644 --- a/packages/interface-compliance-tests/src/mocks/upgrader.ts +++ b/packages/interface-compliance-tests/src/mocks/upgrader.ts @@ -1,9 +1,6 @@ import { mockConnection } from './connection.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { Connection, MultiaddrConnection } from '@libp2p/interface/connection' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { Upgrader, UpgraderOptions } from '@libp2p/interface/transport' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { Libp2pEvents, Connection, MultiaddrConnection, TypedEventTarget, Upgrader, UpgraderOptions } from '@libp2p/interface' +import type { Registrar } from '@libp2p/interface-internal' export interface MockUpgraderInit { registrar?: Registrar diff --git a/packages/interface-compliance-tests/src/peer-discovery/index.ts b/packages/interface-compliance-tests/src/peer-discovery/index.ts index dbeee5cf87..908891f1d4 100644 --- a/packages/interface-compliance-tests/src/peer-discovery/index.ts +++ b/packages/interface-compliance-tests/src/peer-discovery/index.ts @@ -1,10 +1,10 @@ -import { start, stop } from '@libp2p/interface/startable' +import { start, stop } from '@libp2p/interface' import { isMultiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import delay from 'delay' import pDefer from 'p-defer' import type { TestSetup } from '../index.js' -import type { PeerDiscovery } from '@libp2p/interface/peer-discovery' +import type { PeerDiscovery } from '@libp2p/interface' export default (common: TestSetup): void => { describe('interface-peer-discovery compliance tests', () => { diff --git a/packages/interface-compliance-tests/src/pubsub/api.ts b/packages/interface-compliance-tests/src/pubsub/api.ts index 4c81f4f595..32cbc9920c 100644 --- a/packages/interface-compliance-tests/src/pubsub/api.ts +++ b/packages/interface-compliance-tests/src/pubsub/api.ts @@ -1,4 +1,4 @@ -import { isStartable, start, stop } from '@libp2p/interface/startable' +import { isStartable, start, stop } from '@libp2p/interface' import { expect } from 'aegir/chai' import delay from 'delay' import pDefer from 'p-defer' @@ -9,7 +9,7 @@ import { mockNetwork } from '../mocks/index.js' import { createComponents } from './utils.js' import type { PubSubArgs, PubSubComponents } from './index.js' import type { TestSetup } from '../index.js' -import type { PubSub } from '@libp2p/interface/pubsub' +import type { PubSub } from '@libp2p/interface' const topic = 'foo' const data = uint8ArrayFromString('bar') diff --git a/packages/interface-compliance-tests/src/pubsub/connection-handlers.ts b/packages/interface-compliance-tests/src/pubsub/connection-handlers.ts index 687f541422..eefdd552f8 100644 --- a/packages/interface-compliance-tests/src/pubsub/connection-handlers.ts +++ b/packages/interface-compliance-tests/src/pubsub/connection-handlers.ts @@ -1,4 +1,4 @@ -import { start, stop } from '@libp2p/interface/startable' +import { start, stop } from '@libp2p/interface' import { expect } from 'aegir/chai' import pDefer from 'p-defer' import { pEvent } from 'p-event' @@ -11,7 +11,7 @@ import { createComponents } from './utils.js' import type { PubSubArgs } from './index.js' import type { TestSetup } from '../index.js' import type { MockNetworkComponents } from '../mocks/index.js' -import type { Message, PubSub } from '@libp2p/interface/pubsub' +import type { Message, PubSub } from '@libp2p/interface' export default (common: TestSetup): void => { describe('pubsub connection handlers', () => { diff --git a/packages/interface-compliance-tests/src/pubsub/emit-self.ts b/packages/interface-compliance-tests/src/pubsub/emit-self.ts index 9422ed8ddc..03d6b4e973 100644 --- a/packages/interface-compliance-tests/src/pubsub/emit-self.ts +++ b/packages/interface-compliance-tests/src/pubsub/emit-self.ts @@ -1,4 +1,4 @@ -import { start, stop } from '@libp2p/interface/startable' +import { start, stop } from '@libp2p/interface' import { expect } from 'aegir/chai' import sinon from 'sinon' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' @@ -6,7 +6,7 @@ import { mockNetwork } from '../mocks/index.js' import { createComponents } from './utils.js' import type { PubSubArgs, PubSubComponents } from './index.js' import type { TestSetup } from '../index.js' -import type { PubSub } from '@libp2p/interface/pubsub' +import type { PubSub } from '@libp2p/interface' const topic = 'foo' const data = uint8ArrayFromString('bar') diff --git a/packages/interface-compliance-tests/src/pubsub/index.ts b/packages/interface-compliance-tests/src/pubsub/index.ts index 189ff6d171..7e5fa3fe95 100644 --- a/packages/interface-compliance-tests/src/pubsub/index.ts +++ b/packages/interface-compliance-tests/src/pubsub/index.ts @@ -5,11 +5,8 @@ import messagesTest from './messages.js' import multipleNodesTest from './multiple-nodes.js' import twoNodesTest from './two-nodes.js' import type { TestSetup } from '../index.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PubSub, PubSubInit } from '@libp2p/interface/pubsub' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { ComponentLogger, PeerId, PubSub, PubSubInit } from '@libp2p/interface' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' export interface PubSubComponents { peerId: PeerId diff --git a/packages/interface-compliance-tests/src/pubsub/messages.ts b/packages/interface-compliance-tests/src/pubsub/messages.ts index 907b2395c0..1d694672d4 100644 --- a/packages/interface-compliance-tests/src/pubsub/messages.ts +++ b/packages/interface-compliance-tests/src/pubsub/messages.ts @@ -1,4 +1,4 @@ -import { start, stop } from '@libp2p/interface/startable' +import { start, stop } from '@libp2p/interface' import { expect } from 'aegir/chai' import { pEvent } from 'p-event' import sinon from 'sinon' @@ -7,7 +7,7 @@ import { mockNetwork } from '../mocks/index.js' import { createComponents } from './utils.js' import type { PubSubArgs, PubSubComponents } from './index.js' import type { TestSetup } from '../index.js' -import type { Message, PubSub } from '@libp2p/interface/pubsub' +import type { Message, PubSub } from '@libp2p/interface' const topic = 'foo' const data = uint8ArrayFromString('bar') diff --git a/packages/interface-compliance-tests/src/pubsub/multiple-nodes.ts b/packages/interface-compliance-tests/src/pubsub/multiple-nodes.ts index cddc78e1b0..8985f6e993 100644 --- a/packages/interface-compliance-tests/src/pubsub/multiple-nodes.ts +++ b/packages/interface-compliance-tests/src/pubsub/multiple-nodes.ts @@ -1,5 +1,5 @@ /* eslint max-nested-callbacks: ["error", 6] */ -import { start, stop } from '@libp2p/interface/startable' +import { start, stop } from '@libp2p/interface' import { expect } from 'aegir/chai' import delay from 'delay' import pDefer from 'p-defer' @@ -11,7 +11,7 @@ import { mockNetwork } from '../mocks/index.js' import { createComponents, waitForSubscriptionUpdate } from './utils.js' import type { PubSubArgs, PubSubComponents } from './index.js' import type { TestSetup } from '../index.js' -import type { Message, PubSub } from '@libp2p/interface/pubsub' +import type { Message, PubSub } from '@libp2p/interface' export default (common: TestSetup): void => { describe('pubsub with multiple nodes', function () { diff --git a/packages/interface-compliance-tests/src/pubsub/two-nodes.ts b/packages/interface-compliance-tests/src/pubsub/two-nodes.ts index c68d81dedd..6e9f857181 100644 --- a/packages/interface-compliance-tests/src/pubsub/two-nodes.ts +++ b/packages/interface-compliance-tests/src/pubsub/two-nodes.ts @@ -1,6 +1,5 @@ /* eslint max-nested-callbacks: ["error", 6] */ -import { TopicValidatorResult } from '@libp2p/interface/pubsub' -import { start, stop } from '@libp2p/interface/startable' +import { TopicValidatorResult, start, stop } from '@libp2p/interface' import { expect } from 'aegir/chai' import pDefer from 'p-defer' import pWaitFor from 'p-wait-for' @@ -11,7 +10,7 @@ import { mockNetwork } from '../mocks/index.js' import { createComponents, waitForSubscriptionUpdate } from './utils.js' import type { PubSubArgs, PubSubComponents } from './index.js' import type { TestSetup } from '../index.js' -import type { Message, PubSub } from '@libp2p/interface/pubsub' +import type { Message, PubSub } from '@libp2p/interface' const topic = 'foo' diff --git a/packages/interface-compliance-tests/src/pubsub/utils.ts b/packages/interface-compliance-tests/src/pubsub/utils.ts index 46ab447969..b3e626da90 100644 --- a/packages/interface-compliance-tests/src/pubsub/utils.ts +++ b/packages/interface-compliance-tests/src/pubsub/utils.ts @@ -1,12 +1,11 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { pEvent } from 'p-event' import pWaitFor from 'p-wait-for' import { mockConnectionManager, mockRegistrar, mockNetwork } from '../mocks/index.js' import type { MockNetworkComponents } from '../mocks/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PubSub, SubscriptionChangeData } from '@libp2p/interface/pubsub' +import type { PeerId, PubSub, SubscriptionChangeData } from '@libp2p/interface' export async function waitForSubscriptionUpdate (a: PubSub, b: PeerId): Promise { await pWaitFor(async () => { diff --git a/packages/interface-compliance-tests/src/stream-muxer/base-test.ts b/packages/interface-compliance-tests/src/stream-muxer/base-test.ts index 146b005fa1..39456311dd 100644 --- a/packages/interface-compliance-tests/src/stream-muxer/base-test.ts +++ b/packages/interface-compliance-tests/src/stream-muxer/base-test.ts @@ -10,8 +10,7 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { isValidTick } from '../is-valid-tick.js' import type { TestSetup } from '../index.js' -import type { Stream } from '@libp2p/interface/connection' -import type { StreamMuxerFactory } from '@libp2p/interface/stream-muxer' +import type { Stream, StreamMuxerFactory } from '@libp2p/interface' import type { Source, Duplex } from 'it-stream-types' import type { DeferredPromise } from 'p-defer' diff --git a/packages/interface-compliance-tests/src/stream-muxer/close-test.ts b/packages/interface-compliance-tests/src/stream-muxer/close-test.ts index 5f66ea3aec..9ba2f246ba 100644 --- a/packages/interface-compliance-tests/src/stream-muxer/close-test.ts +++ b/packages/interface-compliance-tests/src/stream-muxer/close-test.ts @@ -13,7 +13,7 @@ import { Uint8ArrayList } from 'uint8arraylist' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { Message } from './fixtures/pb/message.js' import type { TestSetup } from '../index.js' -import type { StreamMuxerFactory } from '@libp2p/interface/stream-muxer' +import type { StreamMuxerFactory } from '@libp2p/interface' function randomBuffer (): Uint8Array { return uint8ArrayFromString(Math.random().toString()) diff --git a/packages/interface-compliance-tests/src/stream-muxer/index.ts b/packages/interface-compliance-tests/src/stream-muxer/index.ts index 570eed96a2..ce71d22c16 100644 --- a/packages/interface-compliance-tests/src/stream-muxer/index.ts +++ b/packages/interface-compliance-tests/src/stream-muxer/index.ts @@ -3,7 +3,7 @@ import closeTest from './close-test.js' import megaStressTest from './mega-stress-test.js' import stressTest from './stress-test.js' import type { TestSetup } from '../index.js' -import type { StreamMuxerFactory } from '@libp2p/interface/stream-muxer' +import type { StreamMuxerFactory } from '@libp2p/interface' export default (common: TestSetup): void => { describe('interface-stream-muxer', () => { diff --git a/packages/interface-compliance-tests/src/stream-muxer/mega-stress-test.ts b/packages/interface-compliance-tests/src/stream-muxer/mega-stress-test.ts index 97b8956a6c..0e1c05be33 100644 --- a/packages/interface-compliance-tests/src/stream-muxer/mega-stress-test.ts +++ b/packages/interface-compliance-tests/src/stream-muxer/mega-stress-test.ts @@ -1,6 +1,6 @@ import spawn from './spawner.js' import type { TestSetup } from '../index.js' -import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface/stream-muxer' +import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface' export default (common: TestSetup): void => { const createMuxer = async (init?: StreamMuxerInit): Promise => { diff --git a/packages/interface-compliance-tests/src/stream-muxer/spawner.ts b/packages/interface-compliance-tests/src/stream-muxer/spawner.ts index 2ed7e6cd02..30bb238bf2 100644 --- a/packages/interface-compliance-tests/src/stream-muxer/spawner.ts +++ b/packages/interface-compliance-tests/src/stream-muxer/spawner.ts @@ -6,7 +6,7 @@ import { pipe } from 'it-pipe' import pLimit from 'p-limit' import { Uint8ArrayList } from 'uint8arraylist' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' -import type { StreamMuxer, StreamMuxerInit } from '@libp2p/interface/stream-muxer' +import type { StreamMuxer, StreamMuxerInit } from '@libp2p/interface' export default async (createMuxer: (init?: StreamMuxerInit) => Promise, nStreams: number, nMsg: number, limit?: number): Promise => { const [dialerSocket, listenerSocket] = duplexPair() diff --git a/packages/interface-compliance-tests/src/stream-muxer/stress-test.ts b/packages/interface-compliance-tests/src/stream-muxer/stress-test.ts index 3da0ed22f0..770f81fb88 100644 --- a/packages/interface-compliance-tests/src/stream-muxer/stress-test.ts +++ b/packages/interface-compliance-tests/src/stream-muxer/stress-test.ts @@ -1,6 +1,6 @@ import spawn from './spawner.js' import type { TestSetup } from '../index.js' -import type { StreamMuxerFactory, StreamMuxerInit, StreamMuxer } from '@libp2p/interface/stream-muxer' +import type { StreamMuxerFactory, StreamMuxerInit, StreamMuxer } from '@libp2p/interface' export default (common: TestSetup): void => { const createMuxer = async (init?: StreamMuxerInit): Promise => { diff --git a/packages/interface-compliance-tests/src/transport/dial-test.ts b/packages/interface-compliance-tests/src/transport/dial-test.ts index 98035d9aa5..faa300317c 100644 --- a/packages/interface-compliance-tests/src/transport/dial-test.ts +++ b/packages/interface-compliance-tests/src/transport/dial-test.ts @@ -1,5 +1,4 @@ -import { AbortError } from '@libp2p/interface/errors' -import { TypedEventEmitter } from '@libp2p/interface/events' +import { AbortError, TypedEventEmitter } from '@libp2p/interface' import { expect } from 'aegir/chai' import all from 'it-all' import drain from 'it-drain' @@ -10,8 +9,8 @@ import { isValidTick } from '../is-valid-tick.js' import { mockUpgrader, mockRegistrar } from '../mocks/index.js' import type { TransportTestFixtures, Connector } from './index.js' import type { TestSetup } from '../index.js' -import type { Listener, Transport, Upgrader } from '@libp2p/interface/transport' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { Listener, Transport, Upgrader } from '@libp2p/interface' +import type { Registrar } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export default (common: TestSetup): void => { diff --git a/packages/interface-compliance-tests/src/transport/filter-test.ts b/packages/interface-compliance-tests/src/transport/filter-test.ts index 787353ad48..c54039fcbf 100644 --- a/packages/interface-compliance-tests/src/transport/filter-test.ts +++ b/packages/interface-compliance-tests/src/transport/filter-test.ts @@ -1,7 +1,7 @@ import { expect } from 'aegir/chai' import type { TransportTestFixtures } from './index.js' import type { TestSetup } from '../index.js' -import type { Transport } from '@libp2p/interface/transport' +import type { Transport } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' export default (common: TestSetup): void => { diff --git a/packages/interface-compliance-tests/src/transport/index.ts b/packages/interface-compliance-tests/src/transport/index.ts index c0a5a6ed11..c5925c9f24 100644 --- a/packages/interface-compliance-tests/src/transport/index.ts +++ b/packages/interface-compliance-tests/src/transport/index.ts @@ -2,7 +2,7 @@ import dial from './dial-test.js' import filter from './filter-test.js' import listen from './listen-test.js' import type { TestSetup } from '../index.js' -import type { Transport } from '@libp2p/interface/transport' +import type { Transport } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' export interface Connector { diff --git a/packages/interface-compliance-tests/src/transport/listen-test.ts b/packages/interface-compliance-tests/src/transport/listen-test.ts index d9f3a17c22..54f51668dd 100644 --- a/packages/interface-compliance-tests/src/transport/listen-test.ts +++ b/packages/interface-compliance-tests/src/transport/listen-test.ts @@ -1,5 +1,5 @@ /* eslint max-nested-callbacks: ["error", 8] */ -import { CustomEvent, TypedEventEmitter } from '@libp2p/interface/events' +import { CustomEvent, TypedEventEmitter } from '@libp2p/interface' import { expect } from 'aegir/chai' import drain from 'it-drain' import { pipe } from 'it-pipe' @@ -11,9 +11,8 @@ import { isValidTick } from '../is-valid-tick.js' import { mockUpgrader, mockRegistrar } from '../mocks/index.js' import type { TransportTestFixtures } from './index.js' import type { TestSetup } from '../index.js' -import type { Connection } from '@libp2p/interface/connection' -import type { Transport, Upgrader } from '@libp2p/interface/transport' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { Connection, Transport, Upgrader } from '@libp2p/interface' +import type { Registrar } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export default (common: TestSetup): void => { diff --git a/packages/interface-compliance-tests/test/mocks/connection.spec.ts b/packages/interface-compliance-tests/test/mocks/connection.spec.ts index 744c0486f6..6359d75023 100644 --- a/packages/interface-compliance-tests/test/mocks/connection.spec.ts +++ b/packages/interface-compliance-tests/test/mocks/connection.spec.ts @@ -3,7 +3,7 @@ import { pipe } from 'it-pipe' import tests from '../../src/connection/index.js' import { connectionPair } from '../../src/mocks/connection.js' import { mockRegistrar } from '../../src/mocks/registrar.js' -import type { Connection } from '@libp2p/interface/connection' +import type { Connection } from '@libp2p/interface' describe('mock connection compliance tests', () => { let connections: Connection[] = [] diff --git a/packages/interface-internal/CHANGELOG.md b/packages/interface-internal/CHANGELOG.md index c5a2bab6e8..9a18254308 100644 --- a/packages/interface-internal/CHANGELOG.md +++ b/packages/interface-internal/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +### [0.1.10](https://www.github.com/libp2p/js-libp2p/compare/interface-internal-v0.1.9...interface-internal-v0.1.10) (2023-11-28) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/peer-collections bumped from ^4.0.8 to ^4.0.9 + ### [0.1.9](https://www.github.com/libp2p/js-libp2p/compare/interface-internal-v0.1.8...interface-internal-v0.1.9) (2023-11-07) diff --git a/packages/interface-internal/package.json b/packages/interface-internal/package.json index 2b73299e44..a76931e512 100644 --- a/packages/interface-internal/package.json +++ b/packages/interface-internal/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/interface-internal", - "version": "0.1.9", + "version": "0.1.10", "description": "Interfaces implemented by internal libp2p components", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface-internal#readme", @@ -47,26 +47,6 @@ ".": { "types": "./dist/src/index.d.ts", "import": "./dist/src/index.js" - }, - "./address-manager": { - "types": "./dist/src/address-manager/index.d.ts", - "import": "./dist/src/address-manager/index.js" - }, - "./connection-manager": { - "types": "./dist/src/connection-manager/index.d.ts", - "import": "./dist/src/connection-manager/index.js" - }, - "./record": { - "types": "./dist/src/record/index.d.ts", - "import": "./dist/src/record/index.js" - }, - "./registrar": { - "types": "./dist/src/registrar/index.d.ts", - "import": "./dist/src/registrar/index.js" - }, - "./transport-manager": { - "types": "./dist/src/transport-manager/index.d.ts", - "import": "./dist/src/transport-manager/index.js" } }, "eslintConfig": { @@ -83,8 +63,8 @@ "build": "aegir build" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/peer-collections": "^4.0.8", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-collections": "^4.0.9", "@multiformats/multiaddr": "^12.1.10", "uint8arraylist": "^2.4.3" }, diff --git a/packages/interface-internal/src/connection-manager/index.ts b/packages/interface-internal/src/connection-manager/index.ts index 66051b4e41..9491f5589f 100644 --- a/packages/interface-internal/src/connection-manager/index.ts +++ b/packages/interface-internal/src/connection-manager/index.ts @@ -1,6 +1,4 @@ -import type { AbortOptions, PendingDial } from '@libp2p/interface' -import type { Connection, MultiaddrConnection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { AbortOptions, PendingDial, Connection, MultiaddrConnection, PeerId } from '@libp2p/interface' import type { PeerMap } from '@libp2p/peer-collections' import type { Multiaddr } from '@multiformats/multiaddr' diff --git a/packages/interface-internal/src/index.ts b/packages/interface-internal/src/index.ts index 336ce12bb9..4797490740 100644 --- a/packages/interface-internal/src/index.ts +++ b/packages/interface-internal/src/index.ts @@ -1 +1,5 @@ -export {} +export * from './address-manager/index.js' +export * from './connection-manager/index.js' +export * from './record/index.js' +export * from './registrar/index.js' +export * from './transport-manager/index.js' diff --git a/packages/interface-internal/src/record/index.ts b/packages/interface-internal/src/record/index.ts index ff27b0460b..d890476902 100644 --- a/packages/interface-internal/src/record/index.ts +++ b/packages/interface-internal/src/record/index.ts @@ -1,4 +1,4 @@ -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { Uint8ArrayList } from 'uint8arraylist' /** diff --git a/packages/interface-internal/src/registrar/index.ts b/packages/interface-internal/src/registrar/index.ts index 52db9d5b3e..504ed4ad9f 100644 --- a/packages/interface-internal/src/registrar/index.ts +++ b/packages/interface-internal/src/registrar/index.ts @@ -1,5 +1,4 @@ -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { Topology } from '@libp2p/interface/topology' +import type { Connection, Stream, Topology } from '@libp2p/interface' export interface IncomingStreamData { stream: Stream diff --git a/packages/interface-internal/src/transport-manager/index.ts b/packages/interface-internal/src/transport-manager/index.ts index a905d2a14b..a76642ed87 100644 --- a/packages/interface-internal/src/transport-manager/index.ts +++ b/packages/interface-internal/src/transport-manager/index.ts @@ -1,5 +1,4 @@ -import type { Connection } from '@libp2p/interface/connection' -import type { Listener, Transport } from '@libp2p/interface/transport' +import type { Connection, Listener, Transport } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' export interface TransportManager { diff --git a/packages/interface-internal/typedoc.json b/packages/interface-internal/typedoc.json index 93835c957e..f599dc728d 100644 --- a/packages/interface-internal/typedoc.json +++ b/packages/interface-internal/typedoc.json @@ -1,10 +1,5 @@ { "entryPoints": [ - "./src/index.ts", - "./src/address-manager/index.ts", - "./src/connection-manager/index.ts", - "./src/record/index.ts", - "./src/registrar/index.ts", - "./src/transport-manager/index.ts" + "./src/index.ts" ] } diff --git a/packages/interface/CHANGELOG.md b/packages/interface/CHANGELOG.md index b48276c96f..bb508b9eb3 100644 --- a/packages/interface/CHANGELOG.md +++ b/packages/interface/CHANGELOG.md @@ -5,6 +5,45 @@ * add start/stop events to libp2p interface ([#407](https://github.com/libp2p/js-libp2p-interfaces/issues/407)) ([016c1e8](https://github.com/libp2p/js-libp2p-interfaces/commit/016c1e82b060c93c80546cd8c493ec6e6c97cbec)) +## [1.0.0](https://www.github.com/libp2p/js-libp2p/compare/interface-v0.1.6...interface-v1.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data +* removed EventEmitter re-export - please use TypedEventEmitter instead +* imports from `libp2p/dcutr` now need to be from `@libp2p/dcutr` +* imports from `libp2p/identify` need to change to `@libp2p/identify` +* imports from `libp2p/upnp-nat` should be updated to `@libp2p/upnp-nat` +* the `isStarted` method has been removed from the `Startable` interface +* the `.protocols` property has been removed from the `PeerInfo` interface +* move autonat into separate package (#2107) +* remove libp2p.keychain (#2084) +* remove min/max from topologies (#2158) + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) +* support streaming hashes for key sign/verify ([#2255](https://www.github.com/libp2p/js-libp2p/issues/2255)) ([ac7bc38](https://www.github.com/libp2p/js-libp2p/commit/ac7bc3839ae3d8253e9141c52be2c7c0c66a1d60)) + + +### Bug Fixes + +* allow keys to do sync sign/verify ([#2258](https://www.github.com/libp2p/js-libp2p/issues/2258)) ([dd7d17c](https://www.github.com/libp2p/js-libp2p/commit/dd7d17cc478dfcba02211a47789439b7d7ab9627)) +* remove event emitter type from interfaces ([#2196](https://www.github.com/libp2p/js-libp2p/issues/2196)) ([f3ec538](https://www.github.com/libp2p/js-libp2p/commit/f3ec538451afe105a5a4513d66832965ad63debe)) +* remove min/max from topologies ([#2158](https://www.github.com/libp2p/js-libp2p/issues/2158)) ([511359a](https://www.github.com/libp2p/js-libp2p/commit/511359a86235e7abe65887dce7262b34a53bad5a)) +* remove protocols from PeerInfo ([#2166](https://www.github.com/libp2p/js-libp2p/issues/2166)) ([5468cd1](https://www.github.com/libp2p/js-libp2p/commit/5468cd13a76281e46b221fdbd7d4005c0d3f2252)) + + +### Code Refactoring + +* extract DCUtR into separate module ([#2220](https://www.github.com/libp2p/js-libp2p/issues/2220)) ([d2c3e72](https://www.github.com/libp2p/js-libp2p/commit/d2c3e7235b64558c6cace414c54a42659fee2970)) +* extract identify service into separate module ([#2219](https://www.github.com/libp2p/js-libp2p/issues/2219)) ([72c2f77](https://www.github.com/libp2p/js-libp2p/commit/72c2f775bd85bd4928048dda0fd14740d6fb6a69)) +* extract UPnP NAT into separate module ([#2217](https://www.github.com/libp2p/js-libp2p/issues/2217)) ([f29b73f](https://www.github.com/libp2p/js-libp2p/commit/f29b73f781afcea36cba0589aafdd81e1852e194)) +* move autonat into separate package ([#2107](https://www.github.com/libp2p/js-libp2p/issues/2107)) ([b0e8f06](https://www.github.com/libp2p/js-libp2p/commit/b0e8f06f0dcdbda0e367186b093e42e8bff3ee27)) +* remove isStarted method from Startable ([#2145](https://www.github.com/libp2p/js-libp2p/issues/2145)) ([fca208f](https://www.github.com/libp2p/js-libp2p/commit/fca208f3763af041aa37b1cb915d2bc777acb96d)) +* remove libp2p.keychain ([#2084](https://www.github.com/libp2p/js-libp2p/issues/2084)) ([125c84b](https://www.github.com/libp2p/js-libp2p/commit/125c84bb8a30ac986fb5aed0a4de23bc806d3aea)) + ### [0.1.6](https://www.github.com/libp2p/js-libp2p/compare/interface-v0.1.5...interface-v0.1.6) (2023-11-07) diff --git a/packages/interface/README.md b/packages/interface/README.md index 96ea711780..8d3918e59b 100644 --- a/packages/interface/README.md +++ b/packages/interface/README.md @@ -5,6 +5,20 @@ > The interface implemented by a libp2p node +# About + +Exports a `Libp2p` type for modules to use as a type argument. + +## Example + +```typescript +import type { Libp2p } from '@libp2p/interface' + +function doSomethingWithLibp2p (node: Libp2p) { + // ... +} +``` + # Install ```console diff --git a/packages/interface/package.json b/packages/interface/package.json index 5b6f084303..d5aa035ea7 100644 --- a/packages/interface/package.json +++ b/packages/interface/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/interface", - "version": "0.1.6", + "version": "1.0.0", "description": "The interface implemented by a libp2p node", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface#readme", @@ -152,14 +152,7 @@ "clean": "aegir clean", "lint": "aegir lint", "dep-check": "aegir dep-check -i @libp2p/utils", - "build": "aegir build", - "test": "aegir test", - "test:chrome": "aegir test -t browser --cov", - "test:chrome-webworker": "aegir test -t webworker", - "test:firefox": "aegir test -t browser -- --browser firefox", - "test:firefox-webworker": "aegir test -t webworker -- --browser firefox", - "test:node": "aegir test -t node --cov", - "test:electron-main": "aegir test -t electron-main" + "build": "aegir build" }, "dependencies": { "@multiformats/multiaddr": "^12.1.10", @@ -169,10 +162,7 @@ "uint8arraylist": "^2.4.3" }, "devDependencies": { - "@types/sinon": "^17.0.0", - "aegir": "^41.0.2", - "sinon": "^17.0.0", - "sinon-ts": "^2.0.0" + "aegir": "^41.0.2" }, "browser": { "events": "./dist/src/events.browser.js" diff --git a/packages/interface/src/connection/index.ts b/packages/interface/src/connection/index.ts index 459a63bb16..ccbf3d6d04 100644 --- a/packages/interface/src/connection/index.ts +++ b/packages/interface/src/connection/index.ts @@ -280,10 +280,10 @@ export interface Connection { log: Logger } -export const symbol = Symbol.for('@libp2p/connection') +export const connectionSymbol = Symbol.for('@libp2p/connection') export function isConnection (other: any): other is Connection { - return other != null && Boolean(other[symbol]) + return other != null && Boolean(other[connectionSymbol]) } export interface ConnectionProtector { diff --git a/packages/interface/src/content-routing/index.ts b/packages/interface/src/content-routing/index.ts index 0d38d58143..d5695f265c 100644 --- a/packages/interface/src/content-routing/index.ts +++ b/packages/interface/src/content-routing/index.ts @@ -21,7 +21,7 @@ import type { CID } from 'multiformats/cid' * } * ``` */ -export const contentRouting = Symbol.for('@libp2p/content-routing') +export const contentRoutingSymbol = Symbol.for('@libp2p/content-routing') export interface ContentRouting { /** diff --git a/packages/interface/src/errors.ts b/packages/interface/src/errors.ts index 8a1a4dafeb..7793eccace 100644 --- a/packages/interface/src/errors.ts +++ b/packages/interface/src/errors.ts @@ -18,6 +18,10 @@ export class AbortError extends Error { static readonly type = 'aborted' } +/** + * An {@see Error } subclass that defines a `.code` property that calling code + * can use to detect what type of error has been thrown and act accordingly. + */ export class CodeError = Record> extends Error { public readonly props: T @@ -55,20 +59,22 @@ export class InvalidCryptoExchangeError extends Error { static readonly code = 'ERR_INVALID_CRYPTO_EXCHANGE' } -export class InvalidCryptoTransmissionError extends Error { - public code: string - - constructor (message = 'Invalid crypto transmission') { - super(message) - this.code = InvalidCryptoTransmissionError.code - } - - static readonly code = 'ERR_INVALID_CRYPTO_TRANSMISSION' -} - -// Error codes - +/** + * A generic error code indicating that a timeout occurred + */ export const ERR_TIMEOUT = 'ERR_TIMEOUT' + +/** + * A generic error code indicating that invalid paramters were passed + */ export const ERR_INVALID_PARAMETERS = 'ERR_INVALID_PARAMETERS' + +/** + * A generic error code indicating that something was not found + */ export const ERR_NOT_FOUND = 'ERR_NOT_FOUND' + +/** + * A generic error code indicating that the message was invalid + */ export const ERR_INVALID_MESSAGE = 'ERR_INVALID_MESSAGE' diff --git a/packages/interface/src/index.ts b/packages/interface/src/index.ts index 2389ffc1e3..d81783da65 100644 --- a/packages/interface/src/index.ts +++ b/packages/interface/src/index.ts @@ -660,3 +660,25 @@ export interface LoggerOptions { export type RecursivePartial = { [P in keyof T]?: T[P] extends Array ? Array> : T[P] extends (...args: any[]) => any ? T[P] : RecursivePartial } + +export * from './connection/index.js' +export * from './connection-encrypter/index.js' +export * from './connection-gater/index.js' +export * from './content-routing/index.js' +export * from './keys/index.js' +export * from './metrics/index.js' +export * from './peer-discovery/index.js' +export * from './peer-id/index.js' +export * from './peer-info/index.js' +export * from './peer-routing/index.js' +export * from './peer-store/index.js' +export * from './peer-store/tags.js' +export * from './pubsub/index.js' +export * from './record/index.js' +export * from './stream-handler/index.js' +export * from './stream-muxer/index.js' +export * from './topology/index.js' +export * from './transport/index.js' +export * from './errors.js' +export * from './events.js' +export * from './startable.js' diff --git a/packages/interface/src/peer-discovery/index.ts b/packages/interface/src/peer-discovery/index.ts index 55b1227eb1..5ecd082184 100644 --- a/packages/interface/src/peer-discovery/index.ts +++ b/packages/interface/src/peer-discovery/index.ts @@ -20,7 +20,7 @@ import type { PeerInfo } from '../peer-info/index.js' * } * ``` */ -export const peerDiscovery = Symbol.for('@libp2p/peer-discovery') +export const peerDiscoverySymbol = Symbol.for('@libp2p/peer-discovery') export interface PeerDiscoveryEvents { 'peer': CustomEvent diff --git a/packages/interface/src/peer-id/index.ts b/packages/interface/src/peer-id/index.ts index 931c34bc87..1ee6dee4ac 100644 --- a/packages/interface/src/peer-id/index.ts +++ b/packages/interface/src/peer-id/index.ts @@ -32,8 +32,8 @@ export interface Secp256k1PeerId extends BasePeerId { export type PeerId = RSAPeerId | Ed25519PeerId | Secp256k1PeerId -export const symbol = Symbol.for('@libp2p/peer-id') +export const peerIdSymbol = Symbol.for('@libp2p/peer-id') export function isPeerId (other: any): other is PeerId { - return other != null && Boolean(other[symbol]) + return other != null && Boolean(other[peerIdSymbol]) } diff --git a/packages/interface/src/peer-routing/index.ts b/packages/interface/src/peer-routing/index.ts index dcaa68eaa2..3db378ee6c 100644 --- a/packages/interface/src/peer-routing/index.ts +++ b/packages/interface/src/peer-routing/index.ts @@ -21,7 +21,7 @@ import type { PeerInfo } from '../peer-info/index.js' * } * ``` */ -export const peerRouting = Symbol.for('@libp2p/peer-routing') +export const peerRoutingSymbol = Symbol.for('@libp2p/peer-routing') export interface PeerRouting { /** diff --git a/packages/interface/src/startable.ts b/packages/interface/src/startable.ts index 7923b1d557..69bbcc0ba5 100644 --- a/packages/interface/src/startable.ts +++ b/packages/interface/src/startable.ts @@ -49,6 +49,10 @@ export function isStartable (obj: any): obj is Startable { return obj != null && typeof obj.start === 'function' && typeof obj.stop === 'function' } +/** + * Start one or more {@link Startable}s, calling the `beforeStart` and + * `afterStart` lifecycle methods if defined. + */ export async function start (...objs: any[]): Promise { const startables: Startable[] = [] @@ -81,6 +85,10 @@ export async function start (...objs: any[]): Promise { ) } +/** + * Stop one or more {@link Startable}s, calling the `beforeStop` and + * `afterStop` lifecycle methods if defined. + */ export async function stop (...objs: any[]): Promise { const startables: Startable[] = [] diff --git a/packages/interface/src/transport/index.ts b/packages/interface/src/transport/index.ts index 22ab1a803b..ac22d201fe 100644 --- a/packages/interface/src/transport/index.ts +++ b/packages/interface/src/transport/index.ts @@ -28,7 +28,7 @@ export interface Listener extends TypedEventTarget { close(): Promise } -export const symbol = Symbol.for('@libp2p/transport') +export const transportSymbol = Symbol.for('@libp2p/transport') export interface ConnectionHandler { (connection: Connection): void } @@ -55,7 +55,7 @@ export interface Transport { /** * Used by the isTransport function */ - [symbol]: true + [transportSymbol]: true /** * Dial a given multiaddr. @@ -74,7 +74,7 @@ export interface Transport { } export function isTransport (other: any): other is Transport { - return other != null && Boolean(other[symbol]) + return other != null && Boolean(other[transportSymbol]) } /** diff --git a/packages/interface/typedoc.json b/packages/interface/typedoc.json index be7e86d431..f599dc728d 100644 --- a/packages/interface/typedoc.json +++ b/packages/interface/typedoc.json @@ -1,28 +1,5 @@ { "entryPoints": [ - "./src/index.ts", - "./src/connection/index.ts", - "./src/connection-encrypter/index.ts", - "./src/connection-gater/index.ts", - "./src/content-routing/index.ts", - "./src/errors.ts", - "./src/events.ts", - "./src/keychain/index.ts", - "./src/keys/index.ts", - "./src/metrics/index.ts", - "./src/metrics/tracked-map.ts", - "./src/peer-discovery/index.ts", - "./src/peer-id/index.ts", - "./src/peer-info/index.ts", - "./src/peer-routing/index.ts", - "./src/peer-store/index.ts", - "./src/peer-store/tags.ts", - "./src/pubsub/index.ts", - "./src/record/index.ts", - "./src/startable.ts", - "./src/stream-handler/index.ts", - "./src/stream-muxer/index.ts", - "./src/stream-muxer/stream.ts", - "./src/transport/index.ts" + "./src/index.ts" ] } diff --git a/packages/kad-dht/CHANGELOG.md b/packages/kad-dht/CHANGELOG.md index 1c29d14721..fb654845ef 100644 --- a/packages/kad-dht/CHANGELOG.md +++ b/packages/kad-dht/CHANGELOG.md @@ -5,6 +5,34 @@ * skip self-query if not running ([#479](https://github.com/libp2p/js-libp2p-kad-dht/issues/479)) ([7095290](https://github.com/libp2p/js-libp2p-kad-dht/commit/70952907a27fd8778773172059879656b4f08855)) +## [11.0.0](https://www.github.com/libp2p/js-libp2p/compare/kad-dht-v10.0.15...kad-dht-v11.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `.protocols` property has been removed from the `PeerInfo` interface + +### Bug Fixes + +* remove protocols from PeerInfo ([#2166](https://www.github.com/libp2p/js-libp2p/issues/2166)) ([5468cd1](https://www.github.com/libp2p/js-libp2p/commit/5468cd13a76281e46b221fdbd7d4005c0d3f2252)) +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/crypto bumped from ^2.0.8 to ^3.0.0 + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.9 to ^0.1.10 + * @libp2p/peer-collections bumped from ^4.0.8 to ^4.0.9 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + * @libp2p/peer-store bumped from ^9.0.9 to ^9.0.10 + ### [10.0.15](https://www.github.com/libp2p/js-libp2p/compare/kad-dht-v10.0.14...kad-dht-v10.0.15) (2023-11-10) @@ -1903,4 +1931,4 @@ Co-Authored-By: vasco-santos ### Features -* v0.1.0 ([4bd1fbc](https://github.com/libp2p/js-libp2p-kad-dht/commit/4bd1fbc)) +* v0.1.0 ([4bd1fbc](https://github.com/libp2p/js-libp2p-kad-dht/commit/4bd1fbc)) \ No newline at end of file diff --git a/packages/kad-dht/package.json b/packages/kad-dht/package.json index 1adc96402f..bf3ccfb64a 100644 --- a/packages/kad-dht/package.json +++ b/packages/kad-dht/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/kad-dht", - "version": "10.0.15", + "version": "11.0.0", "description": "JavaScript implementation of the Kad-DHT for libp2p", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/kad-dht#readme", @@ -56,11 +56,11 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "@libp2p/crypto": "^2.0.8", - "@libp2p/interface": "^0.1.6", - "@libp2p/interface-internal": "^0.1.9", - "@libp2p/peer-collections": "^4.0.8", - "@libp2p/peer-id": "^3.0.6", + "@libp2p/crypto": "^3.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/peer-collections": "^4.0.9", + "@libp2p/peer-id": "^4.0.0", "@multiformats/multiaddr": "^12.1.10", "@types/sinon": "^17.0.0", "any-signal": "^4.1.1", @@ -91,10 +91,10 @@ "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", - "@libp2p/peer-store": "^9.0.9", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", + "@libp2p/peer-store": "^9.0.10", "@types/lodash.random": "^3.2.6", "@types/lodash.range": "^3.2.6", "@types/which": "^3.0.0", @@ -110,7 +110,7 @@ "p-wait-for": "^5.0.2", "protons": "^7.3.0", "sinon": "^17.0.0", - "ts-sinon": "^2.0.2", + "sinon-ts": "^2.0.0", "wherearewe": "^2.0.1", "which": "^4.0.0" }, diff --git a/packages/kad-dht/src/content-fetching/index.ts b/packages/kad-dht/src/content-fetching/index.ts index 32ac26b8a5..32c2d87ff7 100644 --- a/packages/kad-dht/src/content-fetching/index.ts +++ b/packages/kad-dht/src/content-fetching/index.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import map from 'it-map' import parallel from 'it-parallel' import { pipe } from 'it-pipe' diff --git a/packages/kad-dht/src/content-routing/index.ts b/packages/kad-dht/src/content-routing/index.ts index a402b6c1a6..22e433b242 100644 --- a/packages/kad-dht/src/content-routing/index.ts +++ b/packages/kad-dht/src/content-routing/index.ts @@ -15,8 +15,7 @@ import type { Providers } from '../providers.js' import type { QueryManager } from '../query/manager.js' import type { QueryFunc } from '../query/types.js' import type { RoutingTable } from '../routing-table/index.js' -import type { Logger } from '@libp2p/interface' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { Logger, PeerInfo } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' import type { CID } from 'multiformats/cid' diff --git a/packages/kad-dht/src/dual-kad-dht.ts b/packages/kad-dht/src/dual-kad-dht.ts index 2f2ca548c9..bb6242f4a1 100644 --- a/packages/kad-dht/src/dual-kad-dht.ts +++ b/packages/kad-dht/src/dual-kad-dht.ts @@ -1,17 +1,11 @@ -import { type ContentRouting, contentRouting } from '@libp2p/interface/content-routing' -import { CodeError } from '@libp2p/interface/errors' -import { TypedEventEmitter, CustomEvent } from '@libp2p/interface/events' -import { type PeerDiscovery, peerDiscovery, type PeerDiscoveryEvents } from '@libp2p/interface/peer-discovery' -import { type PeerRouting, peerRouting } from '@libp2p/interface/peer-routing' +import { type ContentRouting, contentRoutingSymbol, type PeerDiscovery, peerDiscoverySymbol, type PeerDiscoveryEvents, type PeerRouting, peerRoutingSymbol, type Logger, type PeerId, type PeerInfo } from '@libp2p/interface' +import { CodeError, TypedEventEmitter, CustomEvent } from '@libp2p/interface' import drain from 'it-drain' import merge from 'it-merge' import isPrivate from 'private-ip' import { DefaultKadDHT } from './kad-dht.js' import { queryErrorEvent } from './query/events.js' import type { DualKadDHT, KadDHT, KadDHTComponents, KadDHTInit, QueryEvent, QueryOptions } from './index.js' -import type { Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' import type { Multiaddr } from '@multiformats/multiaddr' import type { CID } from 'multiformats/cid' @@ -185,15 +179,15 @@ export class DefaultDualKadDHT extends TypedEventEmitter im readonly [Symbol.toStringTag] = '@libp2p/dual-kad-dht' - get [contentRouting] (): ContentRouting { + get [contentRoutingSymbol] (): ContentRouting { return this.contentRouting } - get [peerRouting] (): PeerRouting { + get [peerRoutingSymbol] (): PeerRouting { return this.peerRouting } - get [peerDiscovery] (): PeerDiscovery { + get [peerDiscoverySymbol] (): PeerDiscovery { return this } diff --git a/packages/kad-dht/src/index.ts b/packages/kad-dht/src/index.ts index 2849207c1b..d2c5c4fe72 100644 --- a/packages/kad-dht/src/index.ts +++ b/packages/kad-dht/src/index.ts @@ -1,14 +1,7 @@ import { DefaultDualKadDHT } from './dual-kad-dht.js' import type { ProvidersInit } from './providers.js' -import type { Libp2pEvents, AbortOptions, ComponentLogger } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { Libp2pEvents, AbortOptions, ComponentLogger, TypedEventTarget, Metrics, PeerId, PeerInfo, PeerStore } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal' import type { Datastore } from 'interface-datastore' import type { CID } from 'multiformats/cid' import type { ProgressOptions, ProgressEvent } from 'progress-events' diff --git a/packages/kad-dht/src/kad-dht.ts b/packages/kad-dht/src/kad-dht.ts index 85de6ff3ba..8bf2dd759a 100644 --- a/packages/kad-dht/src/kad-dht.ts +++ b/packages/kad-dht/src/kad-dht.ts @@ -1,4 +1,4 @@ -import { CustomEvent, TypedEventEmitter } from '@libp2p/interface/events' +import { CustomEvent, TypedEventEmitter } from '@libp2p/interface' import pDefer from 'p-defer' import { PROTOCOL_DHT, PROTOCOL_PREFIX, LAN_PREFIX } from './constants.js' import { ContentFetching } from './content-fetching/index.js' @@ -19,10 +19,7 @@ import { removePublicAddresses } from './utils.js' import type { KadDHTComponents, KadDHTInit, QueryOptions, Validators, Selectors, KadDHT, QueryEvent } from './index.js' -import type { Logger } from '@libp2p/interface' -import type { PeerDiscoveryEvents } from '@libp2p/interface/peer-discovery' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { Logger, PeerDiscoveryEvents, PeerId, PeerInfo } from '@libp2p/interface' import type { CID } from 'multiformats/cid' export const DEFAULT_MAX_INBOUND_STREAMS = 32 diff --git a/packages/kad-dht/src/message/index.ts b/packages/kad-dht/src/message/index.ts index cc82d610f0..2f3ca3b7c6 100644 --- a/packages/kad-dht/src/message/index.ts +++ b/packages/kad-dht/src/message/index.ts @@ -2,7 +2,7 @@ import { peerIdFromBytes } from '@libp2p/peer-id' import { multiaddr } from '@multiformats/multiaddr' import { Libp2pRecord } from '../record/index.js' import { Message as PBMessage } from './dht.js' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { PeerInfo } from '@libp2p/interface' import type { Uint8ArrayList } from 'uint8arraylist' export const MESSAGE_TYPE = PBMessage.MessageType diff --git a/packages/kad-dht/src/network.ts b/packages/kad-dht/src/network.ts index f790763afa..46dfa71251 100644 --- a/packages/kad-dht/src/network.ts +++ b/packages/kad-dht/src/network.ts @@ -1,4 +1,4 @@ -import { TypedEventEmitter, CustomEvent } from '@libp2p/interface/events' +import { TypedEventEmitter, CustomEvent } from '@libp2p/interface' import { pbStream } from 'it-protobuf-stream' import { Message } from './message/index.js' import { @@ -8,11 +8,7 @@ import { queryErrorEvent } from './query/events.js' import type { KadDHTComponents, QueryEvent, QueryOptions } from './index.js' -import type { AbortOptions, Logger } from '@libp2p/interface' -import type { Stream } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { Startable } from '@libp2p/interface/startable' +import type { AbortOptions, Logger, Stream, PeerId, PeerInfo, Startable } from '@libp2p/interface' export interface NetworkInit { protocol: string diff --git a/packages/kad-dht/src/peer-list/index.ts b/packages/kad-dht/src/peer-list/index.ts index 25024a2966..104d75a07d 100644 --- a/packages/kad-dht/src/peer-list/index.ts +++ b/packages/kad-dht/src/peer-list/index.ts @@ -1,4 +1,4 @@ -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' /** * A list of unique peers. diff --git a/packages/kad-dht/src/peer-list/peer-distance-list.ts b/packages/kad-dht/src/peer-list/peer-distance-list.ts index eff3d80485..93df4a374b 100644 --- a/packages/kad-dht/src/peer-list/peer-distance-list.ts +++ b/packages/kad-dht/src/peer-list/peer-distance-list.ts @@ -1,7 +1,7 @@ import { compare as uint8ArrayCompare } from 'uint8arrays/compare' import { xor as uint8ArrayXor } from 'uint8arrays/xor' import * as utils from '../utils.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' interface PeerDistance { peerId: PeerId diff --git a/packages/kad-dht/src/peer-routing/index.ts b/packages/kad-dht/src/peer-routing/index.ts index 28e9da8eb2..6ff115c59a 100644 --- a/packages/kad-dht/src/peer-routing/index.ts +++ b/packages/kad-dht/src/peer-routing/index.ts @@ -1,5 +1,5 @@ import { keys } from '@libp2p/crypto' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { peerIdFromKeys } from '@libp2p/peer-id' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { Message, MESSAGE_TYPE } from '../message/index.js' @@ -17,9 +17,7 @@ import type { Network } from '../network.js' import type { QueryManager, QueryOptions } from '../query/manager.js' import type { QueryFunc } from '../query/types.js' import type { RoutingTable } from '../routing-table/index.js' -import type { AbortOptions, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { AbortOptions, Logger, PeerId, PeerInfo } from '@libp2p/interface' import type { PeerStore } from '@libp2p/interface/src/peer-store/index.js' export interface PeerRoutingInit { diff --git a/packages/kad-dht/src/providers.ts b/packages/kad-dht/src/providers.ts index 29fa66fb7f..e7c6a9439b 100644 --- a/packages/kad-dht/src/providers.ts +++ b/packages/kad-dht/src/providers.ts @@ -10,9 +10,7 @@ import { PROVIDERS_LRU_CACHE_SIZE, PROVIDER_KEY_PREFIX } from './constants.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Startable } from '@libp2p/interface/startable' +import type { ComponentLogger, Logger, PeerId, Startable } from '@libp2p/interface' import type { Datastore } from 'interface-datastore' import type { CID } from 'multiformats' diff --git a/packages/kad-dht/src/query-self.ts b/packages/kad-dht/src/query-self.ts index b595bc03f6..d0d5ae17f8 100644 --- a/packages/kad-dht/src/query-self.ts +++ b/packages/kad-dht/src/query-self.ts @@ -1,4 +1,4 @@ -import { setMaxListeners } from '@libp2p/interface/events' +import { setMaxListeners } from '@libp2p/interface' import { anySignal } from 'any-signal' import length from 'it-length' import { pipe } from 'it-pipe' @@ -8,9 +8,7 @@ import { pEvent } from 'p-event' import { QUERY_SELF_INTERVAL, QUERY_SELF_TIMEOUT, K, QUERY_SELF_INITIAL_INTERVAL } from './constants.js' import type { PeerRouting } from './peer-routing/index.js' import type { RoutingTable } from './routing-table/index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Startable } from '@libp2p/interface/startable' +import type { ComponentLogger, Logger, PeerId, Startable } from '@libp2p/interface' import type { DeferredPromise } from 'p-defer' export interface QuerySelfInit { diff --git a/packages/kad-dht/src/query/events.ts b/packages/kad-dht/src/query/events.ts index b55c2edd5e..40c28bd397 100644 --- a/packages/kad-dht/src/query/events.ts +++ b/packages/kad-dht/src/query/events.ts @@ -1,10 +1,9 @@ -import { CustomEvent } from '@libp2p/interface/events' +import { CustomEvent } from '@libp2p/interface' import { MESSAGE_TYPE_LOOKUP } from '../message/index.js' import type { SendQueryEvent, PeerResponseEvent, DialPeerEvent, AddPeerEvent, ValueEvent, ProviderEvent, QueryErrorEvent, FinalPeerEvent, QueryOptions } from '../index.js' import type { Message } from '../message/dht.js' import type { Libp2pRecord } from '../record/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { PeerId, PeerInfo } from '@libp2p/interface' export interface QueryEventFields { to: PeerId diff --git a/packages/kad-dht/src/query/manager.ts b/packages/kad-dht/src/query/manager.ts index c223e7e07b..9e2ab435ff 100644 --- a/packages/kad-dht/src/query/manager.ts +++ b/packages/kad-dht/src/query/manager.ts @@ -1,5 +1,4 @@ -import { AbortError } from '@libp2p/interface/errors' -import { TypedEventEmitter, CustomEvent, setMaxListeners } from '@libp2p/interface/events' +import { AbortError, TypedEventEmitter, CustomEvent, setMaxListeners } from '@libp2p/interface' import { PeerSet } from '@libp2p/peer-collections' import { anySignal } from 'any-signal' import merge from 'it-merge' @@ -12,10 +11,7 @@ import { queryPath } from './query-path.js' import type { QueryFunc } from './types.js' import type { QueryEvent, QueryOptions as RootQueryOptions } from '../index.js' import type { RoutingTable } from '../routing-table/index.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { Metric, Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Startable } from '@libp2p/interface/startable' +import type { ComponentLogger, Metric, Metrics, PeerId, Startable } from '@libp2p/interface' import type { DeferredPromise } from 'p-defer' export interface CleanUpEvents { diff --git a/packages/kad-dht/src/query/query-path.ts b/packages/kad-dht/src/query/query-path.ts index 8a8db6ff9a..79c2285992 100644 --- a/packages/kad-dht/src/query/query-path.ts +++ b/packages/kad-dht/src/query/query-path.ts @@ -8,9 +8,7 @@ import { queueToGenerator } from './utils.js' import type { CleanUpEvents } from './manager.js' import type { QueryEvent, QueryOptions } from '../index.js' import type { QueryFunc } from '../query/types.js' -import type { Logger } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { Logger, TypedEventTarget, PeerId } from '@libp2p/interface' import type { PeerSet } from '@libp2p/peer-collections' const MAX_XOR = BigInt('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF') diff --git a/packages/kad-dht/src/query/types.ts b/packages/kad-dht/src/query/types.ts index a764aa50c0..1705f1b5b1 100644 --- a/packages/kad-dht/src/query/types.ts +++ b/packages/kad-dht/src/query/types.ts @@ -1,5 +1,5 @@ import type { QueryEvent } from '../index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' export interface QueryContext { // the key we are looking up diff --git a/packages/kad-dht/src/query/utils.ts b/packages/kad-dht/src/query/utils.ts index 4b2fc93deb..c329119ef9 100644 --- a/packages/kad-dht/src/query/utils.ts +++ b/packages/kad-dht/src/query/utils.ts @@ -1,9 +1,8 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { pushable } from 'it-pushable' import type { CleanUpEvents } from './manager.js' import type { QueryEvent } from '../index.js' -import type { Logger } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' +import type { Logger, TypedEventTarget } from '@libp2p/interface' import type Queue from 'p-queue' export async function * queueToGenerator (queue: Queue, signal: AbortSignal, cleanUp: TypedEventTarget, log: Logger): AsyncGenerator { diff --git a/packages/kad-dht/src/record/selectors.ts b/packages/kad-dht/src/record/selectors.ts index 825af34154..710a4301a4 100644 --- a/packages/kad-dht/src/record/selectors.ts +++ b/packages/kad-dht/src/record/selectors.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import type { Selectors } from '../index.js' diff --git a/packages/kad-dht/src/record/validators.ts b/packages/kad-dht/src/record/validators.ts index a31e09b550..7af8b36602 100644 --- a/packages/kad-dht/src/record/validators.ts +++ b/packages/kad-dht/src/record/validators.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { sha256 } from 'multiformats/hashes/sha2' import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' diff --git a/packages/kad-dht/src/routing-table/index.ts b/packages/kad-dht/src/routing-table/index.ts index 14c646aee9..adcdf7d3ce 100644 --- a/packages/kad-dht/src/routing-table/index.ts +++ b/packages/kad-dht/src/routing-table/index.ts @@ -1,14 +1,10 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { PeerSet } from '@libp2p/peer-collections' import Queue from 'p-queue' import * as utils from '../utils.js' import { KBucket, type PingEventDetails } from './k-bucket.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Metric, Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' +import type { ComponentLogger, Logger, Metric, Metrics, PeerId, PeerStore, Startable } from '@libp2p/interface' +import type { ConnectionManager } from '@libp2p/interface-internal' export const KAD_CLOSE_TAG_NAME = 'kad-close' export const KAD_CLOSE_TAG_VALUE = 50 diff --git a/packages/kad-dht/src/routing-table/k-bucket.ts b/packages/kad-dht/src/routing-table/k-bucket.ts index 57585926e9..0f52068e6d 100644 --- a/packages/kad-dht/src/routing-table/k-bucket.ts +++ b/packages/kad-dht/src/routing-table/k-bucket.ts @@ -27,8 +27,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import { TypedEventEmitter } from '@libp2p/interface/events' -import type { PeerId } from '@libp2p/interface/peer-id' +import { TypedEventEmitter } from '@libp2p/interface' +import type { PeerId } from '@libp2p/interface' function arrayEquals (array1: Uint8Array, array2: Uint8Array): boolean { if (array1 === array2) { diff --git a/packages/kad-dht/src/routing-table/refresh.ts b/packages/kad-dht/src/routing-table/refresh.ts index 6732354eee..6a2c183886 100644 --- a/packages/kad-dht/src/routing-table/refresh.ts +++ b/packages/kad-dht/src/routing-table/refresh.ts @@ -7,8 +7,7 @@ import { TABLE_REFRESH_INTERVAL, TABLE_REFRESH_QUERY_TIMEOUT } from '../constant import GENERATED_PREFIXES from './generated-prefix-list.js' import type { RoutingTable } from './index.js' import type { PeerRouting } from '../peer-routing/index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { ComponentLogger, Logger, PeerId } from '@libp2p/interface' /** * Cannot generate random KadIds longer than this + 1 diff --git a/packages/kad-dht/src/rpc/handlers/add-provider.ts b/packages/kad-dht/src/rpc/handlers/add-provider.ts index b30785d5bd..f2dd3a3c43 100644 --- a/packages/kad-dht/src/rpc/handlers/add-provider.ts +++ b/packages/kad-dht/src/rpc/handlers/add-provider.ts @@ -1,10 +1,9 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { CID } from 'multiformats/cid' import type { Message } from '../../message/index.js' import type { Providers } from '../../providers' import type { DHTMessageHandler } from '../index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { ComponentLogger, Logger, PeerId } from '@libp2p/interface' export interface AddProviderComponents { logger: ComponentLogger diff --git a/packages/kad-dht/src/rpc/handlers/find-node.ts b/packages/kad-dht/src/rpc/handlers/find-node.ts index 5608f65c4e..a18713d9c8 100644 --- a/packages/kad-dht/src/rpc/handlers/find-node.ts +++ b/packages/kad-dht/src/rpc/handlers/find-node.ts @@ -7,10 +7,8 @@ import { } from '../../utils.js' import type { PeerRouting } from '../../peer-routing/index.js' import type { DHTMessageHandler } from '../index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' +import type { ComponentLogger, Logger, PeerId, PeerInfo } from '@libp2p/interface' +import type { AddressManager } from '@libp2p/interface-internal' export interface FindNodeHandlerInit { peerRouting: PeerRouting diff --git a/packages/kad-dht/src/rpc/handlers/get-providers.ts b/packages/kad-dht/src/rpc/handlers/get-providers.ts index 725b5d287d..96cf040f1c 100644 --- a/packages/kad-dht/src/rpc/handlers/get-providers.ts +++ b/packages/kad-dht/src/rpc/handlers/get-providers.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { CID } from 'multiformats/cid' import { Message } from '../../message/index.js' import { @@ -8,10 +8,7 @@ import { import type { PeerRouting } from '../../peer-routing/index.js' import type { Providers } from '../../providers.js' import type { DHTMessageHandler } from '../index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { ComponentLogger, Logger, PeerId, PeerInfo, PeerStore } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' export interface GetProvidersHandlerInit { diff --git a/packages/kad-dht/src/rpc/handlers/get-value.ts b/packages/kad-dht/src/rpc/handlers/get-value.ts index d53c9691dd..50475bf191 100644 --- a/packages/kad-dht/src/rpc/handlers/get-value.ts +++ b/packages/kad-dht/src/rpc/handlers/get-value.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { MAX_RECORD_AGE } from '../../constants.js' @@ -7,9 +7,7 @@ import { Libp2pRecord } from '../../record/index.js' import { bufferToRecordKey, isPublicKeyKey, fromPublicKeyKey } from '../../utils.js' import type { PeerRouting } from '../../peer-routing/index.js' import type { DHTMessageHandler } from '../index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { ComponentLogger, Logger, PeerId, PeerStore } from '@libp2p/interface' import type { Datastore } from 'interface-datastore' export interface GetValueHandlerInit { diff --git a/packages/kad-dht/src/rpc/handlers/ping.ts b/packages/kad-dht/src/rpc/handlers/ping.ts index 06a6d50ada..1a63aad153 100644 --- a/packages/kad-dht/src/rpc/handlers/ping.ts +++ b/packages/kad-dht/src/rpc/handlers/ping.ts @@ -1,7 +1,6 @@ import type { Message } from '../../message/index.js' import type { DHTMessageHandler } from '../index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { ComponentLogger, Logger, PeerId } from '@libp2p/interface' export interface PingComponents { logger: ComponentLogger diff --git a/packages/kad-dht/src/rpc/handlers/put-value.ts b/packages/kad-dht/src/rpc/handlers/put-value.ts index f466d7bc1a..9fe1fe76e4 100644 --- a/packages/kad-dht/src/rpc/handlers/put-value.ts +++ b/packages/kad-dht/src/rpc/handlers/put-value.ts @@ -1,11 +1,10 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { verifyRecord } from '../../record/validators.js' import { bufferToRecordKey } from '../../utils.js' import type { Validators } from '../../index.js' import type { Message } from '../../message/index.js' import type { DHTMessageHandler } from '../index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { ComponentLogger, Logger, PeerId } from '@libp2p/interface' import type { Datastore } from 'interface-datastore' export interface PutValueHandlerInit { diff --git a/packages/kad-dht/src/rpc/index.ts b/packages/kad-dht/src/rpc/index.ts index c90703dfc0..8a77a1730b 100644 --- a/packages/kad-dht/src/rpc/index.ts +++ b/packages/kad-dht/src/rpc/index.ts @@ -11,9 +11,8 @@ import type { Validators } from '../index.js' import type { PeerRouting } from '../peer-routing' import type { Providers } from '../providers' import type { RoutingTable } from '../routing-table' -import type { Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { IncomingStreamData } from '@libp2p/interface-internal/registrar' +import type { Logger, PeerId } from '@libp2p/interface' +import type { IncomingStreamData } from '@libp2p/interface-internal' export interface DHTMessageHandler { handle(peerId: PeerId, msg: Message): Promise diff --git a/packages/kad-dht/src/topology-listener.ts b/packages/kad-dht/src/topology-listener.ts index a232ffaf50..cab72514b1 100644 --- a/packages/kad-dht/src/topology-listener.ts +++ b/packages/kad-dht/src/topology-listener.ts @@ -1,8 +1,6 @@ -import { CustomEvent, TypedEventEmitter } from '@libp2p/interface/events' +import { CustomEvent, TypedEventEmitter } from '@libp2p/interface' import type { KadDHTComponents } from '.' -import type { Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Startable } from '@libp2p/interface/startable' +import type { Logger, PeerId, Startable } from '@libp2p/interface' export interface TopologyListenerInit { protocol: string diff --git a/packages/kad-dht/src/utils.ts b/packages/kad-dht/src/utils.ts index 5ee8a06b4c..583c552253 100644 --- a/packages/kad-dht/src/utils.ts +++ b/packages/kad-dht/src/utils.ts @@ -7,8 +7,7 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { RECORD_KEY_PREFIX } from './constants.js' import { Libp2pRecord } from './record/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { PeerId, PeerInfo } from '@libp2p/interface' // const IPNS_PREFIX = uint8ArrayFromString('/ipns/') const PK_PREFIX = uint8ArrayFromString('/pk/') diff --git a/packages/kad-dht/test/generate-peers/generate-peers.node.ts b/packages/kad-dht/test/generate-peers/generate-peers.node.ts index 0c5d1af038..5f482ae3ac 100644 --- a/packages/kad-dht/test/generate-peers/generate-peers.node.ts +++ b/packages/kad-dht/test/generate-peers/generate-peers.node.ts @@ -5,7 +5,7 @@ import { defaultLogger } from '@libp2p/logger' import { createRSAPeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' import { execa } from 'execa' -import { stubInterface } from 'ts-sinon' +import { stubInterface } from 'sinon-ts' import { toString as uintArrayToString } from 'uint8arrays/to-string' import which from 'which' import { RoutingTable } from '../../src/routing-table/index.js' @@ -13,8 +13,8 @@ import { RoutingTableRefresh } from '../../src/routing-table/refresh.js' import { convertPeerId } from '../../src/utils.js' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' +import type { PeerStore } from '@libp2p/interface' +import type { ConnectionManager } from '@libp2p/interface-internal' const dirname = path.dirname(fileURLToPath(import.meta.url)) diff --git a/packages/kad-dht/test/kad-dht.spec.ts b/packages/kad-dht/test/kad-dht.spec.ts index b3ec84dd4f..ef6750c91c 100644 --- a/packages/kad-dht/test/kad-dht.spec.ts +++ b/packages/kad-dht/test/kad-dht.spec.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ /* eslint max-nested-callbacks: ["error", 8] */ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { expect } from 'aegir/chai' import delay from 'delay' import all from 'it-all' @@ -25,7 +25,7 @@ import { countDiffPeers } from './utils/index.js' import { sortClosestPeers } from './utils/sort-closest-peers.js' import { TestDHT } from './utils/test-dht.js' import type { DefaultDualKadDHT } from '../src/dual-kad-dht.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { CID } from 'multiformats/cid' async function findEvent (events: AsyncIterable, name: 'FINAL_PEER'): Promise diff --git a/packages/kad-dht/test/message.node.ts b/packages/kad-dht/test/message.node.ts index 5521e8669d..20bb8729ac 100644 --- a/packages/kad-dht/test/message.node.ts +++ b/packages/kad-dht/test/message.node.ts @@ -2,7 +2,7 @@ import fs from 'fs' import path from 'path' -import { isPeerId } from '@libp2p/interface/peer-id' +import { isPeerId } from '@libp2p/interface' import { expect } from 'aegir/chai' import range from 'lodash.range' import { Message } from '../src/message/index.js' diff --git a/packages/kad-dht/test/network.spec.ts b/packages/kad-dht/test/network.spec.ts index c7a7779c7a..395ab0c138 100644 --- a/packages/kad-dht/test/network.spec.ts +++ b/packages/kad-dht/test/network.spec.ts @@ -9,8 +9,7 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { Message, MESSAGE_TYPE } from '../src/message/index.js' import { TestDHT } from './utils/test-dht.js' import type { DefaultDualKadDHT } from '../src/dual-kad-dht.js' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { Connection, PeerId } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' import type { Sink, Source } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/kad-dht/test/peer-list.spec.ts b/packages/kad-dht/test/peer-list.spec.ts index 3eec30d022..e82710008c 100644 --- a/packages/kad-dht/test/peer-list.spec.ts +++ b/packages/kad-dht/test/peer-list.spec.ts @@ -3,7 +3,7 @@ import { expect } from 'aegir/chai' import { PeerList } from '../src/peer-list/index.js' import { createPeerIds } from './utils/create-peer-id.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' describe('PeerList', () => { let peers: PeerId[] diff --git a/packages/kad-dht/test/providers.spec.ts b/packages/kad-dht/test/providers.spec.ts index 2fa0951a3d..dbb094c146 100644 --- a/packages/kad-dht/test/providers.spec.ts +++ b/packages/kad-dht/test/providers.spec.ts @@ -9,7 +9,7 @@ import { sha256 } from 'multiformats/hashes/sha2' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { Providers } from '../src/providers.js' import { createPeerIds } from './utils/create-peer-id.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' describe('Providers', () => { let peers: PeerId[] diff --git a/packages/kad-dht/test/query-self.spec.ts b/packages/kad-dht/test/query-self.spec.ts index 8bae6d8418..b7b7d72f12 100644 --- a/packages/kad-dht/test/query-self.spec.ts +++ b/packages/kad-dht/test/query-self.spec.ts @@ -1,16 +1,16 @@ /* eslint-env mocha */ -import { CustomEvent } from '@libp2p/interface/events' +import { CustomEvent } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' import pDefer from 'p-defer' -import { stubInterface, type StubbedInstance } from 'ts-sinon' +import { stubInterface, type StubbedInstance } from 'sinon-ts' import { finalPeerEvent } from '../src/query/events.js' import { QuerySelf } from '../src/query-self.js' import type { PeerRouting } from '../src/peer-routing/index.js' import type { RoutingTable } from '../src/routing-table/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { DeferredPromise } from 'p-defer' describe('Query Self', () => { diff --git a/packages/kad-dht/test/query.spec.ts b/packages/kad-dht/test/query.spec.ts index f5c72a360a..2715119ee9 100644 --- a/packages/kad-dht/test/query.spec.ts +++ b/packages/kad-dht/test/query.spec.ts @@ -6,7 +6,7 @@ import delay from 'delay' import all from 'it-all' import drain from 'it-drain' import pDefer from 'p-defer' -import { type StubbedInstance, stubInterface } from 'ts-sinon' +import { type StubbedInstance, stubInterface } from 'sinon-ts' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { EventTypes, type QueryEvent } from '../src/index.js' import { MESSAGE_TYPE } from '../src/message/index.js' @@ -21,7 +21,7 @@ import { createPeerId, createPeerIds } from './utils/create-peer-id.js' import { sortClosestPeers } from './utils/sort-closest-peers.js' import type { QueryFunc } from '../src/query/types.js' import type { RoutingTable } from '../src/routing-table/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' interface TopologyEntry { delay?: number diff --git a/packages/kad-dht/test/query/utils.spec.ts b/packages/kad-dht/test/query/utils.spec.ts index b93d76c2d3..c1d86a8954 100644 --- a/packages/kad-dht/test/query/utils.spec.ts +++ b/packages/kad-dht/test/query/utils.spec.ts @@ -1,4 +1,4 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { logger } from '@libp2p/logger' import { expect } from 'aegir/chai' import delay from 'delay' diff --git a/packages/kad-dht/test/routing-table.spec.ts b/packages/kad-dht/test/routing-table.spec.ts index 762dabdc99..3babf30480 100644 --- a/packages/kad-dht/test/routing-table.spec.ts +++ b/packages/kad-dht/test/routing-table.spec.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter, CustomEvent } from '@libp2p/interface/events' +import { TypedEventEmitter, CustomEvent } from '@libp2p/interface' import { mockConnectionManager } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { PeerSet } from '@libp2p/peer-collections' @@ -15,17 +15,14 @@ import random from 'lodash.random' import { pEvent } from 'p-event' import pWaitFor from 'p-wait-for' import sinon from 'sinon' -import { stubInterface } from 'ts-sinon' +import { stubInterface } from 'sinon-ts' import { PROTOCOL_DHT } from '../src/constants.js' import { KAD_CLOSE_TAG_NAME, KAD_CLOSE_TAG_VALUE, KBUCKET_SIZE, RoutingTable, type RoutingTableComponents } from '../src/routing-table/index.js' import * as kadUtils from '../src/utils.js' import { createPeerId, createPeerIds } from './utils/create-peer-id.js' import { sortClosestPeers } from './utils/sort-closest-peers.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { Libp2pEvents, PeerId, PeerStore } from '@libp2p/interface' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' describe('Routing Table', () => { let table: RoutingTable diff --git a/packages/kad-dht/test/rpc/handlers/add-provider.spec.ts b/packages/kad-dht/test/rpc/handlers/add-provider.spec.ts index e113b7ac68..64973c2bd0 100644 --- a/packages/kad-dht/test/rpc/handlers/add-provider.spec.ts +++ b/packages/kad-dht/test/rpc/handlers/add-provider.spec.ts @@ -11,7 +11,7 @@ import { AddProviderHandler } from '../../../src/rpc/handlers/add-provider.js' import { createPeerIds } from '../../utils/create-peer-id.js' import { createValues } from '../../utils/create-values.js' import type { DHTMessageHandler } from '../../../src/rpc/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { CID } from 'multiformats' describe('rpc - handlers - AddProvider', () => { diff --git a/packages/kad-dht/test/rpc/handlers/find-node.spec.ts b/packages/kad-dht/test/rpc/handlers/find-node.spec.ts index 5e3f82c3d1..5ea85b0763 100644 --- a/packages/kad-dht/test/rpc/handlers/find-node.spec.ts +++ b/packages/kad-dht/test/rpc/handlers/find-node.spec.ts @@ -4,15 +4,15 @@ import { defaultLogger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import Sinon, { type SinonStubbedInstance } from 'sinon' -import { stubInterface } from 'ts-sinon' +import { stubInterface } from 'sinon-ts' import { Message, MESSAGE_TYPE } from '../../../src/message/index.js' import { PeerRouting } from '../../../src/peer-routing/index.js' import { FindNodeHandler } from '../../../src/rpc/handlers/find-node.js' import { createPeerId } from '../../utils/create-peer-id.js' import type { DHTMessageHandler } from '../../../src/rpc/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { StubbedInstance } from 'ts-sinon' +import type { PeerId } from '@libp2p/interface' +import type { AddressManager } from '@libp2p/interface-internal' +import type { StubbedInstance } from 'sinon-ts' const T = MESSAGE_TYPE.FIND_NODE diff --git a/packages/kad-dht/test/rpc/handlers/get-providers.spec.ts b/packages/kad-dht/test/rpc/handlers/get-providers.spec.ts index f5f109b3ac..76df77fc55 100644 --- a/packages/kad-dht/test/rpc/handlers/get-providers.spec.ts +++ b/packages/kad-dht/test/rpc/handlers/get-providers.spec.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { PersistentPeerStore } from '@libp2p/peer-store' import { multiaddr } from '@multiformats/multiaddr' @@ -14,10 +14,7 @@ import { Providers } from '../../../src/providers.js' import { GetProvidersHandler, type GetProvidersHandlerComponents } from '../../../src/rpc/handlers/get-providers.js' import { createPeerId } from '../../utils/create-peer-id.js' import { createValues, type Value } from '../../utils/create-values.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { Libp2pEvents, PeerId, PeerInfo, PeerStore } from '@libp2p/interface' const T = MESSAGE_TYPE.GET_PROVIDERS diff --git a/packages/kad-dht/test/rpc/handlers/get-value.spec.ts b/packages/kad-dht/test/rpc/handlers/get-value.spec.ts index 5332419929..b29d2a975d 100644 --- a/packages/kad-dht/test/rpc/handlers/get-value.spec.ts +++ b/packages/kad-dht/test/rpc/handlers/get-value.spec.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { PersistentPeerStore } from '@libp2p/peer-store' import { expect } from 'aegir/chai' @@ -13,9 +13,7 @@ import { Libp2pRecord } from '../../../src/record/index.js' import { GetValueHandler, type GetValueHandlerComponents } from '../../../src/rpc/handlers/get-value.js' import * as utils from '../../../src/utils.js' import { createPeerId } from '../../utils/create-peer-id.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { Libp2pEvents, PeerId, PeerStore } from '@libp2p/interface' import type { Datastore } from 'interface-datastore' import type { SinonStubbedInstance } from 'sinon' diff --git a/packages/kad-dht/test/rpc/handlers/ping.spec.ts b/packages/kad-dht/test/rpc/handlers/ping.spec.ts index 0a7872bbc8..1cd1a40447 100644 --- a/packages/kad-dht/test/rpc/handlers/ping.spec.ts +++ b/packages/kad-dht/test/rpc/handlers/ping.spec.ts @@ -7,7 +7,7 @@ import { Message, MESSAGE_TYPE } from '../../../src/message/index.js' import { PingHandler } from '../../../src/rpc/handlers/ping.js' import { createPeerId } from '../../utils/create-peer-id.js' import type { DHTMessageHandler } from '../../../src/rpc/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' const T = MESSAGE_TYPE.PING diff --git a/packages/kad-dht/test/rpc/handlers/put-value.spec.ts b/packages/kad-dht/test/rpc/handlers/put-value.spec.ts index b8f2b5ce7a..c747f2432b 100644 --- a/packages/kad-dht/test/rpc/handlers/put-value.spec.ts +++ b/packages/kad-dht/test/rpc/handlers/put-value.spec.ts @@ -12,7 +12,7 @@ import { PutValueHandler } from '../../../src/rpc/handlers/put-value.js' import * as utils from '../../../src/utils.js' import { createPeerId } from '../../utils/create-peer-id.js' import type { Validators } from '../../../src/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { Datastore } from 'interface-datastore' const T = MESSAGE_TYPE.PUT_VALUE diff --git a/packages/kad-dht/test/rpc/index.node.ts b/packages/kad-dht/test/rpc/index.node.ts index d829d26c5b..11e08e233d 100644 --- a/packages/kad-dht/test/rpc/index.node.ts +++ b/packages/kad-dht/test/rpc/index.node.ts @@ -1,7 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter } from '@libp2p/interface/events' -import { start } from '@libp2p/interface/startable' +import { TypedEventEmitter, start } from '@libp2p/interface' import { mockStream } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { PersistentPeerStore } from '@libp2p/peer-store' @@ -13,7 +12,7 @@ import map from 'it-map' import { pipe } from 'it-pipe' import pDefer from 'p-defer' import Sinon, { type SinonStubbedInstance } from 'sinon' -import { stubInterface } from 'ts-sinon' +import { stubInterface } from 'sinon-ts' import { Uint8ArrayList } from 'uint8arraylist' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { Message, MESSAGE_TYPE } from '../../src/message/index.js' @@ -23,11 +22,8 @@ import { RoutingTable } from '../../src/routing-table/index.js' import { RPC, type RPCComponents } from '../../src/rpc/index.js' import { createPeerId } from '../utils/create-peer-id.js' import type { Validators } from '../../src/index.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' +import type { Libp2pEvents, Connection, PeerId, PeerStore } from '@libp2p/interface' +import type { AddressManager } from '@libp2p/interface-internal' import type { Datastore } from 'interface-datastore' import type { Duplex, Source } from 'it-stream-types' diff --git a/packages/kad-dht/test/utils/create-peer-id.ts b/packages/kad-dht/test/utils/create-peer-id.ts index 940aaf24d6..8fe7de9296 100644 --- a/packages/kad-dht/test/utils/create-peer-id.ts +++ b/packages/kad-dht/test/utils/create-peer-id.ts @@ -1,5 +1,5 @@ import { createEd25519PeerId } from '@libp2p/peer-id-factory' -import type { Ed25519PeerId } from '@libp2p/interface/peer-id' +import type { Ed25519PeerId } from '@libp2p/interface' /** * Creates multiple PeerIds diff --git a/packages/kad-dht/test/utils/index.ts b/packages/kad-dht/test/utils/index.ts index 1ee82f8070..ba27fe0e69 100644 --- a/packages/kad-dht/test/utils/index.ts +++ b/packages/kad-dht/test/utils/index.ts @@ -1,4 +1,4 @@ -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' /** * Count how many peers are in b but are not in a diff --git a/packages/kad-dht/test/utils/sort-closest-peers.ts b/packages/kad-dht/test/utils/sort-closest-peers.ts index f0bdd9ae5a..640b26943e 100644 --- a/packages/kad-dht/test/utils/sort-closest-peers.ts +++ b/packages/kad-dht/test/utils/sort-closest-peers.ts @@ -3,7 +3,7 @@ import map from 'it-map' import { compare as uint8ArrayCompare } from 'uint8arrays/compare' import { xor as uint8ArrayXor } from 'uint8arrays/xor' import { convertPeerId } from '../../src/utils.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' /** * Sort peers by distance to the given `kadId` diff --git a/packages/kad-dht/test/utils/test-dht.ts b/packages/kad-dht/test/utils/test-dht.ts index d8b41d6c9f..742eae1357 100644 --- a/packages/kad-dht/test/utils/test-dht.ts +++ b/packages/kad-dht/test/utils/test-dht.ts @@ -1,5 +1,4 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' -import { start, stop } from '@libp2p/interface/startable' +import { TypedEventEmitter, start, stop } from '@libp2p/interface' import { mockRegistrar, mockConnectionManager, mockNetwork } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { PersistentPeerStore } from '@libp2p/peer-store' @@ -7,17 +6,13 @@ import { multiaddr } from '@multiformats/multiaddr' import { MemoryDatastore } from 'datastore-core/memory' import delay from 'delay' import pRetry from 'p-retry' -import { stubInterface } from 'ts-sinon' +import { stubInterface } from 'sinon-ts' import { DefaultDualKadDHT } from '../../src/dual-kad-dht.js' import { createPeerId } from './create-peer-id.js' import type { DualKadDHT, KadDHTComponents, KadDHTInit } from '../../src/index.js' import type { DefaultKadDHT } from '../../src/kad-dht.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { Libp2pEvents, PeerId, PeerStore } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal' export class TestDHT { private readonly peers: Map diff --git a/packages/keychain/CHANGELOG.md b/packages/keychain/CHANGELOG.md index 7003201689..80a1f6deaa 100644 --- a/packages/keychain/CHANGELOG.md +++ b/packages/keychain/CHANGELOG.md @@ -11,6 +11,34 @@ * **dev:** bump aegir from 38.1.8 to 39.0.10 ([#70](https://github.com/libp2p/js-libp2p-keychain/issues/70)) ([4da4a08](https://github.com/libp2p/js-libp2p-keychain/commit/4da4a08b86f436c36e2fae48ecc48817e9b8066f)) +## [4.0.0](https://www.github.com/libp2p/js-libp2p/compare/keychain-v3.0.8...keychain-v4.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* remove libp2p.keychain (#2084) + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* remove libp2p.keychain ([#2084](https://www.github.com/libp2p/js-libp2p/issues/2084)) ([125c84b](https://www.github.com/libp2p/js-libp2p/commit/125c84bb8a30ac986fb5aed0a4de23bc806d3aea)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/crypto bumped from ^2.0.8 to ^3.0.0 + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + ### [3.0.8](https://www.github.com/libp2p/js-libp2p/compare/keychain-v3.0.7...keychain-v3.0.8) (2023-11-07) @@ -341,4 +369,4 @@ Co-Authored-By: Vasco Santos ### Features * move bits from https://github.com/richardschneider/ipfs-encryption ([1a96ae8](https://github.com/libp2p/js-libp2p-keychain/commit/1a96ae8)) -* use libp2p-crypto ([#18](https://github.com/libp2p/js-libp2p-keychain/issues/18)) ([c1627a9](https://github.com/libp2p/js-libp2p-keychain/commit/c1627a9)) +* use libp2p-crypto ([#18](https://github.com/libp2p/js-libp2p-keychain/issues/18)) ([c1627a9](https://github.com/libp2p/js-libp2p-keychain/commit/c1627a9)) \ No newline at end of file diff --git a/packages/keychain/package.json b/packages/keychain/package.json index 4706e94f1b..0535acffd9 100644 --- a/packages/keychain/package.json +++ b/packages/keychain/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/keychain", - "version": "3.0.8", + "version": "4.0.0", "description": "Key management and cryptographically protected messages", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/keychain#readme", @@ -58,17 +58,17 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/crypto": "^2.0.8", - "@libp2p/interface": "^0.1.6", - "@libp2p/peer-id": "^3.0.6", + "@libp2p/crypto": "^3.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-id": "^4.0.0", "interface-datastore": "^8.2.0", "merge-options": "^3.0.4", "sanitize-filename": "^1.6.3", "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "datastore-core": "^9.1.1", "multiformats": "^12.1.3" diff --git a/packages/keychain/src/index.ts b/packages/keychain/src/index.ts index 3c9e1419fd..b11a884663 100644 --- a/packages/keychain/src/index.ts +++ b/packages/keychain/src/index.ts @@ -51,9 +51,7 @@ */ import { DefaultKeychain } from './keychain.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { KeyType } from '@libp2p/interface/keys' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { ComponentLogger, KeyType, PeerId } from '@libp2p/interface' import type { Datastore } from 'interface-datastore' import type { Multibase } from 'multiformats/bases/interface.js' diff --git a/packages/keychain/src/keychain.ts b/packages/keychain/src/keychain.ts index 2f2ad8e043..aafdf534c5 100644 --- a/packages/keychain/src/keychain.ts +++ b/packages/keychain/src/keychain.ts @@ -2,7 +2,7 @@ import { pbkdf2, randomBytes } from '@libp2p/crypto' import { generateKeyPair, importKey, unmarshalPrivateKey } from '@libp2p/crypto/keys' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { peerIdFromKeys } from '@libp2p/peer-id' import { Key } from 'interface-datastore/key' import mergeOptions from 'merge-options' @@ -11,9 +11,7 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { codes } from './errors.js' import type { KeychainComponents, KeychainInit, Keychain, KeyInfo } from './index.js' -import type { Logger } from '@libp2p/interface' -import type { KeyType } from '@libp2p/interface/keys' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { Logger, KeyType, PeerId } from '@libp2p/interface' const keyPrefix = '/pkcs8/' const infoPrefix = '/info/' diff --git a/packages/keychain/test/keychain.spec.ts b/packages/keychain/test/keychain.spec.ts index 6b54fbd472..2c3e6b2b1f 100644 --- a/packages/keychain/test/keychain.spec.ts +++ b/packages/keychain/test/keychain.spec.ts @@ -12,7 +12,7 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { DefaultKeychain } from '../src/keychain.js' import type { KeychainInit, Keychain, KeyInfo } from '../src/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { Datastore } from 'interface-datastore' describe('keychain', () => { diff --git a/packages/keychain/test/peerid.spec.ts b/packages/keychain/test/peerid.spec.ts index 0c567e23ad..d1520b5fff 100644 --- a/packages/keychain/test/peerid.spec.ts +++ b/packages/keychain/test/peerid.spec.ts @@ -5,7 +5,7 @@ import { createFromPrivKey } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' import { base58btc } from 'multiformats/bases/base58' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' const sample = { id: '122019318b6e5e0cf93a2314bf01269a2cc23cd3dcd452d742cdb9379d8646f6e4a9', diff --git a/packages/libp2p/CHANGELOG.md b/packages/libp2p/CHANGELOG.md index 275cce352f..b6167bf4cd 100644 --- a/packages/libp2p/CHANGELOG.md +++ b/packages/libp2p/CHANGELOG.md @@ -20,6 +20,82 @@ * @libp2p/tcp bumped from ^8.0.5 to ^8.0.6 * @libp2p/websockets bumped from ^7.0.5 to ^7.0.6 +## [1.0.0](https://www.github.com/libp2p/js-libp2p/compare/libp2p-v0.46.21...libp2p-v1.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data +* remove per-peer parallel dialling (#2090) (#2251) +* imports from `libp2p/fetch` should be updated to `@libp2p/fetch` +* imports from `libp2p/circuit-relay` should be updated to `@libp2p/circuit-relay-v2` +* imports from `libp2p/plaintext` should be changed to `@libp2p/plaintext` +* imports from `libp2p/dcutr` now need to be from `@libp2p/dcutr` +* imports from `libp2p/identify` need to change to `@libp2p/identify` +* imports from `libp2p/ping` must be updated to `@libp2p/ping` +* imports from `libp2p/upnp-nat` should be updated to `@libp2p/upnp-nat` +* the `isStarted` method has been removed from the `Startable` interface +* the `.protocols` property has been removed from the `PeerInfo` interface +* move autonat into separate package (#2107) +* remove libp2p.keychain (#2084) +* remove dialler language (#2143) + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* allow mss lazy select on read ([#2246](https://www.github.com/libp2p/js-libp2p/issues/2246)) ([d8f5bc2](https://www.github.com/libp2p/js-libp2p/commit/d8f5bc211185a963c2a5182d58d73629457bc78d)) +* remove dialler language ([#2143](https://www.github.com/libp2p/js-libp2p/issues/2143)) ([a321f15](https://www.github.com/libp2p/js-libp2p/commit/a321f15329ba9b8e6a84a5a7429784edf7fa96e9)) +* remove protocols from PeerInfo ([#2166](https://www.github.com/libp2p/js-libp2p/issues/2166)) ([5468cd1](https://www.github.com/libp2p/js-libp2p/commit/5468cd13a76281e46b221fdbd7d4005c0d3f2252)) +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) +* use optimistic protocol negotation ([#2253](https://www.github.com/libp2p/js-libp2p/issues/2253)) ([0b4a2ee](https://www.github.com/libp2p/js-libp2p/commit/0b4a2ee7983b4dc9dc0a7b705a202a4c550e7017)) + + +### Code Refactoring + +* extract circuit relay v2 to separate module ([#2222](https://www.github.com/libp2p/js-libp2p/issues/2222)) ([24afba3](https://www.github.com/libp2p/js-libp2p/commit/24afba30004fb7f24af1f0180229bb164340f00b)) +* extract DCUtR into separate module ([#2220](https://www.github.com/libp2p/js-libp2p/issues/2220)) ([d2c3e72](https://www.github.com/libp2p/js-libp2p/commit/d2c3e7235b64558c6cace414c54a42659fee2970)) +* extract fetch to separate module ([#2223](https://www.github.com/libp2p/js-libp2p/issues/2223)) ([9b19be2](https://www.github.com/libp2p/js-libp2p/commit/9b19be2796c2dbbe207029199b1ac203647744e3)) +* extract identify service into separate module ([#2219](https://www.github.com/libp2p/js-libp2p/issues/2219)) ([72c2f77](https://www.github.com/libp2p/js-libp2p/commit/72c2f775bd85bd4928048dda0fd14740d6fb6a69)) +* extract ping service into separate module ([#2218](https://www.github.com/libp2p/js-libp2p/issues/2218)) ([556282a](https://www.github.com/libp2p/js-libp2p/commit/556282afdc9b328fd58df1045dc7c792199be932)) +* extract plaintext into separate module ([#2221](https://www.github.com/libp2p/js-libp2p/issues/2221)) ([a364d95](https://www.github.com/libp2p/js-libp2p/commit/a364d95bbd7b15a5ce6ce508321e7ff2fa40a5e5)) +* extract UPnP NAT into separate module ([#2217](https://www.github.com/libp2p/js-libp2p/issues/2217)) ([f29b73f](https://www.github.com/libp2p/js-libp2p/commit/f29b73f781afcea36cba0589aafdd81e1852e194)) +* move autonat into separate package ([#2107](https://www.github.com/libp2p/js-libp2p/issues/2107)) ([b0e8f06](https://www.github.com/libp2p/js-libp2p/commit/b0e8f06f0dcdbda0e367186b093e42e8bff3ee27)) +* remove isStarted method from Startable ([#2145](https://www.github.com/libp2p/js-libp2p/issues/2145)) ([fca208f](https://www.github.com/libp2p/js-libp2p/commit/fca208f3763af041aa37b1cb915d2bc777acb96d)) +* remove libp2p.keychain ([#2084](https://www.github.com/libp2p/js-libp2p/issues/2084)) ([125c84b](https://www.github.com/libp2p/js-libp2p/commit/125c84bb8a30ac986fb5aed0a4de23bc806d3aea)) +* remove per-peer parallel dialling ([#2090](https://www.github.com/libp2p/js-libp2p/issues/2090)) ([#2251](https://www.github.com/libp2p/js-libp2p/issues/2251)) ([bb6ceb1](https://www.github.com/libp2p/js-libp2p/commit/bb6ceb19252de2c1441ef736127d13763837d644)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/crypto bumped from ^2.0.8 to ^3.0.0 + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.9 to ^0.1.10 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/multistream-select bumped from ^4.0.6 to ^4.0.7 + * @libp2p/peer-collections bumped from ^4.0.8 to ^4.0.9 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + * @libp2p/peer-store bumped from ^9.0.9 to ^9.0.10 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/bootstrap bumped from ^9.0.12 to ^10.0.0 + * @libp2p/circuit-relay-v2 bumped from ^0.0.0 to ^1.0.0 + * @libp2p/floodsub bumped from ^8.0.13 to ^8.0.14 + * @libp2p/identify bumped from ^0.0.0 to ^1.0.0 + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/kad-dht bumped from ^10.0.15 to ^11.0.0 + * @libp2p/mdns bumped from ^9.0.14 to ^10.0.0 + * @libp2p/mplex bumped from ^9.0.12 to ^10.0.0 + * @libp2p/plaintext bumped from ^0.0.0 to ^1.0.0 + * @libp2p/tcp bumped from ^8.0.13 to ^9.0.0 + * @libp2p/websockets bumped from ^7.0.13 to ^8.0.0 + ### [0.46.21](https://www.github.com/libp2p/js-libp2p/compare/libp2p-v0.46.20...libp2p-v0.46.21) (2023-11-10) @@ -2705,4 +2781,4 @@ for subscribe to see how it should be used. -## [0.5.5](https://github.com/libp2p/js-libp2p/compare/v0.5.4...v0.5.5) (2017-03-21) +## [0.5.5](https://github.com/libp2p/js-libp2p/compare/v0.5.4...v0.5.5) (2017-03-21) \ No newline at end of file diff --git a/packages/libp2p/README.md b/packages/libp2p/README.md index 663d3bc1f0..d1bb87c0e1 100644 --- a/packages/libp2p/README.md +++ b/packages/libp2p/README.md @@ -42,17 +42,6 @@ const node = await createLibp2p({ }) ``` -# Project status - -We've come a long way, but this project is still in Alpha, lots of development is happening, API might change, beware of the Dragons 🐉.. - -The documentation in the master branch may contain changes from a pre-release. -If you are looking for the documentation of the latest release, you can view the latest release on [**npm**](https://www.npmjs.com/package/libp2p), or select the tag in github that matches the version you are looking for. - -**Want to get started?** Check our [GETTING\_STARTED.md](./doc/GETTING_STARTED.md) guide and [examples repo](https://github.com/libp2p/js-libp2p-examples). - -**Want to update libp2p in your project?** Check our [migrations folder](./doc/migrations). - # Background libp2p is the product of a long and arduous quest to understand the evolution of the Internet networking stack. In order to build P2P applications, devs have long had to make custom ad-hoc solutions to fit their needs, sometimes making some hard assumptions about their runtimes and the state of the network at the time of their development. Today, looking back more than 20 years, we see a clear pattern in the types of mechanisms built around the Internet Protocol, IP, which can be found throughout many layers of the OSI layer system, libp2p distils these mechanisms into flat categories and defines clear interfaces that once exposed, enable other protocols and applications to use and swap them, enabling upgradability and adaptability for the runtime, without breaking the API. @@ -128,42 +117,42 @@ List of packages currently in existence for libp2p > This table is generated using the module `package-table` with `package-table --data=package-list.json`. -| Package | Version | Deps | CI | Coverage | -| ---------|---------|---------|---------|--------- | -| **libp2p** | -| [`libp2p`](//github.com/libp2p/js-libp2p) | [![npm](https://img.shields.io/npm/v/libp2p.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/libp2p?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/libp2p) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p) | -| [`@libp2p/interface`](//github.com/libp2p/js-libp2p/tree/main/packages/interface) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Finterface.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/interface/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Finterface?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Finterface) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/interface/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/interface/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/interface/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/interface) | -| **transports** | -| [`@libp2p/tcp`](//github.com/libp2p/js-libp2p/tree/main/packages/transport-tcp) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Ftcp.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-tcp/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Ftcp?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Ftcp) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/transport-tcp/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-tcp/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-tcp/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-tcp) | -| [`@libp2p/webrtc`](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fwebrtc.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fwebrtc?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fwebrtc) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/transport-webrtc/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-webrtc/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-webrtc) | -| [`@libp2p/websockets`](//github.com/libp2p/js-libp2p/tree/main/packages/transport-websockets) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fwebsockets.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-websockets/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fwebsockets?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fwebsockets) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/transport-websockets/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-websockets/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-websockets/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-websockets) | -| [`@libp2p/webtransport`](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webtransport) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fwebtransport.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webtransport/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fwebtransport?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fwebtransport) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/transport-webtransport/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webtransport/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-webtransport/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-webtransport) | -| **secure channels** | -| [`@chainsafe/libp2p-noise`](//github.com/ChainSafe/js-libp2p-noise) | [![npm](https://img.shields.io/npm/v/%40chainsafe%2Flibp2p-noise.svg?maxAge=86400&style=flat-square)](//github.com/ChainSafe/js-libp2p-noise/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40chainsafe%2Flibp2p-noise?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40chainsafe%2Flibp2p-noise) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-noise/js-test-and-release.yml?branch=master&label=ci&style=flat-square)](//github.com/ChainSafe/js-libp2p-noise/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/js-libp2p-noise/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-noise) | -| [`@libp2p/plaintext`](//github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fplaintext.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fplaintext?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fplaintext) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext) | -| **stream multiplexers** | -| [`@libp2p/mplex`](//github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fmplex.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fmplex?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fmplex) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex) | -| [`@chainsafe/libp2p-yamux`](//github.com/ChainSafe/js-libp2p-yamux) | [![npm](https://img.shields.io/npm/v/%40chainsafe%2Flibp2p-yamux.svg?maxAge=86400&style=flat-square)](//github.com/ChainSafe/js-libp2p-yamux/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40chainsafe%2Flibp2p-yamux?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40chainsafe%2Flibp2p-yamux) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-yamux/js-test-and-release.yml?branch=master&label=ci&style=flat-square)](//github.com/ChainSafe/js-libp2p-yamux/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/js-libp2p-yamux/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-yamux) | -| **peer discovery** | -| [`@libp2p/bootstrap`](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fbootstrap.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fbootstrap?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fbootstrap) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap) | -| [`@libp2p/kad-dht`](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fkad-dht.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fkad-dht?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fkad-dht) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/kad-dht/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht) | -| [`@libp2p/mdns`](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fmdns.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fmdns?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fmdns) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns) | -| [`@chainsafe/discv5`](//github.com/ChainSafe/discv5) | [![npm](https://img.shields.io/npm/v/%40chainsafe%2Fdiscv5.svg?maxAge=86400&style=flat-square)](//github.com/ChainSafe/discv5/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40chainsafe%2Fdiscv5?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40chainsafe%2Fdiscv5) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/discv5/test_and_release.yml?branch=master&label=ci&style=flat-square)](//github.com/ChainSafe/discv5/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/discv5/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/discv5) | -| **content routing** | -| [`@libp2p/http-v1-content-routing`](//github.com/libp2p/js-http-v1-content-routing) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fhttp-v1-content-routing.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-http-v1-content-routing/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fhttp-v1-content-routing?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fhttp-v1-content-routing) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-http-v1-content-routing/js-test-and-release.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-http-v1-content-routing/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-http-v1-content-routing/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-http-v1-content-routing) | -| [`@libp2p/delegated-content-routing`](//github.com/libp2p/js-libp2p-delegated-content-routing) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fdelegated-content-routing.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-delegated-content-routing/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fdelegated-content-routing?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fdelegated-content-routing) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-delegated-content-routing/js-test-and-release.yml?branch=master&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p-delegated-content-routing/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-delegated-content-routing/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-delegated-content-routing) | -| [`@libp2p/kad-dht`](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fkad-dht.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fkad-dht?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fkad-dht) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/kad-dht/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht) | -| **peer routing** | -| [`@libp2p/delegated-peer-routing`](//github.com/libp2p/js-libp2p-delegated-peer-routing) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fdelegated-peer-routing.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p-delegated-peer-routing/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fdelegated-peer-routing?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fdelegated-peer-routing) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-delegated-peer-routing/js-test-and-release.yml?branch=master&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p-delegated-peer-routing/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-delegated-peer-routing/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-delegated-peer-routing) | -| [`@libp2p/kad-dht`](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fkad-dht.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fkad-dht?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fkad-dht) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/kad-dht/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht) | -| **utilities** | -| [`@libp2p/crypto`](//github.com/libp2p/js-libp2p/tree/main/packages/crypto) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fcrypto.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/crypto/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fcrypto?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fcrypto) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/crypto/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/crypto/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/crypto/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/crypto) | -| **data types** | -| [`@libp2p/peer-id`](//github.com/libp2p/js-libp2p/tree/main/packages/peer-id) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fpeer-id.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-id/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fpeer-id?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fpeer-id) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/peer-id/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-id/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-id/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-id) | -| [`@libp2p/peer-record`](//github.com/libp2p/js-libp2p/tree/main/packages/peer-record) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fpeer-record.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-record/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fpeer-record?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fpeer-record) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/peer-record/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-record/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-record/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-record) | -| **pubsub** | -| [`@ChainSafe/libp2p-gossipsub`](//github.com/ChainSafe/js-libp2p-gossipsub) | [![npm](https://img.shields.io/npm/v/%40ChainSafe%2Flibp2p-gossipsub.svg?maxAge=86400&style=flat-square)](//github.com/ChainSafe/js-libp2p-gossipsub/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40ChainSafe%2Flibp2p-gossipsub?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40ChainSafe%2Flibp2p-gossipsub) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-gossipsub/main.yml?branch=master&label=ci&style=flat-square)](//github.com/ChainSafe/js-libp2p-gossipsub/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/js-libp2p-gossipsub/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-gossipsub) | -| [`@libp2p/floodsub`](//github.com/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Ffloodsub.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Ffloodsub?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Ffloodsub) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub) | +| Package | Version | Deps | CI | Coverage | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **libp2p** | | | | | +| [`libp2p`](//github.com/libp2p/js-libp2p) | [![npm](https://img.shields.io/npm/v/libp2p.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/libp2p?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/libp2p) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p) | +| [`@libp2p/interface`](//github.com/libp2p/js-libp2p/tree/main/packages/interface) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Finterface.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/interface/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Finterface?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Finterface) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/interface/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/interface/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/interface/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/interface) | +| **transports** | | | | | +| [`@libp2p/tcp`](//github.com/libp2p/js-libp2p/tree/main/packages/transport-tcp) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Ftcp.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-tcp/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Ftcp?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Ftcp) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/transport-tcp/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-tcp/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-tcp/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-tcp) | +| [`@libp2p/webrtc`](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fwebrtc.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fwebrtc?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fwebrtc) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/transport-webrtc/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-webrtc/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-webrtc) | +| [`@libp2p/websockets`](//github.com/libp2p/js-libp2p/tree/main/packages/transport-websockets) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fwebsockets.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-websockets/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fwebsockets?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fwebsockets) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/transport-websockets/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-websockets/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-websockets/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-websockets) | +| [`@libp2p/webtransport`](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webtransport) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fwebtransport.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webtransport/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fwebtransport?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fwebtransport) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/transport-webtransport/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/transport-webtransport/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-webtransport/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/transport-webtransport) | +| **secure channels** | | | | | +| [`@chainsafe/libp2p-noise`](//github.com/ChainSafe/js-libp2p-noise) | [![npm](https://img.shields.io/npm/v/%40chainsafe%2Flibp2p-noise.svg?maxAge=86400\&style=flat-square)](//github.com/ChainSafe/js-libp2p-noise/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40chainsafe%2Flibp2p-noise?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40chainsafe%2Flibp2p-noise) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-noise/js-test-and-release.yml?branch=master\&label=ci\&style=flat-square)](//github.com/ChainSafe/js-libp2p-noise/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/js-libp2p-noise/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-noise) | +| [`@libp2p/plaintext`](//github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fplaintext.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fplaintext?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fplaintext) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext) | +| **stream multiplexers** | | | | | +| [`@libp2p/mplex`](//github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fmplex.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fmplex?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fmplex) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex) | +| [`@chainsafe/libp2p-yamux`](//github.com/ChainSafe/js-libp2p-yamux) | [![npm](https://img.shields.io/npm/v/%40chainsafe%2Flibp2p-yamux.svg?maxAge=86400\&style=flat-square)](//github.com/ChainSafe/js-libp2p-yamux/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40chainsafe%2Flibp2p-yamux?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40chainsafe%2Flibp2p-yamux) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-yamux/js-test-and-release.yml?branch=master\&label=ci\&style=flat-square)](//github.com/ChainSafe/js-libp2p-yamux/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/js-libp2p-yamux/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-yamux) | +| **peer discovery** | | | | | +| [`@libp2p/bootstrap`](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fbootstrap.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fbootstrap?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fbootstrap) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap) | +| [`@libp2p/kad-dht`](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fkad-dht.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fkad-dht?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fkad-dht) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/kad-dht/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht) | +| [`@libp2p/mdns`](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fmdns.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fmdns?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fmdns) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns) | +| [`@chainsafe/discv5`](//github.com/ChainSafe/discv5) | [![npm](https://img.shields.io/npm/v/%40chainsafe%2Fdiscv5.svg?maxAge=86400\&style=flat-square)](//github.com/ChainSafe/discv5/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40chainsafe%2Fdiscv5?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40chainsafe%2Fdiscv5) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/discv5/test_and_release.yml?branch=master\&label=ci\&style=flat-square)](//github.com/ChainSafe/discv5/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/discv5/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/discv5) | +| **content routing** | | | | | +| [`@libp2p/http-v1-content-routing`](//github.com/libp2p/js-http-v1-content-routing) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fhttp-v1-content-routing.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-http-v1-content-routing/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fhttp-v1-content-routing?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fhttp-v1-content-routing) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-http-v1-content-routing/js-test-and-release.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-http-v1-content-routing/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-http-v1-content-routing/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-http-v1-content-routing) | +| [`@libp2p/delegated-content-routing`](//github.com/libp2p/js-libp2p-delegated-content-routing) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fdelegated-content-routing.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p-delegated-content-routing/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fdelegated-content-routing?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fdelegated-content-routing) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-delegated-content-routing/js-test-and-release.yml?branch=master\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p-delegated-content-routing/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-delegated-content-routing/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-delegated-content-routing) | +| [`@libp2p/kad-dht`](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fkad-dht.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fkad-dht?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fkad-dht) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/kad-dht/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht) | +| **peer routing** | | | | | +| [`@libp2p/delegated-peer-routing`](//github.com/libp2p/js-libp2p-delegated-peer-routing) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fdelegated-peer-routing.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p-delegated-peer-routing/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fdelegated-peer-routing?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fdelegated-peer-routing) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p-delegated-peer-routing/js-test-and-release.yml?branch=master\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p-delegated-peer-routing/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p-delegated-peer-routing/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-delegated-peer-routing) | +| [`@libp2p/kad-dht`](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fkad-dht.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fkad-dht?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fkad-dht) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/kad-dht/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/kad-dht/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/kad-dht) | +| **utilities** | | | | | +| [`@libp2p/crypto`](//github.com/libp2p/js-libp2p/tree/main/packages/crypto) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fcrypto.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/crypto/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fcrypto?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fcrypto) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/crypto/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/crypto/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/crypto/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/crypto) | +| **data types** | | | | | +| [`@libp2p/peer-id`](//github.com/libp2p/js-libp2p/tree/main/packages/peer-id) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fpeer-id.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-id/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fpeer-id?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fpeer-id) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/peer-id/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-id/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-id/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-id) | +| [`@libp2p/peer-record`](//github.com/libp2p/js-libp2p/tree/main/packages/peer-record) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fpeer-record.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-record/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fpeer-record?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Fpeer-record) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/peer-record/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-record/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-record/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-record) | +| **pubsub** | | | | | +| [`@ChainSafe/libp2p-gossipsub`](//github.com/ChainSafe/js-libp2p-gossipsub) | [![npm](https://img.shields.io/npm/v/%40ChainSafe%2Flibp2p-gossipsub.svg?maxAge=86400\&style=flat-square)](//github.com/ChainSafe/js-libp2p-gossipsub/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40ChainSafe%2Flibp2p-gossipsub?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40ChainSafe%2Flibp2p-gossipsub) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-gossipsub/main.yml?branch=master\&label=ci\&style=flat-square)](//github.com/ChainSafe/js-libp2p-gossipsub/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/js-libp2p-gossipsub/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-gossipsub) | +| [`@libp2p/floodsub`](//github.com/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Ffloodsub.svg?maxAge=86400\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Ffloodsub?logo=Libraries.io\&logoColor=white\&style=flat-square)](//libraries.io/npm/%40libp2p%2Ffloodsub) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub/main.yml?branch=main\&label=ci\&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub) | # Used by @@ -171,7 +160,9 @@ List of packages currently in existence for libp2p

HOPR Logo - IPFS in JavaScript logo + Helia logo + OrbitDB logo + Waku

diff --git a/packages/libp2p/package.json b/packages/libp2p/package.json index 0258f54943..90eb2fa42b 100644 --- a/packages/libp2p/package.json +++ b/packages/libp2p/package.json @@ -1,6 +1,6 @@ { "name": "libp2p", - "version": "0.46.21", + "version": "1.0.0", "description": "JavaScript implementation of libp2p, a modular peer to peer network stack", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/libp2p#readme", @@ -64,16 +64,16 @@ "test:interop": "aegir test -t node -f dist/test/interop.js" }, "dependencies": { - "@libp2p/crypto": "^2.0.8", - "@libp2p/interface": "^0.1.6", - "@libp2p/interface-internal": "^0.1.9", - "@libp2p/logger": "^3.1.0", - "@libp2p/multistream-select": "^4.0.6", - "@libp2p/peer-collections": "^4.0.8", - "@libp2p/peer-id": "^3.0.6", - "@libp2p/peer-id-factory": "^3.0.8", - "@libp2p/peer-store": "^9.0.9", - "@libp2p/utils": "^4.0.7", + "@libp2p/crypto": "^3.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/logger": "^4.0.0", + "@libp2p/multistream-select": "^4.0.7", + "@libp2p/peer-collections": "^4.0.9", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", + "@libp2p/peer-store": "^9.0.10", + "@libp2p/utils": "^5.0.0", "@multiformats/mafmt": "^12.1.6", "@multiformats/multiaddr": "^12.1.10", "@multiformats/multiaddr-matcher": "^1.1.0", @@ -102,20 +102,20 @@ "@chainsafe/libp2p-gossipsub": "^10.0.0", "@chainsafe/libp2p-noise": "^13.0.2", "@chainsafe/libp2p-yamux": "^5.0.0", - "@libp2p/bootstrap": "^9.0.12", - "@libp2p/circuit-relay-v2": "^0.0.0", + "@libp2p/bootstrap": "^10.0.0", + "@libp2p/circuit-relay-v2": "^1.0.0", "@libp2p/daemon-client": "^7.0.0", "@libp2p/daemon-server": "^6.0.0", - "@libp2p/floodsub": "^8.0.13", - "@libp2p/identify": "^0.0.0", - "@libp2p/interface-compliance-tests": "^4.1.5", + "@libp2p/floodsub": "^8.0.14", + "@libp2p/identify": "^1.0.0", + "@libp2p/interface-compliance-tests": "^5.0.0", "@libp2p/interop": "^9.0.0", - "@libp2p/kad-dht": "^10.0.15", - "@libp2p/mdns": "^9.0.14", - "@libp2p/mplex": "^9.0.12", - "@libp2p/plaintext": "^0.0.0", - "@libp2p/tcp": "^8.0.13", - "@libp2p/websockets": "^7.0.13", + "@libp2p/kad-dht": "^11.0.0", + "@libp2p/mdns": "^10.0.0", + "@libp2p/mplex": "^10.0.0", + "@libp2p/plaintext": "^1.0.0", + "@libp2p/tcp": "^9.0.0", + "@libp2p/websockets": "^8.0.0", "aegir": "^41.0.2", "execa": "^8.0.1", "go-libp2p": "^1.1.1", diff --git a/packages/libp2p/src/address-manager/index.ts b/packages/libp2p/src/address-manager/index.ts index 1ff557a6a7..7dd7c4ca5c 100644 --- a/packages/libp2p/src/address-manager/index.ts +++ b/packages/libp2p/src/address-manager/index.ts @@ -1,11 +1,8 @@ import { peerIdFromString } from '@libp2p/peer-id' import { multiaddr } from '@multiformats/multiaddr' import { debounce } from './utils.js' -import type { ComponentLogger, Libp2pEvents, Logger } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ComponentLogger, Libp2pEvents, Logger, TypedEventTarget, PeerId, PeerStore } from '@libp2p/interface' +import type { TransportManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export interface AddressManagerInit { diff --git a/packages/libp2p/src/components.ts b/packages/libp2p/src/components.ts index f03169820d..f27da1ec7a 100644 --- a/packages/libp2p/src/components.ts +++ b/packages/libp2p/src/components.ts @@ -1,20 +1,7 @@ -import { CodeError } from '@libp2p/interface/errors' -import { isStartable, type Startable } from '@libp2p/interface/startable' +import { CodeError } from '@libp2p/interface' +import { isStartable, type Startable, type Libp2pEvents, type ComponentLogger, type NodeInfo, type ConnectionProtector, type ConnectionGater, type ContentRouting, type TypedEventTarget, type Metrics, type PeerId, type PeerRouting, type PeerStore, type Upgrader } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' -import type { Libp2pEvents, ComponentLogger, NodeInfo } from '@libp2p/interface' -import type { ConnectionProtector } from '@libp2p/interface/connection' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerRouting } from '@libp2p/interface/peer-routing' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Upgrader } from '@libp2p/interface/transport' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { AddressManager, ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal' import type { Datastore } from 'interface-datastore' export interface Components extends Record, Startable { diff --git a/packages/libp2p/src/config.ts b/packages/libp2p/src/config.ts index a9b83fb532..f17593cf16 100644 --- a/packages/libp2p/src/config.ts +++ b/packages/libp2p/src/config.ts @@ -1,5 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' -import { FaultTolerance } from '@libp2p/interface/transport' +import { CodeError, FaultTolerance } from '@libp2p/interface' import { defaultAddressSort } from '@libp2p/utils/address-sort' import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers' import mergeOptions from 'merge-options' diff --git a/packages/libp2p/src/config/connection-gater.browser.ts b/packages/libp2p/src/config/connection-gater.browser.ts index c03a153698..5593c8dbe9 100644 --- a/packages/libp2p/src/config/connection-gater.browser.ts +++ b/packages/libp2p/src/config/connection-gater.browser.ts @@ -1,5 +1,5 @@ import isPrivate from 'private-ip' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' +import type { ConnectionGater } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' /** diff --git a/packages/libp2p/src/config/connection-gater.ts b/packages/libp2p/src/config/connection-gater.ts index 40f1827ae7..7739c71e91 100644 --- a/packages/libp2p/src/config/connection-gater.ts +++ b/packages/libp2p/src/config/connection-gater.ts @@ -1,4 +1,4 @@ -import type { ConnectionGater } from '@libp2p/interface/connection-gater' +import type { ConnectionGater } from '@libp2p/interface' /** * Returns a default connection gater implementation that allows everything diff --git a/packages/libp2p/src/connection-manager/auto-dial.ts b/packages/libp2p/src/connection-manager/auto-dial.ts index 9cd95d6df6..7f65917441 100644 --- a/packages/libp2p/src/connection-manager/auto-dial.ts +++ b/packages/libp2p/src/connection-manager/auto-dial.ts @@ -2,11 +2,8 @@ import { PeerMap, PeerSet } from '@libp2p/peer-collections' import { PeerJobQueue } from '@libp2p/utils/peer-job-queue' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { AUTO_DIAL_CONCURRENCY, AUTO_DIAL_DISCOVERED_PEERS_DEBOUNCE, AUTO_DIAL_INTERVAL, AUTO_DIAL_MAX_QUEUE_LENGTH, AUTO_DIAL_PEER_RETRY_THRESHOLD, AUTO_DIAL_PRIORITY, LAST_DIAL_FAILURE_KEY, MIN_CONNECTIONS } from './constants.js' -import type { Libp2pEvents, Logger, ComponentLogger } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' +import type { Libp2pEvents, Logger, ComponentLogger, TypedEventTarget, PeerStore, Startable } from '@libp2p/interface' +import type { ConnectionManager } from '@libp2p/interface-internal' interface AutoDialInit { minConnections?: number diff --git a/packages/libp2p/src/connection-manager/connection-pruner.ts b/packages/libp2p/src/connection-manager/connection-pruner.ts index 71a2f2308e..62fdffab0e 100644 --- a/packages/libp2p/src/connection-manager/connection-pruner.ts +++ b/packages/libp2p/src/connection-manager/connection-pruner.ts @@ -1,9 +1,7 @@ import { PeerMap } from '@libp2p/peer-collections' import { MAX_CONNECTIONS } from './constants.js' -import type { Libp2pEvents, Logger, ComponentLogger } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' +import type { Libp2pEvents, Logger, ComponentLogger, TypedEventTarget, PeerStore } from '@libp2p/interface' +import type { ConnectionManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' interface ConnectionPrunerInit { diff --git a/packages/libp2p/src/connection-manager/dial-queue.ts b/packages/libp2p/src/connection-manager/dial-queue.ts index 9550c95dfe..426c426734 100644 --- a/packages/libp2p/src/connection-manager/dial-queue.ts +++ b/packages/libp2p/src/connection-manager/dial-queue.ts @@ -1,5 +1,4 @@ -import { AbortError, CodeError, ERR_TIMEOUT } from '@libp2p/interface/errors' -import { setMaxListeners } from '@libp2p/interface/events' +import { AbortError, CodeError, ERR_TIMEOUT, setMaxListeners } from '@libp2p/interface' import { PeerMap } from '@libp2p/peer-collections' import { defaultAddressSort } from '@libp2p/utils/address-sort' import { type Multiaddr, type Resolver, resolvers } from '@multiformats/multiaddr' @@ -17,13 +16,8 @@ import { LAST_DIAL_FAILURE_KEY } from './constants.js' import { combineSignals, resolveMultiaddrs } from './utils.js' -import type { AddressSorter, AbortOptions, PendingDial, ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { Metric, Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Address, PeerStore } from '@libp2p/interface/peer-store' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { AddressSorter, AbortOptions, PendingDial, ComponentLogger, Logger, Connection, ConnectionGater, Metric, Metrics, PeerId, Address, PeerStore } from '@libp2p/interface' +import type { TransportManager } from '@libp2p/interface-internal' export interface PendingDialTarget { resolve(value: any): void diff --git a/packages/libp2p/src/connection-manager/index.ts b/packages/libp2p/src/connection-manager/index.ts index 03240c4bf4..2bc7ac79b8 100644 --- a/packages/libp2p/src/connection-manager/index.ts +++ b/packages/libp2p/src/connection-manager/index.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { KEEP_ALIVE } from '@libp2p/interface/peer-store/tags' import { PeerMap } from '@libp2p/peer-collections' import { defaultAddressSort } from '@libp2p/utils/address-sort' @@ -11,16 +11,8 @@ import { AutoDial } from './auto-dial.js' import { ConnectionPruner } from './connection-pruner.js' import { AUTO_DIAL_CONCURRENCY, AUTO_DIAL_MAX_QUEUE_LENGTH, AUTO_DIAL_PRIORITY, DIAL_TIMEOUT, INBOUND_CONNECTION_THRESHOLD, MAX_CONNECTIONS, MAX_INCOMING_PENDING_CONNECTIONS, MAX_PARALLEL_DIALS, MAX_PEER_ADDRS_TO_DIAL, MIN_CONNECTIONS } from './constants.js' import { DialQueue } from './dial-queue.js' -import type { PendingDial, AddressSorter, Libp2pEvents, AbortOptions, ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection, MultiaddrConnection } from '@libp2p/interface/connection' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Peer, PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' -import type { ConnectionManager, OpenConnectionOptions } from '@libp2p/interface-internal/connection-manager' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { PendingDial, AddressSorter, Libp2pEvents, AbortOptions, ComponentLogger, Logger, Connection, MultiaddrConnection, ConnectionGater, TypedEventTarget, Metrics, PeerId, Peer, PeerStore, Startable } from '@libp2p/interface' +import type { ConnectionManager, OpenConnectionOptions, TransportManager } from '@libp2p/interface-internal' const DEFAULT_DIAL_PRIORITY = 50 diff --git a/packages/libp2p/src/connection-manager/utils.ts b/packages/libp2p/src/connection-manager/utils.ts index d32108e26f..7bde8332d1 100644 --- a/packages/libp2p/src/connection-manager/utils.ts +++ b/packages/libp2p/src/connection-manager/utils.ts @@ -1,4 +1,4 @@ -import { setMaxListeners } from '@libp2p/interface/events' +import { setMaxListeners } from '@libp2p/interface' import { type AbortOptions, multiaddr, type Multiaddr } from '@multiformats/multiaddr' import { type ClearableSignal, anySignal } from 'any-signal' import type { LoggerOptions } from '@libp2p/interface' diff --git a/packages/libp2p/src/connection/index.ts b/packages/libp2p/src/connection/index.ts index bbb248acba..f8cc0a7c23 100644 --- a/packages/libp2p/src/connection/index.ts +++ b/packages/libp2p/src/connection/index.ts @@ -1,9 +1,5 @@ -import { symbol } from '@libp2p/interface/connection' -import { CodeError } from '@libp2p/interface/errors' -import { setMaxListeners } from '@libp2p/interface/events' -import type { AbortOptions, Logger, ComponentLogger } from '@libp2p/interface' -import type { Direction, Connection, Stream, ConnectionTimeline, ConnectionStatus, NewStreamOptions } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' +import { connectionSymbol, CodeError, setMaxListeners } from '@libp2p/interface' +import type { AbortOptions, Logger, ComponentLogger, Direction, Connection, Stream, ConnectionTimeline, ConnectionStatus, NewStreamOptions, PeerId } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' const CLOSE_TIMEOUT = 500 @@ -106,7 +102,7 @@ export class ConnectionImpl implements Connection { readonly [Symbol.toStringTag] = 'Connection' - readonly [symbol] = true + readonly [connectionSymbol] = true /** * Get all the streams of the muxer diff --git a/packages/libp2p/src/content-routing/index.ts b/packages/libp2p/src/content-routing/index.ts index a96c2bd9ab..424815b662 100644 --- a/packages/libp2p/src/content-routing/index.ts +++ b/packages/libp2p/src/content-routing/index.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import merge from 'it-merge' import { pipe } from 'it-pipe' import { codes, messages } from '../errors.js' @@ -7,11 +7,7 @@ import { uniquePeers, requirePeers } from './utils.js' -import type { AbortOptions } from '@libp2p/interface' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' +import type { AbortOptions, ContentRouting, PeerInfo, PeerStore, Startable } from '@libp2p/interface' import type { CID } from 'multiformats/cid' export interface CompoundContentRoutingInit { diff --git a/packages/libp2p/src/content-routing/utils.ts b/packages/libp2p/src/content-routing/utils.ts index f114639c41..20edd912b8 100644 --- a/packages/libp2p/src/content-routing/utils.ts +++ b/packages/libp2p/src/content-routing/utils.ts @@ -1,8 +1,7 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import filter from 'it-filter' import map from 'it-map' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { PeerInfo, PeerStore } from '@libp2p/interface' import type { Source } from 'it-stream-types' /** diff --git a/packages/libp2p/src/get-peer.ts b/packages/libp2p/src/get-peer.ts index 8503fe7b64..d012795c37 100644 --- a/packages/libp2p/src/get-peer.ts +++ b/packages/libp2p/src/get-peer.ts @@ -1,9 +1,8 @@ -import { CodeError } from '@libp2p/interface/errors' -import { isPeerId } from '@libp2p/interface/peer-id' +import { CodeError, isPeerId } from '@libp2p/interface' import { peerIdFromString } from '@libp2p/peer-id' import { isMultiaddr } from '@multiformats/multiaddr' import { codes } from './errors.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' export interface PeerAddress { diff --git a/packages/libp2p/src/index.ts b/packages/libp2p/src/index.ts index 2c5fd44d45..adb9fe8b35 100644 --- a/packages/libp2p/src/index.ts +++ b/packages/libp2p/src/index.ts @@ -19,17 +19,7 @@ import type { AddressManagerInit } from './address-manager/index.js' import type { Components } from './components.js' import type { ConnectionManagerInit } from './connection-manager/index.js' import type { TransportManagerInit } from './transport-manager.js' -import type { Libp2p, ServiceMap, RecursivePartial, ComponentLogger, NodeInfo } from '@libp2p/interface' -import type { ConnectionProtector } from '@libp2p/interface/connection' -import type { ConnectionEncrypter } from '@libp2p/interface/connection-encrypter' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { Metrics } from '@libp2p/interface/metrics' -import type { PeerDiscovery } from '@libp2p/interface/peer-discovery' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerRouting } from '@libp2p/interface/peer-routing' -import type { StreamMuxerFactory } from '@libp2p/interface/stream-muxer' -import type { Transport } from '@libp2p/interface/transport' +import type { Libp2p, ServiceMap, RecursivePartial, ComponentLogger, NodeInfo, ConnectionProtector, ConnectionEncrypter, ConnectionGater, ContentRouting, Metrics, PeerDiscovery, PeerId, PeerRouting, StreamMuxerFactory, Transport } from '@libp2p/interface' import type { PersistentPeerStoreInit } from '@libp2p/peer-store' import type { Datastore } from 'interface-datastore' diff --git a/packages/libp2p/src/libp2p.ts b/packages/libp2p/src/libp2p.ts index afe94969d8..53e7034202 100644 --- a/packages/libp2p/src/libp2p.ts +++ b/packages/libp2p/src/libp2p.ts @@ -1,9 +1,6 @@ import { unmarshalPublicKey } from '@libp2p/crypto/keys' -import { type ContentRouting, contentRouting } from '@libp2p/interface/content-routing' -import { CodeError } from '@libp2p/interface/errors' -import { TypedEventEmitter, CustomEvent, setMaxListeners } from '@libp2p/interface/events' -import { peerDiscovery } from '@libp2p/interface/peer-discovery' -import { type PeerRouting, peerRouting } from '@libp2p/interface/peer-routing' +import { type ContentRouting, contentRoutingSymbol, type PeerRouting, peerRoutingSymbol, type Libp2pEvents, type PendingDial, type ServiceMap, type AbortOptions, type ComponentLogger, type Logger, type Connection, type NewStreamOptions, type Stream, type Metrics, type PeerId, type PeerInfo, type PeerStore, type Topology } from '@libp2p/interface' +import { CodeError, TypedEventEmitter, CustomEvent, setMaxListeners, peerDiscoverySymbol } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { PeerSet } from '@libp2p/peer-collections' import { peerIdFromString } from '@libp2p/peer-id' @@ -27,14 +24,7 @@ import { DefaultUpgrader } from './upgrader.js' import * as pkg from './version.js' import type { Components } from './components.js' import type { Libp2p, Libp2pInit, Libp2pOptions } from './index.js' -import type { Libp2pEvents, PendingDial, ServiceMap, AbortOptions, ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection, NewStreamOptions, Stream } from '@libp2p/interface/connection' -import type { Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Topology } from '@libp2p/interface/topology' -import type { StreamHandler, StreamHandlerOptions } from '@libp2p/interface-internal/registrar' +import type { StreamHandler, StreamHandlerOptions } from '@libp2p/interface-internal' export class Libp2pNode> extends TypedEventEmitter implements Libp2p { public peerId: PeerId @@ -172,19 +162,19 @@ export class Libp2pNode> extends this.services[name as keyof T] = service this.configureComponent(name, service) - if (service[contentRouting] != null) { + if (service[contentRoutingSymbol] != null) { this.log('registering service %s for content routing', name) - contentRouters.push(service[contentRouting]) + contentRouters.push(service[contentRoutingSymbol]) } - if (service[peerRouting] != null) { + if (service[peerRoutingSymbol] != null) { this.log('registering service %s for peer routing', name) - peerRouters.push(service[peerRouting]) + peerRouters.push(service[peerRoutingSymbol]) } - if (service[peerDiscovery] != null) { + if (service[peerDiscoverySymbol] != null) { this.log('registering service %s for peer discovery', name) - service[peerDiscovery].addEventListener('peer', (evt: CustomEvent) => { + service[peerDiscoverySymbol].addEventListener('peer', (evt: CustomEvent) => { this.#onDiscoveryPeer(evt) }) } diff --git a/packages/libp2p/src/peer-routing.ts b/packages/libp2p/src/peer-routing.ts index f5082cab5f..8346a1dc07 100644 --- a/packages/libp2p/src/peer-routing.ts +++ b/packages/libp2p/src/peer-routing.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import filter from 'it-filter' import first from 'it-first' import merge from 'it-merge' @@ -9,11 +9,7 @@ import { requirePeers } from './content-routing/utils.js' import { codes, messages } from './errors.js' -import type { AbortOptions, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerRouting } from '@libp2p/interface/peer-routing' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { AbortOptions, Logger, PeerId, PeerInfo, PeerRouting, PeerStore } from '@libp2p/interface' import type { ComponentLogger } from '@libp2p/logger' export interface PeerRoutingInit { diff --git a/packages/libp2p/src/registrar.ts b/packages/libp2p/src/registrar.ts index 11d70b05a1..d6f669d724 100644 --- a/packages/libp2p/src/registrar.ts +++ b/packages/libp2p/src/registrar.ts @@ -1,13 +1,8 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import merge from 'merge-options' import { codes } from './errors.js' -import type { IdentifyResult, Libp2pEvents, Logger, PeerUpdate } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Topology } from '@libp2p/interface/topology' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { StreamHandlerOptions, StreamHandlerRecord, Registrar, StreamHandler } from '@libp2p/interface-internal/registrar' +import type { IdentifyResult, Libp2pEvents, Logger, PeerUpdate, TypedEventTarget, PeerId, PeerStore, Topology } from '@libp2p/interface' +import type { ConnectionManager, StreamHandlerOptions, StreamHandlerRecord, Registrar, StreamHandler } from '@libp2p/interface-internal' import type { ComponentLogger } from '@libp2p/logger' export const DEFAULT_MAX_INBOUND_STREAMS = 32 diff --git a/packages/libp2p/src/transport-manager.ts b/packages/libp2p/src/transport-manager.ts index a9b47d5cca..9449bc9af2 100644 --- a/packages/libp2p/src/transport-manager.ts +++ b/packages/libp2p/src/transport-manager.ts @@ -1,15 +1,8 @@ -import { CodeError } from '@libp2p/interface/errors' -import { trackedMap } from '@libp2p/interface/metrics/tracked-map' -import { FaultTolerance } from '@libp2p/interface/transport' +import { CodeError, FaultTolerance } from '@libp2p/interface' +import { trackedMap } from '@libp2p/utils/tracked-map' import { codes } from './errors.js' -import type { Libp2pEvents, AbortOptions, ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { Metrics } from '@libp2p/interface/metrics' -import type { Startable } from '@libp2p/interface/startable' -import type { Listener, Transport, Upgrader } from '@libp2p/interface/transport' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { Libp2pEvents, AbortOptions, ComponentLogger, Logger, Connection, TypedEventTarget, Metrics, Startable, Listener, Transport, Upgrader } from '@libp2p/interface' +import type { AddressManager, TransportManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export interface TransportManagerInit { diff --git a/packages/libp2p/src/upgrader.ts b/packages/libp2p/src/upgrader.ts index 4310f07c79..9b546ed5ed 100644 --- a/packages/libp2p/src/upgrader.ts +++ b/packages/libp2p/src/upgrader.ts @@ -1,23 +1,12 @@ -import { CodeError, ERR_TIMEOUT } from '@libp2p/interface/errors' -import { setMaxListeners } from '@libp2p/interface/events' +import { CodeError, ERR_TIMEOUT, setMaxListeners } from '@libp2p/interface' import * as mss from '@libp2p/multistream-select' import { peerIdFromString } from '@libp2p/peer-id' import { createConnection } from './connection/index.js' import { INBOUND_UPGRADE_TIMEOUT } from './connection-manager/constants.js' import { codes } from './errors.js' import { DEFAULT_MAX_INBOUND_STREAMS, DEFAULT_MAX_OUTBOUND_STREAMS } from './registrar.js' -import type { Libp2pEvents, AbortOptions, ComponentLogger, Logger } from '@libp2p/interface' -import type { MultiaddrConnection, Connection, Stream, ConnectionProtector, NewStreamOptions } from '@libp2p/interface/connection' -import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface/connection-encrypter' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { StreamMuxer, StreamMuxerFactory } from '@libp2p/interface/stream-muxer' -import type { Upgrader, UpgraderOptions } from '@libp2p/interface/transport' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { Libp2pEvents, AbortOptions, ComponentLogger, Logger, MultiaddrConnection, Connection, Stream, ConnectionProtector, NewStreamOptions, ConnectionEncrypter, SecuredConnection, ConnectionGater, TypedEventTarget, Metrics, PeerId, PeerStore, StreamMuxer, StreamMuxerFactory, Upgrader, UpgraderOptions } from '@libp2p/interface' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' const DEFAULT_PROTOCOL_SELECT_TIMEOUT = 30000 diff --git a/packages/libp2p/test/addresses/address-manager.spec.ts b/packages/libp2p/test/addresses/address-manager.spec.ts index c470ed83ae..a068688d34 100644 --- a/packages/libp2p/test/addresses/address-manager.spec.ts +++ b/packages/libp2p/test/addresses/address-manager.spec.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' +import { TypedEventEmitter, type TypedEventTarget, type Libp2pEvents, type PeerId, type PeerStore } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' @@ -9,10 +9,7 @@ import delay from 'delay' import Sinon from 'sinon' import { type StubbedInstance, stubInterface } from 'sinon-ts' import { type AddressFilter, DefaultAddressManager } from '../../src/address-manager/index.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { TransportManager } from '@libp2p/interface-internal' const listenAddresses = ['/ip4/127.0.0.1/tcp/15006/ws', '/ip4/127.0.0.1/tcp/15008/ws'] const announceAddreses = ['/dns4/peer.io'] diff --git a/packages/libp2p/test/connection-manager/auto-dial.spec.ts b/packages/libp2p/test/connection-manager/auto-dial.spec.ts index ceedfd5550..955d715408 100644 --- a/packages/libp2p/test/connection-manager/auto-dial.spec.ts +++ b/packages/libp2p/test/connection-manager/auto-dial.spec.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' +import { TypedEventEmitter, type TypedEventTarget, type Libp2pEvents, type Connection, type PeerId, type PeerStore, type Peer } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { PeerMap } from '@libp2p/peer-collections' import { createEd25519PeerId } from '@libp2p/peer-id-factory' @@ -17,11 +17,7 @@ import { defaultComponents } from '../../src/components.js' import { AutoDial } from '../../src/connection-manager/auto-dial.js' import { LAST_DIAL_FAILURE_KEY } from '../../src/connection-manager/constants.js' import { matchPeerId } from '../fixtures/match-peer-id.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore, Peer } from '@libp2p/interface/peer-store' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' +import type { ConnectionManager } from '@libp2p/interface-internal' describe('auto-dial', () => { let autoDialer: AutoDial diff --git a/packages/libp2p/test/connection-manager/dial-queue.spec.ts b/packages/libp2p/test/connection-manager/dial-queue.spec.ts index 56838d986c..1221f05057 100644 --- a/packages/libp2p/test/connection-manager/dial-queue.spec.ts +++ b/packages/libp2p/test/connection-manager/dial-queue.spec.ts @@ -11,13 +11,8 @@ import pDefer from 'p-defer' import sinon from 'sinon' import { type StubbedInstance, stubInterface } from 'sinon-ts' import { DialQueue } from '../../src/connection-manager/dial-queue.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Transport } from '@libp2p/interface/transport' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ComponentLogger, Connection, ConnectionGater, PeerId, PeerStore, Transport } from '@libp2p/interface' +import type { TransportManager } from '@libp2p/interface-internal' describe('dial queue', () => { let components: { diff --git a/packages/libp2p/test/connection-manager/direct.node.ts b/packages/libp2p/test/connection-manager/direct.node.ts index 10d4f9da09..193e12f9cd 100644 --- a/packages/libp2p/test/connection-manager/direct.node.ts +++ b/packages/libp2p/test/connection-manager/direct.node.ts @@ -4,10 +4,8 @@ import fs from 'node:fs' import os from 'node:os' import path from 'node:path' import { yamux } from '@chainsafe/libp2p-yamux' -import { type Connection, type ConnectionProtector, isConnection } from '@libp2p/interface/connection' -import { AbortError, ERR_TIMEOUT } from '@libp2p/interface/errors' -import { TypedEventEmitter } from '@libp2p/interface/events' -import { start, stop } from '@libp2p/interface/startable' +import { type Connection, type ConnectionProtector, isConnection, type PeerId } from '@libp2p/interface' +import { AbortError, ERR_TIMEOUT, TypedEventEmitter, start, stop } from '@libp2p/interface' import { mockConnection, mockConnectionGater, mockDuplex, mockMultiaddrConnection, mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { mplex } from '@libp2p/mplex' @@ -34,8 +32,7 @@ import { codes as ErrorCodes } from '../../src/errors.js' import { createLibp2pNode, type Libp2pNode } from '../../src/libp2p.js' import { DefaultTransportManager } from '../../src/transport-manager.js' import { ECHO_PROTOCOL, echo } from '../fixtures/echo-service.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { TransportManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' const listenAddr = multiaddr('/ip4/127.0.0.1/tcp/0') @@ -299,6 +296,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -333,6 +331,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -362,6 +361,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -426,6 +426,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -453,6 +454,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -483,6 +485,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -512,6 +515,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -552,6 +556,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -611,6 +616,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -629,6 +635,7 @@ describe('libp2p.dialer (direct, TCP)', () => { tcp() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], diff --git a/packages/libp2p/test/connection-manager/direct.spec.ts b/packages/libp2p/test/connection-manager/direct.spec.ts index 5c9a2b2979..82487f9107 100644 --- a/packages/libp2p/test/connection-manager/direct.spec.ts +++ b/packages/libp2p/test/connection-manager/direct.spec.ts @@ -2,8 +2,7 @@ import { yamux } from '@chainsafe/libp2p-yamux' import { type Identify, identify } from '@libp2p/identify' -import { AbortError, ERR_TIMEOUT } from '@libp2p/interface/errors' -import { TypedEventEmitter } from '@libp2p/interface/events' +import { AbortError, ERR_TIMEOUT, TypedEventEmitter } from '@libp2p/interface' import { mockConnectionGater, mockDuplex, mockMultiaddrConnection, mockUpgrader, mockConnection } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { mplex } from '@libp2p/mplex' @@ -29,10 +28,8 @@ import { codes as ErrorCodes } from '../../src/errors.js' import { createLibp2p } from '../../src/index.js' import { DefaultTransportManager } from '../../src/transport-manager.js' import { createPeerId } from '../fixtures/creators/peer.js' -import type { Libp2p } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { Libp2p, Connection, PeerId } from '@libp2p/interface' +import type { TransportManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' const unsupportedAddr = multiaddr('/ip4/127.0.0.1/tcp/9999') @@ -355,6 +352,7 @@ describe('libp2p.dialer (direct, WebSockets)', () => { }) ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -400,6 +398,7 @@ describe('libp2p.dialer (direct, WebSockets)', () => { }) ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux() ], connectionEncryption: [ @@ -442,6 +441,7 @@ describe('libp2p.dialer (direct, WebSockets)', () => { }) ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -472,6 +472,7 @@ describe('libp2p.dialer (direct, WebSockets)', () => { }) ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -493,6 +494,7 @@ describe('libp2p.dialer (direct, WebSockets)', () => { }) ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], diff --git a/packages/libp2p/test/connection-manager/index.node.ts b/packages/libp2p/test/connection-manager/index.node.ts index d15d695bb3..ff3ff21fce 100644 --- a/packages/libp2p/test/connection-manager/index.node.ts +++ b/packages/libp2p/test/connection-manager/index.node.ts @@ -1,7 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter } from '@libp2p/interface/events' -import { start } from '@libp2p/interface/startable' +import { TypedEventEmitter, start } from '@libp2p/interface' import { mockConnection, mockDuplex, mockMultiaddrConnection } from '@libp2p/interface-compliance-tests/mocks' import { expect } from 'aegir/chai' import delay from 'delay' @@ -18,10 +17,8 @@ import { createNode, createPeerId } from '../fixtures/creators/peer.js' import { ECHO_PROTOCOL, echo } from '../fixtures/echo-service.js' import type { Libp2p } from '../../src/index.js' import type { Libp2pNode } from '../../src/libp2p.js' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ConnectionGater, PeerId, PeerStore } from '@libp2p/interface' +import type { TransportManager } from '@libp2p/interface-internal' describe('Connection Manager', () => { let libp2p: Libp2p diff --git a/packages/libp2p/test/connection-manager/index.spec.ts b/packages/libp2p/test/connection-manager/index.spec.ts index 17b33439dc..10d030d662 100644 --- a/packages/libp2p/test/connection-manager/index.spec.ts +++ b/packages/libp2p/test/connection-manager/index.spec.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { KEEP_ALIVE } from '@libp2p/interface/peer-store/tags' import { mockConnection, mockDuplex, mockMultiaddrConnection, mockMetrics } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' @@ -15,12 +15,8 @@ import { DefaultConnectionManager, type DefaultConnectionManagerComponents } fro import { createBaseOptions } from '../fixtures/base-options.browser.js' import { createNode } from '../fixtures/creators/peer.js' import type { Libp2pNode } from '../../src/libp2p.js' -import type { AbortOptions } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { AbortOptions, Connection, ConnectionGater, PeerId, PeerStore } from '@libp2p/interface' +import type { TransportManager } from '@libp2p/interface-internal' const defaultOptions = { maxConnections: 10, diff --git a/packages/libp2p/test/connection-manager/resolver.spec.ts b/packages/libp2p/test/connection-manager/resolver.spec.ts index b19dd34665..f49532a0f6 100644 --- a/packages/libp2p/test/connection-manager/resolver.spec.ts +++ b/packages/libp2p/test/connection-manager/resolver.spec.ts @@ -16,8 +16,7 @@ import pDefer from 'p-defer' import sinon from 'sinon' import { codes as ErrorCodes } from '../../src/errors.js' import { createLibp2pNode, type Libp2pNode } from '../../src/libp2p.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Transport } from '@libp2p/interface/transport' +import type { PeerId, Transport } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' const relayAddr = multiaddr(process.env.RELAY_MULTIADDR) @@ -57,6 +56,7 @@ describe('dialing (resolvable addresses)', () => { }) ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -81,6 +81,7 @@ describe('dialing (resolvable addresses)', () => { }) ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], diff --git a/packages/libp2p/test/connection/compliance.spec.ts b/packages/libp2p/test/connection/compliance.spec.ts index 4c69fe7d97..94a9df75c8 100644 --- a/packages/libp2p/test/connection/compliance.spec.ts +++ b/packages/libp2p/test/connection/compliance.spec.ts @@ -5,7 +5,7 @@ import * as PeerIdFactory from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' import { createConnection } from '../../src/connection/index.js' import { pair } from './fixtures/pair.js' -import type { Stream } from '@libp2p/interface/connection' +import type { Stream } from '@libp2p/interface' describe('connection compliance', () => { tests({ diff --git a/packages/libp2p/test/content-routing/content-routing.node.ts b/packages/libp2p/test/content-routing/content-routing.node.ts index 64f95d5616..8ec21f139b 100644 --- a/packages/libp2p/test/content-routing/content-routing.node.ts +++ b/packages/libp2p/test/content-routing/content-routing.node.ts @@ -14,8 +14,7 @@ import { createLibp2p, type Libp2p } from '../../src/index.js' import { createBaseOptions } from '../fixtures/base-options.js' import { createNode, createPeerId, populateAddressBooks } from '../fixtures/creators/peer.js' import { createRoutingOptions } from './utils.js' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { ContentRouting, PeerInfo } from '@libp2p/interface' describe('content-routing', () => { describe('no routers', () => { diff --git a/packages/libp2p/test/content-routing/dht/operation.node.ts b/packages/libp2p/test/content-routing/dht/operation.node.ts index c52c6d7f81..3ecec50b31 100644 --- a/packages/libp2p/test/content-routing/dht/operation.node.ts +++ b/packages/libp2p/test/content-routing/dht/operation.node.ts @@ -12,8 +12,7 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { createLibp2p } from '../../../src/index.js' import { createPeerId } from '../../fixtures/creators/peer.js' import { subsystemMulticodecs } from './utils.js' -import type { Libp2p } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { Libp2p, PeerId } from '@libp2p/interface' import type { DualKadDHT } from '@libp2p/kad-dht' import type { Multiaddr } from '@multiformats/multiaddr' @@ -60,6 +59,7 @@ describe('DHT subsystem operates correctly', () => { plaintext() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -82,6 +82,7 @@ describe('DHT subsystem operates correctly', () => { plaintext() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], diff --git a/packages/libp2p/test/core/encryption.spec.ts b/packages/libp2p/test/core/encryption.spec.ts index a51bd35a6f..b6819ce70e 100644 --- a/packages/libp2p/test/core/encryption.spec.ts +++ b/packages/libp2p/test/core/encryption.spec.ts @@ -4,7 +4,7 @@ import { plaintext } from '@libp2p/plaintext' import { webSockets } from '@libp2p/websockets' import { createLibp2p, type Libp2pOptions } from '../../src/index.js' import { createPeerId } from '../fixtures/creators/peer.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' describe('Connection encryption configuration', () => { let peerId: PeerId diff --git a/packages/libp2p/test/core/listening.node.ts b/packages/libp2p/test/core/listening.node.ts index 99c445581d..d05a516024 100644 --- a/packages/libp2p/test/core/listening.node.ts +++ b/packages/libp2p/test/core/listening.node.ts @@ -5,7 +5,7 @@ import { tcp } from '@libp2p/tcp' import { expect } from 'aegir/chai' import { createLibp2pNode, type Libp2pNode } from '../../src/libp2p.js' import { createPeerId } from '../fixtures/creators/peer.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' const listenAddr = '/ip4/0.0.0.0/tcp/0' diff --git a/packages/libp2p/test/fixtures/base-options.ts b/packages/libp2p/test/fixtures/base-options.ts index 813a41aaa3..2cc53f72fe 100644 --- a/packages/libp2p/test/fixtures/base-options.ts +++ b/packages/libp2p/test/fixtures/base-options.ts @@ -22,6 +22,7 @@ export function createBaseOptions p.toString() === peerId.toString()) diff --git a/packages/libp2p/test/interop.ts b/packages/libp2p/test/interop.ts index af9991a661..7158f904f8 100644 --- a/packages/libp2p/test/interop.ts +++ b/packages/libp2p/test/interop.ts @@ -8,9 +8,7 @@ import { createClient } from '@libp2p/daemon-client' import { createServer } from '@libp2p/daemon-server' import { floodsub } from '@libp2p/floodsub' import { identify } from '@libp2p/identify' -import { contentRouting } from '@libp2p/interface/content-routing' -import { peerDiscovery } from '@libp2p/interface/peer-discovery' -import { peerRouting } from '@libp2p/interface/peer-routing' +import { contentRoutingSymbol, peerDiscoverySymbol, peerRoutingSymbol } from '@libp2p/interface' import { interopTests } from '@libp2p/interop' import { kadDHT } from '@libp2p/kad-dht' import { logger } from '@libp2p/logger' @@ -22,8 +20,7 @@ import { execa } from 'execa' import { path as p2pd } from 'go-libp2p' import pDefer from 'p-defer' import { createLibp2p, type Libp2pOptions, type ServiceFactoryMap } from '../src/index.js' -import type { ServiceMap } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { ServiceMap, PeerId } from '@libp2p/interface' import type { SpawnOptions, Daemon, DaemonFactory } from '@libp2p/interop' /** @@ -129,6 +126,7 @@ async function createJsPeer (options: SpawnOptions): Promise { }, transports: [tcp(), circuitRelayTransport()], streamMuxers: [], + // @ts-expect-error TODO: noise needs to be upgraded connectionEncryption: [noise()], connectionManager: { minConnections: 0 @@ -142,6 +140,7 @@ async function createJsPeer (options: SpawnOptions): Promise { if (options.muxer === 'mplex') { opts.streamMuxers?.push(mplex()) } else { + // @ts-expect-error TODO: yamux needs to be upgraded opts.streamMuxers?.push(yamux()) } @@ -174,19 +173,19 @@ async function createJsPeer (options: SpawnOptions): Promise { lan.topologyListener.protocol = protocol Object.defineProperties(lan, { - [contentRouting]: { + [contentRoutingSymbol]: { get () { - return dht[contentRouting] + return dht[contentRoutingSymbol] } }, - [peerRouting]: { + [peerRoutingSymbol]: { get () { - return dht[peerRouting] + return dht[peerRoutingSymbol] } }, - [peerDiscovery]: { + [peerDiscoverySymbol]: { get () { - return dht[peerDiscovery] + return dht[peerDiscoverySymbol] } } }) diff --git a/packages/libp2p/test/peer-discovery/index.node.ts b/packages/libp2p/test/peer-discovery/index.node.ts index d3d6bd0939..3749b7f3e0 100644 --- a/packages/libp2p/test/peer-discovery/index.node.ts +++ b/packages/libp2p/test/peer-discovery/index.node.ts @@ -2,8 +2,7 @@ import { bootstrap } from '@libp2p/bootstrap' import { randomBytes } from '@libp2p/crypto' -import { TypedEventEmitter } from '@libp2p/interface/events' -import { peerDiscovery } from '@libp2p/interface/peer-discovery' +import { TypedEventEmitter, peerDiscoverySymbol } from '@libp2p/interface' import { kadDHT } from '@libp2p/kad-dht' import { mdns } from '@libp2p/mdns' import { multiaddr } from '@multiformats/multiaddr' @@ -15,15 +14,13 @@ import { createLibp2p } from '../../src/index.js' import { createBaseOptions } from '../fixtures/base-options.js' import { createPeerId } from '../fixtures/creators/peer.js' import type { Libp2pOptions } from '../../src/index.js' -import type { Libp2p } from '@libp2p/interface' -import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interface/peer-discovery' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { Libp2p, PeerDiscovery, PeerDiscoveryEvents, PeerId } from '@libp2p/interface' import type { KadDHT } from '@libp2p/kad-dht' const listenAddr = multiaddr('/ip4/127.0.0.1/tcp/0') class TestPeerDiscovery extends TypedEventEmitter implements PeerDiscovery { - get [peerDiscovery] (): PeerDiscovery { + get [peerDiscoverySymbol] (): PeerDiscovery { return this } diff --git a/packages/libp2p/test/peer-discovery/index.spec.ts b/packages/libp2p/test/peer-discovery/index.spec.ts index c29dee1c3b..29925db697 100644 --- a/packages/libp2p/test/peer-discovery/index.spec.ts +++ b/packages/libp2p/test/peer-discovery/index.spec.ts @@ -6,9 +6,7 @@ import { stubInterface } from 'sinon-ts' import { createLibp2pNode, type Libp2pNode } from '../../src/libp2p.js' import { createBaseOptions } from '../fixtures/base-options.browser.js' import { createPeerId } from '../fixtures/creators/peer.js' -import type { PeerDiscovery } from '@libp2p/interface/peer-discovery' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Startable } from '@libp2p/interface/startable' +import type { PeerDiscovery, PeerId, Startable } from '@libp2p/interface' describe('peer discovery', () => { describe('basic functions', () => { diff --git a/packages/libp2p/test/peer-routing/peer-routing.node.ts b/packages/libp2p/test/peer-routing/peer-routing.node.ts index 4e64d9da7e..d57fbf1d81 100644 --- a/packages/libp2p/test/peer-routing/peer-routing.node.ts +++ b/packages/libp2p/test/peer-routing/peer-routing.node.ts @@ -14,10 +14,7 @@ import { createBaseOptions } from '../fixtures/base-options.js' import { createNode, createPeerId, populateAddressBooks } from '../fixtures/creators/peer.js' import { createRoutingOptions } from './utils.js' import type { Libp2pNode } from '../../src/libp2p.js' -import type { Libp2p } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerRouting } from '@libp2p/interface/peer-routing' +import type { Libp2p, PeerId, PeerInfo, PeerRouting } from '@libp2p/interface' describe('peer-routing', () => { let peerId: PeerId diff --git a/packages/libp2p/test/registrar/registrar.spec.ts b/packages/libp2p/test/registrar/registrar.spec.ts index 6ae61b6f2a..e38cbc9f5d 100644 --- a/packages/libp2p/test/registrar/registrar.spec.ts +++ b/packages/libp2p/test/registrar/registrar.spec.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ import { yamux } from '@chainsafe/libp2p-yamux' -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' +import { TypedEventEmitter, type TypedEventTarget, type Libp2pEvents, type ConnectionGater, type PeerId, type PeerStore, type Topology } from '@libp2p/interface' import { mockDuplex, mockMultiaddrConnection, mockUpgrader, mockConnection } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { mplex } from '@libp2p/mplex' @@ -19,14 +19,7 @@ import { createLibp2pNode, type Libp2pNode } from '../../src/libp2p.js' import { DefaultRegistrar } from '../../src/registrar.js' import { createPeerId } from '../fixtures/creators/peer.js' import { matchPeerId } from '../fixtures/match-peer-id.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Topology } from '@libp2p/interface/topology' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal' const protocol = '/test/1.0.0' @@ -409,6 +402,7 @@ describe('registrar', () => { webSockets() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], diff --git a/packages/libp2p/test/transports/transport-manager.node.ts b/packages/libp2p/test/transports/transport-manager.node.ts index 52bc09d379..15b78e8f34 100644 --- a/packages/libp2p/test/transports/transport-manager.node.ts +++ b/packages/libp2p/test/transports/transport-manager.node.ts @@ -1,8 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter } from '@libp2p/interface/events' -import { start, stop } from '@libp2p/interface/startable' -import { FaultTolerance } from '@libp2p/interface/transport' +import { TypedEventEmitter, start, stop, FaultTolerance } from '@libp2p/interface' import { mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' @@ -17,7 +15,7 @@ import sinon from 'sinon' import { DefaultAddressManager } from '../../src/address-manager/index.js' import { defaultComponents, type Components } from '../../src/components.js' import { DefaultTransportManager } from '../../src/transport-manager.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' const addrs = [ multiaddr('/ip4/127.0.0.1/tcp/0'), diff --git a/packages/libp2p/test/transports/transport-manager.spec.ts b/packages/libp2p/test/transports/transport-manager.spec.ts index fe1c34b6d8..3fdb0d2892 100644 --- a/packages/libp2p/test/transports/transport-manager.spec.ts +++ b/packages/libp2p/test/transports/transport-manager.spec.ts @@ -1,8 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter } from '@libp2p/interface/events' -import { start, stop } from '@libp2p/interface/startable' -import { FaultTolerance } from '@libp2p/interface/transport' +import { TypedEventEmitter, start, stop, FaultTolerance } from '@libp2p/interface' import { mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' @@ -17,8 +15,7 @@ import { codes as ErrorCodes } from '../../src/errors.js' import { createLibp2p } from '../../src/index.js' import { DefaultTransportManager } from '../../src/transport-manager.js' import type { Components } from '../../src/components.js' -import type { Libp2p } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { Libp2p, PeerId } from '@libp2p/interface' const listenAddr = multiaddr('/ip4/127.0.0.1/tcp/0') diff --git a/packages/libp2p/test/upgrading/upgrader.spec.ts b/packages/libp2p/test/upgrading/upgrader.spec.ts index 81103edfae..2efa324718 100644 --- a/packages/libp2p/test/upgrading/upgrader.spec.ts +++ b/packages/libp2p/test/upgrading/upgrader.spec.ts @@ -2,7 +2,7 @@ import { yamux } from '@chainsafe/libp2p-yamux' import { circuitRelayTransport } from '@libp2p/circuit-relay-v2' -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { mockConnectionGater, mockConnectionManager, mockMultiaddrConnPair, mockRegistrar, mockStream, mockMuxer } from '@libp2p/interface-compliance-tests/mocks' import { mplex } from '@libp2p/mplex' import { createEd25519PeerId } from '@libp2p/peer-id-factory' @@ -28,12 +28,7 @@ import { codes } from '../../src/errors.js' import { createLibp2p } from '../../src/index.js' import { DEFAULT_MAX_OUTBOUND_STREAMS } from '../../src/registrar.js' import { DefaultUpgrader } from '../../src/upgrader.js' -import type { Libp2p } from '@libp2p/interface' -import type { Connection, ConnectionProtector, Stream } from '@libp2p/interface/connection' -import type { ConnectionEncrypter, SecuredConnection } from '@libp2p/interface/connection-encrypter' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface/stream-muxer' -import type { Upgrader } from '@libp2p/interface/transport' +import type { Libp2p, Connection, ConnectionProtector, Stream, ConnectionEncrypter, SecuredConnection, PeerId, StreamMuxer, StreamMuxerFactory, StreamMuxerInit, Upgrader } from '@libp2p/interface' const addrs = [ multiaddr('/ip4/127.0.0.1/tcp/0'), @@ -79,6 +74,7 @@ describe('Upgrader', () => { localComponents.peerStore = new PersistentPeerStore(localComponents) localComponents.connectionManager = mockConnectionManager(localComponents) localMuxerFactory = mplex()(localComponents) + // @ts-expect-error TODO: yamux needs to be upgraded localYamuxerFactory = yamux()() localConnectionEncrypter = plaintext()(localComponents) localUpgrader = new DefaultUpgrader(localComponents, { @@ -106,6 +102,7 @@ describe('Upgrader', () => { remoteComponents.peerStore = new PersistentPeerStore(remoteComponents) remoteComponents.connectionManager = mockConnectionManager(remoteComponents) remoteMuxerFactory = mplex()(remoteComponents) + // @ts-expect-error TODO: yamux needs to be upgraded remoteYamuxerFactory = yamux()() remoteConnectionEncrypter = plaintext()(remoteComponents) remoteUpgrader = new DefaultUpgrader(remoteComponents, { @@ -288,6 +285,7 @@ describe('Upgrader', () => { plaintext()(localComponents) ], muxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux()() ], inboundUpgradeTimeout: 1000 @@ -297,6 +295,7 @@ describe('Upgrader', () => { plaintext()(localComponents) ], muxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux()() ], inboundUpgradeTimeout: 1000 @@ -368,6 +367,7 @@ describe('Upgrader', () => { plaintext()(localComponents) ], muxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux()(), mplex()(localComponents) ], @@ -638,6 +638,7 @@ describe('libp2p.upgrader', () => { webSockets() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -669,6 +670,7 @@ describe('libp2p.upgrader', () => { webSockets() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -690,6 +692,7 @@ describe('libp2p.upgrader', () => { webSockets() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -737,6 +740,7 @@ describe('libp2p.upgrader', () => { circuitRelayTransport() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -756,6 +760,7 @@ describe('libp2p.upgrader', () => { circuitRelayTransport() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux(), mplex() ], @@ -883,6 +888,7 @@ describe('libp2p.upgrader', () => { webSockets() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux() ], connectionEncryption: [ @@ -902,6 +908,7 @@ describe('libp2p.upgrader', () => { webSockets() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux() ], connectionEncryption: [ @@ -959,6 +966,7 @@ describe('libp2p.upgrader', () => { webSockets() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux() ], connectionEncryption: [ @@ -978,6 +986,7 @@ describe('libp2p.upgrader', () => { webSockets() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux() ], connectionEncryption: [ diff --git a/packages/logger/CHANGELOG.md b/packages/logger/CHANGELOG.md index c75a0b4e65..422924f09a 100644 --- a/packages/logger/CHANGELOG.md +++ b/packages/logger/CHANGELOG.md @@ -5,6 +5,28 @@ * specify updated formatter for multiaddrs ([#36](https://github.com/libp2p/js-libp2p-logger/issues/36)) ([abaefb4](https://github.com/libp2p/js-libp2p-logger/commit/abaefb490a0d9464a23b422d9fc5b80051532d10)) +## [4.0.0](https://www.github.com/libp2p/js-libp2p/compare/logger-v3.1.0...logger-v4.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/dcutr` now need to be from `@libp2p/dcutr` +* imports from `libp2p/identify` need to change to `@libp2p/identify` + +### Code Refactoring + +* extract DCUtR into separate module ([#2220](https://www.github.com/libp2p/js-libp2p/issues/2220)) ([d2c3e72](https://www.github.com/libp2p/js-libp2p/commit/d2c3e7235b64558c6cace414c54a42659fee2970)) +* extract identify service into separate module ([#2219](https://www.github.com/libp2p/js-libp2p/issues/2219)) ([72c2f77](https://www.github.com/libp2p/js-libp2p/commit/72c2f775bd85bd4928048dda0fd14740d6fb6a69)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * devDependencies + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + ## [3.1.0](https://www.github.com/libp2p/js-libp2p/compare/logger-v3.0.5...logger-v3.1.0) (2023-11-07) diff --git a/packages/logger/package.json b/packages/logger/package.json index 2c96cd7799..1d81762345 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/logger", - "version": "3.1.0", + "version": "4.0.0", "description": "A logging component for use in js-libp2p modules", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/logger#readme", @@ -53,14 +53,14 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", + "@libp2p/interface": "^1.0.0", "@multiformats/multiaddr": "^12.1.10", "debug": "^4.3.4", "interface-datastore": "^8.2.0", "multiformats": "^12.1.3" }, "devDependencies": { - "@libp2p/peer-id": "^3.0.6", + "@libp2p/peer-id": "^4.0.0", "@types/debug": "^4.1.7", "aegir": "^41.0.2", "sinon": "^17.0.0", diff --git a/packages/logger/src/index.ts b/packages/logger/src/index.ts index 3dce448a66..6e88882c44 100644 --- a/packages/logger/src/index.ts +++ b/packages/logger/src/index.ts @@ -32,7 +32,7 @@ import { base32 } from 'multiformats/bases/base32' import { base58btc } from 'multiformats/bases/base58' import { base64 } from 'multiformats/bases/base64' import { truncatePeerId } from './utils.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' import type { Key } from 'interface-datastore' import type { CID } from 'multiformats/cid' diff --git a/packages/logger/src/utils.ts b/packages/logger/src/utils.ts index 27b4ebcc62..ac6b5d9a6a 100644 --- a/packages/logger/src/utils.ts +++ b/packages/logger/src/utils.ts @@ -1,5 +1,5 @@ import type { PeerLoggerOptions } from './index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' export function truncatePeerId (peerId: PeerId, options: Partial = {}): string { const prefixLength = options.prefixLength ?? 2 diff --git a/packages/metrics-prometheus/CHANGELOG.md b/packages/metrics-prometheus/CHANGELOG.md index 452ba7a5a7..5a4b756755 100644 --- a/packages/metrics-prometheus/CHANGELOG.md +++ b/packages/metrics-prometheus/CHANGELOG.md @@ -5,6 +5,33 @@ * move prom-client to deps ([#32](https://github.com/libp2p/js-libp2p-prometheus-metrics/issues/32)) ([73acad0](https://github.com/libp2p/js-libp2p-prometheus-metrics/commit/73acad0a20a9a0ad024cd47a53f154668dbae77b)) +## [3.0.0](https://www.github.com/libp2p/js-libp2p/compare/prometheus-metrics-v2.0.12...prometheus-metrics-v3.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + ### [2.0.12](https://www.github.com/libp2p/js-libp2p/compare/prometheus-metrics-v2.0.11...prometheus-metrics-v2.0.12) (2023-11-07) @@ -250,4 +277,4 @@ ### Documentation -* update readme to link to correct branch ([1a7565b](https://github.com/libp2p/js-libp2p-prometheus-metrics/commit/1a7565b5986ba689eb7a6d555b15ca1a4e4d3f31)) +* update readme to link to correct branch ([1a7565b](https://github.com/libp2p/js-libp2p-prometheus-metrics/commit/1a7565b5986ba689eb7a6d555b15ca1a4e4d3f31)) \ No newline at end of file diff --git a/packages/metrics-prometheus/package.json b/packages/metrics-prometheus/package.json index 45074e85c3..e551357f59 100644 --- a/packages/metrics-prometheus/package.json +++ b/packages/metrics-prometheus/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/prometheus-metrics", - "version": "2.0.12", + "version": "3.0.0", "description": "Collect libp2p metrics for scraping by Prometheus or Graphana", "author": "", "license": "Apache-2.0 OR MIT", @@ -47,16 +47,16 @@ "test:electron-main": "aegir test -t electron-main --cov" }, "dependencies": { - "@libp2p/interface": "^0.1.6", + "@libp2p/interface": "^1.0.0", "it-foreach": "^2.0.3", "it-stream-types": "^2.0.1", "prom-client": "^15.0.0", "uint8arraylist": "^2.4.3" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "@multiformats/multiaddr": "^12.1.10", "aegir": "^41.0.2", "it-drain": "^3.0.3", diff --git a/packages/metrics-prometheus/src/counter-group.ts b/packages/metrics-prometheus/src/counter-group.ts index 077255e060..1c91c48b9b 100644 --- a/packages/metrics-prometheus/src/counter-group.ts +++ b/packages/metrics-prometheus/src/counter-group.ts @@ -1,7 +1,7 @@ import { Counter as PromCounter, type CollectFunction } from 'prom-client' import { normaliseString, type CalculatedMetric } from './utils.js' import type { PrometheusCalculatedMetricOptions } from './index.js' -import type { CounterGroup, CalculateMetric } from '@libp2p/interface/metrics' +import type { CounterGroup, CalculateMetric } from '@libp2p/interface' export class PrometheusCounterGroup implements CounterGroup, CalculatedMetric> { private readonly counter: PromCounter diff --git a/packages/metrics-prometheus/src/counter.ts b/packages/metrics-prometheus/src/counter.ts index 7e34452cee..771c68ff5f 100644 --- a/packages/metrics-prometheus/src/counter.ts +++ b/packages/metrics-prometheus/src/counter.ts @@ -1,7 +1,7 @@ import { type CollectFunction, Counter as PromCounter } from 'prom-client' import { normaliseString, type CalculatedMetric } from './utils.js' import type { PrometheusCalculatedMetricOptions } from './index.js' -import type { CalculateMetric, Counter } from '@libp2p/interface/metrics' +import type { CalculateMetric, Counter } from '@libp2p/interface' export class PrometheusCounter implements Counter, CalculatedMetric { private readonly counter: PromCounter diff --git a/packages/metrics-prometheus/src/index.ts b/packages/metrics-prometheus/src/index.ts index 9a5c8255c9..437a44f6e3 100644 --- a/packages/metrics-prometheus/src/index.ts +++ b/packages/metrics-prometheus/src/index.ts @@ -161,9 +161,7 @@ import { PrometheusCounterGroup } from './counter-group.js' import { PrometheusCounter } from './counter.js' import { PrometheusMetricGroup } from './metric-group.js' import { PrometheusMetric } from './metric.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { MultiaddrConnection, Stream, Connection } from '@libp2p/interface/connection' -import type { CalculatedMetricOptions, Counter, CounterGroup, Metric, MetricGroup, MetricOptions, Metrics } from '@libp2p/interface/metrics' +import type { ComponentLogger, Logger, MultiaddrConnection, Stream, Connection, CalculatedMetricOptions, Counter, CounterGroup, Metric, MetricGroup, MetricOptions, Metrics } from '@libp2p/interface' import type { Duplex } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/metrics-prometheus/src/metric-group.ts b/packages/metrics-prometheus/src/metric-group.ts index 652e99bbcc..9909ffdd70 100644 --- a/packages/metrics-prometheus/src/metric-group.ts +++ b/packages/metrics-prometheus/src/metric-group.ts @@ -1,7 +1,7 @@ import { type CollectFunction, Gauge } from 'prom-client' import { normaliseString, type CalculatedMetric } from './utils.js' import type { PrometheusCalculatedMetricOptions } from './index.js' -import type { CalculateMetric, MetricGroup, StopTimer } from '@libp2p/interface/metrics' +import type { CalculateMetric, MetricGroup, StopTimer } from '@libp2p/interface' export class PrometheusMetricGroup implements MetricGroup, CalculatedMetric> { private readonly gauge: Gauge diff --git a/packages/metrics-prometheus/src/metric.ts b/packages/metrics-prometheus/src/metric.ts index fc61570f26..f00bdfc962 100644 --- a/packages/metrics-prometheus/src/metric.ts +++ b/packages/metrics-prometheus/src/metric.ts @@ -1,7 +1,7 @@ import { type CollectFunction, Gauge } from 'prom-client' import { normaliseString } from './utils.js' import type { PrometheusCalculatedMetricOptions } from './index.js' -import type { Metric, StopTimer, CalculateMetric } from '@libp2p/interface/metrics' +import type { Metric, StopTimer, CalculateMetric } from '@libp2p/interface' export class PrometheusMetric implements Metric { private readonly gauge: Gauge diff --git a/packages/metrics-prometheus/src/utils.ts b/packages/metrics-prometheus/src/utils.ts index 83e12cb52c..81d81531a2 100644 --- a/packages/metrics-prometheus/src/utils.ts +++ b/packages/metrics-prometheus/src/utils.ts @@ -1,4 +1,4 @@ -import type { CalculateMetric } from '@libp2p/interface/metrics' +import type { CalculateMetric } from '@libp2p/interface' export interface CalculatedMetric { addCalculator(calculator: CalculateMetric): void diff --git a/packages/metrics-prometheus/test/streams.spec.ts b/packages/metrics-prometheus/test/streams.spec.ts index 085e0ceba2..b14446db97 100644 --- a/packages/metrics-prometheus/test/streams.spec.ts +++ b/packages/metrics-prometheus/test/streams.spec.ts @@ -8,7 +8,7 @@ import { pipe } from 'it-pipe' import defer from 'p-defer' import client from 'prom-client' import { prometheusMetrics } from '../src/index.js' -import type { Connection } from '@libp2p/interface/connection' +import type { Connection } from '@libp2p/interface' describe('streams', () => { let connectionA: Connection diff --git a/packages/multistream-select/CHANGELOG.md b/packages/multistream-select/CHANGELOG.md index 3d32480085..8cac64b5ea 100644 --- a/packages/multistream-select/CHANGELOG.md +++ b/packages/multistream-select/CHANGELOG.md @@ -11,6 +11,24 @@ * **dev:** bump aegir from 38.1.8 to 39.0.10 ([#70](https://github.com/libp2p/js-libp2p-multistream-select/issues/70)) ([f87b1c3](https://github.com/libp2p/js-libp2p-multistream-select/commit/f87b1c3505934ebeed6eff018af8d3042e7e6e06)) +### [4.0.7](https://www.github.com/libp2p/js-libp2p/compare/multistream-select-v4.0.6...multistream-select-v4.0.7) (2023-11-28) + + +### Bug Fixes + +* allow mss lazy select on read ([#2246](https://www.github.com/libp2p/js-libp2p/issues/2246)) ([d8f5bc2](https://www.github.com/libp2p/js-libp2p/commit/d8f5bc211185a963c2a5182d58d73629457bc78d)) +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) +* use optimistic protocol negotation ([#2253](https://www.github.com/libp2p/js-libp2p/issues/2253)) ([0b4a2ee](https://www.github.com/libp2p/js-libp2p/commit/0b4a2ee7983b4dc9dc0a7b705a202a4c550e7017)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + ### [4.0.6](https://www.github.com/libp2p/js-libp2p/compare/multistream-select-v4.0.5...multistream-select-v4.0.6) (2023-11-07) @@ -289,4 +307,4 @@ ### Bug Fixes -* add multistream-select and update pubsub types ([#170](https://github.com/libp2p/js-libp2p-interfaces/issues/170)) ([b9ecb2b](https://github.com/libp2p/js-libp2p-interfaces/commit/b9ecb2bee8f2abc0c41bfcf7bf2025894e37ddc2)) +* add multistream-select and update pubsub types ([#170](https://github.com/libp2p/js-libp2p-interfaces/issues/170)) ([b9ecb2b](https://github.com/libp2p/js-libp2p-interfaces/commit/b9ecb2bee8f2abc0c41bfcf7bf2025894e37ddc2)) \ No newline at end of file diff --git a/packages/multistream-select/package.json b/packages/multistream-select/package.json index 361b91e3a7..d238332659 100644 --- a/packages/multistream-select/package.json +++ b/packages/multistream-select/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/multistream-select", - "version": "4.0.6", + "version": "4.0.7", "description": "JavaScript implementation of multistream-select", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/multistream-select#readme", @@ -57,7 +57,7 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", + "@libp2p/interface": "^1.0.0", "it-length-prefixed": "^9.0.3", "it-length-prefixed-stream": "^1.1.1", "it-pipe": "^3.0.1", @@ -68,7 +68,7 @@ "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", + "@libp2p/logger": "^4.0.0", "aegir": "^41.0.2", "iso-random-stream": "^2.0.2", "it-all": "^3.0.3", diff --git a/packages/multistream-select/src/multistream.ts b/packages/multistream-select/src/multistream.ts index 1f76f3dbbd..c1f9930015 100644 --- a/packages/multistream-select/src/multistream.ts +++ b/packages/multistream-select/src/multistream.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { type Uint8ArrayList } from 'uint8arraylist' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' diff --git a/packages/multistream-select/src/select.ts b/packages/multistream-select/src/select.ts index 526c6a4d2b..206ddce5a6 100644 --- a/packages/multistream-select/src/select.ts +++ b/packages/multistream-select/src/select.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { lpStream } from 'it-length-prefixed-stream' import pDefer from 'p-defer' import * as varint from 'uint8-varint' diff --git a/packages/peer-collections/CHANGELOG.md b/packages/peer-collections/CHANGELOG.md index abbe86db54..f0c844f00d 100644 --- a/packages/peer-collections/CHANGELOG.md +++ b/packages/peer-collections/CHANGELOG.md @@ -11,6 +11,18 @@ * **dev:** bump aegir from 38.1.8 to 39.0.10 ([#36](https://github.com/libp2p/js-libp2p-peer-collections/issues/36)) ([9fa3de6](https://github.com/libp2p/js-libp2p-peer-collections/commit/9fa3de6d85dbe1ade54fda86b597ed9ffe6d71d5)) +### [4.0.9](https://www.github.com/libp2p/js-libp2p/compare/peer-collections-v4.0.8...peer-collections-v4.0.9) (2023-11-28) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * devDependencies + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + ### [4.0.8](https://www.github.com/libp2p/js-libp2p/compare/peer-collections-v4.0.7...peer-collections-v4.0.8) (2023-11-07) diff --git a/packages/peer-collections/package.json b/packages/peer-collections/package.json index dacfb4a198..d5497d68d5 100644 --- a/packages/peer-collections/package.json +++ b/packages/peer-collections/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/peer-collections", - "version": "4.0.8", + "version": "4.0.9", "description": "Stores values against a peer id", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-collections#readme", @@ -53,11 +53,11 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/peer-id": "^3.0.6" + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-id": "^4.0.0" }, "devDependencies": { - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2" } } diff --git a/packages/peer-collections/src/list.ts b/packages/peer-collections/src/list.ts index 85aef3be23..f384b870c2 100644 --- a/packages/peer-collections/src/list.ts +++ b/packages/peer-collections/src/list.ts @@ -1,6 +1,6 @@ import { peerIdFromString } from '@libp2p/peer-id' import { mapIterable } from './util.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' /** * We can't use PeerIds as list entries because list entries are diff --git a/packages/peer-collections/src/map.ts b/packages/peer-collections/src/map.ts index 8c31af330b..324f884fa0 100644 --- a/packages/peer-collections/src/map.ts +++ b/packages/peer-collections/src/map.ts @@ -1,6 +1,6 @@ import { peerIdFromString } from '@libp2p/peer-id' import { mapIterable } from './util.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' /** * We can't use PeerIds as map keys because map keys are diff --git a/packages/peer-collections/src/set.ts b/packages/peer-collections/src/set.ts index 355c9a1581..538ec56d27 100644 --- a/packages/peer-collections/src/set.ts +++ b/packages/peer-collections/src/set.ts @@ -1,6 +1,6 @@ import { peerIdFromString } from '@libp2p/peer-id' import { mapIterable } from './util.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' /** * We can't use PeerIds as set entries because set entries are diff --git a/packages/peer-collections/test/set.spec.ts b/packages/peer-collections/test/set.spec.ts index 3479a19e23..5bbb32aa89 100644 --- a/packages/peer-collections/test/set.spec.ts +++ b/packages/peer-collections/test/set.spec.ts @@ -2,7 +2,7 @@ import { peerIdFromBytes } from '@libp2p/peer-id' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' import { PeerSet } from '../src/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' describe('peer-set', () => { it('should return a set', async () => { diff --git a/packages/peer-discovery-bootstrap/CHANGELOG.md b/packages/peer-discovery-bootstrap/CHANGELOG.md index 0bcaee6923..6e79dcbde6 100644 --- a/packages/peer-discovery-bootstrap/CHANGELOG.md +++ b/packages/peer-discovery-bootstrap/CHANGELOG.md @@ -9,6 +9,29 @@ * update @libp2p/interface-peer-discovery to 2.0.0 ([#176](https://github.com/libp2p/js-libp2p-bootstrap/issues/176)) ([1954e75](https://github.com/libp2p/js-libp2p-bootstrap/commit/1954e75fa4b1e6b3b42f885f663f989fd0e422ab)) +## [10.0.0](https://www.github.com/libp2p/js-libp2p/compare/bootstrap-v9.0.12...bootstrap-v10.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `.protocols` property has been removed from the `PeerInfo` interface + +### Bug Fixes + +* remove protocols from PeerInfo ([#2166](https://www.github.com/libp2p/js-libp2p/issues/2166)) ([5468cd1](https://www.github.com/libp2p/js-libp2p/commit/5468cd13a76281e46b221fdbd7d4005c0d3f2252)) +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + ### [9.0.12](https://www.github.com/libp2p/js-libp2p/compare/bootstrap-v9.0.11...bootstrap-v9.0.12) (2023-11-07) @@ -645,4 +668,4 @@ Co-authored-by: Alan Shaw -## [0.4.2](https://github.com/libp2p/js-ipfs-railing/compare/v0.4.1...v0.4.2) (2017-03-21) +## [0.4.2](https://github.com/libp2p/js-ipfs-railing/compare/v0.4.1...v0.4.2) (2017-03-21) \ No newline at end of file diff --git a/packages/peer-discovery-bootstrap/package.json b/packages/peer-discovery-bootstrap/package.json index d48171833a..304a3c1399 100644 --- a/packages/peer-discovery-bootstrap/package.json +++ b/packages/peer-discovery-bootstrap/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/bootstrap", - "version": "9.0.12", + "version": "10.0.0", "description": "Peer discovery via a list of bootstrap peers", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap#readme", @@ -53,14 +53,14 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/peer-id": "^3.0.6", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-id": "^4.0.0", "@multiformats/mafmt": "^12.1.6", "@multiformats/multiaddr": "^12.1.10" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", "aegir": "^41.0.2", "sinon-ts": "^2.0.0" } diff --git a/packages/peer-discovery-bootstrap/src/index.ts b/packages/peer-discovery-bootstrap/src/index.ts index 05345d6e75..9b06d3f2ed 100644 --- a/packages/peer-discovery-bootstrap/src/index.ts +++ b/packages/peer-discovery-bootstrap/src/index.ts @@ -42,21 +42,16 @@ * const libp2p = await createLibp2p(options) * * libp2p.on('peer:discovery', function (peerId) { - * console.this.log('found peer: ', peerId.toB58String()) + * console.log('found peer: ', peerId.toB58String()) * }) * ``` */ -import { TypedEventEmitter } from '@libp2p/interface/events' -import { peerDiscovery } from '@libp2p/interface/peer-discovery' +import { TypedEventEmitter, peerDiscoverySymbol } from '@libp2p/interface' import { peerIdFromString } from '@libp2p/peer-id' import { P2P } from '@multiformats/mafmt' import { multiaddr } from '@multiformats/multiaddr' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interface/peer-discovery' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' +import type { ComponentLogger, Logger, PeerDiscovery, PeerDiscoveryEvents, PeerInfo, PeerStore, Startable } from '@libp2p/interface' const DEFAULT_BOOTSTRAP_TAG_NAME = 'bootstrap' const DEFAULT_BOOTSTRAP_TAG_VALUE = 50 @@ -144,7 +139,7 @@ class Bootstrap extends TypedEventEmitter implements PeerDi this._init = options } - readonly [peerDiscovery] = this + readonly [peerDiscoverySymbol] = this readonly [Symbol.toStringTag] = '@libp2p/bootstrap' diff --git a/packages/peer-discovery-bootstrap/test/bootstrap.spec.ts b/packages/peer-discovery-bootstrap/test/bootstrap.spec.ts index 68fdb199cf..8549f71012 100644 --- a/packages/peer-discovery-bootstrap/test/bootstrap.spec.ts +++ b/packages/peer-discovery-bootstrap/test/bootstrap.spec.ts @@ -1,7 +1,6 @@ /* eslint-env mocha */ -import { isPeerId } from '@libp2p/interface/peer-id' -import { start, stop } from '@libp2p/interface/startable' +import { isPeerId, start, stop } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { peerIdFromString } from '@libp2p/peer-id' import { IPFS } from '@multiformats/mafmt' @@ -11,7 +10,7 @@ import { type StubbedInstance, stubInterface } from 'sinon-ts' import { bootstrap, type BootstrapComponents } from '../src/index.js' import peerList from './fixtures/default-peers.js' import partialValidPeerList from './fixtures/some-invalid-peers.js' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { PeerStore } from '@libp2p/interface' describe('bootstrap', () => { let components: BootstrapComponents diff --git a/packages/peer-discovery-bootstrap/test/compliance.spec.ts b/packages/peer-discovery-bootstrap/test/compliance.spec.ts index c6ce3411d5..9a5a46cb95 100644 --- a/packages/peer-discovery-bootstrap/test/compliance.spec.ts +++ b/packages/peer-discovery-bootstrap/test/compliance.spec.ts @@ -5,7 +5,7 @@ import { defaultLogger } from '@libp2p/logger' import { stubInterface } from 'sinon-ts' import { bootstrap } from '../src/index.js' import peerList from './fixtures/default-peers.js' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { PeerStore } from '@libp2p/interface' describe('compliance tests', () => { tests({ diff --git a/packages/peer-discovery-mdns/CHANGELOG.md b/packages/peer-discovery-mdns/CHANGELOG.md index 05f60040b3..59623e1024 100644 --- a/packages/peer-discovery-mdns/CHANGELOG.md +++ b/packages/peer-discovery-mdns/CHANGELOG.md @@ -9,6 +9,40 @@ * update @libp2p/interface-peer-discovery to 2.0.0 ([#197](https://github.com/libp2p/js-libp2p-mdns/issues/197)) ([e8172af](https://github.com/libp2p/js-libp2p-mdns/commit/e8172af8b9856a934327195238b00e5fbba436a4)) +## [10.0.0](https://www.github.com/libp2p/js-libp2p/compare/mdns-v9.0.14...mdns-v10.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* removed EventEmitter re-export - please use TypedEventEmitter instead +* the `isStarted` method has been removed from the `Startable` interface +* the `.protocols` property has been removed from the `PeerInfo` interface + +### Bug Fixes + +* remove event emitter type from interfaces ([#2196](https://www.github.com/libp2p/js-libp2p/issues/2196)) ([f3ec538](https://www.github.com/libp2p/js-libp2p/commit/f3ec538451afe105a5a4513d66832965ad63debe)) +* remove protocols from PeerInfo ([#2166](https://www.github.com/libp2p/js-libp2p/issues/2166)) ([5468cd1](https://www.github.com/libp2p/js-libp2p/commit/5468cd13a76281e46b221fdbd7d4005c0d3f2252)) +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* remove isStarted method from Startable ([#2145](https://www.github.com/libp2p/js-libp2p/issues/2145)) ([fca208f](https://www.github.com/libp2p/js-libp2p/commit/fca208f3763af041aa37b1cb915d2bc777acb96d)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/interface-internal bumped from ^0.1.9 to ^0.1.10 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + ### [9.0.14](https://www.github.com/libp2p/js-libp2p/compare/mdns-v9.0.13...mdns-v9.0.14) (2023-11-07) @@ -708,4 +742,4 @@ Co-authored-by: Jacob Heun -## [0.6.2](https://github.com/libp2p/js-libp2p-mdns/compare/v0.6.1...v0.6.2) (2017-03-21) +## [0.6.2](https://github.com/libp2p/js-libp2p-mdns/compare/v0.6.1...v0.6.2) (2017-03-21) \ No newline at end of file diff --git a/packages/peer-discovery-mdns/package.json b/packages/peer-discovery-mdns/package.json index 3eb021c180..540fca8dad 100644 --- a/packages/peer-discovery-mdns/package.json +++ b/packages/peer-discovery-mdns/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/mdns", - "version": "9.0.14", + "version": "10.0.0", "description": "Node.js libp2p mDNS discovery implementation for peer discovery", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns#readme", @@ -49,21 +49,21 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/peer-id": "^3.0.6", - "@libp2p/utils": "^4.0.7", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/utils": "^5.0.0", "@multiformats/multiaddr": "^12.1.10", "@types/multicast-dns": "^7.2.1", "dns-packet": "^5.4.0", "multicast-dns": "^7.2.5" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/interface-internal": "^0.1.9", - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "p-wait-for": "^5.0.2", - "ts-sinon": "^2.0.2" + "sinon-ts": "^2.0.0" } } diff --git a/packages/peer-discovery-mdns/src/index.ts b/packages/peer-discovery-mdns/src/index.ts index 6f78e6f7e2..cd6639e180 100644 --- a/packages/peer-discovery-mdns/src/index.ts +++ b/packages/peer-discovery-mdns/src/index.ts @@ -77,8 +77,23 @@ */ import { MulticastDNS } from './mdns.js' -import type { MulticastDNSInit, MulticastDNSComponents } from './mdns.js' -import type { PeerDiscovery } from '@libp2p/interface/peer-discovery' +import type { ComponentLogger, PeerDiscovery } from '@libp2p/interface' +import type { AddressManager } from '@libp2p/interface-internal' + +export interface MulticastDNSInit { + broadcast?: boolean + interval?: number + serviceTag?: string + peerName?: string + port?: number + ip?: string +} + +export interface MulticastDNSComponents { + addressManager: AddressManager + logger: ComponentLogger + +} export function mdns (init: MulticastDNSInit = {}): (components: MulticastDNSComponents) => PeerDiscovery { return (components: MulticastDNSComponents) => new MulticastDNS(components, init) diff --git a/packages/peer-discovery-mdns/src/mdns.ts b/packages/peer-discovery-mdns/src/mdns.ts index 6c748d5657..a07083b11a 100644 --- a/packages/peer-discovery-mdns/src/mdns.ts +++ b/packages/peer-discovery-mdns/src/mdns.ts @@ -1,27 +1,10 @@ -import { CustomEvent, TypedEventEmitter } from '@libp2p/interface/events' -import { peerDiscovery } from '@libp2p/interface/peer-discovery' +import { CustomEvent, TypedEventEmitter, peerDiscoverySymbol } from '@libp2p/interface' import multicastDNS from 'multicast-dns' import * as query from './query.js' import { stringGen } from './utils.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerDiscovery, PeerDiscoveryEvents } from '@libp2p/interface/peer-discovery' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { MulticastDNSComponents, MulticastDNSInit } from './index.js' +import type { Logger, PeerDiscovery, PeerDiscoveryEvents, PeerInfo } from '@libp2p/interface' import type { Startable } from '@libp2p/interface/src/startable.js' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' - -export interface MulticastDNSInit { - broadcast?: boolean - interval?: number - serviceTag?: string - peerName?: string - port?: number - ip?: string -} - -export interface MulticastDNSComponents { - addressManager: AddressManager - logger: ComponentLogger -} export class MulticastDNS extends TypedEventEmitter implements PeerDiscovery, Startable { public mdns?: multicastDNS.MulticastDNS @@ -58,7 +41,7 @@ export class MulticastDNS extends TypedEventEmitter impleme this._onMdnsError = this._onMdnsError.bind(this) } - readonly [peerDiscovery] = this + readonly [peerDiscoverySymbol] = this readonly [Symbol.toStringTag] = '@libp2p/mdns' diff --git a/packages/peer-discovery-mdns/src/query.ts b/packages/peer-discovery-mdns/src/query.ts index e4d0166ce9..29f0c41248 100644 --- a/packages/peer-discovery-mdns/src/query.ts +++ b/packages/peer-discovery-mdns/src/query.ts @@ -1,8 +1,7 @@ import { peerIdFromString } from '@libp2p/peer-id' import { isPrivate } from '@libp2p/utils/multiaddr/is-private' import { multiaddr, type Multiaddr, protocols } from '@multiformats/multiaddr' -import type { LoggerOptions } from '@libp2p/interface' -import type { PeerInfo } from '@libp2p/interface/peer-info' +import type { LoggerOptions, PeerInfo } from '@libp2p/interface' import type { Answer, StringAnswer, TxtAnswer } from 'dns-packet' import type { MulticastDNS, QueryPacket, ResponsePacket } from 'multicast-dns' diff --git a/packages/peer-discovery-mdns/test/compliance.spec.ts b/packages/peer-discovery-mdns/test/compliance.spec.ts index 9b798fc31a..6c9e3ee5af 100644 --- a/packages/peer-discovery-mdns/test/compliance.spec.ts +++ b/packages/peer-discovery-mdns/test/compliance.spec.ts @@ -1,13 +1,13 @@ /* eslint-env mocha */ -import { CustomEvent } from '@libp2p/interface/events' +import { CustomEvent } from '@libp2p/interface' import tests from '@libp2p/interface-compliance-tests/peer-discovery' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' -import { stubInterface } from 'ts-sinon' +import { stubInterface } from 'sinon-ts' import { MulticastDNS } from '../src/mdns.js' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' +import type { AddressManager } from '@libp2p/interface-internal' let discovery: MulticastDNS diff --git a/packages/peer-discovery-mdns/test/multicast-dns.spec.ts b/packages/peer-discovery-mdns/test/multicast-dns.spec.ts index 8a907a97bc..06fc7633d8 100644 --- a/packages/peer-discovery-mdns/test/multicast-dns.spec.ts +++ b/packages/peer-discovery-mdns/test/multicast-dns.spec.ts @@ -1,17 +1,16 @@ /* eslint-env mocha */ -import { start, stop } from '@libp2p/interface/startable' +import { start, stop } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import pWaitFor from 'p-wait-for' -import { stubInterface } from 'ts-sinon' +import { stubInterface } from 'sinon-ts' import { mdns } from './../src/index.js' -import type { MulticastDNSComponents } from './../src/mdns.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' +import type { MulticastDNSComponents } from './../src/index.js' +import type { PeerId, PeerInfo } from '@libp2p/interface' +import type { AddressManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' function getComponents (peerId: PeerId, multiaddrs: Multiaddr[]): MulticastDNSComponents { diff --git a/packages/peer-id-factory/CHANGELOG.md b/packages/peer-id-factory/CHANGELOG.md index bc2e1a418a..b4d7231a3e 100644 --- a/packages/peer-id-factory/CHANGELOG.md +++ b/packages/peer-id-factory/CHANGELOG.md @@ -5,6 +5,17 @@ * update README.md ([#59](https://github.com/libp2p/js-libp2p-peer-id/issues/59)) ([aba6483](https://github.com/libp2p/js-libp2p-peer-id/commit/aba6483dad028ee5c24bfc01135b77568666cfd3)) +### [3.0.9](https://www.github.com/libp2p/js-libp2p/compare/peer-id-factory-v3.0.8...peer-id-factory-v3.0.9) (2023-11-28) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/crypto bumped from ^2.0.8 to ^3.0.0 + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + ### [3.0.8](https://www.github.com/libp2p/js-libp2p/compare/peer-id-factory-v3.0.7...peer-id-factory-v3.0.8) (2023-11-07) diff --git a/packages/peer-id-factory/package.json b/packages/peer-id-factory/package.json index 42608233f3..a5eccdcf2d 100644 --- a/packages/peer-id-factory/package.json +++ b/packages/peer-id-factory/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/peer-id-factory", - "version": "3.0.8", + "version": "3.0.9", "description": "Create PeerId instances", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-id-factory#readme", @@ -57,9 +57,9 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/crypto": "^2.0.8", - "@libp2p/interface": "^0.1.6", - "@libp2p/peer-id": "^3.0.6", + "@libp2p/crypto": "^3.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-id": "^4.0.0", "multiformats": "^12.1.3", "protons-runtime": "^5.0.0", "uint8arraylist": "^2.4.3", diff --git a/packages/peer-id-factory/src/index.ts b/packages/peer-id-factory/src/index.ts index f40646befe..bc4fe85c3f 100644 --- a/packages/peer-id-factory/src/index.ts +++ b/packages/peer-id-factory/src/index.ts @@ -25,8 +25,7 @@ import { generateKeyPair, marshalPrivateKey, unmarshalPrivateKey, marshalPublicK import { peerIdFromKeys, peerIdFromBytes } from '@libp2p/peer-id' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { PeerIdProto } from './proto.js' -import type { PublicKey, PrivateKey } from '@libp2p/interface/keys' -import type { RSAPeerId, Ed25519PeerId, Secp256k1PeerId, PeerId } from '@libp2p/interface/peer-id' +import type { PublicKey, PrivateKey, RSAPeerId, Ed25519PeerId, Secp256k1PeerId, PeerId } from '@libp2p/interface' export const createEd25519PeerId = async (): Promise => { const key = await generateKeyPair('Ed25519') diff --git a/packages/peer-id/CHANGELOG.md b/packages/peer-id/CHANGELOG.md index c7d4f15918..cc5d08e3ab 100644 --- a/packages/peer-id/CHANGELOG.md +++ b/packages/peer-id/CHANGELOG.md @@ -5,6 +5,24 @@ * update README.md ([#59](https://github.com/libp2p/js-libp2p-peer-id/issues/59)) ([aba6483](https://github.com/libp2p/js-libp2p-peer-id/commit/aba6483dad028ee5c24bfc01135b77568666cfd3)) +## [4.0.0](https://www.github.com/libp2p/js-libp2p/compare/peer-id-v3.0.6...peer-id-v4.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/identify` need to change to `@libp2p/identify` + +### Code Refactoring + +* extract identify service into separate module ([#2219](https://www.github.com/libp2p/js-libp2p/issues/2219)) ([72c2f77](https://www.github.com/libp2p/js-libp2p/commit/72c2f775bd85bd4928048dda0fd14740d6fb6a69)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + ### [3.0.6](https://www.github.com/libp2p/js-libp2p/compare/peer-id-v3.0.5...peer-id-v3.0.6) (2023-11-07) @@ -316,4 +334,4 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### Features -* simpler peer id ([#117](https://github.com/libp2p/js-libp2p-interfaces/issues/117)) ([fa2c4f5](https://github.com/libp2p/js-libp2p-interfaces/commit/fa2c4f5be74a5cfc11489771881e57b4e53bf174)) +* simpler peer id ([#117](https://github.com/libp2p/js-libp2p-interfaces/issues/117)) ([fa2c4f5](https://github.com/libp2p/js-libp2p-interfaces/commit/fa2c4f5be74a5cfc11489771881e57b4e53bf174)) \ No newline at end of file diff --git a/packages/peer-id/package.json b/packages/peer-id/package.json index 2e76faa9f2..33faccbe8a 100644 --- a/packages/peer-id/package.json +++ b/packages/peer-id/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/peer-id", - "version": "3.0.6", + "version": "4.0.0", "description": "Implementation of @libp2p/interface-peer-id", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-id#readme", @@ -53,7 +53,7 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", + "@libp2p/interface": "^1.0.0", "multiformats": "^12.1.3", "uint8arrays": "^4.0.6" }, diff --git a/packages/peer-id/src/index.ts b/packages/peer-id/src/index.ts index db722aa171..1a856153e2 100644 --- a/packages/peer-id/src/index.ts +++ b/packages/peer-id/src/index.ts @@ -14,8 +14,7 @@ * ``` */ -import { CodeError } from '@libp2p/interface/errors' -import { type Ed25519PeerId, type PeerIdType, type RSAPeerId, type Secp256k1PeerId, symbol, type PeerId } from '@libp2p/interface/peer-id' +import { CodeError, peerIdSymbol } from '@libp2p/interface' import { base58btc } from 'multiformats/bases/base58' import { bases } from 'multiformats/basics' import { CID } from 'multiformats/cid' @@ -23,10 +22,11 @@ import * as Digest from 'multiformats/hashes/digest' import { identity } from 'multiformats/hashes/identity' import { sha256 } from 'multiformats/hashes/sha2' import { equals as uint8ArrayEquals } from 'uint8arrays/equals' +import type { Ed25519PeerId, PeerIdType, RSAPeerId, Secp256k1PeerId, PeerId } from '@libp2p/interface' import type { MultibaseDecoder } from 'multiformats/bases/interface' import type { MultihashDigest } from 'multiformats/hashes/interface' -const inspect = Symbol.for('nodejs.util.inspect.custom') +const inspectSymbol = Symbol.for('nodejs.util.inspect.custom') const baseDecoder = Object .values(bases) @@ -85,7 +85,7 @@ class PeerIdImpl { return `PeerId(${this.toString()})` } - readonly [symbol] = true + readonly [peerIdSymbol] = true toString (): string { if (this.string == null) { @@ -139,7 +139,7 @@ class PeerIdImpl { * // 'PeerId(QmFoo)' * ``` */ - [inspect] (): string { + [inspectSymbol] (): string { return `PeerId(${this.toString()})` } } diff --git a/packages/peer-record/CHANGELOG.md b/packages/peer-record/CHANGELOG.md index da770b5656..1b3feff8f2 100644 --- a/packages/peer-record/CHANGELOG.md +++ b/packages/peer-record/CHANGELOG.md @@ -11,6 +11,20 @@ * **dev:** bump aegir from 38.1.8 to 39.0.10 ([#64](https://github.com/libp2p/js-libp2p-peer-record/issues/64)) ([ba3ac38](https://github.com/libp2p/js-libp2p-peer-record/commit/ba3ac38c79e9449a75c0a54fefe289ee9e2c78fb)) +### [6.0.10](https://www.github.com/libp2p/js-libp2p/compare/peer-record-v6.0.9...peer-record-v6.0.10) (2023-11-28) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/crypto bumped from ^2.0.8 to ^3.0.0 + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + ### [6.0.9](https://www.github.com/libp2p/js-libp2p/compare/peer-record-v6.0.8...peer-record-v6.0.9) (2023-11-07) diff --git a/packages/peer-record/package.json b/packages/peer-record/package.json index 347d3fa663..44ece18a9b 100644 --- a/packages/peer-record/package.json +++ b/packages/peer-record/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/peer-record", - "version": "6.0.9", + "version": "6.0.10", "description": "Used to transfer signed peer data across the network", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-record#readme", @@ -60,10 +60,10 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/crypto": "^2.0.8", - "@libp2p/interface": "^0.1.6", - "@libp2p/peer-id": "^3.0.6", - "@libp2p/utils": "^4.0.7", + "@libp2p/crypto": "^3.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/utils": "^5.0.0", "@multiformats/multiaddr": "^12.1.10", "protons-runtime": "^5.0.0", "uint8-varint": "^2.0.0", @@ -71,7 +71,7 @@ "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "protons": "^7.3.0" } diff --git a/packages/peer-record/src/envelope/index.ts b/packages/peer-record/src/envelope/index.ts index 15714daa4e..8770af487c 100644 --- a/packages/peer-record/src/envelope/index.ts +++ b/packages/peer-record/src/envelope/index.ts @@ -1,5 +1,5 @@ import { unmarshalPrivateKey, unmarshalPublicKey } from '@libp2p/crypto/keys' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { peerIdFromKeys } from '@libp2p/peer-id' import * as varint from 'uint8-varint' import { Uint8ArrayList } from 'uint8arraylist' @@ -7,8 +7,7 @@ import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { fromString as uint8arraysFromString } from 'uint8arrays/from-string' import { codes } from '../errors.js' import { Envelope as Protobuf } from './envelope.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Record, Envelope } from '@libp2p/interface/record' +import type { PeerId, Record, Envelope } from '@libp2p/interface' export interface RecordEnvelopeInit { peerId: PeerId diff --git a/packages/peer-record/src/peer-record/index.ts b/packages/peer-record/src/peer-record/index.ts index 7ef105c692..b56259f906 100644 --- a/packages/peer-record/src/peer-record/index.ts +++ b/packages/peer-record/src/peer-record/index.ts @@ -6,7 +6,7 @@ import { ENVELOPE_PAYLOAD_TYPE_PEER_RECORD } from './consts.js' import { PeerRecord as Protobuf } from './peer-record.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/peer-record/test/envelope.spec.ts b/packages/peer-record/test/envelope.spec.ts index baff7a2190..9da7b5295d 100644 --- a/packages/peer-record/test/envelope.spec.ts +++ b/packages/peer-record/test/envelope.spec.ts @@ -4,8 +4,7 @@ import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { fromString as uint8arrayFromString } from 'uint8arrays/from-string' import { RecordEnvelope } from '../src/envelope/index.js' import { codes as ErrorCodes } from '../src/errors.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Record } from '@libp2p/interface/record' +import type { PeerId, Record } from '@libp2p/interface' const domain = 'libp2p-testing' const codec = uint8arrayFromString('/libp2p/testdata') diff --git a/packages/peer-record/test/peer-record.spec.ts b/packages/peer-record/test/peer-record.spec.ts index 14de3eca9b..edc623cccc 100644 --- a/packages/peer-record/test/peer-record.spec.ts +++ b/packages/peer-record/test/peer-record.spec.ts @@ -7,7 +7,7 @@ import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { RecordEnvelope } from '../src/envelope/index.js' import { PeerRecord } from '../src/peer-record/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' describe('PeerRecord', () => { let peerId: PeerId diff --git a/packages/peer-store/CHANGELOG.md b/packages/peer-store/CHANGELOG.md index 5c14e7c502..16adc67606 100644 --- a/packages/peer-store/CHANGELOG.md +++ b/packages/peer-store/CHANGELOG.md @@ -11,6 +11,26 @@ * **dev:** bump p-event from 5.0.1 to 6.0.0 ([#89](https://github.com/libp2p/js-libp2p-peer-store/issues/89)) ([9d96700](https://github.com/libp2p/js-libp2p-peer-store/commit/9d9670048b5e8feeac656cba92cb2e513e4a77be)) +### [9.0.10](https://www.github.com/libp2p/js-libp2p/compare/peer-store-v9.0.9...peer-store-v9.0.10) (2023-11-28) + + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/peer-collections bumped from ^4.0.8 to ^4.0.9 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + * @libp2p/peer-record bumped from ^6.0.9 to ^6.0.10 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + ### [9.0.9](https://www.github.com/libp2p/js-libp2p/compare/peer-store-v9.0.8...peer-store-v9.0.9) (2023-11-07) @@ -546,4 +566,4 @@ Co-authored-by: Alex Potsides ### Features -* add peer store/records, and streams are just streams ([#160](https://github.com/libp2p/js-libp2p-interfaces/issues/160)) ([8860a0c](https://github.com/libp2p/js-libp2p-interfaces/commit/8860a0cd46b359a5648402d83870f7ff957222fe)) +* add peer store/records, and streams are just streams ([#160](https://github.com/libp2p/js-libp2p-interfaces/issues/160)) ([8860a0c](https://github.com/libp2p/js-libp2p-interfaces/commit/8860a0cd46b359a5648402d83870f7ff957222fe)) \ No newline at end of file diff --git a/packages/peer-store/package.json b/packages/peer-store/package.json index ca82f1f55a..4cdf78ff9d 100644 --- a/packages/peer-store/package.json +++ b/packages/peer-store/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/peer-store", - "version": "9.0.9", + "version": "9.0.10", "description": "Stores information about peers libp2p knows on the network", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-store#readme", @@ -58,11 +58,11 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/peer-collections": "^4.0.8", - "@libp2p/peer-id": "^3.0.6", - "@libp2p/peer-id-factory": "^3.0.8", - "@libp2p/peer-record": "^6.0.9", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-collections": "^4.0.9", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", + "@libp2p/peer-record": "^6.0.10", "@multiformats/multiaddr": "^12.1.10", "interface-datastore": "^8.2.0", "it-all": "^3.0.2", @@ -73,7 +73,7 @@ "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", + "@libp2p/logger": "^4.0.0", "@types/sinon": "^17.0.0", "aegir": "^41.0.2", "datastore-core": "^9.1.1", diff --git a/packages/peer-store/src/index.ts b/packages/peer-store/src/index.ts index 50e6089fef..82fdef79b4 100644 --- a/packages/peer-store/src/index.ts +++ b/packages/peer-store/src/index.ts @@ -1,10 +1,7 @@ import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record' import all from 'it-all' import { PersistentStore, type PeerUpdate } from './store.js' -import type { ComponentLogger, Libp2pEvents, Logger } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore, Peer, PeerData, PeerQuery } from '@libp2p/interface/peer-store' +import type { ComponentLogger, Libp2pEvents, Logger, TypedEventTarget, PeerId, PeerStore, Peer, PeerData, PeerQuery } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' import type { Datastore } from 'interface-datastore' diff --git a/packages/peer-store/src/store.ts b/packages/peer-store/src/store.ts index 6eaea53097..920788b16a 100644 --- a/packages/peer-store/src/store.ts +++ b/packages/peer-store/src/store.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { PeerMap } from '@libp2p/peer-collections' import { peerIdFromBytes } from '@libp2p/peer-id' import mortice, { type Mortice } from 'mortice' @@ -10,9 +10,7 @@ import { bytesToPeer } from './utils/bytes-to-peer.js' import { NAMESPACE_COMMON, peerIdToDatastoreKey } from './utils/peer-id-to-datastore-key.js' import { toPeerPB } from './utils/to-peer-pb.js' import type { AddressFilter, PersistentPeerStoreComponents, PersistentPeerStoreInit } from './index.js' -import type { PeerUpdate as PeerUpdateExternal } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Peer, PeerData, PeerQuery } from '@libp2p/interface/peer-store' +import type { PeerUpdate as PeerUpdateExternal, PeerId, Peer, PeerData, PeerQuery } from '@libp2p/interface' import type { Datastore, Key, Query } from 'interface-datastore' /** diff --git a/packages/peer-store/src/utils/bytes-to-peer.ts b/packages/peer-store/src/utils/bytes-to-peer.ts index 3b723efcbe..f9d3d07d5e 100644 --- a/packages/peer-store/src/utils/bytes-to-peer.ts +++ b/packages/peer-store/src/utils/bytes-to-peer.ts @@ -1,8 +1,7 @@ import { peerIdFromPeerId } from '@libp2p/peer-id' import { multiaddr } from '@multiformats/multiaddr' import { Peer as PeerPB } from '../pb/peer.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Peer, Tag } from '@libp2p/interface/peer-store' +import type { PeerId, Peer, Tag } from '@libp2p/interface' export function bytesToPeer (peerId: PeerId, buf: Uint8Array): Peer { const peer = PeerPB.decode(buf) diff --git a/packages/peer-store/src/utils/dedupe-addresses.ts b/packages/peer-store/src/utils/dedupe-addresses.ts index d6f55d7120..f6d843a05d 100644 --- a/packages/peer-store/src/utils/dedupe-addresses.ts +++ b/packages/peer-store/src/utils/dedupe-addresses.ts @@ -1,10 +1,9 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { isMultiaddr, multiaddr } from '@multiformats/multiaddr' import { codes } from '../errors.js' import type { AddressFilter } from '../index.js' import type { Address as AddressPB } from '../pb/peer.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Address } from '@libp2p/interface/peer-store' +import type { PeerId, Address } from '@libp2p/interface' export async function dedupeFilterAndSortAddresses (peerId: PeerId, filter: AddressFilter, addresses: Array
): Promise { const addressMap = new Map() diff --git a/packages/peer-store/src/utils/peer-data-to-datastore-peer.ts b/packages/peer-store/src/utils/peer-data-to-datastore-peer.ts index fa7ad930ed..1aca6b1ca5 100644 --- a/packages/peer-store/src/utils/peer-data-to-datastore-peer.ts +++ b/packages/peer-store/src/utils/peer-data-to-datastore-peer.ts @@ -1,10 +1,9 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { isMultiaddr } from '@multiformats/multiaddr' import { equals as uint8arrayEquals } from 'uint8arrays/equals' import { codes } from '../errors.js' import type { Peer as PeerPB } from '../pb/peer.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerData } from '@libp2p/interface/peer-store' +import type { PeerId, PeerData } from '@libp2p/interface' export function toDatastorePeer (peerId: PeerId, data: PeerData): PeerPB { if (data == null) { diff --git a/packages/peer-store/src/utils/peer-id-to-datastore-key.ts b/packages/peer-store/src/utils/peer-id-to-datastore-key.ts index 191ef2dffc..7d46e90c8e 100644 --- a/packages/peer-store/src/utils/peer-id-to-datastore-key.ts +++ b/packages/peer-store/src/utils/peer-id-to-datastore-key.ts @@ -1,5 +1,5 @@ -import { CodeError } from '@libp2p/interface/errors' -import { isPeerId, type PeerId } from '@libp2p/interface/peer-id' +import { CodeError } from '@libp2p/interface' +import { isPeerId, type PeerId } from '@libp2p/interface' import { Key } from 'interface-datastore/key' import { codes } from '../errors.js' diff --git a/packages/peer-store/src/utils/to-peer-pb.ts b/packages/peer-store/src/utils/to-peer-pb.ts index 7270ad6f40..937da55d1d 100644 --- a/packages/peer-store/src/utils/to-peer-pb.ts +++ b/packages/peer-store/src/utils/to-peer-pb.ts @@ -1,11 +1,10 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { equals as uint8arrayEquals } from 'uint8arrays/equals' import { codes } from '../errors.js' import { dedupeFilterAndSortAddresses } from './dedupe-addresses.js' import type { AddressFilter } from '../index.js' import type { Tag, Peer as PeerPB } from '../pb/peer.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Address, Peer, PeerData, TagOptions } from '@libp2p/interface/peer-store' +import type { PeerId, Address, Peer, PeerData, TagOptions } from '@libp2p/interface' export interface ToPBPeerOptions { addressFilter?: AddressFilter diff --git a/packages/peer-store/test/index.spec.ts b/packages/peer-store/test/index.spec.ts index ce860f5f45..60ddfbee9a 100644 --- a/packages/peer-store/test/index.spec.ts +++ b/packages/peer-store/test/index.spec.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ /* eslint max-nested-callbacks: ["error", 6] */ -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' +import { TypedEventEmitter, type TypedEventTarget, type Libp2pEvents, type PeerId } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record' @@ -10,8 +10,6 @@ import { expect } from 'aegir/chai' import { MemoryDatastore } from 'datastore-core/memory' import delay from 'delay' import { PersistentPeerStore } from '../src/index.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' const addr1 = multiaddr('/ip4/127.0.0.1/tcp/8000') diff --git a/packages/peer-store/test/merge.spec.ts b/packages/peer-store/test/merge.spec.ts index dcf46fce3c..52aebec3a4 100644 --- a/packages/peer-store/test/merge.spec.ts +++ b/packages/peer-store/test/merge.spec.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ /* eslint max-nested-callbacks: ["error", 6] */ -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' +import { TypedEventEmitter, type TypedEventTarget, type Libp2pEvents, type PeerId, type PeerData } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' @@ -9,9 +9,6 @@ import { expect } from 'aegir/chai' import { MemoryDatastore } from 'datastore-core/memory' import { pEvent } from 'p-event' import { PersistentPeerStore } from '../src/index.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerData } from '@libp2p/interface/peer-store' const addr1 = multiaddr('/ip4/127.0.0.1/tcp/8000') const addr2 = multiaddr('/ip4/20.0.0.1/tcp/8001') diff --git a/packages/peer-store/test/patch.spec.ts b/packages/peer-store/test/patch.spec.ts index 7f3c390648..63f74ce14a 100644 --- a/packages/peer-store/test/patch.spec.ts +++ b/packages/peer-store/test/patch.spec.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ /* eslint max-nested-callbacks: ["error", 6] */ -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' +import { TypedEventEmitter, type TypedEventTarget, type Libp2pEvents, type PeerId, type PeerData } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' @@ -9,9 +9,6 @@ import { expect } from 'aegir/chai' import { MemoryDatastore } from 'datastore-core/memory' import { pEvent } from 'p-event' import { PersistentPeerStore } from '../src/index.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerData } from '@libp2p/interface/peer-store' const addr1 = multiaddr('/ip4/127.0.0.1/tcp/8000') const addr2 = multiaddr('/ip4/20.0.0.1/tcp/8001') diff --git a/packages/peer-store/test/save.spec.ts b/packages/peer-store/test/save.spec.ts index 328341458f..2afeaabc53 100644 --- a/packages/peer-store/test/save.spec.ts +++ b/packages/peer-store/test/save.spec.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ /* eslint max-nested-callbacks: ["error", 6] */ -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' +import { TypedEventEmitter, type TypedEventTarget, type Libp2pEvents, type PeerUpdate, type PeerId, type PeerData } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId, createRSAPeerId, createSecp256k1PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' @@ -13,9 +13,6 @@ import sinon from 'sinon' import { codes } from '../src/errors.js' import { PersistentPeerStore } from '../src/index.js' import { Peer as PeerPB } from '../src/pb/peer.js' -import type { Libp2pEvents, PeerUpdate } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerData } from '@libp2p/interface/peer-store' const addr1 = multiaddr('/ip4/127.0.0.1/tcp/8000') const addr2 = multiaddr('/ip4/20.0.0.1/tcp/8001') diff --git a/packages/peer-store/test/utils/dedupe-addresses.spec.ts b/packages/peer-store/test/utils/dedupe-addresses.spec.ts index 233e576239..7129f0e7f3 100644 --- a/packages/peer-store/test/utils/dedupe-addresses.spec.ts +++ b/packages/peer-store/test/utils/dedupe-addresses.spec.ts @@ -4,7 +4,7 @@ import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { dedupeFilterAndSortAddresses } from '../../src/utils/dedupe-addresses.js' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' const addr1 = multiaddr('/ip4/127.0.0.1/tcp/8000') const addr2 = multiaddr('/ip4/20.0.0.1/tcp/8001') diff --git a/packages/pnet/package.json b/packages/pnet/package.json index dafb9631af..db1379d6a3 100644 --- a/packages/pnet/package.json +++ b/packages/pnet/package.json @@ -49,8 +49,8 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "@libp2p/crypto": "^2.0.5", - "@libp2p/interface": "^0.1.3", + "@libp2p/crypto": "^3.0.0", + "@libp2p/interface": "^1.0.0", "it-byte-stream": "^1.0.5", "it-map": "^3.0.4", "it-pair": "^2.0.6", @@ -61,9 +61,9 @@ "xsalsa20": "^1.1.0" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.1", - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.5", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "@multiformats/multiaddr": "^12.1.10", "@types/xsalsa20": "^1.1.0", "aegir": "^41.0.2", diff --git a/packages/pnet/src/index.ts b/packages/pnet/src/index.ts index ac49a610ca..305786c032 100644 --- a/packages/pnet/src/index.ts +++ b/packages/pnet/src/index.ts @@ -57,7 +57,7 @@ */ import { randomBytes } from '@libp2p/crypto' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { byteStream } from 'it-byte-stream' import map from 'it-map' import { duplexPair } from 'it-pair/duplex' @@ -69,8 +69,7 @@ import { } from './crypto.js' import * as Errors from './errors.js' import { NONCE_LENGTH } from './key-generator.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { ConnectionProtector, MultiaddrConnection } from '@libp2p/interface/connection' +import type { ComponentLogger, Logger, ConnectionProtector, MultiaddrConnection } from '@libp2p/interface' import type { Uint8ArrayList } from 'uint8arraylist' export { generateKey } from './key-generator.js' diff --git a/packages/protocol-autonat/CHANGELOG.md b/packages/protocol-autonat/CHANGELOG.md new file mode 100644 index 0000000000..a140c3f244 --- /dev/null +++ b/packages/protocol-autonat/CHANGELOG.md @@ -0,0 +1,32 @@ +# Changelog + +## 1.0.0 (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/identify` need to change to `@libp2p/identify` +* move autonat into separate package (#2107) + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* extract identify service into separate module ([#2219](https://www.github.com/libp2p/js-libp2p/issues/2219)) ([72c2f77](https://www.github.com/libp2p/js-libp2p/commit/72c2f775bd85bd4928048dda0fd14740d6fb6a69)) +* move autonat into separate package ([#2107](https://www.github.com/libp2p/js-libp2p/issues/2107)) ([b0e8f06](https://www.github.com/libp2p/js-libp2p/commit/b0e8f06f0dcdbda0e367186b093e42e8bff3ee27)) + + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.2 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.5 to ^0.1.10 + * @libp2p/peer-id bumped from ^3.0.2 to ^4.0.0 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.4 to ^3.0.9 \ No newline at end of file diff --git a/packages/protocol-autonat/package.json b/packages/protocol-autonat/package.json index 3007008697..2707681f8b 100644 --- a/packages/protocol-autonat/package.json +++ b/packages/protocol-autonat/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/autonat", - "version": "0.0.0", + "version": "1.0.0", "description": "Implementation of Autonat Protocol", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-autonat#readme", @@ -51,9 +51,9 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "@libp2p/interface": "^0.1.2", - "@libp2p/interface-internal": "^0.1.5", - "@libp2p/peer-id": "^3.0.2", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/peer-id": "^4.0.0", "@multiformats/multiaddr": "^12.1.10", "it-first": "^3.0.3", "it-length-prefixed": "^9.0.3", @@ -65,8 +65,8 @@ "uint8arraylist": "^2.4.3" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.4", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "it-all": "^3.0.3", "it-pushable": "^3.2.1", diff --git a/packages/protocol-autonat/src/autonat.ts b/packages/protocol-autonat/src/autonat.ts index ec7fb5d6fa..12d4b8a112 100644 --- a/packages/protocol-autonat/src/autonat.ts +++ b/packages/protocol-autonat/src/autonat.ts @@ -1,5 +1,4 @@ -import { CodeError, ERR_TIMEOUT } from '@libp2p/interface/errors' -import { setMaxListeners } from '@libp2p/interface/events' +import { CodeError, ERR_TIMEOUT, setMaxListeners } from '@libp2p/interface' import { peerIdFromBytes } from '@libp2p/peer-id' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr, protocols } from '@multiformats/multiaddr' @@ -16,12 +15,8 @@ import { } from './constants.js' import { Message } from './pb/index.js' import type { AutoNATComponents, AutoNATServiceInit } from './index.js' -import type { Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { Startable } from '@libp2p/interface/startable' -import type { IncomingStreamData } from '@libp2p/interface-internal/registrar' +import type { Logger, Connection, PeerId, PeerInfo, Startable } from '@libp2p/interface' +import type { IncomingStreamData } from '@libp2p/interface-internal' // if more than 3 peers manage to dial us on what we believe to be our external // IP then we are convinced that it is, in fact, our external IP diff --git a/packages/protocol-autonat/src/index.ts b/packages/protocol-autonat/src/index.ts index 45aa266c39..04dde99cb1 100644 --- a/packages/protocol-autonat/src/index.ts +++ b/packages/protocol-autonat/src/index.ts @@ -20,13 +20,8 @@ */ import { AutoNATService } from './autonat.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerRouting } from '@libp2p/interface/peer-routing' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ComponentLogger, PeerId, PeerRouting } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal' export interface AutoNATServiceInit { /** diff --git a/packages/protocol-autonat/test/index.spec.ts b/packages/protocol-autonat/test/index.spec.ts index b84b4c66d7..289f4a597f 100644 --- a/packages/protocol-autonat/test/index.spec.ts +++ b/packages/protocol-autonat/test/index.spec.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ /* eslint max-nested-callbacks: ["error", 5] */ -import { start, stop } from '@libp2p/interface/startable' +import { start, stop } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' @@ -17,15 +17,8 @@ import { AutoNATService } from '../src/autonat.js' import { PROTOCOL_NAME, PROTOCOL_PREFIX, PROTOCOL_VERSION } from '../src/constants.js' import { Message } from '../src/pb/index.js' import type { AutoNATComponents, AutoNATServiceInit } from '../src/index.js' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { PeerRouting } from '@libp2p/interface/peer-routing' -import type { Transport } from '@libp2p/interface/transport' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { Connection, Stream, PeerId, PeerInfo, PeerRouting, Transport } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' import type { StubbedInstance } from 'sinon-ts' diff --git a/packages/protocol-dcutr/CHANGELOG.md b/packages/protocol-dcutr/CHANGELOG.md new file mode 100644 index 0000000000..9952269fb9 --- /dev/null +++ b/packages/protocol-dcutr/CHANGELOG.md @@ -0,0 +1,28 @@ +# Changelog + +## 1.0.0 (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/circuit-relay` should be updated to `@libp2p/circuit-relay-v2` +* imports from `libp2p/dcutr` now need to be from `@libp2p/dcutr` + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* extract circuit relay v2 to separate module ([#2222](https://www.github.com/libp2p/js-libp2p/issues/2222)) ([24afba3](https://www.github.com/libp2p/js-libp2p/commit/24afba30004fb7f24af1f0180229bb164340f00b)) +* extract DCUtR into separate module ([#2220](https://www.github.com/libp2p/js-libp2p/issues/2220)) ([d2c3e72](https://www.github.com/libp2p/js-libp2p/commit/d2c3e7235b64558c6cace414c54a42659fee2970)) + + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.2 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.5 to ^0.1.10 \ No newline at end of file diff --git a/packages/protocol-dcutr/package.json b/packages/protocol-dcutr/package.json index 3082571c09..ee32167f6a 100644 --- a/packages/protocol-dcutr/package.json +++ b/packages/protocol-dcutr/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/dcutr", - "version": "0.0.0", + "version": "1.0.0", "description": "Implementation of the DCUtR Protocol", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-dcutr#readme", @@ -51,8 +51,8 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "@libp2p/interface": "^0.1.2", - "@libp2p/interface-internal": "^0.1.5", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", "@multiformats/multiaddr": "^12.1.10", "@multiformats/multiaddr-matcher": "^1.1.0", "delay": "^6.0.0", diff --git a/packages/protocol-dcutr/src/dcutr.ts b/packages/protocol-dcutr/src/dcutr.ts index d4affc170e..414a7e2159 100644 --- a/packages/protocol-dcutr/src/dcutr.ts +++ b/packages/protocol-dcutr/src/dcutr.ts @@ -1,4 +1,4 @@ -import { CodeError, ERR_INVALID_MESSAGE } from '@libp2p/interface/errors' +import { CodeError, ERR_INVALID_MESSAGE } from '@libp2p/interface' import { type Multiaddr, multiaddr } from '@multiformats/multiaddr' import delay from 'delay' import { pbStream } from 'it-protobuf-stream' @@ -6,14 +6,8 @@ import { HolePunch } from './pb/message.js' import { isPublicAndDialable } from './utils.js' import { multicodec } from './index.js' import type { DCUtRServiceComponents, DCUtRServiceInit } from './index.js' -import type { Logger } from '@libp2p/interface' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/src/transport-manager/index.js' +import type { Logger, Connection, Stream, PeerStore, Startable } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal' // https://github.com/libp2p/specs/blob/master/relay/DCUtR.md#rpc-messages const MAX_DCUTR_MESSAGE_SIZE = 1024 * 4 diff --git a/packages/protocol-dcutr/src/index.ts b/packages/protocol-dcutr/src/index.ts index fefa57740f..ace94619cd 100644 --- a/packages/protocol-dcutr/src/index.ts +++ b/packages/protocol-dcutr/src/index.ts @@ -54,12 +54,8 @@ */ import { DefaultDCUtRService } from './dcutr.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ComponentLogger, PeerStore } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal' export interface DCUtRServiceInit { /** diff --git a/packages/protocol-dcutr/src/utils.ts b/packages/protocol-dcutr/src/utils.ts index c56a139778..900d0b3573 100644 --- a/packages/protocol-dcutr/src/utils.ts +++ b/packages/protocol-dcutr/src/utils.ts @@ -1,7 +1,7 @@ import { type Multiaddr } from '@multiformats/multiaddr' import { Circuit, IP, DNS } from '@multiformats/multiaddr-matcher' import isPrivate from 'private-ip' -import type { TransportManager } from '@libp2p/interface-internal/src/transport-manager' +import type { TransportManager } from '@libp2p/interface-internal' /** * Returns true if the passed multiaddr is public, not relayed and we have a diff --git a/packages/protocol-dcutr/test/utils.spec.ts b/packages/protocol-dcutr/test/utils.spec.ts index bba0f524d2..829e4745b9 100644 --- a/packages/protocol-dcutr/test/utils.spec.ts +++ b/packages/protocol-dcutr/test/utils.spec.ts @@ -5,8 +5,8 @@ import { expect } from 'aegir/chai' import Sinon from 'sinon' import { stubInterface } from 'sinon-ts' import { isPublicAndDialable } from '../src/utils.js' -import type { Transport } from '@libp2p/interface/transport' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { Transport } from '@libp2p/interface' +import type { TransportManager } from '@libp2p/interface-internal' describe('dcutr utils', () => { describe('isPublicAndDialable', () => { diff --git a/packages/protocol-fetch/CHANGELOG.md b/packages/protocol-fetch/CHANGELOG.md new file mode 100644 index 0000000000..b9a851fc90 --- /dev/null +++ b/packages/protocol-fetch/CHANGELOG.md @@ -0,0 +1,29 @@ +# Changelog + +## 1.0.0 (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/fetch` should be updated to `@libp2p/fetch` + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* extract fetch to separate module ([#2223](https://www.github.com/libp2p/js-libp2p/issues/2223)) ([9b19be2](https://www.github.com/libp2p/js-libp2p/commit/9b19be2796c2dbbe207029199b1ac203647744e3)) + + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.2 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.5 to ^0.1.10 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 \ No newline at end of file diff --git a/packages/protocol-fetch/package.json b/packages/protocol-fetch/package.json index f43e1c9b12..9dc63a5966 100644 --- a/packages/protocol-fetch/package.json +++ b/packages/protocol-fetch/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/fetch", - "version": "0.0.0", + "version": "1.0.0", "description": "Implementation of the Fetch Protocol", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-fetch#readme", @@ -51,16 +51,16 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "@libp2p/interface": "^0.1.2", - "@libp2p/interface-internal": "^0.1.5", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", "it-protobuf-stream": "^1.0.2", "protons-runtime": "^5.0.0", "uint8arraylist": "^2.4.3", "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "it-pair": "^2.0.6", "protons": "^7.3.0", diff --git a/packages/protocol-fetch/src/fetch.ts b/packages/protocol-fetch/src/fetch.ts index 4029b3f48f..8808dbcbf2 100644 --- a/packages/protocol-fetch/src/fetch.ts +++ b/packages/protocol-fetch/src/fetch.ts @@ -1,16 +1,12 @@ -import { CodeError, ERR_INVALID_MESSAGE, ERR_INVALID_PARAMETERS, ERR_TIMEOUT } from '@libp2p/interface/errors' -import { setMaxListeners } from '@libp2p/interface/events' +import { CodeError, ERR_INVALID_MESSAGE, ERR_INVALID_PARAMETERS, ERR_TIMEOUT, setMaxListeners } from '@libp2p/interface' import { pbStream } from 'it-protobuf-stream' import { fromString as uint8arrayFromString } from 'uint8arrays/from-string' import { toString as uint8arrayToString } from 'uint8arrays/to-string' import { PROTOCOL_NAME, PROTOCOL_VERSION } from './constants.js' import { FetchRequest, FetchResponse } from './pb/proto.js' import type { Fetch as FetchInterface, FetchComponents, FetchInit, LookupFunction } from './index.js' -import type { AbortOptions, Logger } from '@libp2p/interface' -import type { Stream } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Startable } from '@libp2p/interface/startable' -import type { IncomingStreamData } from '@libp2p/interface-internal/registrar' +import type { AbortOptions, Logger, Stream, PeerId, Startable } from '@libp2p/interface' +import type { IncomingStreamData } from '@libp2p/interface-internal' const DEFAULT_TIMEOUT = 10000 diff --git a/packages/protocol-fetch/src/index.ts b/packages/protocol-fetch/src/index.ts index c270bd770c..715e05615a 100644 --- a/packages/protocol-fetch/src/index.ts +++ b/packages/protocol-fetch/src/index.ts @@ -34,10 +34,8 @@ */ import { Fetch as FetchClass } from './fetch.js' -import type { AbortOptions, ComponentLogger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { AbortOptions, ComponentLogger, PeerId } from '@libp2p/interface' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' export interface FetchInit { protocolPrefix?: string diff --git a/packages/protocol-fetch/test/index.spec.ts b/packages/protocol-fetch/test/index.spec.ts index e97aaa07b3..6630cad008 100644 --- a/packages/protocol-fetch/test/index.spec.ts +++ b/packages/protocol-fetch/test/index.spec.ts @@ -1,7 +1,6 @@ /* eslint-env mocha */ -import { ERR_INVALID_PARAMETERS } from '@libp2p/interface/errors' -import { start, stop } from '@libp2p/interface/startable' +import { ERR_INVALID_PARAMETERS, start, stop } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' @@ -11,11 +10,8 @@ import sinon from 'sinon' import { stubInterface, type StubbedInstance } from 'sinon-ts' import { Fetch } from '../src/fetch.js' import { FetchRequest, FetchResponse } from '../src/pb/proto.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { ComponentLogger, Connection, Stream, PeerId } from '@libp2p/interface' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' interface StubbedFetchComponents { registrar: StubbedInstance diff --git a/packages/protocol-identify/CHANGELOG.md b/packages/protocol-identify/CHANGELOG.md new file mode 100644 index 0000000000..2401bbe910 --- /dev/null +++ b/packages/protocol-identify/CHANGELOG.md @@ -0,0 +1,33 @@ +# Changelog + +## 1.0.0 (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/dcutr` now need to be from `@libp2p/dcutr` +* imports from `libp2p/identify` need to change to `@libp2p/identify` + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* extract DCUtR into separate module ([#2220](https://www.github.com/libp2p/js-libp2p/issues/2220)) ([d2c3e72](https://www.github.com/libp2p/js-libp2p/commit/d2c3e7235b64558c6cace414c54a42659fee2970)) +* extract identify service into separate module ([#2219](https://www.github.com/libp2p/js-libp2p/issues/2219)) ([72c2f77](https://www.github.com/libp2p/js-libp2p/commit/72c2f775bd85bd4928048dda0fd14740d6fb6a69)) + + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.2 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.5 to ^0.1.10 + * @libp2p/peer-id bumped from ^3.0.2 to ^4.0.0 + * @libp2p/peer-record bumped from ^6.0.9 to ^6.0.10 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.4 to ^3.0.9 \ No newline at end of file diff --git a/packages/protocol-identify/package.json b/packages/protocol-identify/package.json index 46fa464edb..7de535a2f4 100644 --- a/packages/protocol-identify/package.json +++ b/packages/protocol-identify/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/identify", - "version": "0.0.0", + "version": "1.0.0", "description": "Implementation of the Identify Protocol", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-identify#readme", @@ -51,10 +51,10 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "@libp2p/interface": "^0.1.2", - "@libp2p/interface-internal": "^0.1.5", - "@libp2p/peer-id": "^3.0.2", - "@libp2p/peer-record": "^6.0.9", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/peer-record": "^6.0.10", "@multiformats/multiaddr": "^12.1.10", "@multiformats/multiaddr-matcher": "^1.1.0", "it-length-prefixed": "^9.0.3", @@ -65,8 +65,8 @@ "wherearewe": "^2.0.1" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.4", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "delay": "^6.0.0", "it-drain": "^3.0.3", diff --git a/packages/protocol-identify/src/identify.ts b/packages/protocol-identify/src/identify.ts index 895e1c7b29..836ee7eb1e 100644 --- a/packages/protocol-identify/src/identify.ts +++ b/packages/protocol-identify/src/identify.ts @@ -1,7 +1,6 @@ /* eslint-disable complexity */ -import { CodeError, ERR_NOT_FOUND } from '@libp2p/interface/errors' -import { setMaxListeners } from '@libp2p/interface/events' +import { CodeError, ERR_NOT_FOUND, setMaxListeners } from '@libp2p/interface' import { peerIdFromKeys } from '@libp2p/peer-id' import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record' import { type Multiaddr, multiaddr, protocols } from '@multiformats/multiaddr' @@ -19,15 +18,8 @@ import { } from './consts.js' import { Identify as IdentifyMessage } from './pb/message.js' import type { Identify as IdentifyInterface, IdentifyComponents, IdentifyInit } from './index.js' -import type { Libp2pEvents, IdentifyResult, SignedPeerRecord, AbortOptions, Logger } from '@libp2p/interface' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Peer, PeerData, PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar' +import type { Libp2pEvents, IdentifyResult, SignedPeerRecord, AbortOptions, Logger, Connection, Stream, TypedEventTarget, PeerId, Peer, PeerData, PeerStore, Startable } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, IncomingStreamData, Registrar } from '@libp2p/interface-internal' // https://github.com/libp2p/go-libp2p/blob/8d2e54e1637041d5cf4fac1e531287560bd1f4ac/p2p/protocol/identify/id.go#L52 const MAX_IDENTIFY_MESSAGE_SIZE = 1024 * 8 diff --git a/packages/protocol-identify/src/index.ts b/packages/protocol-identify/src/index.ts index c9ef0fa5e7..fc4996006d 100644 --- a/packages/protocol-identify/src/index.ts +++ b/packages/protocol-identify/src/index.ts @@ -23,14 +23,9 @@ import { MULTICODEC_IDENTIFY_PUSH } from './consts.js' import { Identify as IdentifyClass } from './identify.js' -import type { AbortOptions, IdentifyResult, Libp2pEvents, ComponentLogger, NodeInfo } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { AbortOptions, IdentifyResult, Libp2pEvents, ComponentLogger, NodeInfo, TypedEventTarget, PeerId, PeerStore } from '@libp2p/interface' import type { Connection } from '@libp2p/interface/src/connection/index.js' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal' export interface IdentifyInit { /** diff --git a/packages/protocol-identify/test/fixtures/index.ts b/packages/protocol-identify/test/fixtures/index.ts index 9827dcd75e..54172c0f5a 100644 --- a/packages/protocol-identify/test/fixtures/index.ts +++ b/packages/protocol-identify/test/fixtures/index.ts @@ -5,14 +5,9 @@ import Sinon from 'sinon' import { stubInterface, type StubbedInstance } from 'sinon-ts' import { Uint8ArrayList } from 'uint8arraylist' import { Identify as IdentifyMessage } from '../../src/pb/message.js' -import type { ComponentLogger, Libp2pEvents, NodeInfo } from '@libp2p/interface' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { ComponentLogger, Libp2pEvents, NodeInfo, TypedEventTarget, PeerId, PeerStore } from '@libp2p/interface' import type { Connection, Stream } from '@libp2p/interface/src/connection' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal' export function matchPeerId (peerId: PeerId): Sinon.SinonMatcher { return Sinon.match(p => p.toString() === peerId.toString()) diff --git a/packages/protocol-identify/test/index.spec.ts b/packages/protocol-identify/test/index.spec.ts index 257f3f6baf..ca992195ca 100644 --- a/packages/protocol-identify/test/index.spec.ts +++ b/packages/protocol-identify/test/index.spec.ts @@ -1,5 +1,4 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' -import { start, stop } from '@libp2p/interface/startable' +import { TypedEventEmitter, start, stop } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { PeerRecord, RecordEnvelope } from '@libp2p/peer-record' @@ -16,12 +15,9 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { Identify } from '../src/identify.js' import { Identify as IdentifyMessage } from '../src/pb/message.js' import { identifyConnection, identifyStream, type StubbedIdentifyComponents } from './fixtures/index.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerStore } from '@libp2p/interface/peer-store' +import type { Libp2pEvents, PeerStore } from '@libp2p/interface' import type { Connection, Stream } from '@libp2p/interface/src/connection' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal' import type { Uint8ArrayList } from 'uint8arraylist' describe('identify', () => { diff --git a/packages/protocol-identify/test/push.spec.ts b/packages/protocol-identify/test/push.spec.ts index f49e939d52..e8cba2a500 100644 --- a/packages/protocol-identify/test/push.spec.ts +++ b/packages/protocol-identify/test/push.spec.ts @@ -1,5 +1,4 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' -import { start, stop } from '@libp2p/interface/startable' +import { TypedEventEmitter, start, stop } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' @@ -10,11 +9,8 @@ import { stubInterface } from 'sinon-ts' import { Identify } from '../src/identify.js' import { Identify as IdentifyMessage } from '../src/pb/message.js' import { identifyPushStream, matchPeerId, type StubbedIdentifyComponents } from './fixtures/index.js' -import type { Libp2pEvents } from '@libp2p/interface' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { Libp2pEvents, PeerStore } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal' describe('identify (push)', () => { let components: StubbedIdentifyComponents diff --git a/packages/protocol-perf/CHANGELOG.md b/packages/protocol-perf/CHANGELOG.md index 41e59eca22..45754b5b0d 100644 --- a/packages/protocol-perf/CHANGELOG.md +++ b/packages/protocol-perf/CHANGELOG.md @@ -1,5 +1,34 @@ # Changelog +## [3.0.0](https://www.github.com/libp2p/js-libp2p/compare/perf-v2.0.1...perf-v3.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `perfService` export is now just `perf` +* imports from `libp2p/plaintext` should be changed to `@libp2p/plaintext` + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* extract plaintext into separate module ([#2221](https://www.github.com/libp2p/js-libp2p/issues/2221)) ([a364d95](https://www.github.com/libp2p/js-libp2p/commit/a364d95bbd7b15a5ce6ce508321e7ff2fa40a5e5)) +* rename perf exports to remove Service ([#2227](https://www.github.com/libp2p/js-libp2p/issues/2227)) ([1034416](https://www.github.com/libp2p/js-libp2p/commit/10344168fe5f56c08a21d6b35468817e17ab0b25)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.9 to ^0.1.10 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + ### [2.0.1](https://www.github.com/libp2p/js-libp2p/compare/perf-v2.0.0...perf-v2.0.1) (2023-11-07) diff --git a/packages/protocol-perf/package.json b/packages/protocol-perf/package.json index 6f8ec43ec8..d2d5eba9f1 100644 --- a/packages/protocol-perf/package.json +++ b/packages/protocol-perf/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/perf", - "version": "2.0.1", + "version": "3.0.0", "description": "Implementation of Perf Protocol", "author": "@maschad / @marcopolo", "license": "Apache-2.0 OR MIT", @@ -52,14 +52,14 @@ "renderResults": "node dist/src/renderResults.js" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/interface-internal": "^0.1.9", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", "@multiformats/multiaddr": "^12.1.10", "it-pushable": "^3.2.3" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", "aegir": "^41.0.2", "it-last": "^3.0.3", "it-pair": "^2.0.6", diff --git a/packages/protocol-perf/src/index.ts b/packages/protocol-perf/src/index.ts index 9ccc3105dc..556986562f 100644 --- a/packages/protocol-perf/src/index.ts +++ b/packages/protocol-perf/src/index.ts @@ -54,8 +54,7 @@ import { Perf as PerfClass } from './perf-service.js' import type { AbortOptions, ComponentLogger } from '@libp2p/interface' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export interface PerfOptions extends AbortOptions { diff --git a/packages/protocol-perf/src/perf-service.ts b/packages/protocol-perf/src/perf-service.ts index aa1d862f2f..f3475eb506 100644 --- a/packages/protocol-perf/src/perf-service.ts +++ b/packages/protocol-perf/src/perf-service.ts @@ -1,9 +1,8 @@ import { pushable } from 'it-pushable' import { MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS, PROTOCOL_NAME, RUN_ON_TRANSIENT_CONNECTION, WRITE_BLOCK_SIZE } from './constants.js' import type { PerfOptions, PerfOutput, PerfComponents, PerfInit, Perf as PerfInterface } from './index.js' -import type { Logger } from '@libp2p/interface' -import type { Startable } from '@libp2p/interface/startable' -import type { IncomingStreamData } from '@libp2p/interface-internal/registrar' +import type { Logger, Startable } from '@libp2p/interface' +import type { IncomingStreamData } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export class Perf implements Startable, PerfInterface { diff --git a/packages/protocol-perf/test/index.spec.ts b/packages/protocol-perf/test/index.spec.ts index 78740f52d3..177989c0cd 100644 --- a/packages/protocol-perf/test/index.spec.ts +++ b/packages/protocol-perf/test/index.spec.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { start, stop } from '@libp2p/interface/startable' +import { start, stop } from '@libp2p/interface' import { streamPair } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' @@ -9,10 +9,8 @@ import last from 'it-last' import { duplexPair } from 'it-pair/duplex' import { stubInterface, type StubbedInstance } from 'sinon-ts' import { Perf } from '../src/perf-service.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { ComponentLogger, Connection } from '@libp2p/interface' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' interface StubbedPerfComponents { registrar: StubbedInstance diff --git a/packages/protocol-ping/CHANGELOG.md b/packages/protocol-ping/CHANGELOG.md new file mode 100644 index 0000000000..edb279fa43 --- /dev/null +++ b/packages/protocol-ping/CHANGELOG.md @@ -0,0 +1,34 @@ +# Changelog + +## 1.0.0 (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/dcutr` now need to be from `@libp2p/dcutr` +* imports from `libp2p/identify` need to change to `@libp2p/identify` +* imports from `libp2p/ping` must be updated to `@libp2p/ping` + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* extract DCUtR into separate module ([#2220](https://www.github.com/libp2p/js-libp2p/issues/2220)) ([d2c3e72](https://www.github.com/libp2p/js-libp2p/commit/d2c3e7235b64558c6cace414c54a42659fee2970)) +* extract identify service into separate module ([#2219](https://www.github.com/libp2p/js-libp2p/issues/2219)) ([72c2f77](https://www.github.com/libp2p/js-libp2p/commit/72c2f775bd85bd4928048dda0fd14740d6fb6a69)) +* extract ping service into separate module ([#2218](https://www.github.com/libp2p/js-libp2p/issues/2218)) ([556282a](https://www.github.com/libp2p/js-libp2p/commit/556282afdc9b328fd58df1045dc7c792199be932)) + + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/crypto bumped from ^2.0.8 to ^3.0.0 + * @libp2p/interface bumped from ^0.1.2 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.5 to ^0.1.10 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 \ No newline at end of file diff --git a/packages/protocol-ping/package.json b/packages/protocol-ping/package.json index 39390fba8e..cecc956772 100644 --- a/packages/protocol-ping/package.json +++ b/packages/protocol-ping/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/ping", - "version": "0.0.0", + "version": "1.0.0", "description": "Implementation of Ping Protocol", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-ping#readme", @@ -49,17 +49,17 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "@libp2p/crypto": "^2.0.8", - "@libp2p/interface": "^0.1.2", - "@libp2p/interface-internal": "^0.1.5", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/crypto": "^3.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/peer-id-factory": "^3.0.9", "@multiformats/multiaddr": "^12.1.10", "it-first": "^3.0.3", "it-pipe": "^3.0.1", "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", + "@libp2p/logger": "^4.0.0", "aegir": "^41.0.2", "it-byte-stream": "^1.0.1", "it-pair": "^2.0.6", diff --git a/packages/protocol-ping/src/index.ts b/packages/protocol-ping/src/index.ts index 03c0d5a5f5..de0c1751c5 100644 --- a/packages/protocol-ping/src/index.ts +++ b/packages/protocol-ping/src/index.ts @@ -23,10 +23,8 @@ */ import { PingService as PingServiceClass } from './ping.js' -import type { AbortOptions, ComponentLogger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { AbortOptions, ComponentLogger, PeerId } from '@libp2p/interface' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export interface PingService { diff --git a/packages/protocol-ping/src/ping.ts b/packages/protocol-ping/src/ping.ts index 19c2998b34..a7af5d16ff 100644 --- a/packages/protocol-ping/src/ping.ts +++ b/packages/protocol-ping/src/ping.ts @@ -1,15 +1,12 @@ import { randomBytes } from '@libp2p/crypto' -import { CodeError, ERR_TIMEOUT } from '@libp2p/interface/errors' +import { CodeError, ERR_TIMEOUT } from '@libp2p/interface' import first from 'it-first' import { pipe } from 'it-pipe' import { equals as uint8ArrayEquals } from 'uint8arrays/equals' import { PROTOCOL_PREFIX, PROTOCOL_NAME, PING_LENGTH, PROTOCOL_VERSION, TIMEOUT, MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS, ERR_WRONG_PING_ACK } from './constants.js' import type { PingServiceComponents, PingServiceInit, PingService as PingServiceInterface } from './index.js' -import type { AbortOptions, Logger } from '@libp2p/interface' -import type { Stream } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Startable } from '@libp2p/interface/startable' -import type { IncomingStreamData } from '@libp2p/interface-internal/registrar' +import type { AbortOptions, Logger, Stream, PeerId, Startable } from '@libp2p/interface' +import type { IncomingStreamData } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export class PingService implements Startable, PingServiceInterface { diff --git a/packages/protocol-ping/test/index.spec.ts b/packages/protocol-ping/test/index.spec.ts index 88858bf73e..a24fe90892 100644 --- a/packages/protocol-ping/test/index.spec.ts +++ b/packages/protocol-ping/test/index.spec.ts @@ -1,7 +1,6 @@ /* eslint-env mocha */ -import { ERR_TIMEOUT } from '@libp2p/interface/errors' -import { start } from '@libp2p/interface/startable' +import { ERR_TIMEOUT, start } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' @@ -12,10 +11,8 @@ import pDefer from 'p-defer' import { stubInterface, type StubbedInstance } from 'sinon-ts' import { PING_PROTOCOL } from '../src/constants.js' import { PingService } from '../src/ping.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { Stream, Connection } from '@libp2p/interface/connection' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { ComponentLogger, Stream, Connection } from '@libp2p/interface' +import type { ConnectionManager, Registrar } from '@libp2p/interface-internal' interface StubbedPingServiceComponents { registrar: StubbedInstance diff --git a/packages/pubsub-floodsub/CHANGELOG.md b/packages/pubsub-floodsub/CHANGELOG.md index c085c9c741..b338cfef50 100644 --- a/packages/pubsub-floodsub/CHANGELOG.md +++ b/packages/pubsub-floodsub/CHANGELOG.md @@ -11,6 +11,26 @@ * **dev:** bump aegir from 38.1.8 to 39.0.10 ([#233](https://github.com/libp2p/js-libp2p-floodsub/issues/233)) ([e073298](https://github.com/libp2p/js-libp2p-floodsub/commit/e073298f324a89656b0ca6d9a629e60eaedc7873)) +### [8.0.14](https://www.github.com/libp2p/js-libp2p/compare/floodsub-v8.0.13...floodsub-v8.0.14) (2023-11-28) + + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/pubsub bumped from ^8.0.10 to ^8.0.11 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-collections bumped from ^4.0.8 to ^4.0.9 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + ### [8.0.13](https://www.github.com/libp2p/js-libp2p/compare/floodsub-v8.0.12...floodsub-v8.0.13) (2023-11-07) @@ -1055,4 +1075,4 @@ -# 0.1.0 (2016-09-14) +# 0.1.0 (2016-09-14) \ No newline at end of file diff --git a/packages/pubsub-floodsub/package.json b/packages/pubsub-floodsub/package.json index f1c738e34b..ec759e888a 100644 --- a/packages/pubsub-floodsub/package.json +++ b/packages/pubsub-floodsub/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/floodsub", - "version": "8.0.13", + "version": "8.0.14", "description": "libp2p-floodsub, also known as pubsub-flood or just dumbsub, this implementation of pubsub focused on delivering an API for Publish/Subscribe, but with no CastTree Forming (it just floods the network).", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/pubsub-floodsub#readme", @@ -59,17 +59,17 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/pubsub": "^8.0.10", + "@libp2p/interface": "^1.0.0", + "@libp2p/pubsub": "^8.0.11", "protons-runtime": "^5.0.0", "uint8arraylist": "^2.4.3", "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-collections": "^4.0.8", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-collections": "^4.0.9", + "@libp2p/peer-id-factory": "^3.0.9", "@multiformats/multiaddr": "^12.1.10", "@types/sinon": "^17.0.0", "aegir": "^41.0.2", diff --git a/packages/pubsub-floodsub/src/index.ts b/packages/pubsub-floodsub/src/index.ts index a87b3fc367..4add66c75f 100644 --- a/packages/pubsub-floodsub/src/index.ts +++ b/packages/pubsub-floodsub/src/index.ts @@ -23,7 +23,7 @@ * * node.pubsub.subscribe('fruit') * node.pubsub.addEventListener('message', (evt) => { - * console.this.log(evt) + * console.log(evt) * }) * * node.pubsub.publish('fruit', new TextEncoder().encode('banana')) @@ -35,8 +35,7 @@ import { toString } from 'uint8arrays/to-string' import { SimpleTimeCache } from './cache.js' import { multicodec } from './config.js' import { RPC } from './message/rpc.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PubSubInit, Message, PubSubRPC, PubSubRPCMessage, PublishResult, PubSub } from '@libp2p/interface/pubsub' +import type { PeerId, PubSubInit, Message, PubSubRPC, PubSubRPCMessage, PublishResult, PubSub } from '@libp2p/interface' import type { Uint8ArrayList } from 'uint8arraylist' export { multicodec } diff --git a/packages/pubsub-floodsub/test/floodsub.spec.ts b/packages/pubsub-floodsub/test/floodsub.spec.ts index 87f8f0ed4a..cae44d0f7e 100644 --- a/packages/pubsub-floodsub/test/floodsub.spec.ts +++ b/packages/pubsub-floodsub/test/floodsub.spec.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { type Message, type PubSubRPC, StrictNoSign } from '@libp2p/interface/pubsub' +import { type Message, type PubSubRPC, StrictNoSign } from '@libp2p/interface' import { mockRegistrar } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { PeerSet } from '@libp2p/peer-collections' diff --git a/packages/pubsub/CHANGELOG.md b/packages/pubsub/CHANGELOG.md index d7cf64cd82..b868964c38 100644 --- a/packages/pubsub/CHANGELOG.md +++ b/packages/pubsub/CHANGELOG.md @@ -5,6 +5,28 @@ * **dev:** bump delay from 5.0.0 to 6.0.0 ([#144](https://github.com/libp2p/js-libp2p-pubsub/issues/144)) ([1364ce4](https://github.com/libp2p/js-libp2p-pubsub/commit/1364ce41815d3392cfca61169e113cc5414ac2d9)) +### [8.0.11](https://www.github.com/libp2p/js-libp2p/compare/pubsub-v8.0.10...pubsub-v8.0.11) (2023-11-28) + + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/crypto bumped from ^2.0.8 to ^3.0.0 + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.9 to ^0.1.10 + * @libp2p/peer-collections bumped from ^4.0.8 to ^4.0.9 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + ### [8.0.10](https://www.github.com/libp2p/js-libp2p/compare/pubsub-v8.0.9...pubsub-v8.0.10) (2023-11-07) @@ -701,4 +723,4 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### BREAKING CHANGES -* not all fields from concrete classes have been added to the interfaces, some adjustment may be necessary as this gets rolled out +* not all fields from concrete classes have been added to the interfaces, some adjustment may be necessary as this gets rolled out \ No newline at end of file diff --git a/packages/pubsub/package.json b/packages/pubsub/package.json index 0ae6b3d144..3389b22174 100644 --- a/packages/pubsub/package.json +++ b/packages/pubsub/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/pubsub", - "version": "8.0.10", + "version": "8.0.11", "description": "libp2p pubsub base class", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/pubsub#readme", @@ -83,12 +83,12 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/crypto": "^2.0.8", - "@libp2p/interface": "^0.1.6", - "@libp2p/interface-internal": "^0.1.9", - "@libp2p/peer-collections": "^4.0.8", - "@libp2p/peer-id": "^3.0.6", - "@libp2p/utils": "^4.0.7", + "@libp2p/crypto": "^3.0.0", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/peer-collections": "^4.0.9", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/utils": "^5.0.0", "it-length-prefixed": "^9.0.3", "it-pipe": "^3.0.1", "it-pushable": "^3.2.1", @@ -98,8 +98,8 @@ "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "@types/sinon": "^17.0.0", "aegir": "^41.0.2", "delay": "^6.0.0", diff --git a/packages/pubsub/src/index.ts b/packages/pubsub/src/index.ts index 9ed69534f2..b7aa797aec 100644 --- a/packages/pubsub/src/index.ts +++ b/packages/pubsub/src/index.ts @@ -13,9 +13,8 @@ * ``` */ -import { CodeError } from '@libp2p/interface/errors' -import { TypedEventEmitter, CustomEvent } from '@libp2p/interface/events' -import { type PubSub, type Message, type StrictNoSign, type StrictSign, type PubSubInit, type PubSubEvents, type PeerStreams, type PubSubRPCMessage, type PubSubRPC, type PubSubRPCSubscription, type SubscriptionChangeData, type PublishResult, type TopicValidatorFn, TopicValidatorResult } from '@libp2p/interface/pubsub' +import { CodeError, TypedEventEmitter, CustomEvent } from '@libp2p/interface' +import { type PubSub, type Message, type StrictNoSign, type StrictSign, type PubSubInit, type PubSubEvents, type PeerStreams, type PubSubRPCMessage, type PubSubRPC, type PubSubRPCSubscription, type SubscriptionChangeData, type PublishResult, type TopicValidatorFn, TopicValidatorResult, type ComponentLogger, type Logger, type Connection, type PeerId } from '@libp2p/interface' import { PeerMap, PeerSet } from '@libp2p/peer-collections' import { pipe } from 'it-pipe' import Queue from 'p-queue' @@ -26,10 +25,7 @@ import { verifySignature } from './sign.js' import { toMessage, ensureArray, noSignMsgId, msgId, toRpcMessage, randomSeqno } from './utils.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar' +import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal' import type { Uint8ArrayList } from 'uint8arraylist' export interface PubSubComponents { diff --git a/packages/pubsub/src/peer-streams.ts b/packages/pubsub/src/peer-streams.ts index 5656172cf8..d9cd9cfa9c 100644 --- a/packages/pubsub/src/peer-streams.ts +++ b/packages/pubsub/src/peer-streams.ts @@ -1,13 +1,10 @@ -import { TypedEventEmitter, CustomEvent } from '@libp2p/interface/events' +import { TypedEventEmitter, CustomEvent } from '@libp2p/interface' import { closeSource } from '@libp2p/utils/close-source' import * as lp from 'it-length-prefixed' import { pipe } from 'it-pipe' import { pushable } from 'it-pushable' import { Uint8ArrayList } from 'uint8arraylist' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Stream } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStreamEvents } from '@libp2p/interface/pubsub' +import type { ComponentLogger, Logger, Stream, PeerId, PeerStreamEvents } from '@libp2p/interface' import type { Pushable } from 'it-pushable' export interface PeerStreamsInit { diff --git a/packages/pubsub/src/sign.ts b/packages/pubsub/src/sign.ts index e41a8ebe41..41de3e7bbc 100644 --- a/packages/pubsub/src/sign.ts +++ b/packages/pubsub/src/sign.ts @@ -3,8 +3,7 @@ import { peerIdFromKeys } from '@libp2p/peer-id' import { concat as uint8ArrayConcat } from 'uint8arrays/concat' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toRpcMessage } from './utils.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PubSubRPCMessage, SignedMessage } from '@libp2p/interface/pubsub' +import type { PeerId, PubSubRPCMessage, SignedMessage } from '@libp2p/interface' export const SignPrefix = uint8ArrayFromString('libp2p-pubsub:') diff --git a/packages/pubsub/src/utils.ts b/packages/pubsub/src/utils.ts index d89412f57c..880be56781 100644 --- a/packages/pubsub/src/utils.ts +++ b/packages/pubsub/src/utils.ts @@ -1,11 +1,11 @@ import { randomBytes } from '@libp2p/crypto' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { peerIdFromBytes, peerIdFromKeys } from '@libp2p/peer-id' import { sha256 } from 'multiformats/hashes/sha2' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { codes } from './errors.js' -import type { Message, PubSubRPCMessage } from '@libp2p/interface/pubsub' +import type { Message, PubSubRPCMessage } from '@libp2p/interface' /** * Generate a random sequence number diff --git a/packages/pubsub/test/instance.spec.ts b/packages/pubsub/test/instance.spec.ts index f5ca436206..8f96356d0b 100644 --- a/packages/pubsub/test/instance.spec.ts +++ b/packages/pubsub/test/instance.spec.ts @@ -3,7 +3,7 @@ import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' import { PubSubBaseProtocol } from '../src/index.js' import { MockRegistrar } from './utils/index.js' -import type { PublishResult, PubSubRPC, PubSubRPCMessage } from '@libp2p/interface/pubsub' +import type { PublishResult, PubSubRPC, PubSubRPCMessage } from '@libp2p/interface' import type { Uint8ArrayList } from 'uint8arraylist' class PubsubProtocol extends PubSubBaseProtocol { diff --git a/packages/pubsub/test/lifecycle.spec.ts b/packages/pubsub/test/lifecycle.spec.ts index 96f1532efd..787588700b 100644 --- a/packages/pubsub/test/lifecycle.spec.ts +++ b/packages/pubsub/test/lifecycle.spec.ts @@ -10,9 +10,8 @@ import { MockRegistrar, mockIncomingStreamEvent } from './utils/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PublishResult, PubSubRPC, PubSubRPCMessage } from '@libp2p/interface/pubsub' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { PeerId, PublishResult, PubSubRPC, PubSubRPCMessage } from '@libp2p/interface' +import type { Registrar } from '@libp2p/interface-internal' import type { Uint8ArrayList } from 'uint8arraylist' class PubsubProtocol extends PubSubBaseProtocol { diff --git a/packages/pubsub/test/message.spec.ts b/packages/pubsub/test/message.spec.ts index 8fad682301..137d875ad2 100644 --- a/packages/pubsub/test/message.spec.ts +++ b/packages/pubsub/test/message.spec.ts @@ -9,8 +9,7 @@ import { MockRegistrar, PubsubImplementation } from './utils/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Message } from '@libp2p/interface/pubsub' +import type { PeerId, Message } from '@libp2p/interface' describe('pubsub base messages', () => { let peerId: PeerId diff --git a/packages/pubsub/test/pubsub.spec.ts b/packages/pubsub/test/pubsub.spec.ts index 0c55846d6c..bd4da454b9 100644 --- a/packages/pubsub/test/pubsub.spec.ts +++ b/packages/pubsub/test/pubsub.spec.ts @@ -17,8 +17,7 @@ import { PubsubImplementation, mockIncomingStreamEvent } from './utils/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Message, PubSubRPC } from '@libp2p/interface/pubsub' +import type { PeerId, Message, PubSubRPC } from '@libp2p/interface' const protocol = '/pubsub/1.0.0' const topic = 'test-topic' diff --git a/packages/pubsub/test/sign.spec.ts b/packages/pubsub/test/sign.spec.ts index b0af2211ad..ffcf571104 100644 --- a/packages/pubsub/test/sign.spec.ts +++ b/packages/pubsub/test/sign.spec.ts @@ -10,8 +10,7 @@ import { } from '../src/sign.js' import { randomSeqno, toRpcMessage } from '../src/utils.js' import { RPC } from './message/rpc.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PubSubRPCMessage } from '@libp2p/interface/pubsub' +import type { PeerId, PubSubRPCMessage } from '@libp2p/interface' function encodeMessage (message: PubSubRPCMessage): Uint8Array { return RPC.Message.encode(message) diff --git a/packages/pubsub/test/topic-validators.spec.ts b/packages/pubsub/test/topic-validators.spec.ts index 1ebf109d3f..153d322de7 100644 --- a/packages/pubsub/test/topic-validators.spec.ts +++ b/packages/pubsub/test/topic-validators.spec.ts @@ -1,4 +1,4 @@ -import { type PubSubRPC, TopicValidatorResult } from '@libp2p/interface/pubsub' +import { type PubSubRPC, TopicValidatorResult, type PeerId } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' @@ -11,7 +11,6 @@ import { MockRegistrar, PubsubImplementation } from './utils/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' const protocol = '/pubsub/1.0.0' diff --git a/packages/pubsub/test/utils.spec.ts b/packages/pubsub/test/utils.spec.ts index d8a4dafacb..c8c19fbd77 100644 --- a/packages/pubsub/test/utils.spec.ts +++ b/packages/pubsub/test/utils.spec.ts @@ -3,7 +3,7 @@ import * as PeerIdFactory from '@libp2p/peer-id-factory' import { expect } from 'aegir/chai' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import * as utils from '../src/utils.js' -import type { Message, PubSubRPCMessage } from '@libp2p/interface/pubsub' +import type { Message, PubSubRPCMessage } from '@libp2p/interface' describe('utils', () => { it('randomSeqno', () => { diff --git a/packages/pubsub/test/utils/index.ts b/packages/pubsub/test/utils/index.ts index fdd7e5b535..9085e808bf 100644 --- a/packages/pubsub/test/utils/index.ts +++ b/packages/pubsub/test/utils/index.ts @@ -2,11 +2,8 @@ import * as PeerIdFactory from '@libp2p/peer-id-factory' import { duplexPair } from 'it-pair/duplex' import { PubSubBaseProtocol } from '../../src/index.js' import { RPC } from '../message/rpc.js' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PublishResult, PubSubRPC, PubSubRPCMessage } from '@libp2p/interface/pubsub' -import type { Topology } from '@libp2p/interface/topology' -import type { IncomingStreamData, Registrar, StreamHandler, StreamHandlerRecord } from '@libp2p/interface-internal/registrar' +import type { Connection, PeerId, PublishResult, PubSubRPC, PubSubRPCMessage, Topology } from '@libp2p/interface' +import type { IncomingStreamData, Registrar, StreamHandler, StreamHandlerRecord } from '@libp2p/interface-internal' export const createPeerId = async (): Promise => { const peerId = await PeerIdFactory.createEd25519PeerId() diff --git a/packages/stream-multiplexer-mplex/CHANGELOG.md b/packages/stream-multiplexer-mplex/CHANGELOG.md index 5f4056d77e..c6623d112d 100644 --- a/packages/stream-multiplexer-mplex/CHANGELOG.md +++ b/packages/stream-multiplexer-mplex/CHANGELOG.md @@ -12,6 +12,33 @@ * **dev:** bump cborg from 1.10.2 to 2.0.1 ([#282](https://github.com/libp2p/js-libp2p-mplex/issues/282)) ([4dbc590](https://github.com/libp2p/js-libp2p-mplex/commit/4dbc590d1ac92581fe2e937757567eef3854acf4)) * **dev:** bump delay from 5.0.0 to 6.0.0 ([#281](https://github.com/libp2p/js-libp2p-mplex/issues/281)) ([1e03e75](https://github.com/libp2p/js-libp2p-mplex/commit/1e03e75369722be9872f747cd83f555bc08d49fe)) +## [10.0.0](https://www.github.com/libp2p/js-libp2p/compare/mplex-v9.0.12...mplex-v10.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + ### [9.0.12](https://www.github.com/libp2p/js-libp2p/compare/mplex-v9.0.11...mplex-v9.0.12) (2023-11-07) @@ -922,4 +949,4 @@ Signed-off-by: Alan Shaw -# 0.1.0 (2016-03-07) +# 0.1.0 (2016-03-07) \ No newline at end of file diff --git a/packages/stream-multiplexer-mplex/package.json b/packages/stream-multiplexer-mplex/package.json index 3321c915c1..4a102dfe2e 100644 --- a/packages/stream-multiplexer-mplex/package.json +++ b/packages/stream-multiplexer-mplex/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/mplex", - "version": "9.0.12", + "version": "10.0.0", "description": "JavaScript implementation of https://github.com/libp2p/mplex", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex#readme", @@ -61,8 +61,8 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/utils": "^4.0.7", + "@libp2p/interface": "^1.0.0", + "@libp2p/utils": "^5.0.0", "benchmark": "^2.1.4", "it-pushable": "^3.2.1", "it-stream-types": "^2.0.1", @@ -72,8 +72,8 @@ "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", "aegir": "^41.0.2", "cborg": "^4.0.3", "delay": "^6.0.0", diff --git a/packages/stream-multiplexer-mplex/src/index.ts b/packages/stream-multiplexer-mplex/src/index.ts index 7637daf026..fcc793cd53 100644 --- a/packages/stream-multiplexer-mplex/src/index.ts +++ b/packages/stream-multiplexer-mplex/src/index.ts @@ -31,8 +31,8 @@ * ``` */ -import { MplexStreamMuxer, type MplexComponents } from './mplex.js' -import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface/stream-muxer' +import { MplexStreamMuxer } from './mplex.js' +import type { ComponentLogger, StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface' export interface MplexInit { /** @@ -99,6 +99,10 @@ class Mplex implements StreamMuxerFactory { } } +export interface MplexComponents { + logger: ComponentLogger +} + export function mplex (init: MplexInit = {}): (components: MplexComponents) => StreamMuxerFactory { return (components) => new Mplex(components, init) } diff --git a/packages/stream-multiplexer-mplex/src/mplex.ts b/packages/stream-multiplexer-mplex/src/mplex.ts index 90d9a9a6c3..1d8b42b127 100644 --- a/packages/stream-multiplexer-mplex/src/mplex.ts +++ b/packages/stream-multiplexer-mplex/src/mplex.ts @@ -1,4 +1,6 @@ -import { CodeError } from '@libp2p/interface/errors' +/* eslint-disable complexity */ + +import { CodeError } from '@libp2p/interface' import { closeSource } from '@libp2p/utils/close-source' import { pipe } from 'it-pipe' import { type Pushable, pushable } from 'it-pushable' @@ -8,10 +10,8 @@ import { Decoder } from './decode.js' import { encode } from './encode.js' import { MessageTypes, MessageTypeNames, type Message } from './message-types.js' import { createStream, type MplexStream } from './stream.js' -import type { MplexInit } from './index.js' -import type { AbortOptions, ComponentLogger, Logger } from '@libp2p/interface' -import type { Stream } from '@libp2p/interface/connection' -import type { StreamMuxer, StreamMuxerInit } from '@libp2p/interface/stream-muxer' +import type { MplexComponents, MplexInit } from './index.js' +import type { AbortOptions, ComponentLogger, Logger, Stream, StreamMuxer, StreamMuxerInit } from '@libp2p/interface' import type { Sink, Source } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' @@ -38,10 +38,6 @@ function printMessage (msg: Message): any { return output } -export interface MplexComponents { - logger: ComponentLogger -} - interface MplexStreamMuxerInit extends MplexInit, StreamMuxerInit { /** * The default timeout to use in ms when shutting down the muxer. diff --git a/packages/transport-circuit-relay-v2/CHANGELOG.md b/packages/transport-circuit-relay-v2/CHANGELOG.md new file mode 100644 index 0000000000..13e1231703 --- /dev/null +++ b/packages/transport-circuit-relay-v2/CHANGELOG.md @@ -0,0 +1,35 @@ +# Changelog + +## 1.0.0 (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/circuit-relay` should be updated to `@libp2p/circuit-relay-v2` + +### Bug Fixes + +* dial relay when we are dialed via it but have no reservation ([#2252](https://www.github.com/libp2p/js-libp2p/issues/2252)) ([d729d66](https://www.github.com/libp2p/js-libp2p/commit/d729d66a54a272dfe11eda8836a555a187cc9c39)) +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* extract circuit relay v2 to separate module ([#2222](https://www.github.com/libp2p/js-libp2p/issues/2222)) ([24afba3](https://www.github.com/libp2p/js-libp2p/commit/24afba30004fb7f24af1f0180229bb164340f00b)) + + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.2 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.5 to ^0.1.10 + * @libp2p/peer-collections bumped from ^4.0.8 to ^4.0.9 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * @libp2p/peer-record bumped from ^6.0.9 to ^6.0.10 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 \ No newline at end of file diff --git a/packages/transport-circuit-relay-v2/package.json b/packages/transport-circuit-relay-v2/package.json index 388edddeab..a387f080d2 100644 --- a/packages/transport-circuit-relay-v2/package.json +++ b/packages/transport-circuit-relay-v2/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/circuit-relay-v2", - "version": "0.0.0", + "version": "1.0.0", "description": "Implementation of Circuit Relay v2", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-circuit-relay-v2#readme", @@ -51,12 +51,12 @@ "dep-check": "aegir dep-check" }, "dependencies": { - "@libp2p/interface": "^0.1.2", - "@libp2p/interface-internal": "^0.1.5", - "@libp2p/peer-collections": "^4.0.8", - "@libp2p/peer-id": "^3.0.6", - "@libp2p/peer-record": "^6.0.9", - "@libp2p/utils": "^4.0.7", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/peer-collections": "^4.0.9", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/peer-record": "^6.0.10", + "@libp2p/utils": "^5.0.0", "@multiformats/mafmt": "^12.1.6", "@multiformats/multiaddr": "^12.1.10", "any-signal": "^4.1.1", @@ -72,9 +72,9 @@ "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "it-drain": "^3.0.3", "it-pair": "^2.0.6", diff --git a/packages/transport-circuit-relay-v2/src/index.ts b/packages/transport-circuit-relay-v2/src/index.ts index d68b389903..8d3a9b2c33 100644 --- a/packages/transport-circuit-relay-v2/src/index.ts +++ b/packages/transport-circuit-relay-v2/src/index.ts @@ -35,7 +35,7 @@ */ import type { Limit } from './pb/index.js' -import type { TypedEventEmitter } from '@libp2p/interface/events' +import type { TypedEventEmitter } from '@libp2p/interface' import type { PeerMap } from '@libp2p/peer-collections' import type { Multiaddr } from '@multiformats/multiaddr' @@ -55,8 +55,8 @@ export interface CircuitRelayService extends TypedEventEmitter } -export { circuitRelayServer } from './server/index.js' -export { circuitRelayTransport } from './transport/index.js' +export { circuitRelayServer, type CircuitRelayServerInit, type CircuitRelayServerComponents } from './server/index.js' +export { circuitRelayTransport, type CircuitRelayTransportInit, type CircuitRelayTransportComponents } from './transport/index.js' export { RELAY_V2_HOP_CODEC, diff --git a/packages/transport-circuit-relay-v2/src/server/advert-service.ts b/packages/transport-circuit-relay-v2/src/server/advert-service.ts index 80a7d9aecc..4b8f55dddb 100644 --- a/packages/transport-circuit-relay-v2/src/server/advert-service.ts +++ b/packages/transport-circuit-relay-v2/src/server/advert-service.ts @@ -1,4 +1,4 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import pRetry from 'p-retry' import { DEFAULT_ADVERT_BOOT_DELAY, @@ -6,9 +6,7 @@ import { RELAY_RENDEZVOUS_NS } from '../constants.js' import { namespaceToCid } from '../utils.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { Startable } from '@libp2p/interface/startable' +import type { ComponentLogger, Logger, ContentRouting, Startable } from '@libp2p/interface' export interface AdvertServiceInit { /** diff --git a/packages/transport-circuit-relay-v2/src/server/index.ts b/packages/transport-circuit-relay-v2/src/server/index.ts index 8271887ea3..36eb9fdfa8 100644 --- a/packages/transport-circuit-relay-v2/src/server/index.ts +++ b/packages/transport-circuit-relay-v2/src/server/index.ts @@ -1,4 +1,4 @@ -import { TypedEventEmitter, setMaxListeners } from '@libp2p/interface/events' +import { TypedEventEmitter, setMaxListeners } from '@libp2p/interface' import { peerIdFromBytes } from '@libp2p/peer-id' import { RecordEnvelope } from '@libp2p/peer-record' import { type Multiaddr, multiaddr } from '@multiformats/multiaddr' @@ -18,15 +18,8 @@ import { AdvertService, type AdvertServiceComponents, type AdvertServiceInit } f import { ReservationStore, type ReservationStoreInit } from './reservation-store.js' import { ReservationVoucherRecord } from './reservation-voucher.js' import type { CircuitRelayService, RelayReservation } from '../index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar' +import type { ComponentLogger, Logger, Connection, Stream, ConnectionGater, PeerId, PeerStore, Startable } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, IncomingStreamData, Registrar } from '@libp2p/interface-internal' import type { PeerMap } from '@libp2p/peer-collections' const isRelayAddr = (ma: Multiaddr): boolean => ma.protoCodes().includes(CIRCUIT_PROTO_CODE) diff --git a/packages/transport-circuit-relay-v2/src/server/reservation-store.ts b/packages/transport-circuit-relay-v2/src/server/reservation-store.ts index 0f5d3bf62e..f5873d838b 100644 --- a/packages/transport-circuit-relay-v2/src/server/reservation-store.ts +++ b/packages/transport-circuit-relay-v2/src/server/reservation-store.ts @@ -2,9 +2,7 @@ import { PeerMap } from '@libp2p/peer-collections' import { DEFAULT_DATA_LIMIT, DEFAULT_DURATION_LIMIT, DEFAULT_MAX_RESERVATION_CLEAR_INTERVAL, DEFAULT_MAX_RESERVATION_STORE_SIZE, DEFAULT_MAX_RESERVATION_TTL } from '../constants.js' import { type Limit, Status } from '../pb/index.js' import type { RelayReservation } from '../index.js' -import type { RecursivePartial } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Startable } from '@libp2p/interface/startable' +import type { RecursivePartial, PeerId, Startable } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' export type ReservationStatus = Status.OK | Status.PERMISSION_DENIED | Status.RESERVATION_REFUSED diff --git a/packages/transport-circuit-relay-v2/src/server/reservation-voucher.ts b/packages/transport-circuit-relay-v2/src/server/reservation-voucher.ts index d32d3f6104..d547d0218d 100644 --- a/packages/transport-circuit-relay-v2/src/server/reservation-voucher.ts +++ b/packages/transport-circuit-relay-v2/src/server/reservation-voucher.ts @@ -1,6 +1,5 @@ import { ReservationVoucher } from '../pb/index.js' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Record } from '@libp2p/interface/record' +import type { PeerId, Record } from '@libp2p/interface' export interface ReservationVoucherOptions { relay: PeerId diff --git a/packages/transport-circuit-relay-v2/src/transport/discovery.ts b/packages/transport-circuit-relay-v2/src/transport/discovery.ts index f0b7347a08..6d4d1ae04b 100644 --- a/packages/transport-circuit-relay-v2/src/transport/discovery.ts +++ b/packages/transport-circuit-relay-v2/src/transport/discovery.ts @@ -1,17 +1,11 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { RELAY_RENDEZVOUS_NS, RELAY_V2_HOP_CODEC } from '../constants.js' import { namespaceToCid } from '../utils.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ComponentLogger, Logger, ContentRouting, PeerId, PeerStore, Startable } from '@libp2p/interface' +import type { ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal' export interface RelayDiscoveryEvents { 'relay:discover': CustomEvent diff --git a/packages/transport-circuit-relay-v2/src/transport/index.ts b/packages/transport-circuit-relay-v2/src/transport/index.ts index 9a1923cbf6..be25883e4b 100644 --- a/packages/transport-circuit-relay-v2/src/transport/index.ts +++ b/packages/transport-circuit-relay-v2/src/transport/index.ts @@ -1,16 +1,8 @@ -import { type Transport, type Upgrader } from '@libp2p/interface/transport' +import { type Transport, type Upgrader, type Libp2pEvents, type ComponentLogger, type ConnectionGater, type ContentRouting, type TypedEventTarget, type PeerId, type PeerStore } from '@libp2p/interface' import { type RelayDiscoveryComponents } from './discovery.js' import { type RelayStoreInit } from './reservation-store.js' import { CircuitRelayTransport } from './transport.js' -import type { Libp2pEvents, ComponentLogger } from '@libp2p/interface' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { TypedEventTarget } from '@libp2p/interface/events' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' +import type { AddressManager, ConnectionManager, Registrar } from '@libp2p/interface-internal' export interface CircuitRelayTransportComponents extends RelayDiscoveryComponents { peerId: PeerId diff --git a/packages/transport-circuit-relay-v2/src/transport/listener.ts b/packages/transport-circuit-relay-v2/src/transport/listener.ts index 91a85e72f3..7058131aac 100644 --- a/packages/transport-circuit-relay-v2/src/transport/listener.ts +++ b/packages/transport-circuit-relay-v2/src/transport/listener.ts @@ -1,12 +1,9 @@ -import { CodeError } from '@libp2p/interface/errors' -import { TypedEventEmitter } from '@libp2p/interface/events' +import { CodeError, TypedEventEmitter } from '@libp2p/interface' import { PeerMap } from '@libp2p/peer-collections' import { multiaddr } from '@multiformats/multiaddr' import type { ReservationStore } from './reservation-store.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { Listener, ListenerEvents } from '@libp2p/interface/transport' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' +import type { ComponentLogger, Logger, PeerId, Listener, ListenerEvents } from '@libp2p/interface' +import type { ConnectionManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export interface CircuitRelayTransportListenerComponents { diff --git a/packages/transport-circuit-relay-v2/src/transport/reservation-store.ts b/packages/transport-circuit-relay-v2/src/transport/reservation-store.ts index f65ce3c241..8516ca3696 100644 --- a/packages/transport-circuit-relay-v2/src/transport/reservation-store.ts +++ b/packages/transport-circuit-relay-v2/src/transport/reservation-store.ts @@ -1,4 +1,4 @@ -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' +import { TypedEventEmitter, type TypedEventTarget, type Libp2pEvents, type AbortOptions, type ComponentLogger, type Logger, type Connection, type PeerId, type PeerStore, type Startable } from '@libp2p/interface' import { PeerMap } from '@libp2p/peer-collections' import { PeerJobQueue } from '@libp2p/utils/peer-job-queue' import { multiaddr } from '@multiformats/multiaddr' @@ -8,13 +8,7 @@ import { DEFAULT_RESERVATION_CONCURRENCY, RELAY_TAG, RELAY_V2_HOP_CODEC } from ' import { HopMessage, Status } from '../pb/index.js' import { getExpirationMilliseconds } from '../utils.js' import type { Reservation } from '../pb/index.js' -import type { Libp2pEvents, AbortOptions, ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Startable } from '@libp2p/interface/startable' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ConnectionManager, TransportManager } from '@libp2p/interface-internal' // allow refreshing a relay reservation if it will expire in the next 10 minutes const REFRESH_WINDOW = (60 * 1000) * 10 diff --git a/packages/transport-circuit-relay-v2/src/transport/transport.ts b/packages/transport-circuit-relay-v2/src/transport/transport.ts index 61b511de29..1c65f61b61 100644 --- a/packages/transport-circuit-relay-v2/src/transport/transport.ts +++ b/packages/transport-circuit-relay-v2/src/transport/transport.ts @@ -1,5 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' -import { symbol, type Transport, type CreateListenerOptions, type Listener, type Upgrader } from '@libp2p/interface/transport' +import { CodeError, transportSymbol } from '@libp2p/interface' import { peerIdFromBytes, peerIdFromString } from '@libp2p/peer-id' import { streamToMaConnection } from '@libp2p/utils/stream-to-ma-conn' import * as mafmt from '@multiformats/mafmt' @@ -11,15 +10,8 @@ import { RelayDiscovery } from './discovery.js' import { createListener } from './listener.js' import { ReservationStore } from './reservation-store.js' import type { CircuitRelayTransportComponents, CircuitRelayTransportInit } from './index.js' -import type { AbortOptions, ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/src/transport-manager/index.js' +import type { AbortOptions, ComponentLogger, Logger, Connection, Stream, ConnectionGater, PeerId, PeerStore, Transport, CreateListenerOptions, Listener, Upgrader } from '@libp2p/interface' +import type { AddressManager, ConnectionManager, IncomingStreamData, Registrar, TransportManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' const isValidStop = (request: StopMessage): request is Required => { @@ -136,7 +128,7 @@ export class CircuitRelayTransport implements Transport { this.started = false } - readonly [symbol] = true + readonly [transportSymbol] = true readonly [Symbol.toStringTag] = 'libp2p/circuit-relay-v2' diff --git a/packages/transport-circuit-relay-v2/src/utils.ts b/packages/transport-circuit-relay-v2/src/utils.ts index 4a7848db7c..5049de7b34 100644 --- a/packages/transport-circuit-relay-v2/src/utils.ts +++ b/packages/transport-circuit-relay-v2/src/utils.ts @@ -1,11 +1,10 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { anySignal } from 'any-signal' import { CID } from 'multiformats/cid' import { sha256 } from 'multiformats/hashes/sha2' import { ERR_TRANSFER_LIMIT_EXCEEDED } from './constants.js' import type { Limit } from './pb/index.js' -import type { LoggerOptions } from '@libp2p/interface' -import type { Stream } from '@libp2p/interface/connection' +import type { LoggerOptions, Stream } from '@libp2p/interface' import type { Source } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/transport-circuit-relay-v2/test/hop.spec.ts b/packages/transport-circuit-relay-v2/test/hop.spec.ts index 5407a9c296..dd2aef249d 100644 --- a/packages/transport-circuit-relay-v2/test/hop.spec.ts +++ b/packages/transport-circuit-relay-v2/test/hop.spec.ts @@ -1,7 +1,7 @@ /* eslint-disable max-nested-callbacks */ -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' -import { isStartable } from '@libp2p/interface/startable' +import { TypedEventEmitter, type TypedEventTarget, type ComponentLogger, type Libp2pEvents, type Connection, type Stream, type ConnectionGater, type ContentRouting, type PeerId, type PeerStore, type Transport, type Upgrader } from '@libp2p/interface' +import { isStartable } from '@libp2p/interface' import { mockRegistrar, mockUpgrader, mockNetwork, mockConnectionManager, mockConnectionGater } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { PeerMap } from '@libp2p/peer-collections' @@ -15,17 +15,7 @@ import { DEFAULT_MAX_RESERVATION_STORE_SIZE, RELAY_SOURCE_TAG, RELAY_V2_HOP_CODE import { circuitRelayServer, type CircuitRelayService, circuitRelayTransport } from '../src/index.js' import { HopMessage, Status } from '../src/pb/index.js' import type { CircuitRelayServerInit } from '../src/server/index.js' -import type { ComponentLogger, Libp2pEvents } from '@libp2p/interface' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Transport, Upgrader } from '@libp2p/interface/transport' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { AddressManager, ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal' export function matchPeerId (peerId: PeerId): Sinon.SinonMatcher { return Sinon.match(p => p.toString() === peerId.toString()) diff --git a/packages/transport-circuit-relay-v2/test/stop.spec.ts b/packages/transport-circuit-relay-v2/test/stop.spec.ts index 306cd67e46..57a9926754 100644 --- a/packages/transport-circuit-relay-v2/test/stop.spec.ts +++ b/packages/transport-circuit-relay-v2/test/stop.spec.ts @@ -1,7 +1,7 @@ /* eslint-env mocha */ -import { TypedEventEmitter, type TypedEventTarget } from '@libp2p/interface/events' -import { isStartable } from '@libp2p/interface/startable' +import { TypedEventEmitter, type TypedEventTarget, type ComponentLogger, type Libp2pEvents, type Connection, type Stream, type ConnectionGater, type ContentRouting, type PeerId, type PeerStore, type Upgrader } from '@libp2p/interface' +import { isStartable } from '@libp2p/interface' import { mockStream } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' @@ -14,17 +14,7 @@ import Sinon from 'sinon' import { stubInterface, type StubbedInstance } from 'sinon-ts' import { Status, StopMessage } from '../src/pb/index.js' import { CircuitRelayTransport } from '../src/transport/transport.js' -import type { ComponentLogger, Libp2pEvents } from '@libp2p/interface' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { ConnectionGater } from '@libp2p/interface/connection-gater' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerStore } from '@libp2p/interface/peer-store' -import type { Upgrader } from '@libp2p/interface/transport' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { Registrar, StreamHandler } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { AddressManager, ConnectionManager, Registrar, StreamHandler, TransportManager } from '@libp2p/interface-internal' interface StubbedCircuitRelayTransportComponents { peerId: PeerId diff --git a/packages/transport-circuit-relay-v2/test/utils.ts b/packages/transport-circuit-relay-v2/test/utils.ts index e0db1f8091..c6b021a96c 100644 --- a/packages/transport-circuit-relay-v2/test/utils.ts +++ b/packages/transport-circuit-relay-v2/test/utils.ts @@ -2,11 +2,8 @@ import { peerIdFromString } from '@libp2p/peer-id' import pWaitFor from 'p-wait-for' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import { RELAY_V2_HOP_CODEC } from '../../../packages/transport-circuit-relay-v2/src/constants.js' -import type { Libp2p, AbortOptions } from '@libp2p/interface' -import type { ContentRouting } from '@libp2p/interface/content-routing' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { PeerInfo } from '@libp2p/interface/peer-info' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' +import type { Libp2p, AbortOptions, ContentRouting, PeerId, PeerInfo } from '@libp2p/interface' +import type { AddressManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' import type { CID, Version } from 'multiformats' import type { Options as PWaitForOptions } from 'p-wait-for' diff --git a/packages/transport-tcp/CHANGELOG.md b/packages/transport-tcp/CHANGELOG.md index dc8dc9d651..4b82fcf10a 100644 --- a/packages/transport-tcp/CHANGELOG.md +++ b/packages/transport-tcp/CHANGELOG.md @@ -5,6 +5,34 @@ * **dev:** bump aegir from 38.1.8 to 39.0.10 ([#279](https://github.com/libp2p/js-libp2p-tcp/issues/279)) ([3ed1235](https://github.com/libp2p/js-libp2p-tcp/commit/3ed12353aa48b5a933f80042846a8f1c2337fa47)) +## [9.0.0](https://www.github.com/libp2p/js-libp2p/compare/tcp-v8.0.13...tcp-v9.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* disable Nagle's algorithm by default ([#2242](https://www.github.com/libp2p/js-libp2p/issues/2242)) ([13a870c](https://www.github.com/libp2p/js-libp2p/commit/13a870cbef326a3a3b3c55b886c2109feaa2b628)) +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + ### [8.0.13](https://www.github.com/libp2p/js-libp2p/compare/tcp-v8.0.12...tcp-v8.0.13) (2023-11-07) diff --git a/packages/transport-tcp/package.json b/packages/transport-tcp/package.json index 6b68440798..ec1c38e92d 100644 --- a/packages/transport-tcp/package.json +++ b/packages/transport-tcp/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/tcp", - "version": "8.0.13", + "version": "9.0.0", "description": "A TCP transport for libp2p", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-tcp#readme", @@ -55,16 +55,16 @@ "test:electron-main": "aegir test -t electron-main" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/utils": "^4.0.7", + "@libp2p/interface": "^1.0.0", + "@libp2p/utils": "^5.0.0", "@multiformats/mafmt": "^12.1.6", "@multiformats/multiaddr": "^12.1.10", "@types/sinon": "^17.0.0", "stream-to-it": "^0.2.2" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", "aegir": "^41.0.2", "it-all": "^3.0.3", "it-pipe": "^3.0.1", diff --git a/packages/transport-tcp/src/index.ts b/packages/transport-tcp/src/index.ts index 65dd7ffdc2..3f1e70ff23 100644 --- a/packages/transport-tcp/src/index.ts +++ b/packages/transport-tcp/src/index.ts @@ -22,7 +22,7 @@ * const listener = transport.createListener({ * upgrader, * handler: (socket) => { - * console.this.log('new connection opened') + * console.log('new connection opened') * pipe( * ['hello', ' ', 'World!'], * socket @@ -32,14 +32,14 @@ * * const addr = multiaddr('/ip4/127.0.0.1/tcp/9090') * await listener.listen(addr) - * console.this.log('listening') + * console.log('listening') * * const socket = await transport.dial(addr, { upgrader }) * const values = await pipe( * socket, * all * ) - * console.this.log(`Value: ${values.toString()}`) + * console.log(`Value: ${values.toString()}`) * * // Close connection after reading * await listener.close() @@ -55,16 +55,13 @@ */ import net from 'net' -import { AbortError, CodeError } from '@libp2p/interface/errors' -import { type CreateListenerOptions, type DialOptions, symbol, type Transport, type Listener } from '@libp2p/interface/transport' +import { transportSymbol, AbortError, CodeError } from '@libp2p/interface' import * as mafmt from '@multiformats/mafmt' import { CODE_CIRCUIT, CODE_P2P, CODE_UNIX } from './constants.js' import { type CloseServerOnMaxConnectionsOpts, TCPListener } from './listener.js' import { toMultiaddrConnection } from './socket-to-conn.js' import { multiaddrToNetConfig } from './utils.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { CounterGroup, Metrics } from '@libp2p/interface/metrics' +import type { ComponentLogger, Logger, Connection, CounterGroup, Metrics, CreateListenerOptions, DialOptions, Transport, Listener } from '@libp2p/interface' import type { AbortOptions, Multiaddr } from '@multiformats/multiaddr' import type { Socket, IpcSocketConnectOpts, TcpSocketConnectOpts } from 'net' @@ -176,7 +173,7 @@ class TCP implements Transport { } } - readonly [symbol] = true + readonly [transportSymbol] = true readonly [Symbol.toStringTag] = '@libp2p/tcp' diff --git a/packages/transport-tcp/src/listener.ts b/packages/transport-tcp/src/listener.ts index 40ffcaf874..0903cf878c 100644 --- a/packages/transport-tcp/src/listener.ts +++ b/packages/transport-tcp/src/listener.ts @@ -1,6 +1,5 @@ import net from 'net' -import { CodeError } from '@libp2p/interface/errors' -import { TypedEventEmitter, CustomEvent } from '@libp2p/interface/events' +import { CodeError, TypedEventEmitter, CustomEvent } from '@libp2p/interface' import { CODE_P2P } from './constants.js' import { toMultiaddrConnection } from './socket-to-conn.js' import { @@ -9,10 +8,7 @@ import { type NetConfig } from './utils.js' import type { TCPCreateListenerOptions } from './index.js' -import type { ComponentLogger, Logger, LoggerOptions } from '@libp2p/interface' -import type { MultiaddrConnection, Connection } from '@libp2p/interface/connection' -import type { CounterGroup, MetricGroup, Metrics } from '@libp2p/interface/metrics' -import type { Listener, ListenerEvents, Upgrader } from '@libp2p/interface/transport' +import type { ComponentLogger, Logger, LoggerOptions, MultiaddrConnection, Connection, CounterGroup, MetricGroup, Metrics, Listener, ListenerEvents, Upgrader } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' /** diff --git a/packages/transport-tcp/src/socket-to-conn.ts b/packages/transport-tcp/src/socket-to-conn.ts index a75711f909..e5e86bd9ba 100644 --- a/packages/transport-tcp/src/socket-to-conn.ts +++ b/packages/transport-tcp/src/socket-to-conn.ts @@ -1,12 +1,10 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { ipPortToMultiaddr as toMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr' // @ts-expect-error no types import toIterable from 'stream-to-it' import { CLOSE_TIMEOUT, SOCKET_TIMEOUT } from './constants.js' import { multiaddrToNetConfig } from './utils.js' -import type { ComponentLogger } from '@libp2p/interface' -import type { MultiaddrConnection } from '@libp2p/interface/connection' -import type { CounterGroup } from '@libp2p/interface/metrics' +import type { ComponentLogger, MultiaddrConnection, CounterGroup } from '@libp2p/interface' import type { AbortOptions, Multiaddr } from '@multiformats/multiaddr' import type { Socket } from 'net' diff --git a/packages/transport-tcp/test/connection-limits.spec.ts b/packages/transport-tcp/test/connection-limits.spec.ts index c802e91d27..a889c7cbe4 100644 --- a/packages/transport-tcp/test/connection-limits.spec.ts +++ b/packages/transport-tcp/test/connection-limits.spec.ts @@ -1,6 +1,6 @@ import net from 'node:net' import { promisify } from 'util' -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' diff --git a/packages/transport-tcp/test/connection.spec.ts b/packages/transport-tcp/test/connection.spec.ts index aa2830a66b..06174b685c 100644 --- a/packages/transport-tcp/test/connection.spec.ts +++ b/packages/transport-tcp/test/connection.spec.ts @@ -1,11 +1,10 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { tcp } from '../src/index.js' -import type { Connection } from '@libp2p/interface/connection' -import type { Transport, Upgrader } from '@libp2p/interface/transport' +import type { Connection, Transport, Upgrader } from '@libp2p/interface' describe('valid localAddr and remoteAddr', () => { let transport: Transport diff --git a/packages/transport-tcp/test/filter.spec.ts b/packages/transport-tcp/test/filter.spec.ts index 8b094c1d01..8bf6324450 100644 --- a/packages/transport-tcp/test/filter.spec.ts +++ b/packages/transport-tcp/test/filter.spec.ts @@ -2,7 +2,7 @@ import { defaultLogger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { tcp } from '../src/index.js' -import type { Transport } from '@libp2p/interface/transport' +import type { Transport } from '@libp2p/interface' describe('filter addrs', () => { const base = '/ip4/127.0.0.1' diff --git a/packages/transport-tcp/test/listen-dial.spec.ts b/packages/transport-tcp/test/listen-dial.spec.ts index f8081246b7..b165267463 100644 --- a/packages/transport-tcp/test/listen-dial.spec.ts +++ b/packages/transport-tcp/test/listen-dial.spec.ts @@ -1,6 +1,6 @@ import os from 'os' import path from 'path' -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { mockRegistrar, mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' @@ -10,8 +10,7 @@ import { pipe } from 'it-pipe' import pDefer from 'p-defer' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { tcp } from '../src/index.js' -import type { MultiaddrConnection } from '@libp2p/interface/connection' -import type { Transport, Upgrader } from '@libp2p/interface/transport' +import type { MultiaddrConnection, Transport, Upgrader } from '@libp2p/interface' const isCI = process.env.CI diff --git a/packages/transport-tcp/test/max-connections.spec.ts b/packages/transport-tcp/test/max-connections.spec.ts index ee0b96b3fb..dc3339061d 100644 --- a/packages/transport-tcp/test/max-connections.spec.ts +++ b/packages/transport-tcp/test/max-connections.spec.ts @@ -1,6 +1,6 @@ import net from 'node:net' import { promisify } from 'node:util' -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' diff --git a/packages/transport-webrtc/CHANGELOG.md b/packages/transport-webrtc/CHANGELOG.md index 2deffc4935..fc58781f40 100644 --- a/packages/transport-webrtc/CHANGELOG.md +++ b/packages/transport-webrtc/CHANGELOG.md @@ -5,6 +5,46 @@ * add browser-to-browser test for bi-directional communication ([#172](https://github.com/libp2p/js-libp2p-webrtc/issues/172)) ([1ec3d8a](https://github.com/libp2p/js-libp2p-webrtc/commit/1ec3d8a8b611d5227f430037e2547fd86d115eaa)) +## [4.0.0](https://www.github.com/libp2p/js-libp2p/compare/webrtc-v3.2.11...webrtc-v4.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data +* imports from `libp2p/circuit-relay` should be updated to `@libp2p/circuit-relay-v2` + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) +* use optimistic protocol negotation ([#2253](https://www.github.com/libp2p/js-libp2p/issues/2253)) ([0b4a2ee](https://www.github.com/libp2p/js-libp2p/commit/0b4a2ee7983b4dc9dc0a7b705a202a4c550e7017)) + + +### Code Refactoring + +* extract circuit relay v2 to separate module ([#2222](https://www.github.com/libp2p/js-libp2p/issues/2222)) ([24afba3](https://www.github.com/libp2p/js-libp2p/commit/24afba30004fb7f24af1f0180229bb164340f00b)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.9 to ^0.1.10 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/circuit-relay-v2 bumped from ^0.0.0 to ^1.0.0 + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + * @libp2p/websockets bumped from ^7.0.13 to ^8.0.0 + * libp2p bumped from ^0.46.21 to ^1.0.0 + ### [3.2.11](https://www.github.com/libp2p/js-libp2p/compare/webrtc-v3.2.10...webrtc-v3.2.11) (2023-11-10) @@ -604,4 +644,4 @@ ### Documentation -* fix 'browser to server' build config ([#66](https://github.com/libp2p/js-libp2p-webrtc/issues/66)) ([b54132c](https://github.com/libp2p/js-libp2p-webrtc/commit/b54132cecac180f0577a1b7905f79b20207c3647)) +* fix 'browser to server' build config ([#66](https://github.com/libp2p/js-libp2p-webrtc/issues/66)) ([b54132c](https://github.com/libp2p/js-libp2p-webrtc/commit/b54132cecac180f0577a1b7905f79b20207c3647)) \ No newline at end of file diff --git a/packages/transport-webrtc/package.json b/packages/transport-webrtc/package.json index 95c4c620a7..4653567a04 100644 --- a/packages/transport-webrtc/package.json +++ b/packages/transport-webrtc/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/webrtc", - "version": "3.2.11", + "version": "4.0.0", "description": "A libp2p transport using WebRTC connections", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc#readme", @@ -50,11 +50,11 @@ }, "dependencies": { "@chainsafe/libp2p-noise": "^13.0.0", - "@libp2p/interface": "^0.1.6", - "@libp2p/interface-internal": "^0.1.9", - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id": "^3.0.6", - "@libp2p/utils": "^4.0.7", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id": "^4.0.0", + "@libp2p/utils": "^5.0.0", "@multiformats/mafmt": "^12.1.6", "@multiformats/multiaddr": "^12.1.10", "@multiformats/multiaddr-matcher": "^1.1.0", @@ -79,10 +79,10 @@ }, "devDependencies": { "@chainsafe/libp2p-yamux": "^5.0.0", - "@libp2p/circuit-relay-v2": "^0.0.0", - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/peer-id-factory": "^3.0.8", - "@libp2p/websockets": "^7.0.13", + "@libp2p/circuit-relay-v2": "^1.0.0", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/peer-id-factory": "^3.0.9", + "@libp2p/websockets": "^8.0.0", "@types/sinon": "^17.0.0", "aegir": "^41.0.2", "delay": "^6.0.0", @@ -90,7 +90,7 @@ "it-length": "^3.0.2", "it-map": "^3.0.3", "it-pair": "^2.0.6", - "libp2p": "^0.46.21", + "libp2p": "^1.0.0", "p-retry": "^6.1.0", "protons": "^7.3.0", "sinon": "^17.0.0", diff --git a/packages/transport-webrtc/src/error.ts b/packages/transport-webrtc/src/error.ts index 4c6d3b42df..c501f0ee0b 100644 --- a/packages/transport-webrtc/src/error.ts +++ b/packages/transport-webrtc/src/error.ts @@ -1,5 +1,5 @@ -import { CodeError } from '@libp2p/interface/errors' -import type { Direction } from '@libp2p/interface/connection' +import { CodeError } from '@libp2p/interface' +import type { Direction } from '@libp2p/interface' export enum codes { ERR_ALREADY_ABORTED = 'ERR_ALREADY_ABORTED', diff --git a/packages/transport-webrtc/src/index.ts b/packages/transport-webrtc/src/index.ts index 4a028fff2b..50f39b8de5 100644 --- a/packages/transport-webrtc/src/index.ts +++ b/packages/transport-webrtc/src/index.ts @@ -30,9 +30,9 @@ */ import { WebRTCTransport } from './private-to-private/transport.js' -import { WebRTCDirectTransport, type WebRTCTransportDirectInit, type WebRTCDirectTransportComponents } from './private-to-public/transport.js' -import type { WebRTCTransportComponents, WebRTCTransportInit } from './private-to-private/transport.js' -import type { Transport } from '@libp2p/interface/transport' +import { WebRTCDirectTransport } from './private-to-public/transport.js' +import type { ComponentLogger, Metrics, PeerId, Transport, Upgrader } from '@libp2p/interface' +import type { ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal' export interface DataChannelOptions { /** @@ -74,6 +74,16 @@ export interface DataChannelOptions { openTimeout?: number } +export interface WebRTCDirectTransportComponents { + peerId: PeerId + metrics?: Metrics + logger: ComponentLogger +} + +export interface WebRTCTransportDirectInit { + dataChannel?: DataChannelOptions +} + /** * @param {WebRTCTransportDirectInit} init - WebRTC direct transport configuration * @param init.dataChannel - DataChannel configurations @@ -86,6 +96,27 @@ function webRTCDirect (init?: WebRTCTransportDirectInit): (components: WebRTCDir return (components: WebRTCDirectTransportComponents) => new WebRTCDirectTransport(components, init) } +export interface WebRTCTransportInit { + rtcConfiguration?: RTCConfiguration + dataChannel?: DataChannelOptions + + /** + * Inbound connections must complete the upgrade within this many ms + * (default: 30s) + */ + inboundConnectionTimeout?: number +} + +export interface WebRTCTransportComponents { + peerId: PeerId + registrar: Registrar + upgrader: Upgrader + transportManager: TransportManager + connectionManager: ConnectionManager + metrics?: Metrics + logger: ComponentLogger +} + /** * @param {WebRTCTransportInit} init - WebRTC transport configuration * @param {RTCConfiguration} init.rtcConfiguration - RTCConfiguration diff --git a/packages/transport-webrtc/src/maconn.ts b/packages/transport-webrtc/src/maconn.ts index 0921284a4f..0e2c20c011 100644 --- a/packages/transport-webrtc/src/maconn.ts +++ b/packages/transport-webrtc/src/maconn.ts @@ -1,7 +1,5 @@ import { nopSink, nopSource } from './util.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { MultiaddrConnection, MultiaddrConnectionTimeline } from '@libp2p/interface/connection' -import type { CounterGroup } from '@libp2p/interface/metrics' +import type { ComponentLogger, Logger, MultiaddrConnection, MultiaddrConnectionTimeline, CounterGroup } from '@libp2p/interface' import type { AbortOptions, Multiaddr } from '@multiformats/multiaddr' import type { Source, Sink } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/transport-webrtc/src/muxer.ts b/packages/transport-webrtc/src/muxer.ts index 09668c8178..63dccd16ff 100644 --- a/packages/transport-webrtc/src/muxer.ts +++ b/packages/transport-webrtc/src/muxer.ts @@ -1,10 +1,7 @@ import { createStream } from './stream.js' import { drainAndClose, nopSink, nopSource } from './util.js' import type { DataChannelOptions } from './index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Stream } from '@libp2p/interface/connection' -import type { CounterGroup } from '@libp2p/interface/metrics' -import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface/stream-muxer' +import type { ComponentLogger, Logger, Stream, CounterGroup, StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface' import type { AbortOptions } from '@multiformats/multiaddr' import type { Source, Sink } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/transport-webrtc/src/private-to-private/initiate-connection.ts b/packages/transport-webrtc/src/private-to-private/initiate-connection.ts index 04e532cea0..5dfa2bca52 100644 --- a/packages/transport-webrtc/src/private-to-private/initiate-connection.ts +++ b/packages/transport-webrtc/src/private-to-private/initiate-connection.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { peerIdFromString } from '@libp2p/peer-id' import { pbStream } from 'it-protobuf-stream' import pDefer, { type DeferredPromise } from 'p-defer' @@ -7,11 +7,8 @@ import { Message } from './pb/message.js' import { SIGNALING_PROTO_ID, splitAddr, type WebRTCTransportMetrics } from './transport.js' import { readCandidatesUntilConnected, resolveOnConnected } from './util.js' import type { DataChannelOptions } from '../index.js' -import type { LoggerOptions } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { IncomingStreamData } from '@libp2p/interface-internal/registrar' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { LoggerOptions, Connection } from '@libp2p/interface' +import type { ConnectionManager, IncomingStreamData, TransportManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export interface IncomingStreamOpts extends IncomingStreamData { diff --git a/packages/transport-webrtc/src/private-to-private/listener.ts b/packages/transport-webrtc/src/private-to-private/listener.ts index 6a73e9e14a..918f4e488b 100644 --- a/packages/transport-webrtc/src/private-to-private/listener.ts +++ b/packages/transport-webrtc/src/private-to-private/listener.ts @@ -1,8 +1,7 @@ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { Circuit } from '@multiformats/mafmt' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { ListenerEvents, Listener } from '@libp2p/interface/transport' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { PeerId, ListenerEvents, Listener } from '@libp2p/interface' +import type { TransportManager } from '@libp2p/interface-internal' import type { Multiaddr } from '@multiformats/multiaddr' export interface WebRTCPeerListenerComponents { diff --git a/packages/transport-webrtc/src/private-to-private/signaling-stream-handler.ts b/packages/transport-webrtc/src/private-to-private/signaling-stream-handler.ts index b6374656f9..5ba751521f 100644 --- a/packages/transport-webrtc/src/private-to-private/signaling-stream-handler.ts +++ b/packages/transport-webrtc/src/private-to-private/signaling-stream-handler.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { multiaddr, type Multiaddr } from '@multiformats/multiaddr' import { pbStream } from 'it-protobuf-stream' import pDefer, { type DeferredPromise } from 'p-defer' @@ -6,7 +6,7 @@ import { type RTCPeerConnection, RTCSessionDescription } from '../webrtc/index.j import { Message } from './pb/message.js' import { readCandidatesUntilConnected, resolveOnConnected } from './util.js' import type { Logger } from '@libp2p/interface' -import type { IncomingStreamData } from '@libp2p/interface-internal/registrar' +import type { IncomingStreamData } from '@libp2p/interface-internal' export interface IncomingStreamOpts extends IncomingStreamData { peerConnection: RTCPeerConnection diff --git a/packages/transport-webrtc/src/private-to-private/transport.ts b/packages/transport-webrtc/src/private-to-private/transport.ts index 1d137ef268..f413ac857b 100644 --- a/packages/transport-webrtc/src/private-to-private/transport.ts +++ b/packages/transport-webrtc/src/private-to-private/transport.ts @@ -1,5 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' -import { type CreateListenerOptions, type DialOptions, symbol, type Transport, type Listener, type Upgrader } from '@libp2p/interface/transport' +import { CodeError, transportSymbol } from '@libp2p/interface' import { peerIdFromString } from '@libp2p/peer-id' import { multiaddr, type Multiaddr } from '@multiformats/multiaddr' import { WebRTC } from '@multiformats/multiaddr-matcher' @@ -10,42 +9,15 @@ import { cleanup, RTCPeerConnection } from '../webrtc/index.js' import { initiateConnection } from './initiate-connection.js' import { WebRTCPeerListener } from './listener.js' import { handleIncomingStream } from './signaling-stream-handler.js' -import type { DataChannelOptions } from '../index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { CounterGroup, Metrics } from '@libp2p/interface/src/metrics/index.js' -import type { Startable } from '@libp2p/interface/startable' -import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar' -import type { ConnectionManager } from '@libp2p/interface-internal/src/connection-manager/index.js' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { WebRTCTransportComponents, WebRTCTransportInit } from '../index.js' +import type { Logger, Connection, CounterGroup, PeerId, Startable, CreateListenerOptions, DialOptions, Transport, Listener } from '@libp2p/interface' +import type { IncomingStreamData } from '@libp2p/interface-internal' const WEBRTC_TRANSPORT = '/webrtc' const CIRCUIT_RELAY_TRANSPORT = '/p2p-circuit' export const SIGNALING_PROTO_ID = '/webrtc-signaling/0.0.1' const INBOUND_CONNECTION_TIMEOUT = 30 * 1000 -export interface WebRTCTransportInit { - rtcConfiguration?: RTCConfiguration - dataChannel?: DataChannelOptions - - /** - * Inbound connections must complete the upgrade within this many ms - * (default: 30s) - */ - inboundConnectionTimeout?: number -} - -export interface WebRTCTransportComponents { - peerId: PeerId - registrar: Registrar - upgrader: Upgrader - transportManager: TransportManager - connectionManager: ConnectionManager - metrics?: Metrics - logger: ComponentLogger -} - export interface WebRTCTransportMetrics { dialerEvents: CounterGroup listenerEvents: CounterGroup @@ -105,7 +77,7 @@ export class WebRTCTransport implements Transport, Startable { readonly [Symbol.toStringTag] = '@libp2p/webrtc' - readonly [symbol] = true + readonly [transportSymbol] = true filter (multiaddrs: Multiaddr[]): Multiaddr[] { return multiaddrs.filter(WebRTC.exactMatch) diff --git a/packages/transport-webrtc/src/private-to-private/util.ts b/packages/transport-webrtc/src/private-to-private/util.ts index 62cc40a875..ff7bd5eb17 100644 --- a/packages/transport-webrtc/src/private-to-private/util.ts +++ b/packages/transport-webrtc/src/private-to-private/util.ts @@ -1,11 +1,10 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { closeSource } from '@libp2p/utils/close-source' import { anySignal } from 'any-signal' import { isFirefox } from '../util.js' import { RTCIceCandidate } from '../webrtc/index.js' import { Message } from './pb/message.js' -import type { LoggerOptions } from '@libp2p/interface' -import type { Stream } from '@libp2p/interface/connection' +import type { LoggerOptions, Stream } from '@libp2p/interface' import type { AbortOptions, MessageStream } from 'it-protobuf-stream' import type { DeferredPromise } from 'p-defer' diff --git a/packages/transport-webrtc/src/private-to-public/options.ts b/packages/transport-webrtc/src/private-to-public/options.ts index d30bc9f304..c9b3b1361d 100644 --- a/packages/transport-webrtc/src/private-to-public/options.ts +++ b/packages/transport-webrtc/src/private-to-public/options.ts @@ -1,4 +1,4 @@ -import type { CreateListenerOptions, DialOptions } from '@libp2p/interface/transport' +import type { CreateListenerOptions, DialOptions } from '@libp2p/interface' export interface WebRTCListenerOptions extends CreateListenerOptions {} export interface WebRTCDialOptions extends DialOptions {} diff --git a/packages/transport-webrtc/src/private-to-public/transport.ts b/packages/transport-webrtc/src/private-to-public/transport.ts index cc3e4f6dd5..f82edd6938 100644 --- a/packages/transport-webrtc/src/private-to-public/transport.ts +++ b/packages/transport-webrtc/src/private-to-public/transport.ts @@ -1,6 +1,6 @@ -import { noise as Noise } from '@chainsafe/libp2p-noise' -import { type CreateListenerOptions, symbol, type Transport, type Listener } from '@libp2p/interface/transport' -import * as p from '@libp2p/peer-id' +import { noise } from '@chainsafe/libp2p-noise' +import { transportSymbol } from '@libp2p/interface' +import { peerIdFromString } from '@libp2p/peer-id' import { protocols } from '@multiformats/multiaddr' import { WebRTCDirect } from '@multiformats/multiaddr-matcher' import * as multihashes from 'multihashes' @@ -15,11 +15,8 @@ import { RTCPeerConnection } from '../webrtc/index.js' import * as sdp from './sdp.js' import { genUfrag } from './util.js' import type { WebRTCDialOptions } from './options.js' -import type { DataChannelOptions } from '../index.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { CounterGroup, Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { WebRTCDirectTransportComponents, WebRTCTransportDirectInit } from '../index.js' +import type { Logger, Connection, CounterGroup, CreateListenerOptions, Transport, Listener } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' /** @@ -41,23 +38,10 @@ export const WEBRTC_CODE: number = protocols('webrtc-direct').code */ export const CERTHASH_CODE: number = protocols('certhash').code -/** - * The peer for this transport - */ -export interface WebRTCDirectTransportComponents { - peerId: PeerId - metrics?: Metrics - logger: ComponentLogger -} - export interface WebRTCMetrics { dialerEvents: CounterGroup } -export interface WebRTCTransportDirectInit { - dataChannel?: DataChannelOptions -} - export class WebRTCDirectTransport implements Transport { private readonly log: Logger private readonly metrics?: WebRTCMetrics @@ -108,7 +92,7 @@ export class WebRTCDirectTransport implements Transport { /** * Symbol.for('@libp2p/transport') */ - readonly [symbol] = true + readonly [transportSymbol] = true /** * Connect to a peer using a multiaddr @@ -121,7 +105,7 @@ export class WebRTCDirectTransport implements Transport { if (remotePeerString === null) { throw inappropriateMultiaddr("we need to have the remote's PeerId") } - const theirPeerId = p.peerIdFromString(remotePeerString) + const theirPeerId = peerIdFromString(remotePeerString) const remoteCerthash = sdp.decodeCerthash(sdp.certhash(ma)) @@ -193,7 +177,7 @@ export class WebRTCDirectTransport implements Transport { // Since we use the default crypto interface and do not use a static key or early data, // we pass in undefined for these parameters. - const noise = Noise({ prologueBytes: fingerprintsPrologue })() + const encrypter = noise({ prologueBytes: fingerprintsPrologue })() const wrappedChannel = createStream({ channel: handshakeDataChannel, @@ -254,7 +238,7 @@ export class WebRTCDirectTransport implements Transport { // For outbound connections, the remote is expected to start the noise handshake. // Therefore, we need to secure an inbound noise connection from the remote. - await noise.secureInbound(myPeerId, wrappedDuplex, theirPeerId) + await encrypter.secureInbound(myPeerId, wrappedDuplex, theirPeerId) return await options.upgrader.upgradeOutbound(maConn, { skipProtection: true, skipEncryption: true, muxerFactory }) } catch (err) { diff --git a/packages/transport-webrtc/src/stream.ts b/packages/transport-webrtc/src/stream.ts index 8417f9109e..d875b2be40 100644 --- a/packages/transport-webrtc/src/stream.ts +++ b/packages/transport-webrtc/src/stream.ts @@ -1,4 +1,4 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { AbstractStream, type AbstractStreamInit } from '@libp2p/utils/abstract-stream' import * as lengthPrefixed from 'it-length-prefixed' import { type Pushable, pushable } from 'it-pushable' @@ -9,8 +9,7 @@ import { raceSignal } from 'race-signal' import { Uint8ArrayList } from 'uint8arraylist' import { Message } from './pb/message.js' import type { DataChannelOptions } from './index.js' -import type { AbortOptions, ComponentLogger } from '@libp2p/interface' -import type { Direction } from '@libp2p/interface/connection' +import type { AbortOptions, ComponentLogger, Direction } from '@libp2p/interface' import type { DeferredPromise } from 'p-defer' export interface WebRTCStreamInit extends AbstractStreamInit, DataChannelOptions { diff --git a/packages/transport-webrtc/test/basics.spec.ts b/packages/transport-webrtc/test/basics.spec.ts index a74384a2a1..819f322723 100644 --- a/packages/transport-webrtc/test/basics.spec.ts +++ b/packages/transport-webrtc/test/basics.spec.ts @@ -17,9 +17,7 @@ import { createLibp2p } from 'libp2p' import pDefer from 'p-defer' import pRetry from 'p-retry' import { webRTC } from '../src/index.js' -import type { Libp2p } from '@libp2p/interface' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { StreamHandler } from '@libp2p/interface/stream-handler' +import type { Libp2p, Connection, Stream, StreamHandler } from '@libp2p/interface' async function createNode (): Promise { return createLibp2p({ @@ -37,9 +35,11 @@ async function createNode (): Promise { webRTC() ], connectionEncryption: [ + // @ts-expect-error TODO: noise needs to be upgraded noise() ], streamMuxers: [ + // @ts-expect-error TODO: yamux needs to be upgraded yamux() ], connectionGater: { diff --git a/packages/transport-webrtc/test/listener.spec.ts b/packages/transport-webrtc/test/listener.spec.ts index 7280feadc3..ec737f54f1 100644 --- a/packages/transport-webrtc/test/listener.spec.ts +++ b/packages/transport-webrtc/test/listener.spec.ts @@ -4,8 +4,8 @@ import { expect } from 'aegir/chai' import Sinon from 'sinon' import { stubInterface } from 'sinon-ts' import { WebRTCPeerListener } from '../src/private-to-private/listener.js' -import type { Listener } from '@libp2p/interface/transport' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { Listener } from '@libp2p/interface' +import type { TransportManager } from '@libp2p/interface-internal' describe('webrtc private-to-private listener', () => { it('should only return relay addresses as webrtc listen addresses', async () => { diff --git a/packages/transport-webrtc/test/maconn.spec.ts b/packages/transport-webrtc/test/maconn.spec.ts index 81d575065d..0328800521 100644 --- a/packages/transport-webrtc/test/maconn.spec.ts +++ b/packages/transport-webrtc/test/maconn.spec.ts @@ -6,7 +6,7 @@ import { expect } from 'aegir/chai' import { stubObject } from 'sinon-ts' import { WebRTCMultiaddrConnection } from '../src/maconn.js' import { RTCPeerConnection } from '../src/webrtc/index.js' -import type { CounterGroup } from '@libp2p/interface/metrics' +import type { CounterGroup } from '@libp2p/interface' describe('Multiaddr Connection', () => { it('can open and close', async () => { diff --git a/packages/transport-webrtc/test/peer.spec.ts b/packages/transport-webrtc/test/peer.spec.ts index 451e14bf50..3382863c66 100644 --- a/packages/transport-webrtc/test/peer.spec.ts +++ b/packages/transport-webrtc/test/peer.spec.ts @@ -14,10 +14,8 @@ import { Message } from '../src/private-to-private/pb/message.js' import { handleIncomingStream } from '../src/private-to-private/signaling-stream-handler.js' import { SIGNALING_PROTO_ID, WebRTCTransport, splitAddr } from '../src/private-to-private/transport.js' import { RTCPeerConnection, RTCSessionDescription } from '../src/webrtc/index.js' -import type { Logger } from '@libp2p/interface' -import type { Connection, Stream } from '@libp2p/interface/connection' -import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { Logger, Connection, Stream } from '@libp2p/interface' +import type { ConnectionManager, TransportManager } from '@libp2p/interface-internal' const browser = detect() diff --git a/packages/transport-webrtc/test/stream.spec.ts b/packages/transport-webrtc/test/stream.spec.ts index a7f09eb109..b9c8735ea9 100644 --- a/packages/transport-webrtc/test/stream.spec.ts +++ b/packages/transport-webrtc/test/stream.spec.ts @@ -13,7 +13,7 @@ import { Message } from '../src/pb/message.js' import { MAX_BUFFERED_AMOUNT, MAX_MESSAGE_SIZE, PROTOBUF_OVERHEAD, type WebRTCStream, createStream } from '../src/stream.js' import { RTCPeerConnection } from '../src/webrtc/index.js' import { mockDataChannel, receiveFinAck } from './util.js' -import type { Stream } from '@libp2p/interface/connection' +import type { Stream } from '@libp2p/interface' describe('Max message size', () => { it(`sends messages smaller or equal to ${MAX_MESSAGE_SIZE} bytes in one`, async () => { diff --git a/packages/transport-webrtc/test/transport.spec.ts b/packages/transport-webrtc/test/transport.spec.ts index c1adff7e9c..f6b20ed5b5 100644 --- a/packages/transport-webrtc/test/transport.spec.ts +++ b/packages/transport-webrtc/test/transport.spec.ts @@ -1,15 +1,15 @@ /* eslint-disable @typescript-eslint/no-floating-promises */ -import { type CreateListenerOptions, symbol } from '@libp2p/interface/transport' +import { type CreateListenerOptions, transportSymbol, type Metrics } from '@libp2p/interface' import { mockMetrics, mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' import { expect } from 'aegir/chai' import { UnimplementedError } from '../src/error.js' -import { WebRTCDirectTransport, type WebRTCDirectTransportComponents } from '../src/private-to-public/transport.js' +import { WebRTCDirectTransport } from '../src/private-to-public/transport.js' import { expectError } from './util.js' -import type { Metrics } from '@libp2p/interface/metrics' +import type { WebRTCDirectTransportComponents } from '../src/index.js' function ignoredDialOption (): CreateListenerOptions { const upgrader = mockUpgrader({}) @@ -61,7 +61,7 @@ describe('WebRTCDirect Transport', () => { it('symbol property getter', () => { const t = new WebRTCDirectTransport(components) - const s = t[symbol] + const s = t[transportSymbol] expect(s).to.equal(true) }) diff --git a/packages/transport-websockets/CHANGELOG.md b/packages/transport-websockets/CHANGELOG.md index 6721cd64bd..adc512bb6a 100644 --- a/packages/transport-websockets/CHANGELOG.md +++ b/packages/transport-websockets/CHANGELOG.md @@ -6,6 +6,33 @@ * **dev:** bump @libp2p/interface-mocks from 11.0.3 to 12.0.1 ([#241](https://github.com/libp2p/js-libp2p-websockets/issues/241)) ([f956836](https://github.com/libp2p/js-libp2p-websockets/commit/f95683641bda2f9b250768768451e0c121afc2a0)) * **dev:** bump aegir from 38.1.8 to 39.0.9 ([#245](https://github.com/libp2p/js-libp2p-websockets/issues/245)) ([4a35f6b](https://github.com/libp2p/js-libp2p-websockets/commit/4a35f6b39a918fb7ef779292553cb452a543afb0)) +## [8.0.0](https://www.github.com/libp2p/js-libp2p/compare/websockets-v7.0.13...websockets-v8.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/interface-compliance-tests bumped from ^4.1.5 to ^5.0.0 + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + ### [7.0.13](https://www.github.com/libp2p/js-libp2p/compare/websockets-v7.0.12...websockets-v7.0.13) (2023-11-07) diff --git a/packages/transport-websockets/package.json b/packages/transport-websockets/package.json index dee47d3902..ca3a2b6e5f 100644 --- a/packages/transport-websockets/package.json +++ b/packages/transport-websockets/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/websockets", - "version": "7.0.13", + "version": "8.0.0", "description": "JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport spec", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-websockets#readme", @@ -73,8 +73,8 @@ "test:electron-main": "aegir test -t electron-main -f ./dist/test/node.js --cov" }, "dependencies": { - "@libp2p/interface": "^0.1.6", - "@libp2p/utils": "^4.0.7", + "@libp2p/interface": "^1.0.0", + "@libp2p/utils": "^5.0.0", "@multiformats/mafmt": "^12.1.6", "@multiformats/multiaddr": "^12.1.10", "@multiformats/multiaddr-to-uri": "^9.0.2", @@ -85,8 +85,8 @@ "ws": "^8.12.1" }, "devDependencies": { - "@libp2p/interface-compliance-tests": "^4.1.5", - "@libp2p/logger": "^3.1.0", + "@libp2p/interface-compliance-tests": "^5.0.0", + "@libp2p/logger": "^4.0.0", "aegir": "^41.0.2", "is-loopback-addr": "^2.0.1", "it-all": "^3.0.3", diff --git a/packages/transport-websockets/src/index.ts b/packages/transport-websockets/src/index.ts index bb3ddb90ad..3bb57aceef 100644 --- a/packages/transport-websockets/src/index.ts +++ b/packages/transport-websockets/src/index.ts @@ -36,7 +36,7 @@ * - `filters.dnsWsOrWss` * - Returns all DNS based addresses, both with `ws` or `wss`. * - * @example + * @example How to allow connecting to insecure addresses * * ```js * import { createLibp2pNode } from 'libp2p' @@ -63,8 +63,7 @@ * ``` */ -import { AbortError, CodeError } from '@libp2p/interface/errors' -import { type Transport, type MultiaddrFilter, symbol, type CreateListenerOptions, type DialOptions, type Listener } from '@libp2p/interface/transport' +import { transportSymbol, AbortError, CodeError } from '@libp2p/interface' import { multiaddrToUri as toUri } from '@multiformats/multiaddr-to-uri' import { connect, type WebSocketOptions } from 'it-ws/client' import pDefer from 'p-defer' @@ -72,8 +71,7 @@ import { isBrowser, isWebWorker } from 'wherearewe' import * as filters from './filters.js' import { createListener } from './listener.js' import { socketToMaConn } from './socket-to-conn.js' -import type { AbortOptions, ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' +import type { AbortOptions, ComponentLogger, Logger, Connection, Transport, MultiaddrFilter, CreateListenerOptions, DialOptions, Listener } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' import type { Server } from 'http' import type { DuplexWebSocket } from 'it-ws/duplex' @@ -102,7 +100,7 @@ class WebSockets implements Transport { readonly [Symbol.toStringTag] = '@libp2p/websockets' - readonly [symbol] = true + readonly [transportSymbol] = true async dial (ma: Multiaddr, options: DialOptions): Promise { this.log('dialing %s', ma) diff --git a/packages/transport-websockets/src/listener.browser.ts b/packages/transport-websockets/src/listener.browser.ts index 9fb4354f23..64526d2d14 100644 --- a/packages/transport-websockets/src/listener.browser.ts +++ b/packages/transport-websockets/src/listener.browser.ts @@ -1,4 +1,4 @@ -import type { Listener } from '@libp2p/interface/transport' +import type { Listener } from '@libp2p/interface' export function createListener (): Listener { throw new Error('WebSocket Servers can not be created in the browser!') diff --git a/packages/transport-websockets/src/listener.ts b/packages/transport-websockets/src/listener.ts index d709bcd7c6..20c2d7b50f 100644 --- a/packages/transport-websockets/src/listener.ts +++ b/packages/transport-websockets/src/listener.ts @@ -1,12 +1,10 @@ import os from 'os' -import { TypedEventEmitter, CustomEvent } from '@libp2p/interface/events' +import { TypedEventEmitter, CustomEvent } from '@libp2p/interface' import { ipPortToMultiaddr as toMultiaddr } from '@libp2p/utils/ip-port-to-multiaddr' import { multiaddr, protocols } from '@multiformats/multiaddr' import { createServer } from 'it-ws/server' import { socketToMaConn } from './socket-to-conn.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection } from '@libp2p/interface/connection' -import type { Listener, ListenerEvents, CreateListenerOptions } from '@libp2p/interface/transport' +import type { ComponentLogger, Logger, Connection, Listener, ListenerEvents, CreateListenerOptions } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' import type { Server } from 'http' import type { DuplexWebSocket } from 'it-ws/duplex' diff --git a/packages/transport-websockets/src/socket-to-conn.ts b/packages/transport-websockets/src/socket-to-conn.ts index 66ce2e149b..1cb3278ca7 100644 --- a/packages/transport-websockets/src/socket-to-conn.ts +++ b/packages/transport-websockets/src/socket-to-conn.ts @@ -1,7 +1,6 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { CLOSE_TIMEOUT } from './constants.js' -import type { AbortOptions, ComponentLogger } from '@libp2p/interface' -import type { MultiaddrConnection } from '@libp2p/interface/connection' +import type { AbortOptions, ComponentLogger, MultiaddrConnection } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' import type { DuplexWebSocket } from 'it-ws/duplex' diff --git a/packages/transport-websockets/test/browser.ts b/packages/transport-websockets/test/browser.ts index 0ca81ac46a..53caeb4683 100644 --- a/packages/transport-websockets/test/browser.ts +++ b/packages/transport-websockets/test/browser.ts @@ -1,6 +1,6 @@ /* eslint-env mocha */ -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' @@ -10,8 +10,7 @@ import { pipe } from 'it-pipe' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { isBrowser, isWebWorker } from 'wherearewe' import { webSockets } from '../src/index.js' -import type { Connection } from '@libp2p/interface/connection' -import type { Transport } from '@libp2p/interface/transport' +import type { Connection, Transport } from '@libp2p/interface' const protocol = '/echo/1.0.0' diff --git a/packages/transport-websockets/test/compliance.node.ts b/packages/transport-websockets/test/compliance.node.ts index faeebf4c4f..20c6748bfa 100644 --- a/packages/transport-websockets/test/compliance.node.ts +++ b/packages/transport-websockets/test/compliance.node.ts @@ -7,7 +7,7 @@ import { multiaddr } from '@multiformats/multiaddr' import * as filters from '../src/filters.js' import { webSockets } from '../src/index.js' import type { WebSocketListenerInit } from '../src/listener.js' -import type { Listener } from '@libp2p/interface/transport' +import type { Listener } from '@libp2p/interface' describe('interface-transport compliance', () => { tests({ diff --git a/packages/transport-websockets/test/node.ts b/packages/transport-websockets/test/node.ts index f6b8888bae..61aee9ec76 100644 --- a/packages/transport-websockets/test/node.ts +++ b/packages/transport-websockets/test/node.ts @@ -4,7 +4,7 @@ import fs from 'fs' import http from 'http' import https from 'https' -import { TypedEventEmitter } from '@libp2p/interface/events' +import { TypedEventEmitter } from '@libp2p/interface' import { mockRegistrar, mockUpgrader } from '@libp2p/interface-compliance-tests/mocks' import { defaultLogger } from '@libp2p/logger' import { multiaddr } from '@multiformats/multiaddr' @@ -19,7 +19,7 @@ import waitFor from 'p-wait-for' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import * as filters from '../src/filters.js' import { webSockets } from '../src/index.js' -import type { Listener, Transport } from '@libp2p/interface/transport' +import type { Listener, Transport } from '@libp2p/interface' import type { Source } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' import './compliance.node.js' diff --git a/packages/transport-webtransport/CHANGELOG.md b/packages/transport-webtransport/CHANGELOG.md index 6147279d50..196c74190c 100644 --- a/packages/transport-webtransport/CHANGELOG.md +++ b/packages/transport-webtransport/CHANGELOG.md @@ -11,6 +11,34 @@ * bump @chainsafe/libp2p-noise from 11.0.4 to 12.0.1 ([#80](https://github.com/libp2p/js-libp2p-webtransport/issues/80)) ([599dab1](https://github.com/libp2p/js-libp2p-webtransport/commit/599dab1b4f6ae816b0c0feefc926c1b38d24b676)) +## [4.0.0](https://www.github.com/libp2p/js-libp2p/compare/webtransport-v3.1.10...webtransport-v4.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/peer-id bumped from ^3.0.6 to ^4.0.0 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + * libp2p bumped from ^0.46.21 to ^1.0.0 + ### [3.1.10](https://www.github.com/libp2p/js-libp2p/compare/webtransport-v3.1.9...webtransport-v3.1.10) (2023-11-10) @@ -424,4 +452,4 @@ * bump protons-runtime from 3.1.0 to 4.0.1 ([a7ef395](https://github.com/libp2p/js-libp2p-webtransport/commit/a7ef3959d024813caa327afdd502d5bcb91a15e3)) * **dev:** bump @libp2p/interface-mocks from 4.0.3 to 7.0.1 ([85a492d](https://github.com/libp2p/js-libp2p-webtransport/commit/85a492da5b8df76d710dd21dd4b8bf59df4e1184)) -* **dev:** bump uint8arrays from 3.1.1 to 4.0.2 ([cb554e8](https://github.com/libp2p/js-libp2p-webtransport/commit/cb554e8dbb19a6ec5b085307f4c04c04ae313d2d)) +* **dev:** bump uint8arrays from 3.1.1 to 4.0.2 ([cb554e8](https://github.com/libp2p/js-libp2p-webtransport/commit/cb554e8dbb19a6ec5b085307f4c04c04ae313d2d)) \ No newline at end of file diff --git a/packages/transport-webtransport/package.json b/packages/transport-webtransport/package.json index 2eb0d7eae5..dc3544adae 100644 --- a/packages/transport-webtransport/package.json +++ b/packages/transport-webtransport/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/webtransport", - "version": "3.1.10", + "version": "4.0.0", "description": "JavaScript implementation of the WebTransport module that libp2p uses and that implements the interface-transport spec", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-webtransport#readme", @@ -50,8 +50,8 @@ }, "dependencies": { "@chainsafe/libp2p-noise": "^13.0.0", - "@libp2p/interface": "^0.1.6", - "@libp2p/peer-id": "^3.0.6", + "@libp2p/interface": "^1.0.0", + "@libp2p/peer-id": "^4.0.0", "@multiformats/multiaddr": "^12.1.10", "@multiformats/multiaddr-matcher": "^1.1.0", "it-stream-types": "^2.0.1", @@ -60,10 +60,10 @@ "uint8arrays": "^4.0.6" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", - "libp2p": "^0.46.21", + "libp2p": "^1.0.0", "p-defer": "^4.0.0" }, "browser": { diff --git a/packages/transport-webtransport/src/index.ts b/packages/transport-webtransport/src/index.ts index 23cf268038..e7791a1cd2 100644 --- a/packages/transport-webtransport/src/index.ts +++ b/packages/transport-webtransport/src/index.ts @@ -22,18 +22,14 @@ */ import { noise } from '@chainsafe/libp2p-noise' -import { type Transport, symbol, type CreateListenerOptions, type DialOptions, type Listener } from '@libp2p/interface/transport' -import { type Multiaddr, type AbortOptions } from '@multiformats/multiaddr' +import { transportSymbol } from '@libp2p/interface' import { WebTransport as WebTransportMatcher } from '@multiformats/multiaddr-matcher' import { webtransportBiDiStreamToStream } from './stream.js' import { inertDuplex } from './utils/inert-duplex.js' import { isSubset } from './utils/is-subset.js' import { parseMultiaddr } from './utils/parse-multiaddr.js' -import type { ComponentLogger, Logger } from '@libp2p/interface' -import type { Connection, MultiaddrConnection, Stream } from '@libp2p/interface/connection' -import type { CounterGroup, Metrics } from '@libp2p/interface/metrics' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { StreamMuxerFactory, StreamMuxerInit, StreamMuxer } from '@libp2p/interface/stream-muxer' +import type { ComponentLogger, Logger, Connection, MultiaddrConnection, Stream, CounterGroup, Metrics, PeerId, StreamMuxerFactory, StreamMuxerInit, StreamMuxer, Transport, CreateListenerOptions, DialOptions, Listener } from '@libp2p/interface' +import type { Multiaddr, AbortOptions } from '@multiformats/multiaddr' import type { Source } from 'it-stream-types' import type { MultihashDigest } from 'multiformats/hashes/interface' import type { Uint8ArrayList } from 'uint8arraylist' @@ -81,7 +77,7 @@ class WebTransportTransport implements Transport { readonly [Symbol.toStringTag] = '@libp2p/webtransport' - readonly [symbol] = true + readonly [transportSymbol] = true async dial (ma: Multiaddr, options: DialOptions): Promise { options?.signal?.throwIfAborted() diff --git a/packages/transport-webtransport/src/stream.ts b/packages/transport-webtransport/src/stream.ts index 5cffec9383..43672408c9 100644 --- a/packages/transport-webtransport/src/stream.ts +++ b/packages/transport-webtransport/src/stream.ts @@ -1,6 +1,5 @@ import { Uint8ArrayList } from 'uint8arraylist' -import type { AbortOptions, ComponentLogger } from '@libp2p/interface' -import type { Direction, Stream } from '@libp2p/interface/connection' +import type { AbortOptions, ComponentLogger, Direction, Stream } from '@libp2p/interface' import type { Source } from 'it-stream-types' export async function webtransportBiDiStreamToStream (bidiStream: WebTransportBidirectionalStream, streamId: string, direction: Direction, activeStreams: Stream[], onStreamEnd: undefined | ((s: Stream) => void), logger: ComponentLogger): Promise { diff --git a/packages/transport-webtransport/src/utils/parse-multiaddr.ts b/packages/transport-webtransport/src/utils/parse-multiaddr.ts index 1592119aad..6788828ead 100644 --- a/packages/transport-webtransport/src/utils/parse-multiaddr.ts +++ b/packages/transport-webtransport/src/utils/parse-multiaddr.ts @@ -1,9 +1,9 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { peerIdFromString } from '@libp2p/peer-id' import { type Multiaddr, protocols } from '@multiformats/multiaddr' import { WebTransport } from '@multiformats/multiaddr-matcher' import { bases, digest } from 'multiformats/basics' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { MultihashDigest } from 'multiformats/hashes/interface' // @ts-expect-error - Not easy to combine these types. diff --git a/packages/transport-webtransport/test/browser.ts b/packages/transport-webtransport/test/browser.ts index c4a54f6ad5..8a5148c551 100644 --- a/packages/transport-webtransport/test/browser.ts +++ b/packages/transport-webtransport/test/browser.ts @@ -13,6 +13,7 @@ describe('libp2p-webtransport', () => { beforeEach(async () => { node = await createLibp2p({ transports: [webTransport()], + // @ts-expect-error TODO: noise needs to be upgraded connectionEncryption: [noise()], connectionGater: { denyDialMultiaddr: async () => false diff --git a/packages/upnp-nat/CHANGELOG.md b/packages/upnp-nat/CHANGELOG.md new file mode 100644 index 0000000000..df12e73ac3 --- /dev/null +++ b/packages/upnp-nat/CHANGELOG.md @@ -0,0 +1,32 @@ +# Changelog + +## 1.0.0 (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* imports from `libp2p/identify` need to change to `@libp2p/identify` +* imports from `libp2p/upnp-nat` should be updated to `@libp2p/upnp-nat` + +### Bug Fixes + +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) + + +### Code Refactoring + +* extract identify service into separate module ([#2219](https://www.github.com/libp2p/js-libp2p/issues/2219)) ([72c2f77](https://www.github.com/libp2p/js-libp2p/commit/72c2f775bd85bd4928048dda0fd14740d6fb6a69)) +* extract UPnP NAT into separate module ([#2217](https://www.github.com/libp2p/js-libp2p/issues/2217)) ([f29b73f](https://www.github.com/libp2p/js-libp2p/commit/f29b73f781afcea36cba0589aafdd81e1852e194)) + + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * @libp2p/interface-internal bumped from ^0.1.9 to ^0.1.10 + * @libp2p/utils bumped from ^4.0.7 to ^5.0.0 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 \ No newline at end of file diff --git a/packages/upnp-nat/package.json b/packages/upnp-nat/package.json index 0134605f5b..992b975121 100644 --- a/packages/upnp-nat/package.json +++ b/packages/upnp-nat/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/upnp-nat", - "version": "0.0.0", + "version": "1.0.0", "description": "UPnP NAT hole punching", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/upnp-nat#readme", @@ -50,16 +50,16 @@ }, "dependencies": { "@achingbrain/nat-port-mapper": "^1.0.12", - "@libp2p/interface": "^0.1.6", - "@libp2p/interface-internal": "^0.1.9", - "@libp2p/utils": "^4.0.7", + "@libp2p/interface": "^1.0.0", + "@libp2p/interface-internal": "^0.1.10", + "@libp2p/utils": "^5.0.0", "@multiformats/multiaddr": "^12.1.10", "private-ip": "^3.0.1", "wherearewe": "^2.0.1" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "sinon-ts": "^2.0.0" } diff --git a/packages/upnp-nat/src/index.ts b/packages/upnp-nat/src/index.ts index 14698c1ce9..b0df23b3a0 100644 --- a/packages/upnp-nat/src/index.ts +++ b/packages/upnp-nat/src/index.ts @@ -36,10 +36,8 @@ */ import { UPnPNAT } from './upnp-nat.js' -import type { ComponentLogger, NodeInfo } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ComponentLogger, NodeInfo, PeerId } from '@libp2p/interface' +import type { AddressManager, TransportManager } from '@libp2p/interface-internal' export interface PMPOptions { /** diff --git a/packages/upnp-nat/src/upnp-nat.ts b/packages/upnp-nat/src/upnp-nat.ts index c68d695315..9c40fbb531 100644 --- a/packages/upnp-nat/src/upnp-nat.ts +++ b/packages/upnp-nat/src/upnp-nat.ts @@ -1,12 +1,11 @@ import { upnpNat, type NatAPI } from '@achingbrain/nat-port-mapper' -import { CodeError, ERR_INVALID_PARAMETERS } from '@libp2p/interface/errors' +import { CodeError, ERR_INVALID_PARAMETERS } from '@libp2p/interface' import { isLoopback } from '@libp2p/utils/multiaddr/is-loopback' import { fromNodeAddress } from '@multiformats/multiaddr' import isPrivateIp from 'private-ip' import { isBrowser } from 'wherearewe' import type { UPnPNATComponents, UPnPNATInit } from './index.js' -import type { Logger } from '@libp2p/interface' -import type { Startable } from '@libp2p/interface/startable' +import type { Logger, Startable } from '@libp2p/interface' const DEFAULT_TTL = 7200 diff --git a/packages/upnp-nat/test/index.spec.ts b/packages/upnp-nat/test/index.spec.ts index df5a86549c..53382be4fb 100644 --- a/packages/upnp-nat/test/index.spec.ts +++ b/packages/upnp-nat/test/index.spec.ts @@ -1,7 +1,6 @@ /* eslint-env mocha */ -import { ERR_INVALID_PARAMETERS } from '@libp2p/interface/errors' -import { stop } from '@libp2p/interface/startable' +import { ERR_INVALID_PARAMETERS, stop } from '@libp2p/interface' import { defaultLogger } from '@libp2p/logger' import { createEd25519PeerId } from '@libp2p/peer-id-factory' import { multiaddr } from '@multiformats/multiaddr' @@ -9,10 +8,8 @@ import { expect } from 'aegir/chai' import { type StubbedInstance, stubInterface } from 'sinon-ts' import { UPnPNAT } from '../src/upnp-nat.js' import type { NatAPI } from '@achingbrain/nat-port-mapper' -import type { ComponentLogger, NodeInfo } from '@libp2p/interface' -import type { PeerId } from '@libp2p/interface/peer-id' -import type { AddressManager } from '@libp2p/interface-internal/address-manager' -import type { TransportManager } from '@libp2p/interface-internal/transport-manager' +import type { ComponentLogger, NodeInfo, PeerId } from '@libp2p/interface' +import type { AddressManager, TransportManager } from '@libp2p/interface-internal' interface StubbedUPnPNATComponents { peerId: PeerId diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md index aa832e665c..c94be265db 100644 --- a/packages/utils/CHANGELOG.md +++ b/packages/utils/CHANGELOG.md @@ -11,6 +11,40 @@ * **dev:** bump aegir from 38.1.8 to 39.0.10 ([#100](https://github.com/libp2p/js-libp2p-utils/issues/100)) ([da6547c](https://github.com/libp2p/js-libp2p-utils/commit/da6547cdd073ba1a4225be5a419c6776c4ebe6f1)) +## [5.0.0](https://www.github.com/libp2p/js-libp2p/compare/utils-v4.0.7...utils-v5.0.0) (2023-11-28) + + +### ⚠ BREAKING CHANGES + +* the `minSendBytes` option has been removed from Mplex since the transport can now decide how to optimise sending data +* imports from `libp2p/circuit-relay` should be updated to `@libp2p/circuit-relay-v2` + +### Features + +* allow stream muxers and connection encrypters to yield lists ([#2256](https://www.github.com/libp2p/js-libp2p/issues/2256)) ([4a474d5](https://www.github.com/libp2p/js-libp2p/commit/4a474d54d3299e0ac30fa143b57436b3cf45e426)) + + +### Bug Fixes + +* close maconn stream after reading/writing ([#2236](https://www.github.com/libp2p/js-libp2p/issues/2236)) ([9c67c5b](https://www.github.com/libp2p/js-libp2p/commit/9c67c5b3d0ab63c7a1a62f363ae732b300ef6b87)) +* use logging component everywhere ([#2228](https://www.github.com/libp2p/js-libp2p/issues/2228)) ([e5dfde0](https://www.github.com/libp2p/js-libp2p/commit/e5dfde0883191c93903ca552433f177d48adf0b3)) +* use optimistic protocol negotation ([#2253](https://www.github.com/libp2p/js-libp2p/issues/2253)) ([0b4a2ee](https://www.github.com/libp2p/js-libp2p/commit/0b4a2ee7983b4dc9dc0a7b705a202a4c550e7017)) + + +### Code Refactoring + +* extract circuit relay v2 to separate module ([#2222](https://www.github.com/libp2p/js-libp2p/issues/2222)) ([24afba3](https://www.github.com/libp2p/js-libp2p/commit/24afba30004fb7f24af1f0180229bb164340f00b)) + + +### Dependencies + +* The following workspace dependencies were updated + * dependencies + * @libp2p/interface bumped from ^0.1.6 to ^1.0.0 + * devDependencies + * @libp2p/logger bumped from ^3.1.0 to ^4.0.0 + * @libp2p/peer-id-factory bumped from ^3.0.8 to ^3.0.9 + ### [4.0.7](https://www.github.com/libp2p/js-libp2p/compare/utils-v4.0.6...utils-v4.0.7) (2023-11-07) @@ -421,4 +455,4 @@ ### Features -* ip port to multiaddr ([#1](https://github.com/libp2p/js-libp2p-utils/issues/1)) ([426b421](https://github.com/libp2p/js-libp2p-utils/commit/426b421)) +* ip port to multiaddr ([#1](https://github.com/libp2p/js-libp2p-utils/issues/1)) ([426b421](https://github.com/libp2p/js-libp2p-utils/commit/426b421)) \ No newline at end of file diff --git a/packages/utils/package.json b/packages/utils/package.json index 899e981570..58ffea43e8 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@libp2p/utils", - "version": "4.0.7", + "version": "5.0.0", "description": "Package to aggregate shared logic and dependencies for the libp2p ecosystem", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/utils#readme", @@ -83,6 +83,10 @@ "./stream-to-ma-conn": { "types": "./dist/src/stream-to-ma-conn.d.ts", "import": "./dist/src/stream-to-ma-conn.js" + }, + "./tracked-map": { + "types": "./dist/src/tracked-map.d.ts", + "import": "./dist/src/tracked-map.js" } }, "eslintConfig": { @@ -107,7 +111,7 @@ }, "dependencies": { "@chainsafe/is-ip": "^2.0.2", - "@libp2p/interface": "^0.1.6", + "@libp2p/interface": "^1.0.0", "@multiformats/multiaddr": "^12.1.10", "@multiformats/multiaddr-matcher": "^1.1.0", "get-iterator": "^2.0.1", @@ -120,8 +124,8 @@ "uint8arraylist": "^2.4.3" }, "devDependencies": { - "@libp2p/logger": "^3.1.0", - "@libp2p/peer-id-factory": "^3.0.8", + "@libp2p/logger": "^4.0.0", + "@libp2p/peer-id-factory": "^3.0.9", "aegir": "^41.0.2", "delay": "^6.0.0", "it-all": "^3.0.3", diff --git a/packages/utils/src/abstract-stream.ts b/packages/utils/src/abstract-stream.ts index a1baf9cf37..3e55900fb4 100644 --- a/packages/utils/src/abstract-stream.ts +++ b/packages/utils/src/abstract-stream.ts @@ -1,11 +1,10 @@ -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { type Pushable, pushable } from 'it-pushable' import defer, { type DeferredPromise } from 'p-defer' import { raceSignal } from 'race-signal' import { Uint8ArrayList } from 'uint8arraylist' import { closeSource } from './close-source.js' -import type { AbortOptions } from '@libp2p/interface' -import type { Direction, ReadStatus, Stream, StreamStatus, StreamTimeline, WriteStatus } from '@libp2p/interface/connection' +import type { AbortOptions, Direction, ReadStatus, Stream, StreamStatus, StreamTimeline, WriteStatus } from '@libp2p/interface' import type { Logger } from '@libp2p/logger' import type { Source } from 'it-stream-types' diff --git a/packages/utils/src/address-sort.ts b/packages/utils/src/address-sort.ts index 5773a2d90c..37fbdd4e49 100644 --- a/packages/utils/src/address-sort.ts +++ b/packages/utils/src/address-sort.ts @@ -22,7 +22,7 @@ import { Circuit } from '@multiformats/multiaddr-matcher' import { isPrivate } from './multiaddr/is-private.js' -import type { Address } from '@libp2p/interface/peer-store' +import type { Address } from '@libp2p/interface' /** * Compare function for array.sort() that moves public addresses to the start diff --git a/packages/utils/src/ip-port-to-multiaddr.ts b/packages/utils/src/ip-port-to-multiaddr.ts index 08571eb92b..9fb3d8b9f6 100644 --- a/packages/utils/src/ip-port-to-multiaddr.ts +++ b/packages/utils/src/ip-port-to-multiaddr.ts @@ -1,5 +1,5 @@ import { isIPv4, isIPv6 } from '@chainsafe/is-ip' -import { CodeError } from '@libp2p/interface/errors' +import { CodeError } from '@libp2p/interface' import { type Multiaddr, multiaddr } from '@multiformats/multiaddr' export const Errors = { diff --git a/packages/utils/src/peer-job-queue.ts b/packages/utils/src/peer-job-queue.ts index 6711798007..beb557ce2a 100644 --- a/packages/utils/src/peer-job-queue.ts +++ b/packages/utils/src/peer-job-queue.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import { CodeError, ERR_INVALID_PARAMETERS } from '@libp2p/interface/errors' +import { CodeError, ERR_INVALID_PARAMETERS } from '@libp2p/interface' import PQueue from 'p-queue' -import type { PeerId } from '@libp2p/interface/peer-id' +import type { PeerId } from '@libp2p/interface' import type { QueueAddOptions, Options, Queue } from 'p-queue' // Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound diff --git a/packages/utils/src/stream-to-ma-conn.ts b/packages/utils/src/stream-to-ma-conn.ts index ff2f919cb0..27b2f298f2 100644 --- a/packages/utils/src/stream-to-ma-conn.ts +++ b/packages/utils/src/stream-to-ma-conn.ts @@ -1,5 +1,4 @@ -import type { ComponentLogger } from '@libp2p/interface' -import type { MultiaddrConnection, Stream } from '@libp2p/interface/connection' +import type { ComponentLogger, MultiaddrConnection, Stream } from '@libp2p/interface' import type { Multiaddr } from '@multiformats/multiaddr' export interface StreamProperties { diff --git a/packages/interface/src/metrics/tracked-map.ts b/packages/utils/src/tracked-map.ts similarity index 95% rename from packages/interface/src/metrics/tracked-map.ts rename to packages/utils/src/tracked-map.ts index 82959e33e0..566abd5fd6 100644 --- a/packages/interface/src/metrics/tracked-map.ts +++ b/packages/utils/src/tracked-map.ts @@ -1,4 +1,4 @@ -import type { Metric, Metrics } from './index.js' +import type { Metric, Metrics } from '@libp2p/interface' export interface TrackedMapInit { name: string diff --git a/packages/utils/test/stream-to-ma-conn.spec.ts b/packages/utils/test/stream-to-ma-conn.spec.ts index b36c8c9f77..627b8878c5 100644 --- a/packages/utils/test/stream-to-ma-conn.spec.ts +++ b/packages/utils/test/stream-to-ma-conn.spec.ts @@ -8,7 +8,7 @@ import { pair } from 'it-pair' import { pipe } from 'it-pipe' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { streamToMaConnection } from '../src/stream-to-ma-conn.js' -import type { Stream } from '@libp2p/interface/connection' +import type { Stream } from '@libp2p/interface' import type { Duplex, Source } from 'it-stream-types' import type { Uint8ArrayList } from 'uint8arraylist' diff --git a/packages/interface/test/metrics/tracked-map.spec.ts b/packages/utils/test/tracked-map.spec.ts similarity index 94% rename from packages/interface/test/metrics/tracked-map.spec.ts rename to packages/utils/test/tracked-map.spec.ts index a24d6a0c9b..8c589818c4 100644 --- a/packages/interface/test/metrics/tracked-map.spec.ts +++ b/packages/utils/test/tracked-map.spec.ts @@ -1,7 +1,7 @@ import { expect } from 'aegir/chai' import { stubInterface } from 'sinon-ts' -import { trackedMap } from '../../src/metrics/tracked-map.js' -import type { Metric, Metrics } from '../../src/metrics/index.js' +import { trackedMap } from '../src/tracked-map.js' +import type { Metric, Metrics } from '@libp2p/interface' import type { SinonStubbedInstance } from 'sinon' describe('tracked-map', () => { diff --git a/run-client.ts b/run-client.ts deleted file mode 100644 index 90380ae35a..0000000000 --- a/run-client.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* eslint-disable no-console */ -import { noise } from '@chainsafe/libp2p-noise' -import { yamux } from '@chainsafe/libp2p-yamux' -import { mplex } from '@libp2p/mplex' -import { plaintext } from '@libp2p/plaintext' -import { tcp } from '@libp2p/tcp' -import { multiaddr } from '@multiformats/multiaddr' -import { createLibp2p, type Libp2p } from 'libp2p' -import { perf, type PerfOutput, type Perf } from '../src/index.js' - -const ONE_MEG = 1024 * 1024 -const DOWNLOAD_BYTES = ONE_MEG * 1024 * 5 - -async function createNode (): Promise> { - return createLibp2p({ - transports: [ - tcp() - ], - connectionEncryption: [ - noise(), plaintext() - ], - streamMuxers: [ - yamux(), mplex() - ], - services: { - perf: perf({ - writeBlockSize: 1024 * 1024 - }) - }, - connectionManager: { - minConnections: 0 - } - }) -} - -const libp2p1 = await createNode() - -let last: PerfOutput | undefined - -const ma = multiaddr('/ip4/127.0.0.1/tcp/59032') - -for await (const output of libp2p1.services.perf.measurePerformance(ma, 0, DOWNLOAD_BYTES)) { - last = output - console.info(output) - - console.info((output.downloadBytes / (1024 * 1024)) / output.timeSeconds, 'MB/s') -} - -if (last?.type === 'final') { - console.info((last.downloadBytes / (1024 * 1024)) / last.timeSeconds, 'MB/s') -} - -await libp2p1.stop() - -// plaintext/yamux - 1354 MB/s -// plaintext/mplex - 34478 MB/s -// noise/yamux - 60 MB/s -// noise/mplex - 62 MB/s - -// noise/yamux/native crypto - 282 MB/s -// noise/mplex/native crypto - 420 MB/s diff --git a/run-server.ts b/run-server.ts deleted file mode 100644 index 8d6d569994..0000000000 --- a/run-server.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* eslint-disable no-console */ -import { noise } from '@chainsafe/libp2p-noise' -import { yamux } from '@chainsafe/libp2p-yamux' -import { mplex } from '@libp2p/mplex' -import { plaintext } from '@libp2p/plaintext' -import { tcp } from '@libp2p/tcp' -import { createLibp2p, type Libp2p } from 'libp2p' -import { perf, type Perf } from '../src/index.js' - -async function createNode (): Promise> { - return createLibp2p({ - addresses: { - listen: [ - '/ip4/0.0.0.0/tcp/59032' - ] - }, - transports: [ - tcp() - ], - connectionEncryption: [ - noise(), plaintext() - ], - streamMuxers: [ - yamux(), mplex() - ], - services: { - perf: perf({ - writeBlockSize: 1024 * 1024 - }) - }, - connectionManager: { - minConnections: 0 - } - }) -} - -const server = await createNode() - -console.info(server.getMultiaddrs()) diff --git a/run.ts b/run.ts deleted file mode 100644 index 37fac789f8..0000000000 --- a/run.ts +++ /dev/null @@ -1,147 +0,0 @@ -/* eslint-disable no-console */ -import { noise } from '@chainsafe/libp2p-noise' -import { yamux } from '@chainsafe/libp2p-yamux' -import { mplex } from '@libp2p/mplex' -import { plaintext } from '@libp2p/plaintext' -import { tcp } from '@libp2p/tcp' -import last from 'it-last' -import { createLibp2p, type Libp2p } from 'libp2p' -import { perf, type PerfOutput, type Perf } from '../src/index.js' - -const ONE_MEG = 1024 * 1024 -const DOWNLOAD_BYTES = ONE_MEG * 1024 * 5 -const REPEAT = 10 - -// plaintext/yamux - 1354 MB/s -// plaintext/mplex - 34478 MB/s -// noise/yamux - 60 MB/s -// noise/mplex - 62 MB/s - -// noise/yamux/native crypto - 282 MB/s -// noise/mplex/native crypto - 420 MB/s - -const sizes = [ - 64, 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536 -] - -for (let i = 0; i < sizes.length; i++) { - const size = sizes[i] - - const measurements: PerfOutput[] = [] - - for (let n = 0; n < REPEAT; n++) { - async function createNode (): Promise> { - return createLibp2p({ - addresses: { - listen: [ - '/ip4/0.0.0.0/tcp/0' - ] - }, - transports: [ - tcp() - ], - connectionEncryption: [ - noise(), plaintext() - ], - streamMuxers: [ - yamux(), mplex() - ], - services: { - perf: perf({ - writeBlockSize: size * 1024 - }) - }, - connectionManager: { - minConnections: 0 - } - }) - } - - const libp2p1 = await createNode() - const libp2p2 = await createNode() - - const result = await last( - libp2p1.services.perf.measurePerformance(libp2p2.getMultiaddrs()[0], 0, DOWNLOAD_BYTES) - ) - - if (result != null) { - measurements.push(result) - } - - await libp2p1.stop() - await libp2p2.stop() - } - - const downloadBytes = measurements - .map(m => { - if (m.type === 'final') { - return m.downloadBytes - } - - return 0 - }) - .filter(outliers()) - .reduce((acc, curr) => acc + curr, 0) - - const timeSeconds = measurements - .map(m => { - if (m.type === 'final') { - return m.timeSeconds - } - - return 0 - }) - .filter(outliers()) - .reduce((acc, curr) => acc + curr, 0) - - console.info(size, 'kb', (downloadBytes / (1024 * 1024)) / timeSeconds, 'MB/s') -} - -function outliers() { - let o: number[] - - return function(v: number, i: number, a: number[]) { - if (o == null) { - o = calc(a) - } - - return !~o.indexOf(v); - } -} - -function calc(arr: number[]): number[] { - arr = arr.slice(0); - - arr = arr.sort(function(a, b) { - return a - b; - }); - - var len = arr.length; - var middle = median(arr); - var range = iqr(arr); - var outliers = []; - - for (var i = 0; i < len; i++) { - Math.abs(arr[i] - middle) > range && outliers.push(arr[i]); - } - - return outliers; -} - -function median(arr: number[]): number { - var len = arr.length; - var half = ~~(len / 2); - - return len % 2 - ? arr[half] - : (arr[half - 1] + arr[half]) / 2; -} - -function iqr(arr: number[]): number { - var len = arr.length; - var q1 = median(arr.slice(0, ~~(len / 2))); - var q3 = median(arr.slice(Math.ceil(len / 2))); - var g = 1.5; - - return (q3 - q1) * g; -}