@waku/core 0.0.24 → 0.0.25

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/CHANGELOG.md +25 -0
  2. package/bundle/{base_protocol-2a0c882e.js → base_protocol-4bcf7514.js} +19 -11
  3. package/bundle/index-27b91e3b.js +31 -0
  4. package/bundle/index.js +199 -167
  5. package/bundle/lib/base_protocol.js +2 -1
  6. package/bundle/lib/message/version_0.js +2 -1
  7. package/bundle/lib/predefined_bootstrap_nodes.js +2 -0
  8. package/bundle/{version_0-f4afd324.js → version_0-2f1176e3.js} +4 -4
  9. package/dist/.tsbuildinfo +1 -1
  10. package/dist/lib/connection_manager.d.ts +2 -1
  11. package/dist/lib/connection_manager.js +35 -27
  12. package/dist/lib/connection_manager.js.map +1 -1
  13. package/dist/lib/filter/index.js +28 -17
  14. package/dist/lib/filter/index.js.map +1 -1
  15. package/dist/lib/keep_alive_manager.js +8 -8
  16. package/dist/lib/keep_alive_manager.js.map +1 -1
  17. package/dist/lib/light_push/index.js +16 -12
  18. package/dist/lib/light_push/index.js.map +1 -1
  19. package/dist/lib/message/version_0.js +3 -4
  20. package/dist/lib/message/version_0.js.map +1 -1
  21. package/dist/lib/store/index.js +7 -8
  22. package/dist/lib/store/index.js.map +1 -1
  23. package/dist/lib/stream_manager.js +4 -4
  24. package/dist/lib/stream_manager.js.map +1 -1
  25. package/dist/lib/wait_for_remote_peer.js +3 -4
  26. package/dist/lib/wait_for_remote_peer.js.map +1 -1
  27. package/dist/lib/waku.js +8 -8
  28. package/dist/lib/waku.js.map +1 -1
  29. package/package.json +6 -6
  30. package/src/lib/connection_manager.ts +46 -28
  31. package/src/lib/filter/index.ts +40 -17
  32. package/src/lib/keep_alive_manager.ts +8 -8
  33. package/src/lib/light_push/index.ts +23 -12
  34. package/src/lib/message/version_0.ts +3 -4
  35. package/src/lib/store/index.ts +7 -9
  36. package/src/lib/stream_manager.ts +7 -5
  37. package/src/lib/wait_for_remote_peer.ts +3 -4
  38. package/src/lib/waku.ts +8 -8
package/CHANGELOG.md CHANGED
@@ -5,6 +5,31 @@ 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.25](https://github.com/waku-org/js-waku/compare/core-v0.0.24...core-v0.0.25) (2023-11-01)
9
+
10
+
11
+ ### Features
12
+
13
+ * Fail early when trying to send empty payload ([#1642](https://github.com/waku-org/js-waku/issues/1642)) ([6bad4ea](https://github.com/waku-org/js-waku/commit/6bad4ea7d1dee79c296c550390da57ffa824e2cf))
14
+ * Logger with log levels ([#1672](https://github.com/waku-org/js-waku/issues/1672)) ([0f7d63e](https://github.com/waku-org/js-waku/commit/0f7d63ef93716223dc8fea7e8cb09e12e267b386))
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * Don't dial discovered peers if have already been attempted dial ([#1657](https://github.com/waku-org/js-waku/issues/1657)) ([1892f50](https://github.com/waku-org/js-waku/commit/1892f5093da540530d7ee5640178ebaa46cf769f))
20
+ * Filter subscription with `pubsubTopic1` and decoder with `pubsubTopic2` ([#1675](https://github.com/waku-org/js-waku/issues/1675)) ([491366b](https://github.com/waku-org/js-waku/commit/491366bd4f96d5b72f83ca47dea5a93389ec5a27))
21
+ * Handle all empty responses in filter ([#1688](https://github.com/waku-org/js-waku/issues/1688)) ([b3864f8](https://github.com/waku-org/js-waku/commit/b3864f8772b072e804954c1096510554ea578424))
22
+ * Measure total message size ([#1643](https://github.com/waku-org/js-waku/issues/1643)) ([b7dc3d7](https://github.com/waku-org/js-waku/commit/b7dc3d7576e9444a5acbb036812c05cfccb25815))
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @waku/enr bumped from ^0.0.18 to ^0.0.19
30
+ * @waku/interfaces bumped from 0.0.19 to 0.0.20
31
+ * @waku/utils bumped from 0.0.12 to 0.0.13
32
+
8
33
  ## [0.0.24](https://github.com/waku-org/js-waku/compare/core-v0.0.23...core-v0.0.24) (2023-10-16)
9
34
 
10
35
 
@@ -1,4 +1,4 @@
1
- import { d as debug } from './browser-90197c87.js';
1
+ import { L as Logger } from './index-27b91e3b.js';
2
2
 
3
3
  // base-x encoding / decoding
4
4
  // Copyright (c) 2018 base-x contributors
@@ -927,13 +927,23 @@ var SendError;
927
927
  (function (SendError) {
928
928
  /** Could not determine the origin of the fault. Best to check connectivity and try again */
929
929
  SendError["GENERIC_FAIL"] = "Generic error";
930
- /** Failure to protobuf encode the message. This is not recoverable and needs
931
- * further investigation. */
930
+ /**
931
+ * Failure to protobuf encode the message. This is not recoverable and needs
932
+ * further investigation.
933
+ */
932
934
  SendError["ENCODE_FAILED"] = "Failed to encode";
933
- /** Failure to protobuf decode the message. May be due to a remote peer issue,
934
- * ensuring that messages are sent via several peer enable mitigation of this error.. */
935
+ /**
936
+ * Failure to protobuf decode the message. May be due to a remote peer issue,
937
+ * ensuring that messages are sent via several peer enable mitigation of this error.
938
+ */
935
939
  SendError["DECODE_FAILED"] = "Failed to decode";
936
- /** The message size is above the maximum message size allowed on the Waku Network.
940
+ /**
941
+ * The message payload is empty, making the message invalid. Ensure that a non-empty
942
+ * payload is set on the outgoing message.
943
+ */
944
+ SendError["EMPTY_PAYLOAD"] = "Payload is empty";
945
+ /**
946
+ * The message size is above the maximum message size allowed on the Waku Network.
937
947
  * Compressing the message or using an alternative strategy for large messages is recommended.
938
948
  */
939
949
  SendError["SIZE_TOO_BIG"] = "Size is too big";
@@ -1003,7 +1013,6 @@ function concat(byteArrays, totalLength) {
1003
1013
  return res;
1004
1014
  }
1005
1015
 
1006
- const log = debug("waku:libp2p-utils");
1007
1016
  /**
1008
1017
  * Returns a pseudo-random peer that supports the given protocol.
1009
1018
  * Useful for protocols such as store and light push
@@ -1083,7 +1092,6 @@ async function selectPeerForProtocol(peerStore, protocols, peerId) {
1083
1092
  // Do not break as we want to keep the last value
1084
1093
  }
1085
1094
  }
1086
- log(`Using codec ${protocol}`);
1087
1095
  if (!protocol) {
1088
1096
  throw new Error(`Peer does not register required protocols (${peer.id.toString()}): ${protocols}`);
1089
1097
  }
@@ -1148,7 +1156,7 @@ class StreamManager {
1148
1156
  this.multicodec = multicodec;
1149
1157
  this.getConnections = getConnections;
1150
1158
  this.addEventListener = addEventListener;
1151
- this.log = debug(`waku:stream-manager:${multicodec}`);
1159
+ this.log = new Logger(`stream-manager:${multicodec}`);
1152
1160
  this.addEventListener("peer:update", this.handlePeerUpdateStreamPool.bind(this));
1153
1161
  this.getStream = this.getStream.bind(this);
1154
1162
  this.streamPool = new Map();
@@ -1179,14 +1187,14 @@ class StreamManager {
1179
1187
  prepareNewStream(peer) {
1180
1188
  const streamPromise = this.newStream(peer).catch(() => {
1181
1189
  // No error thrown as this call is not triggered by the user
1182
- this.log(`Failed to prepare a new stream for ${peer.id.toString()}`);
1190
+ this.log.error(`Failed to prepare a new stream for ${peer.id.toString()}`);
1183
1191
  });
1184
1192
  this.streamPool.set(peer.id.toString(), streamPromise);
1185
1193
  }
1186
1194
  handlePeerUpdateStreamPool = (evt) => {
1187
1195
  const peer = evt.detail.peer;
1188
1196
  if (peer.protocols.includes(this.multicodec)) {
1189
- this.log(`Preemptively opening a stream to ${peer.id.toString()}`);
1197
+ this.log.info(`Preemptively opening a stream to ${peer.id.toString()}`);
1190
1198
  this.prepareNewStream(peer);
1191
1199
  }
1192
1200
  };
@@ -0,0 +1,31 @@
1
+ import { d as debug } from './browser-90197c87.js';
2
+
3
+ const APP_NAME = "waku";
4
+ class Logger {
5
+ _info;
6
+ _warn;
7
+ _error;
8
+ static createDebugNamespace(level, prefix) {
9
+ return prefix ? `${APP_NAME}:${level}:${prefix}` : `${APP_NAME}:${level}`;
10
+ }
11
+ constructor(prefix) {
12
+ this._info = debug(Logger.createDebugNamespace("info", prefix));
13
+ this._warn = debug(Logger.createDebugNamespace("warn", prefix));
14
+ this._error = debug(Logger.createDebugNamespace("error", prefix));
15
+ }
16
+ get info() {
17
+ return this._info;
18
+ }
19
+ get warn() {
20
+ return this._warn;
21
+ }
22
+ get error() {
23
+ return this._error;
24
+ }
25
+ log(level, ...args) {
26
+ const logger = this[level];
27
+ logger(...args);
28
+ }
29
+ }
30
+
31
+ export { Logger as L };