@waku/core 0.0.33-f599932.0 → 0.0.34-09108d9.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 +22 -0
- package/bundle/base_protocol-Bp5a9PNG.js +152 -0
- package/bundle/{index-BVysxsMu.js → index-G1eRBjeI.js} +136 -215
- package/bundle/index.js +1963 -621
- package/bundle/lib/base_protocol.js +2 -2
- package/bundle/lib/message/version_0.js +2 -2
- package/bundle/{version_0-C5ObpJ_0.js → version_0-DJZG2fB2.js} +285 -41
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/lib/base_protocol.d.ts +3 -23
- package/dist/lib/base_protocol.js +3 -51
- package/dist/lib/base_protocol.js.map +1 -1
- package/dist/lib/connection_manager/connection_manager.d.ts +118 -0
- package/dist/lib/{connection_manager.js → connection_manager/connection_manager.js} +136 -36
- package/dist/lib/connection_manager/connection_manager.js.map +1 -0
- package/dist/lib/connection_manager/index.d.ts +1 -0
- package/dist/lib/connection_manager/index.js +2 -0
- package/dist/lib/connection_manager/index.js.map +1 -0
- package/dist/lib/{keep_alive_manager.d.ts → connection_manager/keep_alive_manager.d.ts} +4 -2
- package/dist/lib/{keep_alive_manager.js → connection_manager/keep_alive_manager.js} +2 -2
- package/dist/lib/connection_manager/keep_alive_manager.js.map +1 -0
- package/dist/lib/connection_manager/utils.d.ts +7 -0
- package/dist/lib/connection_manager/utils.js +22 -0
- package/dist/lib/connection_manager/utils.js.map +1 -0
- package/dist/lib/filter/filter.d.ts +18 -0
- package/dist/lib/filter/filter.js +209 -0
- package/dist/lib/filter/filter.js.map +1 -0
- package/dist/lib/filter/index.d.ts +1 -19
- package/dist/lib/filter/index.js +1 -211
- package/dist/lib/filter/index.js.map +1 -1
- package/dist/lib/light_push/index.d.ts +1 -15
- package/dist/lib/light_push/index.js +1 -143
- package/dist/lib/light_push/index.js.map +1 -1
- package/dist/lib/light_push/light_push.d.ts +15 -0
- package/dist/lib/light_push/light_push.js +144 -0
- package/dist/lib/light_push/light_push.js.map +1 -0
- package/dist/lib/light_push/utils.d.ts +0 -2
- package/dist/lib/light_push/utils.js +8 -16
- package/dist/lib/light_push/utils.js.map +1 -1
- package/dist/lib/metadata/index.d.ts +1 -3
- package/dist/lib/metadata/index.js +1 -118
- package/dist/lib/metadata/index.js.map +1 -1
- package/dist/lib/metadata/metadata.d.ts +3 -0
- package/dist/lib/metadata/metadata.js +119 -0
- package/dist/lib/metadata/metadata.js.map +1 -0
- package/dist/lib/store/index.d.ts +1 -9
- package/dist/lib/store/index.js +1 -82
- package/dist/lib/store/index.js.map +1 -1
- package/dist/lib/store/store.d.ts +9 -0
- package/dist/lib/store/store.js +83 -0
- package/dist/lib/store/store.js.map +1 -0
- package/dist/lib/stream_manager/stream_manager.d.ts +13 -10
- package/dist/lib/stream_manager/stream_manager.js +88 -58
- package/dist/lib/stream_manager/stream_manager.js.map +1 -1
- package/dist/lib/stream_manager/utils.d.ts +1 -1
- package/dist/lib/stream_manager/utils.js +5 -17
- package/dist/lib/stream_manager/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -7
- package/src/lib/base_protocol.ts +3 -82
- package/src/lib/{connection_manager.ts → connection_manager/connection_manager.ts} +168 -63
- package/src/lib/connection_manager/index.ts +1 -0
- package/src/lib/{keep_alive_manager.ts → connection_manager/keep_alive_manager.ts} +7 -3
- package/src/lib/connection_manager/utils.ts +25 -0
- package/src/lib/filter/filter.ts +315 -0
- package/src/lib/filter/index.ts +1 -323
- package/src/lib/light_push/index.ts +1 -188
- package/src/lib/light_push/light_push.ts +188 -0
- package/src/lib/light_push/utils.ts +12 -20
- package/src/lib/metadata/index.ts +1 -182
- package/src/lib/metadata/metadata.ts +182 -0
- package/src/lib/store/index.ts +1 -136
- package/src/lib/store/store.ts +136 -0
- package/src/lib/stream_manager/stream_manager.ts +125 -69
- package/src/lib/stream_manager/utils.ts +5 -17
- package/bundle/base_protocol-CS0EDeEY.js +0 -260
- package/dist/lib/connection_manager.d.ts +0 -62
- package/dist/lib/connection_manager.js.map +0 -1
- package/dist/lib/filterPeers.d.ts +0 -13
- package/dist/lib/filterPeers.js +0 -38
- package/dist/lib/filterPeers.js.map +0 -1
- package/dist/lib/health_manager.d.ts +0 -14
- package/dist/lib/health_manager.js +0 -70
- package/dist/lib/health_manager.js.map +0 -1
- package/dist/lib/keep_alive_manager.js.map +0 -1
- package/dist/lib/wait_for_remote_peer.d.ts +0 -22
- package/dist/lib/wait_for_remote_peer.js +0 -142
- package/dist/lib/wait_for_remote_peer.js.map +0 -1
- package/src/lib/filterPeers.ts +0 -51
- package/src/lib/health_manager.ts +0 -90
- package/src/lib/wait_for_remote_peer.ts +0 -200
@@ -1,19 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
|
24
|
+
function fromString(str) {
|
28
25
|
return new TextEncoder().encode(str);
|
29
26
|
}
|
30
|
-
function toString
|
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 (
|
238
|
+
if (prefixCodePoint === undefined) {
|
241
239
|
throw new Error('Invalid prefix character');
|
242
240
|
}
|
243
|
-
this.prefixCodePoint =
|
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) => {
|
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
|
458
|
-
if (
|
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
|
628
|
-
decode: (str) => fromString
|
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
|
-
|
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
|
-
*
|
715
|
-
*
|
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["
|
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
|
-
*
|
767
|
-
*
|
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["
|
699
|
+
ProtocolError["ENCODE_FAILED"] = "Failed to encode";
|
771
700
|
/**
|
772
|
-
* The
|
773
|
-
*
|
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["
|
704
|
+
ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
|
776
705
|
/**
|
777
|
-
*
|
778
|
-
*
|
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["
|
709
|
+
ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
|
781
710
|
/**
|
782
|
-
*
|
783
|
-
*
|
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["
|
714
|
+
ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
786
715
|
/**
|
787
|
-
*
|
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["
|
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
|
-
|
1206
|
-
|
1207
|
-
|
1112
|
+
const split = (typeof namespaces === 'string' ? namespaces : '')
|
1113
|
+
.trim()
|
1114
|
+
.replace(' ', ',')
|
1115
|
+
.split(',')
|
1116
|
+
.filter(Boolean);
|
1208
1117
|
|
1209
|
-
for (
|
1210
|
-
if (
|
1211
|
-
|
1212
|
-
|
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
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
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
|
-
|
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
|
1234
|
-
...createDebug.skips.map(
|
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
|
-
|
1249
|
-
|
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 (
|
1262
|
-
if (
|
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,
|
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 };
|