@waku/core 0.0.34-c43cec2.0 → 0.0.34-caeafce.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/bundle/{base_protocol-DxFKDXX2.js → base_protocol-Bp5a9PNG.js} +19 -20
  2. package/bundle/{index-yLOEQnIE.js → index-G1eRBjeI.js} +115 -84
  3. package/bundle/index.js +1828 -153
  4. package/bundle/lib/base_protocol.js +2 -2
  5. package/bundle/lib/message/version_0.js +2 -2
  6. package/bundle/{version_0-Che4t3mN.js → version_0-DJZG2fB2.js} +163 -42
  7. package/dist/.tsbuildinfo +1 -1
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.js +0 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/lib/base_protocol.d.ts +2 -2
  12. package/dist/lib/base_protocol.js +2 -2
  13. package/dist/lib/base_protocol.js.map +1 -1
  14. package/dist/lib/connection_manager/connection_manager.d.ts +56 -3
  15. package/dist/lib/connection_manager/connection_manager.js +96 -13
  16. package/dist/lib/connection_manager/connection_manager.js.map +1 -1
  17. package/dist/lib/filter/filter.d.ts +18 -0
  18. package/dist/lib/filter/filter.js +209 -0
  19. package/dist/lib/filter/filter.js.map +1 -0
  20. package/dist/lib/filter/index.d.ts +1 -18
  21. package/dist/lib/filter/index.js +1 -208
  22. package/dist/lib/filter/index.js.map +1 -1
  23. package/dist/lib/light_push/index.d.ts +1 -15
  24. package/dist/lib/light_push/index.js +1 -144
  25. package/dist/lib/light_push/index.js.map +1 -1
  26. package/dist/lib/light_push/light_push.d.ts +15 -0
  27. package/dist/lib/light_push/light_push.js +144 -0
  28. package/dist/lib/light_push/light_push.js.map +1 -0
  29. package/dist/lib/light_push/utils.d.ts +0 -2
  30. package/dist/lib/light_push/utils.js +9 -17
  31. package/dist/lib/light_push/utils.js.map +1 -1
  32. package/dist/lib/metadata/index.d.ts +1 -3
  33. package/dist/lib/metadata/index.js +1 -118
  34. package/dist/lib/metadata/index.js.map +1 -1
  35. package/dist/lib/metadata/metadata.d.ts +3 -0
  36. package/dist/lib/metadata/metadata.js +119 -0
  37. package/dist/lib/metadata/metadata.js.map +1 -0
  38. package/dist/lib/store/index.d.ts +1 -9
  39. package/dist/lib/store/index.js +1 -82
  40. package/dist/lib/store/index.js.map +1 -1
  41. package/dist/lib/store/store.d.ts +9 -0
  42. package/dist/lib/store/store.js +83 -0
  43. package/dist/lib/store/store.js.map +1 -0
  44. package/dist/lib/stream_manager/stream_manager.d.ts +2 -2
  45. package/dist/lib/stream_manager/stream_manager.js +16 -17
  46. package/dist/lib/stream_manager/stream_manager.js.map +1 -1
  47. package/package.json +1 -1
  48. package/src/index.ts +0 -2
  49. package/src/lib/base_protocol.ts +3 -3
  50. package/src/lib/connection_manager/connection_manager.ts +114 -20
  51. package/src/lib/filter/filter.ts +315 -0
  52. package/src/lib/filter/index.ts +1 -315
  53. package/src/lib/light_push/index.ts +1 -189
  54. package/src/lib/light_push/light_push.ts +188 -0
  55. package/src/lib/light_push/utils.ts +13 -21
  56. package/src/lib/metadata/index.ts +1 -182
  57. package/src/lib/metadata/metadata.ts +182 -0
  58. package/src/lib/store/index.ts +1 -136
  59. package/src/lib/store/store.ts +136 -0
  60. package/src/lib/stream_manager/stream_manager.ts +16 -18
  61. package/dist/lib/health_manager.d.ts +0 -14
  62. package/dist/lib/health_manager.js +0 -70
  63. package/dist/lib/health_manager.js.map +0 -1
  64. package/src/lib/health_manager.ts +0 -90
@@ -1,2 +1,2 @@
1
- export { B as BaseProtocol } from '../base_protocol-DxFKDXX2.js';
2
- import '../index-yLOEQnIE.js';
1
+ export { B as BaseProtocol } from '../base_protocol-Bp5a9PNG.js';
2
+ import '../index-G1eRBjeI.js';
@@ -1,2 +1,2 @@
1
- export { D as DecodedMessage, o as Decoder, E as Encoder, V as Version, m as createDecoder, i as createEncoder, n as proto } from '../../version_0-Che4t3mN.js';
2
- import '../../index-yLOEQnIE.js';
1
+ export { D as DecodedMessage, r as Decoder, E as Encoder, V as Version, o as createDecoder, k as createEncoder, q as proto } from '../../version_0-DJZG2fB2.js';
2
+ import '../../index-G1eRBjeI.js';
@@ -1,4 +1,4 @@
1
- import { i as identityBase, c as base2, d as base8, e as base10, f as base16, g as base32, h as base36, j as base58, k as base64, l as base256emoji, L as Logger } from './index-yLOEQnIE.js';
1
+ import { i as identityBase, g as base2, h as base8, j as base10, k as base16, l as base32, m as base36, n as base58, o as base64, p as base256emoji, L as Logger } from './index-G1eRBjeI.js';
2
2
 
3
3
  /**
4
4
  * Returns a `Uint8Array` of the requested size. Referenced memory will
@@ -3829,31 +3829,141 @@ var WakuMetadataResponse;
3829
3829
  };
3830
3830
  })(WakuMetadataResponse || (WakuMetadataResponse = {}));
3831
3831
 
3832
- // copied from utils
3832
+ /* eslint-disable import/export */
3833
+ /* eslint-disable complexity */
3834
+ /* eslint-disable @typescript-eslint/no-namespace */
3835
+ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
3836
+ /* eslint-disable @typescript-eslint/no-empty-interface */
3837
+ var SdsMessage;
3838
+ (function (SdsMessage) {
3839
+ let _codec;
3840
+ SdsMessage.codec = () => {
3841
+ if (_codec == null) {
3842
+ _codec = message$1((obj, w, opts = {}) => {
3843
+ if (opts.lengthDelimited !== false) {
3844
+ w.fork();
3845
+ }
3846
+ if ((obj.messageId != null && obj.messageId !== '')) {
3847
+ w.uint32(18);
3848
+ w.string(obj.messageId);
3849
+ }
3850
+ if ((obj.channelId != null && obj.channelId !== '')) {
3851
+ w.uint32(26);
3852
+ w.string(obj.channelId);
3853
+ }
3854
+ if (obj.lamportTimestamp != null) {
3855
+ w.uint32(80);
3856
+ w.int32(obj.lamportTimestamp);
3857
+ }
3858
+ if (obj.causalHistory != null) {
3859
+ for (const value of obj.causalHistory) {
3860
+ w.uint32(90);
3861
+ w.string(value);
3862
+ }
3863
+ }
3864
+ if (obj.bloomFilter != null) {
3865
+ w.uint32(98);
3866
+ w.bytes(obj.bloomFilter);
3867
+ }
3868
+ if (obj.content != null) {
3869
+ w.uint32(162);
3870
+ w.bytes(obj.content);
3871
+ }
3872
+ if (opts.lengthDelimited !== false) {
3873
+ w.ldelim();
3874
+ }
3875
+ }, (reader, length, opts = {}) => {
3876
+ const obj = {
3877
+ messageId: '',
3878
+ channelId: '',
3879
+ causalHistory: []
3880
+ };
3881
+ const end = length == null ? reader.len : reader.pos + length;
3882
+ while (reader.pos < end) {
3883
+ const tag = reader.uint32();
3884
+ switch (tag >>> 3) {
3885
+ case 2: {
3886
+ obj.messageId = reader.string();
3887
+ break;
3888
+ }
3889
+ case 3: {
3890
+ obj.channelId = reader.string();
3891
+ break;
3892
+ }
3893
+ case 10: {
3894
+ obj.lamportTimestamp = reader.int32();
3895
+ break;
3896
+ }
3897
+ case 11: {
3898
+ if (opts.limits?.causalHistory != null && obj.causalHistory.length === opts.limits.causalHistory) {
3899
+ throw new MaxLengthError('Decode error - map field "causalHistory" had too many elements');
3900
+ }
3901
+ obj.causalHistory.push(reader.string());
3902
+ break;
3903
+ }
3904
+ case 12: {
3905
+ obj.bloomFilter = reader.bytes();
3906
+ break;
3907
+ }
3908
+ case 20: {
3909
+ obj.content = reader.bytes();
3910
+ break;
3911
+ }
3912
+ default: {
3913
+ reader.skipType(tag & 7);
3914
+ break;
3915
+ }
3916
+ }
3917
+ }
3918
+ return obj;
3919
+ });
3920
+ }
3921
+ return _codec;
3922
+ };
3923
+ SdsMessage.encode = (obj) => {
3924
+ return encodeMessage(obj, SdsMessage.codec());
3925
+ };
3926
+ SdsMessage.decode = (buf, opts) => {
3927
+ return decodeMessage(buf, SdsMessage.codec(), opts);
3928
+ };
3929
+ })(SdsMessage || (SdsMessage = {}));
3930
+
3931
+ /**
3932
+ * Internal assertion helpers.
3933
+ * @module
3934
+ */
3935
+ /** Asserts something is positive integer. */
3936
+ /** Is number an Uint8Array? Copied from utils for perf. */
3833
3937
  function isBytes(a) {
3834
- return (a instanceof Uint8Array ||
3835
- (a != null && typeof a === 'object' && a.constructor.name === 'Uint8Array'));
3938
+ return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
3836
3939
  }
3837
- function bytes(b, ...lengths) {
3940
+ /** Asserts something is Uint8Array. */
3941
+ function abytes(b, ...lengths) {
3838
3942
  if (!isBytes(b))
3839
3943
  throw new Error('Uint8Array expected');
3840
3944
  if (lengths.length > 0 && !lengths.includes(b.length))
3841
- throw new Error(`Uint8Array expected of length ${lengths}, not of length=${b.length}`);
3945
+ throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
3842
3946
  }
3843
- function exists(instance, checkFinished = true) {
3947
+ /** Asserts a hash instance has not been destroyed / finished */
3948
+ function aexists(instance, checkFinished = true) {
3844
3949
  if (instance.destroyed)
3845
3950
  throw new Error('Hash instance has been destroyed');
3846
3951
  if (checkFinished && instance.finished)
3847
3952
  throw new Error('Hash#digest() has already been called');
3848
3953
  }
3849
- function output(out, instance) {
3850
- bytes(out);
3954
+ /** Asserts output is properly-sized byte array */
3955
+ function aoutput(out, instance) {
3956
+ abytes(out);
3851
3957
  const min = instance.outputLen;
3852
3958
  if (out.length < min) {
3853
- throw new Error(`digestInto() expects output buffer of length at least ${min}`);
3959
+ throw new Error('digestInto() expects output buffer of length at least ' + min);
3854
3960
  }
3855
3961
  }
3856
3962
 
3963
+ /**
3964
+ * Utilities for hex, bytes, CSPRNG.
3965
+ * @module
3966
+ */
3857
3967
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
3858
3968
  // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
3859
3969
  // node.js versions earlier than v19 don't declare it in global scope.
@@ -3862,16 +3972,20 @@ function output(out, instance) {
3862
3972
  // Makes the utils un-importable in browsers without a bundler.
3863
3973
  // Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
3864
3974
  // Cast array to view
3865
- const createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
3866
- // The rotate right (circular right shift) operation for uint32
3867
- const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
3868
- new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
3975
+ function createView(arr) {
3976
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
3977
+ }
3978
+ /** The rotate right (circular right shift) operation for uint32 */
3979
+ function rotr(word, shift) {
3980
+ return (word << (32 - shift)) | (word >>> shift);
3981
+ }
3869
3982
  /**
3983
+ * Convert JS string to byte array.
3870
3984
  * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
3871
3985
  */
3872
3986
  function utf8ToBytes$1(str) {
3873
3987
  if (typeof str !== 'string')
3874
- throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
3988
+ throw new Error('utf8ToBytes expected string, got ' + typeof str);
3875
3989
  return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
3876
3990
  }
3877
3991
  /**
@@ -3882,16 +3996,17 @@ function utf8ToBytes$1(str) {
3882
3996
  function toBytes(data) {
3883
3997
  if (typeof data === 'string')
3884
3998
  data = utf8ToBytes$1(data);
3885
- bytes(data);
3999
+ abytes(data);
3886
4000
  return data;
3887
4001
  }
3888
- // For runtime check if class implements interface
4002
+ /** For runtime check if class implements interface */
3889
4003
  class Hash {
3890
4004
  // Safe version that clones internal state
3891
4005
  clone() {
3892
4006
  return this._cloneInto();
3893
4007
  }
3894
4008
  }
4009
+ /** Wraps hash function, creating an interface on top of it */
3895
4010
  function wrapConstructor(hashCons) {
3896
4011
  const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
3897
4012
  const tmp = hashCons();
@@ -3902,8 +4017,10 @@ function wrapConstructor(hashCons) {
3902
4017
  }
3903
4018
 
3904
4019
  /**
3905
- * Polyfill for Safari 14
4020
+ * Internal Merkle-Damgard hash utils.
4021
+ * @module
3906
4022
  */
4023
+ /** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
3907
4024
  function setBigUint64(view, byteOffset, value, isLE) {
3908
4025
  if (typeof view.setBigUint64 === 'function')
3909
4026
  return view.setBigUint64(byteOffset, value, isLE);
@@ -3916,14 +4033,14 @@ function setBigUint64(view, byteOffset, value, isLE) {
3916
4033
  view.setUint32(byteOffset + h, wh, isLE);
3917
4034
  view.setUint32(byteOffset + l, wl, isLE);
3918
4035
  }
3919
- /**
3920
- * Choice: a ? b : c
3921
- */
3922
- const Chi = (a, b, c) => (a & b) ^ (~a & c);
3923
- /**
3924
- * Majority function, true if any two inputs is true
3925
- */
3926
- const Maj = (a, b, c) => (a & b) ^ (a & c) ^ (b & c);
4036
+ /** Choice: a ? b : c */
4037
+ function Chi(a, b, c) {
4038
+ return (a & b) ^ (~a & c);
4039
+ }
4040
+ /** Majority function, true if any two inputs is true. */
4041
+ function Maj(a, b, c) {
4042
+ return (a & b) ^ (a & c) ^ (b & c);
4043
+ }
3927
4044
  /**
3928
4045
  * Merkle-Damgard hash construction base class.
3929
4046
  * Could be used to create MD5, RIPEMD, SHA1, SHA2.
@@ -3943,7 +4060,7 @@ class HashMD extends Hash {
3943
4060
  this.view = createView(this.buffer);
3944
4061
  }
3945
4062
  update(data) {
3946
- exists(this);
4063
+ aexists(this);
3947
4064
  const { view, buffer, blockLen } = this;
3948
4065
  data = toBytes(data);
3949
4066
  const len = data.length;
@@ -3969,8 +4086,8 @@ class HashMD extends Hash {
3969
4086
  return this;
3970
4087
  }
3971
4088
  digestInto(out) {
3972
- exists(this);
3973
- output(out, this);
4089
+ aexists(this);
4090
+ aoutput(out, this);
3974
4091
  this.finished = true;
3975
4092
  // Padding
3976
4093
  // We can avoid allocation of buffer for padding completely if it
@@ -4027,10 +4144,16 @@ class HashMD extends Hash {
4027
4144
  }
4028
4145
  }
4029
4146
 
4030
- // SHA2-256 need to try 2^128 hashes to execute birthday attack.
4031
- // BTC network is doing 2^67 hashes/sec as per early 2023.
4032
- // Round constants:
4033
- // first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311)
4147
+ /**
4148
+ * SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
4149
+ *
4150
+ * To break sha256 using birthday attack, attackers need to try 2^128 hashes.
4151
+ * BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
4152
+ *
4153
+ * Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
4154
+ * @module
4155
+ */
4156
+ /** Round constants: first 32 bits of fractional parts of the cube roots of the first 64 primes 2..311). */
4034
4157
  // prettier-ignore
4035
4158
  const SHA256_K = /* @__PURE__ */ new Uint32Array([
4036
4159
  0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
@@ -4042,14 +4165,15 @@ const SHA256_K = /* @__PURE__ */ new Uint32Array([
4042
4165
  0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
4043
4166
  0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
4044
4167
  ]);
4045
- // Initial state:
4046
- // first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
4168
+ /** Initial state: first 32 bits of fractional parts of the square roots of the first 8 primes 2..19. */
4047
4169
  // prettier-ignore
4048
4170
  const SHA256_IV = /* @__PURE__ */ new Uint32Array([
4049
4171
  0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
4050
4172
  ]);
4051
- // Temporary buffer, not used to store anything between runs
4052
- // Named this way because it matches specification.
4173
+ /**
4174
+ * Temporary buffer, not used to store anything between runs.
4175
+ * Named this way because it matches specification.
4176
+ */
4053
4177
  const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
4054
4178
  class SHA256 extends HashMD {
4055
4179
  constructor() {
@@ -4126,10 +4250,7 @@ class SHA256 extends HashMD {
4126
4250
  this.buffer.fill(0);
4127
4251
  }
4128
4252
  }
4129
- /**
4130
- * SHA2-256 hash function
4131
- * @param message - data that would be hashed
4132
- */
4253
+ /** SHA2-256 hash function */
4133
4254
  const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
4134
4255
 
4135
4256
  /**
@@ -4468,4 +4589,4 @@ var version_0 = /*#__PURE__*/Object.freeze({
4468
4589
  proto: message
4469
4590
  });
4470
4591
 
4471
- export { DecodedMessage as D, Encoder as E, FilterSubscribeRequest as F, MessagePush as M, PushRpc$1 as P, StoreQueryRequest$1 as S, Version as V, WakuMetadataRequest as W, allocUnsafe as a, alloc$1 as b, encode as c, decode as d, encodingLength as e, FilterSubscribeResponse$1 as f, PushResponse as g, StoreQueryResponse$1 as h, createEncoder as i, bytesToUtf8 as j, pubsubTopicsToShardInfo as k, WakuMetadataResponse as l, createDecoder as m, message as n, Decoder as o, pubsubTopicToSingleShardInfo as p, shardInfoToPubsubTopics as s, utf8ToBytes as u, version_0 as v };
4592
+ export { DecodedMessage as D, Encoder as E, FilterSubscribeRequest as F, MessagePush as M, PushRpc$1 as P, StoreQueryRequest$1 as S, Version as V, WakuMetadataRequest as W, allocUnsafe as a, alloc$1 as b, encode as c, decode as d, encodingLength as e, FilterSubscribeResponse$1 as f, PushResponse as g, StoreQueryResponse$1 as h, bases as i, fromString as j, createEncoder as k, bytesToUtf8 as l, pubsubTopicsToShardInfo as m, WakuMetadataResponse as n, createDecoder as o, pubsubTopicToSingleShardInfo as p, message as q, Decoder as r, shardInfoToPubsubTopics as s, toString as t, utf8ToBytes as u, version_0 as v };