@waku/core 0.0.31-15400a5.0 → 0.0.31-39f8920.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/{base_protocol-0VPHaGce.js → base_protocol-Dge5_tvU.js} +3 -7
- package/bundle/{index-D-yd4hdM.js → index-Gts2Ddu_.js} +26 -46
- package/bundle/index.js +52 -95
- package/bundle/lib/base_protocol.js +2 -2
- package/bundle/lib/message/version_0.js +2 -2
- package/bundle/{version_0-Du1FfEvY.js → version_0-CNRKFufI.js} +22 -17
- package/dist/.tsbuildinfo +1 -1
- package/dist/lib/base_protocol.d.ts +2 -3
- package/dist/lib/base_protocol.js +3 -7
- package/dist/lib/base_protocol.js.map +1 -1
- package/dist/lib/connection_manager.d.ts +1 -1
- package/dist/lib/connection_manager.js.map +1 -1
- package/dist/lib/filter/index.d.ts +3 -2
- package/dist/lib/filter/index.js +4 -2
- package/dist/lib/filter/index.js.map +1 -1
- package/dist/lib/light_push/index.d.ts +3 -2
- package/dist/lib/light_push/index.js +4 -2
- package/dist/lib/light_push/index.js.map +1 -1
- package/dist/lib/metadata/index.d.ts +2 -2
- package/dist/lib/metadata/index.js +9 -9
- package/dist/lib/metadata/index.js.map +1 -1
- package/dist/lib/store/index.d.ts +3 -2
- package/dist/lib/store/index.js +4 -2
- package/dist/lib/store/index.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/base_protocol.ts +3 -7
- package/src/lib/connection_manager.ts +1 -1
- package/src/lib/filter/index.ts +3 -10
- package/src/lib/light_push/index.ts +6 -9
- package/src/lib/metadata/index.ts +11 -12
- package/src/lib/store/index.ts +6 -9
@@ -1,4 +1,4 @@
|
|
1
|
-
import { h as bytesToUtf8, T as Tags, L as Logger,
|
1
|
+
import { h as bytesToUtf8, T as Tags, L as Logger, e as pubsubTopicsToShardInfo } from './index-Gts2Ddu_.js';
|
2
2
|
|
3
3
|
const decodeRelayShard = (bytes) => {
|
4
4
|
// explicitly converting to Uint8Array to avoid Buffer
|
@@ -272,16 +272,14 @@ class BaseProtocol {
|
|
272
272
|
components;
|
273
273
|
log;
|
274
274
|
pubsubTopics;
|
275
|
-
options;
|
276
275
|
addLibp2pEventListener;
|
277
276
|
removeLibp2pEventListener;
|
278
277
|
streamManager;
|
279
|
-
constructor(multicodec, components, log, pubsubTopics
|
278
|
+
constructor(multicodec, components, log, pubsubTopics) {
|
280
279
|
this.multicodec = multicodec;
|
281
280
|
this.components = components;
|
282
281
|
this.log = log;
|
283
282
|
this.pubsubTopics = pubsubTopics;
|
284
|
-
this.options = options;
|
285
283
|
this.addLibp2pEventListener = components.events.addEventListener.bind(components.events);
|
286
284
|
this.removeLibp2pEventListener = components.events.removeEventListener.bind(components.events);
|
287
285
|
this.streamManager = new StreamManager(multicodec, components.connectionManager.getConnections.bind(components.connectionManager), this.addLibp2pEventListener);
|
@@ -319,9 +317,7 @@ class BaseProtocol {
|
|
319
317
|
numPeers: 0
|
320
318
|
}) {
|
321
319
|
// Retrieve all connected peers that support the protocol & shard (if configured)
|
322
|
-
const connectedPeersForProtocolAndShard = await getConnectedPeersForProtocolAndShard(this.components.connectionManager.getConnections(), this.peerStore, [this.multicodec], this.
|
323
|
-
? ensureShardingConfigured(this.options.shardInfo).shardInfo
|
324
|
-
: undefined);
|
320
|
+
const connectedPeersForProtocolAndShard = await getConnectedPeersForProtocolAndShard(this.components.connectionManager.getConnections(), this.peerStore, [this.multicodec], pubsubTopicsToShardInfo(this.pubsubTopics));
|
325
321
|
// Filter the peers based on discovery & number of peers requested
|
326
322
|
const filteredPeers = filterPeersByDiscovery(connectedPeersForProtocolAndShard, numPeers, maxBootstrapPeers);
|
327
323
|
// Sort the peers by latency
|
@@ -1130,7 +1130,7 @@ const utf8ToBytes = (s) => fromString(s, "utf8");
|
|
1130
1130
|
* Concatenate using Uint8Arrays as `Buffer` has a different behavior with `DataView`
|
1131
1131
|
*/
|
1132
1132
|
function concat(byteArrays, totalLength) {
|
1133
|
-
const len =
|
1133
|
+
const len = byteArrays.reduce((acc, curr) => acc + curr.length, 0);
|
1134
1134
|
const res = new Uint8Array(len);
|
1135
1135
|
let offset = 0;
|
1136
1136
|
for (const bytes of byteArrays) {
|
@@ -1182,6 +1182,27 @@ const pubsubTopicToSingleShardInfo = (pubsubTopics) => {
|
|
1182
1182
|
shard
|
1183
1183
|
};
|
1184
1184
|
};
|
1185
|
+
const pubsubTopicsToShardInfo = (pubsubTopics) => {
|
1186
|
+
const shardInfoSet = new Set();
|
1187
|
+
const clusterIds = new Set();
|
1188
|
+
for (const topic of pubsubTopics) {
|
1189
|
+
const { clusterId, shard } = pubsubTopicToSingleShardInfo(topic);
|
1190
|
+
shardInfoSet.add(`${clusterId}:${shard}`);
|
1191
|
+
clusterIds.add(clusterId);
|
1192
|
+
}
|
1193
|
+
if (shardInfoSet.size === 0) {
|
1194
|
+
throw new Error("No valid pubsub topics provided");
|
1195
|
+
}
|
1196
|
+
if (clusterIds.size > 1) {
|
1197
|
+
throw new Error("Pubsub topics from multiple cluster IDs are not supported");
|
1198
|
+
}
|
1199
|
+
const clusterId = clusterIds.values().next().value;
|
1200
|
+
const shards = Array.from(shardInfoSet).map((info) => parseInt(info.split(":")[1]));
|
1201
|
+
return {
|
1202
|
+
clusterId,
|
1203
|
+
shards
|
1204
|
+
};
|
1205
|
+
};
|
1185
1206
|
/**
|
1186
1207
|
* Given a string, will throw an error if it is not formatted as a valid content topic for autosharding based on https://rfc.vac.dev/spec/51/
|
1187
1208
|
* @param contentTopic String to validate
|
@@ -1259,49 +1280,6 @@ pubsubTopicShardInfo) {
|
|
1259
1280
|
? singleShardInfoToPubsubTopic(pubsubTopicShardInfo)
|
1260
1281
|
: contentTopicToPubsubTopic(contentTopic, pubsubTopicShardInfo?.clusterId ?? DEFAULT_CLUSTER_ID);
|
1261
1282
|
}
|
1262
|
-
/**
|
1263
|
-
* Validates sharding configuration and sets defaults where possible.
|
1264
|
-
* @returns Validated sharding parameters, with any missing values set to defaults
|
1265
|
-
*/
|
1266
|
-
const ensureShardingConfigured = (shardInfo) => {
|
1267
|
-
const clusterId = shardInfo.clusterId ?? DEFAULT_CLUSTER_ID;
|
1268
|
-
const shards = "shards" in shardInfo ? shardInfo.shards : [];
|
1269
|
-
const contentTopics = "contentTopics" in shardInfo ? shardInfo.contentTopics : [];
|
1270
|
-
const [application, version] = "application" in shardInfo && "version" in shardInfo
|
1271
|
-
? [shardInfo.application, shardInfo.version]
|
1272
|
-
: [undefined, undefined];
|
1273
|
-
const isShardsConfigured = shards && shards.length > 0;
|
1274
|
-
const isContentTopicsConfigured = contentTopics && contentTopics.length > 0;
|
1275
|
-
const isApplicationVersionConfigured = application && version;
|
1276
|
-
if (isShardsConfigured) {
|
1277
|
-
return {
|
1278
|
-
shardingParams: { clusterId, shards },
|
1279
|
-
shardInfo: { clusterId, shards },
|
1280
|
-
pubsubTopics: shardInfoToPubsubTopics({ clusterId, shards })
|
1281
|
-
};
|
1282
|
-
}
|
1283
|
-
if (isContentTopicsConfigured) {
|
1284
|
-
const pubsubTopics = Array.from(new Set(contentTopics.map((topic) => contentTopicToPubsubTopic(topic, clusterId))));
|
1285
|
-
const shards = Array.from(new Set(contentTopics.map((topic) => contentTopicToShardIndex(topic))));
|
1286
|
-
return {
|
1287
|
-
shardingParams: { clusterId, contentTopics },
|
1288
|
-
shardInfo: { clusterId, shards },
|
1289
|
-
pubsubTopics
|
1290
|
-
};
|
1291
|
-
}
|
1292
|
-
if (isApplicationVersionConfigured) {
|
1293
|
-
const pubsubTopic = contentTopicToPubsubTopic(`/${application}/${version}/default/default`, clusterId);
|
1294
|
-
return {
|
1295
|
-
shardingParams: { clusterId, application, version },
|
1296
|
-
shardInfo: {
|
1297
|
-
clusterId,
|
1298
|
-
shards: [pubsubTopicToSingleShardInfo(pubsubTopic).shard]
|
1299
|
-
},
|
1300
|
-
pubsubTopics: [pubsubTopic]
|
1301
|
-
};
|
1302
|
-
}
|
1303
|
-
throw new Error("Missing minimum required configuration options for static sharding or autosharding.");
|
1304
|
-
};
|
1305
1283
|
|
1306
1284
|
function getDefaultExportFromCjs (x) {
|
1307
1285
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
@@ -1882,6 +1860,8 @@ var common = setup;
|
|
1882
1860
|
return false;
|
1883
1861
|
}
|
1884
1862
|
|
1863
|
+
let m;
|
1864
|
+
|
1885
1865
|
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
1886
1866
|
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
1887
1867
|
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
@@ -1889,7 +1869,7 @@ var common = setup;
|
|
1889
1869
|
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
1890
1870
|
// Is firefox >= v31?
|
1891
1871
|
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
1892
|
-
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(
|
1872
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
1893
1873
|
// Double check webkit in userAgent just in case we are in a worker
|
1894
1874
|
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
1895
1875
|
}
|
@@ -2057,4 +2037,4 @@ class Logger {
|
|
2057
2037
|
}
|
2058
2038
|
}
|
2059
2039
|
|
2060
|
-
export { EConnectionStateEvents as E, HealthStatus as H, Logger as L, ProtocolError as P, Tags as T, allocUnsafe as a, alloc as b, Protocols as c, EPeersByDiscoveryEvents as d,
|
2040
|
+
export { EConnectionStateEvents as E, HealthStatus as H, Logger as L, ProtocolError as P, Tags as T, allocUnsafe as a, alloc as b, Protocols as c, EPeersByDiscoveryEvents as d, pubsubTopicsToShardInfo as e, fromString as f, determinePubsubTopic as g, bytesToUtf8 as h, pubsubTopicToSingleShardInfo as p, shardInfoToPubsubTopics as s, utf8ToBytes as u };
|
package/bundle/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import { v as version_0, e as encodingLength, a as encode$1, d as decode$1, M as MessagePush, F as FilterSubscribeRequest, b as FilterSubscribeResponse$1, P as PushRpc$1, c as PushResponse, S as StoreQueryRequest$1, f as StoreQueryResponse$1, g as createEncoder, W as WakuMetadataRequest, h as WakuMetadataResponse } from './version_0-
|
2
|
-
export { i as createDecoder } from './version_0-
|
3
|
-
import { a as allocUnsafe, b as alloc,
|
4
|
-
import { B as BaseProtocol, d as decodeRelayShard, e as encodeRelayShard } from './base_protocol-
|
5
|
-
export { S as StreamManager } from './base_protocol-
|
1
|
+
import { v as version_0, e as encodingLength, a as encode$1, d as decode$1, M as MessagePush, F as FilterSubscribeRequest, b as FilterSubscribeResponse$1, P as PushRpc$1, c as PushResponse, S as StoreQueryRequest$1, f as StoreQueryResponse$1, g as createEncoder, W as WakuMetadataRequest, h as WakuMetadataResponse } from './version_0-CNRKFufI.js';
|
2
|
+
export { i as createDecoder } from './version_0-CNRKFufI.js';
|
3
|
+
import { a as allocUnsafe, b as alloc, L as Logger, P as ProtocolError, c as Protocols, u as utf8ToBytes, p as pubsubTopicToSingleShardInfo, E as EConnectionStateEvents, T as Tags, d as EPeersByDiscoveryEvents, s as shardInfoToPubsubTopics, H as HealthStatus, e as pubsubTopicsToShardInfo } from './index-Gts2Ddu_.js';
|
4
|
+
import { B as BaseProtocol, d as decodeRelayShard, e as encodeRelayShard } from './base_protocol-Dge5_tvU.js';
|
5
|
+
export { S as StreamManager } from './base_protocol-Dge5_tvU.js';
|
6
6
|
|
7
7
|
const MB = 1024 ** 2;
|
8
8
|
const SIZE_CAP_IN_MB = 1;
|
@@ -743,74 +743,35 @@ encode.single = (chunk, options) => {
|
|
743
743
|
};
|
744
744
|
|
745
745
|
/**
|
746
|
-
*
|
747
|
-
* @typedef {Error} Err
|
748
|
-
* @property {string} message
|
746
|
+
* The reported length of the next data message was not a positive integer
|
749
747
|
*/
|
750
|
-
|
748
|
+
class InvalidMessageLengthError extends Error {
|
749
|
+
name = 'InvalidMessageLengthError';
|
750
|
+
code = 'ERR_INVALID_MSG_LENGTH';
|
751
|
+
}
|
751
752
|
/**
|
752
|
-
*
|
753
|
-
*
|
754
|
-
* @param {Extensions} props
|
755
|
-
* @returns {Error & Extensions}
|
753
|
+
* The reported length of the next data message was larger than the configured
|
754
|
+
* max allowable value
|
756
755
|
*/
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
value: props[key],
|
761
|
-
enumerable: true,
|
762
|
-
configurable: true,
|
763
|
-
});
|
764
|
-
}
|
765
|
-
|
766
|
-
return obj;
|
756
|
+
class InvalidDataLengthError extends Error {
|
757
|
+
name = 'InvalidDataLengthError';
|
758
|
+
code = 'ERR_MSG_DATA_TOO_LONG';
|
767
759
|
}
|
768
|
-
|
769
760
|
/**
|
770
|
-
*
|
771
|
-
*
|
772
|
-
* @param {string|Extensions} code - A string code or props to set on the error
|
773
|
-
* @param {Extensions} [props] - Props to set on the error
|
774
|
-
* @returns {Error & Extensions}
|
761
|
+
* The varint used to specify the length of the next data message contained more
|
762
|
+
* bytes than the configured max allowable value
|
775
763
|
*/
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
props = code;
|
787
|
-
code = '';
|
788
|
-
}
|
789
|
-
|
790
|
-
if (code) {
|
791
|
-
props.code = code;
|
792
|
-
}
|
793
|
-
|
794
|
-
try {
|
795
|
-
return assign(err, props);
|
796
|
-
} catch (_) {
|
797
|
-
props.message = err.message;
|
798
|
-
props.stack = err.stack;
|
799
|
-
|
800
|
-
const ErrClass = function () {};
|
801
|
-
|
802
|
-
ErrClass.prototype = Object.create(Object.getPrototypeOf(err));
|
803
|
-
|
804
|
-
// @ts-ignore
|
805
|
-
const output = assign(new ErrClass(), props);
|
806
|
-
|
807
|
-
return output;
|
808
|
-
}
|
764
|
+
class InvalidDataLengthLengthError extends Error {
|
765
|
+
name = 'InvalidDataLengthLengthError';
|
766
|
+
code = 'ERR_MSG_LENGTH_TOO_LONG';
|
767
|
+
}
|
768
|
+
/**
|
769
|
+
* The incoming stream ended before the expected number of bytes were read
|
770
|
+
*/
|
771
|
+
class UnexpectedEOFError extends Error {
|
772
|
+
name = 'UnexpectedEOFError';
|
773
|
+
code = 'ERR_UNEXPECTED_EOF';
|
809
774
|
}
|
810
|
-
|
811
|
-
var errCode = createError;
|
812
|
-
|
813
|
-
var errCode$1 = /*@__PURE__*/getDefaultExportFromCjs(errCode);
|
814
775
|
|
815
776
|
/* eslint max-depth: ["error", 6] */
|
816
777
|
// Maximum length of the length section of the message
|
@@ -842,10 +803,10 @@ function decode(source, options) {
|
|
842
803
|
try {
|
843
804
|
dataLength = lengthDecoder(buffer);
|
844
805
|
if (dataLength < 0) {
|
845
|
-
throw
|
806
|
+
throw new InvalidMessageLengthError('Invalid message length');
|
846
807
|
}
|
847
808
|
if (dataLength > maxDataLength) {
|
848
|
-
throw
|
809
|
+
throw new InvalidDataLengthError('Message length too long');
|
849
810
|
}
|
850
811
|
const dataLengthLength = lengthDecoder.bytes;
|
851
812
|
buffer.consume(dataLengthLength);
|
@@ -857,7 +818,7 @@ function decode(source, options) {
|
|
857
818
|
catch (err) {
|
858
819
|
if (err instanceof RangeError) {
|
859
820
|
if (buffer.byteLength > maxLengthLength) {
|
860
|
-
throw
|
821
|
+
throw new InvalidDataLengthLengthError('Message length length too long');
|
861
822
|
}
|
862
823
|
break;
|
863
824
|
}
|
@@ -886,7 +847,7 @@ function decode(source, options) {
|
|
886
847
|
yield* maybeYield();
|
887
848
|
}
|
888
849
|
if (buffer.byteLength > 0) {
|
889
|
-
throw
|
850
|
+
throw new UnexpectedEOFError('Unexpected end of input');
|
890
851
|
}
|
891
852
|
})();
|
892
853
|
}
|
@@ -896,7 +857,7 @@ function decode(source, options) {
|
|
896
857
|
yield* maybeYield();
|
897
858
|
}
|
898
859
|
if (buffer.byteLength > 0) {
|
899
|
-
throw
|
860
|
+
throw new UnexpectedEOFError('Unexpected end of input');
|
900
861
|
}
|
901
862
|
})();
|
902
863
|
}
|
@@ -1484,16 +1445,6 @@ function v4(options, buf, offset) {
|
|
1484
1445
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
1485
1446
|
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
1486
1447
|
|
1487
|
-
if (buf) {
|
1488
|
-
offset = offset || 0;
|
1489
|
-
|
1490
|
-
for (let i = 0; i < 16; ++i) {
|
1491
|
-
buf[offset + i] = rnds[i];
|
1492
|
-
}
|
1493
|
-
|
1494
|
-
return buf;
|
1495
|
-
}
|
1496
|
-
|
1497
1448
|
return unsafeStringify(rnds);
|
1498
1449
|
}
|
1499
1450
|
|
@@ -1611,9 +1562,11 @@ const FilterCodecs = {
|
|
1611
1562
|
};
|
1612
1563
|
class FilterCore extends BaseProtocol {
|
1613
1564
|
handleIncomingMessage;
|
1614
|
-
|
1615
|
-
|
1565
|
+
pubsubTopics;
|
1566
|
+
constructor(handleIncomingMessage, pubsubTopics, libp2p) {
|
1567
|
+
super(FilterCodecs.SUBSCRIBE, libp2p.components, log$6, pubsubTopics);
|
1616
1568
|
this.handleIncomingMessage = handleIncomingMessage;
|
1569
|
+
this.pubsubTopics = pubsubTopics;
|
1617
1570
|
libp2p
|
1618
1571
|
.handle(FilterCodecs.PUSH, this.onRequest.bind(this), {
|
1619
1572
|
maxInboundStreams: 100
|
@@ -1846,8 +1799,10 @@ const LightPushCodec = "/vac/waku/lightpush/2.0.0-beta1";
|
|
1846
1799
|
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
|
1847
1800
|
*/
|
1848
1801
|
class LightPushCore extends BaseProtocol {
|
1849
|
-
|
1850
|
-
|
1802
|
+
pubsubTopics;
|
1803
|
+
constructor(pubsubTopics, libp2p) {
|
1804
|
+
super(LightPushCodec, libp2p.components, log$5, pubsubTopics);
|
1805
|
+
this.pubsubTopics = pubsubTopics;
|
1851
1806
|
}
|
1852
1807
|
async preparePushMessage(encoder, message) {
|
1853
1808
|
try {
|
@@ -2054,8 +2009,10 @@ class StoreQueryResponse {
|
|
2054
2009
|
const log$4 = new Logger("store");
|
2055
2010
|
const StoreCodec = "/vac/waku/store-query/3.0.0";
|
2056
2011
|
class StoreCore extends BaseProtocol {
|
2057
|
-
|
2058
|
-
|
2012
|
+
pubsubTopics;
|
2013
|
+
constructor(pubsubTopics, libp2p) {
|
2014
|
+
super(StoreCodec, libp2p.components, log$4, pubsubTopics);
|
2015
|
+
this.pubsubTopics = pubsubTopics;
|
2059
2016
|
}
|
2060
2017
|
async *queryPerPage(queryOpts, decoders, peer) {
|
2061
2018
|
if (queryOpts.contentTopics.toString() !==
|
@@ -3165,12 +3122,12 @@ const getHealthManager = () => HealthManager.getInstance();
|
|
3165
3122
|
const log = new Logger("metadata");
|
3166
3123
|
const MetadataCodec = "/vac/waku/metadata/1.0.0";
|
3167
3124
|
class Metadata extends BaseProtocol {
|
3168
|
-
|
3125
|
+
pubsubTopics;
|
3169
3126
|
libp2pComponents;
|
3170
3127
|
handshakesConfirmed = new Map();
|
3171
|
-
constructor(
|
3172
|
-
super(MetadataCodec, libp2p.components, log,
|
3173
|
-
this.
|
3128
|
+
constructor(pubsubTopics, libp2p) {
|
3129
|
+
super(MetadataCodec, libp2p.components, log, pubsubTopics);
|
3130
|
+
this.pubsubTopics = pubsubTopics;
|
3174
3131
|
this.libp2pComponents = libp2p;
|
3175
3132
|
void libp2p.registrar.handle(MetadataCodec, (streamData) => {
|
3176
3133
|
void this.onRequest(streamData);
|
@@ -3180,7 +3137,7 @@ class Metadata extends BaseProtocol {
|
|
3180
3137
|
* Make a metadata query to a peer
|
3181
3138
|
*/
|
3182
3139
|
async query(peerId) {
|
3183
|
-
const request = WakuMetadataRequest.encode(this.
|
3140
|
+
const request = WakuMetadataRequest.encode(pubsubTopicsToShardInfo(this.pubsubTopics));
|
3184
3141
|
const peer = await this.peerStore.get(peerId);
|
3185
3142
|
if (!peer) {
|
3186
3143
|
return {
|
@@ -3229,7 +3186,7 @@ class Metadata extends BaseProtocol {
|
|
3229
3186
|
async onRequest(streamData) {
|
3230
3187
|
try {
|
3231
3188
|
const { stream, connection } = streamData;
|
3232
|
-
const encodedShardInfo = WakuMetadataResponse.encode(this.
|
3189
|
+
const encodedShardInfo = WakuMetadataResponse.encode(pubsubTopicsToShardInfo(this.pubsubTopics));
|
3233
3190
|
const encodedResponse = await pipe([encodedShardInfo], encode, stream, decode, async (source) => await all(source));
|
3234
3191
|
const { error, shardInfo } = this.decodeMetadataResponse(encodedResponse);
|
3235
3192
|
if (error) {
|
@@ -3269,8 +3226,8 @@ class Metadata extends BaseProtocol {
|
|
3269
3226
|
this.handshakesConfirmed.set(peerId.toString(), shardInfo);
|
3270
3227
|
}
|
3271
3228
|
}
|
3272
|
-
function wakuMetadata(
|
3273
|
-
return (components) => new Metadata(
|
3229
|
+
function wakuMetadata(pubsubTopics) {
|
3230
|
+
return (components) => new Metadata(pubsubTopics, components);
|
3274
3231
|
}
|
3275
3232
|
|
3276
3233
|
export { ConnectionManager, FilterCodecs, FilterCore, KeepAliveManager, LightPushCodec, LightPushCore, MetadataCodec, StoreCore, createEncoder, getHealthManager, index$3 as message, waitForRemotePeer, wakuMetadata, index$2 as waku_filter, index$1 as waku_light_push, index as waku_store };
|
@@ -1,2 +1,2 @@
|
|
1
|
-
import '../index-
|
2
|
-
export { B as BaseProtocol } from '../base_protocol-
|
1
|
+
import '../index-Gts2Ddu_.js';
|
2
|
+
export { B as BaseProtocol } from '../base_protocol-Dge5_tvU.js';
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export { D as DecodedMessage, j as Decoder, E as Encoder, V as Version, i as createDecoder, g as createEncoder, m as proto } from '../../version_0-
|
2
|
-
import '../../index-
|
1
|
+
export { D as DecodedMessage, j as Decoder, E as Encoder, V as Version, i as createDecoder, g as createEncoder, m as proto } from '../../version_0-CNRKFufI.js';
|
2
|
+
import '../../index-Gts2Ddu_.js';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { a as allocUnsafe, f as fromString, b as alloc$1, L as Logger,
|
1
|
+
import { a as allocUnsafe, f as fromString, b as alloc$1, L as Logger, g as determinePubsubTopic } from './index-Gts2Ddu_.js';
|
2
2
|
|
3
3
|
/* eslint-disable no-fallthrough */
|
4
4
|
const N1 = Math.pow(2, 7);
|
@@ -920,7 +920,7 @@ function decodeMessage(buf, codec, opts) {
|
|
920
920
|
* A general purpose buffer pool
|
921
921
|
*/
|
922
922
|
function pool(size) {
|
923
|
-
const SIZE =
|
923
|
+
const SIZE = 8192;
|
924
924
|
const MAX = SIZE >>> 1;
|
925
925
|
let slab;
|
926
926
|
let offset = SIZE;
|
@@ -1433,12 +1433,17 @@ function message$1(encode, decode) {
|
|
1433
1433
|
* npm i protons-runtime
|
1434
1434
|
* ```
|
1435
1435
|
*/
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1436
|
+
/**
|
1437
|
+
* Thrown when a repeated field has too many elements
|
1438
|
+
*/
|
1439
|
+
class MaxLengthError extends Error {
|
1440
|
+
/**
|
1441
|
+
* This will be removed in a future release
|
1442
|
+
*
|
1443
|
+
* @deprecated use the `.name` property instead
|
1444
|
+
*/
|
1445
|
+
code = 'ERR_MAX_LENGTH';
|
1446
|
+
name = 'MaxLengthError';
|
1442
1447
|
}
|
1443
1448
|
|
1444
1449
|
/* eslint-disable import/export */
|
@@ -1746,7 +1751,7 @@ var FilterRequest;
|
|
1746
1751
|
}
|
1747
1752
|
case 3: {
|
1748
1753
|
if (opts.limits?.contentFilters != null && obj.contentFilters.length === opts.limits.contentFilters) {
|
1749
|
-
throw new
|
1754
|
+
throw new MaxLengthError('Decode error - map field "contentFilters" had too many elements');
|
1750
1755
|
}
|
1751
1756
|
obj.contentFilters.push(FilterRequest.ContentFilter.codec().decode(reader, reader.uint32(), {
|
1752
1757
|
limits: opts.limits?.contentFilters$
|
@@ -1799,7 +1804,7 @@ var MessagePush$1;
|
|
1799
1804
|
switch (tag >>> 3) {
|
1800
1805
|
case 1: {
|
1801
1806
|
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
|
1802
|
-
throw new
|
1807
|
+
throw new MaxLengthError('Decode error - map field "messages" had too many elements');
|
1803
1808
|
}
|
1804
1809
|
obj.messages.push(WakuMessage$3.codec().decode(reader, reader.uint32(), {
|
1805
1810
|
limits: opts.limits?.messages$
|
@@ -2218,7 +2223,7 @@ var FilterSubscribeRequest;
|
|
2218
2223
|
}
|
2219
2224
|
case 11: {
|
2220
2225
|
if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) {
|
2221
|
-
throw new
|
2226
|
+
throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');
|
2222
2227
|
}
|
2223
2228
|
obj.contentTopics.push(reader.string());
|
2224
2229
|
break;
|
@@ -3084,7 +3089,7 @@ var StoreQueryRequest$1;
|
|
3084
3089
|
}
|
3085
3090
|
case 11: {
|
3086
3091
|
if (opts.limits?.contentTopics != null && obj.contentTopics.length === opts.limits.contentTopics) {
|
3087
|
-
throw new
|
3092
|
+
throw new MaxLengthError('Decode error - map field "contentTopics" had too many elements');
|
3088
3093
|
}
|
3089
3094
|
obj.contentTopics.push(reader.string());
|
3090
3095
|
break;
|
@@ -3099,7 +3104,7 @@ var StoreQueryRequest$1;
|
|
3099
3104
|
}
|
3100
3105
|
case 20: {
|
3101
3106
|
if (opts.limits?.messageHashes != null && obj.messageHashes.length === opts.limits.messageHashes) {
|
3102
|
-
throw new
|
3107
|
+
throw new MaxLengthError('Decode error - map field "messageHashes" had too many elements');
|
3103
3108
|
}
|
3104
3109
|
obj.messageHashes.push(reader.bytes());
|
3105
3110
|
break;
|
@@ -3191,7 +3196,7 @@ var StoreQueryResponse$1;
|
|
3191
3196
|
}
|
3192
3197
|
case 20: {
|
3193
3198
|
if (opts.limits?.messages != null && obj.messages.length === opts.limits.messages) {
|
3194
|
-
throw new
|
3199
|
+
throw new MaxLengthError('Decode error - map field "messages" had too many elements');
|
3195
3200
|
}
|
3196
3201
|
obj.messages.push(WakuMessageKeyValue.codec().decode(reader, reader.uint32(), {
|
3197
3202
|
limits: opts.limits?.messages$
|
@@ -3539,7 +3544,7 @@ var PeerExchangeResponse;
|
|
3539
3544
|
switch (tag >>> 3) {
|
3540
3545
|
case 1: {
|
3541
3546
|
if (opts.limits?.peerInfos != null && obj.peerInfos.length === opts.limits.peerInfos) {
|
3542
|
-
throw new
|
3547
|
+
throw new MaxLengthError('Decode error - map field "peerInfos" had too many elements');
|
3543
3548
|
}
|
3544
3549
|
obj.peerInfos.push(PeerInfo.codec().decode(reader, reader.uint32(), {
|
3545
3550
|
limits: opts.limits?.peerInfos$
|
@@ -3662,7 +3667,7 @@ var WakuMetadataRequest;
|
|
3662
3667
|
}
|
3663
3668
|
case 2: {
|
3664
3669
|
if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {
|
3665
|
-
throw new
|
3670
|
+
throw new MaxLengthError('Decode error - map field "shards" had too many elements');
|
3666
3671
|
}
|
3667
3672
|
obj.shards.push(reader.uint32());
|
3668
3673
|
break;
|
@@ -3721,7 +3726,7 @@ var WakuMetadataResponse;
|
|
3721
3726
|
}
|
3722
3727
|
case 2: {
|
3723
3728
|
if (opts.limits?.shards != null && obj.shards.length === opts.limits.shards) {
|
3724
|
-
throw new
|
3729
|
+
throw new MaxLengthError('Decode error - map field "shards" had too many elements');
|
3725
3730
|
}
|
3726
3731
|
obj.shards.push(reader.uint32());
|
3727
3732
|
break;
|