@waku/interfaces 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/connection_manager.d.ts +24 -0
- package/dist/connection_manager.js +7 -0
- package/dist/connection_manager.js.map +1 -1
- package/dist/filter.d.ts +4 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/libp2p.d.ts +14 -0
- package/dist/libp2p.js +2 -0
- package/dist/libp2p.js.map +1 -0
- package/dist/light_push.d.ts +2 -2
- package/dist/peer_exchange.d.ts +2 -2
- package/dist/protocols.d.ts +4 -7
- package/dist/protocols.js.map +1 -1
- package/dist/store.d.ts +2 -2
- package/dist/waku.d.ts +5 -5
- package/package.json +11 -18
- package/src/connection_manager.ts +28 -0
- package/src/filter.ts +5 -7
- package/src/index.ts +1 -0
- package/src/libp2p.ts +21 -0
- package/src/light_push.ts +2 -2
- package/src/peer_exchange.ts +2 -2
- package/src/protocols.ts +4 -7
- package/src/store.ts +2 -2
- package/src/waku.ts +5 -5
package/CHANGELOG.md
CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.0.16](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.15...interfaces-v0.0.16) (2023-07-26)
|
9
|
+
|
10
|
+
|
11
|
+
### ⚠ BREAKING CHANGES
|
12
|
+
|
13
|
+
* remove filter v1 ([#1433](https://github.com/waku-org/js-waku/issues/1433))
|
14
|
+
* upgrade to libp2p@0.45 ([#1400](https://github.com/waku-org/js-waku/issues/1400))
|
15
|
+
|
16
|
+
### Features
|
17
|
+
|
18
|
+
* Enable event emission for peer discovery/connection in ConnectionManager ([#1438](https://github.com/waku-org/js-waku/issues/1438)) ([6ce898d](https://github.com/waku-org/js-waku/commit/6ce898d77132f30b5d8f33b48c7f6276992a486e))
|
19
|
+
* Upgrade to libp2p@0.45 ([#1400](https://github.com/waku-org/js-waku/issues/1400)) ([420e6c6](https://github.com/waku-org/js-waku/commit/420e6c698dd8f44d40d34e47d876da5d2e1ce85e))
|
20
|
+
|
21
|
+
|
22
|
+
### Miscellaneous Chores
|
23
|
+
|
24
|
+
* Remove filter v1 ([#1433](https://github.com/waku-org/js-waku/issues/1433)) ([d483644](https://github.com/waku-org/js-waku/commit/d483644a4bb4350df380719b9bcfbdd0b1439482))
|
25
|
+
|
8
26
|
## [0.0.15](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.14...interfaces-v0.0.15) (2023-06-08)
|
9
27
|
|
10
28
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import type { PeerId } from "@libp2p/interface-peer-id";
|
2
|
+
import type { Peer } from "@libp2p/interface-peer-store";
|
1
3
|
export declare enum Tags {
|
2
4
|
BOOTSTRAP = "bootstrap",
|
3
5
|
PEER_EXCHANGE = "peer-exchange"
|
@@ -18,3 +20,25 @@ export interface ConnectionManagerOptions {
|
|
18
20
|
*/
|
19
21
|
maxParallelDials: number;
|
20
22
|
}
|
23
|
+
export declare enum EPeersByDiscoveryEvents {
|
24
|
+
PEER_DISCOVERY_BOOTSTRAP = "peer:discovery:bootstrap",
|
25
|
+
PEER_DISCOVERY_PEER_EXCHANGE = "peer:discovery:peer-exchange",
|
26
|
+
PEER_CONNECT_BOOTSTRAP = "peer:connected:bootstrap",
|
27
|
+
PEER_CONNECT_PEER_EXCHANGE = "peer:connected:peer-exchange"
|
28
|
+
}
|
29
|
+
export interface IPeersByDiscoveryEvents {
|
30
|
+
[EPeersByDiscoveryEvents.PEER_DISCOVERY_BOOTSTRAP]: CustomEvent<PeerId>;
|
31
|
+
[EPeersByDiscoveryEvents.PEER_DISCOVERY_PEER_EXCHANGE]: CustomEvent<PeerId>;
|
32
|
+
[EPeersByDiscoveryEvents.PEER_CONNECT_BOOTSTRAP]: CustomEvent<PeerId>;
|
33
|
+
[EPeersByDiscoveryEvents.PEER_CONNECT_PEER_EXCHANGE]: CustomEvent<PeerId>;
|
34
|
+
}
|
35
|
+
export interface PeersByDiscoveryResult {
|
36
|
+
DISCOVERED: {
|
37
|
+
[Tags.BOOTSTRAP]: Peer[];
|
38
|
+
[Tags.PEER_EXCHANGE]: Peer[];
|
39
|
+
};
|
40
|
+
CONNECTED: {
|
41
|
+
[Tags.BOOTSTRAP]: Peer[];
|
42
|
+
[Tags.PEER_EXCHANGE]: Peer[];
|
43
|
+
};
|
44
|
+
}
|
@@ -3,4 +3,11 @@ export var Tags;
|
|
3
3
|
Tags["BOOTSTRAP"] = "bootstrap";
|
4
4
|
Tags["PEER_EXCHANGE"] = "peer-exchange";
|
5
5
|
})(Tags || (Tags = {}));
|
6
|
+
export var EPeersByDiscoveryEvents;
|
7
|
+
(function (EPeersByDiscoveryEvents) {
|
8
|
+
EPeersByDiscoveryEvents["PEER_DISCOVERY_BOOTSTRAP"] = "peer:discovery:bootstrap";
|
9
|
+
EPeersByDiscoveryEvents["PEER_DISCOVERY_PEER_EXCHANGE"] = "peer:discovery:peer-exchange";
|
10
|
+
EPeersByDiscoveryEvents["PEER_CONNECT_BOOTSTRAP"] = "peer:connected:bootstrap";
|
11
|
+
EPeersByDiscoveryEvents["PEER_CONNECT_PEER_EXCHANGE"] = "peer:connected:peer-exchange";
|
12
|
+
})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));
|
6
13
|
//# sourceMappingURL=connection_manager.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"connection_manager.js","sourceRoot":"","sources":["../src/connection_manager.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"connection_manager.js","sourceRoot":"","sources":["../src/connection_manager.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,IAGX;AAHD,WAAY,IAAI;IACd,+BAAuB,CAAA;IACvB,uCAA+B,CAAA;AACjC,CAAC,EAHW,IAAI,KAAJ,IAAI,QAGf;AAmBD,MAAM,CAAN,IAAY,uBAKX;AALD,WAAY,uBAAuB;IACjC,gFAAqD,CAAA;IACrD,wFAA6D,CAAA;IAC7D,8EAAmD,CAAA;IACnD,sFAA2D,CAAA;AAC7D,CAAC,EALW,uBAAuB,KAAvB,uBAAuB,QAKlC"}
|
package/dist/filter.d.ts
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
2
2
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
3
3
|
import type { ContentTopic } from "./misc.js";
|
4
|
-
import type { Callback,
|
4
|
+
import type { Callback, IBaseProtocol } from "./protocols.js";
|
5
5
|
import type { IReceiver } from "./receiver.js";
|
6
6
|
export type ContentFilter = {
|
7
7
|
contentTopic: string;
|
8
8
|
};
|
9
|
-
export
|
10
|
-
export interface IFilterV2Subscription {
|
9
|
+
export interface IFilterSubscription {
|
11
10
|
subscribe<T extends IDecodedMessage>(decoders: IDecoder<T> | IDecoder<T>[], callback: Callback<T>): Promise<void>;
|
12
11
|
unsubscribe(contentTopics: ContentTopic[]): Promise<void>;
|
13
12
|
ping(): Promise<void>;
|
14
13
|
unsubscribeAll(): Promise<void>;
|
15
14
|
}
|
16
|
-
export type
|
17
|
-
createSubscription(pubSubTopic?: string, peerId?: PeerId): Promise<
|
15
|
+
export type IFilter = IReceiver & IBaseProtocol & {
|
16
|
+
createSubscription(pubSubTopic?: string, peerId?: PeerId): Promise<IFilterSubscription>;
|
18
17
|
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/dist/libp2p.d.ts
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
|
2
|
+
import type { Libp2p as BaseLibp2p } from "@libp2p/interface-libp2p";
|
3
|
+
import type { Libp2pInit } from "libp2p";
|
4
|
+
import type { identifyService } from "libp2p/identify";
|
5
|
+
import type { PingService } from "libp2p/ping";
|
6
|
+
export type Libp2pServices = {
|
7
|
+
ping: PingService;
|
8
|
+
pubsub?: GossipSub;
|
9
|
+
identify: ReturnType<ReturnType<typeof identifyService>>;
|
10
|
+
};
|
11
|
+
export type Libp2pComponents = Parameters<Exclude<Libp2pInit["metrics"], undefined>>[0];
|
12
|
+
export type Libp2p = BaseLibp2p<Libp2pServices> & {
|
13
|
+
components: Libp2pComponents;
|
14
|
+
};
|
package/dist/libp2p.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"libp2p.js","sourceRoot":"","sources":["../src/libp2p.ts"],"names":[],"mappings":""}
|
package/dist/light_push.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import type {
|
1
|
+
import type { IBaseProtocol } from "./protocols.js";
|
2
2
|
import type { ISender } from "./sender.js";
|
3
|
-
export type ILightPush = ISender &
|
3
|
+
export type ILightPush = ISender & IBaseProtocol;
|
package/dist/peer_exchange.d.ts
CHANGED
@@ -2,8 +2,8 @@ import type { ConnectionManager } from "@libp2p/interface-connection-manager";
|
|
2
2
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
3
3
|
import type { PeerStore } from "@libp2p/interface-peer-store";
|
4
4
|
import { IEnr } from "./enr.js";
|
5
|
-
import {
|
6
|
-
export interface IPeerExchange extends
|
5
|
+
import { IBaseProtocol } from "./protocols.js";
|
6
|
+
export interface IPeerExchange extends IBaseProtocol {
|
7
7
|
query(params: PeerExchangeQueryParams): Promise<PeerInfo[] | undefined>;
|
8
8
|
}
|
9
9
|
export interface PeerExchangeQueryParams {
|
package/dist/protocols.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { Libp2p } from "@libp2p/interface-libp2p";
|
1
2
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
2
3
|
import type { Peer, PeerStore } from "@libp2p/interface-peer-store";
|
3
4
|
import type { Libp2pOptions } from "libp2p";
|
@@ -8,10 +9,12 @@ export declare enum Protocols {
|
|
8
9
|
LightPush = "lightpush",
|
9
10
|
Filter = "filter"
|
10
11
|
}
|
11
|
-
export interface
|
12
|
+
export interface IBaseProtocol {
|
12
13
|
multicodec: string;
|
13
14
|
peerStore: PeerStore;
|
14
15
|
peers: () => Promise<Peer[]>;
|
16
|
+
addLibp2pEventListener: Libp2p["addEventListener"];
|
17
|
+
removeLibp2pEventListener: Libp2p["removeEventListener"];
|
15
18
|
}
|
16
19
|
export type ProtocolCreateOptions = {
|
17
20
|
/**
|
@@ -45,12 +48,6 @@ export type ProtocolCreateOptions = {
|
|
45
48
|
* Use recommended bootstrap method to discovery and connect to new nodes.
|
46
49
|
*/
|
47
50
|
defaultBootstrap?: boolean;
|
48
|
-
/**
|
49
|
-
* FilterV2 has been set to default
|
50
|
-
* Use this flag to enable the previous version of the filter protocol
|
51
|
-
* See [Improved Filter protocol specifications](https://github.com/vacp2p/rfc/pull/562)
|
52
|
-
*/
|
53
|
-
useFilterV1?: boolean;
|
54
51
|
};
|
55
52
|
export type ProtocolOptions = {
|
56
53
|
/**
|
package/dist/protocols.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"AAOA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AAuDD,MAAM,CAAN,IAAY,SAMX;AAND,WAAY,SAAS;IACnB,2CAA8B,CAAA;IAC9B,+CAAkC,CAAA;IAClC,+CAAkC,CAAA;IAClC,6CAAgC,CAAA;IAChC,gDAAmC,CAAA;AACrC,CAAC,EANW,SAAS,KAAT,SAAS,QAMpB"}
|
package/dist/store.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
2
|
-
import type {
|
2
|
+
import type { IBaseProtocol, ProtocolOptions } from "./protocols.js";
|
3
3
|
export declare enum PageDirection {
|
4
4
|
BACKWARD = "backward",
|
5
5
|
FORWARD = "forward"
|
@@ -40,7 +40,7 @@ export type StoreQueryOptions = {
|
|
40
40
|
*/
|
41
41
|
cursor?: Cursor;
|
42
42
|
} & ProtocolOptions;
|
43
|
-
export interface IStore extends
|
43
|
+
export interface IStore extends IBaseProtocol {
|
44
44
|
queryOrderedCallback: <T extends IDecodedMessage>(decoders: IDecoder<T>[], callback: (message: T) => Promise<void | boolean> | boolean | void, options?: StoreQueryOptions) => Promise<void>;
|
45
45
|
queryCallbackOnPromise: <T extends IDecodedMessage>(decoders: IDecoder<T>[], callback: (message: Promise<T | undefined>) => Promise<void | boolean> | boolean | void, options?: StoreQueryOptions) => Promise<void>;
|
46
46
|
queryGenerator: <T extends IDecodedMessage>(decoders: IDecoder<T>[], options?: StoreQueryOptions) => AsyncGenerator<Promise<T | undefined>[]>;
|
package/dist/waku.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import type { Stream } from "@libp2p/interface-connection";
|
2
|
-
import type { Libp2p } from "@libp2p/interface-libp2p";
|
3
2
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
4
3
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
5
|
-
import type { IFilter
|
4
|
+
import type { IFilter } from "./filter.js";
|
5
|
+
import type { Libp2p } from "./libp2p.js";
|
6
6
|
import type { ILightPush } from "./light_push.js";
|
7
7
|
import { Protocols } from "./protocols.js";
|
8
8
|
import type { IRelay } from "./relay.js";
|
@@ -11,7 +11,7 @@ export interface Waku {
|
|
11
11
|
libp2p: Libp2p;
|
12
12
|
relay?: IRelay;
|
13
13
|
store?: IStore;
|
14
|
-
filter?: IFilter
|
14
|
+
filter?: IFilter;
|
15
15
|
lightPush?: ILightPush;
|
16
16
|
dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise<Stream>;
|
17
17
|
start(): Promise<void>;
|
@@ -21,7 +21,7 @@ export interface Waku {
|
|
21
21
|
export interface LightNode extends Waku {
|
22
22
|
relay: undefined;
|
23
23
|
store: IStore;
|
24
|
-
filter: IFilter
|
24
|
+
filter: IFilter;
|
25
25
|
lightPush: ILightPush;
|
26
26
|
}
|
27
27
|
export interface RelayNode extends Waku {
|
@@ -33,6 +33,6 @@ export interface RelayNode extends Waku {
|
|
33
33
|
export interface FullNode extends Waku {
|
34
34
|
relay: IRelay;
|
35
35
|
store: IStore;
|
36
|
-
filter: IFilter
|
36
|
+
filter: IFilter;
|
37
37
|
lightPush: ILightPush;
|
38
38
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@waku/interfaces",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.16",
|
4
4
|
"description": "Definition of Waku interfaces",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"module": "./dist/index.js",
|
@@ -47,27 +47,20 @@
|
|
47
47
|
"node": ">=16"
|
48
48
|
},
|
49
49
|
"devDependencies": {
|
50
|
-
"@chainsafe/libp2p-gossipsub": "^
|
51
|
-
"@libp2p/interface-connection": "^
|
52
|
-
"@libp2p/interface-connection-manager": "^
|
53
|
-
"@libp2p/interface-libp2p": "^
|
54
|
-
"@libp2p/interface-peer-id": "^2.0.
|
55
|
-
"@libp2p/interface-peer-info": "^1.0.
|
56
|
-
"@libp2p/interface-peer-store": "^
|
57
|
-
"@libp2p/interface-registrar": "^2.0.
|
50
|
+
"@chainsafe/libp2p-gossipsub": "^9.1.0",
|
51
|
+
"@libp2p/interface-connection": "^5.1.1",
|
52
|
+
"@libp2p/interface-connection-manager": "^3.0.1",
|
53
|
+
"@libp2p/interface-libp2p": "^3.2.0",
|
54
|
+
"@libp2p/interface-peer-id": "^2.0.2",
|
55
|
+
"@libp2p/interface-peer-info": "^1.0.10",
|
56
|
+
"@libp2p/interface-peer-store": "^2.0.4",
|
57
|
+
"@libp2p/interface-registrar": "^2.0.12",
|
58
58
|
"@multiformats/multiaddr": "^12.0.0",
|
59
|
-
"@typescript-eslint/eslint-plugin": "^5.57.0",
|
60
|
-
"@typescript-eslint/parser": "^5.59.8",
|
61
59
|
"cspell": "^6.31.1",
|
62
|
-
"eslint": "^8.41.0",
|
63
|
-
"eslint-config-prettier": "^8.6.0",
|
64
|
-
"eslint-plugin-eslint-comments": "^3.2.0",
|
65
|
-
"eslint-plugin-functional": "^5.0.4",
|
66
|
-
"eslint-plugin-import": "^2.27.5",
|
67
|
-
"eslint-plugin-prettier": "^4.2.1",
|
68
60
|
"npm-run-all": "^4.1.5",
|
69
61
|
"prettier": "^2.8.8",
|
70
|
-
"typescript": "^5.0.4"
|
62
|
+
"typescript": "^5.0.4",
|
63
|
+
"libp2p": "^0.45.9"
|
71
64
|
},
|
72
65
|
"typedoc": {
|
73
66
|
"entryPoint": "./src/index.ts"
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import type { PeerId } from "@libp2p/interface-peer-id";
|
2
|
+
import type { Peer } from "@libp2p/interface-peer-store";
|
3
|
+
|
1
4
|
export enum Tags {
|
2
5
|
BOOTSTRAP = "bootstrap",
|
3
6
|
PEER_EXCHANGE = "peer-exchange",
|
@@ -19,3 +22,28 @@ export interface ConnectionManagerOptions {
|
|
19
22
|
*/
|
20
23
|
maxParallelDials: number;
|
21
24
|
}
|
25
|
+
|
26
|
+
export enum EPeersByDiscoveryEvents {
|
27
|
+
PEER_DISCOVERY_BOOTSTRAP = "peer:discovery:bootstrap",
|
28
|
+
PEER_DISCOVERY_PEER_EXCHANGE = "peer:discovery:peer-exchange",
|
29
|
+
PEER_CONNECT_BOOTSTRAP = "peer:connected:bootstrap",
|
30
|
+
PEER_CONNECT_PEER_EXCHANGE = "peer:connected:peer-exchange",
|
31
|
+
}
|
32
|
+
|
33
|
+
export interface IPeersByDiscoveryEvents {
|
34
|
+
[EPeersByDiscoveryEvents.PEER_DISCOVERY_BOOTSTRAP]: CustomEvent<PeerId>;
|
35
|
+
[EPeersByDiscoveryEvents.PEER_DISCOVERY_PEER_EXCHANGE]: CustomEvent<PeerId>;
|
36
|
+
[EPeersByDiscoveryEvents.PEER_CONNECT_BOOTSTRAP]: CustomEvent<PeerId>;
|
37
|
+
[EPeersByDiscoveryEvents.PEER_CONNECT_PEER_EXCHANGE]: CustomEvent<PeerId>;
|
38
|
+
}
|
39
|
+
|
40
|
+
export interface PeersByDiscoveryResult {
|
41
|
+
DISCOVERED: {
|
42
|
+
[Tags.BOOTSTRAP]: Peer[];
|
43
|
+
[Tags.PEER_EXCHANGE]: Peer[];
|
44
|
+
};
|
45
|
+
CONNECTED: {
|
46
|
+
[Tags.BOOTSTRAP]: Peer[];
|
47
|
+
[Tags.PEER_EXCHANGE]: Peer[];
|
48
|
+
};
|
49
|
+
}
|
package/src/filter.ts
CHANGED
@@ -2,16 +2,14 @@ import type { PeerId } from "@libp2p/interface-peer-id";
|
|
2
2
|
|
3
3
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
4
4
|
import type { ContentTopic } from "./misc.js";
|
5
|
-
import type { Callback,
|
5
|
+
import type { Callback, IBaseProtocol } from "./protocols.js";
|
6
6
|
import type { IReceiver } from "./receiver.js";
|
7
7
|
|
8
8
|
export type ContentFilter = {
|
9
9
|
contentTopic: string;
|
10
10
|
};
|
11
11
|
|
12
|
-
export
|
13
|
-
|
14
|
-
export interface IFilterV2Subscription {
|
12
|
+
export interface IFilterSubscription {
|
15
13
|
subscribe<T extends IDecodedMessage>(
|
16
14
|
decoders: IDecoder<T> | IDecoder<T>[],
|
17
15
|
callback: Callback<T>
|
@@ -24,10 +22,10 @@ export interface IFilterV2Subscription {
|
|
24
22
|
unsubscribeAll(): Promise<void>;
|
25
23
|
}
|
26
24
|
|
27
|
-
export type
|
28
|
-
|
25
|
+
export type IFilter = IReceiver &
|
26
|
+
IBaseProtocol & {
|
29
27
|
createSubscription(
|
30
28
|
pubSubTopic?: string,
|
31
29
|
peerId?: PeerId
|
32
|
-
): Promise<
|
30
|
+
): Promise<IFilterSubscription>;
|
33
31
|
};
|
package/src/index.ts
CHANGED
package/src/libp2p.ts
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
import type { GossipSub } from "@chainsafe/libp2p-gossipsub";
|
2
|
+
import type { Libp2p as BaseLibp2p } from "@libp2p/interface-libp2p";
|
3
|
+
import type { Libp2pInit } from "libp2p";
|
4
|
+
import type { identifyService } from "libp2p/identify";
|
5
|
+
import type { PingService } from "libp2p/ping";
|
6
|
+
|
7
|
+
export type Libp2pServices = {
|
8
|
+
ping: PingService;
|
9
|
+
pubsub?: GossipSub;
|
10
|
+
identify: ReturnType<ReturnType<typeof identifyService>>;
|
11
|
+
};
|
12
|
+
|
13
|
+
// TODO: Get libp2p to export this.
|
14
|
+
export type Libp2pComponents = Parameters<
|
15
|
+
Exclude<Libp2pInit["metrics"], undefined>
|
16
|
+
>[0];
|
17
|
+
|
18
|
+
// thought components are not defined on the Libp2p interface they are present on Libp2pNode class
|
19
|
+
export type Libp2p = BaseLibp2p<Libp2pServices> & {
|
20
|
+
components: Libp2pComponents;
|
21
|
+
};
|
package/src/light_push.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type {
|
1
|
+
import type { IBaseProtocol } from "./protocols.js";
|
2
2
|
import type { ISender } from "./sender.js";
|
3
3
|
|
4
|
-
export type ILightPush = ISender &
|
4
|
+
export type ILightPush = ISender & IBaseProtocol;
|
package/src/peer_exchange.ts
CHANGED
@@ -3,9 +3,9 @@ import type { PeerId } from "@libp2p/interface-peer-id";
|
|
3
3
|
import type { PeerStore } from "@libp2p/interface-peer-store";
|
4
4
|
|
5
5
|
import { IEnr } from "./enr.js";
|
6
|
-
import {
|
6
|
+
import { IBaseProtocol } from "./protocols.js";
|
7
7
|
|
8
|
-
export interface IPeerExchange extends
|
8
|
+
export interface IPeerExchange extends IBaseProtocol {
|
9
9
|
query(params: PeerExchangeQueryParams): Promise<PeerInfo[] | undefined>;
|
10
10
|
}
|
11
11
|
|
package/src/protocols.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import type { Libp2p } from "@libp2p/interface-libp2p";
|
1
2
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
2
3
|
import type { Peer, PeerStore } from "@libp2p/interface-peer-store";
|
3
4
|
import type { Libp2pOptions } from "libp2p";
|
@@ -11,10 +12,12 @@ export enum Protocols {
|
|
11
12
|
Filter = "filter",
|
12
13
|
}
|
13
14
|
|
14
|
-
export interface
|
15
|
+
export interface IBaseProtocol {
|
15
16
|
multicodec: string;
|
16
17
|
peerStore: PeerStore;
|
17
18
|
peers: () => Promise<Peer[]>;
|
19
|
+
addLibp2pEventListener: Libp2p["addEventListener"];
|
20
|
+
removeLibp2pEventListener: Libp2p["removeEventListener"];
|
18
21
|
}
|
19
22
|
|
20
23
|
export type ProtocolCreateOptions = {
|
@@ -49,12 +52,6 @@ export type ProtocolCreateOptions = {
|
|
49
52
|
* Use recommended bootstrap method to discovery and connect to new nodes.
|
50
53
|
*/
|
51
54
|
defaultBootstrap?: boolean;
|
52
|
-
/**
|
53
|
-
* FilterV2 has been set to default
|
54
|
-
* Use this flag to enable the previous version of the filter protocol
|
55
|
-
* See [Improved Filter protocol specifications](https://github.com/vacp2p/rfc/pull/562)
|
56
|
-
*/
|
57
|
-
useFilterV1?: boolean;
|
58
55
|
};
|
59
56
|
|
60
57
|
export type ProtocolOptions = {
|
package/src/store.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
2
|
-
import type {
|
2
|
+
import type { IBaseProtocol, ProtocolOptions } from "./protocols.js";
|
3
3
|
|
4
4
|
export enum PageDirection {
|
5
5
|
BACKWARD = "backward",
|
@@ -45,7 +45,7 @@ export type StoreQueryOptions = {
|
|
45
45
|
cursor?: Cursor;
|
46
46
|
} & ProtocolOptions;
|
47
47
|
|
48
|
-
export interface IStore extends
|
48
|
+
export interface IStore extends IBaseProtocol {
|
49
49
|
queryOrderedCallback: <T extends IDecodedMessage>(
|
50
50
|
decoders: IDecoder<T>[],
|
51
51
|
callback: (message: T) => Promise<void | boolean> | boolean | void,
|
package/src/waku.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import type { Stream } from "@libp2p/interface-connection";
|
2
|
-
import type { Libp2p } from "@libp2p/interface-libp2p";
|
3
2
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
4
3
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
5
4
|
|
6
|
-
import type { IFilter
|
5
|
+
import type { IFilter } from "./filter.js";
|
6
|
+
import type { Libp2p } from "./libp2p.js";
|
7
7
|
import type { ILightPush } from "./light_push.js";
|
8
8
|
import { Protocols } from "./protocols.js";
|
9
9
|
import type { IRelay } from "./relay.js";
|
@@ -13,7 +13,7 @@ export interface Waku {
|
|
13
13
|
libp2p: Libp2p;
|
14
14
|
relay?: IRelay;
|
15
15
|
store?: IStore;
|
16
|
-
filter?: IFilter
|
16
|
+
filter?: IFilter;
|
17
17
|
lightPush?: ILightPush;
|
18
18
|
|
19
19
|
dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise<Stream>;
|
@@ -28,7 +28,7 @@ export interface Waku {
|
|
28
28
|
export interface LightNode extends Waku {
|
29
29
|
relay: undefined;
|
30
30
|
store: IStore;
|
31
|
-
filter: IFilter
|
31
|
+
filter: IFilter;
|
32
32
|
lightPush: ILightPush;
|
33
33
|
}
|
34
34
|
|
@@ -42,6 +42,6 @@ export interface RelayNode extends Waku {
|
|
42
42
|
export interface FullNode extends Waku {
|
43
43
|
relay: IRelay;
|
44
44
|
store: IStore;
|
45
|
-
filter: IFilter
|
45
|
+
filter: IFilter;
|
46
46
|
lightPush: ILightPush;
|
47
47
|
}
|