@waku/core 0.0.33-f599932.0 → 0.0.34-00f2e75.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 (93) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/bundle/base_protocol-Bp5a9PNG.js +152 -0
  3. package/bundle/{index-BVysxsMu.js → index-G1eRBjeI.js} +136 -215
  4. package/bundle/index.js +1964 -622
  5. package/bundle/lib/base_protocol.js +2 -2
  6. package/bundle/lib/message/version_0.js +2 -2
  7. package/bundle/{version_0-C5ObpJ_0.js → version_0-DJZG2fB2.js} +285 -41
  8. package/dist/.tsbuildinfo +1 -1
  9. package/dist/index.d.ts +2 -5
  10. package/dist/index.js +2 -5
  11. package/dist/index.js.map +1 -1
  12. package/dist/lib/base_protocol.d.ts +3 -23
  13. package/dist/lib/base_protocol.js +3 -51
  14. package/dist/lib/base_protocol.js.map +1 -1
  15. package/dist/lib/connection_manager/connection_manager.d.ts +118 -0
  16. package/dist/lib/{connection_manager.js → connection_manager/connection_manager.js} +136 -36
  17. package/dist/lib/connection_manager/connection_manager.js.map +1 -0
  18. package/dist/lib/connection_manager/index.d.ts +1 -0
  19. package/dist/lib/connection_manager/index.js +2 -0
  20. package/dist/lib/connection_manager/index.js.map +1 -0
  21. package/dist/lib/{keep_alive_manager.d.ts → connection_manager/keep_alive_manager.d.ts} +4 -2
  22. package/dist/lib/{keep_alive_manager.js → connection_manager/keep_alive_manager.js} +2 -2
  23. package/dist/lib/connection_manager/keep_alive_manager.js.map +1 -0
  24. package/dist/lib/connection_manager/utils.d.ts +7 -0
  25. package/dist/lib/connection_manager/utils.js +22 -0
  26. package/dist/lib/connection_manager/utils.js.map +1 -0
  27. package/dist/lib/filter/filter.d.ts +18 -0
  28. package/dist/lib/filter/filter.js +209 -0
  29. package/dist/lib/filter/filter.js.map +1 -0
  30. package/dist/lib/filter/index.d.ts +1 -19
  31. package/dist/lib/filter/index.js +1 -211
  32. package/dist/lib/filter/index.js.map +1 -1
  33. package/dist/lib/light_push/index.d.ts +1 -15
  34. package/dist/lib/light_push/index.js +1 -143
  35. package/dist/lib/light_push/index.js.map +1 -1
  36. package/dist/lib/light_push/light_push.d.ts +15 -0
  37. package/dist/lib/light_push/light_push.js +144 -0
  38. package/dist/lib/light_push/light_push.js.map +1 -0
  39. package/dist/lib/light_push/utils.d.ts +0 -2
  40. package/dist/lib/light_push/utils.js +9 -17
  41. package/dist/lib/light_push/utils.js.map +1 -1
  42. package/dist/lib/metadata/index.d.ts +1 -3
  43. package/dist/lib/metadata/index.js +1 -118
  44. package/dist/lib/metadata/index.js.map +1 -1
  45. package/dist/lib/metadata/metadata.d.ts +3 -0
  46. package/dist/lib/metadata/metadata.js +119 -0
  47. package/dist/lib/metadata/metadata.js.map +1 -0
  48. package/dist/lib/store/index.d.ts +1 -9
  49. package/dist/lib/store/index.js +1 -82
  50. package/dist/lib/store/index.js.map +1 -1
  51. package/dist/lib/store/store.d.ts +9 -0
  52. package/dist/lib/store/store.js +83 -0
  53. package/dist/lib/store/store.js.map +1 -0
  54. package/dist/lib/stream_manager/stream_manager.d.ts +13 -10
  55. package/dist/lib/stream_manager/stream_manager.js +88 -58
  56. package/dist/lib/stream_manager/stream_manager.js.map +1 -1
  57. package/dist/lib/stream_manager/utils.d.ts +1 -1
  58. package/dist/lib/stream_manager/utils.js +5 -17
  59. package/dist/lib/stream_manager/utils.js.map +1 -1
  60. package/package.json +1 -1
  61. package/src/index.ts +2 -7
  62. package/src/lib/base_protocol.ts +3 -82
  63. package/src/lib/{connection_manager.ts → connection_manager/connection_manager.ts} +168 -63
  64. package/src/lib/connection_manager/index.ts +1 -0
  65. package/src/lib/{keep_alive_manager.ts → connection_manager/keep_alive_manager.ts} +7 -3
  66. package/src/lib/connection_manager/utils.ts +25 -0
  67. package/src/lib/filter/filter.ts +315 -0
  68. package/src/lib/filter/index.ts +1 -323
  69. package/src/lib/light_push/index.ts +1 -188
  70. package/src/lib/light_push/light_push.ts +188 -0
  71. package/src/lib/light_push/utils.ts +13 -21
  72. package/src/lib/metadata/index.ts +1 -182
  73. package/src/lib/metadata/metadata.ts +182 -0
  74. package/src/lib/store/index.ts +1 -136
  75. package/src/lib/store/store.ts +136 -0
  76. package/src/lib/stream_manager/stream_manager.ts +125 -69
  77. package/src/lib/stream_manager/utils.ts +5 -17
  78. package/bundle/base_protocol-CS0EDeEY.js +0 -260
  79. package/dist/lib/connection_manager.d.ts +0 -62
  80. package/dist/lib/connection_manager.js.map +0 -1
  81. package/dist/lib/filterPeers.d.ts +0 -13
  82. package/dist/lib/filterPeers.js +0 -38
  83. package/dist/lib/filterPeers.js.map +0 -1
  84. package/dist/lib/health_manager.d.ts +0 -14
  85. package/dist/lib/health_manager.js +0 -70
  86. package/dist/lib/health_manager.js.map +0 -1
  87. package/dist/lib/keep_alive_manager.js.map +0 -1
  88. package/dist/lib/wait_for_remote_peer.d.ts +0 -22
  89. package/dist/lib/wait_for_remote_peer.js +0 -142
  90. package/dist/lib/wait_for_remote_peer.js.map +0 -1
  91. package/src/lib/filterPeers.ts +0 -51
  92. package/src/lib/health_manager.ts +0 -90
  93. package/src/lib/wait_for_remote_peer.ts +0 -200
@@ -1,19 +1,16 @@
1
- /**
2
- * Returns a `Uint8Array` of the requested size. Referenced memory will
3
- * be initialized to 0.
4
- */
5
- function alloc(size = 0) {
6
- return new Uint8Array(size);
7
- }
8
- /**
9
- * Where possible returns a Uint8Array of the requested size that references
10
- * uninitialized memory. Only use if you are certain you will immediately
11
- * overwrite every value in the returned `Uint8Array`.
12
- */
13
- function allocUnsafe(size = 0) {
14
- return new Uint8Array(size);
1
+ function equals(aa, bb) {
2
+ if (aa === bb)
3
+ return true;
4
+ if (aa.byteLength !== bb.byteLength) {
5
+ return false;
6
+ }
7
+ for (let ii = 0; ii < aa.byteLength; ii++) {
8
+ if (aa[ii] !== bb[ii]) {
9
+ return false;
10
+ }
11
+ }
12
+ return true;
15
13
  }
16
-
17
14
  function coerce(o) {
18
15
  if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array')
19
16
  return o;
@@ -24,10 +21,10 @@ function coerce(o) {
24
21
  }
25
22
  throw new Error('Unknown type, must be binary type');
26
23
  }
27
- function fromString$1(str) {
24
+ function fromString(str) {
28
25
  return new TextEncoder().encode(str);
29
26
  }
30
- function toString$1(b) {
27
+ function toString(b) {
31
28
  return new TextDecoder().decode(b);
32
29
  }
33
30
 
@@ -236,11 +233,12 @@ class Decoder {
236
233
  constructor(name, prefix, baseDecode) {
237
234
  this.name = name;
238
235
  this.prefix = prefix;
236
+ const prefixCodePoint = prefix.codePointAt(0);
239
237
  /* c8 ignore next 3 */
240
- if (prefix.codePointAt(0) === undefined) {
238
+ if (prefixCodePoint === undefined) {
241
239
  throw new Error('Invalid prefix character');
242
240
  }
243
- this.prefixCodePoint = prefix.codePointAt(0);
241
+ this.prefixCodePoint = prefixCodePoint;
244
242
  this.baseDecode = baseDecode;
245
243
  }
246
244
  decode(text) {
@@ -444,7 +442,14 @@ var base2$1 = /*#__PURE__*/Object.freeze({
444
442
 
445
443
  const alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');
446
444
  const alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));
447
- const alphabetCharsToBytes = (alphabet.reduce((p, c, i) => { p[c.codePointAt(0)] = i; return p; }, ([])));
445
+ const alphabetCharsToBytes = (alphabet.reduce((p, c, i) => {
446
+ const codePoint = c.codePointAt(0);
447
+ if (codePoint == null) {
448
+ throw new Error(`Invalid character: ${c}`);
449
+ }
450
+ p[codePoint] = i;
451
+ return p;
452
+ }, ([])));
448
453
  function encode(data) {
449
454
  return data.reduce((p, c) => {
450
455
  p += alphabetBytesToChars[c];
@@ -454,8 +459,12 @@ function encode(data) {
454
459
  function decode(str) {
455
460
  const byts = [];
456
461
  for (const char of str) {
457
- const byt = alphabetCharsToBytes[char.codePointAt(0)];
458
- if (byt === undefined) {
462
+ const codePoint = char.codePointAt(0);
463
+ if (codePoint == null) {
464
+ throw new Error(`Invalid character: ${char}`);
465
+ }
466
+ const byt = alphabetCharsToBytes[codePoint];
467
+ if (byt == null) {
459
468
  throw new Error(`Non-base256emoji character: ${char}`);
460
469
  }
461
470
  byts.push(byt);
@@ -624,8 +633,8 @@ var base8$1 = /*#__PURE__*/Object.freeze({
624
633
  const identity = from({
625
634
  prefix: '\x00',
626
635
  name: 'identity',
627
- encode: (buf) => toString$1(buf),
628
- decode: (str) => fromString$1(str)
636
+ encode: (buf) => toString(buf),
637
+ decode: (str) => fromString(str)
629
638
  });
630
639
 
631
640
  var identityBase = /*#__PURE__*/Object.freeze({
@@ -636,69 +645,6 @@ var identityBase = /*#__PURE__*/Object.freeze({
636
645
  new TextEncoder();
637
646
  new TextDecoder();
638
647
 
639
- const bases = { ...identityBase, ...base2$1, ...base8$1, ...base10$1, ...base16$1, ...base32$1, ...base36$1, ...base58, ...base64$1, ...base256emoji$1 };
640
-
641
- function createCodec(name, prefix, encode, decode) {
642
- return {
643
- name,
644
- prefix,
645
- encoder: {
646
- name,
647
- prefix,
648
- encode
649
- },
650
- decoder: {
651
- decode
652
- }
653
- };
654
- }
655
- const string = createCodec('utf8', 'u', (buf) => {
656
- const decoder = new TextDecoder('utf8');
657
- return 'u' + decoder.decode(buf);
658
- }, (str) => {
659
- const encoder = new TextEncoder();
660
- return encoder.encode(str.substring(1));
661
- });
662
- const ascii = createCodec('ascii', 'a', (buf) => {
663
- let string = 'a';
664
- for (let i = 0; i < buf.length; i++) {
665
- string += String.fromCharCode(buf[i]);
666
- }
667
- return string;
668
- }, (str) => {
669
- str = str.substring(1);
670
- const buf = allocUnsafe(str.length);
671
- for (let i = 0; i < str.length; i++) {
672
- buf[i] = str.charCodeAt(i);
673
- }
674
- return buf;
675
- });
676
- const BASES = {
677
- utf8: string,
678
- 'utf-8': string,
679
- hex: bases.base16,
680
- latin1: ascii,
681
- ascii,
682
- binary: ascii,
683
- ...bases
684
- };
685
-
686
- /**
687
- * Create a `Uint8Array` from the passed string
688
- *
689
- * Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.
690
- *
691
- * Also `ascii` which is similar to node's 'binary' encoding.
692
- */
693
- function fromString(string, encoding = 'utf8') {
694
- const base = BASES[encoding];
695
- if (base == null) {
696
- throw new Error(`Unsupported encoding "${encoding}"`);
697
- }
698
- // add multibase prefix
699
- return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
700
- }
701
-
702
648
  var Protocols;
703
649
  (function (Protocols) {
704
650
  Protocols["Relay"] = "relay";
@@ -708,43 +654,24 @@ var Protocols;
708
654
  })(Protocols || (Protocols = {}));
709
655
  var ProtocolError;
710
656
  (function (ProtocolError) {
711
- /** Could not determine the origin of the fault. Best to check connectivity and try again */
657
+ //
658
+ // GENERAL ERRORS SECTION
659
+ //
660
+ /**
661
+ * Could not determine the origin of the fault. Best to check connectivity and try again
662
+ * */
712
663
  ProtocolError["GENERIC_FAIL"] = "Generic error";
713
664
  /**
714
- * Failure to protobuf encode the message. This is not recoverable and needs
715
- * further investigation.
665
+ * The remote peer rejected the message. Information provided by the remote peer
666
+ * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
667
+ * or `DECODE_FAILED` can be used.
716
668
  */
717
- ProtocolError["ENCODE_FAILED"] = "Failed to encode";
669
+ ProtocolError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
718
670
  /**
719
671
  * Failure to protobuf decode the message. May be due to a remote peer issue,
720
672
  * ensuring that messages are sent via several peer enable mitigation of this error.
721
673
  */
722
674
  ProtocolError["DECODE_FAILED"] = "Failed to decode";
723
- /**
724
- * The message payload is empty, making the message invalid. Ensure that a non-empty
725
- * payload is set on the outgoing message.
726
- */
727
- ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
728
- /**
729
- * The message size is above the maximum message size allowed on the Waku Network.
730
- * Compressing the message or using an alternative strategy for large messages is recommended.
731
- */
732
- ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
733
- /**
734
- * The PubsubTopic passed to the send function is not configured on the Waku node.
735
- * Please ensure that the PubsubTopic is used when initializing the Waku node.
736
- */
737
- ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
738
- /**
739
- * The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
740
- * Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
741
- */
742
- ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
743
- /**
744
- * The topics passed in the decoders do not match each other, or don't exist at all.
745
- * Ensure that all the pubsub topics used in the decoders are valid and match each other.
746
- */
747
- ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
748
675
  /**
749
676
  * Failure to find a peer with suitable protocols. This may due to a connection issue.
750
677
  * Mitigation can be: retrying after a given time period, display connectivity issue
@@ -762,37 +689,51 @@ var ProtocolError;
762
689
  * or `DECODE_FAILED` can be used.
763
690
  */
764
691
  ProtocolError["NO_RESPONSE"] = "No response received";
692
+ //
693
+ // SEND ERRORS SECTION
694
+ //
765
695
  /**
766
- * The remote peer rejected the message. Information provided by the remote peer
767
- * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
768
- * or `DECODE_FAILED` can be used.
696
+ * Failure to protobuf encode the message. This is not recoverable and needs
697
+ * further investigation.
769
698
  */
770
- ProtocolError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
699
+ ProtocolError["ENCODE_FAILED"] = "Failed to encode";
771
700
  /**
772
- * The protocol request timed out without a response. This may be due to a connection issue.
773
- * Mitigation can be: retrying after a given time period
701
+ * The message payload is empty, making the message invalid. Ensure that a non-empty
702
+ * payload is set on the outgoing message.
774
703
  */
775
- ProtocolError["REQUEST_TIMEOUT"] = "Request timeout";
704
+ ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
776
705
  /**
777
- * Missing credentials info message.
778
- * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L186
706
+ * The message size is above the maximum message size allowed on the Waku Network.
707
+ * Compressing the message or using an alternative strategy for large messages is recommended.
779
708
  */
780
- ProtocolError["RLN_IDENTITY_MISSING"] = "Identity credentials are not set";
709
+ ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
781
710
  /**
782
- * Membership index missing info message.
783
- * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L188
711
+ * The PubsubTopic passed to the send function is not configured on the Waku node.
712
+ * Please ensure that the PubsubTopic is used when initializing the Waku node.
784
713
  */
785
- ProtocolError["RLN_MEMBERSHIP_INDEX"] = "Membership index is not set";
714
+ ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
786
715
  /**
787
- * Message limit is missing.
788
- * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L190
716
+ * Fails when
789
717
  */
790
- ProtocolError["RLN_LIMIT_MISSING"] = "User message limit is not set";
718
+ ProtocolError["STREAM_ABORTED"] = "Stream aborted";
791
719
  /**
792
720
  * General proof generation error message.
793
721
  * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
794
722
  */
795
723
  ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
724
+ //
725
+ // RECEIVE ERRORS SECTION
726
+ //
727
+ /**
728
+ * The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
729
+ * Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
730
+ */
731
+ ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
732
+ /**
733
+ * The topics passed in the decoders do not match each other, or don't exist at all.
734
+ * Ensure that all the pubsub topics used in the decoders are valid and match each other.
735
+ */
736
+ ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
796
737
  })(ProtocolError || (ProtocolError = {}));
797
738
 
798
739
  var Tags;
@@ -813,6 +754,10 @@ var EConnectionStateEvents;
813
754
  EConnectionStateEvents["CONNECTION_STATUS"] = "waku:connection";
814
755
  })(EConnectionStateEvents || (EConnectionStateEvents = {}));
815
756
 
757
+ var HealthStatusChangeEvents;
758
+ (function (HealthStatusChangeEvents) {
759
+ HealthStatusChangeEvents["StatusChange"] = "health:change";
760
+ })(HealthStatusChangeEvents || (HealthStatusChangeEvents = {}));
816
761
  var HealthStatus;
817
762
  (function (HealthStatus) {
818
763
  HealthStatus["Unhealthy"] = "Unhealthy";
@@ -820,44 +765,6 @@ var HealthStatus;
820
765
  HealthStatus["SufficientlyHealthy"] = "SufficientlyHealthy";
821
766
  })(HealthStatus || (HealthStatus = {}));
822
767
 
823
- /**
824
- * Turns a `Uint8Array` into a string.
825
- *
826
- * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.
827
- *
828
- * Also `ascii` which is similar to node's 'binary' encoding.
829
- */
830
- function toString(array, encoding = 'utf8') {
831
- const base = BASES[encoding];
832
- if (base == null) {
833
- throw new Error(`Unsupported encoding "${encoding}"`);
834
- }
835
- // strip multibase prefix
836
- return base.encoder.encode(array).substring(1);
837
- }
838
-
839
- /**
840
- * Decode byte array to utf-8 string.
841
- */
842
- const bytesToUtf8 = (b) => toString(b, "utf8");
843
- /**
844
- * Encode utf-8 string to byte array.
845
- */
846
- const utf8ToBytes = (s) => fromString(s, "utf8");
847
- /**
848
- * Concatenate using Uint8Arrays as `Buffer` has a different behavior with `DataView`
849
- */
850
- function concat(byteArrays, totalLength) {
851
- const len = byteArrays.reduce((acc, curr) => acc + curr.length, 0);
852
- const res = new Uint8Array(len);
853
- let offset = 0;
854
- for (const bytes of byteArrays) {
855
- res.set(bytes, offset);
856
- offset += bytes.length;
857
- }
858
- return res;
859
- }
860
-
861
768
  function getDefaultExportFromCjs (x) {
862
769
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
863
770
  }
@@ -895,7 +802,7 @@ function requireMs () {
895
802
  * @api public
896
803
  */
897
804
 
898
- ms = function(val, options) {
805
+ ms = function (val, options) {
899
806
  options = options || {};
900
807
  var type = typeof val;
901
808
  if (type === 'string' && val.length > 0) {
@@ -1202,24 +1109,62 @@ function setup(env) {
1202
1109
  createDebug.names = [];
1203
1110
  createDebug.skips = [];
1204
1111
 
1205
- let i;
1206
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
1207
- const len = split.length;
1112
+ const split = (typeof namespaces === 'string' ? namespaces : '')
1113
+ .trim()
1114
+ .replace(' ', ',')
1115
+ .split(',')
1116
+ .filter(Boolean);
1208
1117
 
1209
- for (i = 0; i < len; i++) {
1210
- if (!split[i]) {
1211
- // ignore empty strings
1212
- continue;
1118
+ for (const ns of split) {
1119
+ if (ns[0] === '-') {
1120
+ createDebug.skips.push(ns.slice(1));
1121
+ } else {
1122
+ createDebug.names.push(ns);
1213
1123
  }
1124
+ }
1125
+ }
1214
1126
 
1215
- namespaces = split[i].replace(/\*/g, '.*?');
1216
-
1217
- if (namespaces[0] === '-') {
1218
- createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
1127
+ /**
1128
+ * Checks if the given string matches a namespace template, honoring
1129
+ * asterisks as wildcards.
1130
+ *
1131
+ * @param {String} search
1132
+ * @param {String} template
1133
+ * @return {Boolean}
1134
+ */
1135
+ function matchesTemplate(search, template) {
1136
+ let searchIndex = 0;
1137
+ let templateIndex = 0;
1138
+ let starIndex = -1;
1139
+ let matchIndex = 0;
1140
+
1141
+ while (searchIndex < search.length) {
1142
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
1143
+ // Match character or proceed with wildcard
1144
+ if (template[templateIndex] === '*') {
1145
+ starIndex = templateIndex;
1146
+ matchIndex = searchIndex;
1147
+ templateIndex++; // Skip the '*'
1148
+ } else {
1149
+ searchIndex++;
1150
+ templateIndex++;
1151
+ }
1152
+ } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
1153
+ // Backtrack to the last '*' and try to match more characters
1154
+ templateIndex = starIndex + 1;
1155
+ matchIndex++;
1156
+ searchIndex = matchIndex;
1219
1157
  } else {
1220
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
1158
+ return false; // No match
1221
1159
  }
1222
1160
  }
1161
+
1162
+ // Handle trailing '*' in template
1163
+ while (templateIndex < template.length && template[templateIndex] === '*') {
1164
+ templateIndex++;
1165
+ }
1166
+
1167
+ return templateIndex === template.length;
1223
1168
  }
1224
1169
 
1225
1170
  /**
@@ -1230,8 +1175,8 @@ function setup(env) {
1230
1175
  */
1231
1176
  function disable() {
1232
1177
  const namespaces = [
1233
- ...createDebug.names.map(toNamespace),
1234
- ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
1178
+ ...createDebug.names,
1179
+ ...createDebug.skips.map(namespace => '-' + namespace)
1235
1180
  ].join(',');
1236
1181
  createDebug.enable('');
1237
1182
  return namespaces;
@@ -1245,21 +1190,14 @@ function setup(env) {
1245
1190
  * @api public
1246
1191
  */
1247
1192
  function enabled(name) {
1248
- if (name[name.length - 1] === '*') {
1249
- return true;
1250
- }
1251
-
1252
- let i;
1253
- let len;
1254
-
1255
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
1256
- if (createDebug.skips[i].test(name)) {
1193
+ for (const skip of createDebug.skips) {
1194
+ if (matchesTemplate(name, skip)) {
1257
1195
  return false;
1258
1196
  }
1259
1197
  }
1260
1198
 
1261
- for (i = 0, len = createDebug.names.length; i < len; i++) {
1262
- if (createDebug.names[i].test(name)) {
1199
+ for (const ns of createDebug.names) {
1200
+ if (matchesTemplate(name, ns)) {
1263
1201
  return true;
1264
1202
  }
1265
1203
  }
@@ -1267,19 +1205,6 @@ function setup(env) {
1267
1205
  return false;
1268
1206
  }
1269
1207
 
1270
- /**
1271
- * Convert regexp to namespace
1272
- *
1273
- * @param {RegExp} regxep
1274
- * @return {String} namespace
1275
- * @api private
1276
- */
1277
- function toNamespace(regexp) {
1278
- return regexp.toString()
1279
- .substring(2, regexp.toString().length - 2)
1280
- .replace(/\.\*\?$/, '*');
1281
- }
1282
-
1283
1208
  /**
1284
1209
  * Coerce `val`.
1285
1210
  *
@@ -1441,6 +1366,7 @@ var common = setup;
1441
1366
 
1442
1367
  // Is webkit? http://stackoverflow.com/a/16459606/376773
1443
1368
  // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
1369
+ // eslint-disable-next-line no-return-assign
1444
1370
  return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
1445
1371
  // Is firebug? http://stackoverflow.com/a/398120/376773
1446
1372
  (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
@@ -1588,7 +1514,6 @@ var debug = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
1588
1514
 
1589
1515
  const APP_NAME = "waku";
1590
1516
  class Logger {
1591
- _debug;
1592
1517
  _info;
1593
1518
  _warn;
1594
1519
  _error;
@@ -1596,14 +1521,10 @@ class Logger {
1596
1521
  return prefix ? `${APP_NAME}:${level}:${prefix}` : `${APP_NAME}:${level}`;
1597
1522
  }
1598
1523
  constructor(prefix) {
1599
- this._debug = debug(Logger.createDebugNamespace("debug", prefix));
1600
1524
  this._info = debug(Logger.createDebugNamespace("info", prefix));
1601
1525
  this._warn = debug(Logger.createDebugNamespace("warn", prefix));
1602
1526
  this._error = debug(Logger.createDebugNamespace("error", prefix));
1603
1527
  }
1604
- get debug() {
1605
- return this._debug;
1606
- }
1607
1528
  get info() {
1608
1529
  return this._info;
1609
1530
  }
@@ -1619,4 +1540,4 @@ class Logger {
1619
1540
  }
1620
1541
  }
1621
1542
 
1622
- 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, concat as e, fromString as f, bytesToUtf8 as g, utf8ToBytes as u };
1543
+ export { EPeersByDiscoveryEvents as E, Logger as L, ProtocolError as P, Tags as T, base32 as a, base36 as b, coerce as c, base58btc as d, equals as e, EConnectionStateEvents as f, base2$1 as g, base8$1 as h, identityBase as i, base10$1 as j, base16$1 as k, base32$1 as l, base36$1 as m, base58 as n, base64$1 as o, base256emoji$1 as p };