diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
new file mode 100644
index 0000000000..4bf8b2bd06
--- /dev/null
+++ b/.github/pull_request_template.md
@@ -0,0 +1,28 @@
+## Title
+
+
+## Description
+
+
+
+## Notes & open questions
+
+
+
+## Change checklist
+
+- [ ] I have performed a self-review of my own code
+- [ ] I have made corresponding changes to the documentation if necessary (this includes comments as well)
+- [ ] I have added tests that prove my fix is effective or that my feature works
\ No newline at end of file
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 4917feab55..a354658173 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -179,7 +179,7 @@ jobs:
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:example
- multidim-interop:
+ transport-interop:
needs: build
runs-on: ${{ fromJSON(github.repository == 'libp2p/js-libp2p' && '["self-hosted", "linux", "x64", "4xlarge"]' || '"ubuntu-latest"') }}
steps:
@@ -219,7 +219,7 @@ jobs:
test-electron-renderer,
test-interop,
test-examples,
- multidim-interop
+ transport-interop
]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
@@ -237,7 +237,8 @@ jobs:
{ "type": "fix", "section": "Bug Fixes", "hidden": false },
{ "type": "chore", "section": "Trivial Changes", "hidden": false },
{ "type": "docs", "section": "Documentation", "hidden": false },
- { "type": "deps", "section": "Dependencies", "hidden": false }
+ { "type": "deps", "section": "Dependencies", "hidden": false },
+ { "type": "refactor", "section": "Refactors", "hidden": false }
]
- uses: actions/checkout@v3
with:
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 50bb7fccf6..71b4d4c4f6 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1 +1 @@
-{"packages/crypto":"2.0.3","packages/interface":"0.1.2","packages/interface-compliance-tests":"4.0.4","packages/interface-internal":"0.1.4","packages/kad-dht":"10.0.4","packages/keychain":"3.0.3","packages/libp2p":"0.46.5","packages/logger":"3.0.2","packages/metrics-prometheus":"2.0.4","packages/multistream-select":"4.0.2","packages/peer-collections":"4.0.3","packages/peer-discovery-bootstrap":"9.0.4","packages/peer-discovery-mdns":"9.0.4","packages/peer-id":"3.0.2","packages/peer-id-factory":"3.0.3","packages/peer-record":"6.0.3","packages/peer-store":"9.0.3","packages/protocol-perf":"1.1.2","packages/pubsub":"8.0.5","packages/pubsub-floodsub":"8.0.5","packages/stream-multiplexer-mplex":"9.0.4","packages/transport-tcp":"8.0.4","packages/transport-webrtc":"3.1.5","packages/transport-websockets":"7.0.4","packages/transport-webtransport":"3.0.5","packages/utils":"4.0.2"}
\ No newline at end of file
+{"interop":"1.0.6","packages/crypto":"2.0.5","packages/interface":"0.1.3","packages/interface-compliance-tests":"4.1.1","packages/interface-internal":"0.1.6","packages/kad-dht":"10.0.9","packages/keychain":"3.0.5","packages/libp2p":"0.46.14","packages/logger":"3.0.3","packages/metrics-prometheus":"2.0.8","packages/multistream-select":"4.0.3","packages/peer-collections":"4.0.5","packages/peer-discovery-bootstrap":"9.0.8","packages/peer-discovery-mdns":"9.0.10","packages/peer-id":"3.0.3","packages/peer-id-factory":"3.0.5","packages/peer-record":"6.0.6","packages/peer-store":"9.0.6","packages/protocol-perf":"1.1.11","packages/pubsub":"8.0.7","packages/pubsub-floodsub":"8.0.9","packages/stream-multiplexer-mplex":"9.0.8","packages/transport-tcp":"8.0.9","packages/transport-webrtc":"3.2.3","packages/transport-websockets":"7.0.9","packages/transport-webtransport":"3.1.3","packages/utils":"4.0.4"}
\ No newline at end of file
diff --git a/.release-please.json b/.release-please.json
index b2951dc98e..3a33d3ae02 100644
--- a/.release-please.json
+++ b/.release-please.json
@@ -4,6 +4,7 @@
"bump-patch-for-minor-pre-major": true,
"group-pull-request-title-pattern": "chore: release ${component}",
"packages": {
+ "interop": {},
"packages/crypto": {},
"packages/interface": {},
"packages/interface-compliance-tests": {},
diff --git a/CODEOWNERS b/CODEOWNERS
new file mode 100644
index 0000000000..e851c09801
--- /dev/null
+++ b/CODEOWNERS
@@ -0,0 +1 @@
+* @libp2p/js-libp2p-dev
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 2a101e077b..428ae1d725 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,9 +1,11 @@
# Contributing guidelines
-libp2p as a project, including js-libp2p and all of its modules, follows the [standard IPFS Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md).
+👋 Contributions are welcome!
-We also adhere to the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) which provide additional information of how to collaborate and contribute in the JavaScript implementation of libp2p.
+👉 Please see the [IPFS JavaScript Community contributing guidelines](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for how to collaborate and contribute to js-libp2p.
-We appreciate your time and attention for going over these. Please open an issue on [ipfs/community](https://github.com/ipfs/community) if you have any question.
+💪 The [core maintainers](./CODEOWNERS) hang out in #libp2p-implementers in ipfs.io Matrix, FIL Slack, and IPFS Discord. They perform weekly triage of issues and PRs per https://lu.ma/js-libp2p
-Thank you.
+🤲 Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed in [README.md](./README.md), without any additional terms or conditions.
+
+🙏 Thank you!
diff --git a/README.md b/README.md
index db1bfdf952..06b53a0e6b 100644
--- a/README.md
+++ b/README.md
@@ -1,76 +1,3 @@
-# js-libp2p-monorepo
-
-[](http://libp2p.io/)
-[](https://discuss.libp2p.io)
-[](https://codecov.io/gh/libp2p/js-libp2p)
-[](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster)
-
-> JavaScript implementation of libp2p, a modular peer to peer network stack
-
-## Table of contents
-
-- [Structure](#structure)
- - [Project status](#project-status)
-- [Background](#background)
-- [Roadmap](#roadmap)
-- [Install](#install)
-- [Usage](#usage)
- - [Configuration](#configuration)
- - [Limits](#limits)
- - [Getting started](#getting-started)
- - [Tutorials and Examples](#tutorials-and-examples)
-- [Development](#development)
- - [Tests](#tests)
- - [Run unit tests](#run-unit-tests)
- - [Packages](#packages)
-- [Used by](#used-by)
-- [Contribute](#contribute)
-- [API Docs](#api-docs)
-- [License](#license)
-- [Contribution](#contribution)
-
-## Structure
-
-- [`/doc`](./doc) Docs for libp2p
-- [`/examples/auto-relay`](./examples/auto-relay) Shows how to configure relayed connections
-- [`/examples/chat`](./examples/chat) An example chat app using libp2p
-- [`/examples/connection-encryption`](./examples/connection-encryption) An example of how to configure connection encrypters
-- [`/examples/delegated-routing`](./examples/delegated-routing) How to configure libp2p delegated routers
-- [`/examples/discovery-mechanisms`](./examples/discovery-mechanisms) How to configure peer discovery mechanisms
-- [`/examples/echo`](./examples/echo) An example echo app
-- [`/examples/peer-and-content-routing`](./examples/peer-and-content-routing) How to use peer and content routing
-- [`/examples/pnet`](./examples/pnet) How to configure a libp2p private network
-- [`/examples/protocol-and-stream-muxing`](./examples/protocol-and-stream-muxing) How to use multiplex protocols streams
-- [`/examples/pubsub`](./examples/pubsub) An example using libp2p pubsub
-- [`/examples/transports`](./examples/transports) An example using different types of libp2p transport
-- [`/interop`](./interop) Multidimension Interop Test
-- [`/packages/crypto`](./packages/crypto) Crypto primitives for libp2p
-- [`/packages/interface`](./packages/interface) The interface implemented by a libp2p node
-- [`/packages/interface-compliance-tests`](./packages/interface-compliance-tests) Compliance tests for JS libp2p interfaces
-- [`/packages/interface-internal`](./packages/interface-internal) Interfaces implemented by internal libp2p components
-- [`/packages/kad-dht`](./packages/kad-dht) JavaScript implementation of the Kad-DHT for libp2p
-- [`/packages/keychain`](./packages/keychain) Key management and cryptographically protected messages
-- [`/packages/libp2p`](./packages/libp2p) JavaScript implementation of libp2p, a modular peer to peer network stack
-- [`/packages/logger`](./packages/logger) A logging component for use in js-libp2p modules
-- [`/packages/metrics-prometheus`](./packages/metrics-prometheus) Collect libp2p metrics for scraping by Prometheus or Graphana
-- [`/packages/multistream-select`](./packages/multistream-select) JavaScript implementation of multistream-select
-- [`/packages/peer-collections`](./packages/peer-collections) Stores values against a peer id
-- [`/packages/peer-discovery-bootstrap`](./packages/peer-discovery-bootstrap) Peer discovery via a list of bootstrap peers
-- [`/packages/peer-discovery-mdns`](./packages/peer-discovery-mdns) Node.js libp2p mDNS discovery implementation for peer discovery
-- [`/packages/peer-id`](./packages/peer-id) Implementation of @libp2p/interface-peer-id
-- [`/packages/peer-id-factory`](./packages/peer-id-factory) Create PeerId instances
-- [`/packages/peer-record`](./packages/peer-record) Used to transfer signed peer data across the network
-- [`/packages/peer-store`](./packages/peer-store) Stores information about peers libp2p knows on the network
-- [`/packages/protocol-perf`](./packages/protocol-perf) Implementation of Perf Protocol
-- [`/packages/pubsub`](./packages/pubsub) libp2p pubsub base class
-- [`/packages/pubsub-floodsub`](./packages/pubsub-floodsub) 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).
-- [`/packages/stream-multiplexer-mplex`](./packages/stream-multiplexer-mplex) JavaScript implementation of
-- [`/packages/transport-tcp`](./packages/transport-tcp) A TCP transport for libp2p
-- [`/packages/transport-webrtc`](./packages/transport-webrtc) A libp2p transport using WebRTC connections
-- [`/packages/transport-websockets`](./packages/transport-websockets) JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport spec
-- [`/packages/transport-webtransport`](./packages/transport-webtransport) JavaScript implementation of the WebTransport module that libp2p uses and that implements the interface-transport spec
-- [`/packages/utils`](./packages/utils) Package to aggregate shared logic and dependencies for the libp2p ecosystem
-
@@ -99,9 +26,19 @@
+# js-libp2p-monorepo
+
+[](http://libp2p.io/)
+[](https://discuss.libp2p.io)
+[](https://codecov.io/gh/libp2p/js-libp2p)
+[](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster)
+
+> JavaScript implementation of libp2p, a modular peer to peer network stack
+
+
### 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 🐉..
+This project has been used in production for years in Ethereum, IPFS, and more. It is actively maintained by multiple organizations and continues to be improved! The API might change, but we strictly follow semver.
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.
@@ -110,6 +47,26 @@ If you are looking for the documentation of the latest release, you can view the
**Want to update libp2p in your project?** Check our [migrations folder](./doc/migrations).
+## Table of contents
+
+- [Background](#background)
+- [Roadmap](#roadmap)
+- [Install](#install)
+- [Usage](#usage)
+ - [Configuration](#configuration)
+ - [Limits](#limits)
+ - [Getting started](#getting-started)
+ - [Tutorials and Examples](#tutorials-and-examples)
+- [Structure](#structure)
+- [Development](#development)
+ - [Tests](#tests)
+ - [Run unit tests](#run-unit-tests)
+ - [Packages](#packages)
+- [Used by](#used-by)
+- [Contribute](#contribute)
+- [API Docs](#api-docs)
+- [License](#license)
+
## 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.
@@ -159,6 +116,48 @@ If you are starting your journey with `js-libp2p`, read the [GETTING\_STARTED.md
You can find multiple examples on the [examples folder](./examples) that will guide you through using libp2p for several scenarios.
+## Structure
+
+- [`/doc`](./doc) Docs for libp2p
+- [`/examples/auto-relay`](./examples/auto-relay) Shows how to configure relayed connections
+- [`/examples/chat`](./examples/chat) An example chat app using libp2p
+- [`/examples/connection-encryption`](./examples/connection-encryption) An example of how to configure connection encrypters
+- [`/examples/delegated-routing`](./examples/delegated-routing) How to configure libp2p delegated routers
+- [`/examples/discovery-mechanisms`](./examples/discovery-mechanisms) How to configure peer discovery mechanisms
+- [`/examples/echo`](./examples/echo) An example echo app
+- [`/examples/peer-and-content-routing`](./examples/peer-and-content-routing) How to use peer and content routing
+- [`/examples/pnet`](./examples/pnet) How to configure a libp2p private network
+- [`/examples/protocol-and-stream-muxing`](./examples/protocol-and-stream-muxing) How to use multiplex protocols streams
+- [`/examples/pubsub`](./examples/pubsub) An example using libp2p pubsub
+- [`/examples/transports`](./examples/transports) An example using different types of libp2p transport
+- [`/interop`](./interop) Multidimension Interop Test
+- [`/packages/crypto`](./packages/crypto) Crypto primitives for libp2p
+- [`/packages/interface`](./packages/interface) The interface implemented by a libp2p node
+- [`/packages/interface-compliance-tests`](./packages/interface-compliance-tests) Compliance tests for JS libp2p interfaces
+- [`/packages/interface-internal`](./packages/interface-internal) Interfaces implemented by internal libp2p components
+- [`/packages/kad-dht`](./packages/kad-dht) JavaScript implementation of the Kad-DHT for libp2p
+- [`/packages/keychain`](./packages/keychain) Key management and cryptographically protected messages
+- [`/packages/libp2p`](./packages/libp2p) JavaScript implementation of libp2p, a modular peer to peer network stack
+- [`/packages/logger`](./packages/logger) A logging component for use in js-libp2p modules
+- [`/packages/metrics-prometheus`](./packages/metrics-prometheus) Collect libp2p metrics for scraping by Prometheus or Graphana
+- [`/packages/multistream-select`](./packages/multistream-select) JavaScript implementation of multistream-select
+- [`/packages/peer-collections`](./packages/peer-collections) Stores values against a peer id
+- [`/packages/peer-discovery-bootstrap`](./packages/peer-discovery-bootstrap) Peer discovery via a list of bootstrap peers
+- [`/packages/peer-discovery-mdns`](./packages/peer-discovery-mdns) Node.js libp2p mDNS discovery implementation for peer discovery
+- [`/packages/peer-id`](./packages/peer-id) Implementation of @libp2p/interface-peer-id
+- [`/packages/peer-id-factory`](./packages/peer-id-factory) Create PeerId instances
+- [`/packages/peer-record`](./packages/peer-record) Used to transfer signed peer data across the network
+- [`/packages/peer-store`](./packages/peer-store) Stores information about peers libp2p knows on the network
+- [`/packages/protocol-perf`](./packages/protocol-perf) Implementation of Perf Protocol
+- [`/packages/pubsub`](./packages/pubsub) libp2p pubsub base class
+- [`/packages/pubsub-floodsub`](./packages/pubsub-floodsub) 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).
+- [`/packages/stream-multiplexer-mplex`](./packages/stream-multiplexer-mplex) JavaScript implementation of
+- [`/packages/transport-tcp`](./packages/transport-tcp) A TCP transport for libp2p
+- [`/packages/transport-webrtc`](./packages/transport-webrtc) A libp2p transport using WebRTC connections
+- [`/packages/transport-websockets`](./packages/transport-websockets) JavaScript implementation of the WebSockets module that libp2p uses and that implements the interface-transport spec
+- [`/packages/transport-webtransport`](./packages/transport-webtransport) JavaScript implementation of the WebTransport module that libp2p uses and that implements the interface-transport spec
+- [`/packages/utils`](./packages/utils) Package to aggregate shared logic and dependencies for the libp2p ecosystem
+
## Development
**Clone and install dependencies:**
@@ -235,7 +234,7 @@ List of packages currently in existence for libp2p
-
+
@@ -243,11 +242,7 @@ And [many others...](https://github.com/libp2p/js-libp2p/network/dependents)
## Contribute
-The libp2p implementation in JavaScript is a work in progress. As such, there are a few things you can do right now to help out:
-
-- Go through the modules and **check out existing issues**. This would be especially useful for modules in active development. Some knowledge of IPFS/libp2p may be required, as well as the infrastructure behind it - for instance, you may need to read up on p2p and more complex operations like muxing to be able to help technically.
-- **Perform code reviews**. Most of this has been developed by @diasdavid, which means that more eyes will help a) speed the project along b) ensure quality and c) reduce possible future bugs.
-- **Add tests**. There can never be enough tests.
+See [CONTRIBUTING.md](./CONTRIBUTING.md).
## API Docs
@@ -259,7 +254,3 @@ Licensed under either of
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / )
- MIT ([LICENSE-MIT](LICENSE-MIT) / )
-
-## Contribution
-
-Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
diff --git a/doc/ARCHITECTURE.md b/doc/ARCHITECTURE.md
new file mode 100644
index 0000000000..59489f3f42
--- /dev/null
+++ b/doc/ARCHITECTURE.md
@@ -0,0 +1,217 @@
+# Libp2p Architecture
+
+js-libp2p is comprised of a number of components that work together to provide functionality such as dailling peers, managing connections, registering protocols, storing information about peers and much more. This document aims to provide a high level overview of the components and how they interact with each other.
+
+- [Libp2p Architecture](#libp2p-architecture)
+ - [Component Diagram](#component-diagram)
+ - [Sequence Diagrams](#sequence-diagrams)
+ - [Dialing a Peer](#dialing-a-peer)
+ - [Opening a stream on a connection](#opening-a-stream-on-a-connection)
+
+## Component Diagram
+
+```mermaid
+flowchart TB
+ direction TB
+ subgraph Components
+ direction TB
+ PeerId ~~~
+ Events ~~~
+ ConnectionGater ~~~
+ Upgrader
+ AddressManager ~~~
+ ConnectionManager ~~~
+ TransportManager ~~~
+ Registrar
+ PeerStore ~~~
+ Datastore ~~~
+ PeerRouting ~~~
+ _xx[ ]
+ ContentRouting ~~~
+ Metrics ~~~
+ ConnectionProtector ~~~
+ _x[ ]
+
+ style _x opacity:0;
+ style _xx opacity:0;
+
+ end
+
+ subgraph Connections[Connection Configuration]
+ direction TB
+
+ subgraph Transports
+ direction TB
+ TCP
+ WebRTC
+ Websocket
+ Webtransport
+ end
+
+ subgraph Encryption[Connection Encryptions]
+ direction TB
+ Noise
+ Plaintext
+ end
+
+ subgraph Multiplexer[Stream Multiplexers]
+ direction TB
+ Yamux
+ Mplex
+ end
+
+ Multiplexer ~~~ Encryption ~~~ Transports
+
+ end
+```
+
+```mermaid
+---
+title: Components Dependency Graph
+---
+flowchart TD
+ PeerId
+ Events
+ ConnectionGater
+ Upgrader
+ AddressManager
+ ConnectionManager
+ TransportManager
+ Registrar
+ PeerStore
+ Datastore
+ PeerRouting
+ ContentRouting
+ Metrics
+ ConnectionProtector
+
+ %% AddressManager
+ PeerId --> AddressManager
+ TransportManager --> AddressManager
+ PeerStore --> AddressManager
+ Events --> AddressManager
+
+ %% ConnectionManager
+ PeerId --> ConnectionManager
+ Metrics --> ConnectionManager
+ PeerStore --> ConnectionManager
+ TransportManager --> ConnectionManager
+ ConnectionGater --> ConnectionManager
+ Events --> ConnectionManager
+
+ %% TransportManager
+ Metrics --> TransportManager
+ AddressManager --> TransportManager
+ Upgrader --> TransportManager
+ Events --> TransportManager
+
+ %% Upgrader
+ PeerId --> Upgrader
+ Metrics --> Upgrader
+ ConnectionManager --> Upgrader
+ ConnectionGater --> Upgrader
+ ConnectionProtector --> Upgrader
+ Registrar --> Upgrader
+ PeerStore --> Upgrader
+ Events --> Upgrader
+
+ %% Registrar
+ PeerId --> Registrar
+ ConnectionManager --> Registrar
+ PeerStore --> Registrar
+ Events --> Registrar
+
+ %% PeerStore
+ PeerId --> PeerStore
+ Datastore --> PeerStore
+ Events --> PeerStore
+
+ %% PeerRouting
+ PeerId --> PeerRouting
+ PeerStore --> PeerRouting
+
+ %% ContentRouting
+ PeerStore --> ContentRouting
+```
+
+## Sequence Diagrams
+
+These diagrams show the interactions between the components in common scenarios. They are not exhaustive and are intended to provide a high level overview of the interactions between the components.
+
+### Dialing a Peer
+
+This illustrates an outbound connection being established to a peer.
+
+```mermaid
+%% how an outbound connection is opened when a user calls .dial(),
+%% assuming user is not connected to the PeerId for the
+%% Multiaddr that was dialed.
+%%
+%% This is
+%%
+sequenceDiagram
+ User->>+libp2p: dial a multiaddr `.dial()`
+ libp2p->>+Connection Manager: open a connection for me to MA `.openConnection()`
+ %% obfuscating the dial queue.
+ %% Connection Manager->>+Transport Manager: Choose transport to use for Multiaddr
+ Connection Manager->>+Transport Manager: Network level reach out `.dial()`
+ Transport Manager->>+Transport: Get MultiaddrConn `socket + multiaddr`
+ %% Transport->>+Transport Manager: Return MultiaddrConn `socket + multiaddr`
+ %% how the upgrade happens is transport specific, so transports directly call upgrader
+ Transport-->>+Upgrader: upgrade my connection??
+ Upgrader-->>+Upgrader: Perform upgrade (see other diagram)
+ Upgrader->>+Connection Manager: Connection (link to interface)
+ %% Connection Manager->>+Connection Manager: Connection (link to interface)
+ Connection Manager->>+User: Connection (link to interface)
+```
+
+
+### Opening a stream on a connection
+
+This illustrates a stream being opened on an existing connection that will echo a message back to the sender. This assumes that a stable connection has been established between the two peers.
+
+```mermaid
+%% pushing data over stream
+%% register stream handler, local opens a stream for proto, send data,
+%% remote receives data and sends data back
+%% local receives data
+%% stream may or may not then be closed.
+%% Local is the node sending data, Remote is other peer the conn is with
+%% Echo protocol
+sequenceDiagram
+ box Local side
+ participant Local
+ participant Connection
+ participant LocalMuxer
+ end
+ participant Stream
+ box pink Connection
+ end
+ box Remote side
+ participant Remote
+ participant RemoteMuxer
+ participant RemoteUpgrader
+ participant RemoteRegistrar
+ participant RemoteStreamHandler
+ end
+
+ Remote->>RemoteRegistrar: Register Stream Handler `libp2p.handle`
+ %% only register stream handlers when you want to listen for protocols. SENDERs do not need to listen
+ Local->>Connection: Open outbound stream
+ Connection->>LocalMuxer: Open stream
+ LocalMuxer->>RemoteMuxer: Open stream
+ RemoteMuxer->>RemoteUpgrader: notify Stream created
+ Note over Connection,RemoteUpgrader: multi stream select handles protocol negotiation
+ Connection->>Local: return Stream
+ RemoteUpgrader->>RemoteRegistrar: select stream handler
+ RemoteRegistrar->>RemoteStreamHandler: handle stream
+ Note over RemoteStreamHandler,Local: Stream data flow & control is dictated by protocol, below is example of "echo"
+ activate Stream
+ Local->>Stream: send bytes "hello world"
+ Stream->>RemoteStreamHandler: receive bytes "hello world"
+ %% RemoteStreamHandler->>+RemoteStreamHandler: [echo] pipe back received bytes
+ RemoteStreamHandler->>Stream: echo bytes back to sender
+ Stream->>Local: receive echoed bytes
+ deactivate Stream
+
+```
\ No newline at end of file
diff --git a/doc/CONFIGURATION.md b/doc/CONFIGURATION.md
index c49d4ff4ca..dcba663f72 100644
--- a/doc/CONFIGURATION.md
+++ b/doc/CONFIGURATION.md
@@ -44,6 +44,8 @@ libp2p is a modular networking stack. It's designed to be able to suit a variety
Regardless of how you configure libp2p, the top level [API](./API.md) will always remain the same. **Note**: if some modules are not configured, like Content Routing, using those methods will throw errors.
+To get a high-level overview of the js-libp2p architecture, please read the [Architecture](./ARCHITECTURE.md) document.
+
## Modules
`js-libp2p` acts as the composer for this modular p2p networking stack using libp2p compatible modules as its subsystems. For getting an instance of `js-libp2p` compliant with all types of networking requirements, it is possible to specify the following subsystems:
@@ -126,7 +128,7 @@ If you want to know more about libp2p connection encryption, you should read the
Some available peer discovery modules are:
-- [@libp2p/mdns](https://github.com/libp2p/js-libp2ptree/master/packages/peer-discovery-mdns)
+- [@libp2p/mdns](https://github.com/libp2p/js-libp2p/tree/master/packages/peer-discovery-mdns)
- [@libp2p/bootstrap](https://github.com/libp2p/js-libp2p/tree/master/packages/peer-discovery-bootstrap)
- [@libp2p/kad-dht](https://github.com/libp2p/js-libp2p/tree/master/packages/kad-dht)
- [@chainsafe/discv5](https://github.com/chainsafe/discv5)
diff --git a/doc/CONNECTION_MANAGER.md b/doc/CONNECTION_MANAGER.md
deleted file mode 100644
index a22a14fcb1..0000000000
--- a/doc/CONNECTION_MANAGER.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Connection Manager
-
-The documentation here has moved to https://libp2p.github.io/js-libp2p-interfaces/modules/_libp2p_interface_connection_manager.html - please update your bookmarks!
diff --git a/doc/DIALER.md b/doc/DIALER.md
deleted file mode 100644
index bba39d5b70..0000000000
--- a/doc/DIALER.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# js-libp2p Dialer
-
-**Synopsis**
-* Parallel dials to the same peer will yield the same connection/error when the first dial settles.
-* All Dial Requests in js-libp2p must request a token(s) from the Dialer.
- * The number of tokens requested should be between 1 and the MAX_PER_PEER_DIALS max set in the Dialer.
- * If the number of available tokens is less than requested, the Dialer may return less than requested.
-* The number of tokens a DialRequest obtains reflects the maximum number of parallel Multiaddr Dials it can make.
-* If no tokens are available a DialRequest should immediately end and throw.
-* As tokens are limited, DialRequests should be given a prioritized list of Multiaddrs to minimize the potential request time.
-* Once a Multiaddr Dial has succeeded, all pending dials in that Dial Request should be aborted.
-* If DIAL_TIMEOUT time has elapsed before any one Multiaddr Dial succeeds, all remaining dials in the DialRequest should be aborted.
-* When a Multiaddr Dial is settled, if there are no more addresses to dial, its token should be released back to the dialer.
-* Once the DialRequest is settled, any remaining tokens should be released to the dialer.
-
-## Multiaddr Confidence
-
-An effective dialing system should involve the inclusion of a Confidence system for Multiaddrs. This enables ranking of Multiaddrs so that a prioritized list can be passed to DialRequests to maximize usage of Dialer Tokens, and minimize connection times.
-
-**Not Yet Implemented**: This system will be designed and implemented in a future update.
-
-## Notes
-
-* A DialRequest gets a set of tokens from the Dialer, up to the MAX_PER_PEER_DIALS max.
-* A DialRequest SHOULD fail if no dial tokens are available. The DialRequest MAY proceed without tokens, but this should be reserved for High Priority actions and should be rare.
-* A DialRequest MUST NOT request more tokens than it has addresses to dial. Example: If the MAX_PER_PEER_DIALS is 4 and a DialRequest has 1 address, it should only request 1 token.
-* A DialRequest SHOULD execute parallel dials for each of its addresses up the total number of tokens it has.
-* On a successful dial, the DialRequest MUST abort any other in progress dials, return the successful connection and release all tokens.
-* A new DialRequest SHOULD be given a descending list of prioritized Multiaddrs, based on their confidence. Having higher confidence Multiaddrs first can help minimize the time a DialRequest is active.
-* A failed dial to a Multiaddr SHOULD add that Multiaddr to a temporary denyList.
-* A failed dial to a Multiaddr SHOULD lower the confidence of that Multiaddr.
-* A successful dial to a Multiaddr SHOULD increase the confidence of that Multiaddr.
diff --git a/doc/GETTING_STARTED.md b/doc/GETTING_STARTED.md
index 50b37076c6..49db548f8f 100644
--- a/doc/GETTING_STARTED.md
+++ b/doc/GETTING_STARTED.md
@@ -134,7 +134,7 @@ import { createLibp2p } from 'libp2p'
import { webSockets } from '@libp2p/websockets'
import { noise } from '@chainsafe/libp2p-noise'
import { mplex } from '@libp2p/mplex'
-import { yamux } from '@chainsafe/libp2p-yamux',
+import { yamux } from '@chainsafe/libp2p-yamux'
const node = await createLibp2p({
transports: [webSockets()],
@@ -214,7 +214,7 @@ import { createLibp2p } from 'libp2p'
import { webSockets } from '@libp2p/websockets'
import { noise } from '@chainsafe/libp2p-noise'
import { mplex } from '@libp2p/mplex'
-import { yamux } from '@chainsafe/libp2p-yamux',
+import { yamux } from '@chainsafe/libp2p-yamux'
import { bootstrap } from '@libp2p/bootstrap'
diff --git a/doc/package.json b/doc/package.json
index 34c831f289..a1b9c91f2d 100644
--- a/doc/package.json
+++ b/doc/package.json
@@ -15,6 +15,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -27,7 +28,7 @@
"@libp2p/mplex": "^9.0.0",
"@libp2p/prometheus-metrics": "^2.0.0",
"@libp2p/tcp": "^8.0.0",
- "aegir": "^40.0.1",
+ "aegir": "^41.0.2",
"libp2p": "^0.46.0",
"prom-client": "^14.2.0"
},
diff --git a/examples/auto-relay/package.json b/examples/auto-relay/package.json
index 50b2c71e44..fbef4c84c4 100644
--- a/examples/auto-relay/package.json
+++ b/examples/auto-relay/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -37,8 +38,8 @@
"libp2p": "^0.46.0"
},
"devDependencies": {
- "aegir": "^40.0.8",
- "execa": "^7.1.1",
+ "aegir": "^41.0.2",
+ "execa": "^8.0.1",
"p-defer": "^4.0.0",
"uint8arrays": "^4.0.4"
},
diff --git a/examples/chat/package.json b/examples/chat/package.json
index 4f5d8c603e..4c9ca59231 100644
--- a/examples/chat/package.json
+++ b/examples/chat/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -44,8 +45,8 @@
"uint8arrays": "^4.0.6"
},
"devDependencies": {
- "aegir": "^40.0.8",
- "execa": "^7.1.1",
+ "aegir": "^41.0.2",
+ "execa": "^8.0.1",
"p-defer": "^4.0.0"
},
"private": true
diff --git a/examples/connection-encryption/package.json b/examples/connection-encryption/package.json
index 99da5daf14..d4c652bc1b 100644
--- a/examples/connection-encryption/package.json
+++ b/examples/connection-encryption/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -38,7 +39,7 @@
"uint8arrays": "^4.0.6"
},
"devDependencies": {
- "aegir": "^40.0.8",
+ "aegir": "^41.0.2",
"test-ipfs-example": "^1.0.0"
},
"private": true
diff --git a/examples/delegated-routing/package.json b/examples/delegated-routing/package.json
index ffa79e94d2..1dc0953e35 100644
--- a/examples/delegated-routing/package.json
+++ b/examples/delegated-routing/package.json
@@ -46,7 +46,7 @@
"react-scripts": "^5.0.1"
},
"devDependencies": {
- "aegir": "^40.0.8"
+ "aegir": "^41.0.2"
},
"browserslist": [
">0.2%",
diff --git a/examples/discovery-mechanisms/package.json b/examples/discovery-mechanisms/package.json
index 3c4ade5594..934710d4a3 100644
--- a/examples/discovery-mechanisms/package.json
+++ b/examples/discovery-mechanisms/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -36,13 +37,13 @@
"@libp2p/floodsub": "^8.0.0",
"@libp2p/mdns": "^9.0.0",
"@libp2p/mplex": "^9.0.0",
- "@libp2p/pubsub-peer-discovery": "^8.0.4",
+ "@libp2p/pubsub-peer-discovery": "^9.0.0",
"@libp2p/tcp": "^8.0.0",
"libp2p": "^0.46.0"
},
"devDependencies": {
- "aegir": "^40.0.8",
- "execa": "^7.1.1",
+ "aegir": "^41.0.2",
+ "execa": "^8.0.1",
"p-wait-for": "^5.0.2",
"uint8arrays": "^4.0.4"
},
diff --git a/examples/echo/package.json b/examples/echo/package.json
index 4a38ffea9c..fe6e07a54b 100644
--- a/examples/echo/package.json
+++ b/examples/echo/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -42,8 +43,8 @@
"uint8arrays": "^4.0.6"
},
"devDependencies": {
- "aegir": "^40.0.8",
- "execa": "^7.1.1",
+ "aegir": "^41.0.2",
+ "execa": "^8.0.1",
"p-defer": "^4.0.0"
},
"private": true
diff --git a/examples/libp2p-in-the-browser/websockets/package.json b/examples/libp2p-in-the-browser/websockets/package.json
index aaf2a8bbd4..e42fa7b487 100644
--- a/examples/libp2p-in-the-browser/websockets/package.json
+++ b/examples/libp2p-in-the-browser/websockets/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
diff --git a/examples/nat-traversal/README.md b/examples/nat-traversal/README.md
deleted file mode 100644
index 38f33ceff9..0000000000
--- a/examples/nat-traversal/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-# WIP - This example is still in the works
-
diff --git a/examples/peer-and-content-routing/package.json b/examples/peer-and-content-routing/package.json
index 1581c20778..0218be3139 100644
--- a/examples/peer-and-content-routing/package.json
+++ b/examples/peer-and-content-routing/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -40,7 +41,7 @@
"multiformats": "^12.0.1"
},
"devDependencies": {
- "aegir": "^40.0.8",
+ "aegir": "^41.0.2",
"test-ipfs-example": "^1.0.0"
},
"private": true
diff --git a/examples/pnet/package.json b/examples/pnet/package.json
index 47b7cab334..e619f3fe9a 100644
--- a/examples/pnet/package.json
+++ b/examples/pnet/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -38,7 +39,7 @@
"uint8arrays": "^4.0.6"
},
"devDependencies": {
- "aegir": "^40.0.8",
+ "aegir": "^41.0.2",
"test-ipfs-example": "^1.0.0"
},
"private": true
diff --git a/examples/protocol-and-stream-muxing/package.json b/examples/protocol-and-stream-muxing/package.json
index af5eae622c..d8d8086336 100644
--- a/examples/protocol-and-stream-muxing/package.json
+++ b/examples/protocol-and-stream-muxing/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -38,7 +39,7 @@
"uint8arrays": "^4.0.6"
},
"devDependencies": {
- "aegir": "^40.0.8",
+ "aegir": "^41.0.2",
"test-ipfs-example": "^1.0.0"
},
"private": true
diff --git a/examples/pubsub/message-filtering/README.md b/examples/pubsub/message-filtering/README.md
index b6f11d55cb..7b9dba1309 100644
--- a/examples/pubsub/message-filtering/README.md
+++ b/examples/pubsub/message-filtering/README.md
@@ -8,7 +8,7 @@ First, let's update our libp2p configuration with a pubsub implementation.
```JavaScript
import { createLibp2p } from 'libp2p'
-import { GossipSub } from '@chainsafe/libp2p-gossipsub'
+import { gossipsub } from '@chainsafe/libp2p-gossipsub'
import { tcp } from '@libp2p/tcp'
import { mplex } from '@libp2p/mplex'
import { yamux } from '@chainsafe/libp2p-yamux'
@@ -23,7 +23,9 @@ const createNode = async () => {
streamMuxers: [yamux(), mplex()],
connectionEncryption: [noise()],
// we add the Pubsub module we want
- pubsub: gossipsub({ allowPublishToZeroPeers: true })
+ services: {
+ pubsub: gossipsub({ allowPublishToZeroPeers: true })
+ }
})
return node
@@ -88,13 +90,17 @@ await node3.services.pubsub.subscribe(topic)
Finally, let's define the additional filter in the fruit topic.
```JavaScript
+import { TopicValidatorResult } from '@libp2p/interface/pubsub'
+
const validateFruit = (msgTopic, msg) => {
const fruit = uint8ArrayToString(msg.data)
const validFruit = ['banana', 'apple', 'orange']
+ // car is not a fruit !
if (!validFruit.includes(fruit)) {
throw new Error('no valid fruit received')
}
+ return TopicValidatorResult.Accept
}
node1.services.pubsub.topicValidators.set(topic, validateFruit)
diff --git a/examples/pubsub/package.json b/examples/pubsub/package.json
index 56607e076e..97c909fc67 100644
--- a/examples/pubsub/package.json
+++ b/examples/pubsub/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -38,8 +39,8 @@
"uint8arrays": "^4.0.6"
},
"devDependencies": {
- "aegir": "^40.0.8",
- "execa": "^7.1.1",
+ "aegir": "^41.0.2",
+ "execa": "^8.0.1",
"p-defer": "^4.0.0"
},
"private": true
diff --git a/examples/transports/package.json b/examples/transports/package.json
index 4ebd75fd0c..c5c06b6f19 100644
--- a/examples/transports/package.json
+++ b/examples/transports/package.json
@@ -21,6 +21,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -40,7 +41,7 @@
"uint8arrays": "^4.0.6"
},
"devDependencies": {
- "aegir": "^40.0.8",
+ "aegir": "^41.0.2",
"test-ipfs-example": "^1.0.0"
},
"private": true
diff --git a/interop/CHANGELOG.md b/interop/CHANGELOG.md
new file mode 100644
index 0000000000..fb517accc5
--- /dev/null
+++ b/interop/CHANGELOG.md
@@ -0,0 +1,77 @@
+# Changelog
+
+### [1.0.6](https://www.github.com/libp2p/js-libp2p/compare/multidim-interop-v1.0.5...multidim-interop-v1.0.6) (2023-10-10)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/webrtc bumped from ^3.2.2 to ^3.2.3
+ * @libp2p/webtransport bumped from ^3.1.2 to ^3.1.3
+ * libp2p bumped from ^0.46.13 to ^0.46.14
+
+### [1.0.5](https://www.github.com/libp2p/js-libp2p/compare/multidim-interop-v1.0.4...multidim-interop-v1.0.5) (2023-10-06)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/mplex bumped from ^9.0.7 to ^9.0.8
+ * @libp2p/tcp bumped from ^8.0.8 to ^8.0.9
+ * @libp2p/webrtc bumped from ^3.2.1 to ^3.2.2
+ * @libp2p/websockets bumped from ^7.0.8 to ^7.0.9
+ * @libp2p/webtransport bumped from ^3.1.1 to ^3.1.2
+ * libp2p bumped from ^0.46.12 to ^0.46.13
+
+### [1.0.4](https://www.github.com/libp2p/js-libp2p/compare/multidim-interop-v1.0.3...multidim-interop-v1.0.4) (2023-10-01)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/mplex bumped from ^9.0.6 to ^9.0.7
+ * @libp2p/tcp bumped from ^8.0.7 to ^8.0.8
+ * @libp2p/webrtc bumped from ^3.2.0 to ^3.2.1
+ * @libp2p/websockets bumped from ^7.0.7 to ^7.0.8
+ * @libp2p/webtransport bumped from ^3.1.0 to ^3.1.1
+ * libp2p bumped from ^0.46.11 to ^0.46.12
+
+### [1.0.3](https://www.github.com/libp2p/js-libp2p/compare/multidim-interop-v1.0.2...multidim-interop-v1.0.3) (2023-09-20)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/webrtc bumped from ^3.1.11 to ^3.2.0
+ * @libp2p/webtransport bumped from ^3.0.11 to ^3.1.0
+
+### [1.0.2](https://www.github.com/libp2p/js-libp2p/compare/multidim-interop-v1.0.1...multidim-interop-v1.0.2) (2023-09-15)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/mplex bumped from ^9.0.0 to ^9.0.6
+ * @libp2p/tcp bumped from ^8.0.6 to ^8.0.7
+ * @libp2p/webrtc bumped from ^3.1.10 to ^3.1.11
+ * @libp2p/websockets bumped from ^7.0.6 to ^7.0.7
+ * @libp2p/webtransport bumped from ^3.0.10 to ^3.0.11
+ * libp2p bumped from ^0.46.10 to ^0.46.11
+
+### [1.0.1](https://www.github.com/libp2p/js-libp2p/compare/multidim-interop-v1.0.0...multidim-interop-v1.0.1) (2023-09-10)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/tcp bumped from ^8.0.0 to ^8.0.6
+ * @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
diff --git a/interop/README.md b/interop/README.md
index 2b6b88967e..9f77324dac 100644
--- a/interop/README.md
+++ b/interop/README.md
@@ -1,11 +1,11 @@
-# multidim-interop
+# @libp2p/multidim-interop
[](http://libp2p.io/)
[](https://discuss.libp2p.io)
[](https://codecov.io/gh/libp2p/js-libp2p)
[](https://github.com/libp2p/js-libp2p/actions/workflows/main.yml?query=branch%3Amaster)
-> Multidimension Interop Test
+> Multidimensional interop tests
## Table of contents
diff --git a/interop/package.json b/interop/package.json
index fe9df02039..3ab015c03a 100644
--- a/interop/package.json
+++ b/interop/package.json
@@ -1,7 +1,7 @@
{
- "name": "multidim-interop",
- "version": "1.0.0",
- "description": "Multidimension Interop Test",
+ "name": "@libp2p/multidim-interop",
+ "version": "1.0.6",
+ "description": "Multidimensional interop tests",
"author": "Glen De Cauwsemaecker / @marcopolo",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/interop#readme",
@@ -16,8 +16,18 @@
"types": "./dist/src/index.d.ts",
"files": [
"src",
+ "test",
"dist",
- "!dist/test",
+ ".aegir.js",
+ "BrowserDockerfile",
+ "chromium-version.json",
+ "Dockerfile",
+ "firefox-version.json",
+ "Makefile",
+ "node-version.json",
+ "relay.js",
+ "tsconfig.json",
+ "webkit-version.json",
"!**/*.tsbuildinfo"
],
"exports": {
@@ -29,6 +39,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -41,21 +52,18 @@
"dependencies": {
"@chainsafe/libp2p-noise": "^13.0.0",
"@chainsafe/libp2p-yamux": "^5.0.0",
- "@libp2p/mplex": "^9.0.0",
- "@libp2p/tcp": "^8.0.0",
- "@libp2p/webrtc": "^3.0.0",
- "@libp2p/websockets": "^7.0.0",
- "@libp2p/webtransport": "^3.0.0",
+ "@libp2p/mplex": "^9.0.8",
+ "@libp2p/tcp": "^8.0.9",
+ "@libp2p/webrtc": "^3.2.3",
+ "@libp2p/websockets": "^7.0.9",
+ "@libp2p/webtransport": "^3.1.3",
"@multiformats/mafmt": "^12.1.2",
"@multiformats/multiaddr": "^12.1.5",
- "libp2p": "^0.46.0",
+ "aegir": "^41.0.2",
+ "libp2p": "^0.46.14",
"redis": "^4.5.1"
},
- "devDependencies": {
- "aegir": "^40.0.8"
- },
"browser": {
"@libp2p/tcp": false
- },
- "private": true
+ }
}
diff --git a/package.json b/package.json
index b36a7e5759..bb6e033168 100644
--- a/package.json
+++ b/package.json
@@ -33,11 +33,11 @@
"release": "run-s build docs:no-publish npm:release docs",
"npm:release": "aegir exec --bail false npm -- publish",
"release:rc": "aegir release-rc",
- "docs": "NODE_OPTIONS=--max_old_space_size=8192 aegir docs -- --exclude interop --exclude examples --exclude doc",
- "docs:no-publish": "NODE_OPTIONS=--max_old_space_size=8192 aegir docs --publish false -- --exclude interop --exclude examples --exclude doc"
+ "docs": "NODE_OPTIONS=--max_old_space_size=8192 aegir docs -- --exclude interop --exclude examples/auto-relay --exclude examples/chat --exclude examples/connection-encryption --exclude examples/delegated-routing --exclude examples/discovery-mechanisms --exclude examples/echo --exclude examples/peer-and-content-routing --exclude examples/pnet --exclude examples/protocol-and-stream-muxing --exclude examples/pubsub --exclude examples/transports --exclude doc",
+ "docs:no-publish": "NODE_OPTIONS=--max_old_space_size=8192 aegir docs --publish false -- --exclude interop --exclude examples/auto-relay --exclude examples/chat --exclude examples/connection-encryption --exclude examples/delegated-routing --exclude examples/discovery-mechanisms --exclude examples/echo --exclude examples/peer-and-content-routing --exclude examples/pnet --exclude examples/protocol-and-stream-muxing --exclude examples/pubsub --exclude examples/transports --exclude doc"
},
"devDependencies": {
- "aegir": "^40.0.1"
+ "aegir": "^41.0.2"
},
"eslintConfig": {
"extends": "ipfs",
diff --git a/packages/crypto/CHANGELOG.md b/packages/crypto/CHANGELOG.md
index f62cdad420..4f89fc5f0e 100644
--- a/packages/crypto/CHANGELOG.md
+++ b/packages/crypto/CHANGELOG.md
@@ -5,6 +5,22 @@
* **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))
+### [2.0.5](https://www.github.com/libp2p/js-libp2p/compare/crypto-v2.0.4...crypto-v2.0.5) (2023-10-06)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/interface bumped from ^0.1.2 to ^0.1.3
+
+### [2.0.4](https://www.github.com/libp2p/js-libp2p/compare/crypto-v2.0.3...crypto-v2.0.4) (2023-09-15)
+
+
+### Bug Fixes
+
+* **@libp2p/crypto:** improve unsupported key type message ([#2051](https://www.github.com/libp2p/js-libp2p/issues/2051)) ([d9159dd](https://www.github.com/libp2p/js-libp2p/commit/d9159dd5985241160f791acda164bb2e6408dd90))
+
### [2.0.3](https://www.github.com/libp2p/js-libp2p/compare/crypto-v2.0.2...crypto-v2.0.3) (2023-08-14)
@@ -789,4 +805,4 @@ chore: update deps
### Features
-* **keys:** implement generateKeyPairFromSeed for ed25519 ([e5b7c1f](https://github.com/libp2p/js-libp2p-crypto/commit/e5b7c1f))
\ No newline at end of file
+* **keys:** implement generateKeyPairFromSeed for ed25519 ([e5b7c1f](https://github.com/libp2p/js-libp2p-crypto/commit/e5b7c1f))
diff --git a/packages/crypto/package.json b/packages/crypto/package.json
index d359659805..785f3f720d 100644
--- a/packages/crypto/package.json
+++ b/packages/crypto/package.json
@@ -1,6 +1,6 @@
{
"name": "@libp2p/crypto",
- "version": "2.0.3",
+ "version": "2.0.5",
"description": "Crypto primitives for libp2p",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/crypto#readme",
@@ -63,6 +63,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
},
"ignorePatterns": [
@@ -85,7 +86,7 @@
"generate": "protons ./src/keys/keys.proto"
},
"dependencies": {
- "@libp2p/interface": "^0.1.2",
+ "@libp2p/interface": "^0.1.3",
"@noble/curves": "^1.1.0",
"@noble/hashes": "^1.3.1",
"multiformats": "^12.0.1",
@@ -96,7 +97,7 @@
},
"devDependencies": {
"@types/mocha": "^10.0.0",
- "aegir": "^40.0.8",
+ "aegir": "^41.0.2",
"benchmark": "^2.1.4",
"protons": "^7.0.2"
},
diff --git a/packages/crypto/src/aes/ciphers-browser.ts b/packages/crypto/src/aes/ciphers-browser.ts
index f78388f721..da94b50857 100644
--- a/packages/crypto/src/aes/ciphers-browser.ts
+++ b/packages/crypto/src/aes/ciphers-browser.ts
@@ -5,7 +5,7 @@ import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
export interface Cipher {
- update: (data: Uint8Array) => Uint8Array
+ update(data: Uint8Array): Uint8Array
}
export function createCipheriv (mode: any, key: Uint8Array, iv: Uint8Array): Cipher {
diff --git a/packages/crypto/src/aes/index.ts b/packages/crypto/src/aes/index.ts
index b10b108747..cf1dd8b875 100644
--- a/packages/crypto/src/aes/index.ts
+++ b/packages/crypto/src/aes/index.ts
@@ -2,8 +2,8 @@ import { cipherMode } from './cipher-mode.js'
import * as ciphers from './ciphers.js'
export interface AESCipher {
- encrypt: (data: Uint8Array) => Promise
- decrypt: (data: Uint8Array) => Promise
+ encrypt(data: Uint8Array): Promise
+ decrypt(data: Uint8Array): Promise
}
export async function create (key: Uint8Array, iv: Uint8Array): Promise {
diff --git a/packages/crypto/src/ciphers/interface.ts b/packages/crypto/src/ciphers/interface.ts
index f4258e11db..9f30045bf6 100644
--- a/packages/crypto/src/ciphers/interface.ts
+++ b/packages/crypto/src/ciphers/interface.ts
@@ -9,6 +9,6 @@ export interface CreateOptions {
}
export interface AESCipher {
- encrypt: (data: Uint8Array, password: string | Uint8Array) => Promise
- decrypt: (data: Uint8Array, password: string | Uint8Array) => Promise
+ encrypt(data: Uint8Array, password: string | Uint8Array): Promise
+ decrypt(data: Uint8Array, password: string | Uint8Array): Promise
}
diff --git a/packages/crypto/src/hmac/index-browser.ts b/packages/crypto/src/hmac/index-browser.ts
index 683d130ae1..69d7947d9e 100644
--- a/packages/crypto/src/hmac/index-browser.ts
+++ b/packages/crypto/src/hmac/index-browser.ts
@@ -12,7 +12,7 @@ const sign = async (key: CryptoKey, data: Uint8Array): Promise => {
return new Uint8Array(buf, 0, buf.byteLength)
}
-export async function create (hashType: 'SHA1' | 'SHA256' | 'SHA512', secret: Uint8Array): Promise<{ digest: (data: Uint8Array) => Promise, length: number }> {
+export async function create (hashType: 'SHA1' | 'SHA256' | 'SHA512', secret: Uint8Array): Promise<{ digest(data: Uint8Array): Promise, length: number }> {
const hash = hashTypes[hashType]
const key = await webcrypto.get().subtle.importKey(
diff --git a/packages/crypto/src/hmac/index.ts b/packages/crypto/src/hmac/index.ts
index b3d7689168..dc2ec68894 100644
--- a/packages/crypto/src/hmac/index.ts
+++ b/packages/crypto/src/hmac/index.ts
@@ -2,7 +2,7 @@ import crypto from 'crypto'
import lengths from './lengths.js'
export interface HMAC {
- digest: (data: Uint8Array) => Promise
+ digest(data: Uint8Array): Promise
length: number
}
diff --git a/packages/crypto/src/keys/index.ts b/packages/crypto/src/keys/index.ts
index 3b50a33b2e..d8192d5abb 100644
--- a/packages/crypto/src/keys/index.ts
+++ b/packages/crypto/src/keys/index.ts
@@ -69,7 +69,7 @@ export function unmarshalPublicKey (buf: Uint8Array): PublicKey {
case keysPBM.KeyType.Secp256k1:
return supportedKeys.secp256k1.unmarshalSecp256k1PublicKey(data)
default:
- throw unsupportedKey(decoded.Type ?? 'RSA')
+ throw unsupportedKey(decoded.Type ?? 'unknown')
}
}
diff --git a/packages/crypto/src/keys/interface.ts b/packages/crypto/src/keys/interface.ts
index 4630df6a49..2cbfd5a12b 100644
--- a/packages/crypto/src/keys/interface.ts
+++ b/packages/crypto/src/keys/interface.ts
@@ -15,7 +15,7 @@ export interface ECDHKeyPair {
export interface ECDHKey {
key: Uint8Array
- genSharedKey: (theirPub: Uint8Array, forcePrivate?: ECDHKeyPair) => Promise
+ genSharedKey(theirPub: Uint8Array, forcePrivate?: ECDHKeyPair): Promise
}
export interface JWKEncodedPublicKey { kty: string, crv: 'P-256' | 'P-384' | 'P-521', x: string, y: string, ext: boolean }
diff --git a/packages/crypto/src/keys/jwk2pem.ts b/packages/crypto/src/keys/jwk2pem.ts
index 64feebc188..d827f282d9 100644
--- a/packages/crypto/src/keys/jwk2pem.ts
+++ b/packages/crypto/src/keys/jwk2pem.ts
@@ -4,8 +4,8 @@ import forge from 'node-forge/lib/forge.js'
import { base64urlToBigInteger } from '../util.js'
export interface JWK {
- encrypt: (msg: string) => string
- decrypt: (msg: string) => string
+ encrypt(msg: string): string
+ decrypt(msg: string): string
}
function convert (key: any, types: string[]): Array {
diff --git a/packages/crypto/src/keys/rsa-browser.ts b/packages/crypto/src/keys/rsa-browser.ts
index 2f0e0c04b1..0e88e75c55 100644
--- a/packages/crypto/src/keys/rsa-browser.ts
+++ b/packages/crypto/src/keys/rsa-browser.ts
@@ -141,7 +141,7 @@ Explanation:
*/
-function convertKey (key: JsonWebKey, pub: boolean, msg: Uint8Array, handle: (msg: string, key: { encrypt: (msg: string) => string, decrypt: (msg: string) => string }) => string): Uint8Array {
+function convertKey (key: JsonWebKey, pub: boolean, msg: Uint8Array, handle: (msg: string, key: { encrypt(msg: string): string, decrypt(msg: string): string }) => string): Uint8Array {
const fkey = pub ? jwk2pub(key) : jwk2priv(key)
const fmsg = uint8ArrayToString(Uint8Array.from(msg), 'ascii')
const fomsg = handle(fmsg, fkey)
diff --git a/packages/crypto/src/util.ts b/packages/crypto/src/util.ts
index e0bab8c5ff..0dab953f8a 100644
--- a/packages/crypto/src/util.ts
+++ b/packages/crypto/src/util.ts
@@ -6,7 +6,7 @@ import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { toString as uint8ArrayToString } from 'uint8arrays/to-string'
-export function bigIntegerToUintBase64url (num: { abs: () => any }, len?: number): string {
+export function bigIntegerToUintBase64url (num: { abs(): any }, len?: number): string {
// Call `.abs()` to convert to unsigned
let buf = Uint8Array.from(num.abs().toByteArray()) // toByteArray converts to big endian
diff --git a/packages/interface-compliance-tests/CHANGELOG.md b/packages/interface-compliance-tests/CHANGELOG.md
index e27331502b..a9ef37cb25 100644
--- a/packages/interface-compliance-tests/CHANGELOG.md
+++ b/packages/interface-compliance-tests/CHANGELOG.md
@@ -5,6 +5,46 @@
* 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))
+### [4.1.1](https://www.github.com/libp2p/js-libp2p/compare/interface-compliance-tests-v4.1.0...interface-compliance-tests-v4.1.1) (2023-10-06)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/interface bumped from ^0.1.2 to ^0.1.3
+ * @libp2p/interface-internal bumped from ^0.1.5 to ^0.1.6
+ * @libp2p/logger bumped from ^3.0.2 to ^3.0.3
+ * @libp2p/multistream-select bumped from ^4.0.2 to ^4.0.3
+ * @libp2p/peer-collections bumped from ^4.0.4 to ^4.0.5
+ * @libp2p/peer-id bumped from ^3.0.2 to ^3.0.3
+ * @libp2p/peer-id-factory bumped from ^3.0.4 to ^3.0.5
+
+## [4.1.0](https://www.github.com/libp2p/js-libp2p/compare/interface-compliance-tests-v4.0.6...interface-compliance-tests-v4.1.0) (2023-10-01)
+
+
+### Features
+
+* add mock stream pair ([#2069](https://www.github.com/libp2p/js-libp2p/issues/2069)) ([e3ab192](https://www.github.com/libp2p/js-libp2p/commit/e3ab1929b505df6d50b5a6ddc50cd2669f54b894))
+
+### [4.0.6](https://www.github.com/libp2p/js-libp2p/compare/interface-compliance-tests-v4.0.5...interface-compliance-tests-v4.0.6) (2023-09-15)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/interface-internal bumped from ^0.1.4 to ^0.1.5
+ * @libp2p/peer-collections bumped from ^4.0.3 to ^4.0.4
+ * @libp2p/peer-id-factory bumped from ^3.0.3 to ^3.0.4
+
+### [4.0.5](https://www.github.com/libp2p/js-libp2p/compare/interface-compliance-tests-v4.0.4...interface-compliance-tests-v4.0.5) (2023-08-25)
+
+
+### Bug Fixes
+
+* **@libp2p/interface-compliance-tests:** add aegir to deps ([#1983](https://www.github.com/libp2p/js-libp2p/issues/1983)) ([8977862](https://www.github.com/libp2p/js-libp2p/commit/89778624908a536e3253ee4fe1a0d287e1aad2e9)), closes [#1974](https://www.github.com/libp2p/js-libp2p/issues/1974)
+
### [4.0.4](https://www.github.com/libp2p/js-libp2p/compare/interface-compliance-tests-v4.0.3...interface-compliance-tests-v4.0.4) (2023-08-16)
diff --git a/packages/interface-compliance-tests/package.json b/packages/interface-compliance-tests/package.json
index 0864500c2d..f467311297 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.0.4",
+ "version": "4.1.1",
"description": "Compliance tests for JS libp2p interfaces",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/interface-compliance-tests#readme",
@@ -84,6 +84,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -102,15 +103,16 @@
"test:electron-main": "aegir test -t electron-main"
},
"dependencies": {
- "@libp2p/interface": "^0.1.2",
- "@libp2p/interface-internal": "^0.1.4",
- "@libp2p/logger": "^3.0.2",
- "@libp2p/multistream-select": "^4.0.2",
- "@libp2p/peer-collections": "^4.0.3",
- "@libp2p/peer-id": "^3.0.2",
- "@libp2p/peer-id-factory": "^3.0.3",
+ "@libp2p/interface": "^0.1.3",
+ "@libp2p/interface-internal": "^0.1.6",
+ "@libp2p/logger": "^3.0.3",
+ "@libp2p/multistream-select": "^4.0.3",
+ "@libp2p/peer-collections": "^4.0.5",
+ "@libp2p/peer-id": "^3.0.3",
+ "@libp2p/peer-id-factory": "^3.0.5",
"@multiformats/multiaddr": "^12.1.5",
"abortable-iterator": "^5.0.1",
+ "aegir": "^41.0.2",
"delay": "^6.0.0",
"it-all": "^3.0.2",
"it-drain": "^3.0.2",
@@ -129,12 +131,11 @@
"p-limit": "^4.0.0",
"p-wait-for": "^5.0.2",
"protons-runtime": "^5.0.0",
- "sinon": "^15.1.2",
+ "sinon": "^16.0.0",
"uint8arraylist": "^2.4.3",
"uint8arrays": "^4.0.6"
},
"devDependencies": {
- "aegir": "^40.0.8",
"protons": "^7.0.2"
}
}
diff --git a/packages/interface-compliance-tests/src/index.ts b/packages/interface-compliance-tests/src/index.ts
index e9f9db76b3..fec38b0660 100644
--- a/packages/interface-compliance-tests/src/index.ts
+++ b/packages/interface-compliance-tests/src/index.ts
@@ -1,4 +1,4 @@
export interface TestSetup> {
- setup: (args?: SetupArgs) => Promise
- teardown: () => Promise
+ setup(args?: SetupArgs): Promise
+ teardown(): Promise
}
diff --git a/packages/interface-compliance-tests/src/mocks/connection.ts b/packages/interface-compliance-tests/src/mocks/connection.ts
index 566de6d05c..8b1607d2ad 100644
--- a/packages/interface-compliance-tests/src/mocks/connection.ts
+++ b/packages/interface-compliance-tests/src/mocks/connection.ts
@@ -170,7 +170,13 @@ export function mockConnection (maConn: MultiaddrConnection, opts: MockConnectio
return connection
}
-export function mockStream (stream: Duplex, Source, Promise>): Stream {
+export interface StreamInit {
+ direction?: Direction
+ protocol?: string
+ id?: string
+}
+
+export function mockStream (stream: Duplex, Source, Promise>, init: StreamInit = {}): Stream {
return {
...stream,
close: async () => {},
@@ -186,10 +192,31 @@ export function mockStream (stream: Duplex, Sourc
id: `stream-${Date.now()}`,
status: 'open',
readStatus: 'ready',
- writeStatus: 'ready'
+ writeStatus: 'ready',
+ ...init
}
}
+export interface StreamPairInit {
+ duplex: Duplex, Source, Promise>
+ init?: StreamInit
+}
+
+export function streamPair (a: StreamPairInit, b: StreamPairInit, init: StreamInit = {}): [Stream, Stream] {
+ return [
+ mockStream(a.duplex, {
+ direction: 'outbound',
+ ...init,
+ ...(a.init ?? {})
+ }),
+ mockStream(b.duplex, {
+ direction: 'inbound',
+ ...init,
+ ...(b.init ?? {})
+ })
+ ]
+}
+
export interface Peer {
peerId: PeerId
registrar: Registrar
diff --git a/packages/interface-compliance-tests/src/mocks/index.ts b/packages/interface-compliance-tests/src/mocks/index.ts
index 8b78f1f7f3..ffdef08ac3 100644
--- a/packages/interface-compliance-tests/src/mocks/index.ts
+++ b/packages/interface-compliance-tests/src/mocks/index.ts
@@ -1,7 +1,7 @@
export { mockConnectionEncrypter } from './connection-encrypter.js'
export { mockConnectionGater } from './connection-gater.js'
export { mockConnectionManager, mockNetwork } from './connection-manager.js'
-export { mockConnection, mockStream, connectionPair } from './connection.js'
+export { mockConnection, mockStream, streamPair, connectionPair } from './connection.js'
export { mockMultiaddrConnection, mockMultiaddrConnPair } from './multiaddr-connection.js'
export { mockMuxer } from './muxer.js'
export { mockRegistrar } from './registrar.js'
diff --git a/packages/interface-compliance-tests/src/transport/index.ts b/packages/interface-compliance-tests/src/transport/index.ts
index d2b9525687..c0a5a6ed11 100644
--- a/packages/interface-compliance-tests/src/transport/index.ts
+++ b/packages/interface-compliance-tests/src/transport/index.ts
@@ -6,8 +6,8 @@ import type { Transport } from '@libp2p/interface/transport'
import type { Multiaddr } from '@multiformats/multiaddr'
export interface Connector {
- delay: (ms: number) => void
- restore: () => void
+ delay(ms: number): void
+ restore(): void
}
export interface TransportTestFixtures {
diff --git a/packages/interface-internal/CHANGELOG.md b/packages/interface-internal/CHANGELOG.md
index 94ee19579a..4d159c1220 100644
--- a/packages/interface-internal/CHANGELOG.md
+++ b/packages/interface-internal/CHANGELOG.md
@@ -1,5 +1,24 @@
# Changelog
+### [0.1.6](https://www.github.com/libp2p/js-libp2p/compare/interface-internal-v0.1.5...interface-internal-v0.1.6) (2023-10-06)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/interface bumped from ^0.1.2 to ^0.1.3
+ * @libp2p/peer-collections bumped from ^4.0.4 to ^4.0.5
+
+### [0.1.5](https://www.github.com/libp2p/js-libp2p/compare/interface-internal-v0.1.4...interface-internal-v0.1.5) (2023-09-15)
+
+
+### Dependencies
+
+* The following workspace dependencies were updated
+ * dependencies
+ * @libp2p/peer-collections bumped from ^4.0.3 to ^4.0.4
+
### [0.1.4](https://www.github.com/libp2p/js-libp2p/compare/interface-internal-v0.1.3...interface-internal-v0.1.4) (2023-08-16)
diff --git a/packages/interface-internal/package.json b/packages/interface-internal/package.json
index 8774b5c944..f8ea476d52 100644
--- a/packages/interface-internal/package.json
+++ b/packages/interface-internal/package.json
@@ -1,6 +1,6 @@
{
"name": "@libp2p/interface-internal",
- "version": "0.1.4",
+ "version": "0.1.6",
"description": "Interfaces implemented by internal libp2p components",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/interface-internal#readme",
@@ -68,6 +68,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -78,12 +79,12 @@
"build": "aegir build"
},
"dependencies": {
- "@libp2p/interface": "^0.1.2",
- "@libp2p/peer-collections": "^4.0.3",
+ "@libp2p/interface": "^0.1.3",
+ "@libp2p/peer-collections": "^4.0.5",
"@multiformats/multiaddr": "^12.1.5",
"uint8arraylist": "^2.4.3"
},
"devDependencies": {
- "aegir": "^40.0.8"
+ "aegir": "^41.0.2"
}
}
diff --git a/packages/interface-internal/src/address-manager/index.ts b/packages/interface-internal/src/address-manager/index.ts
index 622e0cb315..89b4231cca 100644
--- a/packages/interface-internal/src/address-manager/index.ts
+++ b/packages/interface-internal/src/address-manager/index.ts
@@ -4,40 +4,40 @@ export interface AddressManager {
/**
* Get peer listen multiaddrs
*/
- getListenAddrs: () => Multiaddr[]
+ getListenAddrs(): Multiaddr[]
/**
* Get peer announcing multiaddrs
*/
- getAnnounceAddrs: () => Multiaddr[]
+ getAnnounceAddrs(): Multiaddr[]
/**
* Get observed multiaddrs - these addresses may not have been confirmed as
* publicly dialable yet
*/
- getObservedAddrs: () => Multiaddr[]
+ getObservedAddrs(): Multiaddr[]
/**
* Signal that we have confidence an observed multiaddr is publicly dialable -
* this will make it appear in the output of getAddresses()
*/
- confirmObservedAddr: (addr: Multiaddr) => void
+ confirmObservedAddr(addr: Multiaddr): void
/**
* Signal that we do not have confidence an observed multiaddr is publicly dialable -
* this will remove it from the output of getObservedAddrs()
*/
- removeObservedAddr: (addr: Multiaddr) => void
+ removeObservedAddr(addr: Multiaddr): void
/**
* Add peer observed addresses. These will then appear in the output of getObservedAddrs
* but not getAddresses() until their dialability has been confirmed via a call to
* confirmObservedAddr.
*/
- addObservedAddr: (addr: Multiaddr) => void
+ addObservedAddr(addr: Multiaddr): void
/**
* Get the current node's addresses
*/
- getAddresses: () => Multiaddr[]
+ getAddresses(): Multiaddr[]
}
diff --git a/packages/interface-internal/src/connection-manager/index.ts b/packages/interface-internal/src/connection-manager/index.ts
index 74d7119179..66051b4e41 100644
--- a/packages/interface-internal/src/connection-manager/index.ts
+++ b/packages/interface-internal/src/connection-manager/index.ts
@@ -30,7 +30,7 @@ export interface ConnectionManager {
* // []
* ```
*/
- getConnections: (peerId?: PeerId) => Connection[]
+ getConnections(peerId?: PeerId): Connection[]
/**
* Return a map of all connections with their associated PeerIds
@@ -41,7 +41,7 @@ export interface ConnectionManager {
* const connectionsMap = libp2p.connectionManager.getConnectionsMap()
* ```
*/
- getConnectionsMap: () => PeerMap
+ getConnectionsMap(): PeerMap
/**
* Open a connection to a remote peer
@@ -52,12 +52,12 @@ export interface ConnectionManager {
* const connection = await libp2p.connectionManager.openConnection(peerId)
* ```
*/
- openConnection: (peer: PeerId | Multiaddr | Multiaddr[], options?: OpenConnectionOptions) => Promise
+ openConnection(peer: PeerId | Multiaddr | Multiaddr[], options?: OpenConnectionOptions): Promise
/**
* Close our connections to a peer
*/
- closeConnections: (peer: PeerId, options?: AbortOptions) => Promise
+ closeConnections(peer: PeerId, options?: AbortOptions): Promise
/**
* Invoked after an incoming connection is opened but before PeerIds are
@@ -65,12 +65,12 @@ export interface ConnectionManager {
* resources to accept the connection in which case it will return true,
* otherwise it will return false.
*/
- acceptIncomingConnection: (maConn: MultiaddrConnection) => Promise
+ acceptIncomingConnection(maConn: MultiaddrConnection): Promise
/**
* Invoked after upgrading a multiaddr connection has finished
*/
- afterUpgradeInbound: () => void
+ afterUpgradeInbound(): void
/**
* Return the list of in-progress or queued dials
@@ -81,5 +81,5 @@ export interface ConnectionManager {
* const dials = libp2p.connectionManager.getDialQueue()
* ```
*/
- getDialQueue: () => PendingDial[]
+ getDialQueue(): PendingDial[]
}
diff --git a/packages/interface-internal/src/record/index.ts b/packages/interface-internal/src/record/index.ts
index 1005ba0d02..ff27b0460b 100644
--- a/packages/interface-internal/src/record/index.ts
+++ b/packages/interface-internal/src/record/index.ts
@@ -16,11 +16,11 @@ export interface Record {
/**
* Marshal a record to be used in an envelope.
*/
- marshal: () => Uint8Array
+ marshal(): Uint8Array
/**
* Verifies if the other provided Record is identical to this one.
*/
- equals: (other: Record) => boolean
+ equals(other: Record): boolean
}
export interface Envelope {
@@ -29,7 +29,7 @@ export interface Envelope {
payload: Uint8Array
signature: Uint8Array | Uint8ArrayList
- marshal: () => Uint8Array
- validate: (domain: string) => Promise
- equals: (other: Envelope) => boolean
+ marshal(): Uint8Array
+ validate(domain: string): Promise
+ equals(other: Envelope): boolean
}
diff --git a/packages/interface-internal/src/registrar/index.ts b/packages/interface-internal/src/registrar/index.ts
index a833cf7940..52db9d5b3e 100644
--- a/packages/interface-internal/src/registrar/index.ts
+++ b/packages/interface-internal/src/registrar/index.ts
@@ -38,22 +38,22 @@ export interface Registrar {
/**
* Return the list of protocols with registered handlers
*/
- getProtocols: () => string[]
+ getProtocols(): string[]
/**
* Add a protocol handler
*/
- handle: (protocol: string, handler: StreamHandler, options?: StreamHandlerOptions) => Promise
+ handle(protocol: string, handler: StreamHandler, options?: StreamHandlerOptions): Promise
/**
* Remove a protocol handler
*/
- unhandle: (protocol: string) => Promise
+ unhandle(protocol: string): Promise
/**
* Return the handler for the passed protocol
*/
- getHandler: (protocol: string) => StreamHandlerRecord
+ getHandler(protocol: string): StreamHandlerRecord
/**
* Register a topology handler for a protocol - the topology will be
@@ -63,16 +63,16 @@ export interface Registrar {
* An id will be returned that can later be used to unregister the
* topology.
*/
- register: (protocol: string, topology: Topology) => Promise
+ register(protocol: string, topology: Topology): Promise
/**
* Remove the topology handler with the passed id.
*/
- unregister: (id: string) => void
+ unregister(id: string): void
/**
* Return all topology handlers that wish to be informed about peers
* that support the passed protocol.
*/
- getTopologies: (protocol: string) => Topology[]
+ getTopologies(protocol: string): Topology[]
}
diff --git a/packages/interface-internal/src/transport-manager/index.ts b/packages/interface-internal/src/transport-manager/index.ts
index b649969be2..a905d2a14b 100644
--- a/packages/interface-internal/src/transport-manager/index.ts
+++ b/packages/interface-internal/src/transport-manager/index.ts
@@ -3,13 +3,13 @@ import type { Listener, Transport } from '@libp2p/interface/transport'
import type { Multiaddr } from '@multiformats/multiaddr'
export interface TransportManager {
- add: (transport: Transport) => void
- dial: (ma: Multiaddr, options?: any) => Promise
- getAddrs: () => Multiaddr[]
- getTransports: () => Transport[]
- getListeners: () => Listener[]
- transportForMultiaddr: (ma: Multiaddr) => Transport | undefined
- listen: (addrs: Multiaddr[]) => Promise
- remove: (key: string) => Promise
- removeAll: () => Promise
+ add(transport: Transport): void
+ dial(ma: Multiaddr, options?: any): Promise
+ getAddrs(): Multiaddr[]
+ getTransports(): Transport[]
+ getListeners(): Listener[]
+ transportForMultiaddr(ma: Multiaddr): Transport | undefined
+ listen(addrs: Multiaddr[]): Promise
+ remove(key: string): Promise
+ removeAll(): Promise
}
diff --git a/packages/interface/CHANGELOG.md b/packages/interface/CHANGELOG.md
index 5173192b24..145ba5c8bc 100644
--- a/packages/interface/CHANGELOG.md
+++ b/packages/interface/CHANGELOG.md
@@ -5,6 +5,13 @@
* 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))
+### [0.1.3](https://www.github.com/libp2p/js-libp2p/compare/interface-v0.1.2...interface-v0.1.3) (2023-10-06)
+
+
+### Bug Fixes
+
+* close webrtc streams without data loss ([#2073](https://www.github.com/libp2p/js-libp2p/issues/2073)) ([7d8b155](https://www.github.com/libp2p/js-libp2p/commit/7d8b15517a480e01a8ebd427ab0093509b78d5b0))
+
### [0.1.2](https://www.github.com/libp2p/js-libp2p/compare/interface-v0.1.1...interface-v0.1.2) (2023-08-14)
diff --git a/packages/interface/package.json b/packages/interface/package.json
index 194b1e40f4..801c1023a2 100644
--- a/packages/interface/package.json
+++ b/packages/interface/package.json
@@ -1,6 +1,6 @@
{
"name": "@libp2p/interface",
- "version": "0.1.2",
+ "version": "0.1.3",
"description": "The interface implemented by a libp2p node",
"license": "Apache-2.0 OR MIT",
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/interface#readme",
@@ -140,6 +140,7 @@
"eslintConfig": {
"extends": "ipfs",
"parserOptions": {
+ "project": true,
"sourceType": "module"
}
},
@@ -164,12 +165,16 @@
"multiformats": "^12.0.1",
"p-defer": "^4.0.0",
"progress-events": "^1.0.0",
+ "race-signal": "^1.0.0",
"uint8arraylist": "^2.4.3"
},
"devDependencies": {
"@types/sinon": "^10.0.15",
- "aegir": "^40.0.8",
- "sinon": "^15.1.2",
+ "aegir": "^41.0.2",
+ "delay": "^6.0.0",
+ "it-all": "^3.0.3",
+ "it-drain": "^3.0.3",
+ "sinon": "^16.0.0",
"sinon-ts": "^1.0.0"
}
}
diff --git a/packages/interface/src/connection-encrypter/index.ts b/packages/interface/src/connection-encrypter/index.ts
index 0a4245db33..7faf799953 100644
--- a/packages/interface/src/connection-encrypter/index.ts
+++ b/packages/interface/src/connection-encrypter/index.ts
@@ -13,14 +13,14 @@ export interface ConnectionEncrypter {
* pass it for extra verification, otherwise it will be determined during
* the handshake.
*/
- secureOutbound: (localPeer: PeerId, connection: Duplex, Source, Promise>, remotePeer?: PeerId) => Promise>
+ secureOutbound(localPeer: PeerId, connection: Duplex, Source, Promise>, remotePeer?: PeerId): Promise>
/**
* Decrypt incoming data. If the remote PeerId is known,
* pass it for extra verification, otherwise it will be determined during
* the handshake
*/
- secureInbound: (localPeer: PeerId, connection: Duplex, Source, Promise>, remotePeer?: PeerId) => Promise>
+ secureInbound(localPeer: PeerId, connection: Duplex, Source, Promise>, remotePeer?: PeerId): Promise>
}
export interface SecuredConnection {
diff --git a/packages/interface/src/connection-gater/index.ts b/packages/interface/src/connection-gater/index.ts
index 4d85f5806a..1b59de4f38 100644
--- a/packages/interface/src/connection-gater/index.ts
+++ b/packages/interface/src/connection-gater/index.ts
@@ -12,7 +12,7 @@ export interface ConnectionGater {
*
* Return true to prevent dialing the passed peer.
*/
- denyDialPeer?: (peerId: PeerId) => Promise
+ denyDialPeer?(peerId: PeerId): Promise
/**
* denyDialMultiaddr tests whether we're permitted to dial the specified
@@ -23,7 +23,7 @@ export interface ConnectionGater {
*
* Return true to prevent dialing the passed peer on the passed multiaddr.
*/
- denyDialMultiaddr?: (multiaddr: Multiaddr) => Promise
+ denyDialMultiaddr?(multiaddr: Multiaddr): Promise
/**
* denyInboundConnection tests whether an incipient inbound connection is allowed.
@@ -33,7 +33,7 @@ export interface ConnectionGater {
*
* Return true to deny the incoming passed connection.
*/
- denyInboundConnection?: (maConn: MultiaddrConnection) => Promise
+ denyInboundConnection?(maConn: MultiaddrConnection): Promise
/**
* denyOutboundConnection tests whether an incipient outbound connection is allowed.
@@ -43,7 +43,7 @@ export interface ConnectionGater {
*
* Return true to deny the incoming passed connection.
*/
- denyOutboundConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise
+ denyOutboundConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise
/**
* denyInboundEncryptedConnection tests whether a given connection, now encrypted,
@@ -55,7 +55,7 @@ export interface ConnectionGater {
*
* Return true to deny the passed secured connection.
*/
- denyInboundEncryptedConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise
+ denyInboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise
/**
* denyOutboundEncryptedConnection tests whether a given connection, now encrypted,
@@ -67,7 +67,7 @@ export interface ConnectionGater {
*
* Return true to deny the passed secured connection.
*/
- denyOutboundEncryptedConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise
+ denyOutboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise
/**
* denyInboundUpgradedConnection tests whether a fully capable connection is allowed.
@@ -77,7 +77,7 @@ export interface ConnectionGater {
*
* Return true to deny the passed upgraded connection.
*/
- denyInboundUpgradedConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise
+ denyInboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise
/**
* denyOutboundUpgradedConnection tests whether a fully capable connection is allowed.
@@ -87,7 +87,7 @@ export interface ConnectionGater {
*
* Return true to deny the passed upgraded connection.
*/
- denyOutboundUpgradedConnection?: (peerId: PeerId, maConn: MultiaddrConnection) => Promise
+ denyOutboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise
/**
* denyInboundRelayReservation tests whether a remote peer is allowed make a
@@ -95,7 +95,7 @@ export interface ConnectionGater {
*
* Return true to deny the relay reservation.
*/
- denyInboundRelayReservation?: (source: PeerId) => Promise
+ denyInboundRelayReservation?(source: PeerId): Promise
/**
* denyOutboundRelayedConnection tests whether a remote peer is allowed to open a relayed
@@ -106,7 +106,7 @@ export interface ConnectionGater {
*
* Return true to deny the relayed connection.
*/
- denyOutboundRelayedConnection?: (source: PeerId, destination: PeerId) => Promise
+ denyOutboundRelayedConnection?(source: PeerId, destination: PeerId): Promise
/**
* denyInboundRelayedConnection tests whether a remote peer is allowed to open a relayed
@@ -117,12 +117,12 @@ export interface ConnectionGater {
*
* Return true to deny the relayed connection.
*/
- denyInboundRelayedConnection?: (relay: PeerId, remotePeer: PeerId) => Promise
+ denyInboundRelayedConnection?(relay: PeerId, remotePeer: PeerId): Promise
/**
* Used by the address book to filter passed addresses.
*
* Return true to allow storing the passed multiaddr for the passed peer.
*/
- filterMultiaddrForPeer?: (peer: PeerId, multiaddr: Multiaddr) => Promise
+ filterMultiaddrForPeer?(peer: PeerId, multiaddr: Multiaddr): Promise
}
diff --git a/packages/interface/src/connection/index.ts b/packages/interface/src/connection/index.ts
index 2bed6736a1..684a2b9adb 100644
--- a/packages/interface/src/connection/index.ts
+++ b/packages/interface/src/connection/index.ts
@@ -101,7 +101,7 @@ export interface Stream extends Duplex, Source Promise
+ close(options?: AbortOptions): Promise
/**
* Closes the stream for **reading**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
@@ -110,14 +110,14 @@ export interface Stream extends Duplex, Source Promise
+ closeRead(options?: AbortOptions): Promise
/**
* Closes the stream for **writing**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
*
* The source will return normally, the sink will continue to consume.
*/
- closeWrite: (options?: AbortOptions) => Promise
+ closeWrite(options?: AbortOptions): Promise
/**
* Closes the stream for **reading** *and* **writing**. This should be called when a *local error* has occurred.
@@ -128,7 +128,7 @@ export interface Stream extends Duplex, Source void
+ abort(err: Error): void
/**
* Unique identifier for a stream. Identifiers are not unique across muxers.
@@ -146,7 +146,7 @@ export interface Stream extends Duplex, Source Promise
+ newStream(protocols: string | string[], options?: NewStreamOptions): Promise
/**
* Gracefully close the connection. All queued data will be written to the
* underlying transport.
*/
- close: (options?: AbortOptions) => Promise
+ close(options?: AbortOptions): Promise
/**
* Immediately close the connection, any queued data will be discarded
*/
- abort: (err: Error) => void
+ abort(err: Error): void
}
export const symbol = Symbol.for('@libp2p/connection')
@@ -282,7 +282,7 @@ export interface ConnectionProtector {
* between its two peers from the PSK the Protector instance was
* created with.
*/
- protect: (connection: MultiaddrConnection) => Promise
+ protect(connection: MultiaddrConnection): Promise
}
export interface MultiaddrConnectionTimeline {
@@ -313,12 +313,12 @@ export interface MultiaddrConnection extends Duplex,
* Gracefully close the connection. All queued data will be written to the
* underlying transport.
*/
- close: (options?: AbortOptions) => Promise
+ close(options?: AbortOptions): Promise
/**
* Immediately close the connection, any queued data will be discarded
*/
- abort: (err: Error) => void
+ abort(err: Error): void
/**
* The address of the remote end of the connection
diff --git a/packages/interface/src/content-routing/index.ts b/packages/interface/src/content-routing/index.ts
index 7f094d3fab..0cfa498605 100644
--- a/packages/interface/src/content-routing/index.ts
+++ b/packages/interface/src/content-routing/index.ts
@@ -41,7 +41,7 @@ export interface ContentRouting<
* await contentRouting.provide(cid)
* ```
*/
- provide: (cid: CID, options?: AbortOptions & ProgressOptions) => Promise
+ provide(cid: CID, options?: AbortOptions & ProgressOptions): Promise
/**
* Find the providers of the passed CID.
@@ -55,7 +55,7 @@ export interface ContentRouting<
* }
* ```
*/
- findProviders: (cid: CID, options?: AbortOptions & ProgressOptions) => AsyncIterable
+ findProviders(cid: CID, options?: AbortOptions & ProgressOptions): AsyncIterable
/**
* Puts a value corresponding to the passed key in a way that can later be
@@ -71,7 +71,7 @@ export interface ContentRouting<
* await contentRouting.put(key, value)
* ```
*/
- put: (key: Uint8Array, value: Uint8Array, options?: AbortOptions & ProgressOptions) => Promise
+ put(key: Uint8Array, value: Uint8Array, options?: AbortOptions & ProgressOptions): Promise
/**
* Retrieves a value from the network corresponding to the passed key.
@@ -85,5 +85,5 @@ export interface ContentRouting<
* const value = await contentRouting.get(key)
* ```
*/
- get: (key: Uint8Array, options?: AbortOptions & ProgressOptions) => Promise
+ get(key: Uint8Array, options?: AbortOptions & ProgressOptions): Promise
}
diff --git a/packages/interface/src/index.ts b/packages/interface/src/index.ts
index 5e5fb9b48d..8a59407c39 100644
--- a/packages/interface/src/index.ts
+++ b/packages/interface/src/index.ts
@@ -459,7 +459,7 @@ export interface Libp2p<
* // [ ]
* ```
*/
- getMultiaddrs: () => Multiaddr[]
+ getMultiaddrs(): Multiaddr[]
/**
* Returns a list of supported protocols
@@ -471,7 +471,7 @@ export interface Libp2p<
* // [ '/ipfs/ping/1.0.0', '/ipfs/id/1.0.0' ]
* ```
*/
- getProtocols: () => string[]
+ getProtocols(): string[]
/**
* Return a list of all connections this node has open, optionally filtering
@@ -486,7 +486,7 @@ export interface Libp2p<
* }
* ```
*/
- getConnections: (peerId?: PeerId) => Connection[]
+ getConnections(peerId?: PeerId): Connection[]
/**
* Return the list of dials currently in progress or queued to start
@@ -499,12 +499,12 @@ export interface Libp2p<
* }
* ```
*/
- getDialQueue: () => PendingDial[]
+ getDialQueue(): PendingDial[]
/**
* Return a list of all peers we currently have a connection open to
*/
- getPeers: () => PeerId[]
+ getPeers(): PeerId[]
/**
* Dials to the provided peer. If successful, the known metadata of the
@@ -526,7 +526,7 @@ export interface Libp2p<
* await conn.close()
* ```
*/
- dial: (peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions) => Promise
+ dial(peer: PeerId | Multiaddr | Multiaddr[], options?: AbortOptions): Promise
/**
* Dials to the provided peer and tries to handshake with the given protocols in order.
@@ -544,7 +544,7 @@ export interface Libp2p<
* pipe([1, 2, 3], stream, consume)
* ```
*/
- dialProtocol: (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: NewStreamOptions) => Promise
+ dialProtocol(peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: NewStreamOptions): Promise
/**
* Attempts to gracefully close an open connection to the given peer. If the
@@ -559,7 +559,7 @@ export interface Libp2p<
* await libp2p.hangUp(remotePeerId)
* ```
*/
- hangUp: (peer: PeerId | Multiaddr, options?: AbortOptions) => Promise
+ hangUp(peer: PeerId | Multiaddr, options?: AbortOptions): Promise
/**
* Sets up [multistream-select routing](https://github.com/multiformats/multistream-select) of protocols to their application handlers. Whenever a stream is opened on one of the provided protocols, the handler will be called. `handle` must be called in order to register a handler and support for a given protocol. This also informs other peers of the protocols you support.
@@ -581,7 +581,7 @@ export interface Libp2p<
* })
* ```
*/
- handle: (protocol: string | string[], handler: StreamHandler, options?: StreamHandlerOptions) => Promise
+ handle(protocol: string | string[], handler: StreamHandler, options?: StreamHandlerOptions): Promise
/**
* Removes the handler for each protocol. The protocol
@@ -593,7 +593,7 @@ export interface Libp2p<
* libp2p.unhandle(['/echo/1.0.0'])
* ```
*/
- unhandle: (protocols: string[] | string) => Promise
+ unhandle(protocols: string[] | string): Promise
/**
* Register a topology to be informed when peers are encountered that
@@ -612,7 +612,7 @@ export interface Libp2p<
* })
* ```
*/
- register: (protocol: string, topology: Topology) => Promise
+ register(protocol: string, topology: Topology): Promise
/**
* Unregister topology to no longer be informed when peers connect or
@@ -626,14 +626,14 @@ export interface Libp2p<
* libp2p.unregister(id)
* ```
*/
- unregister: (id: string) => void
+ unregister(id: string): void
/**
* Returns the public key for the passed PeerId. If the PeerId is of the 'RSA' type
* this may mean searching the DHT if the key is not present in the KeyStore.
* A set of user defined services
*/
- getPublicKey: (peer: PeerId, options?: AbortOptions) => Promise
+ getPublicKey(peer: PeerId, options?: AbortOptions): Promise
/**
* A set of user defined services
diff --git a/packages/interface/src/keychain/index.ts b/packages/interface/src/keychain/index.ts
index 7632041dab..0812ff1cd8 100644
--- a/packages/interface/src/keychain/index.ts
+++ b/packages/interface/src/keychain/index.ts
@@ -47,7 +47,7 @@ export interface KeyChain {
* const pemKey = await libp2p.keychain.exportKey('keyTest', 'password123')
* ```
*/
- exportKey: (name: string, password: string) => Promise>
+ exportKey(name: string, password: string): Promise>
/**
* Import a new key from a PEM encoded PKCS #8 string.
@@ -60,7 +60,7 @@ export interface KeyChain {
* const keyInfo = await libp2p.keychain.importKey('keyTestImport', pemKey, 'password123')
* ```
*/
- importKey: (name: string, pem: string, password: string) => Promise
+ importKey(name: string, pem: string, password: string): Promise
/**
* Import a new key from a PeerId with a private key component
@@ -71,7 +71,7 @@ export interface KeyChain {
* const keyInfo = await libp2p.keychain.importPeer('keyTestImport', peerIdFromString('12D3Foo...'))
* ```
*/
- importPeer: (name: string, peerId: PeerId) => Promise
+ importPeer(name: string, peerId: PeerId): Promise
/**
* Export an existing key as a PeerId
@@ -82,7 +82,7 @@ export interface KeyChain {
* const peerId = await libp2p.keychain.exportPeerId('key-name')
* ```
*/
- exportPeerId: (name: string) => Promise
+ exportPeerId(name: string): Promise
/**
* Create a key in the keychain.
@@ -93,7 +93,7 @@ export interface KeyChain {
* const keyInfo = await libp2p.keychain.createKey('keyTest', 'RSA', 4096)
* ```
*/
- createKey: (name: string, type: KeyType, size?: number) => Promise
+ createKey(name: string, type: KeyType, size?: number): Promise
/**
* List all the keys.
@@ -104,7 +104,7 @@ export interface KeyChain {
* const keyInfos = await libp2p.keychain.listKeys()
* ```
*/
- listKeys: () => Promise
+ listKeys(): Promise
/**
* Removes a key from the keychain.
@@ -116,7 +116,7 @@ export interface KeyChain {
* const keyInfo = await libp2p.keychain.removeKey('keyTest')
* ```
*/
- removeKey: (name: string) => Promise
+ removeKey(name: string): Promise
/**
* Rename a key in the keychain.
@@ -128,7 +128,7 @@ export interface KeyChain {
* const keyInfo = await libp2p.keychain.renameKey('keyTest', 'keyNewNtest')
* ```
*/
- renameKey: (oldName: string, newName: string) => Promise
+ renameKey(oldName: string, newName: string): Promise
/**
* Find a key by it's id.
@@ -140,7 +140,7 @@ export interface KeyChain {
* const keyInfo2 = await libp2p.keychain.findKeyById(keyInfo.id)
* ```
*/
- findKeyById: (id: string) => Promise
+ findKeyById(id: string): Promise
/**
* Find a key by it's name.
@@ -152,7 +152,7 @@ export interface KeyChain {
* const keyInfo2 = await libp2p.keychain.findKeyByName('keyTest')
* ```
*/
- findKeyByName: (name: string) => Promise
+ findKeyByName(name: string): Promise
/**
* Rotate keychain password and re-encrypt all associated keys
@@ -163,5 +163,5 @@ export interface KeyChain {
* await libp2p.keychain.rotateKeychainPass('oldPassword', 'newPassword')
* ```
*/
- rotateKeychainPass: (oldPass: string, newPass: string) => Promise
+ rotateKeychainPass(oldPass: string, newPass: string): Promise
}
diff --git a/packages/interface/src/keys/index.ts b/packages/interface/src/keys/index.ts
index 62fac882c3..49c3782234 100644
--- a/packages/interface/src/keys/index.ts
+++ b/packages/interface/src/keys/index.ts
@@ -1,9 +1,9 @@
export interface PublicKey {
readonly bytes: Uint8Array
- verify: (data: Uint8Array, sig: Uint8Array) => Promise
- marshal: () => Uint8Array
- equals: (key: PublicKey) => boolean
- hash: () => Promise
+ verify(data: Uint8Array, sig: Uint8Array): Promise
+ marshal(): Uint8Array
+ equals(key: PublicKey): boolean
+ hash(): Promise
}
/**
@@ -12,10 +12,10 @@ export interface PublicKey {
export interface PrivateKey {
readonly public: PublicKey
readonly bytes: Uint8Array
- sign: (data: Uint8Array) => Promise
- marshal: () => Uint8Array
- equals: (key: PrivateKey) => boolean
- hash: () => Promise
+ sign(data: Uint8Array): Promise
+ marshal(): Uint8Array
+ equals(key: PrivateKey): boolean
+ hash(): Promise
/**
* Gets the ID of the key.
*
@@ -23,11 +23,11 @@ export interface PrivateKey {
* The public key is a protobuf encoding containing a type and the DER encoding
* of the PKCS SubjectPublicKeyInfo.
*/
- id: () => Promise
+ id(): Promise
/**
* Exports the password protected key in the format specified.
*/
- export: (password: string, format?: 'pkcs-8' | string) => Promise
+ export(password: string, format?: 'pkcs-8' | string): Promise
}
export const Ed25519 = 'Ed25519'
diff --git a/packages/interface/src/metrics/index.ts b/packages/interface/src/metrics/index.ts
index 2d08189d30..930eaecc9e 100644
--- a/packages/interface/src/metrics/index.ts
+++ b/packages/interface/src/metrics/index.ts
@@ -48,28 +48,28 @@ export interface Metric {
/**
* Update the stored metric to the passed value
*/
- update: (value: number) => void
+ update(value: number): void
/**
* Increment the metric by the passed value or 1
*/
- increment: (value?: number) => void
+ increment(value?: number): void
/**
* Decrement the metric by the passed value or 1
*/
- decrement: (value?: number) => void
+ decrement(value?: number): void
/**
* Reset this metric to its default value
*/
- reset: () => void
+ reset(): void
/**
* Start a timed metric, call the returned function to
* stop the timer
*/
- timer: () => StopTimer
+ timer(): StopTimer
}
/**
@@ -80,31 +80,31 @@ export interface MetricGroup {
/**
* Update the stored metric group to the passed value
*/
- update: (values: Record) => void
+ update(values: Record): void
/**
* Increment the metric group keys by the passed number or
* any non-numeric value to increment by 1
*/
- increment: (values: Record) => void
+ increment(values: Record): void
/**
* Decrement the metric group keys by the passed number or
* any non-numeric value to decrement by 1
*/
- decrement: (values: Record) => void
+ decrement(values: Record): void
/**
* Reset the passed key in this metric group to its default value
* or all keys if no key is passed
*/
- reset: () => void
+ reset(): void
/**
* Start a timed metric for the named key in the group, call
* the returned function to stop the timer
*/
- timer: (key: string) => StopTimer
+ timer(key: string): StopTimer
}
/**
@@ -115,12 +115,12 @@ export interface Counter {
/**
* Increment the metric by the passed value or 1
*/
- increment: (value?: number) => void
+ increment(value?: number): void
/**
* Reset this metric to its default value
*/
- reset: () => void
+ reset(): void
}
/**
@@ -133,13 +133,13 @@ export interface CounterGroup {
* Increment the metric group keys by the passed number or
* any non-numeric value to increment by 1
*/
- increment: (values: Record) => void
+ increment(values: Record): void
/**
* Reset the passed key in this metric group to its default value
* or all keys if no key is passed
*/
- reset: () => void
+ reset(): void
}
/**
@@ -151,12 +151,12 @@ export interface Metrics {
/**
* Track a newly opened multiaddr connection
*/
- trackMultiaddrConnection: (maConn: MultiaddrConnection) => void
+ trackMultiaddrConnection(maConn: MultiaddrConnection): void
/**
* Track a newly opened protocol stream
*/
- trackProtocolStream: (stream: Stream, connection: Connection) => void
+ trackProtocolStream(stream: Stream, connection: Connection): void
/**
* Register an arbitrary metric. Call this to set help/labels for metrics
diff --git a/packages/interface/src/peer-id/index.ts b/packages/interface/src/peer-id/index.ts
index 39b629141d..931c34bc87 100644
--- a/packages/interface/src/peer-id/index.ts
+++ b/packages/interface/src/peer-id/index.ts
@@ -9,10 +9,10 @@ interface BasePeerId {
readonly privateKey?: Uint8Array
readonly publicKey?: Uint8Array
- toString: () => string
- toCID: () => CID
- toBytes: () => Uint8Array
- equals: (other: PeerId | Uint8Array | string) => boolean
+ toString(): string
+ toCID(): CID
+ toBytes(): Uint8Array
+ equals(other: PeerId | Uint8Array | string): boolean
}
export interface RSAPeerId extends BasePeerId {
diff --git a/packages/interface/src/peer-routing/index.ts b/packages/interface/src/peer-routing/index.ts
index c7823b9f9b..abe1710f09 100644
--- a/packages/interface/src/peer-routing/index.ts
+++ b/packages/interface/src/peer-routing/index.ts
@@ -38,7 +38,7 @@ export interface PeerRouting<
* const peer = await peerRouting.findPeer(peerId, options)
* ```
*/
- findPeer: (peerId: PeerId, options?: AbortOptions & ProgressOptions) => Promise
+ findPeer(peerId: PeerId, options?: AbortOptions & ProgressOptions): Promise
/**
* Search the network for peers that are closer to the passed key. Peer
@@ -53,5 +53,5 @@ export interface PeerRouting<
* }
* ```
*/
- getClosestPeers: (key: Uint8Array, options?: AbortOptions & ProgressOptions) => AsyncIterable
+ getClosestPeers(key: Uint8Array, options?: AbortOptions & ProgressOptions): AsyncIterable
}
diff --git a/packages/interface/src/peer-store/index.ts b/packages/interface/src/peer-store/index.ts
index 93ad16e103..ba0a683c57 100644
--- a/packages/interface/src/peer-store/index.ts
+++ b/packages/interface/src/peer-store/index.ts
@@ -156,7 +156,7 @@ export interface PeerStore {
* })
* ```
*/
- forEach: (fn: (peer: Peer) => void, query?: PeerQuery) => Promise
+ forEach(fn: (peer: Peer) => void, query?: PeerQuery): Promise
/**
* Returns all peers in the peer store.
@@ -169,7 +169,7 @@ export interface PeerStore {
* }
* ```
*/
- all: (query?: PeerQuery) => Promise
+ all(query?: PeerQuery): Promise
/**
* Delete all data stored for the passed peer
@@ -187,7 +187,7 @@ export interface PeerStore {
* // []
* ```
*/
- delete: (peerId: PeerId) => Promise
+ delete(peerId: PeerId): Promise
/**
* Returns true if the passed PeerId is in the peer store
@@ -202,7 +202,7 @@ export interface PeerStore {
* // true
* ```
*/
- has: (peerId: PeerId) => Promise
+ has(peerId: PeerId): Promise
/**
* Returns all data stored for the passed PeerId
@@ -214,7 +214,7 @@ export interface PeerStore {
* // { .. }
* ```
*/
- get: (peerId: PeerId) => Promise
+ get(peerId: PeerId): Promise
/**
* Adds a peer to the peer store, overwriting any existing data
@@ -227,7 +227,7 @@ export interface PeerStore {
* })
* ```
*/
- save: (id: PeerId, data: PeerData) => Promise
+ save(id: PeerId, data: PeerData): Promise
/**
* Adds a peer to the peer store, overwriting only the passed fields
@@ -240,7 +240,7 @@ export interface PeerStore {
* })
* ```
*/
- patch: (id: PeerId, data: PeerData) => Promise
+ patch(id: PeerId, data: PeerData): Promise
/**
* Adds a peer to the peer store, deeply merging any existing data.
@@ -253,7 +253,7 @@ export interface PeerStore {
* })
* ```
*/
- merge: (id: PeerId, data: PeerData) => Promise
+ merge(id: PeerId, data: PeerData): Promise
/**
* Unmarshal and verify a signed peer record, extract the multiaddrs and
@@ -268,5 +268,5 @@ export interface PeerStore {
* await peerStore.consumePeerRecord(buf, expectedPeer)
* ```
*/
- consumePeerRecord: (buf: Uint8Array, expectedPeer?: PeerId) => Promise
+ consumePeerRecord(buf: Uint8Array, expectedPeer?: PeerId): Promise
}
diff --git a/packages/interface/src/pubsub/index.ts b/packages/interface/src/pubsub/index.ts
index f17641419d..6fd94382a1 100644
--- a/packages/interface/src/pubsub/index.ts
+++ b/packages/interface/src/pubsub/index.ts
@@ -72,10 +72,10 @@ export interface PeerStreams extends EventEmitter {
inboundStream?: AsyncIterable
isWritable: boolean
- close: () => void
- write: (buf: Uint8Array | Uint8ArrayList) => void
- attachInboundStream: (stream: Stream) => AsyncIterable
- attachOutboundStream: (stream: Stream) => Promise>
+ close(): void
+ write(buf: Uint8Array | Uint8ArrayList): void
+ attachInboundStream(stream: Stream): AsyncIterable
+ attachOutboundStream(stream: Stream): Promise>
}
export interface PubSubInit {
@@ -189,7 +189,7 @@ export interface PubSub = PubSubEvents> exten
*/
topicValidators: Map
- getPeers: () => PeerId[]
+ getPeers(): PeerId[]
/**
* Gets a list of topics the node is subscribed to.
@@ -198,7 +198,7 @@ export interface PubSub = PubSubEvents> exten
* const topics = libp2p.pubsub.getTopics()
* ```
*/
- getTopics: () => string[]
+ getTopics(): string[]
/**
* Subscribes to a pubsub topic.
@@ -217,7 +217,7 @@ export interface PubSub = PubSubEvents> exten
* libp2p.pubsub.subscribe(topic)
* ```
*/
- subscribe: (topic: string) => void
+ subscribe(topic: string): void
/**
* Unsubscribes from a pubsub topic.
@@ -234,7 +234,7 @@ export interface PubSub = PubSubEvents> exten
* libp2p.pubsub.unsubscribe(topic)
* ```
*/
- unsubscribe: (topic: string) => void
+ unsubscribe(topic: string): void
/**
* Gets a list of the PeerIds that are subscribed to one topic.
@@ -245,7 +245,7 @@ export interface PubSub = PubSubEvents> exten
* const peerIds = libp2p.pubsub.getSubscribers(topic)
* ```
*/
- getSubscribers: (topic: string) => PeerId[]
+ getSubscribers(topic: string): PeerId[]
/**
* Publishes messages to the given topic.
@@ -259,7 +259,7 @@ export interface PubSub = PubSubEvents> exten
* await libp2p.pubsub.publish(topic, data)
* ```
*/
- publish: (topic: string, data: Uint8Array) => Promise
+ publish(topic: string, data: Uint8Array): Promise
}
export interface PeerStreamEvents {
diff --git a/packages/interface/src/record/index.ts b/packages/interface/src/record/index.ts
index cb68e14206..5698d546b5 100644
--- a/packages/interface/src/record/index.ts
+++ b/packages/interface/src/record/index.ts
@@ -16,11 +16,11 @@ export interface Record {
/**
* Marshal a record to be used in an envelope.
*/
- marshal: () => Uint8Array
+ marshal(): Uint8Array
/**
* Verifies if the other provided Record is identical to this one.
*/
- equals: (other: Record) => boolean
+ equals(other: Record): boolean
}
export interface Envelope {
@@ -29,7 +29,7 @@ export interface Envelope {
payload: Uint8Array
signature: Uint8Array | Uint8ArrayList
- marshal: () => Uint8Array
- validate: (domain: string) => Promise
- equals: (other: Envelope) => boolean
+ marshal(): Uint8Array
+ validate(domain: string): Promise
+ equals(other: Envelope): boolean
}
diff --git a/packages/interface/src/startable.ts b/packages/interface/src/startable.ts
index fed543ee59..8393abc489 100644
--- a/packages/interface/src/startable.ts
+++ b/packages/interface/src/startable.ts
@@ -2,49 +2,49 @@
* Implemented by components that have a lifecycle
*/
export interface Startable {
- isStarted: () => boolean
+ isStarted(): boolean
/**
* If implemented, this method will be invoked before the start method.
*
* It should not assume any other components have been started.
*/
- beforeStart?: () => void | Promise
+ beforeStart?(): void | Promise
/**
* This method will be invoked to start the component.
*
* It should not assume that any other components have been started.
*/
- start: () => void | Promise
+ start(): void | Promise
/**
* If implemented, this method will be invoked after the start method.
*
* All other components will have had their start method invoked before this method is called.
*/
- afterStart?: () => void | Promise
+ afterStart?(): void | Promise
/**
* If implemented, this method will be invoked before the stop method.
*
* Any other components will still be running when this method is called.
*/
- beforeStop?: () => void | Promise
+ beforeStop?(): void | Promise
/**
* This method will be invoked to stop the component.
*
* It should not assume any other components are running when it is called.
*/
- stop: () => void | Promise
+ stop(): void | Promise
/**
* If implemented, this method will be invoked after the stop method.
*
* All other components will have had their stop method invoked before this method is called.
*/
- afterStop?: () => void | Promise
+ afterStop?(): void | Promise
}
export function isStartable (obj: any): obj is Startable {
diff --git a/packages/interface/src/stream-muxer/index.ts b/packages/interface/src/stream-muxer/index.ts
index fba7b9da34..1e656d2f8e 100644
--- a/packages/interface/src/stream-muxer/index.ts
+++ b/packages/interface/src/stream-muxer/index.ts
@@ -12,7 +12,7 @@ export interface StreamMuxerFactory {
/**
* Creates a new stream muxer to be used with a new connection
*/
- createStreamMuxer: (init?: StreamMuxerInit) => StreamMuxer
+ createStreamMuxer(init?: StreamMuxerInit): StreamMuxer
}
/**
@@ -32,29 +32,29 @@ export interface StreamMuxer extends Duplex