@waku/rln 0.1.6-f7c290d.0 → 0.1.6

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 (105) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/bundle/_virtual/utils.js +2 -2
  3. package/bundle/_virtual/utils2.js +2 -2
  4. package/bundle/index.js +1 -1
  5. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/_sha2.js +1 -1
  6. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/hmac.js +1 -1
  7. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/pbkdf2.js +1 -1
  8. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/scrypt.js +1 -1
  9. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha256.js +1 -1
  10. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha512.js +1 -1
  11. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/utils.js +1 -1
  12. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
  13. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
  14. package/bundle/node_modules/@chainsafe/is-ip/lib/is-ip.js +12 -0
  15. package/bundle/node_modules/@chainsafe/is-ip/lib/parse.js +26 -0
  16. package/bundle/node_modules/@chainsafe/is-ip/lib/parser.js +202 -0
  17. package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +1 -1
  18. package/bundle/node_modules/@multiformats/multiaddr/dist/src/constants.js +43 -0
  19. package/bundle/node_modules/@multiformats/multiaddr/dist/src/errors.js +17 -0
  20. package/bundle/node_modules/@multiformats/multiaddr/dist/src/registry.js +245 -0
  21. package/bundle/node_modules/@multiformats/multiaddr/dist/src/utils.js +191 -0
  22. package/bundle/node_modules/@multiformats/multiaddr/dist/src/validation.js +30 -0
  23. package/bundle/node_modules/debug/src/browser.js +1 -1
  24. package/bundle/node_modules/debug/src/common.js +1 -1
  25. package/bundle/node_modules/lodash/lodash.js +5 -5
  26. package/bundle/node_modules/multiformats/dist/src/bases/base.js +12 -9
  27. package/bundle/node_modules/multiformats/dist/src/bytes.js +19 -3
  28. package/bundle/node_modules/multiformats/dist/src/cid.js +371 -0
  29. package/bundle/node_modules/multiformats/dist/src/hashes/digest.js +62 -0
  30. package/bundle/node_modules/multiformats/dist/src/varint.js +15 -0
  31. package/bundle/node_modules/multiformats/dist/src/vendor/varint.js +78 -0
  32. package/bundle/node_modules/uint8arrays/dist/src/concat.js +20 -0
  33. package/bundle/node_modules/uint8arrays/dist/src/to-string.js +19 -0
  34. package/bundle/node_modules/uint8arrays/dist/src/util/as-uint8array.js +9 -0
  35. package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +1 -3
  36. package/bundle/packages/proto/dist/generated/filter.js +2 -0
  37. package/bundle/packages/proto/dist/generated/filter_v2.js +2 -0
  38. package/bundle/packages/proto/dist/generated/light_push.js +2 -0
  39. package/bundle/packages/proto/dist/generated/message.js +2 -0
  40. package/bundle/packages/proto/dist/generated/metadata.js +2 -0
  41. package/bundle/packages/proto/dist/generated/peer_exchange.js +2 -0
  42. package/bundle/packages/proto/dist/generated/sds_message.js +2 -0
  43. package/bundle/packages/proto/dist/generated/store_v3.js +2 -0
  44. package/bundle/packages/proto/dist/generated/topic_only_message.js +2 -0
  45. package/bundle/packages/rln/dist/contract/constants.js +1 -7
  46. package/bundle/packages/rln/dist/contract/rln_base_contract.js +2 -5
  47. package/bundle/packages/rln/dist/contract/rln_contract.js +2 -2
  48. package/bundle/packages/rln/dist/credentials_manager.js +16 -24
  49. package/bundle/packages/rln/dist/identity.js +6 -8
  50. package/bundle/packages/rln/dist/keystore/keystore.js +10 -21
  51. package/bundle/packages/rln/dist/proof.js +2 -2
  52. package/bundle/packages/rln/dist/utils/bytes.js +58 -103
  53. package/bundle/packages/rln/dist/utils/hash.js +3 -3
  54. package/bundle/packages/rln/dist/zerokit.js +17 -17
  55. package/dist/.tsbuildinfo +1 -1
  56. package/dist/codec.test-utils.d.ts +1 -1
  57. package/dist/contract/constants.d.ts +0 -6
  58. package/dist/contract/constants.js +0 -6
  59. package/dist/contract/constants.js.map +1 -1
  60. package/dist/contract/rln_base_contract.js +2 -5
  61. package/dist/contract/rln_base_contract.js.map +1 -1
  62. package/dist/contract/rln_contract.js +2 -2
  63. package/dist/contract/rln_contract.js.map +1 -1
  64. package/dist/contract/test-setup.d.ts +1 -1
  65. package/dist/contract/test-utils.d.ts +39 -0
  66. package/dist/contract/test-utils.js +118 -0
  67. package/dist/contract/test-utils.js.map +1 -0
  68. package/dist/credentials_manager.d.ts +0 -4
  69. package/dist/credentials_manager.js +16 -25
  70. package/dist/credentials_manager.js.map +1 -1
  71. package/dist/identity.d.ts +2 -5
  72. package/dist/identity.js +5 -8
  73. package/dist/identity.js.map +1 -1
  74. package/dist/keystore/credential_validation_generated.d.ts +0 -2
  75. package/dist/keystore/keystore.js +10 -21
  76. package/dist/keystore/keystore.js.map +1 -1
  77. package/dist/keystore/keystore_validation_generated.d.ts +0 -2
  78. package/dist/proof.js +2 -2
  79. package/dist/proof.js.map +1 -1
  80. package/dist/utils/bytes.d.ts +20 -42
  81. package/dist/utils/bytes.js +57 -102
  82. package/dist/utils/bytes.js.map +1 -1
  83. package/dist/utils/hash.js +5 -5
  84. package/dist/utils/hash.js.map +1 -1
  85. package/dist/utils/index.d.ts +1 -1
  86. package/dist/utils/index.js +1 -1
  87. package/dist/utils/index.js.map +1 -1
  88. package/dist/zerokit.js +17 -17
  89. package/dist/zerokit.js.map +1 -1
  90. package/package.json +93 -1
  91. package/src/contract/constants.ts +0 -9
  92. package/src/contract/rln_base_contract.ts +3 -5
  93. package/src/contract/rln_contract.ts +2 -5
  94. package/src/contract/test-utils.ts +179 -0
  95. package/src/credentials_manager.ts +24 -46
  96. package/src/identity.ts +7 -11
  97. package/src/keystore/keystore.ts +22 -38
  98. package/src/proof.ts +2 -2
  99. package/src/utils/bytes.ts +72 -118
  100. package/src/utils/hash.ts +5 -15
  101. package/src/utils/index.ts +6 -1
  102. package/src/zerokit.ts +22 -30
  103. package/bundle/node_modules/@multiformats/multiaddr/dist/src/convert.js +0 -15
  104. package/bundle/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js +0 -21
  105. package/bundle/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js +0 -92
@@ -0,0 +1,371 @@
1
+ import { base32 } from './bases/base32.js';
2
+ import { base36 } from './bases/base36.js';
3
+ import { base58btc } from './bases/base58.js';
4
+ import { coerce } from './bytes.js';
5
+ import { create, equals, decode, Digest } from './hashes/digest.js';
6
+ import { decode as decode$1, encodeTo, encodingLength } from './varint.js';
7
+
8
+ function format(link, base) {
9
+ const { bytes, version } = link;
10
+ switch (version) {
11
+ case 0:
12
+ return toStringV0(bytes, baseCache(link), base ?? base58btc.encoder);
13
+ default:
14
+ return toStringV1(bytes, baseCache(link), (base ?? base32.encoder));
15
+ }
16
+ }
17
+ const cache = new WeakMap();
18
+ function baseCache(cid) {
19
+ const baseCache = cache.get(cid);
20
+ if (baseCache == null) {
21
+ const baseCache = new Map();
22
+ cache.set(cid, baseCache);
23
+ return baseCache;
24
+ }
25
+ return baseCache;
26
+ }
27
+ class CID {
28
+ code;
29
+ version;
30
+ multihash;
31
+ bytes;
32
+ '/';
33
+ /**
34
+ * @param version - Version of the CID
35
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
36
+ * @param multihash - (Multi)hash of the of the content.
37
+ */
38
+ constructor(version, code, multihash, bytes) {
39
+ this.code = code;
40
+ this.version = version;
41
+ this.multihash = multihash;
42
+ this.bytes = bytes;
43
+ // flag to serializers that this is a CID and
44
+ // should be treated specially
45
+ this['/'] = bytes;
46
+ }
47
+ /**
48
+ * Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
49
+ * please either use `CID.asCID(cid)` or switch to new signalling mechanism
50
+ *
51
+ * @deprecated
52
+ */
53
+ get asCID() {
54
+ return this;
55
+ }
56
+ // ArrayBufferView
57
+ get byteOffset() {
58
+ return this.bytes.byteOffset;
59
+ }
60
+ // ArrayBufferView
61
+ get byteLength() {
62
+ return this.bytes.byteLength;
63
+ }
64
+ toV0() {
65
+ switch (this.version) {
66
+ case 0: {
67
+ return this;
68
+ }
69
+ case 1: {
70
+ const { code, multihash } = this;
71
+ if (code !== DAG_PB_CODE) {
72
+ throw new Error('Cannot convert a non dag-pb CID to CIDv0');
73
+ }
74
+ // sha2-256
75
+ if (multihash.code !== SHA_256_CODE) {
76
+ throw new Error('Cannot convert non sha2-256 multihash CID to CIDv0');
77
+ }
78
+ return (CID.createV0(multihash));
79
+ }
80
+ default: {
81
+ throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
82
+ }
83
+ }
84
+ }
85
+ toV1() {
86
+ switch (this.version) {
87
+ case 0: {
88
+ const { code, digest } = this.multihash;
89
+ const multihash = create(code, digest);
90
+ return (CID.createV1(this.code, multihash));
91
+ }
92
+ case 1: {
93
+ return this;
94
+ }
95
+ default: {
96
+ throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
97
+ }
98
+ }
99
+ }
100
+ equals(other) {
101
+ return CID.equals(this, other);
102
+ }
103
+ static equals(self, other) {
104
+ const unknown = other;
105
+ return (unknown != null &&
106
+ self.code === unknown.code &&
107
+ self.version === unknown.version &&
108
+ equals(self.multihash, unknown.multihash));
109
+ }
110
+ toString(base) {
111
+ return format(this, base);
112
+ }
113
+ toJSON() {
114
+ return { '/': format(this) };
115
+ }
116
+ link() {
117
+ return this;
118
+ }
119
+ [Symbol.toStringTag] = 'CID';
120
+ // Legacy
121
+ [Symbol.for('nodejs.util.inspect.custom')]() {
122
+ return `CID(${this.toString()})`;
123
+ }
124
+ /**
125
+ * Takes any input `value` and returns a `CID` instance if it was
126
+ * a `CID` otherwise returns `null`. If `value` is instanceof `CID`
127
+ * it will return value back. If `value` is not instance of this CID
128
+ * class, but is compatible CID it will return new instance of this
129
+ * `CID` class. Otherwise returns null.
130
+ *
131
+ * This allows two different incompatible versions of CID library to
132
+ * co-exist and interop as long as binary interface is compatible.
133
+ */
134
+ static asCID(input) {
135
+ if (input == null) {
136
+ return null;
137
+ }
138
+ const value = input;
139
+ if (value instanceof CID) {
140
+ // If value is instance of CID then we're all set.
141
+ return value;
142
+ }
143
+ else if ((value['/'] != null && value['/'] === value.bytes) || value.asCID === value) {
144
+ // If value isn't instance of this CID class but `this.asCID === this` or
145
+ // `value['/'] === value.bytes` is true it is CID instance coming from a
146
+ // different implementation (diff version or duplicate). In that case we
147
+ // rebase it to this `CID` implementation so caller is guaranteed to get
148
+ // instance with expected API.
149
+ const { version, code, multihash, bytes } = value;
150
+ return new CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));
151
+ }
152
+ else if (value[cidSymbol] === true) {
153
+ // If value is a CID from older implementation that used to be tagged via
154
+ // symbol we still rebase it to the this `CID` implementation by
155
+ // delegating that to a constructor.
156
+ const { version, multihash, code } = value;
157
+ const digest = decode(multihash);
158
+ return CID.create(version, code, digest);
159
+ }
160
+ else {
161
+ // Otherwise value is not a CID (or an incompatible version of it) in
162
+ // which case we return `null`.
163
+ return null;
164
+ }
165
+ }
166
+ /**
167
+ * @param version - Version of the CID
168
+ * @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
169
+ * @param digest - (Multi)hash of the of the content.
170
+ */
171
+ static create(version, code, digest) {
172
+ if (typeof code !== 'number') {
173
+ throw new Error('String codecs are no longer supported');
174
+ }
175
+ if (!(digest.bytes instanceof Uint8Array)) {
176
+ throw new Error('Invalid digest');
177
+ }
178
+ switch (version) {
179
+ case 0: {
180
+ if (code !== DAG_PB_CODE) {
181
+ throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
182
+ }
183
+ else {
184
+ return new CID(version, code, digest, digest.bytes);
185
+ }
186
+ }
187
+ case 1: {
188
+ const bytes = encodeCID(version, code, digest.bytes);
189
+ return new CID(version, code, digest, bytes);
190
+ }
191
+ default: {
192
+ throw new Error('Invalid version');
193
+ }
194
+ }
195
+ }
196
+ /**
197
+ * Simplified version of `create` for CIDv0.
198
+ */
199
+ static createV0(digest) {
200
+ return CID.create(0, DAG_PB_CODE, digest);
201
+ }
202
+ /**
203
+ * Simplified version of `create` for CIDv1.
204
+ *
205
+ * @param code - Content encoding format code.
206
+ * @param digest - Multihash of the content.
207
+ */
208
+ static createV1(code, digest) {
209
+ return CID.create(1, code, digest);
210
+ }
211
+ /**
212
+ * Decoded a CID from its binary representation. The byte array must contain
213
+ * only the CID with no additional bytes.
214
+ *
215
+ * An error will be thrown if the bytes provided do not contain a valid
216
+ * binary representation of a CID.
217
+ */
218
+ static decode(bytes) {
219
+ const [cid, remainder] = CID.decodeFirst(bytes);
220
+ if (remainder.length !== 0) {
221
+ throw new Error('Incorrect length');
222
+ }
223
+ return cid;
224
+ }
225
+ /**
226
+ * Decoded a CID from its binary representation at the beginning of a byte
227
+ * array.
228
+ *
229
+ * Returns an array with the first element containing the CID and the second
230
+ * element containing the remainder of the original byte array. The remainder
231
+ * will be a zero-length byte array if the provided bytes only contained a
232
+ * binary CID representation.
233
+ */
234
+ static decodeFirst(bytes) {
235
+ const specs = CID.inspectBytes(bytes);
236
+ const prefixSize = specs.size - specs.multihashSize;
237
+ const multihashBytes = coerce(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
238
+ if (multihashBytes.byteLength !== specs.multihashSize) {
239
+ throw new Error('Incorrect length');
240
+ }
241
+ const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
242
+ const digest = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
243
+ const cid = specs.version === 0
244
+ ? CID.createV0(digest)
245
+ : CID.createV1(specs.codec, digest);
246
+ return [cid, bytes.subarray(specs.size)];
247
+ }
248
+ /**
249
+ * Inspect the initial bytes of a CID to determine its properties.
250
+ *
251
+ * Involves decoding up to 4 varints. Typically this will require only 4 to 6
252
+ * bytes but for larger multicodec code values and larger multihash digest
253
+ * lengths these varints can be quite large. It is recommended that at least
254
+ * 10 bytes be made available in the `initialBytes` argument for a complete
255
+ * inspection.
256
+ */
257
+ static inspectBytes(initialBytes) {
258
+ let offset = 0;
259
+ const next = () => {
260
+ const [i, length] = decode$1(initialBytes.subarray(offset));
261
+ offset += length;
262
+ return i;
263
+ };
264
+ let version = next();
265
+ let codec = DAG_PB_CODE;
266
+ if (version === 18) {
267
+ // CIDv0
268
+ version = 0;
269
+ offset = 0;
270
+ }
271
+ else {
272
+ codec = next();
273
+ }
274
+ if (version !== 0 && version !== 1) {
275
+ throw new RangeError(`Invalid CID version ${version}`);
276
+ }
277
+ const prefixSize = offset;
278
+ const multihashCode = next(); // multihash code
279
+ const digestSize = next(); // multihash length
280
+ const size = offset + digestSize;
281
+ const multihashSize = size - prefixSize;
282
+ return { version, codec, multihashCode, digestSize, multihashSize, size };
283
+ }
284
+ /**
285
+ * Takes cid in a string representation and creates an instance. If `base`
286
+ * decoder is not provided will use a default from the configuration. It will
287
+ * throw an error if encoding of the CID is not compatible with supplied (or
288
+ * a default decoder).
289
+ */
290
+ static parse(source, base) {
291
+ const [prefix, bytes] = parseCIDtoBytes(source, base);
292
+ const cid = CID.decode(bytes);
293
+ if (cid.version === 0 && source[0] !== 'Q') {
294
+ throw Error('Version 0 CID string must not include multibase prefix');
295
+ }
296
+ // Cache string representation to avoid computing it on `this.toString()`
297
+ baseCache(cid).set(prefix, source);
298
+ return cid;
299
+ }
300
+ }
301
+ function parseCIDtoBytes(source, base) {
302
+ switch (source[0]) {
303
+ // CIDv0 is parsed differently
304
+ case 'Q': {
305
+ const decoder = base ?? base58btc;
306
+ return [
307
+ base58btc.prefix,
308
+ decoder.decode(`${base58btc.prefix}${source}`)
309
+ ];
310
+ }
311
+ case base58btc.prefix: {
312
+ const decoder = base ?? base58btc;
313
+ return [base58btc.prefix, decoder.decode(source)];
314
+ }
315
+ case base32.prefix: {
316
+ const decoder = base ?? base32;
317
+ return [base32.prefix, decoder.decode(source)];
318
+ }
319
+ case base36.prefix: {
320
+ const decoder = base ?? base36;
321
+ return [base36.prefix, decoder.decode(source)];
322
+ }
323
+ default: {
324
+ if (base == null) {
325
+ throw Error('To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided');
326
+ }
327
+ return [source[0], base.decode(source)];
328
+ }
329
+ }
330
+ }
331
+ function toStringV0(bytes, cache, base) {
332
+ const { prefix } = base;
333
+ if (prefix !== base58btc.prefix) {
334
+ throw Error(`Cannot string encode V0 in ${base.name} encoding`);
335
+ }
336
+ const cid = cache.get(prefix);
337
+ if (cid == null) {
338
+ const cid = base.encode(bytes).slice(1);
339
+ cache.set(prefix, cid);
340
+ return cid;
341
+ }
342
+ else {
343
+ return cid;
344
+ }
345
+ }
346
+ function toStringV1(bytes, cache, base) {
347
+ const { prefix } = base;
348
+ const cid = cache.get(prefix);
349
+ if (cid == null) {
350
+ const cid = base.encode(bytes);
351
+ cache.set(prefix, cid);
352
+ return cid;
353
+ }
354
+ else {
355
+ return cid;
356
+ }
357
+ }
358
+ const DAG_PB_CODE = 0x70;
359
+ const SHA_256_CODE = 0x12;
360
+ function encodeCID(version, code, multihash) {
361
+ const codeOffset = encodingLength(version);
362
+ const hashOffset = codeOffset + encodingLength(code);
363
+ const bytes = new Uint8Array(hashOffset + multihash.byteLength);
364
+ encodeTo(version, bytes, 0);
365
+ encodeTo(code, bytes, codeOffset);
366
+ bytes.set(multihash, hashOffset);
367
+ return bytes;
368
+ }
369
+ const cidSymbol = Symbol.for('@ipld/js-cid/CID');
370
+
371
+ export { CID, format };
@@ -0,0 +1,62 @@
1
+ import { equals as equals$1, coerce } from '../bytes.js';
2
+ import { encodeTo, decode as decode$1, encodingLength } from '../varint.js';
3
+
4
+ /**
5
+ * Creates a multihash digest.
6
+ */
7
+ function create(code, digest) {
8
+ const size = digest.byteLength;
9
+ const sizeOffset = encodingLength(code);
10
+ const digestOffset = sizeOffset + encodingLength(size);
11
+ const bytes = new Uint8Array(digestOffset + size);
12
+ encodeTo(code, bytes, 0);
13
+ encodeTo(size, bytes, sizeOffset);
14
+ bytes.set(digest, digestOffset);
15
+ return new Digest(code, size, digest, bytes);
16
+ }
17
+ /**
18
+ * Turns bytes representation of multihash digest into an instance.
19
+ */
20
+ function decode(multihash) {
21
+ const bytes = coerce(multihash);
22
+ const [code, sizeOffset] = decode$1(bytes);
23
+ const [size, digestOffset] = decode$1(bytes.subarray(sizeOffset));
24
+ const digest = bytes.subarray(sizeOffset + digestOffset);
25
+ if (digest.byteLength !== size) {
26
+ throw new Error('Incorrect length');
27
+ }
28
+ return new Digest(code, size, digest, bytes);
29
+ }
30
+ function equals(a, b) {
31
+ if (a === b) {
32
+ return true;
33
+ }
34
+ else {
35
+ const data = b;
36
+ return (a.code === data.code &&
37
+ a.size === data.size &&
38
+ data.bytes instanceof Uint8Array &&
39
+ equals$1(a.bytes, data.bytes));
40
+ }
41
+ }
42
+ /**
43
+ * Represents a multihash digest which carries information about the
44
+ * hashing algorithm and an actual hash digest.
45
+ */
46
+ class Digest {
47
+ code;
48
+ size;
49
+ digest;
50
+ bytes;
51
+ /**
52
+ * Creates a multihash digest.
53
+ */
54
+ constructor(code, size, digest, bytes) {
55
+ this.code = code;
56
+ this.size = size;
57
+ this.digest = digest;
58
+ this.bytes = bytes;
59
+ }
60
+ }
61
+
62
+ export { Digest, create, decode, equals };
@@ -0,0 +1,15 @@
1
+ import _brrp_varint from './vendor/varint.js';
2
+
3
+ function decode(data, offset = 0) {
4
+ const code = _brrp_varint.decode(data, offset);
5
+ return [code, _brrp_varint.decode.bytes];
6
+ }
7
+ function encodeTo(int, target, offset = 0) {
8
+ _brrp_varint.encode(int, target, offset);
9
+ return target;
10
+ }
11
+ function encodingLength(int) {
12
+ return _brrp_varint.encodingLength(int);
13
+ }
14
+
15
+ export { decode, encodeTo, encodingLength };
@@ -0,0 +1,78 @@
1
+ /* eslint-disable */
2
+ var encode_1 = encode;
3
+ var MSB = 0x80, MSBALL = -128, INT = Math.pow(2, 31);
4
+ /**
5
+ * @param {number} num
6
+ * @param {number[]} out
7
+ * @param {number} offset
8
+ */
9
+ function encode(num, out, offset) {
10
+ out = out || [];
11
+ offset = offset || 0;
12
+ var oldOffset = offset;
13
+ while (num >= INT) {
14
+ out[offset++] = (num & 0xFF) | MSB;
15
+ num /= 128;
16
+ }
17
+ while (num & MSBALL) {
18
+ out[offset++] = (num & 0xFF) | MSB;
19
+ num >>>= 7;
20
+ }
21
+ out[offset] = num | 0;
22
+ // @ts-ignore
23
+ encode.bytes = offset - oldOffset + 1;
24
+ return out;
25
+ }
26
+ var decode = read;
27
+ var MSB$1 = 0x80, REST$1 = 0x7F;
28
+ /**
29
+ * @param {string | any[]} buf
30
+ * @param {number} offset
31
+ */
32
+ function read(buf, offset) {
33
+ var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
34
+ do {
35
+ if (counter >= l) {
36
+ // @ts-ignore
37
+ read.bytes = 0;
38
+ throw new RangeError('Could not decode varint');
39
+ }
40
+ b = buf[counter++];
41
+ res += shift < 28
42
+ ? (b & REST$1) << shift
43
+ : (b & REST$1) * Math.pow(2, shift);
44
+ shift += 7;
45
+ } while (b >= MSB$1);
46
+ // @ts-ignore
47
+ read.bytes = counter - offset;
48
+ return res;
49
+ }
50
+ var N1 = Math.pow(2, 7);
51
+ var N2 = Math.pow(2, 14);
52
+ var N3 = Math.pow(2, 21);
53
+ var N4 = Math.pow(2, 28);
54
+ var N5 = Math.pow(2, 35);
55
+ var N6 = Math.pow(2, 42);
56
+ var N7 = Math.pow(2, 49);
57
+ var N8 = Math.pow(2, 56);
58
+ var N9 = Math.pow(2, 63);
59
+ var length = function (/** @type {number} */ value) {
60
+ return (value < N1 ? 1
61
+ : value < N2 ? 2
62
+ : value < N3 ? 3
63
+ : value < N4 ? 4
64
+ : value < N5 ? 5
65
+ : value < N6 ? 6
66
+ : value < N7 ? 7
67
+ : value < N8 ? 8
68
+ : value < N9 ? 9
69
+ : 10);
70
+ };
71
+ var varint = {
72
+ encode: encode_1,
73
+ decode: decode,
74
+ encodingLength: length
75
+ };
76
+ var _brrp_varint = varint;
77
+
78
+ export { _brrp_varint as default };
@@ -0,0 +1,20 @@
1
+ import { allocUnsafe } from './alloc.js';
2
+ import { asUint8Array } from './util/as-uint8array.js';
3
+
4
+ /**
5
+ * Returns a new Uint8Array created by concatenating the passed Uint8Arrays
6
+ */
7
+ function concat(arrays, length) {
8
+ if (length == null) {
9
+ length = arrays.reduce((acc, curr) => acc + curr.length, 0);
10
+ }
11
+ const output = allocUnsafe(length);
12
+ let offset = 0;
13
+ for (const arr of arrays) {
14
+ output.set(arr, offset);
15
+ offset += arr.length;
16
+ }
17
+ return asUint8Array(output);
18
+ }
19
+
20
+ export { concat };
@@ -0,0 +1,19 @@
1
+ import BASES from './util/bases.js';
2
+
3
+ /**
4
+ * Turns a `Uint8Array` into a string.
5
+ *
6
+ * Supports `utf8`, `utf-8` and any encoding supported by the multibase module.
7
+ *
8
+ * Also `ascii` which is similar to node's 'binary' encoding.
9
+ */
10
+ function toString(array, encoding = 'utf8') {
11
+ const base = BASES[encoding];
12
+ if (base == null) {
13
+ throw new Error(`Unsupported encoding "${encoding}"`);
14
+ }
15
+ // strip multibase prefix
16
+ return base.encoder.encode(array).substring(1);
17
+ }
18
+
19
+ export { toString };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * To guarantee Uint8Array semantics, convert nodejs Buffers
3
+ * into vanilla Uint8Arrays
4
+ */
5
+ function asUint8Array(buf) {
6
+ return buf;
7
+ }
8
+
9
+ export { asUint8Array };
@@ -9,9 +9,7 @@ import '../../../../../node_modules/multiformats/dist/src/bases/base64.js';
9
9
  import '../../../../../node_modules/multiformats/dist/src/bases/base8.js';
10
10
  import '../../../../../node_modules/multiformats/dist/src/bases/identity.js';
11
11
  import '../../../../../node_modules/multiformats/dist/src/codecs/json.js';
12
- import '../../../../../node_modules/@multiformats/multiaddr/dist/src/convert.js';
13
- import '../../../../../node_modules/@multiformats/multiaddr/dist/src/protocols-table.js';
14
- import '../../../../../node_modules/@multiformats/multiaddr/dist/src/multiaddr.js';
12
+ import '../../../../../node_modules/@multiformats/multiaddr/dist/src/registry.js';
15
13
  import '../../../../interfaces/dist/protocols.js';
16
14
  import '../../../../interfaces/dist/connection_manager.js';
17
15
  import '../../../../interfaces/dist/health_indicator.js';
@@ -9,6 +9,8 @@ import { decodeMessage } from '../../../../node_modules/protons-runtime/dist/src
9
9
  /* eslint-disable @typescript-eslint/no-namespace */
10
10
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
11
11
  /* eslint-disable @typescript-eslint/no-empty-interface */
12
+ /* eslint-disable import/consistent-type-specifier-style */
13
+ /* eslint-disable @typescript-eslint/no-unused-vars */
12
14
  var FilterRequest;
13
15
  (function (FilterRequest) {
14
16
  (function (ContentFilter) {
@@ -10,6 +10,8 @@ import { decodeMessage } from '../../../../node_modules/protons-runtime/dist/src
10
10
  /* eslint-disable @typescript-eslint/no-namespace */
11
11
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
12
12
  /* eslint-disable @typescript-eslint/no-empty-interface */
13
+ /* eslint-disable import/consistent-type-specifier-style */
14
+ /* eslint-disable @typescript-eslint/no-unused-vars */
13
15
  var FilterSubscribeRequest;
14
16
  (function (FilterSubscribeRequest) {
15
17
  let FilterSubscribeType;
@@ -12,6 +12,8 @@ import '../../../../node_modules/protons-runtime/dist/src/utils/writer.js';
12
12
  /* eslint-disable @typescript-eslint/no-namespace */
13
13
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
14
14
  /* eslint-disable @typescript-eslint/no-empty-interface */
15
+ /* eslint-disable import/consistent-type-specifier-style */
16
+ /* eslint-disable @typescript-eslint/no-unused-vars */
15
17
  var PushRequest;
16
18
  (function (PushRequest) {
17
19
  let _codec;
@@ -12,6 +12,8 @@ import '../../../../node_modules/protons-runtime/dist/src/utils/writer.js';
12
12
  /* eslint-disable @typescript-eslint/no-namespace */
13
13
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
14
14
  /* eslint-disable @typescript-eslint/no-empty-interface */
15
+ /* eslint-disable import/consistent-type-specifier-style */
16
+ /* eslint-disable @typescript-eslint/no-unused-vars */
15
17
  var RateLimitProof;
16
18
  (function (RateLimitProof) {
17
19
  let _codec;
@@ -8,6 +8,8 @@ import { decodeMessage } from '../../../../node_modules/protons-runtime/dist/src
8
8
  /* eslint-disable @typescript-eslint/no-namespace */
9
9
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
10
10
  /* eslint-disable @typescript-eslint/no-empty-interface */
11
+ /* eslint-disable import/consistent-type-specifier-style */
12
+ /* eslint-disable @typescript-eslint/no-unused-vars */
11
13
  var WakuMetadataRequest;
12
14
  (function (WakuMetadataRequest) {
13
15
  let _codec;
@@ -8,6 +8,8 @@ import { decodeMessage } from '../../../../node_modules/protons-runtime/dist/src
8
8
  /* eslint-disable @typescript-eslint/no-namespace */
9
9
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
10
10
  /* eslint-disable @typescript-eslint/no-empty-interface */
11
+ /* eslint-disable import/consistent-type-specifier-style */
12
+ /* eslint-disable @typescript-eslint/no-unused-vars */
11
13
  var PeerInfo;
12
14
  (function (PeerInfo) {
13
15
  let _codec;
@@ -8,6 +8,8 @@ import { decodeMessage } from '../../../../node_modules/protons-runtime/dist/src
8
8
  /* eslint-disable @typescript-eslint/no-namespace */
9
9
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
10
10
  /* eslint-disable @typescript-eslint/no-empty-interface */
11
+ /* eslint-disable import/consistent-type-specifier-style */
12
+ /* eslint-disable @typescript-eslint/no-unused-vars */
11
13
  var HistoryEntry;
12
14
  (function (HistoryEntry) {
13
15
  let _codec;
@@ -9,6 +9,8 @@ import { decodeMessage } from '../../../../node_modules/protons-runtime/dist/src
9
9
  /* eslint-disable @typescript-eslint/no-namespace */
10
10
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
11
11
  /* eslint-disable @typescript-eslint/no-empty-interface */
12
+ /* eslint-disable import/consistent-type-specifier-style */
13
+ /* eslint-disable @typescript-eslint/no-unused-vars */
12
14
  var WakuMessageKeyValue;
13
15
  (function (WakuMessageKeyValue) {
14
16
  let _codec;
@@ -11,6 +11,8 @@ import '../../../../node_modules/protons-runtime/dist/src/utils/writer.js';
11
11
  /* eslint-disable @typescript-eslint/no-namespace */
12
12
  /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
13
13
  /* eslint-disable @typescript-eslint/no-empty-interface */
14
+ /* eslint-disable import/consistent-type-specifier-style */
15
+ /* eslint-disable @typescript-eslint/no-unused-vars */
14
16
  var TopicOnlyMessage;
15
17
  (function (TopicOnlyMessage) {
16
18
  let _codec;