@waku/core 0.0.36-f911bf8.0 → 0.0.37-2ed5ddc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/bundle/index.js +5647 -1359
  3. package/bundle/lib/message/version_0.js +1 -2
  4. package/bundle/{version_0-CiYGrPc2.js → version_0-Bc0h7ah2.js} +1886 -31
  5. package/dist/.tsbuildinfo +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +1 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/lib/connection_manager/connection_limiter.d.ts +35 -0
  10. package/dist/lib/connection_manager/connection_limiter.js +103 -0
  11. package/dist/lib/connection_manager/connection_limiter.js.map +1 -0
  12. package/dist/lib/connection_manager/connection_manager.d.ts +19 -104
  13. package/dist/lib/connection_manager/connection_manager.js +64 -499
  14. package/dist/lib/connection_manager/connection_manager.js.map +1 -1
  15. package/dist/lib/connection_manager/discovery_dialer.d.ts +32 -0
  16. package/dist/lib/connection_manager/discovery_dialer.js +131 -0
  17. package/dist/lib/connection_manager/discovery_dialer.js.map +1 -0
  18. package/dist/lib/connection_manager/keep_alive_manager.d.ts +17 -7
  19. package/dist/lib/connection_manager/keep_alive_manager.js +110 -74
  20. package/dist/lib/connection_manager/keep_alive_manager.js.map +1 -1
  21. package/dist/lib/connection_manager/network_monitor.d.ts +22 -0
  22. package/dist/lib/connection_manager/network_monitor.js +63 -0
  23. package/dist/lib/connection_manager/network_monitor.js.map +1 -0
  24. package/dist/lib/connection_manager/shard_reader.d.ts +28 -0
  25. package/dist/lib/connection_manager/shard_reader.js +70 -0
  26. package/dist/lib/connection_manager/shard_reader.js.map +1 -0
  27. package/dist/lib/connection_manager/utils.d.ts +16 -1
  28. package/dist/lib/connection_manager/utils.js +23 -0
  29. package/dist/lib/connection_manager/utils.js.map +1 -1
  30. package/dist/lib/filter/filter.d.ts +7 -5
  31. package/dist/lib/filter/filter.js +14 -11
  32. package/dist/lib/filter/filter.js.map +1 -1
  33. package/dist/lib/light_push/light_push.d.ts +5 -5
  34. package/dist/lib/light_push/light_push.js +7 -7
  35. package/dist/lib/light_push/light_push.js.map +1 -1
  36. package/dist/lib/message/version_0.d.ts +3 -4
  37. package/dist/lib/message/version_0.js +1 -4
  38. package/dist/lib/message/version_0.js.map +1 -1
  39. package/dist/lib/message_hash/index.d.ts +1 -0
  40. package/dist/lib/message_hash/index.js +2 -0
  41. package/dist/lib/message_hash/index.js.map +1 -0
  42. package/dist/lib/message_hash/message_hash.d.ts +52 -0
  43. package/dist/lib/message_hash/message_hash.js +84 -0
  44. package/dist/lib/message_hash/message_hash.js.map +1 -0
  45. package/dist/lib/metadata/metadata.js +6 -4
  46. package/dist/lib/metadata/metadata.js.map +1 -1
  47. package/dist/lib/store/rpc.js +16 -10
  48. package/dist/lib/store/rpc.js.map +1 -1
  49. package/dist/lib/store/store.d.ts +5 -5
  50. package/dist/lib/store/store.js +19 -9
  51. package/dist/lib/store/store.js.map +1 -1
  52. package/dist/lib/stream_manager/stream_manager.d.ts +3 -4
  53. package/dist/lib/stream_manager/stream_manager.js +6 -8
  54. package/dist/lib/stream_manager/stream_manager.js.map +1 -1
  55. package/package.json +1 -1
  56. package/src/index.ts +2 -0
  57. package/src/lib/connection_manager/connection_limiter.ts +161 -0
  58. package/src/lib/connection_manager/connection_manager.ts +87 -668
  59. package/src/lib/connection_manager/discovery_dialer.ts +195 -0
  60. package/src/lib/connection_manager/keep_alive_manager.ts +154 -87
  61. package/src/lib/connection_manager/network_monitor.ts +88 -0
  62. package/src/lib/connection_manager/shard_reader.ts +134 -0
  63. package/src/lib/connection_manager/utils.ts +27 -1
  64. package/src/lib/filter/filter.ts +26 -15
  65. package/src/lib/light_push/light_push.ts +9 -10
  66. package/src/lib/message/version_0.ts +3 -7
  67. package/src/lib/message_hash/index.ts +1 -0
  68. package/src/lib/message_hash/message_hash.ts +106 -0
  69. package/src/lib/metadata/metadata.ts +8 -5
  70. package/src/lib/store/rpc.ts +23 -19
  71. package/src/lib/store/store.ts +22 -11
  72. package/src/lib/stream_manager/stream_manager.ts +8 -6
  73. package/bundle/base_protocol-DvQrudwy.js +0 -152
  74. package/bundle/index-CTo1my9M.js +0 -1543
  75. package/bundle/lib/base_protocol.js +0 -2
  76. package/dist/lib/base_protocol.d.ts +0 -18
  77. package/dist/lib/base_protocol.js +0 -25
  78. package/dist/lib/base_protocol.js.map +0 -1
  79. package/src/lib/base_protocol.ts +0 -44
@@ -1,5 +1,3 @@
1
- import { g as base256emoji, h as base64, i as base58, j as base36, k as base32, l as base16, m as base10, n as base8, o as base2, p as identityBase, L as Logger } from './index-CTo1my9M.js';
2
-
3
1
  /**
4
2
  * Returns a `Uint8Array` of the requested size. Referenced memory will
5
3
  * be initialized to 0.
@@ -221,7 +219,7 @@ function decodeUint8ArrayList(buf, offset) {
221
219
  }
222
220
  throw new RangeError('Could not decode varint');
223
221
  }
224
- function encode(value, buf, offset = 0) {
222
+ function encode$2(value, buf, offset = 0) {
225
223
  if (buf == null) {
226
224
  buf = allocUnsafe(encodingLength(value));
227
225
  }
@@ -232,7 +230,7 @@ function encode(value, buf, offset = 0) {
232
230
  return encodeUint8ArrayList(value, buf, offset);
233
231
  }
234
232
  }
235
- function decode(buf, offset = 0) {
233
+ function decode$2(buf, offset = 0) {
236
234
  if (buf instanceof Uint8Array) {
237
235
  return decodeUint8Array(buf, offset);
238
236
  }
@@ -932,7 +930,660 @@ function decodeMessage(buf, codec, opts) {
932
930
  return codec.decode(reader, undefined, opts);
933
931
  }
934
932
 
935
- const bases = { ...identityBase, ...base2, ...base8, ...base10, ...base16, ...base32, ...base36, ...base58, ...base64, ...base256emoji };
933
+ function equals(aa, bb) {
934
+ if (aa === bb) {
935
+ return true;
936
+ }
937
+ if (aa.byteLength !== bb.byteLength) {
938
+ return false;
939
+ }
940
+ for (let ii = 0; ii < aa.byteLength; ii++) {
941
+ if (aa[ii] !== bb[ii]) {
942
+ return false;
943
+ }
944
+ }
945
+ return true;
946
+ }
947
+ function coerce(o) {
948
+ if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array') {
949
+ return o;
950
+ }
951
+ if (o instanceof ArrayBuffer) {
952
+ return new Uint8Array(o);
953
+ }
954
+ if (ArrayBuffer.isView(o)) {
955
+ return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
956
+ }
957
+ throw new Error('Unknown type, must be binary type');
958
+ }
959
+ function fromString$1(str) {
960
+ return new TextEncoder().encode(str);
961
+ }
962
+ function toString$1(b) {
963
+ return new TextDecoder().decode(b);
964
+ }
965
+
966
+ /* eslint-disable */
967
+ // base-x encoding / decoding
968
+ // Copyright (c) 2018 base-x contributors
969
+ // Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
970
+ // Distributed under the MIT software license, see the accompanying
971
+ // file LICENSE or http://www.opensource.org/licenses/mit-license.php.
972
+ /**
973
+ * @param {string} ALPHABET
974
+ * @param {any} name
975
+ */
976
+ function base(ALPHABET, name) {
977
+ if (ALPHABET.length >= 255) {
978
+ throw new TypeError('Alphabet too long');
979
+ }
980
+ var BASE_MAP = new Uint8Array(256);
981
+ for (var j = 0; j < BASE_MAP.length; j++) {
982
+ BASE_MAP[j] = 255;
983
+ }
984
+ for (var i = 0; i < ALPHABET.length; i++) {
985
+ var x = ALPHABET.charAt(i);
986
+ var xc = x.charCodeAt(0);
987
+ if (BASE_MAP[xc] !== 255) {
988
+ throw new TypeError(x + ' is ambiguous');
989
+ }
990
+ BASE_MAP[xc] = i;
991
+ }
992
+ var BASE = ALPHABET.length;
993
+ var LEADER = ALPHABET.charAt(0);
994
+ var FACTOR = Math.log(BASE) / Math.log(256); // log(BASE) / log(256), rounded up
995
+ var iFACTOR = Math.log(256) / Math.log(BASE); // log(256) / log(BASE), rounded up
996
+ /**
997
+ * @param {any[] | Iterable<number>} source
998
+ */
999
+ function encode(source) {
1000
+ // @ts-ignore
1001
+ if (source instanceof Uint8Array)
1002
+ ;
1003
+ else if (ArrayBuffer.isView(source)) {
1004
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
1005
+ }
1006
+ else if (Array.isArray(source)) {
1007
+ source = Uint8Array.from(source);
1008
+ }
1009
+ if (!(source instanceof Uint8Array)) {
1010
+ throw new TypeError('Expected Uint8Array');
1011
+ }
1012
+ if (source.length === 0) {
1013
+ return '';
1014
+ }
1015
+ // Skip & count leading zeroes.
1016
+ var zeroes = 0;
1017
+ var length = 0;
1018
+ var pbegin = 0;
1019
+ var pend = source.length;
1020
+ while (pbegin !== pend && source[pbegin] === 0) {
1021
+ pbegin++;
1022
+ zeroes++;
1023
+ }
1024
+ // Allocate enough space in big-endian base58 representation.
1025
+ var size = ((pend - pbegin) * iFACTOR + 1) >>> 0;
1026
+ var b58 = new Uint8Array(size);
1027
+ // Process the bytes.
1028
+ while (pbegin !== pend) {
1029
+ var carry = source[pbegin];
1030
+ // Apply "b58 = b58 * 256 + ch".
1031
+ var i = 0;
1032
+ for (var it1 = size - 1; (carry !== 0 || i < length) && (it1 !== -1); it1--, i++) {
1033
+ carry += (256 * b58[it1]) >>> 0;
1034
+ b58[it1] = (carry % BASE) >>> 0;
1035
+ carry = (carry / BASE) >>> 0;
1036
+ }
1037
+ if (carry !== 0) {
1038
+ throw new Error('Non-zero carry');
1039
+ }
1040
+ length = i;
1041
+ pbegin++;
1042
+ }
1043
+ // Skip leading zeroes in base58 result.
1044
+ var it2 = size - length;
1045
+ while (it2 !== size && b58[it2] === 0) {
1046
+ it2++;
1047
+ }
1048
+ // Translate the result into a string.
1049
+ var str = LEADER.repeat(zeroes);
1050
+ for (; it2 < size; ++it2) {
1051
+ str += ALPHABET.charAt(b58[it2]);
1052
+ }
1053
+ return str;
1054
+ }
1055
+ /**
1056
+ * @param {string | string[]} source
1057
+ */
1058
+ function decodeUnsafe(source) {
1059
+ if (typeof source !== 'string') {
1060
+ throw new TypeError('Expected String');
1061
+ }
1062
+ if (source.length === 0) {
1063
+ return new Uint8Array();
1064
+ }
1065
+ var psz = 0;
1066
+ // Skip leading spaces.
1067
+ if (source[psz] === ' ') {
1068
+ return;
1069
+ }
1070
+ // Skip and count leading '1's.
1071
+ var zeroes = 0;
1072
+ var length = 0;
1073
+ while (source[psz] === LEADER) {
1074
+ zeroes++;
1075
+ psz++;
1076
+ }
1077
+ // Allocate enough space in big-endian base256 representation.
1078
+ var size = (((source.length - psz) * FACTOR) + 1) >>> 0; // log(58) / log(256), rounded up.
1079
+ var b256 = new Uint8Array(size);
1080
+ // Process the characters.
1081
+ while (source[psz]) {
1082
+ // Decode character
1083
+ var carry = BASE_MAP[source.charCodeAt(psz)];
1084
+ // Invalid character
1085
+ if (carry === 255) {
1086
+ return;
1087
+ }
1088
+ var i = 0;
1089
+ for (var it3 = size - 1; (carry !== 0 || i < length) && (it3 !== -1); it3--, i++) {
1090
+ carry += (BASE * b256[it3]) >>> 0;
1091
+ b256[it3] = (carry % 256) >>> 0;
1092
+ carry = (carry / 256) >>> 0;
1093
+ }
1094
+ if (carry !== 0) {
1095
+ throw new Error('Non-zero carry');
1096
+ }
1097
+ length = i;
1098
+ psz++;
1099
+ }
1100
+ // Skip trailing spaces.
1101
+ if (source[psz] === ' ') {
1102
+ return;
1103
+ }
1104
+ // Skip leading zeroes in b256.
1105
+ var it4 = size - length;
1106
+ while (it4 !== size && b256[it4] === 0) {
1107
+ it4++;
1108
+ }
1109
+ var vch = new Uint8Array(zeroes + (size - it4));
1110
+ var j = zeroes;
1111
+ while (it4 !== size) {
1112
+ vch[j++] = b256[it4++];
1113
+ }
1114
+ return vch;
1115
+ }
1116
+ /**
1117
+ * @param {string | string[]} string
1118
+ */
1119
+ function decode(string) {
1120
+ var buffer = decodeUnsafe(string);
1121
+ if (buffer) {
1122
+ return buffer;
1123
+ }
1124
+ throw new Error(`Non-${name} character`);
1125
+ }
1126
+ return {
1127
+ encode: encode,
1128
+ decodeUnsafe: decodeUnsafe,
1129
+ decode: decode
1130
+ };
1131
+ }
1132
+ var src = base;
1133
+ var _brrp__multiformats_scope_baseX = src;
1134
+
1135
+ /**
1136
+ * Class represents both BaseEncoder and MultibaseEncoder meaning it
1137
+ * can be used to encode to multibase or base encode without multibase
1138
+ * prefix.
1139
+ */
1140
+ let Encoder$1 = class Encoder {
1141
+ name;
1142
+ prefix;
1143
+ baseEncode;
1144
+ constructor(name, prefix, baseEncode) {
1145
+ this.name = name;
1146
+ this.prefix = prefix;
1147
+ this.baseEncode = baseEncode;
1148
+ }
1149
+ encode(bytes) {
1150
+ if (bytes instanceof Uint8Array) {
1151
+ return `${this.prefix}${this.baseEncode(bytes)}`;
1152
+ }
1153
+ else {
1154
+ throw Error('Unknown type, must be binary type');
1155
+ }
1156
+ }
1157
+ };
1158
+ /**
1159
+ * Class represents both BaseDecoder and MultibaseDecoder so it could be used
1160
+ * to decode multibases (with matching prefix) or just base decode strings
1161
+ * with corresponding base encoding.
1162
+ */
1163
+ let Decoder$1 = class Decoder {
1164
+ name;
1165
+ prefix;
1166
+ baseDecode;
1167
+ prefixCodePoint;
1168
+ constructor(name, prefix, baseDecode) {
1169
+ this.name = name;
1170
+ this.prefix = prefix;
1171
+ const prefixCodePoint = prefix.codePointAt(0);
1172
+ /* c8 ignore next 3 */
1173
+ if (prefixCodePoint === undefined) {
1174
+ throw new Error('Invalid prefix character');
1175
+ }
1176
+ this.prefixCodePoint = prefixCodePoint;
1177
+ this.baseDecode = baseDecode;
1178
+ }
1179
+ decode(text) {
1180
+ if (typeof text === 'string') {
1181
+ if (text.codePointAt(0) !== this.prefixCodePoint) {
1182
+ throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
1183
+ }
1184
+ return this.baseDecode(text.slice(this.prefix.length));
1185
+ }
1186
+ else {
1187
+ throw Error('Can only multibase decode strings');
1188
+ }
1189
+ }
1190
+ or(decoder) {
1191
+ return or(this, decoder);
1192
+ }
1193
+ };
1194
+ class ComposedDecoder {
1195
+ decoders;
1196
+ constructor(decoders) {
1197
+ this.decoders = decoders;
1198
+ }
1199
+ or(decoder) {
1200
+ return or(this, decoder);
1201
+ }
1202
+ decode(input) {
1203
+ const prefix = input[0];
1204
+ const decoder = this.decoders[prefix];
1205
+ if (decoder != null) {
1206
+ return decoder.decode(input);
1207
+ }
1208
+ else {
1209
+ throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
1210
+ }
1211
+ }
1212
+ }
1213
+ function or(left, right) {
1214
+ return new ComposedDecoder({
1215
+ ...(left.decoders ?? { [left.prefix]: left }),
1216
+ ...(right.decoders ?? { [right.prefix]: right })
1217
+ });
1218
+ }
1219
+ class Codec {
1220
+ name;
1221
+ prefix;
1222
+ baseEncode;
1223
+ baseDecode;
1224
+ encoder;
1225
+ decoder;
1226
+ constructor(name, prefix, baseEncode, baseDecode) {
1227
+ this.name = name;
1228
+ this.prefix = prefix;
1229
+ this.baseEncode = baseEncode;
1230
+ this.baseDecode = baseDecode;
1231
+ this.encoder = new Encoder$1(name, prefix, baseEncode);
1232
+ this.decoder = new Decoder$1(name, prefix, baseDecode);
1233
+ }
1234
+ encode(input) {
1235
+ return this.encoder.encode(input);
1236
+ }
1237
+ decode(input) {
1238
+ return this.decoder.decode(input);
1239
+ }
1240
+ }
1241
+ function from({ name, prefix, encode, decode }) {
1242
+ return new Codec(name, prefix, encode, decode);
1243
+ }
1244
+ function baseX({ name, prefix, alphabet }) {
1245
+ const { encode, decode } = _brrp__multiformats_scope_baseX(alphabet, name);
1246
+ return from({
1247
+ prefix,
1248
+ name,
1249
+ encode,
1250
+ decode: (text) => coerce(decode(text))
1251
+ });
1252
+ }
1253
+ function decode$1(string, alphabetIdx, bitsPerChar, name) {
1254
+ // Count the padding bytes:
1255
+ let end = string.length;
1256
+ while (string[end - 1] === '=') {
1257
+ --end;
1258
+ }
1259
+ // Allocate the output:
1260
+ const out = new Uint8Array((end * bitsPerChar / 8) | 0);
1261
+ // Parse the data:
1262
+ let bits = 0; // Number of bits currently in the buffer
1263
+ let buffer = 0; // Bits waiting to be written out, MSB first
1264
+ let written = 0; // Next byte to write
1265
+ for (let i = 0; i < end; ++i) {
1266
+ // Read one character from the string:
1267
+ const value = alphabetIdx[string[i]];
1268
+ if (value === undefined) {
1269
+ throw new SyntaxError(`Non-${name} character`);
1270
+ }
1271
+ // Append the bits to the buffer:
1272
+ buffer = (buffer << bitsPerChar) | value;
1273
+ bits += bitsPerChar;
1274
+ // Write out some bits if the buffer has a byte's worth:
1275
+ if (bits >= 8) {
1276
+ bits -= 8;
1277
+ out[written++] = 0xff & (buffer >> bits);
1278
+ }
1279
+ }
1280
+ // Verify that we have received just enough bits:
1281
+ if (bits >= bitsPerChar || (0xff & (buffer << (8 - bits))) !== 0) {
1282
+ throw new SyntaxError('Unexpected end of data');
1283
+ }
1284
+ return out;
1285
+ }
1286
+ function encode$1(data, alphabet, bitsPerChar) {
1287
+ const pad = alphabet[alphabet.length - 1] === '=';
1288
+ const mask = (1 << bitsPerChar) - 1;
1289
+ let out = '';
1290
+ let bits = 0; // Number of bits currently in the buffer
1291
+ let buffer = 0; // Bits waiting to be written out, MSB first
1292
+ for (let i = 0; i < data.length; ++i) {
1293
+ // Slurp data into the buffer:
1294
+ buffer = (buffer << 8) | data[i];
1295
+ bits += 8;
1296
+ // Write out as much as we can:
1297
+ while (bits > bitsPerChar) {
1298
+ bits -= bitsPerChar;
1299
+ out += alphabet[mask & (buffer >> bits)];
1300
+ }
1301
+ }
1302
+ // Partial character:
1303
+ if (bits !== 0) {
1304
+ out += alphabet[mask & (buffer << (bitsPerChar - bits))];
1305
+ }
1306
+ // Add padding characters until we hit a byte boundary:
1307
+ if (pad) {
1308
+ while (((out.length * bitsPerChar) & 7) !== 0) {
1309
+ out += '=';
1310
+ }
1311
+ }
1312
+ return out;
1313
+ }
1314
+ function createAlphabetIdx(alphabet) {
1315
+ // Build the character lookup table:
1316
+ const alphabetIdx = {};
1317
+ for (let i = 0; i < alphabet.length; ++i) {
1318
+ alphabetIdx[alphabet[i]] = i;
1319
+ }
1320
+ return alphabetIdx;
1321
+ }
1322
+ /**
1323
+ * RFC4648 Factory
1324
+ */
1325
+ function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
1326
+ const alphabetIdx = createAlphabetIdx(alphabet);
1327
+ return from({
1328
+ prefix,
1329
+ name,
1330
+ encode(input) {
1331
+ return encode$1(input, alphabet, bitsPerChar);
1332
+ },
1333
+ decode(input) {
1334
+ return decode$1(input, alphabetIdx, bitsPerChar, name);
1335
+ }
1336
+ });
1337
+ }
1338
+
1339
+ const base10 = baseX({
1340
+ prefix: '9',
1341
+ name: 'base10',
1342
+ alphabet: '0123456789'
1343
+ });
1344
+
1345
+ var base10$1 = /*#__PURE__*/Object.freeze({
1346
+ __proto__: null,
1347
+ base10: base10
1348
+ });
1349
+
1350
+ const base16 = rfc4648({
1351
+ prefix: 'f',
1352
+ name: 'base16',
1353
+ alphabet: '0123456789abcdef',
1354
+ bitsPerChar: 4
1355
+ });
1356
+ const base16upper = rfc4648({
1357
+ prefix: 'F',
1358
+ name: 'base16upper',
1359
+ alphabet: '0123456789ABCDEF',
1360
+ bitsPerChar: 4
1361
+ });
1362
+
1363
+ var base16$1 = /*#__PURE__*/Object.freeze({
1364
+ __proto__: null,
1365
+ base16: base16,
1366
+ base16upper: base16upper
1367
+ });
1368
+
1369
+ const base2 = rfc4648({
1370
+ prefix: '0',
1371
+ name: 'base2',
1372
+ alphabet: '01',
1373
+ bitsPerChar: 1
1374
+ });
1375
+
1376
+ var base2$1 = /*#__PURE__*/Object.freeze({
1377
+ __proto__: null,
1378
+ base2: base2
1379
+ });
1380
+
1381
+ const alphabet = Array.from('🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂');
1382
+ const alphabetBytesToChars = (alphabet.reduce((p, c, i) => { p[i] = c; return p; }, ([])));
1383
+ const alphabetCharsToBytes = (alphabet.reduce((p, c, i) => {
1384
+ const codePoint = c.codePointAt(0);
1385
+ if (codePoint == null) {
1386
+ throw new Error(`Invalid character: ${c}`);
1387
+ }
1388
+ p[codePoint] = i;
1389
+ return p;
1390
+ }, ([])));
1391
+ function encode(data) {
1392
+ return data.reduce((p, c) => {
1393
+ p += alphabetBytesToChars[c];
1394
+ return p;
1395
+ }, '');
1396
+ }
1397
+ function decode(str) {
1398
+ const byts = [];
1399
+ for (const char of str) {
1400
+ const codePoint = char.codePointAt(0);
1401
+ if (codePoint == null) {
1402
+ throw new Error(`Invalid character: ${char}`);
1403
+ }
1404
+ const byt = alphabetCharsToBytes[codePoint];
1405
+ if (byt == null) {
1406
+ throw new Error(`Non-base256emoji character: ${char}`);
1407
+ }
1408
+ byts.push(byt);
1409
+ }
1410
+ return new Uint8Array(byts);
1411
+ }
1412
+ const base256emoji = from({
1413
+ prefix: '🚀',
1414
+ name: 'base256emoji',
1415
+ encode,
1416
+ decode
1417
+ });
1418
+
1419
+ var base256emoji$1 = /*#__PURE__*/Object.freeze({
1420
+ __proto__: null,
1421
+ base256emoji: base256emoji
1422
+ });
1423
+
1424
+ const base32 = rfc4648({
1425
+ prefix: 'b',
1426
+ name: 'base32',
1427
+ alphabet: 'abcdefghijklmnopqrstuvwxyz234567',
1428
+ bitsPerChar: 5
1429
+ });
1430
+ const base32upper = rfc4648({
1431
+ prefix: 'B',
1432
+ name: 'base32upper',
1433
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567',
1434
+ bitsPerChar: 5
1435
+ });
1436
+ const base32pad = rfc4648({
1437
+ prefix: 'c',
1438
+ name: 'base32pad',
1439
+ alphabet: 'abcdefghijklmnopqrstuvwxyz234567=',
1440
+ bitsPerChar: 5
1441
+ });
1442
+ const base32padupper = rfc4648({
1443
+ prefix: 'C',
1444
+ name: 'base32padupper',
1445
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=',
1446
+ bitsPerChar: 5
1447
+ });
1448
+ const base32hex = rfc4648({
1449
+ prefix: 'v',
1450
+ name: 'base32hex',
1451
+ alphabet: '0123456789abcdefghijklmnopqrstuv',
1452
+ bitsPerChar: 5
1453
+ });
1454
+ const base32hexupper = rfc4648({
1455
+ prefix: 'V',
1456
+ name: 'base32hexupper',
1457
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV',
1458
+ bitsPerChar: 5
1459
+ });
1460
+ const base32hexpad = rfc4648({
1461
+ prefix: 't',
1462
+ name: 'base32hexpad',
1463
+ alphabet: '0123456789abcdefghijklmnopqrstuv=',
1464
+ bitsPerChar: 5
1465
+ });
1466
+ const base32hexpadupper = rfc4648({
1467
+ prefix: 'T',
1468
+ name: 'base32hexpadupper',
1469
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUV=',
1470
+ bitsPerChar: 5
1471
+ });
1472
+ const base32z = rfc4648({
1473
+ prefix: 'h',
1474
+ name: 'base32z',
1475
+ alphabet: 'ybndrfg8ejkmcpqxot1uwisza345h769',
1476
+ bitsPerChar: 5
1477
+ });
1478
+
1479
+ var base32$1 = /*#__PURE__*/Object.freeze({
1480
+ __proto__: null,
1481
+ base32: base32,
1482
+ base32hex: base32hex,
1483
+ base32hexpad: base32hexpad,
1484
+ base32hexpadupper: base32hexpadupper,
1485
+ base32hexupper: base32hexupper,
1486
+ base32pad: base32pad,
1487
+ base32padupper: base32padupper,
1488
+ base32upper: base32upper,
1489
+ base32z: base32z
1490
+ });
1491
+
1492
+ const base36 = baseX({
1493
+ prefix: 'k',
1494
+ name: 'base36',
1495
+ alphabet: '0123456789abcdefghijklmnopqrstuvwxyz'
1496
+ });
1497
+ const base36upper = baseX({
1498
+ prefix: 'K',
1499
+ name: 'base36upper',
1500
+ alphabet: '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
1501
+ });
1502
+
1503
+ var base36$1 = /*#__PURE__*/Object.freeze({
1504
+ __proto__: null,
1505
+ base36: base36,
1506
+ base36upper: base36upper
1507
+ });
1508
+
1509
+ const base58btc = baseX({
1510
+ name: 'base58btc',
1511
+ prefix: 'z',
1512
+ alphabet: '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
1513
+ });
1514
+ const base58flickr = baseX({
1515
+ name: 'base58flickr',
1516
+ prefix: 'Z',
1517
+ alphabet: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
1518
+ });
1519
+
1520
+ var base58 = /*#__PURE__*/Object.freeze({
1521
+ __proto__: null,
1522
+ base58btc: base58btc,
1523
+ base58flickr: base58flickr
1524
+ });
1525
+
1526
+ const base64 = rfc4648({
1527
+ prefix: 'm',
1528
+ name: 'base64',
1529
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
1530
+ bitsPerChar: 6
1531
+ });
1532
+ const base64pad = rfc4648({
1533
+ prefix: 'M',
1534
+ name: 'base64pad',
1535
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
1536
+ bitsPerChar: 6
1537
+ });
1538
+ const base64url = rfc4648({
1539
+ prefix: 'u',
1540
+ name: 'base64url',
1541
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_',
1542
+ bitsPerChar: 6
1543
+ });
1544
+ const base64urlpad = rfc4648({
1545
+ prefix: 'U',
1546
+ name: 'base64urlpad',
1547
+ alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=',
1548
+ bitsPerChar: 6
1549
+ });
1550
+
1551
+ var base64$1 = /*#__PURE__*/Object.freeze({
1552
+ __proto__: null,
1553
+ base64: base64,
1554
+ base64pad: base64pad,
1555
+ base64url: base64url,
1556
+ base64urlpad: base64urlpad
1557
+ });
1558
+
1559
+ const base8 = rfc4648({
1560
+ prefix: '7',
1561
+ name: 'base8',
1562
+ alphabet: '01234567',
1563
+ bitsPerChar: 3
1564
+ });
1565
+
1566
+ var base8$1 = /*#__PURE__*/Object.freeze({
1567
+ __proto__: null,
1568
+ base8: base8
1569
+ });
1570
+
1571
+ const identity = from({
1572
+ prefix: '\x00',
1573
+ name: 'identity',
1574
+ encode: (buf) => toString$1(buf),
1575
+ decode: (str) => fromString$1(str)
1576
+ });
1577
+
1578
+ var identityBase = /*#__PURE__*/Object.freeze({
1579
+ __proto__: null,
1580
+ identity: identity
1581
+ });
1582
+
1583
+ new TextEncoder();
1584
+ new TextDecoder();
1585
+
1586
+ const bases = { ...identityBase, ...base2$1, ...base8$1, ...base10$1, ...base16$1, ...base32$1, ...base36$1, ...base58, ...base64$1, ...base256emoji$1 };
936
1587
 
937
1588
  function createCodec$1(name, prefix, encode, decode) {
938
1589
  return {
@@ -1530,6 +2181,8 @@ class MaxLengthError extends Error {
1530
2181
  /* eslint-disable @typescript-eslint/no-namespace */
1531
2182
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
1532
2183
  /* eslint-disable @typescript-eslint/no-empty-interface */
2184
+ /* eslint-disable import/consistent-type-specifier-style */
2185
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1533
2186
  var RateLimitProof$4;
1534
2187
  (function (RateLimitProof) {
1535
2188
  let _codec;
@@ -1739,6 +2392,8 @@ var message = /*#__PURE__*/Object.freeze({
1739
2392
  /* eslint-disable @typescript-eslint/no-namespace */
1740
2393
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
1741
2394
  /* eslint-disable @typescript-eslint/no-empty-interface */
2395
+ /* eslint-disable import/consistent-type-specifier-style */
2396
+ /* eslint-disable @typescript-eslint/no-unused-vars */
1742
2397
  var FilterRequest;
1743
2398
  (function (FilterRequest) {
1744
2399
  (function (ContentFilter) {
@@ -2177,6 +2832,8 @@ var WakuMessage$3;
2177
2832
  /* eslint-disable @typescript-eslint/no-namespace */
2178
2833
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
2179
2834
  /* eslint-disable @typescript-eslint/no-empty-interface */
2835
+ /* eslint-disable import/consistent-type-specifier-style */
2836
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2180
2837
  var TopicOnlyMessage;
2181
2838
  (function (TopicOnlyMessage) {
2182
2839
  let _codec;
@@ -2229,6 +2886,8 @@ var TopicOnlyMessage;
2229
2886
  /* eslint-disable @typescript-eslint/no-namespace */
2230
2887
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
2231
2888
  /* eslint-disable @typescript-eslint/no-empty-interface */
2889
+ /* eslint-disable import/consistent-type-specifier-style */
2890
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2232
2891
  var FilterSubscribeRequest;
2233
2892
  (function (FilterSubscribeRequest) {
2234
2893
  let FilterSubscribeType;
@@ -2645,6 +3304,8 @@ var WakuMessage$2;
2645
3304
  /* eslint-disable @typescript-eslint/no-namespace */
2646
3305
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
2647
3306
  /* eslint-disable @typescript-eslint/no-empty-interface */
3307
+ /* eslint-disable import/consistent-type-specifier-style */
3308
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2648
3309
  var PushRequest;
2649
3310
  (function (PushRequest) {
2650
3311
  let _codec;
@@ -3024,6 +3685,8 @@ var WakuMessage$1;
3024
3685
  /* eslint-disable @typescript-eslint/no-namespace */
3025
3686
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
3026
3687
  /* eslint-disable @typescript-eslint/no-empty-interface */
3688
+ /* eslint-disable import/consistent-type-specifier-style */
3689
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3027
3690
  var WakuMessageKeyValue;
3028
3691
  (function (WakuMessageKeyValue) {
3029
3692
  let _codec;
@@ -3507,6 +4170,8 @@ var WakuMessage;
3507
4170
  /* eslint-disable @typescript-eslint/no-namespace */
3508
4171
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
3509
4172
  /* eslint-disable @typescript-eslint/no-empty-interface */
4173
+ /* eslint-disable import/consistent-type-specifier-style */
4174
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3510
4175
  var PeerInfo;
3511
4176
  (function (PeerInfo) {
3512
4177
  let _codec;
@@ -3710,6 +4375,8 @@ var PeerExchangeRPC;
3710
4375
  /* eslint-disable @typescript-eslint/no-namespace */
3711
4376
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
3712
4377
  /* eslint-disable @typescript-eslint/no-empty-interface */
4378
+ /* eslint-disable import/consistent-type-specifier-style */
4379
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3713
4380
  var WakuMetadataRequest;
3714
4381
  (function (WakuMetadataRequest) {
3715
4382
  let _codec;
@@ -3834,6 +4501,8 @@ var WakuMetadataResponse;
3834
4501
  /* eslint-disable @typescript-eslint/no-namespace */
3835
4502
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
3836
4503
  /* eslint-disable @typescript-eslint/no-empty-interface */
4504
+ /* eslint-disable import/consistent-type-specifier-style */
4505
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3837
4506
  var HistoryEntry;
3838
4507
  (function (HistoryEntry) {
3839
4508
  let _codec;
@@ -3984,6 +4653,8 @@ var SdsMessage;
3984
4653
  };
3985
4654
  })(SdsMessage || (SdsMessage = {}));
3986
4655
 
4656
+ const crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
4657
+
3987
4658
  /**
3988
4659
  * Utilities for hex, bytes, CSPRNG.
3989
4660
  * @module
@@ -3999,6 +4670,11 @@ var SdsMessage;
3999
4670
  function isBytes(a) {
4000
4671
  return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
4001
4672
  }
4673
+ /** Asserts something is positive integer. */
4674
+ function anumber(n) {
4675
+ if (!Number.isSafeInteger(n) || n < 0)
4676
+ throw new Error('positive integer expected, got ' + n);
4677
+ }
4002
4678
  /** Asserts something is Uint8Array. */
4003
4679
  function abytes(b, ...lengths) {
4004
4680
  if (!isBytes(b))
@@ -4006,6 +4682,13 @@ function abytes(b, ...lengths) {
4006
4682
  if (lengths.length > 0 && !lengths.includes(b.length))
4007
4683
  throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
4008
4684
  }
4685
+ /** Asserts something is hash */
4686
+ function ahash(h) {
4687
+ if (typeof h !== 'function' || typeof h.create !== 'function')
4688
+ throw new Error('Hash should be wrapped by utils.createHasher');
4689
+ anumber(h.outputLen);
4690
+ anumber(h.blockLen);
4691
+ }
4009
4692
  /** Asserts a hash instance has not been destroyed / finished */
4010
4693
  function aexists(instance, checkFinished = true) {
4011
4694
  if (instance.destroyed)
@@ -4035,6 +4718,65 @@ function createView(arr) {
4035
4718
  function rotr(word, shift) {
4036
4719
  return (word << (32 - shift)) | (word >>> shift);
4037
4720
  }
4721
+ // Built-in hex conversion https://caniuse.com/mdn-javascript_builtins_uint8array_fromhex
4722
+ const hasHexBuiltin = /* @__PURE__ */ (() =>
4723
+ // @ts-ignore
4724
+ typeof Uint8Array.from([]).toHex === 'function' && typeof Uint8Array.fromHex === 'function')();
4725
+ // Array where index 0xf0 (240) is mapped to string 'f0'
4726
+ const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, '0'));
4727
+ /**
4728
+ * Convert byte array to hex string. Uses built-in function, when available.
4729
+ * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
4730
+ */
4731
+ function bytesToHex$1(bytes) {
4732
+ abytes(bytes);
4733
+ // @ts-ignore
4734
+ if (hasHexBuiltin)
4735
+ return bytes.toHex();
4736
+ // pre-caching improves the speed 6x
4737
+ let hex = '';
4738
+ for (let i = 0; i < bytes.length; i++) {
4739
+ hex += hexes[bytes[i]];
4740
+ }
4741
+ return hex;
4742
+ }
4743
+ // We use optimized technique to convert hex string to byte array
4744
+ const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
4745
+ function asciiToBase16(ch) {
4746
+ if (ch >= asciis._0 && ch <= asciis._9)
4747
+ return ch - asciis._0; // '2' => 50-48
4748
+ if (ch >= asciis.A && ch <= asciis.F)
4749
+ return ch - (asciis.A - 10); // 'B' => 66-(65-10)
4750
+ if (ch >= asciis.a && ch <= asciis.f)
4751
+ return ch - (asciis.a - 10); // 'b' => 98-(97-10)
4752
+ return;
4753
+ }
4754
+ /**
4755
+ * Convert hex string to byte array. Uses built-in function, when available.
4756
+ * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
4757
+ */
4758
+ function hexToBytes(hex) {
4759
+ if (typeof hex !== 'string')
4760
+ throw new Error('hex string expected, got ' + typeof hex);
4761
+ // @ts-ignore
4762
+ if (hasHexBuiltin)
4763
+ return Uint8Array.fromHex(hex);
4764
+ const hl = hex.length;
4765
+ const al = hl / 2;
4766
+ if (hl % 2)
4767
+ throw new Error('hex string expected, got unpadded hex of length ' + hl);
4768
+ const array = new Uint8Array(al);
4769
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
4770
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
4771
+ const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
4772
+ if (n1 === undefined || n2 === undefined) {
4773
+ const char = hex[hi] + hex[hi + 1];
4774
+ throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
4775
+ }
4776
+ array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163
4777
+ }
4778
+ return array;
4779
+ }
4038
4780
  /**
4039
4781
  * Converts string to bytes using UTF8 encoding.
4040
4782
  * @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
@@ -4055,6 +4797,22 @@ function toBytes(data) {
4055
4797
  abytes(data);
4056
4798
  return data;
4057
4799
  }
4800
+ /** Copies several Uint8Arrays into one. */
4801
+ function concatBytes(...arrays) {
4802
+ let sum = 0;
4803
+ for (let i = 0; i < arrays.length; i++) {
4804
+ const a = arrays[i];
4805
+ abytes(a);
4806
+ sum += a.length;
4807
+ }
4808
+ const res = new Uint8Array(sum);
4809
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
4810
+ const a = arrays[i];
4811
+ res.set(a, pad);
4812
+ pad += a.length;
4813
+ }
4814
+ return res;
4815
+ }
4058
4816
  /** For runtime check if class implements interface */
4059
4817
  class Hash {
4060
4818
  }
@@ -4067,6 +4825,17 @@ function createHasher(hashCons) {
4067
4825
  hashC.create = () => hashCons();
4068
4826
  return hashC;
4069
4827
  }
4828
+ /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
4829
+ function randomBytes(bytesLength = 32) {
4830
+ if (crypto && typeof crypto.getRandomValues === 'function') {
4831
+ return crypto.getRandomValues(new Uint8Array(bytesLength));
4832
+ }
4833
+ // Legacy Node.js compatibility
4834
+ if (crypto && typeof crypto.randomBytes === 'function') {
4835
+ return Uint8Array.from(crypto.randomBytes(bytesLength));
4836
+ }
4837
+ throw new Error('crypto.getRandomValues must be defined');
4838
+ }
4070
4839
 
4071
4840
  /**
4072
4841
  * Internal Merkle-Damgard hash utils.
@@ -4207,6 +4976,56 @@ class HashMD extends Hash {
4207
4976
  const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
4208
4977
  0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
4209
4978
  ]);
4979
+ /** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */
4980
+ const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
4981
+ 0x6a09e667, 0xf3bcc908, 0xbb67ae85, 0x84caa73b, 0x3c6ef372, 0xfe94f82b, 0xa54ff53a, 0x5f1d36f1,
4982
+ 0x510e527f, 0xade682d1, 0x9b05688c, 0x2b3e6c1f, 0x1f83d9ab, 0xfb41bd6b, 0x5be0cd19, 0x137e2179,
4983
+ ]);
4984
+
4985
+ /**
4986
+ * Internal helpers for u64. BigUint64Array is too slow as per 2025, so we implement it using Uint32Array.
4987
+ * @todo re-check https://issues.chromium.org/issues/42212588
4988
+ * @module
4989
+ */
4990
+ const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
4991
+ const _32n = /* @__PURE__ */ BigInt(32);
4992
+ function fromBig(n, le = false) {
4993
+ if (le)
4994
+ return { h: Number(n & U32_MASK64), l: Number((n >> _32n) & U32_MASK64) };
4995
+ return { h: Number((n >> _32n) & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
4996
+ }
4997
+ function split(lst, le = false) {
4998
+ const len = lst.length;
4999
+ let Ah = new Uint32Array(len);
5000
+ let Al = new Uint32Array(len);
5001
+ for (let i = 0; i < len; i++) {
5002
+ const { h, l } = fromBig(lst[i], le);
5003
+ [Ah[i], Al[i]] = [h, l];
5004
+ }
5005
+ return [Ah, Al];
5006
+ }
5007
+ // for Shift in [0, 32)
5008
+ const shrSH = (h, _l, s) => h >>> s;
5009
+ const shrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
5010
+ // Right rotate for Shift in [1, 32)
5011
+ const rotrSH = (h, l, s) => (h >>> s) | (l << (32 - s));
5012
+ const rotrSL = (h, l, s) => (h << (32 - s)) | (l >>> s);
5013
+ // Right rotate for Shift in (32, 64), NOTE: 32 is special case.
5014
+ const rotrBH = (h, l, s) => (h << (64 - s)) | (l >>> (s - 32));
5015
+ const rotrBL = (h, l, s) => (h >>> (s - 32)) | (l << (64 - s));
5016
+ // JS uses 32-bit signed integers for bitwise operations which means we cannot
5017
+ // simple take carry out of low bit sum by shift, we need to use division.
5018
+ function add(Ah, Al, Bh, Bl) {
5019
+ const l = (Al >>> 0) + (Bl >>> 0);
5020
+ return { h: (Ah + Bh + ((l / 2 ** 32) | 0)) | 0, l: l | 0 };
5021
+ }
5022
+ // Addition with more than 2 elements
5023
+ const add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
5024
+ const add3H = (low, Ah, Bh, Ch) => (Ah + Bh + Ch + ((low / 2 ** 32) | 0)) | 0;
5025
+ const add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
5026
+ const add4H = (low, Ah, Bh, Ch, Dh) => (Ah + Bh + Ch + Dh + ((low / 2 ** 32) | 0)) | 0;
5027
+ const add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
5028
+ const add5H = (low, Ah, Bh, Ch, Dh, Eh) => (Ah + Bh + Ch + Dh + Eh + ((low / 2 ** 32) | 0)) | 0;
4210
5029
 
4211
5030
  /**
4212
5031
  * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
@@ -4307,6 +5126,162 @@ class SHA256 extends HashMD {
4307
5126
  clean(this.buffer);
4308
5127
  }
4309
5128
  }
5129
+ // SHA2-512 is slower than sha256 in js because u64 operations are slow.
5130
+ // Round contants
5131
+ // First 32 bits of the fractional parts of the cube roots of the first 80 primes 2..409
5132
+ // prettier-ignore
5133
+ const K512 = /* @__PURE__ */ (() => split([
5134
+ '0x428a2f98d728ae22', '0x7137449123ef65cd', '0xb5c0fbcfec4d3b2f', '0xe9b5dba58189dbbc',
5135
+ '0x3956c25bf348b538', '0x59f111f1b605d019', '0x923f82a4af194f9b', '0xab1c5ed5da6d8118',
5136
+ '0xd807aa98a3030242', '0x12835b0145706fbe', '0x243185be4ee4b28c', '0x550c7dc3d5ffb4e2',
5137
+ '0x72be5d74f27b896f', '0x80deb1fe3b1696b1', '0x9bdc06a725c71235', '0xc19bf174cf692694',
5138
+ '0xe49b69c19ef14ad2', '0xefbe4786384f25e3', '0x0fc19dc68b8cd5b5', '0x240ca1cc77ac9c65',
5139
+ '0x2de92c6f592b0275', '0x4a7484aa6ea6e483', '0x5cb0a9dcbd41fbd4', '0x76f988da831153b5',
5140
+ '0x983e5152ee66dfab', '0xa831c66d2db43210', '0xb00327c898fb213f', '0xbf597fc7beef0ee4',
5141
+ '0xc6e00bf33da88fc2', '0xd5a79147930aa725', '0x06ca6351e003826f', '0x142929670a0e6e70',
5142
+ '0x27b70a8546d22ffc', '0x2e1b21385c26c926', '0x4d2c6dfc5ac42aed', '0x53380d139d95b3df',
5143
+ '0x650a73548baf63de', '0x766a0abb3c77b2a8', '0x81c2c92e47edaee6', '0x92722c851482353b',
5144
+ '0xa2bfe8a14cf10364', '0xa81a664bbc423001', '0xc24b8b70d0f89791', '0xc76c51a30654be30',
5145
+ '0xd192e819d6ef5218', '0xd69906245565a910', '0xf40e35855771202a', '0x106aa07032bbd1b8',
5146
+ '0x19a4c116b8d2d0c8', '0x1e376c085141ab53', '0x2748774cdf8eeb99', '0x34b0bcb5e19b48a8',
5147
+ '0x391c0cb3c5c95a63', '0x4ed8aa4ae3418acb', '0x5b9cca4f7763e373', '0x682e6ff3d6b2b8a3',
5148
+ '0x748f82ee5defb2fc', '0x78a5636f43172f60', '0x84c87814a1f0ab72', '0x8cc702081a6439ec',
5149
+ '0x90befffa23631e28', '0xa4506cebde82bde9', '0xbef9a3f7b2c67915', '0xc67178f2e372532b',
5150
+ '0xca273eceea26619c', '0xd186b8c721c0c207', '0xeada7dd6cde0eb1e', '0xf57d4f7fee6ed178',
5151
+ '0x06f067aa72176fba', '0x0a637dc5a2c898a6', '0x113f9804bef90dae', '0x1b710b35131c471b',
5152
+ '0x28db77f523047d84', '0x32caab7b40c72493', '0x3c9ebe0a15c9bebc', '0x431d67c49c100d4c',
5153
+ '0x4cc5d4becb3e42b6', '0x597f299cfc657e2a', '0x5fcb6fab3ad6faec', '0x6c44198c4a475817'
5154
+ ].map(n => BigInt(n))))();
5155
+ const SHA512_Kh = /* @__PURE__ */ (() => K512[0])();
5156
+ const SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
5157
+ // Reusable temporary buffers
5158
+ const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
5159
+ const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
5160
+ class SHA512 extends HashMD {
5161
+ constructor(outputLen = 64) {
5162
+ super(128, outputLen, 16, false);
5163
+ // We cannot use array here since array allows indexing by variable
5164
+ // which means optimizer/compiler cannot use registers.
5165
+ // h -- high 32 bits, l -- low 32 bits
5166
+ this.Ah = SHA512_IV[0] | 0;
5167
+ this.Al = SHA512_IV[1] | 0;
5168
+ this.Bh = SHA512_IV[2] | 0;
5169
+ this.Bl = SHA512_IV[3] | 0;
5170
+ this.Ch = SHA512_IV[4] | 0;
5171
+ this.Cl = SHA512_IV[5] | 0;
5172
+ this.Dh = SHA512_IV[6] | 0;
5173
+ this.Dl = SHA512_IV[7] | 0;
5174
+ this.Eh = SHA512_IV[8] | 0;
5175
+ this.El = SHA512_IV[9] | 0;
5176
+ this.Fh = SHA512_IV[10] | 0;
5177
+ this.Fl = SHA512_IV[11] | 0;
5178
+ this.Gh = SHA512_IV[12] | 0;
5179
+ this.Gl = SHA512_IV[13] | 0;
5180
+ this.Hh = SHA512_IV[14] | 0;
5181
+ this.Hl = SHA512_IV[15] | 0;
5182
+ }
5183
+ // prettier-ignore
5184
+ get() {
5185
+ const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
5186
+ return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
5187
+ }
5188
+ // prettier-ignore
5189
+ set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
5190
+ this.Ah = Ah | 0;
5191
+ this.Al = Al | 0;
5192
+ this.Bh = Bh | 0;
5193
+ this.Bl = Bl | 0;
5194
+ this.Ch = Ch | 0;
5195
+ this.Cl = Cl | 0;
5196
+ this.Dh = Dh | 0;
5197
+ this.Dl = Dl | 0;
5198
+ this.Eh = Eh | 0;
5199
+ this.El = El | 0;
5200
+ this.Fh = Fh | 0;
5201
+ this.Fl = Fl | 0;
5202
+ this.Gh = Gh | 0;
5203
+ this.Gl = Gl | 0;
5204
+ this.Hh = Hh | 0;
5205
+ this.Hl = Hl | 0;
5206
+ }
5207
+ process(view, offset) {
5208
+ // Extend the first 16 words into the remaining 64 words w[16..79] of the message schedule array
5209
+ for (let i = 0; i < 16; i++, offset += 4) {
5210
+ SHA512_W_H[i] = view.getUint32(offset);
5211
+ SHA512_W_L[i] = view.getUint32((offset += 4));
5212
+ }
5213
+ for (let i = 16; i < 80; i++) {
5214
+ // s0 := (w[i-15] rightrotate 1) xor (w[i-15] rightrotate 8) xor (w[i-15] rightshift 7)
5215
+ const W15h = SHA512_W_H[i - 15] | 0;
5216
+ const W15l = SHA512_W_L[i - 15] | 0;
5217
+ const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
5218
+ const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
5219
+ // s1 := (w[i-2] rightrotate 19) xor (w[i-2] rightrotate 61) xor (w[i-2] rightshift 6)
5220
+ const W2h = SHA512_W_H[i - 2] | 0;
5221
+ const W2l = SHA512_W_L[i - 2] | 0;
5222
+ const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
5223
+ const s1l = rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6);
5224
+ // SHA256_W[i] = s0 + s1 + SHA256_W[i - 7] + SHA256_W[i - 16];
5225
+ const SUMl = add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
5226
+ const SUMh = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
5227
+ SHA512_W_H[i] = SUMh | 0;
5228
+ SHA512_W_L[i] = SUMl | 0;
5229
+ }
5230
+ let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
5231
+ // Compression function main loop, 80 rounds
5232
+ for (let i = 0; i < 80; i++) {
5233
+ // S1 := (e rightrotate 14) xor (e rightrotate 18) xor (e rightrotate 41)
5234
+ const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
5235
+ const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
5236
+ //const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
5237
+ const CHIh = (Eh & Fh) ^ (~Eh & Gh);
5238
+ const CHIl = (El & Fl) ^ (~El & Gl);
5239
+ // T1 = H + sigma1 + Chi(E, F, G) + SHA512_K[i] + SHA512_W[i]
5240
+ // prettier-ignore
5241
+ const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
5242
+ const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
5243
+ const T1l = T1ll | 0;
5244
+ // S0 := (a rightrotate 28) xor (a rightrotate 34) xor (a rightrotate 39)
5245
+ const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
5246
+ const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
5247
+ const MAJh = (Ah & Bh) ^ (Ah & Ch) ^ (Bh & Ch);
5248
+ const MAJl = (Al & Bl) ^ (Al & Cl) ^ (Bl & Cl);
5249
+ Hh = Gh | 0;
5250
+ Hl = Gl | 0;
5251
+ Gh = Fh | 0;
5252
+ Gl = Fl | 0;
5253
+ Fh = Eh | 0;
5254
+ Fl = El | 0;
5255
+ ({ h: Eh, l: El } = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
5256
+ Dh = Ch | 0;
5257
+ Dl = Cl | 0;
5258
+ Ch = Bh | 0;
5259
+ Cl = Bl | 0;
5260
+ Bh = Ah | 0;
5261
+ Bl = Al | 0;
5262
+ const All = add3L(T1l, sigma0l, MAJl);
5263
+ Ah = add3H(All, T1h, sigma0h, MAJh);
5264
+ Al = All | 0;
5265
+ }
5266
+ // Add the compressed chunk to the current hash value
5267
+ ({ h: Ah, l: Al } = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
5268
+ ({ h: Bh, l: Bl } = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
5269
+ ({ h: Ch, l: Cl } = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
5270
+ ({ h: Dh, l: Dl } = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
5271
+ ({ h: Eh, l: El } = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
5272
+ ({ h: Fh, l: Fl } = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
5273
+ ({ h: Gh, l: Gl } = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
5274
+ ({ h: Hh, l: Hl } = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
5275
+ this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
5276
+ }
5277
+ roundClean() {
5278
+ clean(SHA512_W_H, SHA512_W_L);
5279
+ }
5280
+ destroy() {
5281
+ clean(this.buffer);
5282
+ this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
5283
+ }
5284
+ }
4310
5285
  /**
4311
5286
  * SHA2-256 hash function from RFC 4634.
4312
5287
  *
@@ -4315,6 +5290,8 @@ class SHA256 extends HashMD {
4315
5290
  * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
4316
5291
  */
4317
5292
  const sha256$1 = /* @__PURE__ */ createHasher(() => new SHA256());
5293
+ /** SHA2-512 hash function from RFC 4634. */
5294
+ const sha512 = /* @__PURE__ */ createHasher(() => new SHA512());
4318
5295
 
4319
5296
  /**
4320
5297
  * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
@@ -4329,11 +5306,120 @@ const sha256$1 = /* @__PURE__ */ createHasher(() => new SHA256());
4329
5306
  /** @deprecated Use import from `noble/hashes/sha2` module */
4330
5307
  const sha256 = sha256$1;
4331
5308
 
5309
+ var Protocols;
5310
+ (function (Protocols) {
5311
+ Protocols["Relay"] = "relay";
5312
+ Protocols["Store"] = "store";
5313
+ Protocols["LightPush"] = "lightpush";
5314
+ Protocols["Filter"] = "filter";
5315
+ })(Protocols || (Protocols = {}));
5316
+ var ProtocolError;
5317
+ (function (ProtocolError) {
5318
+ //
5319
+ // GENERAL ERRORS SECTION
5320
+ //
5321
+ /**
5322
+ * Could not determine the origin of the fault. Best to check connectivity and try again
5323
+ * */
5324
+ ProtocolError["GENERIC_FAIL"] = "Generic error";
5325
+ /**
5326
+ * The remote peer rejected the message. Information provided by the remote peer
5327
+ * is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
5328
+ * or `DECODE_FAILED` can be used.
5329
+ */
5330
+ ProtocolError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
5331
+ /**
5332
+ * Failure to protobuf decode the message. May be due to a remote peer issue,
5333
+ * ensuring that messages are sent via several peer enable mitigation of this error.
5334
+ */
5335
+ ProtocolError["DECODE_FAILED"] = "Failed to decode";
5336
+ /**
5337
+ * Failure to find a peer with suitable protocols. This may due to a connection issue.
5338
+ * Mitigation can be: retrying after a given time period, display connectivity issue
5339
+ * to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`
5340
+ * on the connection manager before retrying.
5341
+ */
5342
+ ProtocolError["NO_PEER_AVAILABLE"] = "No peer available";
5343
+ /**
5344
+ * Failure to find a stream to the peer. This may be because the connection with the peer is not still alive.
5345
+ * Mitigation can be: retrying after a given time period, or mitigation for `NO_PEER_AVAILABLE` can be used.
5346
+ */
5347
+ ProtocolError["NO_STREAM_AVAILABLE"] = "No stream available";
5348
+ /**
5349
+ * The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
5350
+ * or `DECODE_FAILED` can be used.
5351
+ */
5352
+ ProtocolError["NO_RESPONSE"] = "No response received";
5353
+ //
5354
+ // SEND ERRORS SECTION
5355
+ //
5356
+ /**
5357
+ * Failure to protobuf encode the message. This is not recoverable and needs
5358
+ * further investigation.
5359
+ */
5360
+ ProtocolError["ENCODE_FAILED"] = "Failed to encode";
5361
+ /**
5362
+ * The message payload is empty, making the message invalid. Ensure that a non-empty
5363
+ * payload is set on the outgoing message.
5364
+ */
5365
+ ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
5366
+ /**
5367
+ * The message size is above the maximum message size allowed on the Waku Network.
5368
+ * Compressing the message or using an alternative strategy for large messages is recommended.
5369
+ */
5370
+ ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
5371
+ /**
5372
+ * The PubsubTopic passed to the send function is not configured on the Waku node.
5373
+ * Please ensure that the PubsubTopic is used when initializing the Waku node.
5374
+ */
5375
+ ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
5376
+ /**
5377
+ * Fails when
5378
+ */
5379
+ ProtocolError["STREAM_ABORTED"] = "Stream aborted";
5380
+ /**
5381
+ * General proof generation error message.
5382
+ * nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
5383
+ */
5384
+ ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
5385
+ //
5386
+ // RECEIVE ERRORS SECTION
5387
+ //
5388
+ /**
5389
+ * The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
5390
+ * Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
5391
+ */
5392
+ ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
5393
+ /**
5394
+ * The topics passed in the decoders do not match each other, or don't exist at all.
5395
+ * Ensure that all the pubsub topics used in the decoders are valid and match each other.
5396
+ */
5397
+ ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
5398
+ })(ProtocolError || (ProtocolError = {}));
5399
+
5400
+ var Tags;
5401
+ (function (Tags) {
5402
+ Tags["BOOTSTRAP"] = "bootstrap";
5403
+ Tags["PEER_EXCHANGE"] = "peer-exchange";
5404
+ Tags["LOCAL"] = "local-peer-cache";
5405
+ })(Tags || (Tags = {}));
5406
+
4332
5407
  /**
4333
5408
  * The default cluster ID for The Waku Network
4334
5409
  */
4335
5410
  const DEFAULT_CLUSTER_ID = 1;
4336
5411
 
5412
+ var HealthStatusChangeEvents;
5413
+ (function (HealthStatusChangeEvents) {
5414
+ HealthStatusChangeEvents["StatusChange"] = "health:change";
5415
+ })(HealthStatusChangeEvents || (HealthStatusChangeEvents = {}));
5416
+ var HealthStatus;
5417
+ (function (HealthStatus) {
5418
+ HealthStatus["Unhealthy"] = "Unhealthy";
5419
+ HealthStatus["MinimallyHealthy"] = "MinimallyHealthy";
5420
+ HealthStatus["SufficientlyHealthy"] = "SufficientlyHealthy";
5421
+ })(HealthStatus || (HealthStatus = {}));
5422
+
4337
5423
  /**
4338
5424
  * Turns a `Uint8Array` into a string.
4339
5425
  *
@@ -4350,6 +5436,21 @@ function toString(array, encoding = 'utf8') {
4350
5436
  return base.encoder.encode(array).substring(1);
4351
5437
  }
4352
5438
 
5439
+ function numberToBytes(value) {
5440
+ const buffer = new ArrayBuffer(8);
5441
+ const view = new DataView(buffer);
5442
+ if (typeof value === "number") {
5443
+ view.setFloat64(0, value, false);
5444
+ }
5445
+ else {
5446
+ view.setBigInt64(0, value, false);
5447
+ }
5448
+ return new Uint8Array(buffer);
5449
+ }
5450
+ /**
5451
+ * Convert byte array to hex string (no `0x` prefix).
5452
+ */
5453
+ const bytesToHex = (bytes) => toString(bytes, "base16");
4353
5454
  /**
4354
5455
  * Decode byte array to utf-8 string.
4355
5456
  */
@@ -4377,27 +5478,9 @@ const singleShardInfoToPubsubTopic = (shardInfo) => {
4377
5478
  throw new Error("Invalid shard");
4378
5479
  return `/waku/2/rs/${shardInfo.clusterId ?? DEFAULT_CLUSTER_ID}/${shardInfo.shard}`;
4379
5480
  };
4380
- const shardInfoToPubsubTopics = (shardInfo) => {
4381
- if ("contentTopics" in shardInfo && shardInfo.contentTopics) {
4382
- // Autosharding: explicitly defined content topics
4383
- return Array.from(new Set(shardInfo.contentTopics.map((contentTopic) => contentTopicToPubsubTopic(contentTopic, shardInfo.clusterId))));
4384
- }
4385
- else if ("shards" in shardInfo) {
4386
- // Static sharding
4387
- if (shardInfo.shards === undefined)
4388
- throw new Error("Invalid shard");
4389
- return Array.from(new Set(shardInfo.shards.map((index) => `/waku/2/rs/${shardInfo.clusterId ?? DEFAULT_CLUSTER_ID}/${index}`)));
4390
- }
4391
- else if ("application" in shardInfo && "version" in shardInfo) {
4392
- // Autosharding: single shard from application and version
4393
- return [
4394
- contentTopicToPubsubTopic(`/${shardInfo.application}/${shardInfo.version}/default/default`, shardInfo.clusterId)
4395
- ];
4396
- }
4397
- else {
4398
- throw new Error("Missing required configuration in shard parameters");
4399
- }
4400
- };
5481
+ /**
5482
+ * @deprecated will be removed
5483
+ */
4401
5484
  const pubsubTopicToSingleShardInfo = (pubsubTopics) => {
4402
5485
  const parts = pubsubTopics.split("/");
4403
5486
  if (parts.length != 6 ||
@@ -4513,6 +5596,781 @@ pubsubTopicShardInfo) {
4513
5596
  : contentTopicToPubsubTopic(contentTopic, pubsubTopicShardInfo?.clusterId ?? DEFAULT_CLUSTER_ID);
4514
5597
  }
4515
5598
 
5599
+ function getDefaultExportFromCjs (x) {
5600
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5601
+ }
5602
+
5603
+ var browser = {exports: {}};
5604
+
5605
+ /**
5606
+ * Helpers.
5607
+ */
5608
+
5609
+ var ms;
5610
+ var hasRequiredMs;
5611
+
5612
+ function requireMs () {
5613
+ if (hasRequiredMs) return ms;
5614
+ hasRequiredMs = 1;
5615
+ var s = 1000;
5616
+ var m = s * 60;
5617
+ var h = m * 60;
5618
+ var d = h * 24;
5619
+ var w = d * 7;
5620
+ var y = d * 365.25;
5621
+
5622
+ /**
5623
+ * Parse or format the given `val`.
5624
+ *
5625
+ * Options:
5626
+ *
5627
+ * - `long` verbose formatting [false]
5628
+ *
5629
+ * @param {String|Number} val
5630
+ * @param {Object} [options]
5631
+ * @throws {Error} throw an error if val is not a non-empty string or a number
5632
+ * @return {String|Number}
5633
+ * @api public
5634
+ */
5635
+
5636
+ ms = function (val, options) {
5637
+ options = options || {};
5638
+ var type = typeof val;
5639
+ if (type === 'string' && val.length > 0) {
5640
+ return parse(val);
5641
+ } else if (type === 'number' && isFinite(val)) {
5642
+ return options.long ? fmtLong(val) : fmtShort(val);
5643
+ }
5644
+ throw new Error(
5645
+ 'val is not a non-empty string or a valid number. val=' +
5646
+ JSON.stringify(val)
5647
+ );
5648
+ };
5649
+
5650
+ /**
5651
+ * Parse the given `str` and return milliseconds.
5652
+ *
5653
+ * @param {String} str
5654
+ * @return {Number}
5655
+ * @api private
5656
+ */
5657
+
5658
+ function parse(str) {
5659
+ str = String(str);
5660
+ if (str.length > 100) {
5661
+ return;
5662
+ }
5663
+ var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
5664
+ str
5665
+ );
5666
+ if (!match) {
5667
+ return;
5668
+ }
5669
+ var n = parseFloat(match[1]);
5670
+ var type = (match[2] || 'ms').toLowerCase();
5671
+ switch (type) {
5672
+ case 'years':
5673
+ case 'year':
5674
+ case 'yrs':
5675
+ case 'yr':
5676
+ case 'y':
5677
+ return n * y;
5678
+ case 'weeks':
5679
+ case 'week':
5680
+ case 'w':
5681
+ return n * w;
5682
+ case 'days':
5683
+ case 'day':
5684
+ case 'd':
5685
+ return n * d;
5686
+ case 'hours':
5687
+ case 'hour':
5688
+ case 'hrs':
5689
+ case 'hr':
5690
+ case 'h':
5691
+ return n * h;
5692
+ case 'minutes':
5693
+ case 'minute':
5694
+ case 'mins':
5695
+ case 'min':
5696
+ case 'm':
5697
+ return n * m;
5698
+ case 'seconds':
5699
+ case 'second':
5700
+ case 'secs':
5701
+ case 'sec':
5702
+ case 's':
5703
+ return n * s;
5704
+ case 'milliseconds':
5705
+ case 'millisecond':
5706
+ case 'msecs':
5707
+ case 'msec':
5708
+ case 'ms':
5709
+ return n;
5710
+ default:
5711
+ return undefined;
5712
+ }
5713
+ }
5714
+
5715
+ /**
5716
+ * Short format for `ms`.
5717
+ *
5718
+ * @param {Number} ms
5719
+ * @return {String}
5720
+ * @api private
5721
+ */
5722
+
5723
+ function fmtShort(ms) {
5724
+ var msAbs = Math.abs(ms);
5725
+ if (msAbs >= d) {
5726
+ return Math.round(ms / d) + 'd';
5727
+ }
5728
+ if (msAbs >= h) {
5729
+ return Math.round(ms / h) + 'h';
5730
+ }
5731
+ if (msAbs >= m) {
5732
+ return Math.round(ms / m) + 'm';
5733
+ }
5734
+ if (msAbs >= s) {
5735
+ return Math.round(ms / s) + 's';
5736
+ }
5737
+ return ms + 'ms';
5738
+ }
5739
+
5740
+ /**
5741
+ * Long format for `ms`.
5742
+ *
5743
+ * @param {Number} ms
5744
+ * @return {String}
5745
+ * @api private
5746
+ */
5747
+
5748
+ function fmtLong(ms) {
5749
+ var msAbs = Math.abs(ms);
5750
+ if (msAbs >= d) {
5751
+ return plural(ms, msAbs, d, 'day');
5752
+ }
5753
+ if (msAbs >= h) {
5754
+ return plural(ms, msAbs, h, 'hour');
5755
+ }
5756
+ if (msAbs >= m) {
5757
+ return plural(ms, msAbs, m, 'minute');
5758
+ }
5759
+ if (msAbs >= s) {
5760
+ return plural(ms, msAbs, s, 'second');
5761
+ }
5762
+ return ms + ' ms';
5763
+ }
5764
+
5765
+ /**
5766
+ * Pluralization helper.
5767
+ */
5768
+
5769
+ function plural(ms, msAbs, n, name) {
5770
+ var isPlural = msAbs >= n * 1.5;
5771
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
5772
+ }
5773
+ return ms;
5774
+ }
5775
+
5776
+ /**
5777
+ * This is the common logic for both the Node.js and web browser
5778
+ * implementations of `debug()`.
5779
+ */
5780
+
5781
+ function setup(env) {
5782
+ createDebug.debug = createDebug;
5783
+ createDebug.default = createDebug;
5784
+ createDebug.coerce = coerce;
5785
+ createDebug.disable = disable;
5786
+ createDebug.enable = enable;
5787
+ createDebug.enabled = enabled;
5788
+ createDebug.humanize = requireMs();
5789
+ createDebug.destroy = destroy;
5790
+
5791
+ Object.keys(env).forEach(key => {
5792
+ createDebug[key] = env[key];
5793
+ });
5794
+
5795
+ /**
5796
+ * The currently active debug mode names, and names to skip.
5797
+ */
5798
+
5799
+ createDebug.names = [];
5800
+ createDebug.skips = [];
5801
+
5802
+ /**
5803
+ * Map of special "%n" handling functions, for the debug "format" argument.
5804
+ *
5805
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
5806
+ */
5807
+ createDebug.formatters = {};
5808
+
5809
+ /**
5810
+ * Selects a color for a debug namespace
5811
+ * @param {String} namespace The namespace string for the debug instance to be colored
5812
+ * @return {Number|String} An ANSI color code for the given namespace
5813
+ * @api private
5814
+ */
5815
+ function selectColor(namespace) {
5816
+ let hash = 0;
5817
+
5818
+ for (let i = 0; i < namespace.length; i++) {
5819
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
5820
+ hash |= 0; // Convert to 32bit integer
5821
+ }
5822
+
5823
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
5824
+ }
5825
+ createDebug.selectColor = selectColor;
5826
+
5827
+ /**
5828
+ * Create a debugger with the given `namespace`.
5829
+ *
5830
+ * @param {String} namespace
5831
+ * @return {Function}
5832
+ * @api public
5833
+ */
5834
+ function createDebug(namespace) {
5835
+ let prevTime;
5836
+ let enableOverride = null;
5837
+ let namespacesCache;
5838
+ let enabledCache;
5839
+
5840
+ function debug(...args) {
5841
+ // Disabled?
5842
+ if (!debug.enabled) {
5843
+ return;
5844
+ }
5845
+
5846
+ const self = debug;
5847
+
5848
+ // Set `diff` timestamp
5849
+ const curr = Number(new Date());
5850
+ const ms = curr - (prevTime || curr);
5851
+ self.diff = ms;
5852
+ self.prev = prevTime;
5853
+ self.curr = curr;
5854
+ prevTime = curr;
5855
+
5856
+ args[0] = createDebug.coerce(args[0]);
5857
+
5858
+ if (typeof args[0] !== 'string') {
5859
+ // Anything else let's inspect with %O
5860
+ args.unshift('%O');
5861
+ }
5862
+
5863
+ // Apply any `formatters` transformations
5864
+ let index = 0;
5865
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
5866
+ // If we encounter an escaped % then don't increase the array index
5867
+ if (match === '%%') {
5868
+ return '%';
5869
+ }
5870
+ index++;
5871
+ const formatter = createDebug.formatters[format];
5872
+ if (typeof formatter === 'function') {
5873
+ const val = args[index];
5874
+ match = formatter.call(self, val);
5875
+
5876
+ // Now we need to remove `args[index]` since it's inlined in the `format`
5877
+ args.splice(index, 1);
5878
+ index--;
5879
+ }
5880
+ return match;
5881
+ });
5882
+
5883
+ // Apply env-specific formatting (colors, etc.)
5884
+ createDebug.formatArgs.call(self, args);
5885
+
5886
+ const logFn = self.log || createDebug.log;
5887
+ logFn.apply(self, args);
5888
+ }
5889
+
5890
+ debug.namespace = namespace;
5891
+ debug.useColors = createDebug.useColors();
5892
+ debug.color = createDebug.selectColor(namespace);
5893
+ debug.extend = extend;
5894
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
5895
+
5896
+ Object.defineProperty(debug, 'enabled', {
5897
+ enumerable: true,
5898
+ configurable: false,
5899
+ get: () => {
5900
+ if (enableOverride !== null) {
5901
+ return enableOverride;
5902
+ }
5903
+ if (namespacesCache !== createDebug.namespaces) {
5904
+ namespacesCache = createDebug.namespaces;
5905
+ enabledCache = createDebug.enabled(namespace);
5906
+ }
5907
+
5908
+ return enabledCache;
5909
+ },
5910
+ set: v => {
5911
+ enableOverride = v;
5912
+ }
5913
+ });
5914
+
5915
+ // Env-specific initialization logic for debug instances
5916
+ if (typeof createDebug.init === 'function') {
5917
+ createDebug.init(debug);
5918
+ }
5919
+
5920
+ return debug;
5921
+ }
5922
+
5923
+ function extend(namespace, delimiter) {
5924
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
5925
+ newDebug.log = this.log;
5926
+ return newDebug;
5927
+ }
5928
+
5929
+ /**
5930
+ * Enables a debug mode by namespaces. This can include modes
5931
+ * separated by a colon and wildcards.
5932
+ *
5933
+ * @param {String} namespaces
5934
+ * @api public
5935
+ */
5936
+ function enable(namespaces) {
5937
+ createDebug.save(namespaces);
5938
+ createDebug.namespaces = namespaces;
5939
+
5940
+ createDebug.names = [];
5941
+ createDebug.skips = [];
5942
+
5943
+ const split = (typeof namespaces === 'string' ? namespaces : '')
5944
+ .trim()
5945
+ .replace(/\s+/g, ',')
5946
+ .split(',')
5947
+ .filter(Boolean);
5948
+
5949
+ for (const ns of split) {
5950
+ if (ns[0] === '-') {
5951
+ createDebug.skips.push(ns.slice(1));
5952
+ } else {
5953
+ createDebug.names.push(ns);
5954
+ }
5955
+ }
5956
+ }
5957
+
5958
+ /**
5959
+ * Checks if the given string matches a namespace template, honoring
5960
+ * asterisks as wildcards.
5961
+ *
5962
+ * @param {String} search
5963
+ * @param {String} template
5964
+ * @return {Boolean}
5965
+ */
5966
+ function matchesTemplate(search, template) {
5967
+ let searchIndex = 0;
5968
+ let templateIndex = 0;
5969
+ let starIndex = -1;
5970
+ let matchIndex = 0;
5971
+
5972
+ while (searchIndex < search.length) {
5973
+ if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
5974
+ // Match character or proceed with wildcard
5975
+ if (template[templateIndex] === '*') {
5976
+ starIndex = templateIndex;
5977
+ matchIndex = searchIndex;
5978
+ templateIndex++; // Skip the '*'
5979
+ } else {
5980
+ searchIndex++;
5981
+ templateIndex++;
5982
+ }
5983
+ } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
5984
+ // Backtrack to the last '*' and try to match more characters
5985
+ templateIndex = starIndex + 1;
5986
+ matchIndex++;
5987
+ searchIndex = matchIndex;
5988
+ } else {
5989
+ return false; // No match
5990
+ }
5991
+ }
5992
+
5993
+ // Handle trailing '*' in template
5994
+ while (templateIndex < template.length && template[templateIndex] === '*') {
5995
+ templateIndex++;
5996
+ }
5997
+
5998
+ return templateIndex === template.length;
5999
+ }
6000
+
6001
+ /**
6002
+ * Disable debug output.
6003
+ *
6004
+ * @return {String} namespaces
6005
+ * @api public
6006
+ */
6007
+ function disable() {
6008
+ const namespaces = [
6009
+ ...createDebug.names,
6010
+ ...createDebug.skips.map(namespace => '-' + namespace)
6011
+ ].join(',');
6012
+ createDebug.enable('');
6013
+ return namespaces;
6014
+ }
6015
+
6016
+ /**
6017
+ * Returns true if the given mode name is enabled, false otherwise.
6018
+ *
6019
+ * @param {String} name
6020
+ * @return {Boolean}
6021
+ * @api public
6022
+ */
6023
+ function enabled(name) {
6024
+ for (const skip of createDebug.skips) {
6025
+ if (matchesTemplate(name, skip)) {
6026
+ return false;
6027
+ }
6028
+ }
6029
+
6030
+ for (const ns of createDebug.names) {
6031
+ if (matchesTemplate(name, ns)) {
6032
+ return true;
6033
+ }
6034
+ }
6035
+
6036
+ return false;
6037
+ }
6038
+
6039
+ /**
6040
+ * Coerce `val`.
6041
+ *
6042
+ * @param {Mixed} val
6043
+ * @return {Mixed}
6044
+ * @api private
6045
+ */
6046
+ function coerce(val) {
6047
+ if (val instanceof Error) {
6048
+ return val.stack || val.message;
6049
+ }
6050
+ return val;
6051
+ }
6052
+
6053
+ /**
6054
+ * XXX DO NOT USE. This is a temporary stub function.
6055
+ * XXX It WILL be removed in the next major release.
6056
+ */
6057
+ function destroy() {
6058
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
6059
+ }
6060
+
6061
+ createDebug.enable(createDebug.load());
6062
+
6063
+ return createDebug;
6064
+ }
6065
+
6066
+ var common = setup;
6067
+
6068
+ /* eslint-env browser */
6069
+
6070
+ (function (module, exports) {
6071
+ /**
6072
+ * This is the web browser implementation of `debug()`.
6073
+ */
6074
+
6075
+ exports.formatArgs = formatArgs;
6076
+ exports.save = save;
6077
+ exports.load = load;
6078
+ exports.useColors = useColors;
6079
+ exports.storage = localstorage();
6080
+ exports.destroy = (() => {
6081
+ let warned = false;
6082
+
6083
+ return () => {
6084
+ if (!warned) {
6085
+ warned = true;
6086
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
6087
+ }
6088
+ };
6089
+ })();
6090
+
6091
+ /**
6092
+ * Colors.
6093
+ */
6094
+
6095
+ exports.colors = [
6096
+ '#0000CC',
6097
+ '#0000FF',
6098
+ '#0033CC',
6099
+ '#0033FF',
6100
+ '#0066CC',
6101
+ '#0066FF',
6102
+ '#0099CC',
6103
+ '#0099FF',
6104
+ '#00CC00',
6105
+ '#00CC33',
6106
+ '#00CC66',
6107
+ '#00CC99',
6108
+ '#00CCCC',
6109
+ '#00CCFF',
6110
+ '#3300CC',
6111
+ '#3300FF',
6112
+ '#3333CC',
6113
+ '#3333FF',
6114
+ '#3366CC',
6115
+ '#3366FF',
6116
+ '#3399CC',
6117
+ '#3399FF',
6118
+ '#33CC00',
6119
+ '#33CC33',
6120
+ '#33CC66',
6121
+ '#33CC99',
6122
+ '#33CCCC',
6123
+ '#33CCFF',
6124
+ '#6600CC',
6125
+ '#6600FF',
6126
+ '#6633CC',
6127
+ '#6633FF',
6128
+ '#66CC00',
6129
+ '#66CC33',
6130
+ '#9900CC',
6131
+ '#9900FF',
6132
+ '#9933CC',
6133
+ '#9933FF',
6134
+ '#99CC00',
6135
+ '#99CC33',
6136
+ '#CC0000',
6137
+ '#CC0033',
6138
+ '#CC0066',
6139
+ '#CC0099',
6140
+ '#CC00CC',
6141
+ '#CC00FF',
6142
+ '#CC3300',
6143
+ '#CC3333',
6144
+ '#CC3366',
6145
+ '#CC3399',
6146
+ '#CC33CC',
6147
+ '#CC33FF',
6148
+ '#CC6600',
6149
+ '#CC6633',
6150
+ '#CC9900',
6151
+ '#CC9933',
6152
+ '#CCCC00',
6153
+ '#CCCC33',
6154
+ '#FF0000',
6155
+ '#FF0033',
6156
+ '#FF0066',
6157
+ '#FF0099',
6158
+ '#FF00CC',
6159
+ '#FF00FF',
6160
+ '#FF3300',
6161
+ '#FF3333',
6162
+ '#FF3366',
6163
+ '#FF3399',
6164
+ '#FF33CC',
6165
+ '#FF33FF',
6166
+ '#FF6600',
6167
+ '#FF6633',
6168
+ '#FF9900',
6169
+ '#FF9933',
6170
+ '#FFCC00',
6171
+ '#FFCC33'
6172
+ ];
6173
+
6174
+ /**
6175
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
6176
+ * and the Firebug extension (any Firefox version) are known
6177
+ * to support "%c" CSS customizations.
6178
+ *
6179
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
6180
+ */
6181
+
6182
+ // eslint-disable-next-line complexity
6183
+ function useColors() {
6184
+ // NB: In an Electron preload script, document will be defined but not fully
6185
+ // initialized. Since we know we're in Chrome, we'll just detect this case
6186
+ // explicitly
6187
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
6188
+ return true;
6189
+ }
6190
+
6191
+ // Internet Explorer and Edge do not support colors.
6192
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
6193
+ return false;
6194
+ }
6195
+
6196
+ let m;
6197
+
6198
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
6199
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
6200
+ // eslint-disable-next-line no-return-assign
6201
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
6202
+ // Is firebug? http://stackoverflow.com/a/398120/376773
6203
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
6204
+ // Is firefox >= v31?
6205
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
6206
+ (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
6207
+ // Double check webkit in userAgent just in case we are in a worker
6208
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
6209
+ }
6210
+
6211
+ /**
6212
+ * Colorize log arguments if enabled.
6213
+ *
6214
+ * @api public
6215
+ */
6216
+
6217
+ function formatArgs(args) {
6218
+ args[0] = (this.useColors ? '%c' : '') +
6219
+ this.namespace +
6220
+ (this.useColors ? ' %c' : ' ') +
6221
+ args[0] +
6222
+ (this.useColors ? '%c ' : ' ') +
6223
+ '+' + module.exports.humanize(this.diff);
6224
+
6225
+ if (!this.useColors) {
6226
+ return;
6227
+ }
6228
+
6229
+ const c = 'color: ' + this.color;
6230
+ args.splice(1, 0, c, 'color: inherit');
6231
+
6232
+ // The final "%c" is somewhat tricky, because there could be other
6233
+ // arguments passed either before or after the %c, so we need to
6234
+ // figure out the correct index to insert the CSS into
6235
+ let index = 0;
6236
+ let lastC = 0;
6237
+ args[0].replace(/%[a-zA-Z%]/g, match => {
6238
+ if (match === '%%') {
6239
+ return;
6240
+ }
6241
+ index++;
6242
+ if (match === '%c') {
6243
+ // We only are interested in the *last* %c
6244
+ // (the user may have provided their own)
6245
+ lastC = index;
6246
+ }
6247
+ });
6248
+
6249
+ args.splice(lastC, 0, c);
6250
+ }
6251
+
6252
+ /**
6253
+ * Invokes `console.debug()` when available.
6254
+ * No-op when `console.debug` is not a "function".
6255
+ * If `console.debug` is not available, falls back
6256
+ * to `console.log`.
6257
+ *
6258
+ * @api public
6259
+ */
6260
+ exports.log = console.debug || console.log || (() => {});
6261
+
6262
+ /**
6263
+ * Save `namespaces`.
6264
+ *
6265
+ * @param {String} namespaces
6266
+ * @api private
6267
+ */
6268
+ function save(namespaces) {
6269
+ try {
6270
+ if (namespaces) {
6271
+ exports.storage.setItem('debug', namespaces);
6272
+ } else {
6273
+ exports.storage.removeItem('debug');
6274
+ }
6275
+ } catch (error) {
6276
+ // Swallow
6277
+ // XXX (@Qix-) should we be logging these?
6278
+ }
6279
+ }
6280
+
6281
+ /**
6282
+ * Load `namespaces`.
6283
+ *
6284
+ * @return {String} returns the previously persisted debug modes
6285
+ * @api private
6286
+ */
6287
+ function load() {
6288
+ let r;
6289
+ try {
6290
+ r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;
6291
+ } catch (error) {
6292
+ // Swallow
6293
+ // XXX (@Qix-) should we be logging these?
6294
+ }
6295
+
6296
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
6297
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
6298
+ r = process.env.DEBUG;
6299
+ }
6300
+
6301
+ return r;
6302
+ }
6303
+
6304
+ /**
6305
+ * Localstorage attempts to return the localstorage.
6306
+ *
6307
+ * This is necessary because safari throws
6308
+ * when a user disables cookies/localstorage
6309
+ * and you attempt to access it.
6310
+ *
6311
+ * @return {LocalStorage}
6312
+ * @api private
6313
+ */
6314
+
6315
+ function localstorage() {
6316
+ try {
6317
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
6318
+ // The Browser also has localStorage in the global context.
6319
+ return localStorage;
6320
+ } catch (error) {
6321
+ // Swallow
6322
+ // XXX (@Qix-) should we be logging these?
6323
+ }
6324
+ }
6325
+
6326
+ module.exports = common(exports);
6327
+
6328
+ const {formatters} = module.exports;
6329
+
6330
+ /**
6331
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
6332
+ */
6333
+
6334
+ formatters.j = function (v) {
6335
+ try {
6336
+ return JSON.stringify(v);
6337
+ } catch (error) {
6338
+ return '[UnexpectedJSONParseError]: ' + error.message;
6339
+ }
6340
+ };
6341
+ } (browser, browser.exports));
6342
+
6343
+ var browserExports = browser.exports;
6344
+ var debug = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
6345
+
6346
+ const APP_NAME = "waku";
6347
+ class Logger {
6348
+ _info;
6349
+ _warn;
6350
+ _error;
6351
+ static createDebugNamespace(level, prefix) {
6352
+ return prefix ? `${APP_NAME}:${level}:${prefix}` : `${APP_NAME}:${level}`;
6353
+ }
6354
+ constructor(prefix) {
6355
+ this._info = debug(Logger.createDebugNamespace("info", prefix));
6356
+ this._warn = debug(Logger.createDebugNamespace("warn", prefix));
6357
+ this._error = debug(Logger.createDebugNamespace("error", prefix));
6358
+ }
6359
+ get info() {
6360
+ return this._info;
6361
+ }
6362
+ get warn() {
6363
+ return this._warn;
6364
+ }
6365
+ get error() {
6366
+ return this._error;
6367
+ }
6368
+ log(level, ...args) {
6369
+ const logger = this[level];
6370
+ logger(...args);
6371
+ }
6372
+ }
6373
+
4516
6374
  const log = new Logger("message:version-0");
4517
6375
  const OneMillion = BigInt(1_000_000);
4518
6376
  const Version = 0;
@@ -4532,9 +6390,6 @@ class DecodedMessage {
4532
6390
  get contentTopic() {
4533
6391
  return this.proto.contentTopic;
4534
6392
  }
4535
- get _rawTimestamp() {
4536
- return this.proto.timestamp;
4537
- }
4538
6393
  get timestamp() {
4539
6394
  // In the case we receive a value that is bigger than JS's max number,
4540
6395
  // we catch the error and return undefined.
@@ -4556,7 +6411,7 @@ class DecodedMessage {
4556
6411
  get version() {
4557
6412
  // https://rfc.vac.dev/spec/14/
4558
6413
  // > If omitted, the value SHOULD be interpreted as version 0.
4559
- return this.proto.version ?? 0;
6414
+ return this.proto.version ?? Version;
4560
6415
  }
4561
6416
  get rateLimitProof() {
4562
6417
  return this.proto.rateLimitProof;
@@ -4665,4 +6520,4 @@ var version_0 = /*#__PURE__*/Object.freeze({
4665
6520
  proto: message
4666
6521
  });
4667
6522
 
4668
- export { DecodedMessage as D, Encoder as E, FilterSubscribeRequest as F, MessagePush as M, PushRpc$1 as P, StoreQueryRequest$1 as S, Version as V, WakuMetadataRequest as W, allocUnsafe as a, alloc$1 as b, encode as c, decode as d, encodingLength as e, FilterSubscribeResponse$1 as f, PushResponse as g, StoreQueryResponse$1 as h, bases as i, fromString as j, createEncoder as k, bytesToUtf8 as l, pubsubTopicsToShardInfo as m, WakuMetadataResponse as n, createDecoder as o, pubsubTopicToSingleShardInfo as p, message as q, Decoder as r, shardInfoToPubsubTopics as s, toString as t, utf8ToBytes as u, version_0 as v };
6523
+ export { sha256 as $, anumber as A, randomBytes as B, sha512 as C, enumeration as D, message$1 as E, FilterSubscribeRequest as F, encodeMessage as G, decodeMessage as H, Hash as I, ahash as J, toBytes as K, Logger as L, MessagePush as M, clean as N, aexists as O, ProtocolError as P, sha256$1 as Q, bases as R, StoreQueryRequest$1 as S, Tags as T, base64url as U, encodeUint8Array as V, bytesToUtf8 as W, WakuMetadataRequest as X, pubsubTopicsToShardInfo as Y, WakuMetadataResponse as Z, concat as _, base58btc as a, bytesToHex as a0, numberToBytes as a1, createDecoder as a2, Version as a3, message as a4, DecodedMessage as a5, Encoder as a6, Decoder as a7, base32 as b, coerce as c, base36 as d, equals as e, allocUnsafe as f, alloc$1 as g, encodingLength as h, encode$2 as i, decode$2 as j, FilterSubscribeResponse$1 as k, PushRpc$1 as l, PushResponse as m, StoreQueryResponse$1 as n, createEncoder as o, pubsubTopicToSingleShardInfo as p, contentTopicToShardIndex as q, fromString as r, hexToBytes as s, toString as t, utf8ToBytes as u, version_0 as v, isBytes as w, abytes as x, bytesToHex$1 as y, concatBytes as z };