@waku/core 0.0.36-383e0b2.0 → 0.0.36-4c18ca2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/index.js +1098 -593
- package/bundle/lib/message/version_0.js +1 -2
- package/bundle/{version_0-4TwtF5aQ.js → version_0-9DPFjcJG.js} +1661 -65
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/filter/filter.d.ts +8 -5
- package/dist/lib/filter/filter.js +30 -10
- package/dist/lib/filter/filter.js.map +1 -1
- package/dist/lib/light_push/light_push.d.ts +4 -3
- package/dist/lib/light_push/light_push.js +6 -4
- package/dist/lib/light_push/light_push.js.map +1 -1
- package/dist/lib/message/version_0.d.ts +3 -4
- package/dist/lib/message/version_0.js +1 -4
- package/dist/lib/message/version_0.js.map +1 -1
- package/dist/lib/message_hash/index.d.ts +1 -0
- package/dist/lib/message_hash/index.js +2 -0
- package/dist/lib/message_hash/index.js.map +1 -0
- package/dist/lib/message_hash/message_hash.d.ts +52 -0
- package/dist/lib/message_hash/message_hash.js +84 -0
- package/dist/lib/message_hash/message_hash.js.map +1 -0
- package/dist/lib/metadata/metadata.js +6 -4
- package/dist/lib/metadata/metadata.js.map +1 -1
- package/dist/lib/store/rpc.js +0 -4
- package/dist/lib/store/rpc.js.map +1 -1
- package/dist/lib/store/store.d.ts +4 -3
- package/dist/lib/store/store.js +6 -4
- package/dist/lib/store/store.js.map +1 -1
- package/dist/lib/stream_manager/stream_manager.d.ts +3 -4
- package/dist/lib/stream_manager/stream_manager.js +6 -8
- package/dist/lib/stream_manager/stream_manager.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/lib/filter/filter.ts +46 -14
- package/src/lib/light_push/light_push.ts +8 -5
- package/src/lib/message/version_0.ts +3 -7
- package/src/lib/message_hash/index.ts +1 -0
- package/src/lib/message_hash/message_hash.ts +106 -0
- package/src/lib/metadata/metadata.ts +8 -5
- package/src/lib/store/rpc.ts +0 -4
- package/src/lib/store/store.ts +8 -5
- package/src/lib/stream_manager/stream_manager.ts +8 -6
- package/bundle/base_protocol-DvQrudwy.js +0 -152
- package/bundle/index-CTo1my9M.js +0 -1543
- package/bundle/lib/base_protocol.js +0 -2
- package/dist/lib/base_protocol.d.ts +0 -18
- package/dist/lib/base_protocol.js +0 -25
- package/dist/lib/base_protocol.js.map +0 -1
- 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
|
-
|
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;
|
@@ -3985,11 +4654,17 @@ var SdsMessage;
|
|
3985
4654
|
})(SdsMessage || (SdsMessage = {}));
|
3986
4655
|
|
3987
4656
|
/**
|
3988
|
-
*
|
4657
|
+
* Utilities for hex, bytes, CSPRNG.
|
3989
4658
|
* @module
|
3990
4659
|
*/
|
3991
|
-
|
3992
|
-
|
4660
|
+
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
4661
|
+
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
4662
|
+
// node.js versions earlier than v19 don't declare it in global scope.
|
4663
|
+
// For node.js, package.json#exports field mapping rewrites import
|
4664
|
+
// from `crypto` to `cryptoNode`, which imports native module.
|
4665
|
+
// Makes the utils un-importable in browsers without a bundler.
|
4666
|
+
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
4667
|
+
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
3993
4668
|
function isBytes(a) {
|
3994
4669
|
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
|
3995
4670
|
}
|
@@ -4015,19 +4690,13 @@ function aoutput(out, instance) {
|
|
4015
4690
|
throw new Error('digestInto() expects output buffer of length at least ' + min);
|
4016
4691
|
}
|
4017
4692
|
}
|
4018
|
-
|
4019
|
-
|
4020
|
-
|
4021
|
-
|
4022
|
-
|
4023
|
-
|
4024
|
-
|
4025
|
-
// node.js versions earlier than v19 don't declare it in global scope.
|
4026
|
-
// For node.js, package.json#exports field mapping rewrites import
|
4027
|
-
// from `crypto` to `cryptoNode`, which imports native module.
|
4028
|
-
// Makes the utils un-importable in browsers without a bundler.
|
4029
|
-
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
4030
|
-
// Cast array to view
|
4693
|
+
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
4694
|
+
function clean(...arrays) {
|
4695
|
+
for (let i = 0; i < arrays.length; i++) {
|
4696
|
+
arrays[i].fill(0);
|
4697
|
+
}
|
4698
|
+
}
|
4699
|
+
/** Create DataView of an array for easy byte-level manipulation. */
|
4031
4700
|
function createView(arr) {
|
4032
4701
|
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
4033
4702
|
}
|
@@ -4036,12 +4705,12 @@ function rotr(word, shift) {
|
|
4036
4705
|
return (word << (32 - shift)) | (word >>> shift);
|
4037
4706
|
}
|
4038
4707
|
/**
|
4039
|
-
*
|
4040
|
-
* @example utf8ToBytes('abc') //
|
4708
|
+
* Converts string to bytes using UTF8 encoding.
|
4709
|
+
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
4041
4710
|
*/
|
4042
4711
|
function utf8ToBytes$1(str) {
|
4043
4712
|
if (typeof str !== 'string')
|
4044
|
-
throw new Error('
|
4713
|
+
throw new Error('string expected');
|
4045
4714
|
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
4046
4715
|
}
|
4047
4716
|
/**
|
@@ -4057,13 +4726,9 @@ function toBytes(data) {
|
|
4057
4726
|
}
|
4058
4727
|
/** For runtime check if class implements interface */
|
4059
4728
|
class Hash {
|
4060
|
-
// Safe version that clones internal state
|
4061
|
-
clone() {
|
4062
|
-
return this._cloneInto();
|
4063
|
-
}
|
4064
4729
|
}
|
4065
4730
|
/** Wraps hash function, creating an interface on top of it */
|
4066
|
-
function
|
4731
|
+
function createHasher(hashCons) {
|
4067
4732
|
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
4068
4733
|
const tmp = hashCons();
|
4069
4734
|
hashC.outputLen = tmp.outputLen;
|
@@ -4104,21 +4769,22 @@ function Maj(a, b, c) {
|
|
4104
4769
|
class HashMD extends Hash {
|
4105
4770
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
4106
4771
|
super();
|
4107
|
-
this.blockLen = blockLen;
|
4108
|
-
this.outputLen = outputLen;
|
4109
|
-
this.padOffset = padOffset;
|
4110
|
-
this.isLE = isLE;
|
4111
4772
|
this.finished = false;
|
4112
4773
|
this.length = 0;
|
4113
4774
|
this.pos = 0;
|
4114
4775
|
this.destroyed = false;
|
4776
|
+
this.blockLen = blockLen;
|
4777
|
+
this.outputLen = outputLen;
|
4778
|
+
this.padOffset = padOffset;
|
4779
|
+
this.isLE = isLE;
|
4115
4780
|
this.buffer = new Uint8Array(blockLen);
|
4116
4781
|
this.view = createView(this.buffer);
|
4117
4782
|
}
|
4118
4783
|
update(data) {
|
4119
4784
|
aexists(this);
|
4120
|
-
const { view, buffer, blockLen } = this;
|
4121
4785
|
data = toBytes(data);
|
4786
|
+
abytes(data);
|
4787
|
+
const { view, buffer, blockLen } = this;
|
4122
4788
|
const len = data.length;
|
4123
4789
|
for (let pos = 0; pos < len;) {
|
4124
4790
|
const take = Math.min(blockLen - this.pos, len - pos);
|
@@ -4152,7 +4818,7 @@ class HashMD extends Hash {
|
|
4152
4818
|
let { pos } = this;
|
4153
4819
|
// append the bit '1' to the message
|
4154
4820
|
buffer[pos++] = 0b10000000;
|
4155
|
-
this.buffer.subarray(pos)
|
4821
|
+
clean(this.buffer.subarray(pos));
|
4156
4822
|
// we have less than padOffset left in buffer, so we cannot put length in
|
4157
4823
|
// current block, need process it and pad again
|
4158
4824
|
if (this.padOffset > blockLen - pos) {
|
@@ -4190,28 +4856,40 @@ class HashMD extends Hash {
|
|
4190
4856
|
to || (to = new this.constructor());
|
4191
4857
|
to.set(...this.get());
|
4192
4858
|
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
4859
|
+
to.destroyed = destroyed;
|
4860
|
+
to.finished = finished;
|
4193
4861
|
to.length = length;
|
4194
4862
|
to.pos = pos;
|
4195
|
-
to.finished = finished;
|
4196
|
-
to.destroyed = destroyed;
|
4197
4863
|
if (length % blockLen)
|
4198
4864
|
to.buffer.set(buffer);
|
4199
4865
|
return to;
|
4200
4866
|
}
|
4867
|
+
clone() {
|
4868
|
+
return this._cloneInto();
|
4869
|
+
}
|
4201
4870
|
}
|
4871
|
+
/**
|
4872
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
4873
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
4874
|
+
*/
|
4875
|
+
/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
|
4876
|
+
const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
4877
|
+
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
4878
|
+
]);
|
4202
4879
|
|
4203
4880
|
/**
|
4204
|
-
* SHA2
|
4205
|
-
*
|
4206
|
-
*
|
4207
|
-
*
|
4208
|
-
*
|
4209
|
-
* Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
4881
|
+
* SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
|
4882
|
+
* SHA256 is the fastest hash implementable in JS, even faster than Blake3.
|
4883
|
+
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
|
4884
|
+
* [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
4210
4885
|
* @module
|
4211
4886
|
*/
|
4212
|
-
/**
|
4887
|
+
/**
|
4888
|
+
* Round constants:
|
4889
|
+
* First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
|
4890
|
+
*/
|
4213
4891
|
// prettier-ignore
|
4214
|
-
const SHA256_K = /* @__PURE__ */
|
4892
|
+
const SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
4215
4893
|
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
4216
4894
|
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
4217
4895
|
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
@@ -4221,19 +4899,11 @@ const SHA256_K = /* @__PURE__ */ new Uint32Array([
|
|
4221
4899
|
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
4222
4900
|
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
4223
4901
|
]);
|
4224
|
-
/**
|
4225
|
-
// prettier-ignore
|
4226
|
-
const SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
4227
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
|
4228
|
-
]);
|
4229
|
-
/**
|
4230
|
-
* Temporary buffer, not used to store anything between runs.
|
4231
|
-
* Named this way because it matches specification.
|
4232
|
-
*/
|
4902
|
+
/** Reusable temporary buffer. "W" comes straight from spec. */
|
4233
4903
|
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
4234
4904
|
class SHA256 extends HashMD {
|
4235
|
-
constructor() {
|
4236
|
-
super(64,
|
4905
|
+
constructor(outputLen = 32) {
|
4906
|
+
super(64, outputLen, 8, false);
|
4237
4907
|
// We cannot use array here since array allows indexing by variable
|
4238
4908
|
// which means optimizer/compiler cannot use registers.
|
4239
4909
|
this.A = SHA256_IV[0] | 0;
|
@@ -4299,21 +4969,160 @@ class SHA256 extends HashMD {
|
|
4299
4969
|
this.set(A, B, C, D, E, F, G, H);
|
4300
4970
|
}
|
4301
4971
|
roundClean() {
|
4302
|
-
SHA256_W
|
4972
|
+
clean(SHA256_W);
|
4303
4973
|
}
|
4304
4974
|
destroy() {
|
4305
4975
|
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
4306
|
-
this.buffer
|
4976
|
+
clean(this.buffer);
|
4307
4977
|
}
|
4308
4978
|
}
|
4309
|
-
/**
|
4310
|
-
|
4979
|
+
/**
|
4980
|
+
* SHA2-256 hash function from RFC 4634.
|
4981
|
+
*
|
4982
|
+
* It is the fastest JS hash, even faster than Blake3.
|
4983
|
+
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
4984
|
+
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
4985
|
+
*/
|
4986
|
+
const sha256$1 = /* @__PURE__ */ createHasher(() => new SHA256());
|
4987
|
+
|
4988
|
+
/**
|
4989
|
+
* SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
|
4990
|
+
*
|
4991
|
+
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
4992
|
+
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
4993
|
+
*
|
4994
|
+
* Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
4995
|
+
* @module
|
4996
|
+
* @deprecated
|
4997
|
+
*/
|
4998
|
+
/** @deprecated Use import from `noble/hashes/sha2` module */
|
4999
|
+
const sha256 = sha256$1;
|
5000
|
+
|
5001
|
+
var Protocols;
|
5002
|
+
(function (Protocols) {
|
5003
|
+
Protocols["Relay"] = "relay";
|
5004
|
+
Protocols["Store"] = "store";
|
5005
|
+
Protocols["LightPush"] = "lightpush";
|
5006
|
+
Protocols["Filter"] = "filter";
|
5007
|
+
})(Protocols || (Protocols = {}));
|
5008
|
+
var ProtocolError;
|
5009
|
+
(function (ProtocolError) {
|
5010
|
+
//
|
5011
|
+
// GENERAL ERRORS SECTION
|
5012
|
+
//
|
5013
|
+
/**
|
5014
|
+
* Could not determine the origin of the fault. Best to check connectivity and try again
|
5015
|
+
* */
|
5016
|
+
ProtocolError["GENERIC_FAIL"] = "Generic error";
|
5017
|
+
/**
|
5018
|
+
* The remote peer rejected the message. Information provided by the remote peer
|
5019
|
+
* is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
|
5020
|
+
* or `DECODE_FAILED` can be used.
|
5021
|
+
*/
|
5022
|
+
ProtocolError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
|
5023
|
+
/**
|
5024
|
+
* Failure to protobuf decode the message. May be due to a remote peer issue,
|
5025
|
+
* ensuring that messages are sent via several peer enable mitigation of this error.
|
5026
|
+
*/
|
5027
|
+
ProtocolError["DECODE_FAILED"] = "Failed to decode";
|
5028
|
+
/**
|
5029
|
+
* Failure to find a peer with suitable protocols. This may due to a connection issue.
|
5030
|
+
* Mitigation can be: retrying after a given time period, display connectivity issue
|
5031
|
+
* to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`
|
5032
|
+
* on the connection manager before retrying.
|
5033
|
+
*/
|
5034
|
+
ProtocolError["NO_PEER_AVAILABLE"] = "No peer available";
|
5035
|
+
/**
|
5036
|
+
* Failure to find a stream to the peer. This may be because the connection with the peer is not still alive.
|
5037
|
+
* Mitigation can be: retrying after a given time period, or mitigation for `NO_PEER_AVAILABLE` can be used.
|
5038
|
+
*/
|
5039
|
+
ProtocolError["NO_STREAM_AVAILABLE"] = "No stream available";
|
5040
|
+
/**
|
5041
|
+
* The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
|
5042
|
+
* or `DECODE_FAILED` can be used.
|
5043
|
+
*/
|
5044
|
+
ProtocolError["NO_RESPONSE"] = "No response received";
|
5045
|
+
//
|
5046
|
+
// SEND ERRORS SECTION
|
5047
|
+
//
|
5048
|
+
/**
|
5049
|
+
* Failure to protobuf encode the message. This is not recoverable and needs
|
5050
|
+
* further investigation.
|
5051
|
+
*/
|
5052
|
+
ProtocolError["ENCODE_FAILED"] = "Failed to encode";
|
5053
|
+
/**
|
5054
|
+
* The message payload is empty, making the message invalid. Ensure that a non-empty
|
5055
|
+
* payload is set on the outgoing message.
|
5056
|
+
*/
|
5057
|
+
ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
|
5058
|
+
/**
|
5059
|
+
* The message size is above the maximum message size allowed on the Waku Network.
|
5060
|
+
* Compressing the message or using an alternative strategy for large messages is recommended.
|
5061
|
+
*/
|
5062
|
+
ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
|
5063
|
+
/**
|
5064
|
+
* The PubsubTopic passed to the send function is not configured on the Waku node.
|
5065
|
+
* Please ensure that the PubsubTopic is used when initializing the Waku node.
|
5066
|
+
*/
|
5067
|
+
ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
5068
|
+
/**
|
5069
|
+
* Fails when
|
5070
|
+
*/
|
5071
|
+
ProtocolError["STREAM_ABORTED"] = "Stream aborted";
|
5072
|
+
/**
|
5073
|
+
* General proof generation error message.
|
5074
|
+
* nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
|
5075
|
+
*/
|
5076
|
+
ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
|
5077
|
+
//
|
5078
|
+
// RECEIVE ERRORS SECTION
|
5079
|
+
//
|
5080
|
+
/**
|
5081
|
+
* The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
|
5082
|
+
* Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
|
5083
|
+
*/
|
5084
|
+
ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
|
5085
|
+
/**
|
5086
|
+
* The topics passed in the decoders do not match each other, or don't exist at all.
|
5087
|
+
* Ensure that all the pubsub topics used in the decoders are valid and match each other.
|
5088
|
+
*/
|
5089
|
+
ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
|
5090
|
+
})(ProtocolError || (ProtocolError = {}));
|
5091
|
+
|
5092
|
+
var Tags;
|
5093
|
+
(function (Tags) {
|
5094
|
+
Tags["BOOTSTRAP"] = "bootstrap";
|
5095
|
+
Tags["PEER_EXCHANGE"] = "peer-exchange";
|
5096
|
+
Tags["LOCAL"] = "local-peer-cache";
|
5097
|
+
})(Tags || (Tags = {}));
|
5098
|
+
var EPeersByDiscoveryEvents;
|
5099
|
+
(function (EPeersByDiscoveryEvents) {
|
5100
|
+
EPeersByDiscoveryEvents["PEER_DISCOVERY_BOOTSTRAP"] = "peer:discovery:bootstrap";
|
5101
|
+
EPeersByDiscoveryEvents["PEER_DISCOVERY_PEER_EXCHANGE"] = "peer:discovery:peer-exchange";
|
5102
|
+
EPeersByDiscoveryEvents["PEER_CONNECT_BOOTSTRAP"] = "peer:connected:bootstrap";
|
5103
|
+
EPeersByDiscoveryEvents["PEER_CONNECT_PEER_EXCHANGE"] = "peer:connected:peer-exchange";
|
5104
|
+
})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));
|
5105
|
+
var EConnectionStateEvents;
|
5106
|
+
(function (EConnectionStateEvents) {
|
5107
|
+
EConnectionStateEvents["CONNECTION_STATUS"] = "waku:connection";
|
5108
|
+
})(EConnectionStateEvents || (EConnectionStateEvents = {}));
|
4311
5109
|
|
4312
5110
|
/**
|
4313
5111
|
* The default cluster ID for The Waku Network
|
4314
5112
|
*/
|
4315
5113
|
const DEFAULT_CLUSTER_ID = 1;
|
4316
5114
|
|
5115
|
+
var HealthStatusChangeEvents;
|
5116
|
+
(function (HealthStatusChangeEvents) {
|
5117
|
+
HealthStatusChangeEvents["StatusChange"] = "health:change";
|
5118
|
+
})(HealthStatusChangeEvents || (HealthStatusChangeEvents = {}));
|
5119
|
+
var HealthStatus;
|
5120
|
+
(function (HealthStatus) {
|
5121
|
+
HealthStatus["Unhealthy"] = "Unhealthy";
|
5122
|
+
HealthStatus["MinimallyHealthy"] = "MinimallyHealthy";
|
5123
|
+
HealthStatus["SufficientlyHealthy"] = "SufficientlyHealthy";
|
5124
|
+
})(HealthStatus || (HealthStatus = {}));
|
5125
|
+
|
4317
5126
|
/**
|
4318
5127
|
* Turns a `Uint8Array` into a string.
|
4319
5128
|
*
|
@@ -4330,6 +5139,21 @@ function toString(array, encoding = 'utf8') {
|
|
4330
5139
|
return base.encoder.encode(array).substring(1);
|
4331
5140
|
}
|
4332
5141
|
|
5142
|
+
function numberToBytes(value) {
|
5143
|
+
const buffer = new ArrayBuffer(8);
|
5144
|
+
const view = new DataView(buffer);
|
5145
|
+
if (typeof value === "number") {
|
5146
|
+
view.setFloat64(0, value, false);
|
5147
|
+
}
|
5148
|
+
else {
|
5149
|
+
view.setBigInt64(0, value, false);
|
5150
|
+
}
|
5151
|
+
return new Uint8Array(buffer);
|
5152
|
+
}
|
5153
|
+
/**
|
5154
|
+
* Convert byte array to hex string (no `0x` prefix).
|
5155
|
+
*/
|
5156
|
+
const bytesToHex = (bytes) => toString(bytes, "base16");
|
4333
5157
|
/**
|
4334
5158
|
* Decode byte array to utf-8 string.
|
4335
5159
|
*/
|
@@ -4493,6 +5317,781 @@ pubsubTopicShardInfo) {
|
|
4493
5317
|
: contentTopicToPubsubTopic(contentTopic, pubsubTopicShardInfo?.clusterId ?? DEFAULT_CLUSTER_ID);
|
4494
5318
|
}
|
4495
5319
|
|
5320
|
+
function getDefaultExportFromCjs (x) {
|
5321
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
5322
|
+
}
|
5323
|
+
|
5324
|
+
var browser = {exports: {}};
|
5325
|
+
|
5326
|
+
/**
|
5327
|
+
* Helpers.
|
5328
|
+
*/
|
5329
|
+
|
5330
|
+
var ms;
|
5331
|
+
var hasRequiredMs;
|
5332
|
+
|
5333
|
+
function requireMs () {
|
5334
|
+
if (hasRequiredMs) return ms;
|
5335
|
+
hasRequiredMs = 1;
|
5336
|
+
var s = 1000;
|
5337
|
+
var m = s * 60;
|
5338
|
+
var h = m * 60;
|
5339
|
+
var d = h * 24;
|
5340
|
+
var w = d * 7;
|
5341
|
+
var y = d * 365.25;
|
5342
|
+
|
5343
|
+
/**
|
5344
|
+
* Parse or format the given `val`.
|
5345
|
+
*
|
5346
|
+
* Options:
|
5347
|
+
*
|
5348
|
+
* - `long` verbose formatting [false]
|
5349
|
+
*
|
5350
|
+
* @param {String|Number} val
|
5351
|
+
* @param {Object} [options]
|
5352
|
+
* @throws {Error} throw an error if val is not a non-empty string or a number
|
5353
|
+
* @return {String|Number}
|
5354
|
+
* @api public
|
5355
|
+
*/
|
5356
|
+
|
5357
|
+
ms = function (val, options) {
|
5358
|
+
options = options || {};
|
5359
|
+
var type = typeof val;
|
5360
|
+
if (type === 'string' && val.length > 0) {
|
5361
|
+
return parse(val);
|
5362
|
+
} else if (type === 'number' && isFinite(val)) {
|
5363
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
5364
|
+
}
|
5365
|
+
throw new Error(
|
5366
|
+
'val is not a non-empty string or a valid number. val=' +
|
5367
|
+
JSON.stringify(val)
|
5368
|
+
);
|
5369
|
+
};
|
5370
|
+
|
5371
|
+
/**
|
5372
|
+
* Parse the given `str` and return milliseconds.
|
5373
|
+
*
|
5374
|
+
* @param {String} str
|
5375
|
+
* @return {Number}
|
5376
|
+
* @api private
|
5377
|
+
*/
|
5378
|
+
|
5379
|
+
function parse(str) {
|
5380
|
+
str = String(str);
|
5381
|
+
if (str.length > 100) {
|
5382
|
+
return;
|
5383
|
+
}
|
5384
|
+
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(
|
5385
|
+
str
|
5386
|
+
);
|
5387
|
+
if (!match) {
|
5388
|
+
return;
|
5389
|
+
}
|
5390
|
+
var n = parseFloat(match[1]);
|
5391
|
+
var type = (match[2] || 'ms').toLowerCase();
|
5392
|
+
switch (type) {
|
5393
|
+
case 'years':
|
5394
|
+
case 'year':
|
5395
|
+
case 'yrs':
|
5396
|
+
case 'yr':
|
5397
|
+
case 'y':
|
5398
|
+
return n * y;
|
5399
|
+
case 'weeks':
|
5400
|
+
case 'week':
|
5401
|
+
case 'w':
|
5402
|
+
return n * w;
|
5403
|
+
case 'days':
|
5404
|
+
case 'day':
|
5405
|
+
case 'd':
|
5406
|
+
return n * d;
|
5407
|
+
case 'hours':
|
5408
|
+
case 'hour':
|
5409
|
+
case 'hrs':
|
5410
|
+
case 'hr':
|
5411
|
+
case 'h':
|
5412
|
+
return n * h;
|
5413
|
+
case 'minutes':
|
5414
|
+
case 'minute':
|
5415
|
+
case 'mins':
|
5416
|
+
case 'min':
|
5417
|
+
case 'm':
|
5418
|
+
return n * m;
|
5419
|
+
case 'seconds':
|
5420
|
+
case 'second':
|
5421
|
+
case 'secs':
|
5422
|
+
case 'sec':
|
5423
|
+
case 's':
|
5424
|
+
return n * s;
|
5425
|
+
case 'milliseconds':
|
5426
|
+
case 'millisecond':
|
5427
|
+
case 'msecs':
|
5428
|
+
case 'msec':
|
5429
|
+
case 'ms':
|
5430
|
+
return n;
|
5431
|
+
default:
|
5432
|
+
return undefined;
|
5433
|
+
}
|
5434
|
+
}
|
5435
|
+
|
5436
|
+
/**
|
5437
|
+
* Short format for `ms`.
|
5438
|
+
*
|
5439
|
+
* @param {Number} ms
|
5440
|
+
* @return {String}
|
5441
|
+
* @api private
|
5442
|
+
*/
|
5443
|
+
|
5444
|
+
function fmtShort(ms) {
|
5445
|
+
var msAbs = Math.abs(ms);
|
5446
|
+
if (msAbs >= d) {
|
5447
|
+
return Math.round(ms / d) + 'd';
|
5448
|
+
}
|
5449
|
+
if (msAbs >= h) {
|
5450
|
+
return Math.round(ms / h) + 'h';
|
5451
|
+
}
|
5452
|
+
if (msAbs >= m) {
|
5453
|
+
return Math.round(ms / m) + 'm';
|
5454
|
+
}
|
5455
|
+
if (msAbs >= s) {
|
5456
|
+
return Math.round(ms / s) + 's';
|
5457
|
+
}
|
5458
|
+
return ms + 'ms';
|
5459
|
+
}
|
5460
|
+
|
5461
|
+
/**
|
5462
|
+
* Long format for `ms`.
|
5463
|
+
*
|
5464
|
+
* @param {Number} ms
|
5465
|
+
* @return {String}
|
5466
|
+
* @api private
|
5467
|
+
*/
|
5468
|
+
|
5469
|
+
function fmtLong(ms) {
|
5470
|
+
var msAbs = Math.abs(ms);
|
5471
|
+
if (msAbs >= d) {
|
5472
|
+
return plural(ms, msAbs, d, 'day');
|
5473
|
+
}
|
5474
|
+
if (msAbs >= h) {
|
5475
|
+
return plural(ms, msAbs, h, 'hour');
|
5476
|
+
}
|
5477
|
+
if (msAbs >= m) {
|
5478
|
+
return plural(ms, msAbs, m, 'minute');
|
5479
|
+
}
|
5480
|
+
if (msAbs >= s) {
|
5481
|
+
return plural(ms, msAbs, s, 'second');
|
5482
|
+
}
|
5483
|
+
return ms + ' ms';
|
5484
|
+
}
|
5485
|
+
|
5486
|
+
/**
|
5487
|
+
* Pluralization helper.
|
5488
|
+
*/
|
5489
|
+
|
5490
|
+
function plural(ms, msAbs, n, name) {
|
5491
|
+
var isPlural = msAbs >= n * 1.5;
|
5492
|
+
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
5493
|
+
}
|
5494
|
+
return ms;
|
5495
|
+
}
|
5496
|
+
|
5497
|
+
/**
|
5498
|
+
* This is the common logic for both the Node.js and web browser
|
5499
|
+
* implementations of `debug()`.
|
5500
|
+
*/
|
5501
|
+
|
5502
|
+
function setup(env) {
|
5503
|
+
createDebug.debug = createDebug;
|
5504
|
+
createDebug.default = createDebug;
|
5505
|
+
createDebug.coerce = coerce;
|
5506
|
+
createDebug.disable = disable;
|
5507
|
+
createDebug.enable = enable;
|
5508
|
+
createDebug.enabled = enabled;
|
5509
|
+
createDebug.humanize = requireMs();
|
5510
|
+
createDebug.destroy = destroy;
|
5511
|
+
|
5512
|
+
Object.keys(env).forEach(key => {
|
5513
|
+
createDebug[key] = env[key];
|
5514
|
+
});
|
5515
|
+
|
5516
|
+
/**
|
5517
|
+
* The currently active debug mode names, and names to skip.
|
5518
|
+
*/
|
5519
|
+
|
5520
|
+
createDebug.names = [];
|
5521
|
+
createDebug.skips = [];
|
5522
|
+
|
5523
|
+
/**
|
5524
|
+
* Map of special "%n" handling functions, for the debug "format" argument.
|
5525
|
+
*
|
5526
|
+
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
5527
|
+
*/
|
5528
|
+
createDebug.formatters = {};
|
5529
|
+
|
5530
|
+
/**
|
5531
|
+
* Selects a color for a debug namespace
|
5532
|
+
* @param {String} namespace The namespace string for the debug instance to be colored
|
5533
|
+
* @return {Number|String} An ANSI color code for the given namespace
|
5534
|
+
* @api private
|
5535
|
+
*/
|
5536
|
+
function selectColor(namespace) {
|
5537
|
+
let hash = 0;
|
5538
|
+
|
5539
|
+
for (let i = 0; i < namespace.length; i++) {
|
5540
|
+
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
5541
|
+
hash |= 0; // Convert to 32bit integer
|
5542
|
+
}
|
5543
|
+
|
5544
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
5545
|
+
}
|
5546
|
+
createDebug.selectColor = selectColor;
|
5547
|
+
|
5548
|
+
/**
|
5549
|
+
* Create a debugger with the given `namespace`.
|
5550
|
+
*
|
5551
|
+
* @param {String} namespace
|
5552
|
+
* @return {Function}
|
5553
|
+
* @api public
|
5554
|
+
*/
|
5555
|
+
function createDebug(namespace) {
|
5556
|
+
let prevTime;
|
5557
|
+
let enableOverride = null;
|
5558
|
+
let namespacesCache;
|
5559
|
+
let enabledCache;
|
5560
|
+
|
5561
|
+
function debug(...args) {
|
5562
|
+
// Disabled?
|
5563
|
+
if (!debug.enabled) {
|
5564
|
+
return;
|
5565
|
+
}
|
5566
|
+
|
5567
|
+
const self = debug;
|
5568
|
+
|
5569
|
+
// Set `diff` timestamp
|
5570
|
+
const curr = Number(new Date());
|
5571
|
+
const ms = curr - (prevTime || curr);
|
5572
|
+
self.diff = ms;
|
5573
|
+
self.prev = prevTime;
|
5574
|
+
self.curr = curr;
|
5575
|
+
prevTime = curr;
|
5576
|
+
|
5577
|
+
args[0] = createDebug.coerce(args[0]);
|
5578
|
+
|
5579
|
+
if (typeof args[0] !== 'string') {
|
5580
|
+
// Anything else let's inspect with %O
|
5581
|
+
args.unshift('%O');
|
5582
|
+
}
|
5583
|
+
|
5584
|
+
// Apply any `formatters` transformations
|
5585
|
+
let index = 0;
|
5586
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
5587
|
+
// If we encounter an escaped % then don't increase the array index
|
5588
|
+
if (match === '%%') {
|
5589
|
+
return '%';
|
5590
|
+
}
|
5591
|
+
index++;
|
5592
|
+
const formatter = createDebug.formatters[format];
|
5593
|
+
if (typeof formatter === 'function') {
|
5594
|
+
const val = args[index];
|
5595
|
+
match = formatter.call(self, val);
|
5596
|
+
|
5597
|
+
// Now we need to remove `args[index]` since it's inlined in the `format`
|
5598
|
+
args.splice(index, 1);
|
5599
|
+
index--;
|
5600
|
+
}
|
5601
|
+
return match;
|
5602
|
+
});
|
5603
|
+
|
5604
|
+
// Apply env-specific formatting (colors, etc.)
|
5605
|
+
createDebug.formatArgs.call(self, args);
|
5606
|
+
|
5607
|
+
const logFn = self.log || createDebug.log;
|
5608
|
+
logFn.apply(self, args);
|
5609
|
+
}
|
5610
|
+
|
5611
|
+
debug.namespace = namespace;
|
5612
|
+
debug.useColors = createDebug.useColors();
|
5613
|
+
debug.color = createDebug.selectColor(namespace);
|
5614
|
+
debug.extend = extend;
|
5615
|
+
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
5616
|
+
|
5617
|
+
Object.defineProperty(debug, 'enabled', {
|
5618
|
+
enumerable: true,
|
5619
|
+
configurable: false,
|
5620
|
+
get: () => {
|
5621
|
+
if (enableOverride !== null) {
|
5622
|
+
return enableOverride;
|
5623
|
+
}
|
5624
|
+
if (namespacesCache !== createDebug.namespaces) {
|
5625
|
+
namespacesCache = createDebug.namespaces;
|
5626
|
+
enabledCache = createDebug.enabled(namespace);
|
5627
|
+
}
|
5628
|
+
|
5629
|
+
return enabledCache;
|
5630
|
+
},
|
5631
|
+
set: v => {
|
5632
|
+
enableOverride = v;
|
5633
|
+
}
|
5634
|
+
});
|
5635
|
+
|
5636
|
+
// Env-specific initialization logic for debug instances
|
5637
|
+
if (typeof createDebug.init === 'function') {
|
5638
|
+
createDebug.init(debug);
|
5639
|
+
}
|
5640
|
+
|
5641
|
+
return debug;
|
5642
|
+
}
|
5643
|
+
|
5644
|
+
function extend(namespace, delimiter) {
|
5645
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
5646
|
+
newDebug.log = this.log;
|
5647
|
+
return newDebug;
|
5648
|
+
}
|
5649
|
+
|
5650
|
+
/**
|
5651
|
+
* Enables a debug mode by namespaces. This can include modes
|
5652
|
+
* separated by a colon and wildcards.
|
5653
|
+
*
|
5654
|
+
* @param {String} namespaces
|
5655
|
+
* @api public
|
5656
|
+
*/
|
5657
|
+
function enable(namespaces) {
|
5658
|
+
createDebug.save(namespaces);
|
5659
|
+
createDebug.namespaces = namespaces;
|
5660
|
+
|
5661
|
+
createDebug.names = [];
|
5662
|
+
createDebug.skips = [];
|
5663
|
+
|
5664
|
+
const split = (typeof namespaces === 'string' ? namespaces : '')
|
5665
|
+
.trim()
|
5666
|
+
.replace(/\s+/g, ',')
|
5667
|
+
.split(',')
|
5668
|
+
.filter(Boolean);
|
5669
|
+
|
5670
|
+
for (const ns of split) {
|
5671
|
+
if (ns[0] === '-') {
|
5672
|
+
createDebug.skips.push(ns.slice(1));
|
5673
|
+
} else {
|
5674
|
+
createDebug.names.push(ns);
|
5675
|
+
}
|
5676
|
+
}
|
5677
|
+
}
|
5678
|
+
|
5679
|
+
/**
|
5680
|
+
* Checks if the given string matches a namespace template, honoring
|
5681
|
+
* asterisks as wildcards.
|
5682
|
+
*
|
5683
|
+
* @param {String} search
|
5684
|
+
* @param {String} template
|
5685
|
+
* @return {Boolean}
|
5686
|
+
*/
|
5687
|
+
function matchesTemplate(search, template) {
|
5688
|
+
let searchIndex = 0;
|
5689
|
+
let templateIndex = 0;
|
5690
|
+
let starIndex = -1;
|
5691
|
+
let matchIndex = 0;
|
5692
|
+
|
5693
|
+
while (searchIndex < search.length) {
|
5694
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
|
5695
|
+
// Match character or proceed with wildcard
|
5696
|
+
if (template[templateIndex] === '*') {
|
5697
|
+
starIndex = templateIndex;
|
5698
|
+
matchIndex = searchIndex;
|
5699
|
+
templateIndex++; // Skip the '*'
|
5700
|
+
} else {
|
5701
|
+
searchIndex++;
|
5702
|
+
templateIndex++;
|
5703
|
+
}
|
5704
|
+
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
|
5705
|
+
// Backtrack to the last '*' and try to match more characters
|
5706
|
+
templateIndex = starIndex + 1;
|
5707
|
+
matchIndex++;
|
5708
|
+
searchIndex = matchIndex;
|
5709
|
+
} else {
|
5710
|
+
return false; // No match
|
5711
|
+
}
|
5712
|
+
}
|
5713
|
+
|
5714
|
+
// Handle trailing '*' in template
|
5715
|
+
while (templateIndex < template.length && template[templateIndex] === '*') {
|
5716
|
+
templateIndex++;
|
5717
|
+
}
|
5718
|
+
|
5719
|
+
return templateIndex === template.length;
|
5720
|
+
}
|
5721
|
+
|
5722
|
+
/**
|
5723
|
+
* Disable debug output.
|
5724
|
+
*
|
5725
|
+
* @return {String} namespaces
|
5726
|
+
* @api public
|
5727
|
+
*/
|
5728
|
+
function disable() {
|
5729
|
+
const namespaces = [
|
5730
|
+
...createDebug.names,
|
5731
|
+
...createDebug.skips.map(namespace => '-' + namespace)
|
5732
|
+
].join(',');
|
5733
|
+
createDebug.enable('');
|
5734
|
+
return namespaces;
|
5735
|
+
}
|
5736
|
+
|
5737
|
+
/**
|
5738
|
+
* Returns true if the given mode name is enabled, false otherwise.
|
5739
|
+
*
|
5740
|
+
* @param {String} name
|
5741
|
+
* @return {Boolean}
|
5742
|
+
* @api public
|
5743
|
+
*/
|
5744
|
+
function enabled(name) {
|
5745
|
+
for (const skip of createDebug.skips) {
|
5746
|
+
if (matchesTemplate(name, skip)) {
|
5747
|
+
return false;
|
5748
|
+
}
|
5749
|
+
}
|
5750
|
+
|
5751
|
+
for (const ns of createDebug.names) {
|
5752
|
+
if (matchesTemplate(name, ns)) {
|
5753
|
+
return true;
|
5754
|
+
}
|
5755
|
+
}
|
5756
|
+
|
5757
|
+
return false;
|
5758
|
+
}
|
5759
|
+
|
5760
|
+
/**
|
5761
|
+
* Coerce `val`.
|
5762
|
+
*
|
5763
|
+
* @param {Mixed} val
|
5764
|
+
* @return {Mixed}
|
5765
|
+
* @api private
|
5766
|
+
*/
|
5767
|
+
function coerce(val) {
|
5768
|
+
if (val instanceof Error) {
|
5769
|
+
return val.stack || val.message;
|
5770
|
+
}
|
5771
|
+
return val;
|
5772
|
+
}
|
5773
|
+
|
5774
|
+
/**
|
5775
|
+
* XXX DO NOT USE. This is a temporary stub function.
|
5776
|
+
* XXX It WILL be removed in the next major release.
|
5777
|
+
*/
|
5778
|
+
function destroy() {
|
5779
|
+
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
5780
|
+
}
|
5781
|
+
|
5782
|
+
createDebug.enable(createDebug.load());
|
5783
|
+
|
5784
|
+
return createDebug;
|
5785
|
+
}
|
5786
|
+
|
5787
|
+
var common = setup;
|
5788
|
+
|
5789
|
+
/* eslint-env browser */
|
5790
|
+
|
5791
|
+
(function (module, exports) {
|
5792
|
+
/**
|
5793
|
+
* This is the web browser implementation of `debug()`.
|
5794
|
+
*/
|
5795
|
+
|
5796
|
+
exports.formatArgs = formatArgs;
|
5797
|
+
exports.save = save;
|
5798
|
+
exports.load = load;
|
5799
|
+
exports.useColors = useColors;
|
5800
|
+
exports.storage = localstorage();
|
5801
|
+
exports.destroy = (() => {
|
5802
|
+
let warned = false;
|
5803
|
+
|
5804
|
+
return () => {
|
5805
|
+
if (!warned) {
|
5806
|
+
warned = true;
|
5807
|
+
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
5808
|
+
}
|
5809
|
+
};
|
5810
|
+
})();
|
5811
|
+
|
5812
|
+
/**
|
5813
|
+
* Colors.
|
5814
|
+
*/
|
5815
|
+
|
5816
|
+
exports.colors = [
|
5817
|
+
'#0000CC',
|
5818
|
+
'#0000FF',
|
5819
|
+
'#0033CC',
|
5820
|
+
'#0033FF',
|
5821
|
+
'#0066CC',
|
5822
|
+
'#0066FF',
|
5823
|
+
'#0099CC',
|
5824
|
+
'#0099FF',
|
5825
|
+
'#00CC00',
|
5826
|
+
'#00CC33',
|
5827
|
+
'#00CC66',
|
5828
|
+
'#00CC99',
|
5829
|
+
'#00CCCC',
|
5830
|
+
'#00CCFF',
|
5831
|
+
'#3300CC',
|
5832
|
+
'#3300FF',
|
5833
|
+
'#3333CC',
|
5834
|
+
'#3333FF',
|
5835
|
+
'#3366CC',
|
5836
|
+
'#3366FF',
|
5837
|
+
'#3399CC',
|
5838
|
+
'#3399FF',
|
5839
|
+
'#33CC00',
|
5840
|
+
'#33CC33',
|
5841
|
+
'#33CC66',
|
5842
|
+
'#33CC99',
|
5843
|
+
'#33CCCC',
|
5844
|
+
'#33CCFF',
|
5845
|
+
'#6600CC',
|
5846
|
+
'#6600FF',
|
5847
|
+
'#6633CC',
|
5848
|
+
'#6633FF',
|
5849
|
+
'#66CC00',
|
5850
|
+
'#66CC33',
|
5851
|
+
'#9900CC',
|
5852
|
+
'#9900FF',
|
5853
|
+
'#9933CC',
|
5854
|
+
'#9933FF',
|
5855
|
+
'#99CC00',
|
5856
|
+
'#99CC33',
|
5857
|
+
'#CC0000',
|
5858
|
+
'#CC0033',
|
5859
|
+
'#CC0066',
|
5860
|
+
'#CC0099',
|
5861
|
+
'#CC00CC',
|
5862
|
+
'#CC00FF',
|
5863
|
+
'#CC3300',
|
5864
|
+
'#CC3333',
|
5865
|
+
'#CC3366',
|
5866
|
+
'#CC3399',
|
5867
|
+
'#CC33CC',
|
5868
|
+
'#CC33FF',
|
5869
|
+
'#CC6600',
|
5870
|
+
'#CC6633',
|
5871
|
+
'#CC9900',
|
5872
|
+
'#CC9933',
|
5873
|
+
'#CCCC00',
|
5874
|
+
'#CCCC33',
|
5875
|
+
'#FF0000',
|
5876
|
+
'#FF0033',
|
5877
|
+
'#FF0066',
|
5878
|
+
'#FF0099',
|
5879
|
+
'#FF00CC',
|
5880
|
+
'#FF00FF',
|
5881
|
+
'#FF3300',
|
5882
|
+
'#FF3333',
|
5883
|
+
'#FF3366',
|
5884
|
+
'#FF3399',
|
5885
|
+
'#FF33CC',
|
5886
|
+
'#FF33FF',
|
5887
|
+
'#FF6600',
|
5888
|
+
'#FF6633',
|
5889
|
+
'#FF9900',
|
5890
|
+
'#FF9933',
|
5891
|
+
'#FFCC00',
|
5892
|
+
'#FFCC33'
|
5893
|
+
];
|
5894
|
+
|
5895
|
+
/**
|
5896
|
+
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
5897
|
+
* and the Firebug extension (any Firefox version) are known
|
5898
|
+
* to support "%c" CSS customizations.
|
5899
|
+
*
|
5900
|
+
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
5901
|
+
*/
|
5902
|
+
|
5903
|
+
// eslint-disable-next-line complexity
|
5904
|
+
function useColors() {
|
5905
|
+
// NB: In an Electron preload script, document will be defined but not fully
|
5906
|
+
// initialized. Since we know we're in Chrome, we'll just detect this case
|
5907
|
+
// explicitly
|
5908
|
+
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
5909
|
+
return true;
|
5910
|
+
}
|
5911
|
+
|
5912
|
+
// Internet Explorer and Edge do not support colors.
|
5913
|
+
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
5914
|
+
return false;
|
5915
|
+
}
|
5916
|
+
|
5917
|
+
let m;
|
5918
|
+
|
5919
|
+
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
5920
|
+
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
5921
|
+
// eslint-disable-next-line no-return-assign
|
5922
|
+
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
5923
|
+
// Is firebug? http://stackoverflow.com/a/398120/376773
|
5924
|
+
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
5925
|
+
// Is firefox >= v31?
|
5926
|
+
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
5927
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
5928
|
+
// Double check webkit in userAgent just in case we are in a worker
|
5929
|
+
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
5930
|
+
}
|
5931
|
+
|
5932
|
+
/**
|
5933
|
+
* Colorize log arguments if enabled.
|
5934
|
+
*
|
5935
|
+
* @api public
|
5936
|
+
*/
|
5937
|
+
|
5938
|
+
function formatArgs(args) {
|
5939
|
+
args[0] = (this.useColors ? '%c' : '') +
|
5940
|
+
this.namespace +
|
5941
|
+
(this.useColors ? ' %c' : ' ') +
|
5942
|
+
args[0] +
|
5943
|
+
(this.useColors ? '%c ' : ' ') +
|
5944
|
+
'+' + module.exports.humanize(this.diff);
|
5945
|
+
|
5946
|
+
if (!this.useColors) {
|
5947
|
+
return;
|
5948
|
+
}
|
5949
|
+
|
5950
|
+
const c = 'color: ' + this.color;
|
5951
|
+
args.splice(1, 0, c, 'color: inherit');
|
5952
|
+
|
5953
|
+
// The final "%c" is somewhat tricky, because there could be other
|
5954
|
+
// arguments passed either before or after the %c, so we need to
|
5955
|
+
// figure out the correct index to insert the CSS into
|
5956
|
+
let index = 0;
|
5957
|
+
let lastC = 0;
|
5958
|
+
args[0].replace(/%[a-zA-Z%]/g, match => {
|
5959
|
+
if (match === '%%') {
|
5960
|
+
return;
|
5961
|
+
}
|
5962
|
+
index++;
|
5963
|
+
if (match === '%c') {
|
5964
|
+
// We only are interested in the *last* %c
|
5965
|
+
// (the user may have provided their own)
|
5966
|
+
lastC = index;
|
5967
|
+
}
|
5968
|
+
});
|
5969
|
+
|
5970
|
+
args.splice(lastC, 0, c);
|
5971
|
+
}
|
5972
|
+
|
5973
|
+
/**
|
5974
|
+
* Invokes `console.debug()` when available.
|
5975
|
+
* No-op when `console.debug` is not a "function".
|
5976
|
+
* If `console.debug` is not available, falls back
|
5977
|
+
* to `console.log`.
|
5978
|
+
*
|
5979
|
+
* @api public
|
5980
|
+
*/
|
5981
|
+
exports.log = console.debug || console.log || (() => {});
|
5982
|
+
|
5983
|
+
/**
|
5984
|
+
* Save `namespaces`.
|
5985
|
+
*
|
5986
|
+
* @param {String} namespaces
|
5987
|
+
* @api private
|
5988
|
+
*/
|
5989
|
+
function save(namespaces) {
|
5990
|
+
try {
|
5991
|
+
if (namespaces) {
|
5992
|
+
exports.storage.setItem('debug', namespaces);
|
5993
|
+
} else {
|
5994
|
+
exports.storage.removeItem('debug');
|
5995
|
+
}
|
5996
|
+
} catch (error) {
|
5997
|
+
// Swallow
|
5998
|
+
// XXX (@Qix-) should we be logging these?
|
5999
|
+
}
|
6000
|
+
}
|
6001
|
+
|
6002
|
+
/**
|
6003
|
+
* Load `namespaces`.
|
6004
|
+
*
|
6005
|
+
* @return {String} returns the previously persisted debug modes
|
6006
|
+
* @api private
|
6007
|
+
*/
|
6008
|
+
function load() {
|
6009
|
+
let r;
|
6010
|
+
try {
|
6011
|
+
r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;
|
6012
|
+
} catch (error) {
|
6013
|
+
// Swallow
|
6014
|
+
// XXX (@Qix-) should we be logging these?
|
6015
|
+
}
|
6016
|
+
|
6017
|
+
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
6018
|
+
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
6019
|
+
r = process.env.DEBUG;
|
6020
|
+
}
|
6021
|
+
|
6022
|
+
return r;
|
6023
|
+
}
|
6024
|
+
|
6025
|
+
/**
|
6026
|
+
* Localstorage attempts to return the localstorage.
|
6027
|
+
*
|
6028
|
+
* This is necessary because safari throws
|
6029
|
+
* when a user disables cookies/localstorage
|
6030
|
+
* and you attempt to access it.
|
6031
|
+
*
|
6032
|
+
* @return {LocalStorage}
|
6033
|
+
* @api private
|
6034
|
+
*/
|
6035
|
+
|
6036
|
+
function localstorage() {
|
6037
|
+
try {
|
6038
|
+
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
6039
|
+
// The Browser also has localStorage in the global context.
|
6040
|
+
return localStorage;
|
6041
|
+
} catch (error) {
|
6042
|
+
// Swallow
|
6043
|
+
// XXX (@Qix-) should we be logging these?
|
6044
|
+
}
|
6045
|
+
}
|
6046
|
+
|
6047
|
+
module.exports = common(exports);
|
6048
|
+
|
6049
|
+
const {formatters} = module.exports;
|
6050
|
+
|
6051
|
+
/**
|
6052
|
+
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
6053
|
+
*/
|
6054
|
+
|
6055
|
+
formatters.j = function (v) {
|
6056
|
+
try {
|
6057
|
+
return JSON.stringify(v);
|
6058
|
+
} catch (error) {
|
6059
|
+
return '[UnexpectedJSONParseError]: ' + error.message;
|
6060
|
+
}
|
6061
|
+
};
|
6062
|
+
} (browser, browser.exports));
|
6063
|
+
|
6064
|
+
var browserExports = browser.exports;
|
6065
|
+
var debug = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
6066
|
+
|
6067
|
+
const APP_NAME = "waku";
|
6068
|
+
class Logger {
|
6069
|
+
_info;
|
6070
|
+
_warn;
|
6071
|
+
_error;
|
6072
|
+
static createDebugNamespace(level, prefix) {
|
6073
|
+
return prefix ? `${APP_NAME}:${level}:${prefix}` : `${APP_NAME}:${level}`;
|
6074
|
+
}
|
6075
|
+
constructor(prefix) {
|
6076
|
+
this._info = debug(Logger.createDebugNamespace("info", prefix));
|
6077
|
+
this._warn = debug(Logger.createDebugNamespace("warn", prefix));
|
6078
|
+
this._error = debug(Logger.createDebugNamespace("error", prefix));
|
6079
|
+
}
|
6080
|
+
get info() {
|
6081
|
+
return this._info;
|
6082
|
+
}
|
6083
|
+
get warn() {
|
6084
|
+
return this._warn;
|
6085
|
+
}
|
6086
|
+
get error() {
|
6087
|
+
return this._error;
|
6088
|
+
}
|
6089
|
+
log(level, ...args) {
|
6090
|
+
const logger = this[level];
|
6091
|
+
logger(...args);
|
6092
|
+
}
|
6093
|
+
}
|
6094
|
+
|
4496
6095
|
const log = new Logger("message:version-0");
|
4497
6096
|
const OneMillion = BigInt(1_000_000);
|
4498
6097
|
const Version = 0;
|
@@ -4512,9 +6111,6 @@ class DecodedMessage {
|
|
4512
6111
|
get contentTopic() {
|
4513
6112
|
return this.proto.contentTopic;
|
4514
6113
|
}
|
4515
|
-
get _rawTimestamp() {
|
4516
|
-
return this.proto.timestamp;
|
4517
|
-
}
|
4518
6114
|
get timestamp() {
|
4519
6115
|
// In the case we receive a value that is bigger than JS's max number,
|
4520
6116
|
// we catch the error and return undefined.
|
@@ -4536,7 +6132,7 @@ class DecodedMessage {
|
|
4536
6132
|
get version() {
|
4537
6133
|
// https://rfc.vac.dev/spec/14/
|
4538
6134
|
// > If omitted, the value SHOULD be interpreted as version 0.
|
4539
|
-
return this.proto.version ??
|
6135
|
+
return this.proto.version ?? Version;
|
4540
6136
|
}
|
4541
6137
|
get rateLimitProof() {
|
4542
6138
|
return this.proto.rateLimitProof;
|
@@ -4645,4 +6241,4 @@ var version_0 = /*#__PURE__*/Object.freeze({
|
|
4645
6241
|
proto: message
|
4646
6242
|
});
|
4647
6243
|
|
4648
|
-
export {
|
6244
|
+
export { pubsubTopicsToShardInfo as A, WakuMetadataResponse as B, concat as C, sha256 as D, EPeersByDiscoveryEvents as E, FilterSubscribeRequest as F, bytesToHex as G, numberToBytes as H, createDecoder as I, message as J, DecodedMessage as K, Logger as L, MessagePush as M, Encoder as N, Decoder as O, ProtocolError as P, StoreQueryRequest$1 as S, Tags as T, Version as V, WakuMetadataRequest as W, base58btc as a, 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, bases as o, fromString as p, base64url as q, encodeUint8Array as r, createEncoder as s, toString as t, utf8ToBytes as u, version_0 as v, pubsubTopicToSingleShardInfo as w, bytesToUtf8 as x, shardInfoToPubsubTopics as y, EConnectionStateEvents as z };
|