@waku/message-encryption 0.0.35-c7fe44e.0 → 0.0.36-3545a8e.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/CHANGELOG.md +12 -0
- package/bundle/crypto.js +1 -1
- package/bundle/{ecies-SoJnlQ4a.js → ecies-HdUXyKbi.js} +15 -11
- package/bundle/ecies.js +3 -3
- package/bundle/{encryption-D_9ex828.js → encryption-DCdb0Qpb.js} +169 -560
- package/bundle/{index-uHWNcEd0.js → index-BVMnprgl.js} +1 -1
- package/bundle/index.js +5 -5
- package/bundle/{symmetric-DPlNQ4aL.js → symmetric-B5XVN0Wd.js} +1 -5
- package/bundle/{symmetric-CIP2vKQ6.js → symmetric-_y7uWU-v.js} +15 -11
- package/bundle/symmetric.js +3 -3
- package/dist/.tsbuildinfo +1 -1
- package/dist/ecies.d.ts +8 -10
- package/dist/ecies.js +14 -10
- package/dist/ecies.js.map +1 -1
- package/dist/symmetric.d.ts +8 -6
- package/dist/symmetric.js +14 -10
- package/dist/symmetric.js.map +1 -1
- package/package.json +1 -1
- package/src/ecies.ts +16 -20
- package/src/symmetric.ts +16 -16
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h as allocUnsafe, i as fromString, j as alloc$1, l as
|
|
1
|
+
import { h as allocUnsafe, i as fromString, j as alloc$1, l as getDefaultExportFromCjs, m as decrypt, n as encrypt, o as hexToBytes, p as concat, r as randomBytes, k as keccak256, d as sign, S as Symmetric, q as decrypt$1, t as generateIv, u as encrypt$1, v as Signature, w as recoverPublicKey } from './symmetric-B5XVN0Wd.js';
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-fallthrough */
|
|
4
4
|
const N1 = Math.pow(2, 7);
|
|
@@ -2541,6 +2541,18 @@ var PushResponse;
|
|
|
2541
2541
|
w.uint32(18);
|
|
2542
2542
|
w.string(obj.info);
|
|
2543
2543
|
}
|
|
2544
|
+
if (obj.statusCode != null) {
|
|
2545
|
+
w.uint32(80);
|
|
2546
|
+
w.uint32(obj.statusCode);
|
|
2547
|
+
}
|
|
2548
|
+
if (obj.statusDesc != null) {
|
|
2549
|
+
w.uint32(90);
|
|
2550
|
+
w.string(obj.statusDesc);
|
|
2551
|
+
}
|
|
2552
|
+
if (obj.relayPeerCount != null) {
|
|
2553
|
+
w.uint32(96);
|
|
2554
|
+
w.uint32(obj.relayPeerCount);
|
|
2555
|
+
}
|
|
2544
2556
|
if (opts.lengthDelimited !== false) {
|
|
2545
2557
|
w.ldelim();
|
|
2546
2558
|
}
|
|
@@ -2560,6 +2572,18 @@ var PushResponse;
|
|
|
2560
2572
|
obj.info = reader.string();
|
|
2561
2573
|
break;
|
|
2562
2574
|
}
|
|
2575
|
+
case 10: {
|
|
2576
|
+
obj.statusCode = reader.uint32();
|
|
2577
|
+
break;
|
|
2578
|
+
}
|
|
2579
|
+
case 11: {
|
|
2580
|
+
obj.statusDesc = reader.string();
|
|
2581
|
+
break;
|
|
2582
|
+
}
|
|
2583
|
+
case 12: {
|
|
2584
|
+
obj.relayPeerCount = reader.uint32();
|
|
2585
|
+
break;
|
|
2586
|
+
}
|
|
2563
2587
|
default: {
|
|
2564
2588
|
reader.skipType(tag & 7);
|
|
2565
2589
|
break;
|
|
@@ -2644,6 +2668,141 @@ var PushRpc;
|
|
|
2644
2668
|
return decodeMessage(buf, PushRpc.codec(), opts);
|
|
2645
2669
|
};
|
|
2646
2670
|
})(PushRpc || (PushRpc = {}));
|
|
2671
|
+
var LightPushRequestV3;
|
|
2672
|
+
(function (LightPushRequestV3) {
|
|
2673
|
+
let _codec;
|
|
2674
|
+
LightPushRequestV3.codec = () => {
|
|
2675
|
+
if (_codec == null) {
|
|
2676
|
+
_codec = message((obj, w, opts = {}) => {
|
|
2677
|
+
if (opts.lengthDelimited !== false) {
|
|
2678
|
+
w.fork();
|
|
2679
|
+
}
|
|
2680
|
+
if ((obj.requestId != null && obj.requestId !== '')) {
|
|
2681
|
+
w.uint32(10);
|
|
2682
|
+
w.string(obj.requestId);
|
|
2683
|
+
}
|
|
2684
|
+
if (obj.pubsubTopic != null) {
|
|
2685
|
+
w.uint32(162);
|
|
2686
|
+
w.string(obj.pubsubTopic);
|
|
2687
|
+
}
|
|
2688
|
+
if (obj.message != null) {
|
|
2689
|
+
w.uint32(170);
|
|
2690
|
+
WakuMessage$1.codec().encode(obj.message, w);
|
|
2691
|
+
}
|
|
2692
|
+
if (opts.lengthDelimited !== false) {
|
|
2693
|
+
w.ldelim();
|
|
2694
|
+
}
|
|
2695
|
+
}, (reader, length, opts = {}) => {
|
|
2696
|
+
const obj = {
|
|
2697
|
+
requestId: ''
|
|
2698
|
+
};
|
|
2699
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
2700
|
+
while (reader.pos < end) {
|
|
2701
|
+
const tag = reader.uint32();
|
|
2702
|
+
switch (tag >>> 3) {
|
|
2703
|
+
case 1: {
|
|
2704
|
+
obj.requestId = reader.string();
|
|
2705
|
+
break;
|
|
2706
|
+
}
|
|
2707
|
+
case 20: {
|
|
2708
|
+
obj.pubsubTopic = reader.string();
|
|
2709
|
+
break;
|
|
2710
|
+
}
|
|
2711
|
+
case 21: {
|
|
2712
|
+
obj.message = WakuMessage$1.codec().decode(reader, reader.uint32(), {
|
|
2713
|
+
limits: opts.limits?.message
|
|
2714
|
+
});
|
|
2715
|
+
break;
|
|
2716
|
+
}
|
|
2717
|
+
default: {
|
|
2718
|
+
reader.skipType(tag & 7);
|
|
2719
|
+
break;
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
return obj;
|
|
2724
|
+
});
|
|
2725
|
+
}
|
|
2726
|
+
return _codec;
|
|
2727
|
+
};
|
|
2728
|
+
LightPushRequestV3.encode = (obj) => {
|
|
2729
|
+
return encodeMessage(obj, LightPushRequestV3.codec());
|
|
2730
|
+
};
|
|
2731
|
+
LightPushRequestV3.decode = (buf, opts) => {
|
|
2732
|
+
return decodeMessage(buf, LightPushRequestV3.codec(), opts);
|
|
2733
|
+
};
|
|
2734
|
+
})(LightPushRequestV3 || (LightPushRequestV3 = {}));
|
|
2735
|
+
var LightPushResponseV3;
|
|
2736
|
+
(function (LightPushResponseV3) {
|
|
2737
|
+
let _codec;
|
|
2738
|
+
LightPushResponseV3.codec = () => {
|
|
2739
|
+
if (_codec == null) {
|
|
2740
|
+
_codec = message((obj, w, opts = {}) => {
|
|
2741
|
+
if (opts.lengthDelimited !== false) {
|
|
2742
|
+
w.fork();
|
|
2743
|
+
}
|
|
2744
|
+
if ((obj.requestId != null && obj.requestId !== '')) {
|
|
2745
|
+
w.uint32(10);
|
|
2746
|
+
w.string(obj.requestId);
|
|
2747
|
+
}
|
|
2748
|
+
if ((obj.statusCode != null && obj.statusCode !== 0)) {
|
|
2749
|
+
w.uint32(80);
|
|
2750
|
+
w.uint32(obj.statusCode);
|
|
2751
|
+
}
|
|
2752
|
+
if (obj.statusDesc != null) {
|
|
2753
|
+
w.uint32(90);
|
|
2754
|
+
w.string(obj.statusDesc);
|
|
2755
|
+
}
|
|
2756
|
+
if (obj.relayPeerCount != null) {
|
|
2757
|
+
w.uint32(96);
|
|
2758
|
+
w.uint32(obj.relayPeerCount);
|
|
2759
|
+
}
|
|
2760
|
+
if (opts.lengthDelimited !== false) {
|
|
2761
|
+
w.ldelim();
|
|
2762
|
+
}
|
|
2763
|
+
}, (reader, length, opts = {}) => {
|
|
2764
|
+
const obj = {
|
|
2765
|
+
requestId: '',
|
|
2766
|
+
statusCode: 0
|
|
2767
|
+
};
|
|
2768
|
+
const end = length == null ? reader.len : reader.pos + length;
|
|
2769
|
+
while (reader.pos < end) {
|
|
2770
|
+
const tag = reader.uint32();
|
|
2771
|
+
switch (tag >>> 3) {
|
|
2772
|
+
case 1: {
|
|
2773
|
+
obj.requestId = reader.string();
|
|
2774
|
+
break;
|
|
2775
|
+
}
|
|
2776
|
+
case 10: {
|
|
2777
|
+
obj.statusCode = reader.uint32();
|
|
2778
|
+
break;
|
|
2779
|
+
}
|
|
2780
|
+
case 11: {
|
|
2781
|
+
obj.statusDesc = reader.string();
|
|
2782
|
+
break;
|
|
2783
|
+
}
|
|
2784
|
+
case 12: {
|
|
2785
|
+
obj.relayPeerCount = reader.uint32();
|
|
2786
|
+
break;
|
|
2787
|
+
}
|
|
2788
|
+
default: {
|
|
2789
|
+
reader.skipType(tag & 7);
|
|
2790
|
+
break;
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
}
|
|
2794
|
+
return obj;
|
|
2795
|
+
});
|
|
2796
|
+
}
|
|
2797
|
+
return _codec;
|
|
2798
|
+
};
|
|
2799
|
+
LightPushResponseV3.encode = (obj) => {
|
|
2800
|
+
return encodeMessage(obj, LightPushResponseV3.codec());
|
|
2801
|
+
};
|
|
2802
|
+
LightPushResponseV3.decode = (buf, opts) => {
|
|
2803
|
+
return decodeMessage(buf, LightPushResponseV3.codec(), opts);
|
|
2804
|
+
};
|
|
2805
|
+
})(LightPushResponseV3 || (LightPushResponseV3 = {}));
|
|
2647
2806
|
var RateLimitProof$1;
|
|
2648
2807
|
(function (RateLimitProof) {
|
|
2649
2808
|
let _codec;
|
|
@@ -3815,559 +3974,6 @@ var SdsMessage;
|
|
|
3815
3974
|
};
|
|
3816
3975
|
})(SdsMessage || (SdsMessage = {}));
|
|
3817
3976
|
|
|
3818
|
-
/**
|
|
3819
|
-
* Utilities for hex, bytes, CSPRNG.
|
|
3820
|
-
* @module
|
|
3821
|
-
*/
|
|
3822
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3823
|
-
// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
|
|
3824
|
-
// node.js versions earlier than v19 don't declare it in global scope.
|
|
3825
|
-
// For node.js, package.json#exports field mapping rewrites import
|
|
3826
|
-
// from `crypto` to `cryptoNode`, which imports native module.
|
|
3827
|
-
// Makes the utils un-importable in browsers without a bundler.
|
|
3828
|
-
// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.
|
|
3829
|
-
/** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
|
|
3830
|
-
function isBytes(a) {
|
|
3831
|
-
return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');
|
|
3832
|
-
}
|
|
3833
|
-
/** Asserts something is Uint8Array. */
|
|
3834
|
-
function abytes(b, ...lengths) {
|
|
3835
|
-
if (!isBytes(b))
|
|
3836
|
-
throw new Error('Uint8Array expected');
|
|
3837
|
-
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
3838
|
-
throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);
|
|
3839
|
-
}
|
|
3840
|
-
/** Asserts a hash instance has not been destroyed / finished */
|
|
3841
|
-
function aexists(instance, checkFinished = true) {
|
|
3842
|
-
if (instance.destroyed)
|
|
3843
|
-
throw new Error('Hash instance has been destroyed');
|
|
3844
|
-
if (checkFinished && instance.finished)
|
|
3845
|
-
throw new Error('Hash#digest() has already been called');
|
|
3846
|
-
}
|
|
3847
|
-
/** Asserts output is properly-sized byte array */
|
|
3848
|
-
function aoutput(out, instance) {
|
|
3849
|
-
abytes(out);
|
|
3850
|
-
const min = instance.outputLen;
|
|
3851
|
-
if (out.length < min) {
|
|
3852
|
-
throw new Error('digestInto() expects output buffer of length at least ' + min);
|
|
3853
|
-
}
|
|
3854
|
-
}
|
|
3855
|
-
/** Zeroize a byte array. Warning: JS provides no guarantees. */
|
|
3856
|
-
function clean(...arrays) {
|
|
3857
|
-
for (let i = 0; i < arrays.length; i++) {
|
|
3858
|
-
arrays[i].fill(0);
|
|
3859
|
-
}
|
|
3860
|
-
}
|
|
3861
|
-
/** Create DataView of an array for easy byte-level manipulation. */
|
|
3862
|
-
function createView(arr) {
|
|
3863
|
-
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
3864
|
-
}
|
|
3865
|
-
/** The rotate right (circular right shift) operation for uint32 */
|
|
3866
|
-
function rotr(word, shift) {
|
|
3867
|
-
return (word << (32 - shift)) | (word >>> shift);
|
|
3868
|
-
}
|
|
3869
|
-
/**
|
|
3870
|
-
* Converts string to bytes using UTF8 encoding.
|
|
3871
|
-
* @example utf8ToBytes('abc') // Uint8Array.from([97, 98, 99])
|
|
3872
|
-
*/
|
|
3873
|
-
function utf8ToBytes(str) {
|
|
3874
|
-
if (typeof str !== 'string')
|
|
3875
|
-
throw new Error('string expected');
|
|
3876
|
-
return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
|
|
3877
|
-
}
|
|
3878
|
-
/**
|
|
3879
|
-
* Normalizes (non-hex) string or Uint8Array to Uint8Array.
|
|
3880
|
-
* Warning: when Uint8Array is passed, it would NOT get copied.
|
|
3881
|
-
* Keep in mind for future mutable operations.
|
|
3882
|
-
*/
|
|
3883
|
-
function toBytes(data) {
|
|
3884
|
-
if (typeof data === 'string')
|
|
3885
|
-
data = utf8ToBytes(data);
|
|
3886
|
-
abytes(data);
|
|
3887
|
-
return data;
|
|
3888
|
-
}
|
|
3889
|
-
/** For runtime check if class implements interface */
|
|
3890
|
-
class Hash {
|
|
3891
|
-
}
|
|
3892
|
-
/** Wraps hash function, creating an interface on top of it */
|
|
3893
|
-
function createHasher(hashCons) {
|
|
3894
|
-
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
3895
|
-
const tmp = hashCons();
|
|
3896
|
-
hashC.outputLen = tmp.outputLen;
|
|
3897
|
-
hashC.blockLen = tmp.blockLen;
|
|
3898
|
-
hashC.create = () => hashCons();
|
|
3899
|
-
return hashC;
|
|
3900
|
-
}
|
|
3901
|
-
|
|
3902
|
-
/**
|
|
3903
|
-
* Internal Merkle-Damgard hash utils.
|
|
3904
|
-
* @module
|
|
3905
|
-
*/
|
|
3906
|
-
/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
|
|
3907
|
-
function setBigUint64(view, byteOffset, value, isLE) {
|
|
3908
|
-
if (typeof view.setBigUint64 === 'function')
|
|
3909
|
-
return view.setBigUint64(byteOffset, value, isLE);
|
|
3910
|
-
const _32n = BigInt(32);
|
|
3911
|
-
const _u32_max = BigInt(0xffffffff);
|
|
3912
|
-
const wh = Number((value >> _32n) & _u32_max);
|
|
3913
|
-
const wl = Number(value & _u32_max);
|
|
3914
|
-
const h = isLE ? 4 : 0;
|
|
3915
|
-
const l = isLE ? 0 : 4;
|
|
3916
|
-
view.setUint32(byteOffset + h, wh, isLE);
|
|
3917
|
-
view.setUint32(byteOffset + l, wl, isLE);
|
|
3918
|
-
}
|
|
3919
|
-
/** Choice: a ? b : c */
|
|
3920
|
-
function Chi(a, b, c) {
|
|
3921
|
-
return (a & b) ^ (~a & c);
|
|
3922
|
-
}
|
|
3923
|
-
/** Majority function, true if any two inputs is true. */
|
|
3924
|
-
function Maj(a, b, c) {
|
|
3925
|
-
return (a & b) ^ (a & c) ^ (b & c);
|
|
3926
|
-
}
|
|
3927
|
-
/**
|
|
3928
|
-
* Merkle-Damgard hash construction base class.
|
|
3929
|
-
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
3930
|
-
*/
|
|
3931
|
-
class HashMD extends Hash {
|
|
3932
|
-
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
3933
|
-
super();
|
|
3934
|
-
this.finished = false;
|
|
3935
|
-
this.length = 0;
|
|
3936
|
-
this.pos = 0;
|
|
3937
|
-
this.destroyed = false;
|
|
3938
|
-
this.blockLen = blockLen;
|
|
3939
|
-
this.outputLen = outputLen;
|
|
3940
|
-
this.padOffset = padOffset;
|
|
3941
|
-
this.isLE = isLE;
|
|
3942
|
-
this.buffer = new Uint8Array(blockLen);
|
|
3943
|
-
this.view = createView(this.buffer);
|
|
3944
|
-
}
|
|
3945
|
-
update(data) {
|
|
3946
|
-
aexists(this);
|
|
3947
|
-
data = toBytes(data);
|
|
3948
|
-
abytes(data);
|
|
3949
|
-
const { view, buffer, blockLen } = this;
|
|
3950
|
-
const len = data.length;
|
|
3951
|
-
for (let pos = 0; pos < len;) {
|
|
3952
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
3953
|
-
// Fast path: we have at least one block in input, cast it to view and process
|
|
3954
|
-
if (take === blockLen) {
|
|
3955
|
-
const dataView = createView(data);
|
|
3956
|
-
for (; blockLen <= len - pos; pos += blockLen)
|
|
3957
|
-
this.process(dataView, pos);
|
|
3958
|
-
continue;
|
|
3959
|
-
}
|
|
3960
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
3961
|
-
this.pos += take;
|
|
3962
|
-
pos += take;
|
|
3963
|
-
if (this.pos === blockLen) {
|
|
3964
|
-
this.process(view, 0);
|
|
3965
|
-
this.pos = 0;
|
|
3966
|
-
}
|
|
3967
|
-
}
|
|
3968
|
-
this.length += data.length;
|
|
3969
|
-
this.roundClean();
|
|
3970
|
-
return this;
|
|
3971
|
-
}
|
|
3972
|
-
digestInto(out) {
|
|
3973
|
-
aexists(this);
|
|
3974
|
-
aoutput(out, this);
|
|
3975
|
-
this.finished = true;
|
|
3976
|
-
// Padding
|
|
3977
|
-
// We can avoid allocation of buffer for padding completely if it
|
|
3978
|
-
// was previously not allocated here. But it won't change performance.
|
|
3979
|
-
const { buffer, view, blockLen, isLE } = this;
|
|
3980
|
-
let { pos } = this;
|
|
3981
|
-
// append the bit '1' to the message
|
|
3982
|
-
buffer[pos++] = 0b10000000;
|
|
3983
|
-
clean(this.buffer.subarray(pos));
|
|
3984
|
-
// we have less than padOffset left in buffer, so we cannot put length in
|
|
3985
|
-
// current block, need process it and pad again
|
|
3986
|
-
if (this.padOffset > blockLen - pos) {
|
|
3987
|
-
this.process(view, 0);
|
|
3988
|
-
pos = 0;
|
|
3989
|
-
}
|
|
3990
|
-
// Pad until full block byte with zeros
|
|
3991
|
-
for (let i = pos; i < blockLen; i++)
|
|
3992
|
-
buffer[i] = 0;
|
|
3993
|
-
// Note: sha512 requires length to be 128bit integer, but length in JS will overflow before that
|
|
3994
|
-
// You need to write around 2 exabytes (u64_max / 8 / (1024**6)) for this to happen.
|
|
3995
|
-
// So we just write lowest 64 bits of that value.
|
|
3996
|
-
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
3997
|
-
this.process(view, 0);
|
|
3998
|
-
const oview = createView(out);
|
|
3999
|
-
const len = this.outputLen;
|
|
4000
|
-
// NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
|
|
4001
|
-
if (len % 4)
|
|
4002
|
-
throw new Error('_sha2: outputLen should be aligned to 32bit');
|
|
4003
|
-
const outLen = len / 4;
|
|
4004
|
-
const state = this.get();
|
|
4005
|
-
if (outLen > state.length)
|
|
4006
|
-
throw new Error('_sha2: outputLen bigger than state');
|
|
4007
|
-
for (let i = 0; i < outLen; i++)
|
|
4008
|
-
oview.setUint32(4 * i, state[i], isLE);
|
|
4009
|
-
}
|
|
4010
|
-
digest() {
|
|
4011
|
-
const { buffer, outputLen } = this;
|
|
4012
|
-
this.digestInto(buffer);
|
|
4013
|
-
const res = buffer.slice(0, outputLen);
|
|
4014
|
-
this.destroy();
|
|
4015
|
-
return res;
|
|
4016
|
-
}
|
|
4017
|
-
_cloneInto(to) {
|
|
4018
|
-
to || (to = new this.constructor());
|
|
4019
|
-
to.set(...this.get());
|
|
4020
|
-
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
4021
|
-
to.destroyed = destroyed;
|
|
4022
|
-
to.finished = finished;
|
|
4023
|
-
to.length = length;
|
|
4024
|
-
to.pos = pos;
|
|
4025
|
-
if (length % blockLen)
|
|
4026
|
-
to.buffer.set(buffer);
|
|
4027
|
-
return to;
|
|
4028
|
-
}
|
|
4029
|
-
clone() {
|
|
4030
|
-
return this._cloneInto();
|
|
4031
|
-
}
|
|
4032
|
-
}
|
|
4033
|
-
/**
|
|
4034
|
-
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
4035
|
-
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
4036
|
-
*/
|
|
4037
|
-
/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
|
|
4038
|
-
const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
4039
|
-
0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
|
|
4040
|
-
]);
|
|
4041
|
-
|
|
4042
|
-
/**
|
|
4043
|
-
* SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
|
|
4044
|
-
* SHA256 is the fastest hash implementable in JS, even faster than Blake3.
|
|
4045
|
-
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
|
|
4046
|
-
* [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
|
4047
|
-
* @module
|
|
4048
|
-
*/
|
|
4049
|
-
/**
|
|
4050
|
-
* Round constants:
|
|
4051
|
-
* First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
|
|
4052
|
-
*/
|
|
4053
|
-
// prettier-ignore
|
|
4054
|
-
const SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
4055
|
-
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
4056
|
-
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
4057
|
-
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
4058
|
-
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
4059
|
-
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
4060
|
-
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
4061
|
-
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
4062
|
-
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
4063
|
-
]);
|
|
4064
|
-
/** Reusable temporary buffer. "W" comes straight from spec. */
|
|
4065
|
-
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
4066
|
-
class SHA256 extends HashMD {
|
|
4067
|
-
constructor(outputLen = 32) {
|
|
4068
|
-
super(64, outputLen, 8, false);
|
|
4069
|
-
// We cannot use array here since array allows indexing by variable
|
|
4070
|
-
// which means optimizer/compiler cannot use registers.
|
|
4071
|
-
this.A = SHA256_IV[0] | 0;
|
|
4072
|
-
this.B = SHA256_IV[1] | 0;
|
|
4073
|
-
this.C = SHA256_IV[2] | 0;
|
|
4074
|
-
this.D = SHA256_IV[3] | 0;
|
|
4075
|
-
this.E = SHA256_IV[4] | 0;
|
|
4076
|
-
this.F = SHA256_IV[5] | 0;
|
|
4077
|
-
this.G = SHA256_IV[6] | 0;
|
|
4078
|
-
this.H = SHA256_IV[7] | 0;
|
|
4079
|
-
}
|
|
4080
|
-
get() {
|
|
4081
|
-
const { A, B, C, D, E, F, G, H } = this;
|
|
4082
|
-
return [A, B, C, D, E, F, G, H];
|
|
4083
|
-
}
|
|
4084
|
-
// prettier-ignore
|
|
4085
|
-
set(A, B, C, D, E, F, G, H) {
|
|
4086
|
-
this.A = A | 0;
|
|
4087
|
-
this.B = B | 0;
|
|
4088
|
-
this.C = C | 0;
|
|
4089
|
-
this.D = D | 0;
|
|
4090
|
-
this.E = E | 0;
|
|
4091
|
-
this.F = F | 0;
|
|
4092
|
-
this.G = G | 0;
|
|
4093
|
-
this.H = H | 0;
|
|
4094
|
-
}
|
|
4095
|
-
process(view, offset) {
|
|
4096
|
-
// Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array
|
|
4097
|
-
for (let i = 0; i < 16; i++, offset += 4)
|
|
4098
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
|
4099
|
-
for (let i = 16; i < 64; i++) {
|
|
4100
|
-
const W15 = SHA256_W[i - 15];
|
|
4101
|
-
const W2 = SHA256_W[i - 2];
|
|
4102
|
-
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ (W15 >>> 3);
|
|
4103
|
-
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ (W2 >>> 10);
|
|
4104
|
-
SHA256_W[i] = (s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16]) | 0;
|
|
4105
|
-
}
|
|
4106
|
-
// Compression function main loop, 64 rounds
|
|
4107
|
-
let { A, B, C, D, E, F, G, H } = this;
|
|
4108
|
-
for (let i = 0; i < 64; i++) {
|
|
4109
|
-
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
4110
|
-
const T1 = (H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i]) | 0;
|
|
4111
|
-
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
4112
|
-
const T2 = (sigma0 + Maj(A, B, C)) | 0;
|
|
4113
|
-
H = G;
|
|
4114
|
-
G = F;
|
|
4115
|
-
F = E;
|
|
4116
|
-
E = (D + T1) | 0;
|
|
4117
|
-
D = C;
|
|
4118
|
-
C = B;
|
|
4119
|
-
B = A;
|
|
4120
|
-
A = (T1 + T2) | 0;
|
|
4121
|
-
}
|
|
4122
|
-
// Add the compressed chunk to the current hash value
|
|
4123
|
-
A = (A + this.A) | 0;
|
|
4124
|
-
B = (B + this.B) | 0;
|
|
4125
|
-
C = (C + this.C) | 0;
|
|
4126
|
-
D = (D + this.D) | 0;
|
|
4127
|
-
E = (E + this.E) | 0;
|
|
4128
|
-
F = (F + this.F) | 0;
|
|
4129
|
-
G = (G + this.G) | 0;
|
|
4130
|
-
H = (H + this.H) | 0;
|
|
4131
|
-
this.set(A, B, C, D, E, F, G, H);
|
|
4132
|
-
}
|
|
4133
|
-
roundClean() {
|
|
4134
|
-
clean(SHA256_W);
|
|
4135
|
-
}
|
|
4136
|
-
destroy() {
|
|
4137
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
4138
|
-
clean(this.buffer);
|
|
4139
|
-
}
|
|
4140
|
-
}
|
|
4141
|
-
/**
|
|
4142
|
-
* SHA2-256 hash function from RFC 4634.
|
|
4143
|
-
*
|
|
4144
|
-
* It is the fastest JS hash, even faster than Blake3.
|
|
4145
|
-
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
|
4146
|
-
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
4147
|
-
*/
|
|
4148
|
-
const sha256$1 = /* @__PURE__ */ createHasher(() => new SHA256());
|
|
4149
|
-
|
|
4150
|
-
/**
|
|
4151
|
-
* SHA2-256 a.k.a. sha256. In JS, it is the fastest hash, even faster than Blake3.
|
|
4152
|
-
*
|
|
4153
|
-
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
|
4154
|
-
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
4155
|
-
*
|
|
4156
|
-
* Check out [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
|
4157
|
-
* @module
|
|
4158
|
-
* @deprecated
|
|
4159
|
-
*/
|
|
4160
|
-
/** @deprecated Use import from `noble/hashes/sha2` module */
|
|
4161
|
-
const sha256 = sha256$1;
|
|
4162
|
-
|
|
4163
|
-
var Protocols;
|
|
4164
|
-
(function (Protocols) {
|
|
4165
|
-
Protocols["Relay"] = "relay";
|
|
4166
|
-
Protocols["Store"] = "store";
|
|
4167
|
-
Protocols["LightPush"] = "lightpush";
|
|
4168
|
-
Protocols["Filter"] = "filter";
|
|
4169
|
-
})(Protocols || (Protocols = {}));
|
|
4170
|
-
var ProtocolError;
|
|
4171
|
-
(function (ProtocolError) {
|
|
4172
|
-
//
|
|
4173
|
-
// GENERAL ERRORS SECTION
|
|
4174
|
-
//
|
|
4175
|
-
/**
|
|
4176
|
-
* Could not determine the origin of the fault. Best to check connectivity and try again
|
|
4177
|
-
* */
|
|
4178
|
-
ProtocolError["GENERIC_FAIL"] = "Generic error";
|
|
4179
|
-
/**
|
|
4180
|
-
* The remote peer rejected the message. Information provided by the remote peer
|
|
4181
|
-
* is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
|
|
4182
|
-
* or `DECODE_FAILED` can be used.
|
|
4183
|
-
*/
|
|
4184
|
-
ProtocolError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
|
|
4185
|
-
/**
|
|
4186
|
-
* Failure to protobuf decode the message. May be due to a remote peer issue,
|
|
4187
|
-
* ensuring that messages are sent via several peer enable mitigation of this error.
|
|
4188
|
-
*/
|
|
4189
|
-
ProtocolError["DECODE_FAILED"] = "Failed to decode";
|
|
4190
|
-
/**
|
|
4191
|
-
* Failure to find a peer with suitable protocols. This may due to a connection issue.
|
|
4192
|
-
* Mitigation can be: retrying after a given time period, display connectivity issue
|
|
4193
|
-
* to user or listening for `peer:connected:bootstrap` or `peer:connected:peer-exchange`
|
|
4194
|
-
* on the connection manager before retrying.
|
|
4195
|
-
*/
|
|
4196
|
-
ProtocolError["NO_PEER_AVAILABLE"] = "No peer available";
|
|
4197
|
-
/**
|
|
4198
|
-
* Failure to find a stream to the peer. This may be because the connection with the peer is not still alive.
|
|
4199
|
-
* Mitigation can be: retrying after a given time period, or mitigation for `NO_PEER_AVAILABLE` can be used.
|
|
4200
|
-
*/
|
|
4201
|
-
ProtocolError["NO_STREAM_AVAILABLE"] = "No stream available";
|
|
4202
|
-
/**
|
|
4203
|
-
* The remote peer did not behave as expected. Mitigation for `NO_PEER_AVAILABLE`
|
|
4204
|
-
* or `DECODE_FAILED` can be used.
|
|
4205
|
-
*/
|
|
4206
|
-
ProtocolError["NO_RESPONSE"] = "No response received";
|
|
4207
|
-
//
|
|
4208
|
-
// SEND ERRORS SECTION
|
|
4209
|
-
//
|
|
4210
|
-
/**
|
|
4211
|
-
* Failure to protobuf encode the message. This is not recoverable and needs
|
|
4212
|
-
* further investigation.
|
|
4213
|
-
*/
|
|
4214
|
-
ProtocolError["ENCODE_FAILED"] = "Failed to encode";
|
|
4215
|
-
/**
|
|
4216
|
-
* The message payload is empty, making the message invalid. Ensure that a non-empty
|
|
4217
|
-
* payload is set on the outgoing message.
|
|
4218
|
-
*/
|
|
4219
|
-
ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
|
|
4220
|
-
/**
|
|
4221
|
-
* The message size is above the maximum message size allowed on the Waku Network.
|
|
4222
|
-
* Compressing the message or using an alternative strategy for large messages is recommended.
|
|
4223
|
-
*/
|
|
4224
|
-
ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
|
|
4225
|
-
/**
|
|
4226
|
-
* The PubsubTopic passed to the send function is not configured on the Waku node.
|
|
4227
|
-
* Please ensure that the PubsubTopic is used when initializing the Waku node.
|
|
4228
|
-
*/
|
|
4229
|
-
ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
|
4230
|
-
/**
|
|
4231
|
-
* Fails when
|
|
4232
|
-
*/
|
|
4233
|
-
ProtocolError["STREAM_ABORTED"] = "Stream aborted";
|
|
4234
|
-
/**
|
|
4235
|
-
* General proof generation error message.
|
|
4236
|
-
* nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
|
|
4237
|
-
*/
|
|
4238
|
-
ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
|
|
4239
|
-
//
|
|
4240
|
-
// RECEIVE ERRORS SECTION
|
|
4241
|
-
//
|
|
4242
|
-
/**
|
|
4243
|
-
* The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
|
|
4244
|
-
* Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
|
|
4245
|
-
*/
|
|
4246
|
-
ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
|
|
4247
|
-
/**
|
|
4248
|
-
* The topics passed in the decoders do not match each other, or don't exist at all.
|
|
4249
|
-
* Ensure that all the pubsub topics used in the decoders are valid and match each other.
|
|
4250
|
-
*/
|
|
4251
|
-
ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
|
|
4252
|
-
})(ProtocolError || (ProtocolError = {}));
|
|
4253
|
-
|
|
4254
|
-
var Tags;
|
|
4255
|
-
(function (Tags) {
|
|
4256
|
-
Tags["BOOTSTRAP"] = "bootstrap";
|
|
4257
|
-
Tags["PEER_EXCHANGE"] = "peer-exchange";
|
|
4258
|
-
Tags["LOCAL"] = "local-peer-cache";
|
|
4259
|
-
})(Tags || (Tags = {}));
|
|
4260
|
-
var EPeersByDiscoveryEvents;
|
|
4261
|
-
(function (EPeersByDiscoveryEvents) {
|
|
4262
|
-
EPeersByDiscoveryEvents["PEER_DISCOVERY_BOOTSTRAP"] = "peer:discovery:bootstrap";
|
|
4263
|
-
EPeersByDiscoveryEvents["PEER_DISCOVERY_PEER_EXCHANGE"] = "peer:discovery:peer-exchange";
|
|
4264
|
-
EPeersByDiscoveryEvents["PEER_CONNECT_BOOTSTRAP"] = "peer:connected:bootstrap";
|
|
4265
|
-
EPeersByDiscoveryEvents["PEER_CONNECT_PEER_EXCHANGE"] = "peer:connected:peer-exchange";
|
|
4266
|
-
})(EPeersByDiscoveryEvents || (EPeersByDiscoveryEvents = {}));
|
|
4267
|
-
var EConnectionStateEvents;
|
|
4268
|
-
(function (EConnectionStateEvents) {
|
|
4269
|
-
EConnectionStateEvents["CONNECTION_STATUS"] = "waku:connection";
|
|
4270
|
-
})(EConnectionStateEvents || (EConnectionStateEvents = {}));
|
|
4271
|
-
|
|
4272
|
-
/**
|
|
4273
|
-
* The default cluster ID for The Waku Network
|
|
4274
|
-
*/
|
|
4275
|
-
const DEFAULT_CLUSTER_ID = 1;
|
|
4276
|
-
|
|
4277
|
-
var HealthStatusChangeEvents;
|
|
4278
|
-
(function (HealthStatusChangeEvents) {
|
|
4279
|
-
HealthStatusChangeEvents["StatusChange"] = "health:change";
|
|
4280
|
-
})(HealthStatusChangeEvents || (HealthStatusChangeEvents = {}));
|
|
4281
|
-
var HealthStatus;
|
|
4282
|
-
(function (HealthStatus) {
|
|
4283
|
-
HealthStatus["Unhealthy"] = "Unhealthy";
|
|
4284
|
-
HealthStatus["MinimallyHealthy"] = "MinimallyHealthy";
|
|
4285
|
-
HealthStatus["SufficientlyHealthy"] = "SufficientlyHealthy";
|
|
4286
|
-
})(HealthStatus || (HealthStatus = {}));
|
|
4287
|
-
|
|
4288
|
-
const singleShardInfoToPubsubTopic = (shardInfo) => {
|
|
4289
|
-
if (shardInfo.shard === undefined)
|
|
4290
|
-
throw new Error("Invalid shard");
|
|
4291
|
-
return `/waku/2/rs/${shardInfo.clusterId ?? DEFAULT_CLUSTER_ID}/${shardInfo.shard}`;
|
|
4292
|
-
};
|
|
4293
|
-
/**
|
|
4294
|
-
* Given a string, will throw an error if it is not formatted as a valid content topic for autosharding based on https://rfc.vac.dev/spec/51/
|
|
4295
|
-
* @param contentTopic String to validate
|
|
4296
|
-
* @returns Object with each content topic field as an attribute
|
|
4297
|
-
*/
|
|
4298
|
-
function ensureValidContentTopic(contentTopic) {
|
|
4299
|
-
const parts = contentTopic.split("/");
|
|
4300
|
-
if (parts.length < 5 || parts.length > 6) {
|
|
4301
|
-
throw Error("Content topic format is invalid");
|
|
4302
|
-
}
|
|
4303
|
-
// Validate generation field if present
|
|
4304
|
-
let generation = 0;
|
|
4305
|
-
if (parts.length == 6) {
|
|
4306
|
-
generation = parseInt(parts[1]);
|
|
4307
|
-
if (isNaN(generation)) {
|
|
4308
|
-
throw new Error("Invalid generation field in content topic");
|
|
4309
|
-
}
|
|
4310
|
-
if (generation > 0) {
|
|
4311
|
-
throw new Error("Generation greater than 0 is not supported");
|
|
4312
|
-
}
|
|
4313
|
-
}
|
|
4314
|
-
// Validate remaining fields
|
|
4315
|
-
const fields = parts.splice(-4);
|
|
4316
|
-
// Validate application field
|
|
4317
|
-
if (fields[0].length == 0) {
|
|
4318
|
-
throw new Error("Application field cannot be empty");
|
|
4319
|
-
}
|
|
4320
|
-
// Validate version field
|
|
4321
|
-
if (fields[1].length == 0) {
|
|
4322
|
-
throw new Error("Version field cannot be empty");
|
|
4323
|
-
}
|
|
4324
|
-
// Validate topic name field
|
|
4325
|
-
if (fields[2].length == 0) {
|
|
4326
|
-
throw new Error("Topic name field cannot be empty");
|
|
4327
|
-
}
|
|
4328
|
-
// Validate encoding field
|
|
4329
|
-
if (fields[3].length == 0) {
|
|
4330
|
-
throw new Error("Encoding field cannot be empty");
|
|
4331
|
-
}
|
|
4332
|
-
return {
|
|
4333
|
-
generation,
|
|
4334
|
-
application: fields[0],
|
|
4335
|
-
version: fields[1],
|
|
4336
|
-
topicName: fields[2],
|
|
4337
|
-
encoding: fields[3]
|
|
4338
|
-
};
|
|
4339
|
-
}
|
|
4340
|
-
/**
|
|
4341
|
-
* Given a string, determines which autoshard index to use for its pubsub topic.
|
|
4342
|
-
* Based on the algorithm described in the RFC: https://rfc.vac.dev/spec/51//#algorithm
|
|
4343
|
-
*/
|
|
4344
|
-
function contentTopicToShardIndex(contentTopic, networkShards = 8) {
|
|
4345
|
-
const { application, version } = ensureValidContentTopic(contentTopic);
|
|
4346
|
-
const digest = sha256(concat([utf8ToBytes$1(application), utf8ToBytes$1(version)]));
|
|
4347
|
-
const dataview = new DataView(digest.buffer.slice(-8));
|
|
4348
|
-
return Number(dataview.getBigUint64(0, false) % BigInt(networkShards));
|
|
4349
|
-
}
|
|
4350
|
-
function contentTopicToPubsubTopic(contentTopic, clusterId = DEFAULT_CLUSTER_ID, networkShards = 8) {
|
|
4351
|
-
if (!contentTopic) {
|
|
4352
|
-
throw Error("Content topic must be specified");
|
|
4353
|
-
}
|
|
4354
|
-
const shardIndex = contentTopicToShardIndex(contentTopic, networkShards);
|
|
4355
|
-
return `/waku/2/rs/${clusterId}/${shardIndex}`;
|
|
4356
|
-
}
|
|
4357
|
-
/**
|
|
4358
|
-
* Used when creating encoders/decoders to determine which pubsub topic to use
|
|
4359
|
-
*/
|
|
4360
|
-
function determinePubsubTopic(contentTopic,
|
|
4361
|
-
// TODO: make it accept ShardInfo https://github.com/waku-org/js-waku/issues/2086
|
|
4362
|
-
pubsubTopicShardInfo) {
|
|
4363
|
-
if (typeof pubsubTopicShardInfo == "string") {
|
|
4364
|
-
return pubsubTopicShardInfo;
|
|
4365
|
-
}
|
|
4366
|
-
return pubsubTopicShardInfo?.shard !== undefined
|
|
4367
|
-
? singleShardInfoToPubsubTopic(pubsubTopicShardInfo)
|
|
4368
|
-
: contentTopicToPubsubTopic(contentTopic, pubsubTopicShardInfo?.clusterId ?? DEFAULT_CLUSTER_ID);
|
|
4369
|
-
}
|
|
4370
|
-
|
|
4371
3977
|
var browser = {exports: {}};
|
|
4372
3978
|
|
|
4373
3979
|
/**
|
|
@@ -5117,7 +4723,7 @@ class Logger {
|
|
|
5117
4723
|
_warn;
|
|
5118
4724
|
_error;
|
|
5119
4725
|
static createDebugNamespace(level, prefix) {
|
|
5120
|
-
return prefix ? `${APP_NAME}:${
|
|
4726
|
+
return prefix ? `${APP_NAME}:${prefix}:${level}` : `${APP_NAME}:${level}`;
|
|
5121
4727
|
}
|
|
5122
4728
|
constructor(prefix) {
|
|
5123
4729
|
this._info = debug(Logger.createDebugNamespace("info", prefix));
|
|
@@ -5134,7 +4740,7 @@ class Logger {
|
|
|
5134
4740
|
return this._error;
|
|
5135
4741
|
}
|
|
5136
4742
|
log(level, ...args) {
|
|
5137
|
-
const logger = this[level];
|
|
4743
|
+
const logger = this[level] || this.log;
|
|
5138
4744
|
logger(...args);
|
|
5139
4745
|
}
|
|
5140
4746
|
}
|
|
@@ -5186,15 +4792,18 @@ let DecodedMessage$1 = class DecodedMessage {
|
|
|
5186
4792
|
}
|
|
5187
4793
|
};
|
|
5188
4794
|
let Decoder$1 = class Decoder {
|
|
5189
|
-
pubsubTopic;
|
|
5190
4795
|
contentTopic;
|
|
5191
|
-
|
|
5192
|
-
|
|
4796
|
+
routingInfo;
|
|
4797
|
+
constructor(contentTopic, routingInfo) {
|
|
5193
4798
|
this.contentTopic = contentTopic;
|
|
4799
|
+
this.routingInfo = routingInfo;
|
|
5194
4800
|
if (!contentTopic || contentTopic === "") {
|
|
5195
4801
|
throw new Error("Content topic must be specified");
|
|
5196
4802
|
}
|
|
5197
4803
|
}
|
|
4804
|
+
get pubsubTopic() {
|
|
4805
|
+
return this.routingInfo.pubsubTopic;
|
|
4806
|
+
}
|
|
5198
4807
|
fromWireToProtoObj(bytes) {
|
|
5199
4808
|
const protoMessage = WakuMessage$4.decode(bytes);
|
|
5200
4809
|
return Promise.resolve({
|
|
@@ -5434,4 +5043,4 @@ function postCipher(message) {
|
|
|
5434
5043
|
return { payload, sig };
|
|
5435
5044
|
}
|
|
5436
5045
|
|
|
5437
|
-
export { Decoder$1 as D, Logger as L, WakuMessage$3 as W,
|
|
5046
|
+
export { Decoder$1 as D, Logger as L, WakuMessage$3 as W, postCipher as a, DecodedMessage as b, encryptSymmetric as c, decryptAsymmetric as d, encryptAsymmetric as e, decryptSymmetric as f, preCipher as p };
|