@waku/core 0.0.6 → 0.0.8
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 +42 -4
- package/bundle/index.js +10870 -3756
- package/bundle/lib/message/topic_only_message.js +33 -0
- package/bundle/lib/message/version_0.js +133 -0
- package/bundle/{message-70dbb19b.js → peer_exchange-df95c3a7.js} +1899 -16
- package/dist/index.d.ts +14 -14
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/lib/{waku_filter → filter}/filter_rpc.d.ts +1 -1
- package/dist/lib/{waku_filter → filter}/filter_rpc.js +1 -1
- package/dist/lib/filter/filter_rpc.js.map +1 -0
- package/dist/lib/{waku_filter → filter}/index.d.ts +3 -3
- package/dist/lib/{waku_filter → filter}/index.js +3 -4
- package/dist/lib/filter/index.js.map +1 -0
- package/dist/lib/{waku_light_push → light_push}/index.d.ts +3 -3
- package/dist/lib/{waku_light_push → light_push}/index.js +4 -5
- package/dist/lib/light_push/index.js.map +1 -0
- package/dist/lib/{waku_light_push → light_push}/push_rpc.d.ts +1 -1
- package/dist/lib/{waku_light_push → light_push}/push_rpc.js +1 -1
- package/dist/lib/light_push/push_rpc.js.map +1 -0
- package/dist/lib/message/topic_only_message.d.ts +16 -0
- package/dist/lib/{waku_message → message}/topic_only_message.js +1 -1
- package/dist/lib/message/topic_only_message.js.map +1 -0
- package/dist/lib/message/version_0.d.ts +54 -0
- package/dist/lib/{waku_message → message}/version_0.js +35 -7
- package/dist/lib/message/version_0.js.map +1 -0
- package/dist/lib/predefined_bootstrap_nodes.js.map +1 -1
- package/dist/lib/{waku_relay → relay}/constants.d.ts +0 -0
- package/dist/lib/{waku_relay → relay}/constants.js +0 -0
- package/dist/lib/relay/constants.js.map +1 -0
- package/dist/lib/{waku_relay → relay}/index.d.ts +5 -5
- package/dist/lib/{waku_relay → relay}/index.js +5 -5
- package/dist/lib/relay/index.js.map +1 -0
- package/dist/lib/{waku_store → store}/history_rpc.d.ts +1 -1
- package/dist/lib/{waku_store → store}/history_rpc.js +1 -1
- package/dist/lib/store/history_rpc.js.map +1 -0
- package/dist/lib/{waku_store → store}/index.d.ts +7 -5
- package/dist/lib/{waku_store → store}/index.js +9 -8
- package/dist/lib/store/index.js.map +1 -0
- package/dist/lib/to_proto_message.d.ts +3 -3
- package/dist/lib/to_proto_message.js.map +1 -1
- package/dist/lib/wait_for_remote_peer.js +12 -3
- package/dist/lib/wait_for_remote_peer.js.map +1 -1
- package/dist/lib/waku.d.ts +10 -9
- package/dist/lib/waku.js +19 -9
- package/dist/lib/waku.js.map +1 -1
- package/package.json +21 -19
- package/src/index.ts +19 -18
- package/src/lib/{waku_filter → filter}/filter_rpc.ts +1 -2
- package/src/lib/{waku_filter → filter}/index.ts +26 -26
- package/src/lib/{waku_light_push → light_push}/index.ts +17 -18
- package/src/lib/{waku_light_push → light_push}/push_rpc.ts +1 -2
- package/src/lib/{waku_message → message}/topic_only_message.ts +10 -7
- package/src/lib/{waku_message → message}/version_0.ts +53 -18
- package/src/lib/predefined_bootstrap_nodes.ts +1 -1
- package/src/lib/{waku_relay → relay}/constants.ts +0 -0
- package/src/lib/{waku_relay → relay}/index.ts +20 -26
- package/src/lib/{waku_store → store}/history_rpc.ts +1 -2
- package/src/lib/{waku_store → store}/index.ts +38 -24
- package/src/lib/to_proto_message.ts +4 -5
- package/src/lib/wait_for_remote_peer.ts +17 -5
- package/src/lib/waku.ts +40 -17
- package/bundle/index-925587a4.js +0 -5642
- package/bundle/lib/wait_for_remote_peer.js +0 -324
- package/bundle/lib/waku_message/topic_only_message.js +0 -2
- package/bundle/lib/waku_message/version_0.js +0 -330
- package/bundle/topic_only_message-a80fe8b2.js +0 -82
- package/dist/lib/multiaddr_to_peer_info.d.ts +0 -3
- package/dist/lib/multiaddr_to_peer_info.js +0 -15
- package/dist/lib/multiaddr_to_peer_info.js.map +0 -1
- package/dist/lib/select_connection.d.ts +0 -2
- package/dist/lib/select_connection.js +0 -19
- package/dist/lib/select_connection.js.map +0 -1
- package/dist/lib/select_peer.d.ts +0 -15
- package/dist/lib/select_peer.js +0 -59
- package/dist/lib/select_peer.js.map +0 -1
- package/dist/lib/waku_filter/filter_rpc.js.map +0 -1
- package/dist/lib/waku_filter/index.js.map +0 -1
- package/dist/lib/waku_light_push/index.js.map +0 -1
- package/dist/lib/waku_light_push/push_rpc.js.map +0 -1
- package/dist/lib/waku_message/topic_only_message.d.ts +0 -16
- package/dist/lib/waku_message/topic_only_message.js.map +0 -1
- package/dist/lib/waku_message/version_0.d.ts +0 -30
- package/dist/lib/waku_message/version_0.js.map +0 -1
- package/dist/lib/waku_relay/constants.js.map +0 -1
- package/dist/lib/waku_relay/index.js.map +0 -1
- package/dist/lib/waku_store/history_rpc.js.map +0 -1
- package/dist/lib/waku_store/index.js.map +0 -1
- package/dist/proto/filter.d.ts +0 -66
- package/dist/proto/filter.js +0 -432
- package/dist/proto/filter.js.map +0 -1
- package/dist/proto/light_push.d.ts +0 -58
- package/dist/proto/light_push.js +0 -376
- package/dist/proto/light_push.js.map +0 -1
- package/dist/proto/message.d.ts +0 -30
- package/dist/proto/message.js +0 -222
- package/dist/proto/message.js.map +0 -1
- package/dist/proto/store.d.ts +0 -105
- package/dist/proto/store.js +0 -609
- package/dist/proto/store.js.map +0 -1
- package/dist/proto/topic_only_message.d.ts +0 -10
- package/dist/proto/topic_only_message.js +0 -46
- package/dist/proto/topic_only_message.js.map +0 -1
- package/src/lib/multiaddr_to_peer_info.ts +0 -17
- package/src/lib/select_connection.ts +0 -24
- package/src/lib/select_peer.ts +0 -77
- package/src/proto/filter.ts +0 -611
- package/src/proto/light_push.ts +0 -535
- package/src/proto/message.ts +0 -313
- package/src/proto/store.ts +0 -853
- package/src/proto/topic_only_message.ts +0 -67
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"to_proto_message.js","sourceRoot":"","sources":["../../src/lib/to_proto_message.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"to_proto_message.js","sourceRoot":"","sources":["../../src/lib/to_proto_message.ts"],"names":[],"mappings":"AAGA,MAAM,YAAY,GAAkB;IAClC,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,SAAS;IACvB,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,SAAS;IACpB,cAAc,EAAE,SAAS;IACzB,SAAS,EAAE,SAAS;CACrB,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,IAAsB;IACnD,OAAO,EAAE,GAAG,YAAY,EAAE,GAAG,IAAI,EAAE,CAAC;AACtC,CAAC"}
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { Protocols } from "@waku/interfaces";
|
2
|
+
import { PeerExchangeCodec } from "@waku/peer-exchange";
|
2
3
|
import debug from "debug";
|
3
4
|
import { pEvent } from "p-event";
|
4
|
-
import { FilterCodec } from "./
|
5
|
-
import { LightPushCodec } from "./
|
6
|
-
import { StoreCodec } from "./
|
5
|
+
import { FilterCodec } from "./filter/index.js";
|
6
|
+
import { LightPushCodec } from "./light_push/index.js";
|
7
|
+
import { StoreCodec } from "./store/index.js";
|
7
8
|
const log = debug("waku:wait-for-remote-peer");
|
8
9
|
/**
|
9
10
|
* Wait for a remote peer to be ready given the passed protocols.
|
@@ -49,6 +50,11 @@ export async function waitForRemotePeer(waku, protocols, timeoutMs) {
|
|
49
50
|
throw new Error("Cannot wait for Filter peer: protocol not mounted");
|
50
51
|
promises.push(waitForConnectedPeer(waku.filter, [FilterCodec]));
|
51
52
|
}
|
53
|
+
if (protocols.includes(Protocols.PeerExchange)) {
|
54
|
+
if (!waku.peerExchange)
|
55
|
+
throw new Error("Cannot wait for Peer Exchange peer: protocol not mounted");
|
56
|
+
promises.push(waitForConnectedPeer(waku.peerExchange, [PeerExchangeCodec]));
|
57
|
+
}
|
52
58
|
if (timeoutMs) {
|
53
59
|
await rejectOnTimeout(Promise.all(promises), timeoutMs, "Timed out waiting for a remote peer.");
|
54
60
|
}
|
@@ -108,6 +114,9 @@ function getEnabledProtocols(waku) {
|
|
108
114
|
if (waku.lightPush) {
|
109
115
|
protocols.push(Protocols.LightPush);
|
110
116
|
}
|
117
|
+
if (waku.peerExchange) {
|
118
|
+
protocols.push(Protocols.PeerExchange);
|
119
|
+
}
|
111
120
|
return protocols;
|
112
121
|
}
|
113
122
|
//# sourceMappingURL=wait_for_remote_peer.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"wait_for_remote_peer.js","sourceRoot":"","sources":["../../src/lib/wait_for_remote_peer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"wait_for_remote_peer.js","sourceRoot":"","sources":["../../src/lib/wait_for_remote_peer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,GAAG,GAAG,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAU,EACV,SAAuB,EACvB,SAAkB;IAElB,SAAS,GAAG,SAAS,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEnD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO,OAAO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;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/lib/waku.d.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { Stream } from "@libp2p/interface-connection";
|
2
2
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
3
3
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
4
|
-
import type {
|
4
|
+
import type { IFilter, ILightPush, IPeerExchange, IRelay, IStore, PeerExchangeComponents, Waku } from "@waku/interfaces";
|
5
5
|
import { Protocols } from "@waku/interfaces";
|
6
6
|
import type { Libp2p } from "libp2p";
|
7
|
-
import { FilterComponents } from "./
|
8
|
-
import { LightPushComponents } from "./
|
9
|
-
import { StoreComponents } from "./
|
7
|
+
import { FilterComponents } from "./filter/index.js";
|
8
|
+
import { LightPushComponents } from "./light_push/index.js";
|
9
|
+
import { StoreComponents } from "./store/index.js";
|
10
10
|
export declare const DefaultPingKeepAliveValueSecs = 0;
|
11
11
|
export declare const DefaultRelayKeepAliveValueSecs: number;
|
12
12
|
export declare const DefaultUserAgent = "js-waku";
|
@@ -33,13 +33,14 @@ export interface WakuOptions {
|
|
33
33
|
}
|
34
34
|
export declare class WakuNode implements Waku {
|
35
35
|
libp2p: Libp2p;
|
36
|
-
relay?:
|
37
|
-
store?:
|
38
|
-
filter?:
|
39
|
-
lightPush?:
|
36
|
+
relay?: IRelay;
|
37
|
+
store?: IStore;
|
38
|
+
filter?: IFilter;
|
39
|
+
lightPush?: ILightPush;
|
40
|
+
peerExchange?: IPeerExchange;
|
40
41
|
private pingKeepAliveTimers;
|
41
42
|
private relayKeepAliveTimers;
|
42
|
-
constructor(options: WakuOptions, libp2p: Libp2p, store?: (components: StoreComponents) =>
|
43
|
+
constructor(options: WakuOptions, libp2p: Libp2p, store?: (components: StoreComponents) => IStore, lightPush?: (components: LightPushComponents) => ILightPush, filter?: (components: FilterComponents) => IFilter, peerExchange?: (components: PeerExchangeComponents) => IPeerExchange);
|
43
44
|
/**
|
44
45
|
* Dials to the provided peer.
|
45
46
|
*
|
package/dist/lib/waku.js
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
import { Protocols } from "@waku/interfaces";
|
2
|
+
import { PeerExchangeCodec } from "@waku/peer-exchange";
|
2
3
|
import debug from "debug";
|
3
|
-
import { FilterCodec } from "./
|
4
|
-
import { LightPushCodec } from "./
|
5
|
-
import {
|
6
|
-
import * as relayConstants from "./
|
7
|
-
import { RelayCodecs, RelayPingContentTopic } from "./
|
8
|
-
import { StoreCodec } from "./
|
4
|
+
import { FilterCodec } from "./filter/index.js";
|
5
|
+
import { LightPushCodec } from "./light_push/index.js";
|
6
|
+
import { createEncoder } from "./message/version_0.js";
|
7
|
+
import * as relayConstants from "./relay/constants.js";
|
8
|
+
import { RelayCodecs, RelayPingContentTopic } from "./relay/constants.js";
|
9
|
+
import { StoreCodec } from "./store/index.js";
|
9
10
|
export const DefaultPingKeepAliveValueSecs = 0;
|
10
11
|
export const DefaultRelayKeepAliveValueSecs = 5 * 60;
|
11
12
|
export const DefaultUserAgent = "js-waku";
|
12
13
|
const log = debug("waku:waku");
|
13
14
|
export class WakuNode {
|
14
|
-
constructor(options, libp2p, store, lightPush, filter) {
|
15
|
+
constructor(options, libp2p, store, lightPush, filter, peerExchange) {
|
15
16
|
this.libp2p = libp2p;
|
16
17
|
const { peerStore, connectionManager, registrar } = libp2p;
|
17
18
|
const components = { peerStore, connectionManager, registrar };
|
@@ -24,11 +25,15 @@ export class WakuNode {
|
|
24
25
|
if (lightPush) {
|
25
26
|
this.lightPush = lightPush(components);
|
26
27
|
}
|
28
|
+
if (peerExchange) {
|
29
|
+
this.peerExchange = peerExchange(components);
|
30
|
+
}
|
27
31
|
if (isRelay(libp2p.pubsub)) {
|
28
32
|
this.relay = libp2p.pubsub;
|
29
33
|
}
|
30
34
|
log("Waku node created", this.libp2p.peerId.toString(), `relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this
|
31
|
-
.lightPush}, filter: ${!!this.filter}
|
35
|
+
.lightPush}, filter: ${!!this.filter}, peer exchange: ${!!this
|
36
|
+
.peerExchange} `);
|
32
37
|
this.pingKeepAliveTimers = {};
|
33
38
|
this.relayKeepAliveTimers = {};
|
34
39
|
const pingKeepAlive = options.pingKeepAlive || DefaultPingKeepAliveValueSecs;
|
@@ -74,6 +79,7 @@ export class WakuNode {
|
|
74
79
|
this.store && _protocols.push(Protocols.Store);
|
75
80
|
this.filter && _protocols.push(Protocols.Filter);
|
76
81
|
this.lightPush && _protocols.push(Protocols.LightPush);
|
82
|
+
this.peerExchange && _protocols.push(Protocols.PeerExchange);
|
77
83
|
}
|
78
84
|
const codecs = [];
|
79
85
|
if (_protocols.includes(Protocols.Relay)) {
|
@@ -88,6 +94,10 @@ export class WakuNode {
|
|
88
94
|
if (_protocols.includes(Protocols.Filter)) {
|
89
95
|
codecs.push(FilterCodec);
|
90
96
|
}
|
97
|
+
if (_protocols.includes(Protocols.PeerExchange)) {
|
98
|
+
codecs.push(PeerExchangeCodec);
|
99
|
+
}
|
100
|
+
log(`Dialing to ${peer.toString()} with protocols ${_protocols}`);
|
91
101
|
return this.libp2p.dialProtocol(peer, codecs);
|
92
102
|
}
|
93
103
|
async start() {
|
@@ -127,7 +137,7 @@ export class WakuNode {
|
|
127
137
|
}
|
128
138
|
const relay = this.relay;
|
129
139
|
if (relay && relayPeriodSecs !== 0) {
|
130
|
-
const encoder =
|
140
|
+
const encoder = createEncoder(RelayPingContentTopic);
|
131
141
|
this.relayKeepAliveTimers[peerIdStr] = setInterval(() => {
|
132
142
|
log("Sending Waku Relay ping message");
|
133
143
|
relay
|
package/dist/lib/waku.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"waku.js","sourceRoot":"","sources":["../../src/lib/waku.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"waku.js","sourceRoot":"","sources":["../../src/lib/waku.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,O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a,CAAC,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;SAC5C;QAED,IAAI,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE;YACxC,aAAa,CAAC,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC;YACpD,OAAO,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;SAC7C;IACH,CAAC;IAEO,iBAAiB;QACvB,KAAK,MAAM,KAAK,IAAI;YAClB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC;YAC1C,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC;SAC5C,EAAE;YACD,aAAa,CAAC,KAAK,CAAC,CAAC;SACtB;QAED,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC;QAC9B,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAC;IACjC,CAAC;CACF;AAED,SAAS,OAAO,CAAC,MAAc;IAC7B,IAAI,MAAM,EAAE;QACV,IAAI;YACF,OAAO,MAAM,CAAC,WAAW,CAAC,QAAQ,CAChC,cAAc,CAAC,WAAW,CAAC,cAAc,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAClE,CAAC;YACF,qEAAqE;YACrE,oCAAoC;SACrC;QAAC,OAAO,CAAC,EAAE,GAAE;KACf;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@waku/core",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.8",
|
4
4
|
"description": "TypeScript implementation of the Waku v2 protocol",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"module": "./dist/index.js",
|
@@ -13,17 +13,13 @@
|
|
13
13
|
"types": "./dist/lib/predefined_bootstrap_nodes.d.ts",
|
14
14
|
"import": "./dist/lib/predefined_bootstrap_nodes.js"
|
15
15
|
},
|
16
|
-
"./lib/
|
17
|
-
"types": "./dist/lib/
|
18
|
-
"import": "./dist/lib/
|
16
|
+
"./lib/message/version_0": {
|
17
|
+
"types": "./dist/lib/message/version_0.d.ts",
|
18
|
+
"import": "./dist/lib/message/version_0.js"
|
19
19
|
},
|
20
|
-
"./lib/
|
21
|
-
"types": "./dist/lib/
|
22
|
-
"import": "./dist/lib/
|
23
|
-
},
|
24
|
-
"./lib/waku_message/topic_only_message": {
|
25
|
-
"types": "./dist/lib/waku_message/topic_only_message.d.ts",
|
26
|
-
"import": "./dist/lib/waku_message/topic_only_message.js"
|
20
|
+
"./lib/message/topic_only_message": {
|
21
|
+
"types": "./dist/lib/message/topic_only_message.d.ts",
|
22
|
+
"import": "./dist/lib/message/topic_only_message.js"
|
27
23
|
}
|
28
24
|
},
|
29
25
|
"typesVersions": {
|
@@ -53,7 +49,7 @@
|
|
53
49
|
],
|
54
50
|
"scripts": {
|
55
51
|
"build": "run-s build:**",
|
56
|
-
"build:esm": "tsc
|
52
|
+
"build:esm": "tsc",
|
57
53
|
"build:bundle": "rollup --config rollup.config.js",
|
58
54
|
"fix": "run-s fix:*",
|
59
55
|
"fix:prettier": "prettier . --write",
|
@@ -71,11 +67,9 @@
|
|
71
67
|
"test": "run-s test:*",
|
72
68
|
"test:node": "TS_NODE_PROJECT=./tsconfig.dev.json mocha",
|
73
69
|
"test:browser": "karma start karma.conf.cjs",
|
74
|
-
"proto": "rimraf src/proto/*.ts; protons src/proto/*.proto",
|
75
70
|
"watch:build": "tsc -p tsconfig.json -w",
|
76
71
|
"watch:test": "mocha --watch",
|
77
72
|
"prepublish": "npm run build",
|
78
|
-
"deploy": "node ci/deploy.js",
|
79
73
|
"reset-hard": "git clean -dfx -e .idea && git reset --hard && npm i && npm run build"
|
80
74
|
},
|
81
75
|
"engines": {
|
@@ -96,16 +90,18 @@
|
|
96
90
|
"@noble/hashes": "^1.1.3",
|
97
91
|
"@waku/byte-utils": "*",
|
98
92
|
"@waku/interfaces": "*",
|
93
|
+
"@waku/libp2p-utils": "*",
|
94
|
+
"@waku/peer-exchange": "*",
|
95
|
+
"@waku/proto": "*",
|
99
96
|
"debug": "^4.3.4",
|
100
97
|
"it-all": "^1.0.6",
|
101
98
|
"it-length-prefixed": "^8.0.2",
|
102
99
|
"it-pipe": "^2.0.4",
|
103
100
|
"libp2p": "0.40.0",
|
104
101
|
"p-event": "^5.0.1",
|
105
|
-
"protons-runtime": "^3.1.0",
|
106
102
|
"uint8arraylist": "^2.3.2",
|
107
103
|
"uint8arrays": "^4.0.2",
|
108
|
-
"uuid": "^
|
104
|
+
"uuid": "^9.0.0"
|
109
105
|
},
|
110
106
|
"devDependencies": {
|
111
107
|
"@rollup/plugin-commonjs": "^22.0.0",
|
@@ -122,7 +118,7 @@
|
|
122
118
|
"@typescript-eslint/parser": "^5.8.1",
|
123
119
|
"app-root-path": "^3.0.0",
|
124
120
|
"chai": "^4.3.4",
|
125
|
-
"cspell": "^
|
121
|
+
"cspell": "^6.17.0",
|
126
122
|
"eslint": "^8.6.0",
|
127
123
|
"eslint-config-prettier": "^8.3.0",
|
128
124
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
@@ -145,7 +141,6 @@
|
|
145
141
|
"portfinder": "^1.0.28",
|
146
142
|
"prettier": "^2.1.1",
|
147
143
|
"process": "^0.11.10",
|
148
|
-
"protons": "^5.1.0",
|
149
144
|
"puppeteer": "^13.0.1",
|
150
145
|
"rollup": "^2.75.0",
|
151
146
|
"tail": "^2.2.0",
|
@@ -153,6 +148,14 @@
|
|
153
148
|
"ts-node": "^10.9.1",
|
154
149
|
"typescript": "^4.6.3"
|
155
150
|
},
|
151
|
+
"peerDependencies": {
|
152
|
+
"@multiformats/multiaddr": "^11.0.6"
|
153
|
+
},
|
154
|
+
"peerDependenciesMeta": {
|
155
|
+
"@multiformats/multiaddr": {
|
156
|
+
"optional": true
|
157
|
+
}
|
158
|
+
},
|
156
159
|
"typedoc": {
|
157
160
|
"entryPoint": "./src/index.ts"
|
158
161
|
},
|
@@ -161,7 +164,6 @@
|
|
161
164
|
"bundle",
|
162
165
|
"src/*.ts",
|
163
166
|
"src/lib/**/*.ts",
|
164
|
-
"src/proto/**/*.ts",
|
165
167
|
"!**/*.spec.*",
|
166
168
|
"!**/*.json",
|
167
169
|
"CHANGELOG.md",
|
package/src/index.ts
CHANGED
@@ -1,29 +1,30 @@
|
|
1
|
-
export { DefaultPubSubTopic } from "./lib/constants";
|
2
|
-
export { DefaultUserAgent } from "./lib/waku";
|
1
|
+
export { DefaultPubSubTopic } from "./lib/constants.js";
|
2
|
+
export { DefaultUserAgent } from "./lib/waku.js";
|
3
3
|
|
4
|
-
export
|
5
|
-
|
4
|
+
export {
|
5
|
+
createEncoder,
|
6
|
+
createDecoder,
|
7
|
+
DecodedMessage,
|
8
|
+
} from "./lib/message/version_0.js";
|
6
9
|
|
7
|
-
export * as waku from "./lib/waku";
|
8
|
-
export { WakuNode } from "./lib/waku";
|
10
|
+
export * as waku from "./lib/waku.js";
|
11
|
+
export { WakuNode } from "./lib/waku.js";
|
9
12
|
|
10
|
-
export * as waku_filter from "./lib/
|
11
|
-
export { wakuFilter } from "./lib/
|
13
|
+
export * as waku_filter from "./lib/filter/index.js";
|
14
|
+
export { wakuFilter } from "./lib/filter/index.js";
|
12
15
|
|
13
|
-
export * as waku_light_push from "./lib/
|
14
|
-
export {
|
15
|
-
wakuLightPush,
|
16
|
-
LightPushCodec,
|
17
|
-
PushResponse,
|
18
|
-
} from "./lib/waku_light_push";
|
16
|
+
export * as waku_light_push from "./lib/light_push/index.js";
|
17
|
+
export { wakuLightPush, LightPushCodec } from "./lib/light_push/index.js";
|
19
18
|
|
20
|
-
export * as waku_relay from "./lib/
|
21
|
-
export { wakuRelay } from "./lib/
|
19
|
+
export * as waku_relay from "./lib/relay/index.js";
|
20
|
+
export { wakuRelay } from "./lib/relay/index.js";
|
22
21
|
|
23
|
-
export * as waku_store from "./lib/
|
22
|
+
export * as waku_store from "./lib/store/index.js";
|
24
23
|
export {
|
25
24
|
PageDirection,
|
26
25
|
wakuStore,
|
27
26
|
StoreCodec,
|
28
27
|
createCursor,
|
29
|
-
} from "./lib/
|
28
|
+
} from "./lib/store/index.js";
|
29
|
+
|
30
|
+
export { waitForRemotePeer } from "./lib/wait_for_remote_peer.js";
|
@@ -7,29 +7,29 @@ import type { IncomingStreamData } from "@libp2p/interface-registrar";
|
|
7
7
|
import type { Registrar } from "@libp2p/interface-registrar";
|
8
8
|
import type {
|
9
9
|
Callback,
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
IDecodedMessage,
|
11
|
+
IDecoder,
|
12
|
+
IFilter,
|
13
|
+
IMessage,
|
14
14
|
ProtocolOptions,
|
15
15
|
} from "@waku/interfaces";
|
16
|
+
import {
|
17
|
+
getPeersForProtocol,
|
18
|
+
selectConnection,
|
19
|
+
selectPeerForProtocol,
|
20
|
+
selectRandomPeer,
|
21
|
+
} from "@waku/libp2p-utils";
|
22
|
+
import { WakuMessage as WakuMessageProto } from "@waku/proto";
|
16
23
|
import debug from "debug";
|
17
24
|
import all from "it-all";
|
18
25
|
import * as lp from "it-length-prefixed";
|
19
26
|
import { pipe } from "it-pipe";
|
20
27
|
|
21
|
-
import {
|
22
|
-
import {
|
23
|
-
import {
|
24
|
-
import { selectConnection } from "../select_connection";
|
25
|
-
import {
|
26
|
-
getPeersForProtocol,
|
27
|
-
selectPeerForProtocol,
|
28
|
-
selectRandomPeer,
|
29
|
-
} from "../select_peer";
|
30
|
-
import { toProtoMessage } from "../to_proto_message";
|
28
|
+
import { DefaultPubSubTopic } from "../constants.js";
|
29
|
+
import { groupByContentTopic } from "../group_by.js";
|
30
|
+
import { toProtoMessage } from "../to_proto_message.js";
|
31
31
|
|
32
|
-
import { ContentFilter, FilterRPC } from "./filter_rpc";
|
32
|
+
import { ContentFilter, FilterRPC } from "./filter_rpc.js";
|
33
33
|
|
34
34
|
export { ContentFilter };
|
35
35
|
|
@@ -64,12 +64,12 @@ export type UnsubscribeFunction = () => Promise<void>;
|
|
64
64
|
* - https://github.com/status-im/go-waku/issues/245
|
65
65
|
* - https://github.com/status-im/nwaku/issues/948
|
66
66
|
*/
|
67
|
-
class
|
67
|
+
class Filter implements IFilter {
|
68
68
|
pubSubTopic: string;
|
69
69
|
private subscriptions: Map<string, Callback<any>>;
|
70
70
|
private decoders: Map<
|
71
71
|
string, // content topic
|
72
|
-
Set<
|
72
|
+
Set<IDecoder<any>>
|
73
73
|
>;
|
74
74
|
|
75
75
|
constructor(public components: FilterComponents, options?: CreateOptions) {
|
@@ -87,8 +87,8 @@ class WakuFilter implements Filter {
|
|
87
87
|
* @param opts The FilterSubscriptionOpts used to narrow which messages are returned, and which peer to connect to.
|
88
88
|
* @returns Unsubscribe function that can be used to end the subscription.
|
89
89
|
*/
|
90
|
-
async subscribe<T extends
|
91
|
-
decoders:
|
90
|
+
async subscribe<T extends IDecodedMessage>(
|
91
|
+
decoders: IDecoder<T>[],
|
92
92
|
callback: Callback<T>,
|
93
93
|
opts?: ProtocolOptions
|
94
94
|
): Promise<UnsubscribeFunction> {
|
@@ -198,7 +198,7 @@ class WakuFilter implements Filter {
|
|
198
198
|
return;
|
199
199
|
}
|
200
200
|
|
201
|
-
let msg:
|
201
|
+
let msg: IMessage | undefined;
|
202
202
|
// We don't want to wait for decoding failure, just attempt to decode
|
203
203
|
// all messages and do the call back on the one that works
|
204
204
|
// noinspection ES6MissingAwait
|
@@ -225,8 +225,8 @@ class WakuFilter implements Filter {
|
|
225
225
|
this.subscriptions.delete(requestId);
|
226
226
|
}
|
227
227
|
|
228
|
-
private addDecoders<T extends
|
229
|
-
decoders: Map<string, Array<
|
228
|
+
private addDecoders<T extends IDecodedMessage>(
|
229
|
+
decoders: Map<string, Array<IDecoder<T>>>
|
230
230
|
): void {
|
231
231
|
decoders.forEach((decoders, contentTopic) => {
|
232
232
|
const currDecs = this.decoders.get(contentTopic);
|
@@ -238,8 +238,8 @@ class WakuFilter implements Filter {
|
|
238
238
|
});
|
239
239
|
}
|
240
240
|
|
241
|
-
private deleteDecoders<T extends
|
242
|
-
decoders: Map<string, Array<
|
241
|
+
private deleteDecoders<T extends IDecodedMessage>(
|
242
|
+
decoders: Map<string, Array<IDecoder<T>>>
|
243
243
|
): void {
|
244
244
|
decoders.forEach((decoders, contentTopic) => {
|
245
245
|
const currDecs = this.decoders.get(contentTopic);
|
@@ -308,6 +308,6 @@ class WakuFilter implements Filter {
|
|
308
308
|
|
309
309
|
export function wakuFilter(
|
310
310
|
init: Partial<CreateOptions> = {}
|
311
|
-
): (components: FilterComponents) =>
|
312
|
-
return (components: FilterComponents) => new
|
311
|
+
): (components: FilterComponents) => IFilter {
|
312
|
+
return (components: FilterComponents) => new Filter(components, init);
|
313
313
|
}
|
@@ -3,28 +3,28 @@ import type { PeerId } from "@libp2p/interface-peer-id";
|
|
3
3
|
import type { Peer } from "@libp2p/interface-peer-store";
|
4
4
|
import type { PeerStore } from "@libp2p/interface-peer-store";
|
5
5
|
import type {
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
IEncoder,
|
7
|
+
ILightPush,
|
8
|
+
IMessage,
|
9
9
|
ProtocolOptions,
|
10
10
|
SendResult,
|
11
11
|
} from "@waku/interfaces";
|
12
|
+
import {
|
13
|
+
getPeersForProtocol,
|
14
|
+
selectConnection,
|
15
|
+
selectPeerForProtocol,
|
16
|
+
selectRandomPeer,
|
17
|
+
} from "@waku/libp2p-utils";
|
18
|
+
import { PushResponse } from "@waku/proto";
|
12
19
|
import debug from "debug";
|
13
20
|
import all from "it-all";
|
14
21
|
import * as lp from "it-length-prefixed";
|
15
22
|
import { pipe } from "it-pipe";
|
16
23
|
import { Uint8ArrayList } from "uint8arraylist";
|
17
24
|
|
18
|
-
import {
|
19
|
-
import { DefaultPubSubTopic } from "../constants";
|
20
|
-
import { selectConnection } from "../select_connection";
|
21
|
-
import {
|
22
|
-
getPeersForProtocol,
|
23
|
-
selectPeerForProtocol,
|
24
|
-
selectRandomPeer,
|
25
|
-
} from "../select_peer";
|
25
|
+
import { DefaultPubSubTopic } from "../constants.js";
|
26
26
|
|
27
|
-
import { PushRPC } from "./push_rpc";
|
27
|
+
import { PushRPC } from "./push_rpc.js";
|
28
28
|
|
29
29
|
const log = debug("waku:light-push");
|
30
30
|
|
@@ -51,7 +51,7 @@ export interface CreateOptions {
|
|
51
51
|
/**
|
52
52
|
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
|
53
53
|
*/
|
54
|
-
class
|
54
|
+
class LightPush implements ILightPush {
|
55
55
|
pubSubTopic: string;
|
56
56
|
|
57
57
|
constructor(public components: LightPushComponents, options?: CreateOptions) {
|
@@ -59,8 +59,8 @@ class WakuLightPush implements LightPush {
|
|
59
59
|
}
|
60
60
|
|
61
61
|
async push(
|
62
|
-
encoder:
|
63
|
-
message:
|
62
|
+
encoder: IEncoder,
|
63
|
+
message: IMessage,
|
64
64
|
opts?: ProtocolOptions
|
65
65
|
): Promise<SendResult> {
|
66
66
|
const pubSubTopic = opts?.pubSubTopic ? opts.pubSubTopic : this.pubSubTopic;
|
@@ -151,7 +151,6 @@ class WakuLightPush implements LightPush {
|
|
151
151
|
|
152
152
|
export function wakuLightPush(
|
153
153
|
init: Partial<CreateOptions> = {}
|
154
|
-
): (components: LightPushComponents) =>
|
155
|
-
return (components: LightPushComponents) =>
|
156
|
-
new WakuLightPush(components, init);
|
154
|
+
): (components: LightPushComponents) => ILightPush {
|
155
|
+
return (components: LightPushComponents) => new LightPush(components, init);
|
157
156
|
}
|
@@ -1,8 +1,7 @@
|
|
1
|
+
import { proto_lightpush as proto } from "@waku/proto";
|
1
2
|
import type { Uint8ArrayList } from "uint8arraylist";
|
2
3
|
import { v4 as uuid } from "uuid";
|
3
4
|
|
4
|
-
import * as proto from "../../proto/light_push";
|
5
|
-
|
6
5
|
export class PushRPC {
|
7
6
|
public constructor(public proto: proto.PushRPC) {}
|
8
7
|
|
@@ -1,11 +1,14 @@
|
|
1
|
-
import type {
|
1
|
+
import type {
|
2
|
+
IDecodedMessage,
|
3
|
+
IDecoder,
|
4
|
+
IProtoMessage,
|
5
|
+
} from "@waku/interfaces";
|
6
|
+
import { proto_topic_only_message as proto } from "@waku/proto";
|
2
7
|
import debug from "debug";
|
3
8
|
|
4
|
-
import * as proto from "../../proto/topic_only_message";
|
5
|
-
|
6
9
|
const log = debug("waku:message:topic-only");
|
7
10
|
|
8
|
-
export class TopicOnlyMessage implements
|
11
|
+
export class TopicOnlyMessage implements IDecodedMessage {
|
9
12
|
public payload: undefined;
|
10
13
|
public rateLimitProof: undefined;
|
11
14
|
public timestamp: undefined;
|
@@ -18,10 +21,10 @@ export class TopicOnlyMessage implements DecodedMessage {
|
|
18
21
|
}
|
19
22
|
}
|
20
23
|
|
21
|
-
export class TopicOnlyDecoder implements
|
24
|
+
export class TopicOnlyDecoder implements IDecoder<TopicOnlyMessage> {
|
22
25
|
public contentTopic = "";
|
23
26
|
|
24
|
-
fromWireToProtoObj(bytes: Uint8Array): Promise<
|
27
|
+
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
|
25
28
|
const protoMessage = proto.TopicOnlyMessage.decode(bytes);
|
26
29
|
log("Message decoded", protoMessage);
|
27
30
|
return Promise.resolve({
|
@@ -35,7 +38,7 @@ export class TopicOnlyDecoder implements Decoder<TopicOnlyMessage> {
|
|
35
38
|
}
|
36
39
|
|
37
40
|
async fromProtoObj(
|
38
|
-
proto:
|
41
|
+
proto: IProtoMessage
|
39
42
|
): Promise<TopicOnlyMessage | undefined> {
|
40
43
|
return new TopicOnlyMessage(proto);
|
41
44
|
}
|