@waku/core 0.0.26-678635e.0 → 0.0.26-7eb3375.0

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.
Files changed (38) hide show
  1. package/bundle/base_protocol-46017f51.js +468 -0
  2. package/bundle/{base_protocol-4bcf7514.js → browser-9a6558bb.js} +742 -451
  3. package/bundle/{index-27b91e3b.js → index-7581d519.js} +1 -1
  4. package/bundle/index.js +3742 -4917
  5. package/bundle/lib/base_protocol.js +3 -3
  6. package/bundle/lib/message/version_0.js +3 -3
  7. package/bundle/lib/predefined_bootstrap_nodes.js +1 -1
  8. package/bundle/{version_0-2f1176e3.js → version_0-7190df43.js} +7 -7
  9. package/dist/.tsbuildinfo +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/lib/connection_manager.d.ts +8 -4
  13. package/dist/lib/connection_manager.js +34 -12
  14. package/dist/lib/connection_manager.js.map +1 -1
  15. package/dist/lib/constants.d.ts +2 -2
  16. package/dist/lib/constants.js +2 -2
  17. package/dist/lib/filter/index.js +4 -4
  18. package/dist/lib/keep_alive_manager.d.ts +1 -0
  19. package/dist/lib/keep_alive_manager.js +4 -1
  20. package/dist/lib/keep_alive_manager.js.map +1 -1
  21. package/dist/lib/light_push/index.js +2 -2
  22. package/dist/lib/message/version_0.d.ts +6 -6
  23. package/dist/lib/message/version_0.js +3 -3
  24. package/dist/lib/store/index.js +11 -11
  25. package/dist/lib/waku.d.ts +4 -3
  26. package/dist/lib/waku.js +3 -0
  27. package/dist/lib/waku.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/index.ts +1 -1
  30. package/src/lib/connection_manager.ts +44 -13
  31. package/src/lib/constants.ts +2 -2
  32. package/src/lib/filter/index.ts +11 -11
  33. package/src/lib/keep_alive_manager.ts +7 -1
  34. package/src/lib/light_push/index.ts +4 -4
  35. package/src/lib/message/version_0.ts +6 -6
  36. package/src/lib/store/index.ts +13 -13
  37. package/src/lib/waku.ts +6 -2
  38. package/bundle/browser-90197c87.js +0 -754
@@ -4,7 +4,7 @@ import all from "it-all";
4
4
  import * as lp from "it-length-prefixed";
5
5
  import { pipe } from "it-pipe";
6
6
  import { BaseProtocol } from "../base_protocol.js";
7
- import { DefaultPubSubTopic } from "../constants.js";
7
+ import { DefaultPubsubTopic } from "../constants.js";
8
8
  import { FilterPushRpc, FilterSubscribeResponse, FilterSubscribeRpc } from "./filter_rpc.js";
9
9
  const log = new Logger("filter:v2");
10
10
  export const FilterCodecs = {
@@ -142,13 +142,13 @@ class Filter extends BaseProtocol {
142
142
  }
143
143
  constructor(libp2p, options) {
144
144
  super(FilterCodecs.SUBSCRIBE, libp2p.components);
145
- this.pubsubTopics = options?.pubsubTopics || [DefaultPubSubTopic];
145
+ this.pubsubTopics = options?.pubsubTopics || [DefaultPubsubTopic];
146
146
  libp2p.handle(FilterCodecs.PUSH, this.onRequest.bind(this)).catch((e) => {
147
147
  log.error("Failed to register ", FilterCodecs.PUSH, e);
148
148
  });
149
149
  this.activeSubscriptions = new Map();
150
150
  }
151
- async createSubscription(pubsubTopic = DefaultPubSubTopic) {
151
+ async createSubscription(pubsubTopic = DefaultPubsubTopic) {
152
152
  ensurePubsubTopicIsConfigured(pubsubTopic, this.pubsubTopics);
153
153
  //TODO: get a relevant peer for the topic/shard
154
154
  // https://github.com/waku-org/js-waku/pull/1586#discussion_r1336428230
@@ -197,7 +197,7 @@ class Filter extends BaseProtocol {
197
197
  return;
198
198
  }
199
199
  if (!pubsubTopic) {
200
- log.error("PubSub topic missing from push message");
200
+ log.error("Pubsub topic missing from push message");
201
201
  return;
202
202
  }
203
203
  const peerIdStr = streamData.connection.remotePeer.toString();
@@ -13,5 +13,6 @@ export declare class KeepAliveManager {
13
13
  start(peerId: PeerId, libp2pPing: PingService, peerStore: PeerStore): void;
14
14
  stop(peerId: PeerId): void;
15
15
  stopAll(): void;
16
+ connectionsExist(): boolean;
16
17
  private scheduleRelayPings;
17
18
  }
@@ -83,8 +83,11 @@ export class KeepAliveManager {
83
83
  this.pingKeepAliveTimers.clear();
84
84
  this.relayKeepAliveTimers.clear();
85
85
  }
86
+ connectionsExist() {
87
+ return (this.pingKeepAliveTimers.size > 0 || this.relayKeepAliveTimers.size > 0);
88
+ }
86
89
  scheduleRelayPings(relay, relayPeriodSecs, peerIdStr) {
87
- // send a ping message to each PubSubTopic the peer is part of
90
+ // send a ping message to each PubsubTopic the peer is part of
88
91
  const intervals = [];
89
92
  for (const topic of relay.pubsubTopics) {
90
93
  const meshPeers = relay.getMeshPeers(topic);
@@ -1 +1 @@
1
- {"version":3,"file":"keep_alive_manager.js","sourceRoot":"","sources":["../../src/lib/keep_alive_manager.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAC/D,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,CAAC;AAErC,MAAM,OAAO,gBAAgB;IACnB,mBAAmB,CAA8C;IACjE,oBAAoB,CAAgD;IACpE,OAAO,CAAmB;IAC1B,KAAK,CAAU;IAEvB,YAAY,OAAyB,EAAE,KAAc;QACnD,IAAI,CAAC,mBAAmB,GAAG,IAAI,GAAG,EAAE,CAAC;QACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,GAAG,EAAE,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAEM,KAAK,CACV,MAAc,EACd,UAAuB,EACvB,SAAoB;QAEpB,oDAAoD;QACpD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAElB,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,e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IAAI,CAAC,QAAQ,CAAC,CAAC;SAC1B;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF"}
@@ -7,7 +7,7 @@ import * as lp from "it-length-prefixed";
7
7
  import { pipe } from "it-pipe";
8
8
  import { Uint8ArrayList } from "uint8arraylist";
9
9
  import { BaseProtocol } from "../base_protocol.js";
10
- import { DefaultPubSubTopic } from "../constants.js";
10
+ import { DefaultPubsubTopic } from "../constants.js";
11
11
  import { PushRpc } from "./push_rpc.js";
12
12
  const log = new Logger("light-push");
13
13
  export const LightPushCodec = "/vac/waku/lightpush/2.0.0-beta1";
@@ -20,7 +20,7 @@ class LightPush extends BaseProtocol {
20
20
  NUM_PEERS_PROTOCOL = 1;
21
21
  constructor(libp2p, options) {
22
22
  super(LightPushCodec, libp2p.components);
23
- this.pubsubTopics = options?.pubsubTopics ?? [DefaultPubSubTopic];
23
+ this.pubsubTopics = options?.pubsubTopics ?? [DefaultPubsubTopic];
24
24
  }
25
25
  async preparePushMessage(encoder, message, pubsubTopic) {
26
26
  try {
@@ -1,4 +1,4 @@
1
- import type { EncoderOptions, IDecodedMessage, IDecoder, IEncoder, IMessage, IMetaSetter, IProtoMessage, IRateLimitProof, PubSubTopic } from "@waku/interfaces";
1
+ import type { EncoderOptions, IDecodedMessage, IDecoder, IEncoder, IMessage, IMetaSetter, IProtoMessage, IRateLimitProof, PubsubTopic } from "@waku/interfaces";
2
2
  import { proto_message as proto } from "@waku/proto";
3
3
  export declare const Version = 0;
4
4
  export { proto };
@@ -18,9 +18,9 @@ export declare class DecodedMessage implements IDecodedMessage {
18
18
  export declare class Encoder implements IEncoder {
19
19
  contentTopic: string;
20
20
  ephemeral: boolean;
21
- pubsubTopic: PubSubTopic;
21
+ pubsubTopic: PubsubTopic;
22
22
  metaSetter?: IMetaSetter | undefined;
23
- constructor(contentTopic: string, ephemeral: boolean, pubsubTopic: PubSubTopic, metaSetter?: IMetaSetter | undefined);
23
+ constructor(contentTopic: string, ephemeral: boolean, pubsubTopic: PubsubTopic, metaSetter?: IMetaSetter | undefined);
24
24
  toWire(message: IMessage): Promise<Uint8Array>;
25
25
  toProtoObj(message: IMessage): Promise<IProtoMessage>;
26
26
  }
@@ -34,9 +34,9 @@ export declare class Encoder implements IEncoder {
34
34
  */
35
35
  export declare function createEncoder({ pubsubTopic, contentTopic, ephemeral, metaSetter }: EncoderOptions): Encoder;
36
36
  export declare class Decoder implements IDecoder<DecodedMessage> {
37
- pubsubTopic: PubSubTopic;
37
+ pubsubTopic: PubsubTopic;
38
38
  contentTopic: string;
39
- constructor(pubsubTopic: PubSubTopic, contentTopic: string);
39
+ constructor(pubsubTopic: PubsubTopic, contentTopic: string);
40
40
  fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined>;
41
41
  fromProtoObj(pubsubTopic: string, proto: IProtoMessage): Promise<DecodedMessage | undefined>;
42
42
  }
@@ -50,4 +50,4 @@ export declare class Decoder implements IDecoder<DecodedMessage> {
50
50
  *
51
51
  * @param contentTopic The resulting decoder will only decode messages with this content topic.
52
52
  */
53
- export declare function createDecoder(contentTopic: string, pubsubTopic?: PubSubTopic): Decoder;
53
+ export declare function createDecoder(contentTopic: string, pubsubTopic?: PubsubTopic): Decoder;
@@ -1,6 +1,6 @@
1
1
  import { proto_message as proto } from "@waku/proto";
2
2
  import { Logger } from "@waku/utils";
3
- import { DefaultPubSubTopic } from "../constants.js";
3
+ import { DefaultPubsubTopic } from "../constants.js";
4
4
  const log = new Logger("message:version-0");
5
5
  const OneMillion = BigInt(1000000);
6
6
  export const Version = 0;
@@ -94,7 +94,7 @@ export class Encoder {
94
94
  * pass to { @link @waku/interfaces!ISender.send } to automatically encode outgoing
95
95
  * messages.
96
96
  */
97
- export function createEncoder({ pubsubTopic = DefaultPubSubTopic, contentTopic, ephemeral, metaSetter }) {
97
+ export function createEncoder({ pubsubTopic = DefaultPubsubTopic, contentTopic, ephemeral, metaSetter }) {
98
98
  return new Encoder(contentTopic, ephemeral, pubsubTopic, metaSetter);
99
99
  }
100
100
  export class Decoder {
@@ -139,7 +139,7 @@ export class Decoder {
139
139
  *
140
140
  * @param contentTopic The resulting decoder will only decode messages with this content topic.
141
141
  */
142
- export function createDecoder(contentTopic, pubsubTopic = DefaultPubSubTopic) {
142
+ export function createDecoder(contentTopic, pubsubTopic = DefaultPubsubTopic) {
143
143
  return new Decoder(pubsubTopic, contentTopic);
144
144
  }
145
145
  //# sourceMappingURL=version_0.js.map
@@ -8,7 +8,7 @@ import * as lp from "it-length-prefixed";
8
8
  import { pipe } from "it-pipe";
9
9
  import { Uint8ArrayList } from "uint8arraylist";
10
10
  import { BaseProtocol } from "../base_protocol.js";
11
- import { DefaultPubSubTopic } from "../constants.js";
11
+ import { DefaultPubsubTopic } from "../constants.js";
12
12
  import { toProtoMessage } from "../to_proto_message.js";
13
13
  import { HistoryRpc, PageDirection } from "./history_rpc.js";
14
14
  var HistoryError = proto.HistoryResponse.HistoryError;
@@ -26,7 +26,7 @@ class Store extends BaseProtocol {
26
26
  NUM_PEERS_PROTOCOL = 1;
27
27
  constructor(libp2p, options) {
28
28
  super(StoreCodec, libp2p.components);
29
- this.pubsubTopics = options?.pubsubTopics ?? [DefaultPubSubTopic];
29
+ this.pubsubTopics = options?.pubsubTopics ?? [DefaultPubsubTopic];
30
30
  }
31
31
  /**
32
32
  * Processes messages based on the provided callback and options.
@@ -145,18 +145,18 @@ class Store extends BaseProtocol {
145
145
  endTime = options.timeFilter.endTime;
146
146
  }
147
147
  // convert array to set to remove duplicates
148
- const uniquePubSubTopicsInQuery = Array.from(new Set(decoders.map((decoder) => decoder.pubsubTopic)));
148
+ const uniquePubsubTopicsInQuery = Array.from(new Set(decoders.map((decoder) => decoder.pubsubTopic)));
149
149
  // If multiple pubsub topics are provided, throw an error
150
- if (uniquePubSubTopicsInQuery.length > 1) {
150
+ if (uniquePubsubTopicsInQuery.length > 1) {
151
151
  throw new Error("API does not support querying multiple pubsub topics at once");
152
152
  }
153
153
  // we can be certain that there is only one pubsub topic in the query
154
- const pubSubTopicForQuery = uniquePubSubTopicsInQuery[0];
155
- ensurePubsubTopicIsConfigured(pubSubTopicForQuery, this.pubsubTopics);
154
+ const pubsubTopicForQuery = uniquePubsubTopicsInQuery[0];
155
+ ensurePubsubTopicIsConfigured(pubsubTopicForQuery, this.pubsubTopics);
156
156
  // check that the pubsubTopic from the Cursor and Decoder match
157
157
  if (options?.cursor?.pubsubTopic &&
158
- options.cursor.pubsubTopic !== pubSubTopicForQuery) {
159
- throw new Error(`Cursor pubsub topic (${options?.cursor?.pubsubTopic}) does not match decoder pubsub topic (${pubSubTopicForQuery})`);
158
+ options.cursor.pubsubTopic !== pubsubTopicForQuery) {
159
+ throw new Error(`Cursor pubsub topic (${options?.cursor?.pubsubTopic}) does not match decoder pubsub topic (${pubsubTopicForQuery})`);
160
160
  }
161
161
  const decodersAsMap = new Map();
162
162
  decoders.forEach((dec) => {
@@ -166,13 +166,13 @@ class Store extends BaseProtocol {
166
166
  decodersAsMap.set(dec.contentTopic, dec);
167
167
  });
168
168
  const contentTopics = decoders
169
- .filter((decoder) => decoder.pubsubTopic === pubSubTopicForQuery)
169
+ .filter((decoder) => decoder.pubsubTopic === pubsubTopicForQuery)
170
170
  .map((dec) => dec.contentTopic);
171
171
  if (contentTopics.length === 0) {
172
- throw new Error("No decoders found for topic " + pubSubTopicForQuery);
172
+ throw new Error("No decoders found for topic " + pubsubTopicForQuery);
173
173
  }
174
174
  const queryOpts = Object.assign({
175
- pubsubTopic: pubSubTopicForQuery,
175
+ pubsubTopic: pubsubTopicForQuery,
176
176
  pageDirection: PageDirection.BACKWARD,
177
177
  pageSize: DefaultPageSize
178
178
  }, options, { contentTopics, startTime, endTime });
@@ -1,7 +1,7 @@
1
1
  import type { Stream } from "@libp2p/interface/connection";
2
2
  import { PeerId } from "@libp2p/interface/peer-id";
3
3
  import { MultiaddrInput } from "@multiformats/multiaddr";
4
- import type { IFilter, ILightPush, IRelay, IStore, Libp2p, PubSubTopic, Waku } from "@waku/interfaces";
4
+ import type { IFilter, ILightPush, IRelay, IStore, Libp2p, PubsubTopic, Waku } from "@waku/interfaces";
5
5
  import { Protocols } from "@waku/interfaces";
6
6
  import { ConnectionManager } from "./connection_manager.js";
7
7
  export declare const DefaultPingKeepAliveValueSecs: number;
@@ -29,14 +29,14 @@ export interface WakuOptions {
29
29
  userAgent?: string;
30
30
  }
31
31
  export declare class WakuNode implements Waku {
32
- readonly pubsubTopics: PubSubTopic[];
32
+ readonly pubsubTopics: PubsubTopic[];
33
33
  libp2p: Libp2p;
34
34
  relay?: IRelay;
35
35
  store?: IStore;
36
36
  filter?: IFilter;
37
37
  lightPush?: ILightPush;
38
38
  connectionManager: ConnectionManager;
39
- constructor(options: WakuOptions, pubsubTopics: PubSubTopic[], libp2p: Libp2p, store?: (libp2p: Libp2p) => IStore, lightPush?: (libp2p: Libp2p) => ILightPush, filter?: (libp2p: Libp2p) => IFilter, relay?: (libp2p: Libp2p) => IRelay);
39
+ constructor(options: WakuOptions, pubsubTopics: PubsubTopic[], libp2p: Libp2p, store?: (libp2p: Libp2p) => IStore, lightPush?: (libp2p: Libp2p) => ILightPush, filter?: (libp2p: Libp2p) => IFilter, relay?: (libp2p: Libp2p) => IRelay);
40
40
  /**
41
41
  * Dials to the provided peer.
42
42
  *
@@ -47,6 +47,7 @@ export declare class WakuNode implements Waku {
47
47
  start(): Promise<void>;
48
48
  stop(): Promise<void>;
49
49
  isStarted(): boolean;
50
+ isConnected(): boolean;
50
51
  /**
51
52
  * Return the local multiaddr with peer id on which libp2p is listening.
52
53
  *
package/dist/lib/waku.js CHANGED
@@ -100,6 +100,9 @@ export class WakuNode {
100
100
  isStarted() {
101
101
  return this.libp2p.isStarted();
102
102
  }
103
+ isConnected() {
104
+ return this.connectionManager.isConnected();
105
+ }
103
106
  /**
104
107
  * Return the local multiaddr with peer id on which libp2p is listening.
105
108
  *
@@ -1 +1 @@
1
- {"version":3,"file":"waku.js","sourceRoot":"","sources":["../../src/lib/waku.ts"],"names":[],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AC,iBAAiB,CAAC,WAAW,EAAE,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACH,uBAAuB;QACrB,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM;aAC/B,aAAa,EAAE;aACf,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,cAAc,IAAI,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;YACvD,MAAM,4BAA4B,CAAC;SACpC;QACD,OAAO,cAAc,GAAG,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClE,CAAC;CACF;AACD,SAAS,sBAAsB,CAC7B,MAA+B;IAE/B,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AACvD,CAAC"}
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@waku/core","version":"0.0.26-678635e.0","description":"TypeScript implementation of the Waku v2 protocol","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./lib/predefined_bootstrap_nodes":{"types":"./dist/lib/predefined_bootstrap_nodes.d.ts","import":"./dist/lib/predefined_bootstrap_nodes.js"},"./lib/message/version_0":{"types":"./dist/lib/message/version_0.d.ts","import":"./dist/lib/message/version_0.js"},"./lib/base_protocol":{"types":"./dist/lib/base_protocol.d.ts","import":"./dist/lib/base_protocol.js"}},"typesVersions":{"*":{"lib/*":["dist/lib/*"],"constants/*":["dist/constants/*"]}},"type":"module","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/core#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","decentralised","communication","web3","ethereum","dapps"],"scripts":{"build":"run-s build:**","build:esm":"tsc","build:bundle":"rollup --config rollup.config.js","fix":"run-s fix:*","fix:lint":"eslint src *.js --fix","check":"run-s check:*","check:tsc":"tsc -p tsconfig.dev.json","check:lint":"eslint src *.js","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","test":"run-s test:*","test:node":"TS_NODE_PROJECT=./tsconfig.dev.json mocha","test:browser":"karma start karma.conf.cjs","watch:build":"tsc -p tsconfig.json -w","watch:test":"mocha --watch","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build"},"engines":{"node":">=18"},"dependencies":{"@noble/hashes":"^1.3.2","@waku/enr":"0.0.20-678635e.0","@waku/interfaces":"0.0.21-678635e.0","@waku/proto":"0.0.6-678635e.0","@waku/utils":"0.0.14-678635e.0","debug":"^4.3.4","it-all":"^3.0.3","it-length-prefixed":"^9.0.1","it-pipe":"^3.0.1","p-event":"^6.0.0","uint8arraylist":"^2.4.3","uuid":"^9.0.0"},"devDependencies":{"@multiformats/multiaddr":"^12.0.0","@rollup/plugin-commonjs":"^25.0.4","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.3","@types/chai":"^4.3.5","@types/debug":"^4.1.10","@types/mocha":"^10.0.1","@types/uuid":"^9.0.3","@waku/build-utils":"*","chai":"^4.3.7","cspell":"^7.3.2","fast-check":"^3.13.1","ignore-loader":"^0.1.2","isomorphic-fetch":"^3.0.0","mocha":"^10.2.0","npm-run-all":"^4.1.5","process":"^0.11.10","rollup":"^3.29.2"},"peerDependencies":{"@multiformats/multiaddr":"^12.0.0","libp2p":"^0.46.3"},"peerDependenciesMeta":{"@multiformats/multiaddr":{"optional":true}},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"]}
1
+ {"name":"@waku/core","version":"0.0.26-7eb3375.0","description":"TypeScript implementation of the Waku v2 protocol","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./lib/predefined_bootstrap_nodes":{"types":"./dist/lib/predefined_bootstrap_nodes.d.ts","import":"./dist/lib/predefined_bootstrap_nodes.js"},"./lib/message/version_0":{"types":"./dist/lib/message/version_0.d.ts","import":"./dist/lib/message/version_0.js"},"./lib/base_protocol":{"types":"./dist/lib/base_protocol.d.ts","import":"./dist/lib/base_protocol.js"}},"typesVersions":{"*":{"lib/*":["dist/lib/*"],"constants/*":["dist/constants/*"]}},"type":"module","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/core#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","decentralised","communication","web3","ethereum","dapps"],"scripts":{"build":"run-s build:**","build:esm":"tsc","build:bundle":"rollup --config rollup.config.js","fix":"run-s fix:*","fix:lint":"eslint src *.js --fix","check":"run-s check:*","check:tsc":"tsc -p tsconfig.dev.json","check:lint":"eslint src *.js","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","test":"run-s test:*","test:node":"TS_NODE_PROJECT=./tsconfig.dev.json mocha","test:browser":"karma start karma.conf.cjs","watch:build":"tsc -p tsconfig.json -w","watch:test":"mocha --watch","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build"},"engines":{"node":">=18"},"dependencies":{"@noble/hashes":"^1.3.2","@waku/enr":"0.0.20-7eb3375.0","@waku/interfaces":"0.0.21-7eb3375.0","@waku/proto":"0.0.6-7eb3375.0","@waku/utils":"0.0.14-7eb3375.0","debug":"^4.3.4","it-all":"^3.0.4","it-length-prefixed":"^9.0.1","it-pipe":"^3.0.1","p-event":"^6.0.0","uint8arraylist":"^2.4.3","uuid":"^9.0.0"},"devDependencies":{"@multiformats/multiaddr":"^12.0.0","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.3","@types/chai":"^4.3.11","@types/debug":"^4.1.10","@types/mocha":"^10.0.1","@types/uuid":"^9.0.7","@waku/build-utils":"*","chai":"^4.3.10","cspell":"^7.3.2","fast-check":"^3.13.1","ignore-loader":"^0.1.2","isomorphic-fetch":"^3.0.0","mocha":"^10.2.0","npm-run-all":"^4.1.5","process":"^0.11.10","rollup":"^3.29.2"},"peerDependencies":{"@multiformats/multiaddr":"^12.0.0","libp2p":"^0.46.3"},"peerDependenciesMeta":{"@multiformats/multiaddr":{"optional":true}},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"]}
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { DefaultUserAgent } from "./lib/waku.js";
2
- export { DefaultPubSubTopic } from "./lib/constants.js";
2
+ export { DefaultPubsubTopic } from "./lib/constants.js";
3
3
  export { createEncoder, createDecoder } from "./lib/message/version_0.js";
4
4
  export type {
5
5
  Encoder,
@@ -6,17 +6,19 @@ import { CustomEvent, EventEmitter } from "@libp2p/interfaces/events";
6
6
  import { decodeRelayShard } from "@waku/enr";
7
7
  import {
8
8
  ConnectionManagerOptions,
9
+ EConnectionStateEvents,
9
10
  EPeersByDiscoveryEvents,
10
11
  IConnectionManager,
12
+ IConnectionStateEvents,
11
13
  IPeersByDiscoveryEvents,
12
14
  IRelay,
13
15
  KeepAliveOptions,
14
16
  PeersByDiscoveryResult,
15
- PubSubTopic,
17
+ PubsubTopic,
16
18
  ShardInfo
17
19
  } from "@waku/interfaces";
18
20
  import { Libp2p, Tags } from "@waku/interfaces";
19
- import { shardInfoToPubSubTopics } from "@waku/utils";
21
+ import { shardInfoToPubsubTopics } from "@waku/utils";
20
22
  import { Logger } from "@waku/utils";
21
23
 
22
24
  import { KeepAliveManager } from "./keep_alive_manager.js";
@@ -28,7 +30,7 @@ export const DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER = 3;
28
30
  export const DEFAULT_MAX_PARALLEL_DIALS = 3;
29
31
 
30
32
  export class ConnectionManager
31
- extends EventEmitter<IPeersByDiscoveryEvents>
33
+ extends EventEmitter<IPeersByDiscoveryEvents & IConnectionStateEvents>
32
34
  implements IConnectionManager
33
35
  {
34
36
  private static instances = new Map<string, ConnectionManager>();
@@ -40,12 +42,39 @@ export class ConnectionManager
40
42
 
41
43
  private currentActiveParallelDialCount = 0;
42
44
  private pendingPeerDialQueue: Array<PeerId> = [];
45
+ private online: boolean = false;
46
+
47
+ public isConnected(): boolean {
48
+ return this.online;
49
+ }
50
+
51
+ private toggleOnline(): void {
52
+ if (!this.online) {
53
+ this.online = true;
54
+ this.dispatchEvent(
55
+ new CustomEvent<boolean>(EConnectionStateEvents.CONNECTION_STATUS, {
56
+ detail: this.online
57
+ })
58
+ );
59
+ }
60
+ }
61
+
62
+ private toggleOffline(): void {
63
+ if (this.online && this.libp2p.getConnections().length == 0) {
64
+ this.online = false;
65
+ this.dispatchEvent(
66
+ new CustomEvent<boolean>(EConnectionStateEvents.CONNECTION_STATUS, {
67
+ detail: this.online
68
+ })
69
+ );
70
+ }
71
+ }
43
72
 
44
73
  public static create(
45
74
  peerId: string,
46
75
  libp2p: Libp2p,
47
76
  keepAliveOptions: KeepAliveOptions,
48
- pubsubTopics: PubSubTopic[],
77
+ pubsubTopics: PubsubTopic[],
49
78
  relay?: IRelay,
50
79
  options?: ConnectionManagerOptions
51
80
  ): ConnectionManager {
@@ -111,13 +140,13 @@ export class ConnectionManager
111
140
  private constructor(
112
141
  libp2p: Libp2p,
113
142
  keepAliveOptions: KeepAliveOptions,
114
- private configuredPubSubTopics: PubSubTopic[],
143
+ private configuredPubsubTopics: PubsubTopic[],
115
144
  relay?: IRelay,
116
145
  options?: Partial<ConnectionManagerOptions>
117
146
  ) {
118
147
  super();
119
148
  this.libp2p = libp2p;
120
- this.configuredPubSubTopics = configuredPubSubTopics;
149
+ this.configuredPubsubTopics = configuredPubsubTopics;
121
150
  this.options = {
122
151
  maxDialAttemptsForPeer: DEFAULT_MAX_DIAL_ATTEMPTS_FOR_PEER,
123
152
  maxBootstrapPeersAllowed: DEFAULT_MAX_BOOTSTRAP_PEERS_ALLOWED,
@@ -393,12 +422,14 @@ export class ConnectionManager
393
422
  )
394
423
  );
395
424
  }
425
+ this.toggleOnline();
396
426
  })();
397
427
  },
398
- "peer:disconnect": () => {
399
- return (evt: CustomEvent<PeerId>): void => {
428
+ "peer:disconnect": (evt: CustomEvent<PeerId>): void => {
429
+ void (async () => {
400
430
  this.keepAliveManager.stop(evt.detail);
401
- };
431
+ this.toggleOffline();
432
+ })();
402
433
  }
403
434
  };
404
435
 
@@ -426,8 +457,8 @@ export class ConnectionManager
426
457
  );
427
458
  log.warn(
428
459
  `Discovered peer ${peerId.toString()} with ShardInfo ${shardInfo} is not part of any of the configured pubsub topics (${
429
- this.configuredPubSubTopics
430
- }).
460
+ this.configuredPubsubTopics
461
+ }).
431
462
  Not dialing.`
432
463
  );
433
464
  return false;
@@ -518,10 +549,10 @@ export class ConnectionManager
518
549
  // If there's no shard information, simply return true
519
550
  if (!shardInfo) return true;
520
551
 
521
- const pubsubTopics = shardInfoToPubSubTopics(shardInfo);
552
+ const pubsubTopics = shardInfoToPubsubTopics(shardInfo);
522
553
 
523
554
  const isTopicConfigured = pubsubTopics.some((topic) =>
524
- this.configuredPubSubTopics.includes(topic)
555
+ this.configuredPubsubTopics.includes(topic)
525
556
  );
526
557
  return isTopicConfigured;
527
558
  }
@@ -1,4 +1,4 @@
1
1
  /**
2
- * DefaultPubSubTopic is the default gossipsub topic to use for Waku.
2
+ * DefaultPubsubTopic is the default gossipsub topic to use for Waku.
3
3
  */
4
- export const DefaultPubSubTopic = "/waku/2/default-waku/proto";
4
+ export const DefaultPubsubTopic = "/waku/2/default-waku/proto";
@@ -13,7 +13,7 @@ import type {
13
13
  Libp2p,
14
14
  PeerIdStr,
15
15
  ProtocolCreateOptions,
16
- PubSubTopic,
16
+ PubsubTopic,
17
17
  Unsubscribe
18
18
  } from "@waku/interfaces";
19
19
  import { WakuMessage } from "@waku/proto";
@@ -28,7 +28,7 @@ import * as lp from "it-length-prefixed";
28
28
  import { pipe } from "it-pipe";
29
29
 
30
30
  import { BaseProtocol } from "../base_protocol.js";
31
- import { DefaultPubSubTopic } from "../constants.js";
31
+ import { DefaultPubsubTopic } from "../constants.js";
32
32
 
33
33
  import {
34
34
  FilterPushRpc,
@@ -50,7 +50,7 @@ export const FilterCodecs = {
50
50
 
51
51
  class Subscription {
52
52
  private readonly peer: Peer;
53
- private readonly pubsubTopic: PubSubTopic;
53
+ private readonly pubsubTopic: PubsubTopic;
54
54
  private newStream: (peer: Peer) => Promise<Stream>;
55
55
 
56
56
  private subscriptionCallbacks: Map<
@@ -59,7 +59,7 @@ class Subscription {
59
59
  >;
60
60
 
61
61
  constructor(
62
- pubsubTopic: PubSubTopic,
62
+ pubsubTopic: PubsubTopic,
63
63
  remotePeer: Peer,
64
64
  newStream: (peer: Peer) => Promise<Stream>
65
65
  ) {
@@ -256,19 +256,19 @@ class Subscription {
256
256
  }
257
257
 
258
258
  class Filter extends BaseProtocol implements IReceiver {
259
- private readonly pubsubTopics: PubSubTopic[] = [];
259
+ private readonly pubsubTopics: PubsubTopic[] = [];
260
260
  private activeSubscriptions = new Map<string, Subscription>();
261
261
  private readonly NUM_PEERS_PROTOCOL = 1;
262
262
 
263
263
  private getActiveSubscription(
264
- pubsubTopic: PubSubTopic,
264
+ pubsubTopic: PubsubTopic,
265
265
  peerIdStr: PeerIdStr
266
266
  ): Subscription | undefined {
267
267
  return this.activeSubscriptions.get(`${pubsubTopic}_${peerIdStr}`);
268
268
  }
269
269
 
270
270
  private setActiveSubscription(
271
- pubsubTopic: PubSubTopic,
271
+ pubsubTopic: PubsubTopic,
272
272
  peerIdStr: PeerIdStr,
273
273
  subscription: Subscription
274
274
  ): Subscription {
@@ -279,7 +279,7 @@ class Filter extends BaseProtocol implements IReceiver {
279
279
  constructor(libp2p: Libp2p, options?: ProtocolCreateOptions) {
280
280
  super(FilterCodecs.SUBSCRIBE, libp2p.components);
281
281
 
282
- this.pubsubTopics = options?.pubsubTopics || [DefaultPubSubTopic];
282
+ this.pubsubTopics = options?.pubsubTopics || [DefaultPubsubTopic];
283
283
 
284
284
  libp2p.handle(FilterCodecs.PUSH, this.onRequest.bind(this)).catch((e) => {
285
285
  log.error("Failed to register ", FilterCodecs.PUSH, e);
@@ -289,7 +289,7 @@ class Filter extends BaseProtocol implements IReceiver {
289
289
  }
290
290
 
291
291
  async createSubscription(
292
- pubsubTopic: string = DefaultPubSubTopic
292
+ pubsubTopic: string = DefaultPubsubTopic
293
293
  ): Promise<Subscription> {
294
294
  ensurePubsubTopicIsConfigured(pubsubTopic, this.pubsubTopics);
295
295
 
@@ -367,7 +367,7 @@ class Filter extends BaseProtocol implements IReceiver {
367
367
  }
368
368
 
369
369
  if (!pubsubTopic) {
370
- log.error("PubSub topic missing from push message");
370
+ log.error("Pubsub topic missing from push message");
371
371
  return;
372
372
  }
373
373
 
@@ -408,7 +408,7 @@ export function wakuFilter(
408
408
 
409
409
  async function pushMessage<T extends IDecodedMessage>(
410
410
  subscriptionCallback: SubscriptionCallback<T>,
411
- pubsubTopic: PubSubTopic,
411
+ pubsubTopic: PubsubTopic,
412
412
  message: WakuMessage
413
413
  ): Promise<void> {
414
414
  const { decoders, callback } = subscriptionCallback;
@@ -111,12 +111,18 @@ export class KeepAliveManager {
111
111
  this.relayKeepAliveTimers.clear();
112
112
  }
113
113
 
114
+ public connectionsExist(): boolean {
115
+ return (
116
+ this.pingKeepAliveTimers.size > 0 || this.relayKeepAliveTimers.size > 0
117
+ );
118
+ }
119
+
114
120
  private scheduleRelayPings(
115
121
  relay: IRelay,
116
122
  relayPeriodSecs: number,
117
123
  peerIdStr: PeerIdStr
118
124
  ): NodeJS.Timeout[] {
119
- // send a ping message to each PubSubTopic the peer is part of
125
+ // send a ping message to each PubsubTopic the peer is part of
120
126
  const intervals: NodeJS.Timeout[] = [];
121
127
  for (const topic of relay.pubsubTopics) {
122
128
  const meshPeers = relay.getMeshPeers(topic);
@@ -6,7 +6,7 @@ import {
6
6
  IMessage,
7
7
  Libp2p,
8
8
  ProtocolCreateOptions,
9
- PubSubTopic,
9
+ PubsubTopic,
10
10
  SendError,
11
11
  SendResult
12
12
  } from "@waku/interfaces";
@@ -22,7 +22,7 @@ import { pipe } from "it-pipe";
22
22
  import { Uint8ArrayList } from "uint8arraylist";
23
23
 
24
24
  import { BaseProtocol } from "../base_protocol.js";
25
- import { DefaultPubSubTopic } from "../constants.js";
25
+ import { DefaultPubsubTopic } from "../constants.js";
26
26
 
27
27
  import { PushRpc } from "./push_rpc.js";
28
28
 
@@ -45,12 +45,12 @@ type PreparePushMessageResult =
45
45
  * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
46
46
  */
47
47
  class LightPush extends BaseProtocol implements ILightPush {
48
- private readonly pubsubTopics: PubSubTopic[];
48
+ private readonly pubsubTopics: PubsubTopic[];
49
49
  private readonly NUM_PEERS_PROTOCOL = 1;
50
50
 
51
51
  constructor(libp2p: Libp2p, options?: ProtocolCreateOptions) {
52
52
  super(LightPushCodec, libp2p.components);
53
- this.pubsubTopics = options?.pubsubTopics ?? [DefaultPubSubTopic];
53
+ this.pubsubTopics = options?.pubsubTopics ?? [DefaultPubsubTopic];
54
54
  }
55
55
 
56
56
  private async preparePushMessage(
@@ -7,12 +7,12 @@ import type {
7
7
  IMetaSetter,
8
8
  IProtoMessage,
9
9
  IRateLimitProof,
10
- PubSubTopic
10
+ PubsubTopic
11
11
  } from "@waku/interfaces";
12
12
  import { proto_message as proto } from "@waku/proto";
13
13
  import { Logger } from "@waku/utils";
14
14
 
15
- import { DefaultPubSubTopic } from "../constants.js";
15
+ import { DefaultPubsubTopic } from "../constants.js";
16
16
 
17
17
  const log = new Logger("message:version-0");
18
18
  const OneMillion = BigInt(1_000_000);
@@ -76,7 +76,7 @@ export class Encoder implements IEncoder {
76
76
  constructor(
77
77
  public contentTopic: string,
78
78
  public ephemeral: boolean = false,
79
- public pubsubTopic: PubSubTopic,
79
+ public pubsubTopic: PubsubTopic,
80
80
  public metaSetter?: IMetaSetter
81
81
  ) {
82
82
  if (!contentTopic || contentTopic === "") {
@@ -119,7 +119,7 @@ export class Encoder implements IEncoder {
119
119
  * messages.
120
120
  */
121
121
  export function createEncoder({
122
- pubsubTopic = DefaultPubSubTopic,
122
+ pubsubTopic = DefaultPubsubTopic,
123
123
  contentTopic,
124
124
  ephemeral,
125
125
  metaSetter
@@ -129,7 +129,7 @@ export function createEncoder({
129
129
 
130
130
  export class Decoder implements IDecoder<DecodedMessage> {
131
131
  constructor(
132
- public pubsubTopic: PubSubTopic,
132
+ public pubsubTopic: PubsubTopic,
133
133
  public contentTopic: string
134
134
  ) {
135
135
  if (!contentTopic || contentTopic === "") {
@@ -182,7 +182,7 @@ export class Decoder implements IDecoder<DecodedMessage> {
182
182
  */
183
183
  export function createDecoder(
184
184
  contentTopic: string,
185
- pubsubTopic: PubSubTopic = DefaultPubSubTopic
185
+ pubsubTopic: PubsubTopic = DefaultPubsubTopic
186
186
  ): Decoder {
187
187
  return new Decoder(pubsubTopic, contentTopic);
188
188
  }