diff --git a/README.md b/README.md index 0770558e..d1f097f2 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,26 @@ -# js-libp2p-daemon +# js-libp2p-daemon -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://protocol.ai) -[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) -[![](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) -[![](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io) -[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-interfaces.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-interfaces) -[![test & maybe release](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml/badge.svg)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml) +[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) +[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) +[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) +[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon) +[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml) > Standalone libp2p executable +## Table of contents + +- [Structure](#structure) +- [Contribute](#contribute) +- [License](#license) +- [Contribution](#contribution) + ## Structure -* [`/packages/libp2p-daemon`](./packages/libp2p-daemon) The CLI tool - starts an instance of the server -* [`/packages/libp2p-daemon-client`](./packages/libp2p-daemon-client) A client to talk to libp2p-daemon instances -* [`/packages/libp2p-daemon-protocol`](./packages/libp2p-daemon-protocol) The wire protocol used by the client/server -* [`/packages/libp2p-daemon-server`](./packages/libp2p-daemon-server) An RPC server controllable by the client +- [`/packages/libp2p-daemon`](./packages/libp2p-daemon) libp2p-daemon JavaScript implementation +- [`/packages/libp2p-daemon-client`](./packages/libp2p-daemon-client) libp2p-daemon client implementation +- [`/packages/libp2p-daemon-protocol`](./packages/libp2p-daemon-protocol) Communication protocol between libp2p daemons and clients +- [`/packages/libp2p-daemon-server`](./packages/libp2p-daemon-server) API server for libp2p-daemon instances ## Contribute @@ -26,4 +32,11 @@ This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/c ## License -[Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) © Protocol Labs +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/packages/libp2p-daemon-client/README.md b/packages/libp2p-daemon-client/README.md index 07d9a01e..aefccdbd 100644 --- a/packages/libp2p-daemon-client/README.md +++ b/packages/libp2p-daemon-client/README.md @@ -1,30 +1,34 @@ -# libp2p-daemon client JavaScript implementation +# @libp2p/daemon-client -[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](https://protocol.ai/) -[![](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) -[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) -[![Discourse posts](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg)](https://discuss.libp2p.io) +[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) +[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) +[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) +[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon) +[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml) -> A Javascript client to interact with a standalone deployment of a libp2p host, running in its own OS process. Essentially, this client allows to communicate with other peers, interact with the DHT, participate in pubsub, etc. no matter the language they are implemented with. +> libp2p-daemon client implementation -## Table of Contents +## Table of contents -- [Specs](#specs) - [Install](#install) +- [Specs](#specs) - [Usage](#usage) - [Run a daemon process](#run-a-daemon-process) - [Interact with the daemon process using the client](#interact-with-the-daemon-process-using-the-client) - [API](#api) - [Contribute](#contribute) - [License](#license) +- [Contribution](#contribution) -## Specs +## Install -The specs for the daemon are currently housed in the go implementation. You can read them at [libp2p/go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon/blob/master/specs/README.md) +```console +$ npm i @libp2p/daemon-client +``` -## Install +## Specs -`npm install @libp2p/daemon-client` +The specs for the daemon are currently housed in the go implementation. You can read them at [libp2p/go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon/blob/master/specs/README.md) ## Usage @@ -58,20 +62,20 @@ await client.close() ## API -* [Getting started](API.md#getting-started) -* [`close`](API.md#close) -* [`connect`](API.md#connect) -* [`identify`](API.md#identify) -* [`listPeers`](API.md#listPeers) -* [`openStream`](API.md#openStream) -* [`registerStream`](API.md#registerStream) -* [`dht.put`](API.md#dht.put) -* [`dht.get`](API.md#dht.get) -* [`dht.findPeer`](API.md#dht.findPeer) -* [`dht.provide`](API.md#dht.provide) -* [`dht.findProviders`](API.md#dht.findProviders) -* [`dht.getClosestPeers`](API.md#dht.getClosestPeers) -* [`dht.getPublicKey`](API.md#dht.getPublicKey) +- [Getting started](API.md#getting-started) +- [`close`](API.md#close) +- [`connect`](API.md#connect) +- [`identify`](API.md#identify) +- [`listPeers`](API.md#listPeers) +- [`openStream`](API.md#openStream) +- [`registerStream`](API.md#registerStream) +- [`dht.put`](API.md#dht.put) +- [`dht.get`](API.md#dht.get) +- [`dht.findPeer`](API.md#dht.findPeer) +- [`dht.provide`](API.md#dht.provide) +- [`dht.findProviders`](API.md#dht.findProviders) +- [`dht.getClosestPeers`](API.md#dht.getClosestPeers) +- [`dht.getPublicKey`](API.md#dht.getPublicKey) ## Contribute @@ -79,4 +83,11 @@ This module is actively under development. Please check out the issues and submi ## License -[Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) © Protocol Labs +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/packages/libp2p-daemon-client/package.json b/packages/libp2p-daemon-client/package.json index ab5dab1f..8e854a27 100644 --- a/packages/libp2p-daemon-client/package.json +++ b/packages/libp2p-daemon-client/package.json @@ -28,6 +28,7 @@ ], "exports": { ".": { + "types": "./src/index.d.ts", "import": "./dist/src/index.js" } }, @@ -130,20 +131,26 @@ }, "dependencies": { "@libp2p/daemon-protocol": "^1.0.0", - "@libp2p/interfaces": "^2.0.1", - "@libp2p/logger": "^1.1.4", + "@libp2p/interface-peer-id": "^1.0.2", + "@libp2p/interface-peer-info": "^1.0.1", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", - "@libp2p/tcp": "^1.0.8", + "@libp2p/tcp": "^2.0.0", "@multiformats/multiaddr": "^10.1.8", "err-code": "^3.0.1", "it-stream-types": "^1.0.4", "multiformats": "^9.6.4" }, "devDependencies": { + "@libp2p/components": "^1.0.0", "@libp2p/daemon-server": "^1.0.0", - "@libp2p/interface-compliance-tests": "^2.0.1", + "@libp2p/interface-compliance-tests": "^3.0.1", + "@libp2p/interface-dht": "^1.0.0", + "@libp2p/interface-mocks": "^1.0.1", + "@libp2p/interface-peer-store": "^1.0.0", + "@libp2p/interface-pubsub": "^1.0.1", "@libp2p/peer-id-factory": "^1.0.9", - "aegir": "^37.0.5", + "aegir": "^37.2.0", "it-all": "^1.0.6", "it-pipe": "^2.0.3", "sinon": "^14.0.0", diff --git a/packages/libp2p-daemon-client/src/dht.ts b/packages/libp2p-daemon-client/src/dht.ts index 760bc143..739a861b 100644 --- a/packages/libp2p-daemon-client/src/dht.ts +++ b/packages/libp2p-daemon-client/src/dht.ts @@ -8,8 +8,8 @@ import { DHTResponse } from '@libp2p/daemon-protocol' import type { DaemonClient } from './index.js' -import { isPeerId, PeerId } from '@libp2p/interfaces/peer-id' -import type { PeerInfo } from '@libp2p/interfaces/peer-info' +import { isPeerId, PeerId } from '@libp2p/interface-peer-id' +import type { PeerInfo } from '@libp2p/interface-peer-info' import { peerIdFromBytes } from '@libp2p/peer-id' export class DHT { diff --git a/packages/libp2p-daemon-client/src/index.ts b/packages/libp2p-daemon-client/src/index.ts index 0099a3d9..77013c65 100644 --- a/packages/libp2p-daemon-client/src/index.ts +++ b/packages/libp2p-daemon-client/src/index.ts @@ -5,12 +5,12 @@ import { StreamHandler } from '@libp2p/daemon-protocol/stream-handler' import { Multiaddr } from '@multiformats/multiaddr' import { DHT } from './dht.js' import { Pubsub } from './pubsub.js' -import { isPeerId, PeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId, PeerId } from '@libp2p/interface-peer-id' import { passThroughUpgrader } from '@libp2p/daemon-protocol/upgrader' import { peerIdFromBytes } from '@libp2p/peer-id' import type { Duplex } from 'it-stream-types' import type { CID } from 'multiformats/cid' -import type { PeerInfo } from '@libp2p/interfaces/peer-info' +import type { PeerInfo } from '@libp2p/interface-peer-info' class Client implements DaemonClient { private readonly multiaddr: Multiaddr diff --git a/packages/libp2p-daemon-client/test/dht.spec.ts b/packages/libp2p-daemon-client/test/dht.spec.ts index e074a95a..6d0dffcb 100644 --- a/packages/libp2p-daemon-client/test/dht.spec.ts +++ b/packages/libp2p-daemon-client/test/dht.spec.ts @@ -7,7 +7,7 @@ import { createServer, Libp2p, Libp2pServer } from '@libp2p/daemon-server' import { createClient, DaemonClient } from '../src/index.js' import { Multiaddr } from '@multiformats/multiaddr' import { StubbedInstance, stubInterface } from 'ts-sinon' -import { DualDHT, ValueEvent, FinalPeerEvent, PeerResponseEvent, MessageType, EventTypes } from '@libp2p/interfaces/dht' +import { DualDHT, ValueEvent, FinalPeerEvent, PeerResponseEvent, MessageType, EventTypes } from '@libp2p/interface-dht' import { peerIdFromString } from '@libp2p/peer-id' import { CID } from 'multiformats/cid' import all from 'it-all' diff --git a/packages/libp2p-daemon-client/test/index.spec.ts b/packages/libp2p-daemon-client/test/index.spec.ts index ba53a338..256186a2 100644 --- a/packages/libp2p-daemon-client/test/index.spec.ts +++ b/packages/libp2p-daemon-client/test/index.spec.ts @@ -6,10 +6,10 @@ import { createServer, Libp2p, Libp2pServer } from '@libp2p/daemon-server' import { createClient, DaemonClient } from '../src/index.js' import { Multiaddr } from '@multiformats/multiaddr' import { StubbedInstance, stubInterface } from 'ts-sinon' -import { isPeerId } from '@libp2p/interfaces/peer-id' +import { isPeerId } from '@libp2p/interface-peer-id' import { peerIdFromString } from '@libp2p/peer-id' -import { mockConnection, mockDuplex, mockMultiaddrConnection } from '@libp2p/interface-compliance-tests/mocks' -import type { PeerStore, AddressBook } from '@libp2p/interfaces/peer-store' +import { mockConnection, mockDuplex, mockMultiaddrConnection } from '@libp2p/interface-mocks' +import type { PeerStore, AddressBook } from '@libp2p/interface-peer-store' const defaultMultiaddr = new Multiaddr('/ip4/0.0.0.0/tcp/0') diff --git a/packages/libp2p-daemon-client/test/pubsub.spec.ts b/packages/libp2p-daemon-client/test/pubsub.spec.ts index d97950e1..e455717a 100644 --- a/packages/libp2p-daemon-client/test/pubsub.spec.ts +++ b/packages/libp2p-daemon-client/test/pubsub.spec.ts @@ -7,7 +7,7 @@ import { createServer, Libp2p, Libp2pServer } from '@libp2p/daemon-server' import { createClient, DaemonClient } from '../src/index.js' import { Multiaddr } from '@multiformats/multiaddr' import { StubbedInstance, stubInterface } from 'ts-sinon' -import type { PubSub } from '@libp2p/interfaces/pubsub' +import type { PubSub } from '@libp2p/interface-pubsub' const defaultMultiaddr = new Multiaddr('/ip4/0.0.0.0/tcp/12345') diff --git a/packages/libp2p-daemon-client/test/stream.spec.ts b/packages/libp2p-daemon-client/test/stream.spec.ts index 2b3c9289..0622f5b6 100644 --- a/packages/libp2p-daemon-client/test/stream.spec.ts +++ b/packages/libp2p-daemon-client/test/stream.spec.ts @@ -7,13 +7,13 @@ import { createClient, DaemonClient } from '../src/index.js' import { Multiaddr } from '@multiformats/multiaddr' import { StubbedInstance, stubInterface } from 'ts-sinon' import { peerIdFromString } from '@libp2p/peer-id' -import { mockRegistrar, connectionPair } from '@libp2p/interface-compliance-tests/mocks' -import type { PeerStore, AddressBook } from '@libp2p/interfaces/peer-store' +import { mockRegistrar, connectionPair } from '@libp2p/interface-mocks' +import type { PeerStore, AddressBook } from '@libp2p/interface-peer-store' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { toString as uint8ArrayToString } from 'uint8arrays/to-string' import all from 'it-all' import { pipe } from 'it-pipe' -import { Components } from '@libp2p/interfaces/components' +import { Components } from '@libp2p/components' const defaultMultiaddr = new Multiaddr('/ip4/0.0.0.0/tcp/0') diff --git a/packages/libp2p-daemon-protocol/README.md b/packages/libp2p-daemon-protocol/README.md index 919fd067..416a5b0c 100644 --- a/packages/libp2p-daemon-protocol/README.md +++ b/packages/libp2p-daemon-protocol/README.md @@ -1,21 +1,24 @@ -# js-libp2p-daemon-protocol +# @libp2p/daemon-protocol - - - +[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) +[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) +[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) +[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon) +[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml) -> Contains the protobuf definitions of the communication protocol for libp2p daemons +> Communication protocol between libp2p daemons and clients ## Table of contents - [Install](#install) - [Contribute](#contribute) - [License](#license) +- [Contribution](#contribution) ## Install -``` -npm i @libp2p/daemon-protocol +```console +$ npm i @libp2p/daemon-protocol ``` ## Contribute @@ -24,4 +27,11 @@ This module is actively under development. Please check out the issues and submi ## License -[Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) © Protocol Labs +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/packages/libp2p-daemon-protocol/package.json b/packages/libp2p-daemon-protocol/package.json index d01755cc..4e28c301 100644 --- a/packages/libp2p-daemon-protocol/package.json +++ b/packages/libp2p-daemon-protocol/package.json @@ -36,18 +36,21 @@ }, "files": [ "src", - "dist", + "dist/src", "!dist/test", "!**/*.tsbuildinfo" ], "exports": { ".": { + "types": "./src/index.d.ts", "import": "./dist/src/index.js" }, "./stream-handler": { + "types": "./dist/src/stream-handler.d.ts", "import": "./dist/src/stream-handler.js" }, "./upgrader": { + "types": "./dist/src/upgrader.d.ts", "import": "./dist/src/upgrader.js" } }, @@ -150,10 +153,12 @@ "release": "aegir release" }, "dependencies": { + "@libp2p/interface-transport": "^1.0.0", + "it-handshake": "^4.0.0", "protons-runtime": "^1.0.4" }, "devDependencies": { - "aegir": "^37.0.14", + "aegir": "^37.2.0", "protons": "^3.0.4" } } diff --git a/packages/libp2p-daemon-protocol/src/upgrader.ts b/packages/libp2p-daemon-protocol/src/upgrader.ts index cf9905ae..4977eb5e 100644 --- a/packages/libp2p-daemon-protocol/src/upgrader.ts +++ b/packages/libp2p-daemon-protocol/src/upgrader.ts @@ -1,4 +1,4 @@ -import type { Upgrader } from '@libp2p/interfaces/transport' +import type { Upgrader } from '@libp2p/interface-transport' export const passThroughUpgrader: Upgrader = { // @ts-expect-error should return a connection diff --git a/packages/libp2p-daemon-server/README.md b/packages/libp2p-daemon-server/README.md index 79a2354c..9dfcc5f2 100644 --- a/packages/libp2p-daemon-server/README.md +++ b/packages/libp2p-daemon-server/README.md @@ -1,29 +1,32 @@ -# libp2p-daemon JavaScript implementation +# @libp2p/daemon-server - - - +[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) +[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) +[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) +[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon) +[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml) -> A standalone deployment of a libp2p host, running in its own OS process and installing a set of virtual endpoints to enable co-local applications to: communicate with peers, handle protocols, interact with the DHT, participate in pubsub, etc. no matter the language they are developed in, nor whether a native libp2p implementation exists in that language. +> API server for libp2p-daemon instances ## Table of contents -- [Specs](#specs) - [Install](#install) +- [Specs](#specs) - [Usage](#usage) - [Contribute](#contribute) - [License](#license) - -## Specs - -The specs for the daemon are currently housed in the go implementation. You can read them at [libp2p/go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon/blob/master/specs/README.md) +- [Contribution](#contribution) ## Install -``` -npm i -g @libp2p/daemon-server +```console +$ npm i @libp2p/daemon-server ``` +## Specs + +The specs for the daemon are currently housed in the go implementation. You can read them at [libp2p/go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon/blob/master/specs/README.md) + ## Usage ```js @@ -46,4 +49,11 @@ This module is actively under development. Please check out the issues and submi ## License -[Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) © Protocol Labs +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/packages/libp2p-daemon-server/package.json b/packages/libp2p-daemon-server/package.json index 0e1370d9..c248897a 100644 --- a/packages/libp2p-daemon-server/package.json +++ b/packages/libp2p-daemon-server/package.json @@ -28,6 +28,7 @@ ], "exports": { ".": { + "types": "./src/index.d.ts", "import": "./dist/src/index.js" } }, @@ -134,20 +135,25 @@ }, "dependencies": { "@libp2p/daemon-protocol": "^1.0.0", - "@libp2p/interfaces": "^2.0.1", - "@libp2p/logger": "^1.1.4", + "@libp2p/interface-connection": "^1.0.1", + "@libp2p/interface-dht": "^1.0.0", + "@libp2p/interface-peer-id": "^1.0.2", + "@libp2p/interface-registrar": "^1.0.0", + "@libp2p/interface-transport": "^1.0.0", + "@libp2p/interfaces": "^3.0.2", + "@libp2p/logger": "^2.0.0", "@libp2p/peer-id": "^1.1.10", - "@libp2p/tcp": "^1.0.8", + "@libp2p/tcp": "^2.0.0", "@multiformats/multiaddr": "^10.1.8", "it-drain": "^1.0.5", "it-length-prefixed": "^7.0.1", "it-pipe": "^2.0.3", - "it-pushable": "^2.0.1", + "it-pushable": "^3.0.0", "multiformats": "^9.6.4", "uint8arrays": "^3.0.0" }, "devDependencies": { - "aegir": "^37.0.5", + "aegir": "^37.2.0", "sinon": "^14.0.0", "ts-sinon": "^2.0.2" } diff --git a/packages/libp2p-daemon-server/src/dht.ts b/packages/libp2p-daemon-server/src/dht.ts index 4310ff31..846a828f 100644 --- a/packages/libp2p-daemon-server/src/dht.ts +++ b/packages/libp2p-daemon-server/src/dht.ts @@ -4,8 +4,8 @@ import { DHTResponse } from '@libp2p/daemon-protocol' import { ErrorResponse, OkResponse } from './responses.js' -import type { PeerId } from '@libp2p/interfaces/peer-id' -import type { DualDHT } from '@libp2p/interfaces/dht' +import type { PeerId } from '@libp2p/interface-peer-id' +import type { DualDHT } from '@libp2p/interface-dht' import type { CID } from 'multiformats/cid' import drain from 'it-drain' import { logger } from '@libp2p/logger' diff --git a/packages/libp2p-daemon-server/src/index.ts b/packages/libp2p-daemon-server/src/index.ts index 6a3fd5c7..b2184f83 100644 --- a/packages/libp2p-daemon-server/src/index.ts +++ b/packages/libp2p-daemon-server/src/index.ts @@ -14,14 +14,14 @@ import { PSRequest, StreamInfo } from '@libp2p/daemon-protocol' -import type { Listener } from '@libp2p/interfaces/transport' -import type { Connection, Stream } from '@libp2p/interfaces/connection' -import type { PeerId } from '@libp2p/interfaces/peer-id' +import type { Listener } from '@libp2p/interface-transport' +import type { Connection, Stream } from '@libp2p/interface-connection' +import type { PeerId } from '@libp2p/interface-peer-id' import type { AbortOptions } from '@libp2p/interfaces' -import type { StreamHandler as StreamCallback } from '@libp2p/interfaces/registrar' -import type { DualDHT } from '@libp2p/interfaces/dht' -import type { PubSub } from '@libp2p/interfaces/pubsub' -import type { PeerStore } from '@libp2p/interfaces/peer-store' +import type { StreamHandler as StreamCallback } from '@libp2p/interface-registrar' +import type { DualDHT } from '@libp2p/interface-dht' +import type { PubSub } from '@libp2p/interface-pubsub' +import type { PeerStore } from '@libp2p/interface-peer-store' import { ErrorResponse, OkResponse } from './responses.js' import { DHTOperations } from './dht.js' import { peerIdFromBytes } from '@libp2p/peer-id' diff --git a/packages/libp2p-daemon-server/src/pubsub.ts b/packages/libp2p-daemon-server/src/pubsub.ts index b66bf146..efdfde62 100644 --- a/packages/libp2p-daemon-server/src/pubsub.ts +++ b/packages/libp2p-daemon-server/src/pubsub.ts @@ -4,7 +4,7 @@ import { PSMessage } from '@libp2p/daemon-protocol' import { ErrorResponse, OkResponse } from './responses.js' -import type { PubSub } from '@libp2p/interfaces/pubsub' +import type { PubSub } from '@libp2p/interface-pubsub' import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string' import { pushable } from 'it-pushable' import { logger } from '@libp2p/logger' @@ -40,7 +40,7 @@ export class PubSubOperations { async * subscribe (topic: string) { try { - const onMessage = pushable() + const onMessage = pushable() this.pubsub.subscribe(topic) await this.pubsub.addEventListener('message', (evt) => { diff --git a/packages/libp2p-daemon/README.md b/packages/libp2p-daemon/README.md index ef0841de..d262a0b1 100644 --- a/packages/libp2p-daemon/README.md +++ b/packages/libp2p-daemon/README.md @@ -1,29 +1,32 @@ -# libp2p-daemon JavaScript implementation +# @libp2p/daemon - - - +[![libp2p.io](https://img.shields.io/badge/project-libp2p-yellow.svg?style=flat-square)](http://libp2p.io/) +[![IRC](https://img.shields.io/badge/freenode-%23libp2p-yellow.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23libp2p) +[![Discuss](https://img.shields.io/discourse/https/discuss.libp2p.io/posts.svg?style=flat-square)](https://discuss.libp2p.io) +[![codecov](https://img.shields.io/codecov/c/github/libp2p/js-libp2p-daemon.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p-daemon) +[![CI](https://img.shields.io/github/workflow/status/libp2p/js-libp2p-interfaces/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/libp2p/js-libp2p-daemon/actions/workflows/js-test-and-release.yml) -> A standalone deployment of a libp2p host, running in its own OS process and installing a set of virtual endpoints to enable co-local applications to: communicate with peers, handle protocols, interact with the DHT, participate in pubsub, etc. no matter the language they are developed in, nor whether a native libp2p implementation exists +> libp2p-daemon JavaScript implementation ## Table of contents -- [Specs](#specs) - [Install](#install) +- [Specs](#specs) - [Usage](#usage) - [Contribute](#contribute) - [License](#license) - -## Specs - -The specs for the daemon are currently housed in the go implementation. You can read them at [libp2p/go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon/blob/master/specs/README.md) +- [Contribution](#contribution) ## Install -``` -npm i -g @libp2p/daemon +```console +$ npm i @libp2p/daemon ``` +## Specs + +The specs for the daemon are currently housed in the go implementation. You can read them at [libp2p/go-libp2p-daemon](https://github.com/libp2p/go-libp2p-daemon/blob/master/specs/README.md) + ## Usage ```console @@ -46,4 +49,11 @@ This module is actively under development. Please check out the issues and submi ## License -[Apache-2.0](LICENSE-APACHE) or [MIT](LICENSE-MIT) © Protocol Labs +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/packages/libp2p-daemon/package.json b/packages/libp2p-daemon/package.json index 751b2c94..0321851a 100644 --- a/packages/libp2p-daemon/package.json +++ b/packages/libp2p-daemon/package.json @@ -31,6 +31,7 @@ ], "exports": { ".": { + "types": "./src/index.d.ts", "import": "./dist/src/index.js" } }, @@ -132,14 +133,13 @@ }, "dependencies": { "@libp2p/daemon-server": "^1.0.0", - "@libp2p/interfaces": "^2.0.1", "@multiformats/multiaddr": "^10.1.8", "es-main": "^1.0.2", "yargs": "^17.3.1", "yargs-promise": "^1.1.0" }, "devDependencies": { - "aegir": "^37.0.5", + "aegir": "^37.2.0", "sinon": "^14.0.0" } }