@waku/core 0.0.31-f387f59.0 → 0.0.32-3687d81.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,35 @@ 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.31](https://github.com/waku-org/js-waku/compare/core-v0.0.30...core-v0.0.31) (2024-08-29)
9
+
10
+
11
+ ### ⚠ BREAKING CHANGES
12
+
13
+ * **lightpush:** return new error messages ([#2115](https://github.com/waku-org/js-waku/issues/2115))
14
+ * deprecate named pubsub topics and use static/auto sharding ([#2097](https://github.com/waku-org/js-waku/issues/2097))
15
+ * store v3 ([#2036](https://github.com/waku-org/js-waku/issues/2036))
16
+
17
+ ### Features
18
+
19
+ * Deprecate named pubsub topics and use static/auto sharding ([#2097](https://github.com/waku-org/js-waku/issues/2097)) ([5ce36c8](https://github.com/waku-org/js-waku/commit/5ce36c8f187f218df8af66e0643ab277e909b227))
20
+ * Fix peer renewal, change Filter keep alive ([#2065](https://github.com/waku-org/js-waku/issues/2065)) ([00635b7](https://github.com/waku-org/js-waku/commit/00635b7afe60c2ed739f2ccd1f07b2a6cc04f797))
21
+ * **lightpush:** Return new error messages ([#2115](https://github.com/waku-org/js-waku/issues/2115)) ([a022433](https://github.com/waku-org/js-waku/commit/a022433851e6e187679b8c40bb465b431854809b))
22
+ * Node and protocols health ([#2080](https://github.com/waku-org/js-waku/issues/2080)) ([d464af3](https://github.com/waku-org/js-waku/commit/d464af3645d769034d6c6293607de5b00e904ae4))
23
+ * Offline state recovery for Filter subscription ([#2049](https://github.com/waku-org/js-waku/issues/2049)) ([eadb85a](https://github.com/waku-org/js-waku/commit/eadb85ab8367c0e0d8fa9f9fd012eebc71200b6c))
24
+ * Store v3 ([#2036](https://github.com/waku-org/js-waku/issues/2036)) ([86f730f](https://github.com/waku-org/js-waku/commit/86f730f9587e3688b79c8e846e5c005bb4d5fae4))
25
+ * Validate messages for individual filter nodes & perform renewals ([#2057](https://github.com/waku-org/js-waku/issues/2057)) ([9b0f1e8](https://github.com/waku-org/js-waku/commit/9b0f1e855aa3a1f7b9aec3a4c726568d37595c28))
26
+
27
+
28
+ ### Dependencies
29
+
30
+ * The following workspace dependencies were updated
31
+ * dependencies
32
+ * @waku/enr bumped from ^0.0.24 to ^0.0.25
33
+ * @waku/interfaces bumped from 0.0.25 to 0.0.26
34
+ * @waku/proto bumped from 0.0.7 to 0.0.8
35
+ * @waku/utils bumped from 0.0.18 to 0.0.19
36
+
8
37
  ## [0.0.30](https://github.com/waku-org/js-waku/compare/core-v0.0.29...core-v0.0.30) (2024-07-10)
9
38
 
10
39
 
@@ -1,4 +1,4 @@
1
- import { h as bytesToUtf8, T as Tags, L as Logger, e as pubsubTopicsToShardInfo } from './index-Gts2Ddu_.js';
1
+ import { h as bytesToUtf8, T as Tags, L as Logger, e as pubsubTopicsToShardInfo } from './index-tdQNdKHx.js';
2
2
 
3
3
  const decodeRelayShard = (bytes) => {
4
4
  // explicitly converting to Uint8Array to avoid Buffer
@@ -1058,7 +1058,7 @@ var ProtocolError;
1058
1058
  * The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
1059
1059
  * or `DECODE_FAILED` can be used.
1060
1060
  */
1061
- ProtocolError["REMOTE_PEER_FAULT"] = "Remote peer fault";
1061
+ ProtocolError["NO_RESPONSE"] = "No response received";
1062
1062
  /**
1063
1063
  * The remote peer rejected the message. Information provided by the remote peer
1064
1064
  * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
@@ -1070,6 +1070,26 @@ var ProtocolError;
1070
1070
  * Mitigation can be: retrying after a given time period
1071
1071
  */
1072
1072
  ProtocolError["REQUEST_TIMEOUT"] = "Request timeout";
1073
+ /**
1074
+ * Missing credentials info message.
1075
+ * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L186
1076
+ */
1077
+ ProtocolError["RLN_IDENTITY_MISSING"] = "Identity credentials are not set";
1078
+ /**
1079
+ * Membership index missing info message.
1080
+ * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L188
1081
+ */
1082
+ ProtocolError["RLN_MEMBERSHIP_INDEX"] = "Membership index is not set";
1083
+ /**
1084
+ * Message limit is missing.
1085
+ * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L190
1086
+ */
1087
+ ProtocolError["RLN_LIMIT_MISSING"] = "User message limit is not set";
1088
+ /**
1089
+ * General proof generation error message.
1090
+ * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
1091
+ */
1092
+ ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
1073
1093
  })(ProtocolError || (ProtocolError = {}));
1074
1094
 
1075
1095
  var Tags;
@@ -2037,4 +2057,4 @@ class Logger {
2037
2057
  }
2038
2058
  }
2039
2059
 
2040
- export { EConnectionStateEvents as E, HealthStatus as H, Logger as L, ProtocolError as P, Tags as T, allocUnsafe as a, alloc as b, Protocols as c, EPeersByDiscoveryEvents as d, pubsubTopicsToShardInfo as e, fromString as f, determinePubsubTopic as g, bytesToUtf8 as h, pubsubTopicToSingleShardInfo as p, shardInfoToPubsubTopics as s, utf8ToBytes as u };
2060
+ export { EPeersByDiscoveryEvents as E, HealthStatus as H, Logger as L, ProtocolError as P, Tags as T, allocUnsafe as a, alloc as b, Protocols as c, EConnectionStateEvents as d, pubsubTopicsToShardInfo as e, fromString as f, determinePubsubTopic as g, bytesToUtf8 as h, pubsubTopicToSingleShardInfo as p, shardInfoToPubsubTopics as s, utf8ToBytes as u };
package/bundle/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { v as version_0, e as encodingLength, a as encode$1, d as decode$1, M as MessagePush, F as FilterSubscribeRequest, b as FilterSubscribeResponse$1, P as PushRpc$1, c as PushResponse, S as StoreQueryRequest$1, f as StoreQueryResponse$1, g as createEncoder, W as WakuMetadataRequest, h as WakuMetadataResponse } from './version_0-CNRKFufI.js';
2
- export { i as createDecoder } from './version_0-CNRKFufI.js';
3
- import { a as allocUnsafe, b as alloc, L as Logger, P as ProtocolError, c as Protocols, u as utf8ToBytes, p as pubsubTopicToSingleShardInfo, E as EConnectionStateEvents, T as Tags, d as EPeersByDiscoveryEvents, s as shardInfoToPubsubTopics, H as HealthStatus, e as pubsubTopicsToShardInfo } from './index-Gts2Ddu_.js';
4
- import { B as BaseProtocol, d as decodeRelayShard, e as encodeRelayShard } from './base_protocol-Dge5_tvU.js';
5
- export { S as StreamManager } from './base_protocol-Dge5_tvU.js';
1
+ import { v as version_0, e as encodingLength, a as encode$1, d as decode$1, M as MessagePush, F as FilterSubscribeRequest, b as FilterSubscribeResponse$1, P as PushRpc$1, c as PushResponse, S as StoreQueryRequest$1, f as StoreQueryResponse$1, g as createEncoder, W as WakuMetadataRequest, h as WakuMetadataResponse } from './version_0-BrbNEwD-.js';
2
+ export { i as createDecoder } from './version_0-BrbNEwD-.js';
3
+ import { a as allocUnsafe, b as alloc, L as Logger, P as ProtocolError, c as Protocols, u as utf8ToBytes, p as pubsubTopicToSingleShardInfo, T as Tags, E as EPeersByDiscoveryEvents, s as shardInfoToPubsubTopics, d as EConnectionStateEvents, H as HealthStatus, e as pubsubTopicsToShardInfo } from './index-tdQNdKHx.js';
4
+ import { B as BaseProtocol, d as decodeRelayShard, e as encodeRelayShard } from './base_protocol-C47QkJ2o.js';
5
+ export { S as StreamManager } from './base_protocol-C47QkJ2o.js';
6
6
 
7
7
  const MB = 1024 ** 2;
8
8
  const SIZE_CAP_IN_MB = 1;
@@ -1618,7 +1618,7 @@ class FilterCore extends BaseProtocol {
1618
1618
  return {
1619
1619
  success: null,
1620
1620
  failure: {
1621
- error: ProtocolError.REMOTE_PEER_FAULT,
1621
+ error: ProtocolError.NO_STREAM_AVAILABLE,
1622
1622
  peerId: peer.id
1623
1623
  }
1624
1624
  };
@@ -1649,7 +1649,7 @@ class FilterCore extends BaseProtocol {
1649
1649
  if (!res || !res.length) {
1650
1650
  return {
1651
1651
  failure: {
1652
- error: ProtocolError.REMOTE_PEER_FAULT,
1652
+ error: ProtocolError.NO_RESPONSE,
1653
1653
  peerId: peer.id
1654
1654
  },
1655
1655
  success: null
@@ -1681,7 +1681,7 @@ class FilterCore extends BaseProtocol {
1681
1681
  return {
1682
1682
  success: null,
1683
1683
  failure: {
1684
- error: ProtocolError.REMOTE_PEER_FAULT,
1684
+ error: ProtocolError.NO_STREAM_AVAILABLE,
1685
1685
  peerId: peer.id
1686
1686
  }
1687
1687
  };
@@ -1705,7 +1705,7 @@ class FilterCore extends BaseProtocol {
1705
1705
  return {
1706
1706
  success: null,
1707
1707
  failure: {
1708
- error: ProtocolError.REMOTE_PEER_FAULT,
1708
+ error: ProtocolError.NO_RESPONSE,
1709
1709
  peerId: peer.id
1710
1710
  }
1711
1711
  };
@@ -1793,6 +1793,31 @@ class PushRpc {
1793
1793
  }
1794
1794
  }
1795
1795
 
1796
+ // should match nwaku
1797
+ // https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/rln_relay.nim#L309
1798
+ // https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/tests/waku_rln_relay/rln/waku_rln_relay_utils.nim#L20
1799
+ const RLN_GENERATION_PREFIX_ERROR = "could not generate rln-v2 proof";
1800
+ const isRLNResponseError = (info) => {
1801
+ if (!info) {
1802
+ return false;
1803
+ }
1804
+ return info.includes(RLN_GENERATION_PREFIX_ERROR);
1805
+ };
1806
+ const matchRLNErrorMessage = (info) => {
1807
+ const rlnErrorMap = {
1808
+ [ProtocolError.RLN_IDENTITY_MISSING]: ProtocolError.RLN_IDENTITY_MISSING,
1809
+ [ProtocolError.RLN_MEMBERSHIP_INDEX]: ProtocolError.RLN_MEMBERSHIP_INDEX,
1810
+ [ProtocolError.RLN_LIMIT_MISSING]: ProtocolError.RLN_LIMIT_MISSING
1811
+ };
1812
+ const infoLowerCase = info.toLowerCase();
1813
+ for (const errorKey in rlnErrorMap) {
1814
+ if (infoLowerCase.includes(errorKey.toLowerCase())) {
1815
+ return rlnErrorMap[errorKey];
1816
+ }
1817
+ }
1818
+ return ProtocolError.RLN_PROOF_GENERATION;
1819
+ };
1820
+
1796
1821
  const log$5 = new Logger("light-push");
1797
1822
  const LightPushCodec = "/vac/waku/lightpush/2.0.0-beta1";
1798
1823
  /**
@@ -1895,7 +1920,18 @@ class LightPushCore extends BaseProtocol {
1895
1920
  return {
1896
1921
  success: null,
1897
1922
  failure: {
1898
- error: ProtocolError.REMOTE_PEER_FAULT,
1923
+ error: ProtocolError.NO_RESPONSE,
1924
+ peerId: peer.id
1925
+ }
1926
+ };
1927
+ }
1928
+ if (isRLNResponseError(response.info)) {
1929
+ const rlnErrorCase = matchRLNErrorMessage(response.info);
1930
+ log$5.error("Remote peer rejected the message: ", rlnErrorCase);
1931
+ return {
1932
+ success: null,
1933
+ failure: {
1934
+ error: rlnErrorCase,
1899
1935
  peerId: peer.id
1900
1936
  }
1901
1937
  };
@@ -2650,25 +2686,12 @@ class ConnectionManager extends TypedEventEmitter {
2650
2686
  dialErrorsForPeer = new Map();
2651
2687
  currentActiveParallelDialCount = 0;
2652
2688
  pendingPeerDialQueue = [];
2653
- online = false;
2689
+ isP2PNetworkConnected = false;
2654
2690
  isConnected() {
2655
- return this.online;
2656
- }
2657
- toggleOnline() {
2658
- if (!this.online) {
2659
- this.online = true;
2660
- this.dispatchEvent(new CustomEvent(EConnectionStateEvents.CONNECTION_STATUS, {
2661
- detail: this.online
2662
- }));
2663
- }
2664
- }
2665
- toggleOffline() {
2666
- if (this.online && this.libp2p.getConnections().length == 0) {
2667
- this.online = false;
2668
- this.dispatchEvent(new CustomEvent(EConnectionStateEvents.CONNECTION_STATUS, {
2669
- detail: this.online
2670
- }));
2691
+ if (globalThis?.navigator && !globalThis?.navigator?.onLine) {
2692
+ return false;
2671
2693
  }
2694
+ return this.isP2PNetworkConnected;
2672
2695
  }
2673
2696
  static create(peerId, libp2p, keepAliveOptions, pubsubTopics, relay, options) {
2674
2697
  let instance = ConnectionManager.instances.get(peerId);
@@ -2683,6 +2706,7 @@ class ConnectionManager extends TypedEventEmitter {
2683
2706
  this.libp2p.removeEventListener("peer:connect", this.onEventHandlers["peer:connect"]);
2684
2707
  this.libp2p.removeEventListener("peer:disconnect", this.onEventHandlers["peer:disconnect"]);
2685
2708
  this.libp2p.removeEventListener("peer:discovery", this.onEventHandlers["peer:discovery"]);
2709
+ this.stopNetworkStatusListener();
2686
2710
  }
2687
2711
  async dropConnection(peerId) {
2688
2712
  try {
@@ -2759,7 +2783,7 @@ class ConnectionManager extends TypedEventEmitter {
2759
2783
  libp2p,
2760
2784
  options: keepAliveOptions
2761
2785
  });
2762
- this.run()
2786
+ this.startEventListeners()
2763
2787
  .then(() => log$1.info(`Connection Manager is now running`))
2764
2788
  .catch((error) => log$1.error(`Unexpected error while running service`, error));
2765
2789
  // libp2p emits `peer:discovery` events during its initialization
@@ -2782,11 +2806,11 @@ class ConnectionManager extends TypedEventEmitter {
2782
2806
  log$1.error(`Unexpected error while dialing peer store peers`, error);
2783
2807
  }
2784
2808
  }
2785
- async run() {
2786
- // start event listeners
2809
+ async startEventListeners() {
2787
2810
  this.startPeerDiscoveryListener();
2788
2811
  this.startPeerConnectionListener();
2789
2812
  this.startPeerDisconnectionListener();
2813
+ this.startNetworkStatusListener();
2790
2814
  }
2791
2815
  async dialPeer(peerId) {
2792
2816
  this.currentActiveParallelDialCount += 1;
@@ -2934,14 +2958,17 @@ class ConnectionManager extends TypedEventEmitter {
2934
2958
  detail: peerId
2935
2959
  }));
2936
2960
  }
2937
- this.toggleOnline();
2961
+ this.setP2PNetworkConnected();
2938
2962
  })();
2939
2963
  },
2940
2964
  "peer:disconnect": (evt) => {
2941
2965
  void (async () => {
2942
2966
  this.keepAliveManager.stop(evt.detail);
2943
- this.toggleOffline();
2967
+ this.setP2PNetworkDisconnected();
2944
2968
  })();
2969
+ },
2970
+ "browser:network": () => {
2971
+ this.dispatchWakuConnectionEvent();
2945
2972
  }
2946
2973
  };
2947
2974
  /**
@@ -3032,6 +3059,42 @@ class ConnectionManager extends TypedEventEmitter {
3032
3059
  return undefined;
3033
3060
  return decodeRelayShard(shardInfoBytes);
3034
3061
  }
3062
+ startNetworkStatusListener() {
3063
+ try {
3064
+ globalThis.addEventListener("online", this.onEventHandlers["browser:network"]);
3065
+ globalThis.addEventListener("offline", this.onEventHandlers["browser:network"]);
3066
+ }
3067
+ catch (err) {
3068
+ log$1.error(`Failed to start network listener: ${err}`);
3069
+ }
3070
+ }
3071
+ stopNetworkStatusListener() {
3072
+ try {
3073
+ globalThis.removeEventListener("online", this.onEventHandlers["browser:network"]);
3074
+ globalThis.removeEventListener("offline", this.onEventHandlers["browser:network"]);
3075
+ }
3076
+ catch (err) {
3077
+ log$1.error(`Failed to stop network listener: ${err}`);
3078
+ }
3079
+ }
3080
+ setP2PNetworkConnected() {
3081
+ if (!this.isP2PNetworkConnected) {
3082
+ this.isP2PNetworkConnected = true;
3083
+ this.dispatchWakuConnectionEvent();
3084
+ }
3085
+ }
3086
+ setP2PNetworkDisconnected() {
3087
+ if (this.isP2PNetworkConnected &&
3088
+ this.libp2p.getConnections().length === 0) {
3089
+ this.isP2PNetworkConnected = false;
3090
+ this.dispatchWakuConnectionEvent();
3091
+ }
3092
+ }
3093
+ dispatchWakuConnectionEvent() {
3094
+ this.dispatchEvent(new CustomEvent(EConnectionStateEvents.CONNECTION_STATUS, {
3095
+ detail: this.isConnected()
3096
+ }));
3097
+ }
3035
3098
  }
3036
3099
 
3037
3100
  class HealthManager {
@@ -1,2 +1,2 @@
1
- import '../index-Gts2Ddu_.js';
2
- export { B as BaseProtocol } from '../base_protocol-Dge5_tvU.js';
1
+ import '../index-tdQNdKHx.js';
2
+ export { B as BaseProtocol } from '../base_protocol-C47QkJ2o.js';
@@ -1,2 +1,2 @@
1
- export { D as DecodedMessage, j as Decoder, E as Encoder, V as Version, i as createDecoder, g as createEncoder, m as proto } from '../../version_0-CNRKFufI.js';
2
- import '../../index-Gts2Ddu_.js';
1
+ export { D as DecodedMessage, j as Decoder, E as Encoder, V as Version, i as createDecoder, g as createEncoder, m as proto } from '../../version_0-BrbNEwD-.js';
2
+ import '../../index-tdQNdKHx.js';
@@ -1,4 +1,4 @@
1
- import { a as allocUnsafe, f as fromString, b as alloc$1, L as Logger, g as determinePubsubTopic } from './index-Gts2Ddu_.js';
1
+ import { a as allocUnsafe, f as fromString, b as alloc$1, L as Logger, g as determinePubsubTopic } from './index-tdQNdKHx.js';
2
2
 
3
3
  /* eslint-disable no-fallthrough */
4
4
  const N1 = Math.pow(2, 7);