@waku/core 0.0.38 → 0.0.39-8866516.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/bundle/index.js +411 -167
- package/bundle/lib/message/version_0.js +1 -1
- package/bundle/{version_0-CGLjyYN6.js → version_0-C6zxTApZ.js} +3 -3
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/filter/filter.d.ts +6 -6
- package/dist/lib/filter/filter.js +14 -14
- package/dist/lib/filter/filter.js.map +1 -1
- package/dist/lib/light_push/index.d.ts +1 -1
- package/dist/lib/light_push/index.js +1 -1
- package/dist/lib/light_push/index.js.map +1 -1
- package/dist/lib/light_push/light_push.d.ts +7 -5
- package/dist/lib/light_push/light_push.js +36 -78
- package/dist/lib/light_push/light_push.js.map +1 -1
- package/dist/lib/light_push/protocol_handler.d.ts +27 -0
- package/dist/lib/light_push/protocol_handler.js +145 -0
- package/dist/lib/light_push/protocol_handler.js.map +1 -0
- package/dist/lib/light_push/push_rpc.d.ts +3 -3
- package/dist/lib/light_push/push_rpc.js +3 -3
- package/dist/lib/light_push/push_rpc.js.map +1 -1
- package/dist/lib/light_push/push_rpc_v3.d.ts +73 -0
- package/dist/lib/light_push/push_rpc_v3.js +136 -0
- package/dist/lib/light_push/push_rpc_v3.js.map +1 -0
- package/dist/lib/metadata/metadata.js +1 -1
- package/dist/lib/metadata/metadata.js.map +1 -1
- package/dist/lib/store/store.d.ts +1 -1
- package/dist/lib/store/store.js +1 -1
- package/dist/lib/store/store.js.map +1 -1
- package/package.json +1 -125
- package/src/index.ts +5 -1
- package/src/lib/filter/filter.ts +19 -19
- package/src/lib/light_push/index.ts +5 -1
- package/src/lib/light_push/light_push.ts +50 -105
- package/src/lib/light_push/protocol_handler.ts +192 -0
- package/src/lib/light_push/push_rpc.ts +5 -5
- package/src/lib/light_push/push_rpc_v3.ts +162 -0
- package/src/lib/metadata/metadata.ts +1 -1
- package/src/lib/store/store.ts +1 -1
package/bundle/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { e as equals$2, c as coerce, b as base32, a as base58btc, d as base36, B as BASES, f as fromString, v as version_0, g as allocUnsafe, h as alloc, i as encodingLength$1, j as encode$3, k as decode$4, L as Logger, F as FilterSubscribeRequest, l as FilterSubscribeResponse$1, M as MessagePush, P as PushRpc$1, m as
|
|
2
|
-
export {
|
|
1
|
+
import { e as equals$2, c as coerce, b as base32, a as base58btc, d as base36, B as BASES, f as fromString, v as version_0, g as allocUnsafe, h as alloc, i as encodingLength$1, j as encode$3, k as decode$4, L as Logger, F as FilterSubscribeRequest, l as FilterSubscribeResponse$1, M as MessagePush, P as PushRpc$1, m as LightPushRequestV3, n as LightPushResponseV3, S as StoreQueryRequest$1, o as StoreQueryResponse$1, p as createEncoder, q as enumeration, r as message, s as encodeMessage, t as decodeMessage, u as bases, w as base64url, x as encodeUint8Array, W as WakuMetadataRequest, y as WakuMetadataResponse } from './version_0-C6zxTApZ.js';
|
|
2
|
+
export { z as createDecoder } from './version_0-C6zxTApZ.js';
|
|
3
3
|
|
|
4
4
|
/* eslint-disable */
|
|
5
5
|
var encode_1 = encode$2;
|
|
@@ -1540,6 +1540,32 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
1540
1540
|
version_0: version_0
|
|
1541
1541
|
});
|
|
1542
1542
|
|
|
1543
|
+
var LightPushStatusCode;
|
|
1544
|
+
(function (LightPushStatusCode) {
|
|
1545
|
+
LightPushStatusCode[LightPushStatusCode["SUCCESS"] = 200] = "SUCCESS";
|
|
1546
|
+
LightPushStatusCode[LightPushStatusCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
1547
|
+
LightPushStatusCode[LightPushStatusCode["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
1548
|
+
LightPushStatusCode[LightPushStatusCode["INVALID_MESSAGE"] = 420] = "INVALID_MESSAGE";
|
|
1549
|
+
LightPushStatusCode[LightPushStatusCode["UNSUPPORTED_TOPIC"] = 421] = "UNSUPPORTED_TOPIC";
|
|
1550
|
+
LightPushStatusCode[LightPushStatusCode["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
1551
|
+
LightPushStatusCode[LightPushStatusCode["INTERNAL_ERROR"] = 500] = "INTERNAL_ERROR";
|
|
1552
|
+
LightPushStatusCode[LightPushStatusCode["UNAVAILABLE"] = 503] = "UNAVAILABLE";
|
|
1553
|
+
LightPushStatusCode[LightPushStatusCode["NO_RLN_PROOF"] = 504] = "NO_RLN_PROOF";
|
|
1554
|
+
LightPushStatusCode[LightPushStatusCode["NO_PEERS"] = 505] = "NO_PEERS";
|
|
1555
|
+
})(LightPushStatusCode || (LightPushStatusCode = {}));
|
|
1556
|
+
({
|
|
1557
|
+
[LightPushStatusCode.SUCCESS]: "Message sent successfully",
|
|
1558
|
+
[LightPushStatusCode.BAD_REQUEST]: "Bad request format",
|
|
1559
|
+
[LightPushStatusCode.PAYLOAD_TOO_LARGE]: "Message payload exceeds maximum size",
|
|
1560
|
+
[LightPushStatusCode.INVALID_MESSAGE]: "Message validation failed",
|
|
1561
|
+
[LightPushStatusCode.UNSUPPORTED_TOPIC]: "Unsupported pubsub topic",
|
|
1562
|
+
[LightPushStatusCode.TOO_MANY_REQUESTS]: "Rate limit exceeded",
|
|
1563
|
+
[LightPushStatusCode.INTERNAL_ERROR]: "Internal server error",
|
|
1564
|
+
[LightPushStatusCode.UNAVAILABLE]: "Service temporarily unavailable",
|
|
1565
|
+
[LightPushStatusCode.NO_RLN_PROOF]: "RLN proof generation failed",
|
|
1566
|
+
[LightPushStatusCode.NO_PEERS]: "No relay peers available"
|
|
1567
|
+
});
|
|
1568
|
+
|
|
1543
1569
|
var Protocols;
|
|
1544
1570
|
(function (Protocols) {
|
|
1545
1571
|
Protocols["Relay"] = "relay";
|
|
@@ -1547,87 +1573,71 @@ var Protocols;
|
|
|
1547
1573
|
Protocols["LightPush"] = "lightpush";
|
|
1548
1574
|
Protocols["Filter"] = "filter";
|
|
1549
1575
|
})(Protocols || (Protocols = {}));
|
|
1576
|
+
var LightPushError;
|
|
1577
|
+
(function (LightPushError) {
|
|
1578
|
+
LightPushError["GENERIC_FAIL"] = "Generic error";
|
|
1579
|
+
LightPushError["DECODE_FAILED"] = "Failed to decode";
|
|
1580
|
+
LightPushError["NO_PEER_AVAILABLE"] = "No peer available";
|
|
1581
|
+
LightPushError["NO_STREAM_AVAILABLE"] = "No stream available";
|
|
1582
|
+
LightPushError["NO_RESPONSE"] = "No response received";
|
|
1583
|
+
LightPushError["STREAM_ABORTED"] = "Stream aborted";
|
|
1584
|
+
LightPushError["ENCODE_FAILED"] = "Failed to encode";
|
|
1585
|
+
LightPushError["EMPTY_PAYLOAD"] = "Payload is empty";
|
|
1586
|
+
LightPushError["SIZE_TOO_BIG"] = "Size is too big";
|
|
1587
|
+
LightPushError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
|
1588
|
+
LightPushError["RLN_PROOF_GENERATION"] = "Proof generation failed";
|
|
1589
|
+
LightPushError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
|
|
1590
|
+
LightPushError["BAD_REQUEST"] = "Bad request format";
|
|
1591
|
+
LightPushError["PAYLOAD_TOO_LARGE"] = "Message payload exceeds maximum size";
|
|
1592
|
+
LightPushError["INVALID_MESSAGE"] = "Message validation failed";
|
|
1593
|
+
LightPushError["UNSUPPORTED_TOPIC"] = "Unsupported pubsub topic";
|
|
1594
|
+
LightPushError["TOO_MANY_REQUESTS"] = "Rate limit exceeded";
|
|
1595
|
+
LightPushError["INTERNAL_ERROR"] = "Internal server error";
|
|
1596
|
+
LightPushError["UNAVAILABLE"] = "Service temporarily unavailable";
|
|
1597
|
+
LightPushError["NO_RLN_PROOF"] = "RLN proof generation failed";
|
|
1598
|
+
LightPushError["NO_PEERS"] = "No relay peers available";
|
|
1599
|
+
})(LightPushError || (LightPushError = {}));
|
|
1600
|
+
var FilterError;
|
|
1601
|
+
(function (FilterError) {
|
|
1602
|
+
// General errors
|
|
1603
|
+
FilterError["GENERIC_FAIL"] = "Generic error";
|
|
1604
|
+
FilterError["DECODE_FAILED"] = "Failed to decode";
|
|
1605
|
+
FilterError["NO_PEER_AVAILABLE"] = "No peer available";
|
|
1606
|
+
FilterError["NO_STREAM_AVAILABLE"] = "No stream available";
|
|
1607
|
+
FilterError["NO_RESPONSE"] = "No response received";
|
|
1608
|
+
FilterError["STREAM_ABORTED"] = "Stream aborted";
|
|
1609
|
+
// Filter specific errors
|
|
1610
|
+
FilterError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
|
|
1611
|
+
FilterError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
|
1612
|
+
FilterError["SUBSCRIPTION_FAILED"] = "Subscription failed";
|
|
1613
|
+
FilterError["UNSUBSCRIBE_FAILED"] = "Unsubscribe failed";
|
|
1614
|
+
FilterError["PING_FAILED"] = "Ping failed";
|
|
1615
|
+
FilterError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
|
|
1616
|
+
FilterError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
|
|
1617
|
+
FilterError["SUBSCRIPTION_LIMIT_EXCEEDED"] = "Subscription limit exceeded";
|
|
1618
|
+
FilterError["INVALID_CONTENT_TOPIC"] = "Invalid content topic";
|
|
1619
|
+
FilterError["PUSH_MESSAGE_FAILED"] = "Push message failed";
|
|
1620
|
+
FilterError["EMPTY_MESSAGE"] = "Empty message received";
|
|
1621
|
+
FilterError["MISSING_PUBSUB_TOPIC"] = "Pubsub topic missing from push message";
|
|
1622
|
+
})(FilterError || (FilterError = {}));
|
|
1623
|
+
/**
|
|
1624
|
+
* @deprecated Use LightPushError or FilterError instead
|
|
1625
|
+
*/
|
|
1550
1626
|
var ProtocolError;
|
|
1551
1627
|
(function (ProtocolError) {
|
|
1552
|
-
//
|
|
1553
|
-
// GENERAL ERRORS SECTION
|
|
1554
|
-
//
|
|
1555
|
-
/**
|
|
1556
|
-
* Could not determine the origin of the fault. Best to check connectivity and try again
|
|
1557
|
-
* */
|
|
1558
1628
|
ProtocolError["GENERIC_FAIL"] = "Generic error";
|
|
1559
|
-
/**
|
|
1560
|
-
* The remote peer rejected the message. Information provided by the remote peer
|
|
1561
|
-
* is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
|
|
1562
|
-
* or `DECODE_FAILED` can be used.
|
|
1563
|
-
*/
|
|
1564
1629
|
ProtocolError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
|
|
1565
|
-
/**
|
|
1566
|
-
* Failure to protobuf decode the message. May be due to a remote peer issue,
|
|
1567
|
-
* ensuring that messages are sent via several peer enable mitigation of this error.
|
|
1568
|
-
*/
|
|
1569
1630
|
ProtocolError["DECODE_FAILED"] = "Failed to decode";
|
|
1570
|
-
/**
|
|
1571
|
-
* Failure to find a peer with suitable protocols. This may due to a connection issue.
|
|
1572
|
-
* Mitigation can be: retrying after a given time period, display connectivity issue
|
|
1573
|
-
* to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`
|
|
1574
|
-
* on the connection manager before retrying.
|
|
1575
|
-
*/
|
|
1576
1631
|
ProtocolError["NO_PEER_AVAILABLE"] = "No peer available";
|
|
1577
|
-
/**
|
|
1578
|
-
* Failure to find a stream to the peer. This may be because the connection with the peer is not still alive.
|
|
1579
|
-
* Mitigation can be: retrying after a given time period, or mitigation for `NO_PEER_AVAILABLE` can be used.
|
|
1580
|
-
*/
|
|
1581
1632
|
ProtocolError["NO_STREAM_AVAILABLE"] = "No stream available";
|
|
1582
|
-
/**
|
|
1583
|
-
* The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
|
|
1584
|
-
* or `DECODE_FAILED` can be used.
|
|
1585
|
-
*/
|
|
1586
1633
|
ProtocolError["NO_RESPONSE"] = "No response received";
|
|
1587
|
-
//
|
|
1588
|
-
// SEND ERRORS SECTION
|
|
1589
|
-
//
|
|
1590
|
-
/**
|
|
1591
|
-
* Failure to protobuf encode the message. This is not recoverable and needs
|
|
1592
|
-
* further investigation.
|
|
1593
|
-
*/
|
|
1594
1634
|
ProtocolError["ENCODE_FAILED"] = "Failed to encode";
|
|
1595
|
-
/**
|
|
1596
|
-
* The message payload is empty, making the message invalid. Ensure that a non-empty
|
|
1597
|
-
* payload is set on the outgoing message.
|
|
1598
|
-
*/
|
|
1599
1635
|
ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
|
|
1600
|
-
/**
|
|
1601
|
-
* The message size is above the maximum message size allowed on the Waku Network.
|
|
1602
|
-
* Compressing the message or using an alternative strategy for large messages is recommended.
|
|
1603
|
-
*/
|
|
1604
1636
|
ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
|
|
1605
|
-
/**
|
|
1606
|
-
* The PubsubTopic passed to the send function is not configured on the Waku node.
|
|
1607
|
-
* Please ensure that the PubsubTopic is used when initializing the Waku node.
|
|
1608
|
-
*/
|
|
1609
1637
|
ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
|
1610
|
-
/**
|
|
1611
|
-
* Fails when
|
|
1612
|
-
*/
|
|
1613
1638
|
ProtocolError["STREAM_ABORTED"] = "Stream aborted";
|
|
1614
|
-
/**
|
|
1615
|
-
* General proof generation error message.
|
|
1616
|
-
* nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
|
|
1617
|
-
*/
|
|
1618
1639
|
ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
|
|
1619
|
-
//
|
|
1620
|
-
// RECEIVE ERRORS SECTION
|
|
1621
|
-
//
|
|
1622
|
-
/**
|
|
1623
|
-
* The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
|
|
1624
|
-
* Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
|
|
1625
|
-
*/
|
|
1626
1640
|
ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
|
|
1627
|
-
/**
|
|
1628
|
-
* The topics passed in the decoders do not match each other, or don't exist at all.
|
|
1629
|
-
* Ensure that all the pubsub topics used in the decoders are valid and match each other.
|
|
1630
|
-
*/
|
|
1631
1641
|
ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
|
|
1632
1642
|
})(ProtocolError || (ProtocolError = {}));
|
|
1633
1643
|
|
|
@@ -3505,7 +3515,7 @@ class FilterSubscribeResponse {
|
|
|
3505
3515
|
}
|
|
3506
3516
|
}
|
|
3507
3517
|
|
|
3508
|
-
const log$
|
|
3518
|
+
const log$a = new Logger("filter-core");
|
|
3509
3519
|
const FilterCodecs = {
|
|
3510
3520
|
SUBSCRIBE: "/vac/waku/filter-subscribe/2.0.0-beta1",
|
|
3511
3521
|
PUSH: "/vac/waku/filter-push/2.0.0-beta1"
|
|
@@ -3513,7 +3523,7 @@ const FilterCodecs = {
|
|
|
3513
3523
|
class FilterCore {
|
|
3514
3524
|
handleIncomingMessage;
|
|
3515
3525
|
streamManager;
|
|
3516
|
-
multicodec = FilterCodecs.SUBSCRIBE;
|
|
3526
|
+
multicodec = [FilterCodecs.SUBSCRIBE];
|
|
3517
3527
|
constructor(handleIncomingMessage, libp2p) {
|
|
3518
3528
|
this.handleIncomingMessage = handleIncomingMessage;
|
|
3519
3529
|
this.streamManager = new StreamManager(FilterCodecs.SUBSCRIBE, libp2p.components);
|
|
@@ -3522,7 +3532,7 @@ class FilterCore {
|
|
|
3522
3532
|
maxInboundStreams: 100
|
|
3523
3533
|
})
|
|
3524
3534
|
.catch((e) => {
|
|
3525
|
-
log$
|
|
3535
|
+
log$a.error("Failed to register ", FilterCodecs.PUSH, e);
|
|
3526
3536
|
});
|
|
3527
3537
|
}
|
|
3528
3538
|
async subscribe(pubsubTopic, peerId, contentTopics) {
|
|
@@ -3531,7 +3541,7 @@ class FilterCore {
|
|
|
3531
3541
|
return {
|
|
3532
3542
|
success: null,
|
|
3533
3543
|
failure: {
|
|
3534
|
-
error:
|
|
3544
|
+
error: FilterError.NO_STREAM_AVAILABLE,
|
|
3535
3545
|
peerId: peerId
|
|
3536
3546
|
}
|
|
3537
3547
|
};
|
|
@@ -3545,21 +3555,21 @@ class FilterCore {
|
|
|
3545
3555
|
}
|
|
3546
3556
|
}
|
|
3547
3557
|
catch (error) {
|
|
3548
|
-
log$
|
|
3558
|
+
log$a.error("Failed to send subscribe request", error);
|
|
3549
3559
|
return {
|
|
3550
3560
|
success: null,
|
|
3551
3561
|
failure: {
|
|
3552
|
-
error:
|
|
3562
|
+
error: FilterError.GENERIC_FAIL,
|
|
3553
3563
|
peerId: peerId
|
|
3554
3564
|
}
|
|
3555
3565
|
};
|
|
3556
3566
|
}
|
|
3557
3567
|
const { statusCode, requestId, statusDesc } = FilterSubscribeResponse.decode(res[0].slice());
|
|
3558
3568
|
if (statusCode < 200 || statusCode >= 300) {
|
|
3559
|
-
log$
|
|
3569
|
+
log$a.error(`Filter subscribe request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);
|
|
3560
3570
|
return {
|
|
3561
3571
|
failure: {
|
|
3562
|
-
error:
|
|
3572
|
+
error: FilterError.REMOTE_PEER_REJECTED,
|
|
3563
3573
|
peerId: peerId
|
|
3564
3574
|
},
|
|
3565
3575
|
success: null
|
|
@@ -3573,11 +3583,11 @@ class FilterCore {
|
|
|
3573
3583
|
async unsubscribe(pubsubTopic, peerId, contentTopics) {
|
|
3574
3584
|
const stream = await this.streamManager.getStream(peerId);
|
|
3575
3585
|
if (!stream) {
|
|
3576
|
-
log$
|
|
3586
|
+
log$a.error(`Failed to get a stream for remote peer:${peerId.toString()}`);
|
|
3577
3587
|
return {
|
|
3578
3588
|
success: null,
|
|
3579
3589
|
failure: {
|
|
3580
|
-
error:
|
|
3590
|
+
error: FilterError.NO_STREAM_AVAILABLE,
|
|
3581
3591
|
peerId: peerId
|
|
3582
3592
|
}
|
|
3583
3593
|
};
|
|
@@ -3587,11 +3597,11 @@ class FilterCore {
|
|
|
3587
3597
|
await pipe([unsubscribeRequest.encode()], encode, stream.sink);
|
|
3588
3598
|
}
|
|
3589
3599
|
catch (error) {
|
|
3590
|
-
log$
|
|
3600
|
+
log$a.error("Failed to send unsubscribe request", error);
|
|
3591
3601
|
return {
|
|
3592
3602
|
success: null,
|
|
3593
3603
|
failure: {
|
|
3594
|
-
error:
|
|
3604
|
+
error: FilterError.GENERIC_FAIL,
|
|
3595
3605
|
peerId: peerId
|
|
3596
3606
|
}
|
|
3597
3607
|
};
|
|
@@ -3604,11 +3614,11 @@ class FilterCore {
|
|
|
3604
3614
|
async unsubscribeAll(pubsubTopic, peerId) {
|
|
3605
3615
|
const stream = await this.streamManager.getStream(peerId);
|
|
3606
3616
|
if (!stream) {
|
|
3607
|
-
log$
|
|
3617
|
+
log$a.error(`Failed to get a stream for remote peer:${peerId.toString()}`);
|
|
3608
3618
|
return {
|
|
3609
3619
|
success: null,
|
|
3610
3620
|
failure: {
|
|
3611
|
-
error:
|
|
3621
|
+
error: FilterError.NO_STREAM_AVAILABLE,
|
|
3612
3622
|
peerId: peerId
|
|
3613
3623
|
}
|
|
3614
3624
|
};
|
|
@@ -3618,7 +3628,7 @@ class FilterCore {
|
|
|
3618
3628
|
if (!res || !res.length) {
|
|
3619
3629
|
return {
|
|
3620
3630
|
failure: {
|
|
3621
|
-
error:
|
|
3631
|
+
error: FilterError.NO_RESPONSE,
|
|
3622
3632
|
peerId: peerId
|
|
3623
3633
|
},
|
|
3624
3634
|
success: null
|
|
@@ -3626,10 +3636,10 @@ class FilterCore {
|
|
|
3626
3636
|
}
|
|
3627
3637
|
const { statusCode, requestId, statusDesc } = FilterSubscribeResponse.decode(res[0].slice());
|
|
3628
3638
|
if (statusCode < 200 || statusCode >= 300) {
|
|
3629
|
-
log$
|
|
3639
|
+
log$a.error(`Filter unsubscribe all request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);
|
|
3630
3640
|
return {
|
|
3631
3641
|
failure: {
|
|
3632
|
-
error:
|
|
3642
|
+
error: FilterError.REMOTE_PEER_REJECTED,
|
|
3633
3643
|
peerId: peerId
|
|
3634
3644
|
},
|
|
3635
3645
|
success: null
|
|
@@ -3643,11 +3653,11 @@ class FilterCore {
|
|
|
3643
3653
|
async ping(peerId) {
|
|
3644
3654
|
const stream = await this.streamManager.getStream(peerId);
|
|
3645
3655
|
if (!stream) {
|
|
3646
|
-
log$
|
|
3656
|
+
log$a.error(`Failed to get a stream for remote peer:${peerId.toString()}`);
|
|
3647
3657
|
return {
|
|
3648
3658
|
success: null,
|
|
3649
3659
|
failure: {
|
|
3650
|
-
error:
|
|
3660
|
+
error: FilterError.NO_STREAM_AVAILABLE,
|
|
3651
3661
|
peerId: peerId
|
|
3652
3662
|
}
|
|
3653
3663
|
};
|
|
@@ -3658,11 +3668,11 @@ class FilterCore {
|
|
|
3658
3668
|
res = await pipe([request.encode()], encode, stream, decode, async (source) => await all(source));
|
|
3659
3669
|
}
|
|
3660
3670
|
catch (error) {
|
|
3661
|
-
log$
|
|
3671
|
+
log$a.error("Failed to send ping request", error);
|
|
3662
3672
|
return {
|
|
3663
3673
|
success: null,
|
|
3664
3674
|
failure: {
|
|
3665
|
-
error:
|
|
3675
|
+
error: FilterError.GENERIC_FAIL,
|
|
3666
3676
|
peerId: peerId
|
|
3667
3677
|
}
|
|
3668
3678
|
};
|
|
@@ -3671,18 +3681,18 @@ class FilterCore {
|
|
|
3671
3681
|
return {
|
|
3672
3682
|
success: null,
|
|
3673
3683
|
failure: {
|
|
3674
|
-
error:
|
|
3684
|
+
error: FilterError.NO_RESPONSE,
|
|
3675
3685
|
peerId: peerId
|
|
3676
3686
|
}
|
|
3677
3687
|
};
|
|
3678
3688
|
}
|
|
3679
3689
|
const { statusCode, requestId, statusDesc } = FilterSubscribeResponse.decode(res[0].slice());
|
|
3680
3690
|
if (statusCode < 200 || statusCode >= 300) {
|
|
3681
|
-
log$
|
|
3691
|
+
log$a.error(`Filter ping request ${requestId} failed with status code ${statusCode}: ${statusDesc}`);
|
|
3682
3692
|
return {
|
|
3683
3693
|
success: null,
|
|
3684
3694
|
failure: {
|
|
3685
|
-
error:
|
|
3695
|
+
error: FilterError.REMOTE_PEER_REJECTED,
|
|
3686
3696
|
peerId: peerId
|
|
3687
3697
|
}
|
|
3688
3698
|
};
|
|
@@ -3695,30 +3705,30 @@ class FilterCore {
|
|
|
3695
3705
|
onRequest(streamData) {
|
|
3696
3706
|
const { connection, stream } = streamData;
|
|
3697
3707
|
const { remotePeer } = connection;
|
|
3698
|
-
log$
|
|
3708
|
+
log$a.info(`Received message from ${remotePeer.toString()}`);
|
|
3699
3709
|
try {
|
|
3700
3710
|
pipe(stream, decode, async (source) => {
|
|
3701
3711
|
for await (const bytes of source) {
|
|
3702
3712
|
const response = FilterPushRpc.decode(bytes.slice());
|
|
3703
3713
|
const { pubsubTopic, wakuMessage } = response;
|
|
3704
3714
|
if (!wakuMessage) {
|
|
3705
|
-
log$
|
|
3715
|
+
log$a.error("Received empty message");
|
|
3706
3716
|
return;
|
|
3707
3717
|
}
|
|
3708
3718
|
if (!pubsubTopic) {
|
|
3709
|
-
log$
|
|
3719
|
+
log$a.error("Pubsub topic missing from push message");
|
|
3710
3720
|
return;
|
|
3711
3721
|
}
|
|
3712
3722
|
await this.handleIncomingMessage(pubsubTopic, wakuMessage, connection.remotePeer.toString());
|
|
3713
3723
|
}
|
|
3714
3724
|
}).then(() => {
|
|
3715
|
-
log$
|
|
3725
|
+
log$a.info("Receiving pipe closed.");
|
|
3716
3726
|
}, async (e) => {
|
|
3717
|
-
log$
|
|
3727
|
+
log$a.error(`Error with receiving pipe on peer:${connection.remotePeer.toString()} -- stream:${stream.id} -- protocol:${stream.protocol}: `, e);
|
|
3718
3728
|
});
|
|
3719
3729
|
}
|
|
3720
3730
|
catch (e) {
|
|
3721
|
-
log$
|
|
3731
|
+
log$a.error("Error decoding message", e);
|
|
3722
3732
|
}
|
|
3723
3733
|
}
|
|
3724
3734
|
}
|
|
@@ -3729,13 +3739,13 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
3729
3739
|
FilterCore: FilterCore
|
|
3730
3740
|
});
|
|
3731
3741
|
|
|
3732
|
-
class
|
|
3742
|
+
class PushRpcV2 {
|
|
3733
3743
|
proto;
|
|
3734
3744
|
constructor(proto) {
|
|
3735
3745
|
this.proto = proto;
|
|
3736
3746
|
}
|
|
3737
3747
|
static createRequest(message, pubsubTopic) {
|
|
3738
|
-
return new
|
|
3748
|
+
return new PushRpcV2({
|
|
3739
3749
|
requestId: v4(),
|
|
3740
3750
|
request: {
|
|
3741
3751
|
message: message,
|
|
@@ -3746,7 +3756,7 @@ class PushRpc {
|
|
|
3746
3756
|
}
|
|
3747
3757
|
static decode(bytes) {
|
|
3748
3758
|
const res = PushRpc$1.decode(bytes);
|
|
3749
|
-
return new
|
|
3759
|
+
return new PushRpcV2(res);
|
|
3750
3760
|
}
|
|
3751
3761
|
encode() {
|
|
3752
3762
|
return PushRpc$1.encode(this.proto);
|
|
@@ -3759,6 +3769,140 @@ class PushRpc {
|
|
|
3759
3769
|
}
|
|
3760
3770
|
}
|
|
3761
3771
|
|
|
3772
|
+
/**
|
|
3773
|
+
* LightPush v3 protocol RPC handler.
|
|
3774
|
+
* Implements the v3 message format with correct field numbers:
|
|
3775
|
+
* - requestId: 1
|
|
3776
|
+
* - pubsubTopic: 20
|
|
3777
|
+
* - message: 21
|
|
3778
|
+
*/
|
|
3779
|
+
class PushRpc {
|
|
3780
|
+
proto;
|
|
3781
|
+
constructor(proto) {
|
|
3782
|
+
this.proto = proto;
|
|
3783
|
+
}
|
|
3784
|
+
/**
|
|
3785
|
+
* Create a v3 request message with proper field numbering
|
|
3786
|
+
*/
|
|
3787
|
+
static createRequest(message, pubsubTopic) {
|
|
3788
|
+
return new PushRpc({
|
|
3789
|
+
requestId: v4(),
|
|
3790
|
+
pubsubTopic: pubsubTopic,
|
|
3791
|
+
message: message
|
|
3792
|
+
});
|
|
3793
|
+
}
|
|
3794
|
+
/**
|
|
3795
|
+
* Create a v3 response message with status code handling
|
|
3796
|
+
*/
|
|
3797
|
+
static createResponse(requestId, statusCode, statusDesc, relayPeerCount) {
|
|
3798
|
+
return new PushRpc({
|
|
3799
|
+
requestId,
|
|
3800
|
+
statusCode,
|
|
3801
|
+
statusDesc,
|
|
3802
|
+
relayPeerCount
|
|
3803
|
+
});
|
|
3804
|
+
}
|
|
3805
|
+
/**
|
|
3806
|
+
* Decode v3 request message
|
|
3807
|
+
*/
|
|
3808
|
+
static decodeRequest(bytes) {
|
|
3809
|
+
const res = LightPushRequestV3.decode(bytes);
|
|
3810
|
+
return new PushRpc(res);
|
|
3811
|
+
}
|
|
3812
|
+
/**
|
|
3813
|
+
* Decode v3 response message
|
|
3814
|
+
*/
|
|
3815
|
+
static decodeResponse(bytes) {
|
|
3816
|
+
const res = LightPushResponseV3.decode(bytes);
|
|
3817
|
+
return new PushRpc(res);
|
|
3818
|
+
}
|
|
3819
|
+
/**
|
|
3820
|
+
* Encode message to bytes
|
|
3821
|
+
*/
|
|
3822
|
+
encode() {
|
|
3823
|
+
if (this.isRequest()) {
|
|
3824
|
+
return LightPushRequestV3.encode(this.proto);
|
|
3825
|
+
}
|
|
3826
|
+
else {
|
|
3827
|
+
return LightPushResponseV3.encode(this.proto);
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
/**
|
|
3831
|
+
* Get request data (if this is a request message)
|
|
3832
|
+
*/
|
|
3833
|
+
get request() {
|
|
3834
|
+
return this.isRequest()
|
|
3835
|
+
? this.proto
|
|
3836
|
+
: undefined;
|
|
3837
|
+
}
|
|
3838
|
+
/**
|
|
3839
|
+
* Get response data (if this is a response message)
|
|
3840
|
+
*/
|
|
3841
|
+
get response() {
|
|
3842
|
+
return this.isResponse()
|
|
3843
|
+
? this.proto
|
|
3844
|
+
: undefined;
|
|
3845
|
+
}
|
|
3846
|
+
/**
|
|
3847
|
+
* Get the request ID
|
|
3848
|
+
*/
|
|
3849
|
+
get requestId() {
|
|
3850
|
+
return this.proto.requestId;
|
|
3851
|
+
}
|
|
3852
|
+
/**
|
|
3853
|
+
* Get the pubsub topic (only available in requests)
|
|
3854
|
+
*/
|
|
3855
|
+
get pubsubTopic() {
|
|
3856
|
+
return this.isRequest()
|
|
3857
|
+
? this.proto.pubsubTopic
|
|
3858
|
+
: undefined;
|
|
3859
|
+
}
|
|
3860
|
+
/**
|
|
3861
|
+
* Get the message (only available in requests)
|
|
3862
|
+
*/
|
|
3863
|
+
get message() {
|
|
3864
|
+
return this.isRequest()
|
|
3865
|
+
? this.proto.message
|
|
3866
|
+
: undefined;
|
|
3867
|
+
}
|
|
3868
|
+
/**
|
|
3869
|
+
* Get the status code (only available in responses)
|
|
3870
|
+
*/
|
|
3871
|
+
get statusCode() {
|
|
3872
|
+
return this.isResponse()
|
|
3873
|
+
? this.proto.statusCode
|
|
3874
|
+
: undefined;
|
|
3875
|
+
}
|
|
3876
|
+
/**
|
|
3877
|
+
* Get the status description (only available in responses)
|
|
3878
|
+
*/
|
|
3879
|
+
get statusDesc() {
|
|
3880
|
+
return this.isResponse()
|
|
3881
|
+
? this.proto.statusDesc
|
|
3882
|
+
: undefined;
|
|
3883
|
+
}
|
|
3884
|
+
/**
|
|
3885
|
+
* Get the relay peer count (only available in responses)
|
|
3886
|
+
*/
|
|
3887
|
+
get relayPeerCount() {
|
|
3888
|
+
return this.isResponse()
|
|
3889
|
+
? this.proto.relayPeerCount
|
|
3890
|
+
: undefined;
|
|
3891
|
+
}
|
|
3892
|
+
/**
|
|
3893
|
+
* Check if this is a request message
|
|
3894
|
+
*/
|
|
3895
|
+
isRequest() {
|
|
3896
|
+
return "pubsubTopic" in this.proto && "message" in this.proto;
|
|
3897
|
+
}
|
|
3898
|
+
/**
|
|
3899
|
+
* Check if this is a response message
|
|
3900
|
+
*/
|
|
3901
|
+
isResponse() {
|
|
3902
|
+
return "statusCode" in this.proto;
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
|
|
3762
3906
|
// should match nwaku
|
|
3763
3907
|
// https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/rln_relay.nim#L309
|
|
3764
3908
|
// https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/tests/waku_rln_relay/rln/waku_rln_relay_utils.nim#L20
|
|
@@ -3777,140 +3921,240 @@ const isRLNResponseError = (info) => {
|
|
|
3777
3921
|
info.includes(RLN_REMOTE_VALIDATION));
|
|
3778
3922
|
};
|
|
3779
3923
|
|
|
3780
|
-
const
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
class
|
|
3786
|
-
|
|
3787
|
-
multicodec = LightPushCodec;
|
|
3788
|
-
constructor(libp2p) {
|
|
3789
|
-
this.streamManager = new StreamManager(LightPushCodec, libp2p.components);
|
|
3790
|
-
}
|
|
3791
|
-
async preparePushMessage(encoder, message) {
|
|
3924
|
+
const CODECS = {
|
|
3925
|
+
v2: "/vac/waku/lightpush/2.0.0-beta1",
|
|
3926
|
+
v3: "/vac/waku/lightpush/3.0.0"
|
|
3927
|
+
};
|
|
3928
|
+
const log$9 = new Logger("light-push:protocol-handler");
|
|
3929
|
+
class ProtocolHandler {
|
|
3930
|
+
static async preparePushMessage(encoder, message, protocol) {
|
|
3792
3931
|
try {
|
|
3793
3932
|
if (!message.payload || message.payload.length === 0) {
|
|
3794
|
-
log$
|
|
3795
|
-
return {
|
|
3933
|
+
log$9.error("Failed to send waku light push: payload is empty");
|
|
3934
|
+
return { rpc: null, error: LightPushError.EMPTY_PAYLOAD };
|
|
3796
3935
|
}
|
|
3797
3936
|
if (!(await isMessageSizeUnderCap(encoder, message))) {
|
|
3798
|
-
log$
|
|
3799
|
-
return {
|
|
3937
|
+
log$9.error("Failed to send waku light push: message is bigger than 1MB");
|
|
3938
|
+
return { rpc: null, error: LightPushError.SIZE_TOO_BIG };
|
|
3800
3939
|
}
|
|
3801
3940
|
const protoMessage = await encoder.toProtoObj(message);
|
|
3802
3941
|
if (!protoMessage) {
|
|
3803
|
-
log$
|
|
3942
|
+
log$9.error("Failed to encode to protoMessage, aborting push");
|
|
3943
|
+
return { rpc: null, error: LightPushError.ENCODE_FAILED };
|
|
3944
|
+
}
|
|
3945
|
+
// Select version implementation
|
|
3946
|
+
if (protocol === CODECS.v3) {
|
|
3947
|
+
log$9.info("Creating v3 RPC message");
|
|
3804
3948
|
return {
|
|
3805
|
-
|
|
3806
|
-
error:
|
|
3949
|
+
rpc: createV3Rpc(protoMessage, encoder.pubsubTopic),
|
|
3950
|
+
error: null
|
|
3807
3951
|
};
|
|
3808
3952
|
}
|
|
3809
|
-
|
|
3810
|
-
|
|
3953
|
+
// Default to v2
|
|
3954
|
+
log$9.info("Creating v2 RPC message");
|
|
3955
|
+
return {
|
|
3956
|
+
rpc: createV2Rpc(protoMessage, encoder.pubsubTopic),
|
|
3957
|
+
error: null
|
|
3958
|
+
};
|
|
3811
3959
|
}
|
|
3812
|
-
catch (
|
|
3813
|
-
log$
|
|
3960
|
+
catch (err) {
|
|
3961
|
+
log$9.error("Failed to prepare push message", err);
|
|
3962
|
+
return { rpc: null, error: LightPushError.GENERIC_FAIL };
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
/**
|
|
3966
|
+
* Decode and evaluate a LightPush response according to the protocol version
|
|
3967
|
+
*/
|
|
3968
|
+
static handleResponse(bytes, protocol, peerId) {
|
|
3969
|
+
if (protocol === CODECS.v3) {
|
|
3970
|
+
return ProtocolHandler.handleV3Response(bytes, peerId);
|
|
3971
|
+
}
|
|
3972
|
+
return ProtocolHandler.handleV2Response(bytes, peerId);
|
|
3973
|
+
}
|
|
3974
|
+
static handleV3Response(bytes, peerId) {
|
|
3975
|
+
try {
|
|
3976
|
+
const decodedRpcV3 = PushRpc.decodeResponse(bytes);
|
|
3977
|
+
const statusCode = decodedRpcV3.statusCode;
|
|
3978
|
+
const statusDesc = decodedRpcV3.statusDesc;
|
|
3979
|
+
if (statusCode !== LightPushStatusCode.SUCCESS) {
|
|
3980
|
+
const error = LightPushError.REMOTE_PEER_REJECTED;
|
|
3981
|
+
log$9.error(`Remote peer rejected with v3 status code ${statusCode}: ${statusDesc}`);
|
|
3982
|
+
return {
|
|
3983
|
+
success: null,
|
|
3984
|
+
failure: {
|
|
3985
|
+
error,
|
|
3986
|
+
peerId: peerId
|
|
3987
|
+
}
|
|
3988
|
+
};
|
|
3989
|
+
}
|
|
3990
|
+
if (decodedRpcV3.relayPeerCount !== undefined) {
|
|
3991
|
+
log$9.info(`Message relayed to ${decodedRpcV3.relayPeerCount} peers`);
|
|
3992
|
+
}
|
|
3993
|
+
return { success: peerId, failure: null };
|
|
3994
|
+
}
|
|
3995
|
+
catch (err) {
|
|
3814
3996
|
return {
|
|
3815
|
-
|
|
3816
|
-
|
|
3997
|
+
success: null,
|
|
3998
|
+
failure: {
|
|
3999
|
+
error: LightPushError.DECODE_FAILED,
|
|
4000
|
+
peerId: peerId
|
|
4001
|
+
}
|
|
3817
4002
|
};
|
|
3818
4003
|
}
|
|
3819
4004
|
}
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
4005
|
+
static handleV2Response(bytes, peerId) {
|
|
4006
|
+
let response;
|
|
4007
|
+
try {
|
|
4008
|
+
const decodedRpc = PushRpcV2.decode(bytes);
|
|
4009
|
+
response = decodedRpc.response;
|
|
4010
|
+
}
|
|
4011
|
+
catch (err) {
|
|
3823
4012
|
return {
|
|
3824
4013
|
success: null,
|
|
3825
4014
|
failure: {
|
|
3826
|
-
error:
|
|
3827
|
-
peerId
|
|
4015
|
+
error: LightPushError.DECODE_FAILED,
|
|
4016
|
+
peerId: peerId
|
|
3828
4017
|
}
|
|
3829
4018
|
};
|
|
3830
4019
|
}
|
|
3831
|
-
|
|
3832
|
-
if (!stream) {
|
|
3833
|
-
log$8.error(`Failed to get a stream for remote peer:${peerId.toString()}`);
|
|
4020
|
+
if (!response) {
|
|
3834
4021
|
return {
|
|
3835
4022
|
success: null,
|
|
3836
4023
|
failure: {
|
|
3837
|
-
error:
|
|
4024
|
+
error: LightPushError.NO_RESPONSE,
|
|
3838
4025
|
peerId: peerId
|
|
3839
4026
|
}
|
|
3840
4027
|
};
|
|
3841
4028
|
}
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
4029
|
+
if (isRLNResponseError(response.info)) {
|
|
4030
|
+
log$9.error("Remote peer fault: RLN generation");
|
|
4031
|
+
return {
|
|
4032
|
+
success: null,
|
|
4033
|
+
failure: {
|
|
4034
|
+
error: LightPushError.RLN_PROOF_GENERATION,
|
|
4035
|
+
peerId: peerId
|
|
4036
|
+
}
|
|
4037
|
+
};
|
|
3845
4038
|
}
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
log$8.error("Failed to send waku light push request", err);
|
|
4039
|
+
if (!response.isSuccess) {
|
|
4040
|
+
log$9.error("Remote peer rejected the message: ", response.info);
|
|
3849
4041
|
return {
|
|
3850
4042
|
success: null,
|
|
3851
4043
|
failure: {
|
|
3852
|
-
error:
|
|
4044
|
+
error: LightPushError.REMOTE_PEER_REJECTED,
|
|
3853
4045
|
peerId: peerId
|
|
3854
4046
|
}
|
|
3855
4047
|
};
|
|
3856
4048
|
}
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
4049
|
+
return { success: peerId, failure: null };
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
function createV2Rpc(message, pubsubTopic) {
|
|
4053
|
+
const v2Rpc = PushRpcV2.createRequest(message, pubsubTopic);
|
|
4054
|
+
return Object.assign(v2Rpc, { version: "v2" });
|
|
4055
|
+
}
|
|
4056
|
+
function createV3Rpc(message, pubsubTopic) {
|
|
4057
|
+
if (!message.timestamp) {
|
|
4058
|
+
message.timestamp = BigInt(Date.now()) * BigInt(1_000_000);
|
|
4059
|
+
}
|
|
4060
|
+
const v3Rpc = PushRpc.createRequest(message, pubsubTopic);
|
|
4061
|
+
return Object.assign(v3Rpc, { version: "v3" });
|
|
4062
|
+
}
|
|
4063
|
+
|
|
4064
|
+
const log$8 = new Logger("light-push");
|
|
4065
|
+
const LightPushCodec = CODECS.v3;
|
|
4066
|
+
const LightPushCodecV2 = CODECS.v2;
|
|
4067
|
+
/**
|
|
4068
|
+
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
|
|
4069
|
+
*/
|
|
4070
|
+
class LightPushCore {
|
|
4071
|
+
libp2p;
|
|
4072
|
+
streamManager;
|
|
4073
|
+
streamManagerV2;
|
|
4074
|
+
multicodec = [CODECS.v3, CODECS.v2];
|
|
4075
|
+
constructor(libp2p) {
|
|
4076
|
+
this.libp2p = libp2p;
|
|
4077
|
+
this.streamManager = new StreamManager(CODECS.v3, libp2p.components);
|
|
4078
|
+
this.streamManagerV2 = new StreamManager(CODECS.v2, libp2p.components);
|
|
4079
|
+
}
|
|
4080
|
+
async send(encoder, message, peerId) {
|
|
4081
|
+
let stream;
|
|
4082
|
+
let protocol;
|
|
3862
4083
|
try {
|
|
3863
|
-
|
|
4084
|
+
const peer = await this.libp2p.peerStore.get(peerId);
|
|
4085
|
+
if (peer.protocols.includes(CODECS.v3)) {
|
|
4086
|
+
stream = await this.streamManager.getStream(peerId);
|
|
4087
|
+
protocol = CODECS.v3;
|
|
4088
|
+
}
|
|
4089
|
+
else {
|
|
4090
|
+
stream = await this.streamManagerV2.getStream(peerId);
|
|
4091
|
+
protocol = CODECS.v2;
|
|
4092
|
+
}
|
|
3864
4093
|
}
|
|
3865
|
-
catch (
|
|
3866
|
-
log$8.error("Failed to
|
|
4094
|
+
catch (error) {
|
|
4095
|
+
log$8.error("Failed to get stream", error);
|
|
3867
4096
|
return {
|
|
3868
4097
|
success: null,
|
|
3869
4098
|
failure: {
|
|
3870
|
-
error:
|
|
3871
|
-
peerId
|
|
4099
|
+
error: LightPushError.GENERIC_FAIL,
|
|
4100
|
+
peerId
|
|
3872
4101
|
}
|
|
3873
4102
|
};
|
|
3874
4103
|
}
|
|
3875
|
-
if (!
|
|
3876
|
-
log$8.error(
|
|
4104
|
+
if (!stream) {
|
|
4105
|
+
log$8.error(`Failed to get a stream for remote peer:${peerId.toString()}`);
|
|
3877
4106
|
return {
|
|
3878
4107
|
success: null,
|
|
3879
4108
|
failure: {
|
|
3880
|
-
error:
|
|
4109
|
+
error: LightPushError.NO_STREAM_AVAILABLE,
|
|
3881
4110
|
peerId: peerId
|
|
3882
4111
|
}
|
|
3883
4112
|
};
|
|
3884
4113
|
}
|
|
3885
|
-
|
|
3886
|
-
|
|
4114
|
+
const { rpc, error: prepError } = await ProtocolHandler.preparePushMessage(encoder, message, protocol);
|
|
4115
|
+
if (prepError || !rpc) {
|
|
4116
|
+
return {
|
|
4117
|
+
success: null,
|
|
4118
|
+
failure: {
|
|
4119
|
+
error: prepError ?? LightPushError.GENERIC_FAIL,
|
|
4120
|
+
peerId
|
|
4121
|
+
}
|
|
4122
|
+
};
|
|
4123
|
+
}
|
|
4124
|
+
let res;
|
|
4125
|
+
try {
|
|
4126
|
+
res = await pipe([rpc.encode()], encode, stream, decode, async (source) => await all(source));
|
|
4127
|
+
}
|
|
4128
|
+
catch (err) {
|
|
4129
|
+
log$8.error("Failed to send waku light push request", err);
|
|
3887
4130
|
return {
|
|
3888
4131
|
success: null,
|
|
3889
4132
|
failure: {
|
|
3890
|
-
error:
|
|
4133
|
+
error: LightPushError.STREAM_ABORTED,
|
|
3891
4134
|
peerId: peerId
|
|
3892
4135
|
}
|
|
3893
4136
|
};
|
|
3894
4137
|
}
|
|
3895
|
-
|
|
3896
|
-
|
|
4138
|
+
const bytes = new Uint8ArrayList();
|
|
4139
|
+
res.forEach((chunk) => bytes.append(chunk));
|
|
4140
|
+
if (bytes.length === 0) {
|
|
3897
4141
|
return {
|
|
3898
4142
|
success: null,
|
|
3899
4143
|
failure: {
|
|
3900
|
-
error:
|
|
4144
|
+
error: LightPushError.NO_RESPONSE,
|
|
3901
4145
|
peerId: peerId
|
|
3902
4146
|
}
|
|
3903
4147
|
};
|
|
3904
4148
|
}
|
|
3905
|
-
return
|
|
4149
|
+
return ProtocolHandler.handleResponse(bytes, protocol, peerId);
|
|
3906
4150
|
}
|
|
3907
4151
|
}
|
|
3908
4152
|
|
|
3909
4153
|
var index$1 = /*#__PURE__*/Object.freeze({
|
|
3910
4154
|
__proto__: null,
|
|
3911
4155
|
LightPushCodec: LightPushCodec,
|
|
3912
|
-
|
|
3913
|
-
|
|
4156
|
+
LightPushCodecV2: LightPushCodecV2,
|
|
4157
|
+
LightPushCore: LightPushCore
|
|
3914
4158
|
});
|
|
3915
4159
|
|
|
3916
4160
|
const EmptyMessage = {
|
|
@@ -4009,7 +4253,7 @@ const log$7 = new Logger("store");
|
|
|
4009
4253
|
const StoreCodec = "/vac/waku/store-query/3.0.0";
|
|
4010
4254
|
class StoreCore {
|
|
4011
4255
|
streamManager;
|
|
4012
|
-
multicodec = StoreCodec;
|
|
4256
|
+
multicodec = [StoreCodec];
|
|
4013
4257
|
constructor(libp2p) {
|
|
4014
4258
|
this.streamManager = new StreamManager(StoreCodec, libp2p.components);
|
|
4015
4259
|
}
|
|
@@ -10188,7 +10432,7 @@ class Metadata {
|
|
|
10188
10432
|
streamManager;
|
|
10189
10433
|
libp2pComponents;
|
|
10190
10434
|
handshakesConfirmed = new Map();
|
|
10191
|
-
multicodec = MetadataCodec;
|
|
10435
|
+
multicodec = [MetadataCodec];
|
|
10192
10436
|
constructor(clusterId, libp2p) {
|
|
10193
10437
|
this.clusterId = clusterId;
|
|
10194
10438
|
this.streamManager = new StreamManager(MetadataCodec, libp2p);
|
|
@@ -10378,4 +10622,4 @@ function messageHashStr(pubsubTopic, message) {
|
|
|
10378
10622
|
return hashStr;
|
|
10379
10623
|
}
|
|
10380
10624
|
|
|
10381
|
-
export { ConnectionManager, FilterCodecs, FilterCore, LightPushCodec, LightPushCore, MetadataCodec, StoreCodec, StoreCore, StreamManager, createEncoder, index$3 as message, messageHash, messageHashStr, wakuMetadata, index$2 as waku_filter, index$1 as waku_light_push, index as waku_store };
|
|
10625
|
+
export { ConnectionManager, FilterCodecs, FilterCore, LightPushCodec, LightPushCodecV2, LightPushCore, MetadataCodec, StoreCodec, StoreCore, StreamManager, createEncoder, index$3 as message, messageHash, messageHashStr, wakuMetadata, index$2 as waku_filter, index$1 as waku_light_push, index as waku_store };
|