mirror of https://github.com/waku-org/js-waku.git
Merge pull request #1160 from waku-org/chore/bump-libp2p-deps
This commit is contained in:
commit
79838d8c69
File diff suppressed because it is too large
Load Diff
|
@ -28,7 +28,7 @@
|
||||||
"proto": "npm run proto --workspaces --if-present",
|
"proto": "npm run proto --workspaces --if-present",
|
||||||
"deploy": "node ci/deploy.js",
|
"deploy": "node ci/deploy.js",
|
||||||
"doc": "run-s doc:*",
|
"doc": "run-s doc:*",
|
||||||
"doc:html": "typedoc --options typedoc.cjs --treatWarningsAsErrors",
|
"doc:html": "typedoc --options typedoc.cjs",
|
||||||
"doc:cname": "echo 'js.waku.org' > docs/CNAME"
|
"doc:cname": "echo 'js.waku.org' > docs/CNAME"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
@ -76,45 +76,37 @@
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chainsafe/libp2p-gossipsub": "^5.2.1",
|
"@chainsafe/libp2p-gossipsub": "^6.1.0",
|
||||||
"@libp2p/interface-connection": "^3.0.3",
|
|
||||||
"@libp2p/interface-peer-discovery": "^1.0.0",
|
|
||||||
"@libp2p/interface-peer-id": "^1.0.6",
|
|
||||||
"@libp2p/interface-peer-info": "^1.0.4",
|
|
||||||
"@libp2p/interface-peer-store": "^1.2.3",
|
|
||||||
"@libp2p/interface-pubsub": "^3.0.1",
|
|
||||||
"@libp2p/interface-registrar": "^2.0.4",
|
|
||||||
"@libp2p/interfaces": "^3.0.4",
|
|
||||||
"@libp2p/peer-id": "^1.1.10",
|
|
||||||
"@multiformats/multiaddr": "^11.0.6",
|
|
||||||
"@noble/hashes": "^1.1.3",
|
"@noble/hashes": "^1.1.3",
|
||||||
"@waku/utils": "*",
|
|
||||||
"@waku/interfaces": "*",
|
"@waku/interfaces": "*",
|
||||||
"@waku/proto": "*",
|
"@waku/proto": "*",
|
||||||
|
"@waku/utils": "*",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"it-all": "^1.0.6",
|
"it-all": "^1.0.6",
|
||||||
"it-length-prefixed": "^8.0.2",
|
"it-length-prefixed": "^8.0.2",
|
||||||
"it-pipe": "^2.0.4",
|
"it-pipe": "^2.0.4",
|
||||||
"libp2p": "0.40.0",
|
|
||||||
"p-event": "^5.0.1",
|
"p-event": "^5.0.1",
|
||||||
"uint8arraylist": "^2.3.2",
|
"uint8arraylist": "^2.4.3",
|
||||||
"uint8arrays": "^4.0.2",
|
|
||||||
"uuid": "^9.0.0"
|
"uuid": "^9.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@libp2p/interface-connection": "^3.0.8",
|
||||||
|
"@libp2p/interface-libp2p": "^1.1.1",
|
||||||
|
"@libp2p/interface-peer-id": "^2.0.1",
|
||||||
|
"@libp2p/interface-peer-store": "^1.2.8",
|
||||||
|
"@libp2p/interface-pubsub": "^3.0.6",
|
||||||
|
"@libp2p/interface-registrar": "^2.0.8",
|
||||||
|
"@multiformats/multiaddr": "^11.4.0",
|
||||||
"@rollup/plugin-commonjs": "^22.0.0",
|
"@rollup/plugin-commonjs": "^22.0.0",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||||
"@types/app-root-path": "^1.2.4",
|
|
||||||
"@types/chai": "^4.2.15",
|
"@types/chai": "^4.2.15",
|
||||||
"@types/debug": "^4.1.7",
|
"@types/debug": "^4.1.7",
|
||||||
"@types/mocha": "^9.1.0",
|
"@types/mocha": "^9.1.0",
|
||||||
"@types/node": "^18.11.17",
|
"@types/uuid": "^9.0.0",
|
||||||
"@types/tail": "^2.0.0",
|
|
||||||
"@types/uuid": "^8.3.0",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/parser": "^5.8.1",
|
||||||
"app-root-path": "^3.0.0",
|
"chai": "^4.3.4",
|
||||||
"cspell": "^6.17.0",
|
"cspell": "^6.17.0",
|
||||||
"eslint": "^8.6.0",
|
"eslint": "^8.6.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
@ -122,6 +114,7 @@
|
||||||
"eslint-plugin-functional": "^4.0.2",
|
"eslint-plugin-functional": "^4.0.2",
|
||||||
"eslint-plugin-import": "^2.25.3",
|
"eslint-plugin-import": "^2.25.3",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"fast-check": "^2.14.0",
|
||||||
"gh-pages": "^3.2.3",
|
"gh-pages": "^3.2.3",
|
||||||
"ignore-loader": "^0.1.2",
|
"ignore-loader": "^0.1.2",
|
||||||
"isomorphic-fetch": "^3.0.0",
|
"isomorphic-fetch": "^3.0.0",
|
||||||
|
@ -132,22 +125,19 @@
|
||||||
"karma-mocha": "^2.0.1",
|
"karma-mocha": "^2.0.1",
|
||||||
"karma-webpack": "^5.0.0",
|
"karma-webpack": "^5.0.0",
|
||||||
"mocha": "^9.1.3",
|
"mocha": "^9.1.3",
|
||||||
"chai": "^4.3.4",
|
|
||||||
"fast-check": "^2.14.0",
|
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"p-timeout": "^6.0.0",
|
"p-timeout": "^6.0.0",
|
||||||
"portfinder": "^1.0.28",
|
|
||||||
"prettier": "^2.1.1",
|
"prettier": "^2.1.1",
|
||||||
"process": "^0.11.10",
|
"process": "^0.11.10",
|
||||||
"puppeteer": "^13.0.1",
|
"puppeteer": "^13.0.1",
|
||||||
"rollup": "^2.75.0",
|
"rollup": "^2.75.0",
|
||||||
"tail": "^2.2.0",
|
|
||||||
"ts-loader": "^9.3.1",
|
"ts-loader": "^9.3.1",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^4.6.3"
|
"typescript": "^4.6.3"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@multiformats/multiaddr": "^11.0.6"
|
"@multiformats/multiaddr": "^11.4.0",
|
||||||
|
"libp2p": "^0.42.2"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@multiformats/multiaddr": {
|
"@multiformats/multiaddr": {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import type { Stream } from "@libp2p/interface-connection";
|
import type { Stream } from "@libp2p/interface-connection";
|
||||||
import type { ConnectionManager } from "@libp2p/interface-connection-manager";
|
import type { Libp2p } from "@libp2p/interface-libp2p";
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||||
import type { PeerStore } from "@libp2p/interface-peer-store";
|
import type { PeerStore } from "@libp2p/interface-peer-store";
|
||||||
import type { Peer } from "@libp2p/interface-peer-store";
|
import type { Peer } from "@libp2p/interface-peer-store";
|
||||||
import type { IncomingStreamData } from "@libp2p/interface-registrar";
|
import type { IncomingStreamData } from "@libp2p/interface-registrar";
|
||||||
import type { Registrar } from "@libp2p/interface-registrar";
|
|
||||||
import type {
|
import type {
|
||||||
Callback,
|
Callback,
|
||||||
IDecodedMessage,
|
IDecodedMessage,
|
||||||
|
@ -38,12 +37,6 @@ export const FilterCodec = "/vac/waku/filter/2.0.0-beta1";
|
||||||
|
|
||||||
const log = debug("waku:filter");
|
const log = debug("waku:filter");
|
||||||
|
|
||||||
export interface FilterComponents {
|
|
||||||
peerStore: PeerStore;
|
|
||||||
registrar: Registrar;
|
|
||||||
connectionManager: ConnectionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UnsubscribeFunction = () => Promise<void>;
|
export type UnsubscribeFunction = () => Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,15 +55,12 @@ class Filter implements IFilter {
|
||||||
Set<IDecoder<any>>
|
Set<IDecoder<any>>
|
||||||
>;
|
>;
|
||||||
|
|
||||||
constructor(
|
constructor(public libp2p: Libp2p, options?: ProtocolCreateOptions) {
|
||||||
public components: FilterComponents,
|
|
||||||
options?: ProtocolCreateOptions
|
|
||||||
) {
|
|
||||||
this.options = options ?? {};
|
this.options = options ?? {};
|
||||||
this.multicodec = FilterCodec;
|
this.multicodec = FilterCodec;
|
||||||
this.subscriptions = new Map();
|
this.subscriptions = new Map();
|
||||||
this.decoders = new Map();
|
this.decoders = new Map();
|
||||||
this.components.registrar
|
this.libp2p
|
||||||
.handle(FilterCodec, this.onRequest.bind(this))
|
.handle(FilterCodec, this.onRequest.bind(this))
|
||||||
.catch((e) => log("Failed to register filter protocol", e));
|
.catch((e) => log("Failed to register filter protocol", e));
|
||||||
}
|
}
|
||||||
|
@ -143,7 +133,7 @@ class Filter implements IFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
get peerStore(): PeerStore {
|
get peerStore(): PeerStore {
|
||||||
return this.components.peerStore;
|
return this.libp2p.peerStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
private onRequest(streamData: IncomingStreamData): void {
|
private onRequest(streamData: IncomingStreamData): void {
|
||||||
|
@ -268,9 +258,7 @@ class Filter implements IFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async newStream(peer: Peer): Promise<Stream> {
|
private async newStream(peer: Peer): Promise<Stream> {
|
||||||
const connections = this.components.connectionManager.getConnections(
|
const connections = this.libp2p.getConnections(peer.id);
|
||||||
peer.id
|
|
||||||
);
|
|
||||||
const connection = selectConnection(connections);
|
const connection = selectConnection(connections);
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
throw new Error("Failed to get a connection to the peer");
|
throw new Error("Failed to get a connection to the peer");
|
||||||
|
@ -281,7 +269,7 @@ class Filter implements IFilter {
|
||||||
|
|
||||||
private async getPeer(peerId?: PeerId): Promise<Peer> {
|
private async getPeer(peerId?: PeerId): Promise<Peer> {
|
||||||
const res = await selectPeerForProtocol(
|
const res = await selectPeerForProtocol(
|
||||||
this.components.peerStore,
|
this.peerStore,
|
||||||
[FilterCodec],
|
[FilterCodec],
|
||||||
peerId
|
peerId
|
||||||
);
|
);
|
||||||
|
@ -292,7 +280,7 @@ class Filter implements IFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async peers(): Promise<Peer[]> {
|
async peers(): Promise<Peer[]> {
|
||||||
return getPeersForProtocol(this.components.peerStore, [FilterCodec]);
|
return getPeersForProtocol(this.peerStore, [FilterCodec]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async randomPeer(): Promise<Peer | undefined> {
|
async randomPeer(): Promise<Peer | undefined> {
|
||||||
|
@ -302,6 +290,6 @@ class Filter implements IFilter {
|
||||||
|
|
||||||
export function wakuFilter(
|
export function wakuFilter(
|
||||||
init: Partial<ProtocolCreateOptions> = {}
|
init: Partial<ProtocolCreateOptions> = {}
|
||||||
): (components: FilterComponents) => IFilter {
|
): (libp2p: Libp2p) => IFilter {
|
||||||
return (components: FilterComponents) => new Filter(components, init);
|
return (libp2p: Libp2p) => new Filter(libp2p, init);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ConnectionManager } from "@libp2p/interface-connection-manager";
|
import type { Libp2p } from "@libp2p/interface-libp2p";
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||||
import type { Peer } from "@libp2p/interface-peer-store";
|
import type { Peer } from "@libp2p/interface-peer-store";
|
||||||
import type { PeerStore } from "@libp2p/interface-peer-store";
|
import type { PeerStore } from "@libp2p/interface-peer-store";
|
||||||
|
@ -32,11 +32,6 @@ const log = debug("waku:light-push");
|
||||||
export const LightPushCodec = "/vac/waku/lightpush/2.0.0-beta1";
|
export const LightPushCodec = "/vac/waku/lightpush/2.0.0-beta1";
|
||||||
export { PushResponse };
|
export { PushResponse };
|
||||||
|
|
||||||
export interface LightPushComponents {
|
|
||||||
peerStore: PeerStore;
|
|
||||||
connectionManager: ConnectionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
|
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
|
||||||
*/
|
*/
|
||||||
|
@ -44,10 +39,7 @@ class LightPush implements ILightPush {
|
||||||
multicodec: string;
|
multicodec: string;
|
||||||
options: ProtocolCreateOptions;
|
options: ProtocolCreateOptions;
|
||||||
|
|
||||||
constructor(
|
constructor(public libp2p: Libp2p, options?: ProtocolCreateOptions) {
|
||||||
public components: LightPushComponents,
|
|
||||||
options?: ProtocolCreateOptions
|
|
||||||
) {
|
|
||||||
this.multicodec = LightPushCodec;
|
this.multicodec = LightPushCodec;
|
||||||
this.options = options || {};
|
this.options = options || {};
|
||||||
}
|
}
|
||||||
|
@ -60,7 +52,7 @@ class LightPush implements ILightPush {
|
||||||
const { pubSubTopic = DefaultPubSubTopic } = this.options;
|
const { pubSubTopic = DefaultPubSubTopic } = this.options;
|
||||||
|
|
||||||
const res = await selectPeerForProtocol(
|
const res = await selectPeerForProtocol(
|
||||||
this.components.peerStore,
|
this.peerStore,
|
||||||
[this.multicodec],
|
[this.multicodec],
|
||||||
opts?.peerId
|
opts?.peerId
|
||||||
);
|
);
|
||||||
|
@ -70,9 +62,7 @@ class LightPush implements ILightPush {
|
||||||
}
|
}
|
||||||
const { peer } = res;
|
const { peer } = res;
|
||||||
|
|
||||||
const connections = this.components.connectionManager.getConnections(
|
const connections = this.libp2p.getConnections(peer.id);
|
||||||
peer.id
|
|
||||||
);
|
|
||||||
const connection = selectConnection(connections);
|
const connection = selectConnection(connections);
|
||||||
|
|
||||||
if (!connection) throw "Failed to get a connection to the peer";
|
if (!connection) throw "Failed to get a connection to the peer";
|
||||||
|
@ -126,7 +116,7 @@ class LightPush implements ILightPush {
|
||||||
* peers.
|
* peers.
|
||||||
*/
|
*/
|
||||||
async peers(): Promise<Peer[]> {
|
async peers(): Promise<Peer[]> {
|
||||||
return getPeersForProtocol(this.components.peerStore, [LightPushCodec]);
|
return getPeersForProtocol(this.peerStore, [LightPushCodec]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -139,12 +129,12 @@ class LightPush implements ILightPush {
|
||||||
}
|
}
|
||||||
|
|
||||||
get peerStore(): PeerStore {
|
get peerStore(): PeerStore {
|
||||||
return this.components.peerStore;
|
return this.libp2p.peerStore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function wakuLightPush(
|
export function wakuLightPush(
|
||||||
init: Partial<ProtocolCreateOptions> = {}
|
init: Partial<ProtocolCreateOptions> = {}
|
||||||
): (components: LightPushComponents) => ILightPush {
|
): (libp2p: Libp2p) => ILightPush {
|
||||||
return (components: LightPushComponents) => new LightPush(components, init);
|
return (libp2p: Libp2p) => new LightPush(libp2p, init);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { Connection } from "@libp2p/interface-connection";
|
import type { Connection } from "@libp2p/interface-connection";
|
||||||
import type { ConnectionManager } from "@libp2p/interface-connection-manager";
|
import type { Libp2p } from "@libp2p/interface-libp2p";
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||||
import type { Peer, PeerStore } from "@libp2p/interface-peer-store";
|
import type { Peer, PeerStore } from "@libp2p/interface-peer-store";
|
||||||
import { sha256 } from "@noble/hashes/sha256";
|
import { sha256 } from "@noble/hashes/sha256";
|
||||||
|
@ -40,11 +40,6 @@ export const DefaultPageSize = 10;
|
||||||
|
|
||||||
export { PageDirection };
|
export { PageDirection };
|
||||||
|
|
||||||
export interface StoreComponents {
|
|
||||||
peerStore: PeerStore;
|
|
||||||
connectionManager: ConnectionManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TimeFilter {
|
export interface TimeFilter {
|
||||||
startTime: Date;
|
startTime: Date;
|
||||||
endTime: Date;
|
endTime: Date;
|
||||||
|
@ -93,10 +88,7 @@ class Store implements IStore {
|
||||||
multicodec: string;
|
multicodec: string;
|
||||||
options: ProtocolCreateOptions;
|
options: ProtocolCreateOptions;
|
||||||
|
|
||||||
constructor(
|
constructor(public libp2p: Libp2p, options?: ProtocolCreateOptions) {
|
||||||
public components: StoreComponents,
|
|
||||||
options?: ProtocolCreateOptions
|
|
||||||
) {
|
|
||||||
this.multicodec = StoreCodec;
|
this.multicodec = StoreCodec;
|
||||||
this.options = options ?? {};
|
this.options = options ?? {};
|
||||||
}
|
}
|
||||||
|
@ -246,7 +238,7 @@ class Store implements IStore {
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await selectPeerForProtocol(
|
const res = await selectPeerForProtocol(
|
||||||
this.components.peerStore,
|
this.peerStore,
|
||||||
[StoreCodec],
|
[StoreCodec],
|
||||||
options?.peerId
|
options?.peerId
|
||||||
);
|
);
|
||||||
|
@ -256,9 +248,7 @@ class Store implements IStore {
|
||||||
}
|
}
|
||||||
const { peer, protocol } = res;
|
const { peer, protocol } = res;
|
||||||
|
|
||||||
const connections = this.components.connectionManager.getConnections(
|
const connections = this.libp2p.getConnections(peer.id);
|
||||||
peer.id
|
|
||||||
);
|
|
||||||
const connection = selectConnection(connections);
|
const connection = selectConnection(connections);
|
||||||
|
|
||||||
if (!connection) throw "Failed to get a connection to the peer";
|
if (!connection) throw "Failed to get a connection to the peer";
|
||||||
|
@ -279,11 +269,11 @@ class Store implements IStore {
|
||||||
* store protocol. Waku may or may not be currently connected to these peers.
|
* store protocol. Waku may or may not be currently connected to these peers.
|
||||||
*/
|
*/
|
||||||
async peers(): Promise<Peer[]> {
|
async peers(): Promise<Peer[]> {
|
||||||
return getPeersForProtocol(this.components.peerStore, [StoreCodec]);
|
return getPeersForProtocol(this.peerStore, [StoreCodec]);
|
||||||
}
|
}
|
||||||
|
|
||||||
get peerStore(): PeerStore {
|
get peerStore(): PeerStore {
|
||||||
return this.components.peerStore;
|
return this.libp2p.peerStore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,6 +414,6 @@ export async function createCursor(
|
||||||
|
|
||||||
export function wakuStore(
|
export function wakuStore(
|
||||||
init: Partial<ProtocolCreateOptions> = {}
|
init: Partial<ProtocolCreateOptions> = {}
|
||||||
): (components: StoreComponents) => IStore {
|
): (libp2p: Libp2p) => IStore {
|
||||||
return (components: StoreComponents) => new Store(components, init);
|
return (libp2p: Libp2p) => new Store(libp2p, init);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { PeerProtocolsChangeData } from "@libp2p/interface-peer-store";
|
import type { PeerProtocolsChangeData } from "@libp2p/interface-peer-store";
|
||||||
import type { IRelay, PointToPointProtocol, Waku } from "@waku/interfaces";
|
import type { IRelay, PointToPointProtocol, Waku } from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import type { Stream } from "@libp2p/interface-connection";
|
import type { Stream } from "@libp2p/interface-connection";
|
||||||
|
import type { Libp2p } from "@libp2p/interface-libp2p";
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||||
import type { PubSub } from "@libp2p/interface-pubsub";
|
import type { PubSub } from "@libp2p/interface-pubsub";
|
||||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||||
|
@ -13,14 +14,10 @@ import type {
|
||||||
} from "@waku/interfaces";
|
} from "@waku/interfaces";
|
||||||
import { Protocols } from "@waku/interfaces";
|
import { Protocols } from "@waku/interfaces";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
import type { Libp2p } from "libp2p";
|
|
||||||
|
|
||||||
import { FilterComponents } from "./filter/index.js";
|
|
||||||
import { LightPushComponents } from "./light_push/index.js";
|
|
||||||
import { createEncoder } from "./message/version_0.js";
|
import { createEncoder } from "./message/version_0.js";
|
||||||
import * as relayConstants from "./relay/constants.js";
|
import * as relayConstants from "./relay/constants.js";
|
||||||
import { RelayPingContentTopic } from "./relay/constants.js";
|
import { RelayPingContentTopic } from "./relay/constants.js";
|
||||||
import { StoreComponents } from "./store/index.js";
|
|
||||||
|
|
||||||
export const DefaultPingKeepAliveValueSecs = 0;
|
export const DefaultPingKeepAliveValueSecs = 0;
|
||||||
export const DefaultRelayKeepAliveValueSecs = 5 * 60;
|
export const DefaultRelayKeepAliveValueSecs = 5 * 60;
|
||||||
|
@ -33,19 +30,19 @@ export interface WakuOptions {
|
||||||
* Set keep alive frequency in seconds: Waku will send a `/ipfs/ping/1.0.0`
|
* Set keep alive frequency in seconds: Waku will send a `/ipfs/ping/1.0.0`
|
||||||
* request to each peer after the set number of seconds. Set to 0 to disable.
|
* request to each peer after the set number of seconds. Set to 0 to disable.
|
||||||
*
|
*
|
||||||
* @default {@link DefaultPingKeepAliveValueSecs}
|
* @default {@link @waku/core.DefaultPingKeepAliveValueSecs}
|
||||||
*/
|
*/
|
||||||
pingKeepAlive?: number;
|
pingKeepAlive?: number;
|
||||||
/**
|
/**
|
||||||
* Set keep alive frequency in seconds: Waku will send a ping message over
|
* Set keep alive frequency in seconds: Waku will send a ping message over
|
||||||
* relay to each peer after the set number of seconds. Set to 0 to disable.
|
* relay to each peer after the set number of seconds. Set to 0 to disable.
|
||||||
*
|
*
|
||||||
* @default {@link DefaultRelayKeepAliveValueSecs}
|
* @default {@link @waku/core.DefaultRelayKeepAliveValueSecs}
|
||||||
*/
|
*/
|
||||||
relayKeepAlive?: number;
|
relayKeepAlive?: number;
|
||||||
/**
|
/**
|
||||||
* Set the user agent string to be used in identification of the node.
|
* Set the user agent string to be used in identification of the node.
|
||||||
* @default {@link DefaultUserAgent}
|
* @default {@link @waku/core.DefaultUserAgent}
|
||||||
*/
|
*/
|
||||||
userAgent?: string;
|
userAgent?: string;
|
||||||
}
|
}
|
||||||
|
@ -68,28 +65,28 @@ export class WakuNode implements Waku {
|
||||||
constructor(
|
constructor(
|
||||||
options: WakuOptions,
|
options: WakuOptions,
|
||||||
libp2p: Libp2p,
|
libp2p: Libp2p,
|
||||||
store?: (components: StoreComponents) => IStore,
|
store?: (libp2p: Libp2p) => IStore,
|
||||||
lightPush?: (components: LightPushComponents) => ILightPush,
|
lightPush?: (libp2p: Libp2p) => ILightPush,
|
||||||
filter?: (components: FilterComponents) => IFilter,
|
filter?: (libp2p: Libp2p) => IFilter,
|
||||||
peerExchange?: (components: PeerExchangeComponents) => IPeerExchange
|
peerExchange?: (components: PeerExchangeComponents) => IPeerExchange
|
||||||
) {
|
) {
|
||||||
this.libp2p = libp2p;
|
this.libp2p = libp2p;
|
||||||
|
|
||||||
const { peerStore, connectionManager, registrar } = libp2p;
|
|
||||||
const components = { peerStore, connectionManager, registrar };
|
|
||||||
|
|
||||||
if (store) {
|
if (store) {
|
||||||
this.store = store(components);
|
this.store = store(libp2p);
|
||||||
}
|
}
|
||||||
if (filter) {
|
if (filter) {
|
||||||
this.filter = filter(components);
|
this.filter = filter(libp2p);
|
||||||
}
|
}
|
||||||
if (lightPush) {
|
if (lightPush) {
|
||||||
this.lightPush = lightPush(components);
|
this.lightPush = lightPush(libp2p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peerExchange) {
|
if (peerExchange) {
|
||||||
this.peerExchange = peerExchange(components);
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore: Libp2p is now hiding internal components but peer discovery
|
||||||
|
// implementation still expect to receive said components.
|
||||||
|
this.peerExchange = peerExchange(libp2p.components);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRelay(libp2p.pubsub)) {
|
if (isRelay(libp2p.pubsub)) {
|
||||||
|
@ -113,7 +110,7 @@ export class WakuNode implements Waku {
|
||||||
? options.relayKeepAlive || DefaultRelayKeepAliveValueSecs
|
? options.relayKeepAlive || DefaultRelayKeepAliveValueSecs
|
||||||
: 0;
|
: 0;
|
||||||
|
|
||||||
libp2p.connectionManager.addEventListener("peer:connect", (evt) => {
|
libp2p.addEventListener("peer:connect", (evt) => {
|
||||||
this.startKeepAlive(evt.detail.remotePeer, pingKeepAlive, relayKeepAlive);
|
this.startKeepAlive(evt.detail.remotePeer, pingKeepAlive, relayKeepAlive);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -128,7 +125,7 @@ export class WakuNode implements Waku {
|
||||||
* >this event will **only** be triggered when the last connection is closed.
|
* >this event will **only** be triggered when the last connection is closed.
|
||||||
* @see https://github.com/libp2p/js-libp2p/blob/bad9e8c0ff58d60a78314077720c82ae331cc55b/doc/API.md?plain=1#L2100
|
* @see https://github.com/libp2p/js-libp2p/blob/bad9e8c0ff58d60a78314077720c82ae331cc55b/doc/API.md?plain=1#L2100
|
||||||
*/
|
*/
|
||||||
libp2p.connectionManager.addEventListener("peer:disconnect", (evt) => {
|
libp2p.addEventListener("peer:disconnect", (evt) => {
|
||||||
this.stopKeepAlive(evt.detail.remotePeer);
|
this.stopKeepAlive(evt.detail.remotePeer);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -50,28 +50,29 @@
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chainsafe/libp2p-noise": "^10.1.0",
|
"@chainsafe/libp2p-noise": "^11.0.0",
|
||||||
"@libp2p/interface-address-manager": "^2.0.1",
|
"@libp2p/mplex": "^7.1.1",
|
||||||
"@libp2p/interface-connection": "^3.0.3",
|
"@libp2p/websockets": "^5.0.3",
|
||||||
"@libp2p/interface-connection-manager": "^1.3.1",
|
|
||||||
"@libp2p/interface-content-routing": "^1.0.4",
|
|
||||||
"@libp2p/interface-dht": "^1.0.3",
|
|
||||||
"@libp2p/interface-metrics": "^3.0.0",
|
|
||||||
"@libp2p/interface-peer-discovery": "^1.0.2",
|
|
||||||
"@libp2p/interface-peer-id": "^1.0.6",
|
|
||||||
"@libp2p/interface-peer-routing": "^1.0.2",
|
|
||||||
"@libp2p/interface-peer-store": "^1.2.3",
|
|
||||||
"@libp2p/interface-pubsub": "^3.0.1",
|
|
||||||
"@libp2p/interface-registrar": "^2.0.4",
|
|
||||||
"@libp2p/interface-transport": "^2.0.1",
|
|
||||||
"@libp2p/mplex": "^7.0.0",
|
|
||||||
"@libp2p/websockets": "^5.0.0",
|
|
||||||
"@waku/core": "*",
|
"@waku/core": "*",
|
||||||
"@waku/dns-discovery": "*",
|
"@waku/dns-discovery": "*",
|
||||||
"@waku/peer-exchange": "*",
|
"@waku/peer-exchange": "*",
|
||||||
"interface-datastore": "^7.0.1"
|
"libp2p": "^0.42.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@libp2p/interface-address-manager": "^2.0.4",
|
||||||
|
"@libp2p/interface-connection": "^3.0.8",
|
||||||
|
"@libp2p/interface-connection-manager": "^1.3.7",
|
||||||
|
"@libp2p/interface-content-routing": "^2.0.1",
|
||||||
|
"@libp2p/interface-dht": "^2.0.1",
|
||||||
|
"@libp2p/interface-libp2p": "^1.1.1",
|
||||||
|
"@libp2p/interface-metrics": "^4.0.5",
|
||||||
|
"@libp2p/interface-peer-discovery": "^1.0.5",
|
||||||
|
"@libp2p/interface-peer-id": "^2.0.1",
|
||||||
|
"@libp2p/interface-peer-routing": "^1.0.7",
|
||||||
|
"@libp2p/interface-peer-store": "^1.2.8",
|
||||||
|
"@libp2p/interface-pubsub": "^3.0.6",
|
||||||
|
"@libp2p/interface-registrar": "^2.0.8",
|
||||||
|
"@libp2p/interface-transport": "^2.1.1",
|
||||||
"@rollup/plugin-commonjs": "^22.0.0",
|
"@rollup/plugin-commonjs": "^22.0.0",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||||
|
@ -85,6 +86,7 @@
|
||||||
"eslint-plugin-functional": "^4.0.2",
|
"eslint-plugin-functional": "^4.0.2",
|
||||||
"eslint-plugin-import": "^2.25.3",
|
"eslint-plugin-import": "^2.25.3",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"interface-datastore": "^7.0.4",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^2.1.1",
|
"prettier": "^2.1.1",
|
||||||
"rollup": "^2.75.0",
|
"rollup": "^2.75.0",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { noise } from "@chainsafe/libp2p-noise";
|
import { noise } from "@chainsafe/libp2p-noise";
|
||||||
|
import type { Libp2p } from "@libp2p/interface-libp2p";
|
||||||
import type { PeerDiscovery } from "@libp2p/interface-peer-discovery";
|
import type { PeerDiscovery } from "@libp2p/interface-peer-discovery";
|
||||||
import { mplex } from "@libp2p/mplex";
|
import { mplex } from "@libp2p/mplex";
|
||||||
import { webSockets } from "@libp2p/websockets";
|
import { webSockets } from "@libp2p/websockets";
|
||||||
|
@ -22,7 +23,6 @@ import type {
|
||||||
RelayNode,
|
RelayNode,
|
||||||
} from "@waku/interfaces";
|
} from "@waku/interfaces";
|
||||||
import { wakuPeerExchange } from "@waku/peer-exchange";
|
import { wakuPeerExchange } from "@waku/peer-exchange";
|
||||||
import type { Libp2p } from "libp2p";
|
|
||||||
import { createLibp2p, Libp2pOptions } from "libp2p";
|
import { createLibp2p, Libp2pOptions } from "libp2p";
|
||||||
|
|
||||||
import type { Libp2pComponents } from "./libp2p_components.js";
|
import type { Libp2pComponents } from "./libp2p_components.js";
|
||||||
|
|
|
@ -57,31 +57,31 @@
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@libp2p/interface-peer-discovery": "^1.0.5",
|
||||||
|
"@libp2p/interfaces": "^3.3.1",
|
||||||
"@waku/enr": "*",
|
"@waku/enr": "*",
|
||||||
"@waku/utils": "*",
|
"@waku/utils": "*",
|
||||||
"hi-base32": "^0.5.1",
|
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"dns-query": "^0.11.2",
|
"dns-query": "^0.11.2",
|
||||||
"uint8arrays": "^4.0.2",
|
"hi-base32": "^0.5.1",
|
||||||
"@libp2p/interface-peer-discovery": "^1.0.0",
|
"uint8arrays": "^4.0.3"
|
||||||
"@libp2p/interface-peer-info": "^1.0.1",
|
|
||||||
"@libp2p/interfaces": "^3.0.2",
|
|
||||||
"@libp2p/peer-id": "^1.1.10"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@waku/interfaces": "*",
|
"@libp2p/interface-peer-info": "^1.0.8",
|
||||||
"@multiformats/multiaddr": "^11.0.6",
|
"@libp2p/interface-peer-store": "^1.2.8",
|
||||||
"@libp2p/peer-id-factory": "^1.0.15",
|
"@libp2p/peer-id": "^2.0.1",
|
||||||
|
"@libp2p/peer-id-factory": "^2.0.1",
|
||||||
|
"@multiformats/multiaddr": "^11.4.0",
|
||||||
"@rollup/plugin-commonjs": "^22.0.0",
|
"@rollup/plugin-commonjs": "^22.0.0",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/parser": "^5.8.1",
|
||||||
"cspell": "^6.17.0",
|
"@waku/interfaces": "*",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
|
"cspell": "^6.17.0",
|
||||||
"eslint": "^8.6.0",
|
"eslint": "^8.6.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"@libp2p/interface-peer-discovery-compliance-tests": "^2.0.4",
|
|
||||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||||
"eslint-plugin-functional": "^4.0.2",
|
"eslint-plugin-functional": "^4.0.2",
|
||||||
"eslint-plugin-import": "^2.25.3",
|
"eslint-plugin-import": "^2.25.3",
|
||||||
|
|
|
@ -4,8 +4,9 @@ import type {
|
||||||
} from "@libp2p/interface-peer-discovery";
|
} from "@libp2p/interface-peer-discovery";
|
||||||
import { symbol } from "@libp2p/interface-peer-discovery";
|
import { symbol } from "@libp2p/interface-peer-discovery";
|
||||||
import type { PeerInfo } from "@libp2p/interface-peer-info";
|
import type { PeerInfo } from "@libp2p/interface-peer-info";
|
||||||
|
import type { PeerStore } from "@libp2p/interface-peer-store";
|
||||||
import { CustomEvent, EventEmitter } from "@libp2p/interfaces/events";
|
import { CustomEvent, EventEmitter } from "@libp2p/interfaces/events";
|
||||||
import type { IEnr, PeerExchangeComponents } from "@waku/interfaces";
|
import type { IEnr } from "@waku/interfaces";
|
||||||
import { multiaddrsToPeerInfo } from "@waku/utils";
|
import { multiaddrsToPeerInfo } from "@waku/utils";
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
|
|
||||||
|
@ -24,6 +25,10 @@ const DEFAULT_BOOTSTRAP_TAG_NAME = "bootstrap";
|
||||||
const DEFAULT_BOOTSTRAP_TAG_VALUE = 50;
|
const DEFAULT_BOOTSTRAP_TAG_VALUE = 50;
|
||||||
const DEFAULT_BOOTSTRAP_TAG_TTL = 120000;
|
const DEFAULT_BOOTSTRAP_TAG_TTL = 120000;
|
||||||
|
|
||||||
|
export interface DnsDiscoveryComponents {
|
||||||
|
peerStore: PeerStore;
|
||||||
|
}
|
||||||
|
|
||||||
export interface Options {
|
export interface Options {
|
||||||
/**
|
/**
|
||||||
* ENR URL to use for DNS discovery
|
* ENR URL to use for DNS discovery
|
||||||
|
@ -58,10 +63,10 @@ export class PeerDiscoveryDns
|
||||||
{
|
{
|
||||||
private readonly nextPeer: () => AsyncGenerator<IEnr>;
|
private readonly nextPeer: () => AsyncGenerator<IEnr>;
|
||||||
private _started: boolean;
|
private _started: boolean;
|
||||||
private _components: PeerExchangeComponents;
|
private _components: DnsDiscoveryComponents;
|
||||||
private _options: Options;
|
private _options: Options;
|
||||||
|
|
||||||
constructor(components: PeerExchangeComponents, options: Options) {
|
constructor(components: DnsDiscoveryComponents, options: Options) {
|
||||||
super();
|
super();
|
||||||
this._started = false;
|
this._started = false;
|
||||||
this._components = components;
|
this._components = components;
|
||||||
|
@ -125,8 +130,8 @@ export class PeerDiscoveryDns
|
||||||
export function wakuDnsDiscovery(
|
export function wakuDnsDiscovery(
|
||||||
enrUrl: string,
|
enrUrl: string,
|
||||||
wantedNodeCapabilityCount: Partial<NodeCapabilityCount>
|
wantedNodeCapabilityCount: Partial<NodeCapabilityCount>
|
||||||
): (components: PeerExchangeComponents) => PeerDiscoveryDns {
|
): (components: DnsDiscoveryComponents) => PeerDiscoveryDns {
|
||||||
return (components: PeerExchangeComponents) =>
|
return (components: DnsDiscoveryComponents) =>
|
||||||
new PeerDiscoveryDns(components, { enrUrl, wantedNodeCapabilityCount });
|
new PeerDiscoveryDns(components, { enrUrl, wantedNodeCapabilityCount });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,26 +54,25 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ethersproject/rlp": "^5.5.0",
|
"@ethersproject/rlp": "^5.5.0",
|
||||||
"@libp2p/crypto": "^1.0.4",
|
"@libp2p/crypto": "^1.0.11",
|
||||||
"@libp2p/interface-peer-id": "^1.0.2",
|
"@libp2p/peer-id": "^2.0.1",
|
||||||
"@libp2p/peer-id": "^1.1.10",
|
"@multiformats/multiaddr": "^11.4.0",
|
||||||
"@multiformats/multiaddr": "^11.0.6",
|
|
||||||
"@noble/secp256k1": "^1.3.4",
|
"@noble/secp256k1": "^1.3.4",
|
||||||
"@waku/utils": "*",
|
"@waku/utils": "*",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"js-sha3": "^0.8.0"
|
"js-sha3": "^0.8.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@waku/interfaces": "*",
|
"@libp2p/interface-peer-id": "^2.0.1",
|
||||||
"uint8arrays": "^4.0.2",
|
"@libp2p/peer-id-factory": "^2.0.1",
|
||||||
"@libp2p/peer-id-factory": "^1.0.15",
|
|
||||||
"@rollup/plugin-commonjs": "^22.0.0",
|
"@rollup/plugin-commonjs": "^22.0.0",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/parser": "^5.8.1",
|
||||||
"cspell": "^6.17.0",
|
"@waku/interfaces": "*",
|
||||||
"chai": "^4.3.6",
|
"chai": "^4.3.6",
|
||||||
|
"cspell": "^6.17.0",
|
||||||
"eslint": "^8.6.0",
|
"eslint": "^8.6.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||||
|
@ -84,7 +83,8 @@
|
||||||
"prettier": "^2.1.1",
|
"prettier": "^2.1.1",
|
||||||
"rollup": "^2.75.0",
|
"rollup": "^2.75.0",
|
||||||
"ts-loader": "^9.4.1",
|
"ts-loader": "^9.4.1",
|
||||||
"typescript": "^4.6.3"
|
"typescript": "^4.6.3",
|
||||||
|
"uint8arrays": "^4.0.3"
|
||||||
},
|
},
|
||||||
"typedoc": {
|
"typedoc": {
|
||||||
"entryPoint": "./src/index.ts"
|
"entryPoint": "./src/index.ts"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as RLP from "@ethersproject/rlp";
|
import * as RLP from "@ethersproject/rlp";
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||||
import { Multiaddr } from "@multiformats/multiaddr";
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||||
import {
|
import {
|
||||||
convertToBytes,
|
convertToBytes,
|
||||||
convertToString,
|
convertToString,
|
||||||
|
|
|
@ -48,15 +48,15 @@
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
|
||||||
"@chainsafe/libp2p-gossipsub": "^5.2.1",
|
|
||||||
"@libp2p/interface-connection": "^3.0.2",
|
|
||||||
"@libp2p/interface-peer-id": "^1.0.5",
|
|
||||||
"@libp2p/interface-peer-store": "^1.2.3",
|
|
||||||
"@multiformats/multiaddr": "^11.0.6",
|
|
||||||
"libp2p": "0.40.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@chainsafe/libp2p-gossipsub": "^6.1.0",
|
||||||
|
"@libp2p/interface-connection": "^3.0.8",
|
||||||
|
"@libp2p/interface-connection-manager": "^1.3.7",
|
||||||
|
"@libp2p/interface-libp2p": "^1.1.1",
|
||||||
|
"@libp2p/interface-peer-id": "^2.0.1",
|
||||||
|
"@libp2p/interface-peer-store": "^1.2.8",
|
||||||
|
"@libp2p/interface-registrar": "^2.0.8",
|
||||||
|
"@multiformats/multiaddr": "^11.4.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/parser": "^5.8.1",
|
||||||
"cspell": "^6.17.0",
|
"cspell": "^6.17.0",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Stream } from "@libp2p/interface-connection";
|
import type { Stream } from "@libp2p/interface-connection";
|
||||||
|
import type { Libp2p } from "@libp2p/interface-libp2p";
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||||
import type { Multiaddr } from "@multiformats/multiaddr";
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
||||||
import type { Libp2p } from "libp2p";
|
|
||||||
|
|
||||||
import type { IFilter } from "./filter.js";
|
import type { IFilter } from "./filter.js";
|
||||||
import type { ILightPush } from "./light_push.js";
|
import type { ILightPush } from "./light_push.js";
|
||||||
|
|
|
@ -74,19 +74,26 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/secp256k1": "^1.3.4",
|
"@noble/secp256k1": "^1.3.4",
|
||||||
"@waku/utils": "*",
|
|
||||||
"@waku/core": "*",
|
"@waku/core": "*",
|
||||||
"@waku/interfaces": "*",
|
"@waku/interfaces": "*",
|
||||||
"@waku/proto": "*",
|
"@waku/proto": "*",
|
||||||
|
"@waku/utils": "*",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"js-sha3": "^0.8.0"
|
"js-sha3": "^0.8.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@libp2p/interface-connection": "^3.0.8",
|
||||||
|
"@libp2p/interface-connection-manager": "^1.3.7",
|
||||||
|
"@libp2p/interface-libp2p": "^1.1.1",
|
||||||
|
"@libp2p/interface-peer-id": "^2.0.1",
|
||||||
|
"@libp2p/interface-peer-store": "^1.2.8",
|
||||||
|
"@libp2p/interface-registrar": "^2.0.8",
|
||||||
"@rollup/plugin-commonjs": "^22.0.0",
|
"@rollup/plugin-commonjs": "^22.0.0",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/parser": "^5.8.1",
|
||||||
|
"chai": "^4.3.6",
|
||||||
"cspell": "^6.17.0",
|
"cspell": "^6.17.0",
|
||||||
"eslint": "^8.6.0",
|
"eslint": "^8.6.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
|
@ -94,13 +101,12 @@
|
||||||
"eslint-plugin-functional": "^4.0.2",
|
"eslint-plugin-functional": "^4.0.2",
|
||||||
"eslint-plugin-import": "^2.25.3",
|
"eslint-plugin-import": "^2.25.3",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"fast-check": "^2.14.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^2.1.1",
|
"prettier": "^2.1.1",
|
||||||
"rollup": "^2.75.0",
|
"rollup": "^2.75.0",
|
||||||
"ts-loader": "^9.4.1",
|
"ts-loader": "^9.4.1",
|
||||||
"typescript": "^4.6.3",
|
"typescript": "^4.6.3"
|
||||||
"chai": "^4.3.6",
|
|
||||||
"fast-check": "^2.14.0"
|
|
||||||
},
|
},
|
||||||
"typedoc": {
|
"typedoc": {
|
||||||
"entryPoint": "./src/index.ts"
|
"entryPoint": "./src/index.ts"
|
||||||
|
|
|
@ -50,29 +50,29 @@
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@libp2p/interface-connection": "^3.0.3",
|
"@libp2p/interface-peer-discovery": "^1.0.5",
|
||||||
"@libp2p/interface-peer-discovery": "^1.0.0",
|
"@libp2p/interfaces": "^3.3.1",
|
||||||
"@libp2p/interface-peer-id": "^1.0.6",
|
|
||||||
"@libp2p/interface-peer-info": "^1.0.4",
|
|
||||||
"@libp2p/interface-peer-store": "^1.2.3",
|
|
||||||
"@waku/core": "*",
|
|
||||||
"@waku/enr": "*",
|
"@waku/enr": "*",
|
||||||
"@waku/interfaces": "*",
|
|
||||||
"@waku/utils": "*",
|
|
||||||
"@waku/proto": "*",
|
"@waku/proto": "*",
|
||||||
|
"@waku/utils": "*",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"it-all": "^1.0.6",
|
"it-all": "^1.0.6",
|
||||||
"it-length-prefixed": "^8.0.2",
|
"it-length-prefixed": "^8.0.2",
|
||||||
"it-pipe": "^2.0.4",
|
"it-pipe": "^2.0.4"
|
||||||
"uint8arraylist": "^2.3.2"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@libp2p/peer-id-factory": "^1.0.15",
|
"@libp2p/interface-connection": "^3.0.8",
|
||||||
|
"@libp2p/interface-connection-manager": "^1.3.7",
|
||||||
|
"@libp2p/interface-peer-id": "^2.0.1",
|
||||||
|
"@libp2p/interface-peer-info": "^1.0.8",
|
||||||
|
"@libp2p/interface-peer-store": "^1.2.8",
|
||||||
|
"@libp2p/interface-registrar": "^2.0.8",
|
||||||
"@rollup/plugin-commonjs": "^22.0.0",
|
"@rollup/plugin-commonjs": "^22.0.0",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/parser": "^5.8.1",
|
||||||
|
"@waku/interfaces": "*",
|
||||||
"chai": "^4.3.6",
|
"chai": "^4.3.6",
|
||||||
"cspell": "^6.17.0",
|
"cspell": "^6.17.0",
|
||||||
"eslint": "^8.6.0",
|
"eslint": "^8.6.0",
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
"rollup": "^2.75.0",
|
"rollup": "^2.75.0",
|
||||||
"ts-loader": "^9.4.1",
|
"ts-loader": "^9.4.1",
|
||||||
"typescript": "^4.6.3",
|
"typescript": "^4.6.3",
|
||||||
"uint8arrays": "^4.0.2"
|
"uint8arraylist": "^2.4.3"
|
||||||
},
|
},
|
||||||
"typedoc": {
|
"typedoc": {
|
||||||
"entryPoint": "./src/index.ts"
|
"entryPoint": "./src/index.ts"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { proto_peer_exchange as proto } from "@waku/proto";
|
import { proto_peer_exchange as proto } from "@waku/proto";
|
||||||
import { Uint8ArrayList } from "uint8arraylist";
|
import type { Uint8ArrayList } from "uint8arraylist";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PeerExchangeRPC represents a message conforming to the Waku Peer Exchange protocol
|
* PeerExchangeRPC represents a message conforming to the Waku Peer Exchange protocol
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
import type { Stream } from "@libp2p/interface-connection";
|
import type { Stream } from "@libp2p/interface-connection";
|
||||||
|
import type { ConnectionManager } from "@libp2p/interface-connection-manager";
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||||
import type { Peer, PeerStore } from "@libp2p/interface-peer-store";
|
import type { Peer, PeerStore } from "@libp2p/interface-peer-store";
|
||||||
import type { IncomingStreamData } from "@libp2p/interface-registrar";
|
import type {
|
||||||
|
IncomingStreamData,
|
||||||
|
Registrar,
|
||||||
|
} from "@libp2p/interface-registrar";
|
||||||
import { ENR } from "@waku/enr";
|
import { ENR } from "@waku/enr";
|
||||||
import type {
|
import type {
|
||||||
IPeerExchange,
|
IPeerExchange,
|
||||||
PeerExchangeComponents,
|
|
||||||
PeerExchangeQueryParams,
|
PeerExchangeQueryParams,
|
||||||
PeerExchangeResponse,
|
PeerExchangeResponse,
|
||||||
} from "@waku/interfaces";
|
} from "@waku/interfaces";
|
||||||
|
@ -25,6 +28,12 @@ export const PeerExchangeCodec = "/vac/waku/peer-exchange/2.0.0-alpha1";
|
||||||
|
|
||||||
const log = debug("waku:peer-exchange");
|
const log = debug("waku:peer-exchange");
|
||||||
|
|
||||||
|
export interface PeerExchangeComponents {
|
||||||
|
peerStore: PeerStore;
|
||||||
|
registrar: Registrar;
|
||||||
|
connectionManager: ConnectionManager;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of the Peer Exchange protocol (https://rfc.vac.dev/spec/34/)
|
* Implementation of the Peer Exchange protocol (https://rfc.vac.dev/spec/34/)
|
||||||
*/
|
*/
|
||||||
|
@ -111,7 +120,7 @@ export class WakuPeerExchange implements IPeerExchange {
|
||||||
*/
|
*/
|
||||||
private async getPeer(peerId?: PeerId): Promise<Peer> {
|
private async getPeer(peerId?: PeerId): Promise<Peer> {
|
||||||
const res = await selectPeerForProtocol(
|
const res = await selectPeerForProtocol(
|
||||||
this.components.peerStore,
|
this.peerStore,
|
||||||
[PeerExchangeCodec],
|
[PeerExchangeCodec],
|
||||||
peerId
|
peerId
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
import {
|
import type {
|
||||||
PeerDiscovery,
|
PeerDiscovery,
|
||||||
PeerDiscoveryEvents,
|
PeerDiscoveryEvents,
|
||||||
symbol,
|
|
||||||
} from "@libp2p/interface-peer-discovery";
|
} from "@libp2p/interface-peer-discovery";
|
||||||
|
import { symbol } from "@libp2p/interface-peer-discovery";
|
||||||
import type { PeerId } from "@libp2p/interface-peer-id";
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
||||||
import { PeerInfo } from "@libp2p/interface-peer-info";
|
import type { PeerInfo } from "@libp2p/interface-peer-info";
|
||||||
import { PeerProtocolsChangeData } from "@libp2p/interface-peer-store";
|
import type { PeerProtocolsChangeData } from "@libp2p/interface-peer-store";
|
||||||
import { EventEmitter } from "@libp2p/interfaces/events";
|
import { EventEmitter } from "@libp2p/interfaces/events";
|
||||||
import { PeerExchangeComponents } from "@waku/interfaces";
|
|
||||||
import debug from "debug";
|
import debug from "debug";
|
||||||
|
|
||||||
import { PeerExchangeCodec, WakuPeerExchange } from "./waku_peer_exchange.js";
|
import {
|
||||||
|
PeerExchangeCodec,
|
||||||
|
PeerExchangeComponents,
|
||||||
|
WakuPeerExchange,
|
||||||
|
} from "./waku_peer_exchange.js";
|
||||||
|
|
||||||
const log = debug("waku:peer-exchange-discovery");
|
const log = debug("waku:peer-exchange-discovery");
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,10 @@
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^2.1.1",
|
"prettier": "^2.1.1",
|
||||||
|
"protons": "^5.1.0",
|
||||||
"rollup": "^2.75.0",
|
"rollup": "^2.75.0",
|
||||||
"typescript": "^4.6.3",
|
"typescript": "^4.6.3",
|
||||||
"protons": "^5.1.0"
|
"uint8arraylist": "^2.4.3"
|
||||||
},
|
},
|
||||||
"typedoc": {
|
"typedoc": {
|
||||||
"entryPoint": "./src/index.ts"
|
"entryPoint": "./src/index.ts"
|
||||||
|
|
|
@ -55,37 +55,39 @@
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@libp2p/components": "^3.1.1",
|
"@libp2p/peer-id": "^2.0.1",
|
||||||
"@waku/utils": "*",
|
|
||||||
"@waku/core": "*",
|
"@waku/core": "*",
|
||||||
"@waku/create": "*",
|
|
||||||
"@waku/dns-discovery": "*",
|
|
||||||
"@waku/enr": "*",
|
"@waku/enr": "*",
|
||||||
"@waku/interfaces": "*",
|
"@waku/interfaces": "*",
|
||||||
"@waku/message-encryption": "*",
|
"@waku/utils": "*",
|
||||||
"@waku/peer-exchange": "*",
|
|
||||||
"app-root-path": "^3.0.0",
|
"app-root-path": "^3.0.0",
|
||||||
"chai": "^4.3.6",
|
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"mocha": "^9.1.3",
|
|
||||||
"p-timeout": "^6.0.0",
|
"p-timeout": "^6.0.0",
|
||||||
"portfinder": "^1.0.28",
|
"portfinder": "^1.0.28",
|
||||||
"tail": "^2.2.0"
|
"tail": "^2.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "^9.1.3",
|
"@libp2p/bootstrap": "^6.0.0",
|
||||||
"chai": "^4.3.6",
|
"@libp2p/components": "^3.1.1",
|
||||||
"debug": "^4.3.4",
|
"@libp2p/interface-peer-discovery-compliance-tests": "^2.0.5",
|
||||||
"@libp2p/bootstrap": "^5.0.0",
|
"@libp2p/interface-peer-id": "^2.0.1",
|
||||||
|
"@types/tail": "^2.2.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
||||||
"@typescript-eslint/parser": "^5.8.1",
|
"@typescript-eslint/parser": "^5.8.1",
|
||||||
|
"@waku/create": "*",
|
||||||
|
"@waku/dns-discovery": "*",
|
||||||
|
"@waku/message-encryption": "*",
|
||||||
|
"@waku/peer-exchange": "*",
|
||||||
|
"chai": "^4.3.6",
|
||||||
"cspell": "^6.17.0",
|
"cspell": "^6.17.0",
|
||||||
|
"debug": "^4.3.4",
|
||||||
"eslint": "^8.6.0",
|
"eslint": "^8.6.0",
|
||||||
"eslint-config-prettier": "^8.3.0",
|
"eslint-config-prettier": "^8.3.0",
|
||||||
"eslint-plugin-eslint-comments": "^3.2.0",
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
||||||
"eslint-plugin-functional": "^4.0.2",
|
"eslint-plugin-functional": "^4.0.2",
|
||||||
"eslint-plugin-import": "^2.25.3",
|
"eslint-plugin-import": "^2.25.3",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"mocha": "^9.1.3",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^2.1.1",
|
"prettier": "^2.1.1",
|
||||||
"typescript": "^4.6.3"
|
"typescript": "^4.6.3"
|
||||||
|
|
|
@ -102,7 +102,7 @@ describe("Waku Relay [node only]", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Register correct protocols", async function () {
|
it("Register correct protocols", async function () {
|
||||||
const protocols = waku1.libp2p.registrar.getProtocols();
|
const protocols = waku1.libp2p.getProtocols();
|
||||||
|
|
||||||
expect(protocols).to.contain("/vac/waku/relay/2.0.0");
|
expect(protocols).to.contain("/vac/waku/relay/2.0.0");
|
||||||
expect(protocols.findIndex((value) => value.match(/sub/))).to.eq(-1);
|
expect(protocols.findIndex((value) => value.match(/sub/))).to.eq(-1);
|
||||||
|
|
|
@ -85,12 +85,9 @@ describe("Waku Dial [node only]", function () {
|
||||||
await waku.start();
|
await waku.start();
|
||||||
|
|
||||||
const connectedPeerID: PeerId = await new Promise((resolve) => {
|
const connectedPeerID: PeerId = await new Promise((resolve) => {
|
||||||
waku.libp2p.connectionManager.addEventListener(
|
waku.libp2p.addEventListener("peer:connect", (evt) => {
|
||||||
"peer:connect",
|
|
||||||
(evt) => {
|
|
||||||
resolve(evt.detail.remotePeer);
|
resolve(evt.detail.remotePeer);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(connectedPeerID.toString()).to.eq(multiAddrWithId.getPeerId());
|
expect(connectedPeerID.toString()).to.eq(multiAddrWithId.getPeerId());
|
||||||
|
@ -113,12 +110,9 @@ describe("Waku Dial [node only]", function () {
|
||||||
await waku.start();
|
await waku.start();
|
||||||
|
|
||||||
const connectedPeerID: PeerId = await new Promise((resolve) => {
|
const connectedPeerID: PeerId = await new Promise((resolve) => {
|
||||||
waku.libp2p.connectionManager.addEventListener(
|
waku.libp2p.addEventListener("peer:connect", (evt) => {
|
||||||
"peer:connect",
|
|
||||||
(evt) => {
|
|
||||||
resolve(evt.detail.remotePeer);
|
resolve(evt.detail.remotePeer);
|
||||||
}
|
});
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const multiAddrWithId = await nwaku.getMultiaddrWithId();
|
const multiAddrWithId = await nwaku.getMultiaddrWithId();
|
||||||
|
|
|
@ -50,10 +50,16 @@
|
||||||
"node": ">=16"
|
"node": ">=16"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@libp2p/peer-id": "^2.0.1",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"uint8arrays": "^4.0.2"
|
"uint8arrays": "^4.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@libp2p/interface-connection": "^3.0.8",
|
||||||
|
"@libp2p/interface-peer-id": "^2.0.1",
|
||||||
|
"@libp2p/interface-peer-info": "^1.0.8",
|
||||||
|
"@libp2p/interface-peer-store": "^1.2.8",
|
||||||
|
"@multiformats/multiaddr": "^11.4.0",
|
||||||
"@rollup/plugin-commonjs": "^22.0.0",
|
"@rollup/plugin-commonjs": "^22.0.0",
|
||||||
"@rollup/plugin-json": "^4.1.0",
|
"@rollup/plugin-json": "^4.1.0",
|
||||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||||
|
|
|
@ -8,9 +8,10 @@ module.exports = {
|
||||||
out: "docs",
|
out: "docs",
|
||||||
exclude: ["**/*.spec.ts"],
|
exclude: ["**/*.spec.ts"],
|
||||||
excludeInternal: true,
|
excludeInternal: true,
|
||||||
|
treatWarningsAsErrors: true,
|
||||||
|
excludeExternals: true,
|
||||||
validation: {
|
validation: {
|
||||||
invalidLink: true,
|
invalidLink: true,
|
||||||
notExported: true,
|
notExported: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
packageJson.workspaces;
|
|
||||||
|
|
Loading…
Reference in New Issue