@waku/core 0.0.23 → 0.0.25-a42b7be.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 +34 -0
- package/bundle/{base_protocol-84d9b670.js → base_protocol-4bcf7514.js} +194 -134
- package/bundle/{browser-bde977a3.js → browser-90197c87.js} +26 -1
- package/bundle/index-27b91e3b.js +31 -0
- package/bundle/index.js +19384 -2421
- package/bundle/lib/base_protocol.js +3 -2
- package/bundle/lib/message/version_0.js +3 -2
- package/bundle/lib/predefined_bootstrap_nodes.js +2 -0
- package/bundle/{version_0-74b4b9db.js → version_0-2f1176e3.js} +36 -24
- package/dist/.tsbuildinfo +1 -1
- package/dist/lib/connection_manager.d.ts +17 -4
- package/dist/lib/connection_manager.js +111 -45
- package/dist/lib/connection_manager.js.map +1 -1
- package/dist/lib/filter/index.js +53 -37
- package/dist/lib/filter/index.js.map +1 -1
- package/dist/lib/keep_alive_manager.d.ts +1 -0
- package/dist/lib/keep_alive_manager.js +42 -18
- package/dist/lib/keep_alive_manager.js.map +1 -1
- package/dist/lib/light_push/index.js +60 -38
- package/dist/lib/light_push/index.js.map +1 -1
- package/dist/lib/light_push/push_rpc.d.ts +1 -1
- package/dist/lib/light_push/push_rpc.js +2 -2
- package/dist/lib/message/version_0.d.ts +13 -13
- package/dist/lib/message/version_0.js +22 -20
- package/dist/lib/message/version_0.js.map +1 -1
- package/dist/lib/store/history_rpc.d.ts +1 -1
- package/dist/lib/store/history_rpc.js +1 -1
- package/dist/lib/store/index.d.ts +1 -1
- package/dist/lib/store/index.js +43 -17
- package/dist/lib/store/index.js.map +1 -1
- package/dist/lib/stream_manager.d.ts +1 -1
- package/dist/lib/stream_manager.js +8 -5
- package/dist/lib/stream_manager.js.map +1 -1
- package/dist/lib/wait_for_remote_peer.d.ts +2 -2
- package/dist/lib/wait_for_remote_peer.js +13 -11
- package/dist/lib/wait_for_remote_peer.js.map +1 -1
- package/dist/lib/waku.d.ts +4 -3
- package/dist/lib/waku.js +13 -11
- package/dist/lib/waku.js.map +1 -1
- package/package.json +1 -137
- package/src/lib/connection_manager.ts +156 -51
- package/src/lib/filter/index.ts +76 -40
- package/src/lib/keep_alive_manager.ts +53 -20
- package/src/lib/light_push/index.ts +74 -38
- package/src/lib/light_push/push_rpc.ts +2 -2
- package/src/lib/message/version_0.ts +25 -17
- package/src/lib/store/history_rpc.ts +2 -2
- package/src/lib/store/index.ts +60 -23
- package/src/lib/stream_manager.ts +12 -7
- package/src/lib/wait_for_remote_peer.ts +13 -11
- package/src/lib/waku.ts +12 -9
- package/dist/lib/push_or_init_map.d.ts +0 -1
- package/dist/lib/push_or_init_map.js +0 -9
- package/dist/lib/push_or_init_map.js.map +0 -1
- package/src/lib/push_or_init_map.ts +0 -13
package/CHANGELOG.md
CHANGED
@@ -5,6 +5,40 @@ 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.24](https://github.com/waku-org/js-waku/compare/core-v0.0.23...core-v0.0.24) (2023-10-16)
|
9
|
+
|
10
|
+
|
11
|
+
### ⚠ BREAKING CHANGES
|
12
|
+
|
13
|
+
* **store:** use `pubSubTopic` from `DecodedMessage` for `createCursor` ([#1640](https://github.com/waku-org/js-waku/issues/1640))
|
14
|
+
* **static-sharding:** allow multiple pubSubTopics ([#1586](https://github.com/waku-org/js-waku/issues/1586))
|
15
|
+
* return `REMOTE_PEER_REJECTED` if remote peer rejected the message
|
16
|
+
|
17
|
+
### Features
|
18
|
+
|
19
|
+
* Add Firefox and Webkit to karma ([#1598](https://github.com/waku-org/js-waku/issues/1598)) ([d9e4bcb](https://github.com/waku-org/js-waku/commit/d9e4bcbe3f7bcc092f20621bd362d76426701dab))
|
20
|
+
* Enable pinging connected peers by default ([#1647](https://github.com/waku-org/js-waku/issues/1647)) ([1d60c4b](https://github.com/waku-org/js-waku/commit/1d60c4ba44f7fd511371e926247d9151590edec5))
|
21
|
+
* Return `REMOTE_PEER_REJECTED` if remote peer rejected the message ([053b654](https://github.com/waku-org/js-waku/commit/053b6545ad0c2450af5687495eb7b6049c0f21ad))
|
22
|
+
* **static-sharding:** Allow multiple pubSubTopics ([#1586](https://github.com/waku-org/js-waku/issues/1586)) ([a3c45b6](https://github.com/waku-org/js-waku/commit/a3c45b6e1a9beae488cae3c71c48949fa47bcaf6))
|
23
|
+
* **static-sharding:** Filter peer connections per shards ([#1626](https://github.com/waku-org/js-waku/issues/1626)) ([124a29e](https://github.com/waku-org/js-waku/commit/124a29ebba59c05fbbf199d969e6ba3f9e57d45b))
|
24
|
+
|
25
|
+
|
26
|
+
### Bug Fixes
|
27
|
+
|
28
|
+
* Catch stream creation promise rejection for `lightPush.send` ([b696a89](https://github.com/waku-org/js-waku/commit/b696a8957211bf20577f419a207a23ceca03d23f))
|
29
|
+
* Catch top level exception when preemptively creating streams ([fb37c89](https://github.com/waku-org/js-waku/commit/fb37c89e40a9d7c98bef17a085876478486fca8b))
|
30
|
+
* **store:** Use `pubSubTopic` from `DecodedMessage` for `createCursor` ([#1640](https://github.com/waku-org/js-waku/issues/1640)) ([b10c46b](https://github.com/waku-org/js-waku/commit/b10c46b910511418a048d7092dfd8b500a71a931))
|
31
|
+
* Throw error when no response ([#1567](https://github.com/waku-org/js-waku/issues/1567)) ([d049ebb](https://github.com/waku-org/js-waku/commit/d049ebbc3417e5c20eccba3aa1b9fc5382e8d7fc))
|
32
|
+
|
33
|
+
|
34
|
+
### Dependencies
|
35
|
+
|
36
|
+
* The following workspace dependencies were updated
|
37
|
+
* dependencies
|
38
|
+
* @waku/enr bumped from ^0.0.17 to ^0.0.18
|
39
|
+
* @waku/interfaces bumped from 0.0.18 to 0.0.19
|
40
|
+
* @waku/utils bumped from 0.0.11 to 0.0.12
|
41
|
+
|
8
42
|
## [0.0.23](https://github.com/waku-org/js-waku/compare/core-v0.0.22...core-v0.0.23) (2023-09-11)
|
9
43
|
|
10
44
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
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
|
@@ -126,6 +126,25 @@ var src = base;
|
|
126
126
|
|
127
127
|
var _brrp__multiformats_scope_baseX = src;
|
128
128
|
|
129
|
+
/**
|
130
|
+
* @param {Uint8Array} aa
|
131
|
+
* @param {Uint8Array} bb
|
132
|
+
*/
|
133
|
+
const equals = (aa, bb) => {
|
134
|
+
if (aa === bb) return true
|
135
|
+
if (aa.byteLength !== bb.byteLength) {
|
136
|
+
return false
|
137
|
+
}
|
138
|
+
|
139
|
+
for (let ii = 0; ii < aa.byteLength; ii++) {
|
140
|
+
if (aa[ii] !== bb[ii]) {
|
141
|
+
return false
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
return true
|
146
|
+
};
|
147
|
+
|
129
148
|
/**
|
130
149
|
* @param {ArrayBufferView|ArrayBuffer|Uint8Array} o
|
131
150
|
* @returns {Uint8Array}
|
@@ -493,83 +512,22 @@ const rfc4648 = ({ name, prefix, bitsPerChar, alphabet }) => {
|
|
493
512
|
})
|
494
513
|
};
|
495
514
|
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
prefix: '\x00',
|
501
|
-
name: 'identity',
|
502
|
-
encode: (buf) => toString$1(buf),
|
503
|
-
decode: (str) => fromString$1(str)
|
504
|
-
});
|
505
|
-
|
506
|
-
var identityBase = /*#__PURE__*/Object.freeze({
|
507
|
-
__proto__: null,
|
508
|
-
identity: identity
|
509
|
-
});
|
510
|
-
|
511
|
-
// @ts-check
|
512
|
-
|
513
|
-
|
514
|
-
const base2 = rfc4648({
|
515
|
-
prefix: '0',
|
516
|
-
name: 'base2',
|
517
|
-
alphabet: '01',
|
518
|
-
bitsPerChar: 1
|
519
|
-
});
|
520
|
-
|
521
|
-
var base2$1 = /*#__PURE__*/Object.freeze({
|
522
|
-
__proto__: null,
|
523
|
-
base2: base2
|
524
|
-
});
|
525
|
-
|
526
|
-
// @ts-check
|
527
|
-
|
528
|
-
|
529
|
-
const base8 = rfc4648({
|
530
|
-
prefix: '7',
|
531
|
-
name: 'base8',
|
532
|
-
alphabet: '01234567',
|
533
|
-
bitsPerChar: 3
|
534
|
-
});
|
535
|
-
|
536
|
-
var base8$1 = /*#__PURE__*/Object.freeze({
|
537
|
-
__proto__: null,
|
538
|
-
base8: base8
|
539
|
-
});
|
540
|
-
|
541
|
-
const base10 = baseX({
|
542
|
-
prefix: '9',
|
543
|
-
name: 'base10',
|
544
|
-
alphabet: '0123456789'
|
545
|
-
});
|
546
|
-
|
547
|
-
var base10$1 = /*#__PURE__*/Object.freeze({
|
548
|
-
__proto__: null,
|
549
|
-
base10: base10
|
550
|
-
});
|
551
|
-
|
552
|
-
// @ts-check
|
553
|
-
|
554
|
-
|
555
|
-
const base16 = rfc4648({
|
556
|
-
prefix: 'f',
|
557
|
-
name: 'base16',
|
558
|
-
alphabet: '0123456789abcdef',
|
559
|
-
bitsPerChar: 4
|
515
|
+
const base58btc = baseX({
|
516
|
+
name: 'base58btc',
|
517
|
+
prefix: 'z',
|
518
|
+
alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
560
519
|
});
|
561
520
|
|
562
|
-
const
|
563
|
-
|
564
|
-
|
565
|
-
alphabet: '
|
566
|
-
bitsPerChar: 4
|
521
|
+
const base58flickr = baseX({
|
522
|
+
name: 'base58flickr',
|
523
|
+
prefix: 'Z',
|
524
|
+
alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
|
567
525
|
});
|
568
526
|
|
569
|
-
var
|
527
|
+
var base58 = /*#__PURE__*/Object.freeze({
|
570
528
|
__proto__: null,
|
571
|
-
|
572
|
-
|
529
|
+
base58btc: base58btc,
|
530
|
+
base58flickr: base58flickr
|
573
531
|
});
|
574
532
|
|
575
533
|
const base32 = rfc4648({
|
@@ -648,6 +606,98 @@ var base32$1 = /*#__PURE__*/Object.freeze({
|
|
648
606
|
base32z: base32z
|
649
607
|
});
|
650
608
|
|
609
|
+
const base10 = baseX({
|
610
|
+
prefix: '9',
|
611
|
+
name: 'base10',
|
612
|
+
alphabet: '0123456789'
|
613
|
+
});
|
614
|
+
|
615
|
+
var base10$1 = /*#__PURE__*/Object.freeze({
|
616
|
+
__proto__: null,
|
617
|
+
base10: base10
|
618
|
+
});
|
619
|
+
|
620
|
+
// @ts-check
|
621
|
+
|
622
|
+
|
623
|
+
const base16 = rfc4648({
|
624
|
+
prefix: 'f',
|
625
|
+
name: 'base16',
|
626
|
+
alphabet: '0123456789abcdef',
|
627
|
+
bitsPerChar: 4
|
628
|
+
});
|
629
|
+
|
630
|
+
const base16upper = rfc4648({
|
631
|
+
prefix: 'F',
|
632
|
+
name: 'base16upper',
|
633
|
+
alphabet: '0123456789ABCDEF',
|
634
|
+
bitsPerChar: 4
|
635
|
+
});
|
636
|
+
|
637
|
+
var base16$1 = /*#__PURE__*/Object.freeze({
|
638
|
+
__proto__: null,
|
639
|
+
base16: base16,
|
640
|
+
base16upper: base16upper
|
641
|
+
});
|
642
|
+
|
643
|
+
// @ts-check
|
644
|
+
|
645
|
+
|
646
|
+
const base2 = rfc4648({
|
647
|
+
prefix: '0',
|
648
|
+
name: 'base2',
|
649
|
+
alphabet: '01',
|
650
|
+
bitsPerChar: 1
|
651
|
+
});
|
652
|
+
|
653
|
+
var base2$1 = /*#__PURE__*/Object.freeze({
|
654
|
+
__proto__: null,
|
655
|
+
base2: base2
|
656
|
+
});
|
657
|
+
|
658
|
+
const alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');
|
659
|
+
const alphabetBytesToChars = /** @type {string[]} */ (alphabet.reduce((p, c, i) => { p[i] = c; return p }, /** @type {string[]} */([])));
|
660
|
+
const alphabetCharsToBytes = /** @type {number[]} */ (alphabet.reduce((p, c, i) => { p[/** @type {number} */ (c.codePointAt(0))] = i; return p }, /** @type {number[]} */([])));
|
661
|
+
|
662
|
+
/**
|
663
|
+
* @param {Uint8Array} data
|
664
|
+
* @returns {string}
|
665
|
+
*/
|
666
|
+
function encode (data) {
|
667
|
+
return data.reduce((p, c) => {
|
668
|
+
p += alphabetBytesToChars[c];
|
669
|
+
return p
|
670
|
+
}, '')
|
671
|
+
}
|
672
|
+
|
673
|
+
/**
|
674
|
+
* @param {string} str
|
675
|
+
* @returns {Uint8Array}
|
676
|
+
*/
|
677
|
+
function decode (str) {
|
678
|
+
const byts = [];
|
679
|
+
for (const char of str) {
|
680
|
+
const byt = alphabetCharsToBytes[/** @type {number} */ (char.codePointAt(0))];
|
681
|
+
if (byt === undefined) {
|
682
|
+
throw new Error(`Non-base256emoji character: ${char}`)
|
683
|
+
}
|
684
|
+
byts.push(byt);
|
685
|
+
}
|
686
|
+
return new Uint8Array(byts)
|
687
|
+
}
|
688
|
+
|
689
|
+
const base256emoji = from({
|
690
|
+
prefix: '🚀',
|
691
|
+
name: 'base256emoji',
|
692
|
+
encode,
|
693
|
+
decode
|
694
|
+
});
|
695
|
+
|
696
|
+
var base256emoji$1 = /*#__PURE__*/Object.freeze({
|
697
|
+
__proto__: null,
|
698
|
+
base256emoji: base256emoji
|
699
|
+
});
|
700
|
+
|
651
701
|
const base36 = baseX({
|
652
702
|
prefix: 'k',
|
653
703
|
name: 'base36',
|
@@ -666,24 +716,6 @@ var base36$1 = /*#__PURE__*/Object.freeze({
|
|
666
716
|
base36upper: base36upper
|
667
717
|
});
|
668
718
|
|
669
|
-
const base58btc = baseX({
|
670
|
-
name: 'base58btc',
|
671
|
-
prefix: 'z',
|
672
|
-
alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
673
|
-
});
|
674
|
-
|
675
|
-
const base58flickr = baseX({
|
676
|
-
name: 'base58flickr',
|
677
|
-
prefix: 'Z',
|
678
|
-
alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
|
679
|
-
});
|
680
|
-
|
681
|
-
var base58 = /*#__PURE__*/Object.freeze({
|
682
|
-
__proto__: null,
|
683
|
-
base58btc: base58btc,
|
684
|
-
base58flickr: base58flickr
|
685
|
-
});
|
686
|
-
|
687
719
|
// @ts-check
|
688
720
|
|
689
721
|
|
@@ -723,47 +755,34 @@ var base64$1 = /*#__PURE__*/Object.freeze({
|
|
723
755
|
base64urlpad: base64urlpad
|
724
756
|
});
|
725
757
|
|
726
|
-
|
727
|
-
const alphabetBytesToChars = /** @type {string[]} */ (alphabet.reduce((p, c, i) => { p[i] = c; return p }, /** @type {string[]} */([])));
|
728
|
-
const alphabetCharsToBytes = /** @type {number[]} */ (alphabet.reduce((p, c, i) => { p[/** @type {number} */ (c.codePointAt(0))] = i; return p }, /** @type {number[]} */([])));
|
758
|
+
// @ts-check
|
729
759
|
|
730
|
-
/**
|
731
|
-
* @param {Uint8Array} data
|
732
|
-
* @returns {string}
|
733
|
-
*/
|
734
|
-
function encode (data) {
|
735
|
-
return data.reduce((p, c) => {
|
736
|
-
p += alphabetBytesToChars[c];
|
737
|
-
return p
|
738
|
-
}, '')
|
739
|
-
}
|
740
760
|
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
for (const char of str) {
|
748
|
-
const byt = alphabetCharsToBytes[/** @type {number} */ (char.codePointAt(0))];
|
749
|
-
if (byt === undefined) {
|
750
|
-
throw new Error(`Non-base256emoji character: ${char}`)
|
751
|
-
}
|
752
|
-
byts.push(byt);
|
753
|
-
}
|
754
|
-
return new Uint8Array(byts)
|
755
|
-
}
|
761
|
+
const base8 = rfc4648({
|
762
|
+
prefix: '7',
|
763
|
+
name: 'base8',
|
764
|
+
alphabet: '01234567',
|
765
|
+
bitsPerChar: 3
|
766
|
+
});
|
756
767
|
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
encode,
|
761
|
-
decode
|
768
|
+
var base8$1 = /*#__PURE__*/Object.freeze({
|
769
|
+
__proto__: null,
|
770
|
+
base8: base8
|
762
771
|
});
|
763
772
|
|
764
|
-
|
773
|
+
// @ts-check
|
774
|
+
|
775
|
+
|
776
|
+
const identity = from({
|
777
|
+
prefix: '\x00',
|
778
|
+
name: 'identity',
|
779
|
+
encode: (buf) => toString$1(buf),
|
780
|
+
decode: (str) => fromString$1(str)
|
781
|
+
});
|
782
|
+
|
783
|
+
var identityBase = /*#__PURE__*/Object.freeze({
|
765
784
|
__proto__: null,
|
766
|
-
|
785
|
+
identity: identity
|
767
786
|
});
|
768
787
|
|
769
788
|
// @ts-check
|
@@ -906,11 +925,51 @@ var Protocols;
|
|
906
925
|
})(Protocols || (Protocols = {}));
|
907
926
|
var SendError;
|
908
927
|
(function (SendError) {
|
928
|
+
/** Could not determine the origin of the fault. Best to check connectivity and try again */
|
909
929
|
SendError["GENERIC_FAIL"] = "Generic error";
|
930
|
+
/**
|
931
|
+
* Failure to protobuf encode the message. This is not recoverable and needs
|
932
|
+
* further investigation.
|
933
|
+
*/
|
910
934
|
SendError["ENCODE_FAILED"] = "Failed to encode";
|
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
|
+
*/
|
911
939
|
SendError["DECODE_FAILED"] = "Failed to decode";
|
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.
|
947
|
+
* Compressing the message or using an alternative strategy for large messages is recommended.
|
948
|
+
*/
|
912
949
|
SendError["SIZE_TOO_BIG"] = "Size is too big";
|
913
|
-
|
950
|
+
/**
|
951
|
+
* The PubSubTopic passed to the send function is not configured on the Waku node.
|
952
|
+
* Please ensure that the PubSubTopic is used when initializing the Waku node.
|
953
|
+
*/
|
954
|
+
SendError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
955
|
+
/**
|
956
|
+
* Failure to find a peer with suitable protocols. This may due to a connection issue.
|
957
|
+
* Mitigation can be: retrying after a given time period, display connectivity issue
|
958
|
+
* to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`
|
959
|
+
* on the connection manager before retrying.
|
960
|
+
*/
|
961
|
+
SendError["NO_PEER_AVAILABLE"] = "No peer available";
|
962
|
+
/**
|
963
|
+
* The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
|
964
|
+
* or `DECODE_FAILED` can be used.
|
965
|
+
*/
|
966
|
+
SendError["REMOTE_PEER_FAULT"] = "Remote peer fault";
|
967
|
+
/**
|
968
|
+
* The remote peer rejected the message. Information provided by the remote peer
|
969
|
+
* is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
|
970
|
+
* or `DECODE_FAILED` can be used.
|
971
|
+
*/
|
972
|
+
SendError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
|
914
973
|
})(SendError || (SendError = {}));
|
915
974
|
|
916
975
|
var PageDirection;
|
@@ -954,7 +1013,6 @@ function concat(byteArrays, totalLength) {
|
|
954
1013
|
return res;
|
955
1014
|
}
|
956
1015
|
|
957
|
-
const log = debug("waku:libp2p-utils");
|
958
1016
|
/**
|
959
1017
|
* Returns a pseudo-random peer that supports the given protocol.
|
960
1018
|
* Useful for protocols such as store and light push
|
@@ -1034,7 +1092,6 @@ async function selectPeerForProtocol(peerStore, protocols, peerId) {
|
|
1034
1092
|
// Do not break as we want to keep the last value
|
1035
1093
|
}
|
1036
1094
|
}
|
1037
|
-
log(`Using codec ${protocol}`);
|
1038
1095
|
if (!protocol) {
|
1039
1096
|
throw new Error(`Peer does not register required protocols (${peer.id.toString()}): ${protocols}`);
|
1040
1097
|
}
|
@@ -1099,7 +1156,7 @@ class StreamManager {
|
|
1099
1156
|
this.multicodec = multicodec;
|
1100
1157
|
this.getConnections = getConnections;
|
1101
1158
|
this.addEventListener = addEventListener;
|
1102
|
-
this.log =
|
1159
|
+
this.log = new Logger(`stream-manager:${multicodec}`);
|
1103
1160
|
this.addEventListener("peer:update", this.handlePeerUpdateStreamPool.bind(this));
|
1104
1161
|
this.getStream = this.getStream.bind(this);
|
1105
1162
|
this.streamPool = new Map();
|
@@ -1114,7 +1171,7 @@ class StreamManager {
|
|
1114
1171
|
this.streamPool.delete(peerIdStr);
|
1115
1172
|
this.prepareNewStream(peer);
|
1116
1173
|
const stream = await streamPromise;
|
1117
|
-
if (stream.status === "closed") {
|
1174
|
+
if (!stream || stream.status === "closed") {
|
1118
1175
|
return this.newStream(peer); // fallback by creating a new stream on the spot
|
1119
1176
|
}
|
1120
1177
|
return stream;
|
@@ -1128,13 +1185,16 @@ class StreamManager {
|
|
1128
1185
|
return connection.newStream(this.multicodec);
|
1129
1186
|
}
|
1130
1187
|
prepareNewStream(peer) {
|
1131
|
-
const streamPromise = this.newStream(peer)
|
1188
|
+
const streamPromise = this.newStream(peer).catch(() => {
|
1189
|
+
// No error thrown as this call is not triggered by the user
|
1190
|
+
this.log.error(`Failed to prepare a new stream for ${peer.id.toString()}`);
|
1191
|
+
});
|
1132
1192
|
this.streamPool.set(peer.id.toString(), streamPromise);
|
1133
1193
|
}
|
1134
1194
|
handlePeerUpdateStreamPool = (evt) => {
|
1135
1195
|
const peer = evt.detail.peer;
|
1136
1196
|
if (peer.protocols.includes(this.multicodec)) {
|
1137
|
-
this.log(`Preemptively opening a stream to ${peer.id.toString()}`);
|
1197
|
+
this.log.info(`Preemptively opening a stream to ${peer.id.toString()}`);
|
1138
1198
|
this.prepareNewStream(peer);
|
1139
1199
|
}
|
1140
1200
|
};
|
@@ -1195,4 +1255,4 @@ class BaseProtocol {
|
|
1195
1255
|
}
|
1196
1256
|
}
|
1197
1257
|
|
1198
|
-
export { BaseProtocol as B, EPeersByDiscoveryEvents as E, Protocols as P, SendError as S, Tags as T,
|
1258
|
+
export { BaseProtocol as B, EPeersByDiscoveryEvents as E, Protocols as P, SendError as S, Tags as T, base58btc as a, base32 as b, coerce as c, allocUnsafe as d, equals as e, asUint8Array as f, bases as g, fromString as h, alloc as i, concat as j, StreamManager as k, toString as t, utf8ToBytes as u };
|
@@ -4,6 +4,31 @@ function getDefaultExportFromCjs (x) {
|
|
4
4
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
5
5
|
}
|
6
6
|
|
7
|
+
function getAugmentedNamespace(n) {
|
8
|
+
if (n.__esModule) return n;
|
9
|
+
var f = n.default;
|
10
|
+
if (typeof f == "function") {
|
11
|
+
var a = function a () {
|
12
|
+
if (this instanceof a) {
|
13
|
+
return Reflect.construct(f, arguments, this.constructor);
|
14
|
+
}
|
15
|
+
return f.apply(this, arguments);
|
16
|
+
};
|
17
|
+
a.prototype = f.prototype;
|
18
|
+
} else a = {};
|
19
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
20
|
+
Object.keys(n).forEach(function (k) {
|
21
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
22
|
+
Object.defineProperty(a, k, d.get ? d : {
|
23
|
+
enumerable: true,
|
24
|
+
get: function () {
|
25
|
+
return n[k];
|
26
|
+
}
|
27
|
+
});
|
28
|
+
});
|
29
|
+
return a;
|
30
|
+
}
|
31
|
+
|
7
32
|
var browser = {exports: {}};
|
8
33
|
|
9
34
|
/**
|
@@ -726,4 +751,4 @@ var common = setup;
|
|
726
751
|
var browserExports = browser.exports;
|
727
752
|
var debug = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
728
753
|
|
729
|
-
export { commonjsGlobal as c, debug as d,
|
754
|
+
export { getDefaultExportFromCjs as a, commonjsGlobal as c, debug as d, getAugmentedNamespace as g };
|
@@ -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 };
|