@waku/core 0.0.7 → 0.0.9
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 +22 -1
- package/bundle/index.js +96 -95
- package/bundle/lib/message/topic_only_message.js +2 -33
- package/bundle/lib/message/version_0.js +1 -132
- package/bundle/topic_only_message-ece0fef9.js +39 -0
- package/bundle/version_0-b1fc527d.js +143 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/message/index.d.ts +2 -0
- package/dist/lib/message/index.js +3 -0
- package/dist/lib/message/index.js.map +1 -0
- package/dist/lib/message/topic_only_message.d.ts +2 -2
- package/dist/lib/message/topic_only_message.js +2 -2
- package/dist/lib/message/topic_only_message.js.map +1 -1
- package/dist/lib/relay/constants.js +1 -4
- package/dist/lib/relay/constants.js.map +1 -1
- package/dist/lib/relay/index.d.ts +3 -3
- package/dist/lib/relay/index.js.map +1 -1
- package/dist/lib/wait_for_remote_peer.d.ts +2 -2
- package/dist/lib/wait_for_remote_peer.js +2 -5
- package/dist/lib/wait_for_remote_peer.js.map +1 -1
- package/package.json +7 -4
- package/src/index.ts +4 -7
- package/src/lib/message/index.ts +2 -0
- package/src/lib/message/topic_only_message.ts +3 -3
- package/src/lib/relay/constants.ts +1 -4
- package/src/lib/relay/index.ts +4 -4
- package/src/lib/wait_for_remote_peer.ts +2 -5
package/CHANGELOG.md
CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [@waku/core@0.0.9] - 2023-01-18
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
- Removed `/vac/waku/relay/2.0.0-beta2` from `WakuRelay` protocols.
|
15
|
+
- Moved `@chai` and `@fast-check` to `dependencies` list.
|
16
|
+
- Remove peer exchange from protocols to expect in `waitForRemotePeer` by default.
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
|
20
|
+
- Documentation links.
|
21
|
+
|
22
|
+
## [@waku/core@0.0.8] - 2022-12-19
|
23
|
+
|
24
|
+
### Fixed
|
25
|
+
|
26
|
+
- Missing dependency declarations.
|
27
|
+
- Invalid re-export.
|
28
|
+
|
10
29
|
## [@waku/core@0.0.7] - 2022-12-15
|
11
30
|
|
12
31
|
### Added
|
@@ -627,7 +646,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
627
646
|
- [ReactJS Chat App example](./examples/web-chat).
|
628
647
|
- [Typedoc Documentation](https://js-waku.wakuconnect.dev/).
|
629
648
|
|
630
|
-
[unreleased]: https://github.com/status-im/js-waku/compare/@waku/core@0.0.
|
649
|
+
[unreleased]: https://github.com/status-im/js-waku/compare/@waku/core@0.0.9...HEAD
|
650
|
+
[@waku/core@0.0.9]: https://github.com/waku-org/js-waku/compare/@waku/core@0.0.8...@waku/core@0.0.9
|
651
|
+
[@waku/core@0.0.8]: https://github.com/waku-org/js-waku/compare/@waku/core@0.0.7...@waku/core@0.0.8
|
631
652
|
[@waku/core@0.0.7]: https://github.com/waku-org/js-waku/compare/@waku/core@0.0.6...@waku/core@0.0.7
|
632
653
|
[@waku/core@0.0.6]: https://github.com/waku-org/js-waku/compare/@waku/core@0.0.5...@waku/core@0.0.6
|
633
654
|
[@waku/core@0.0.5]: https://github.com/waku-org/js-waku/compare/@waku/core@0.0.4...@waku/core@0.0.5
|
package/bundle/index.js
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
import { c as commonjsGlobal, a as aspromise, b as base64$5, e as eventemitter, f as float, i as inquire_1, u as utf8$6, p as pool_1, g as getAugmentedNamespace, d as debug, F as FilterRPC$1, P as PushRPC$1, h as PushResponse, H as HistoryRPC$1, j as PagingInfo, k as HistoryResponse, l as getDefaultExportFromCjs } from './peer_exchange-53df2b11.js';
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
import { TopicOnlyDecoder } from './lib/message/topic_only_message.js';
|
2
|
+
import { c as createEncoder, v as version_0 } from './version_0-b1fc527d.js';
|
3
|
+
export { D as DecodedMessage, a as createDecoder, c as createEncoder } from './version_0-b1fc527d.js';
|
4
|
+
import { t as topic_only_message, T as TopicOnlyDecoder } from './topic_only_message-ece0fef9.js';
|
6
5
|
|
7
6
|
/**
|
8
7
|
* DefaultPubSubTopic is the default gossipsub topic to use for Waku.
|
@@ -24117,12 +24116,12 @@ function decodeWaku2(byte) {
|
|
24117
24116
|
|
24118
24117
|
const log$8 = debug("waku:enr");
|
24119
24118
|
class ENR extends Map {
|
24120
|
-
constructor(kvs = {}, seq = BigInt(1), signature
|
24119
|
+
constructor(kvs = {}, seq = BigInt(1), signature) {
|
24121
24120
|
super(Object.entries(kvs));
|
24122
24121
|
this.seq = seq;
|
24123
24122
|
this.signature = signature;
|
24124
24123
|
}
|
24125
|
-
static async create(kvs = {}, seq = BigInt(1), signature
|
24124
|
+
static async create(kvs = {}, seq = BigInt(1), signature) {
|
24126
24125
|
const enr = new ENR(kvs, seq, signature);
|
24127
24126
|
try {
|
24128
24127
|
const publicKey = enr.publicKey;
|
@@ -24199,7 +24198,7 @@ class ENR extends Map {
|
|
24199
24198
|
return ENR.decode(fromString$1(encoded.slice(4), "base64url"));
|
24200
24199
|
}
|
24201
24200
|
set(k, v) {
|
24202
|
-
this.signature =
|
24201
|
+
this.signature = undefined;
|
24203
24202
|
this.seq++;
|
24204
24203
|
return super.set(k, v);
|
24205
24204
|
}
|
@@ -25958,6 +25957,83 @@ function pipe(first, ...rest) {
|
|
25958
25957
|
const PeerExchangeCodec = "/vac/waku/peer-exchange/2.0.0-alpha1";
|
25959
25958
|
debug("waku:peer-exchange");
|
25960
25959
|
|
25960
|
+
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
25961
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
25962
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
25963
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
25964
|
+
};
|
25965
|
+
var _EventEmitter_listeners;
|
25966
|
+
/**
|
25967
|
+
* Adds types to the EventTarget class. Hopefully this won't be necessary forever.
|
25968
|
+
*
|
25969
|
+
* https://github.com/microsoft/TypeScript/issues/28357
|
25970
|
+
* https://github.com/microsoft/TypeScript/issues/43477
|
25971
|
+
* https://github.com/microsoft/TypeScript/issues/299
|
25972
|
+
* etc
|
25973
|
+
*/
|
25974
|
+
class EventEmitter extends EventTarget {
|
25975
|
+
constructor() {
|
25976
|
+
super(...arguments);
|
25977
|
+
_EventEmitter_listeners.set(this, new Map());
|
25978
|
+
}
|
25979
|
+
listenerCount(type) {
|
25980
|
+
const listeners = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(type);
|
25981
|
+
if (listeners == null) {
|
25982
|
+
return 0;
|
25983
|
+
}
|
25984
|
+
return listeners.length;
|
25985
|
+
}
|
25986
|
+
addEventListener(type, listener, options) {
|
25987
|
+
super.addEventListener(type, listener, options);
|
25988
|
+
let list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(type);
|
25989
|
+
if (list == null) {
|
25990
|
+
list = [];
|
25991
|
+
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(type, list);
|
25992
|
+
}
|
25993
|
+
list.push({
|
25994
|
+
callback: listener,
|
25995
|
+
once: (options !== true && options !== false && options?.once) ?? false
|
25996
|
+
});
|
25997
|
+
}
|
25998
|
+
removeEventListener(type, listener, options) {
|
25999
|
+
super.removeEventListener(type.toString(), listener ?? null, options);
|
26000
|
+
let list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(type);
|
26001
|
+
if (list == null) {
|
26002
|
+
return;
|
26003
|
+
}
|
26004
|
+
list = list.filter(({ callback }) => callback !== listener);
|
26005
|
+
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(type, list);
|
26006
|
+
}
|
26007
|
+
dispatchEvent(event) {
|
26008
|
+
const result = super.dispatchEvent(event);
|
26009
|
+
let list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(event.type);
|
26010
|
+
if (list == null) {
|
26011
|
+
return result;
|
26012
|
+
}
|
26013
|
+
list = list.filter(({ once }) => !once);
|
26014
|
+
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(event.type, list);
|
26015
|
+
return result;
|
26016
|
+
}
|
26017
|
+
}
|
26018
|
+
_EventEmitter_listeners = new WeakMap();
|
26019
|
+
/**
|
26020
|
+
* CustomEvent is a standard event but it's not supported by node.
|
26021
|
+
*
|
26022
|
+
* Remove this when https://github.com/nodejs/node/issues/40678 is closed.
|
26023
|
+
*
|
26024
|
+
* Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
|
26025
|
+
*/
|
26026
|
+
class CustomEventPolyfill extends Event {
|
26027
|
+
constructor(message, data) {
|
26028
|
+
super(message, data);
|
26029
|
+
// @ts-expect-error could be undefined
|
26030
|
+
this.detail = data?.detail;
|
26031
|
+
}
|
26032
|
+
}
|
26033
|
+
const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill;
|
26034
|
+
|
26035
|
+
debug("waku:peer-exchange-discovery");
|
26036
|
+
|
25961
26037
|
function groupByContentTopic(values) {
|
25962
26038
|
const groupedDecoders = new Map();
|
25963
26039
|
values.forEach((value) => {
|
@@ -26682,7 +26758,7 @@ function wakuFilter(init = {}) {
|
|
26682
26758
|
return (components) => new Filter(components, init);
|
26683
26759
|
}
|
26684
26760
|
|
26685
|
-
var index$
|
26761
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
26686
26762
|
__proto__: null,
|
26687
26763
|
FilterCodec: FilterCodec,
|
26688
26764
|
wakuFilter: wakuFilter
|
@@ -26795,7 +26871,7 @@ function wakuLightPush(init = {}) {
|
|
26795
26871
|
return (components) => new LightPush(components, init);
|
26796
26872
|
}
|
26797
26873
|
|
26798
|
-
var index$
|
26874
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
26799
26875
|
__proto__: null,
|
26800
26876
|
LightPushCodec: LightPushCodec,
|
26801
26877
|
get PushResponse () { return PushResponse; },
|
@@ -26805,10 +26881,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
26805
26881
|
/**
|
26806
26882
|
* RelayCodec is the libp2p identifier for the waku relay protocol
|
26807
26883
|
*/
|
26808
|
-
const RelayCodecs = [
|
26809
|
-
"/vac/waku/relay/2.0.0-beta2",
|
26810
|
-
"/vac/waku/relay/2.0.0",
|
26811
|
-
];
|
26884
|
+
const RelayCodecs = ["/vac/waku/relay/2.0.0"];
|
26812
26885
|
const RelayPingContentTopic = "/relay-ping/1/ping/null";
|
26813
26886
|
|
26814
26887
|
function number(n) {
|
@@ -27401,7 +27474,7 @@ function wakuStore(init = {}) {
|
|
27401
27474
|
return (components) => new Store(components, init);
|
27402
27475
|
}
|
27403
27476
|
|
27404
|
-
var index$
|
27477
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
27405
27478
|
__proto__: null,
|
27406
27479
|
StoreCodec: StoreCodec,
|
27407
27480
|
DefaultPageSize: DefaultPageSize,
|
@@ -27592,6 +27665,12 @@ var waku = /*#__PURE__*/Object.freeze({
|
|
27592
27665
|
WakuNode: WakuNode
|
27593
27666
|
});
|
27594
27667
|
|
27668
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
27669
|
+
__proto__: null,
|
27670
|
+
version_0: version_0,
|
27671
|
+
topic_only_message: topic_only_message
|
27672
|
+
});
|
27673
|
+
|
27595
27674
|
const codes = {
|
27596
27675
|
ERR_SIGNATURE_NOT_VALID: 'ERR_SIGNATURE_NOT_VALID'
|
27597
27676
|
};
|
@@ -29698,81 +29777,6 @@ function createTopology(init) {
|
|
29698
29777
|
return new TopologyImpl(init);
|
29699
29778
|
}
|
29700
29779
|
|
29701
|
-
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
29702
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
29703
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
29704
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
29705
|
-
};
|
29706
|
-
var _EventEmitter_listeners;
|
29707
|
-
/**
|
29708
|
-
* Adds types to the EventTarget class. Hopefully this won't be necessary forever.
|
29709
|
-
*
|
29710
|
-
* https://github.com/microsoft/TypeScript/issues/28357
|
29711
|
-
* https://github.com/microsoft/TypeScript/issues/43477
|
29712
|
-
* https://github.com/microsoft/TypeScript/issues/299
|
29713
|
-
* etc
|
29714
|
-
*/
|
29715
|
-
class EventEmitter extends EventTarget {
|
29716
|
-
constructor() {
|
29717
|
-
super(...arguments);
|
29718
|
-
_EventEmitter_listeners.set(this, new Map());
|
29719
|
-
}
|
29720
|
-
listenerCount(type) {
|
29721
|
-
const listeners = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(type);
|
29722
|
-
if (listeners == null) {
|
29723
|
-
return 0;
|
29724
|
-
}
|
29725
|
-
return listeners.length;
|
29726
|
-
}
|
29727
|
-
addEventListener(type, listener, options) {
|
29728
|
-
super.addEventListener(type, listener, options);
|
29729
|
-
let list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(type);
|
29730
|
-
if (list == null) {
|
29731
|
-
list = [];
|
29732
|
-
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(type, list);
|
29733
|
-
}
|
29734
|
-
list.push({
|
29735
|
-
callback: listener,
|
29736
|
-
once: (options !== true && options !== false && options?.once) ?? false
|
29737
|
-
});
|
29738
|
-
}
|
29739
|
-
removeEventListener(type, listener, options) {
|
29740
|
-
super.removeEventListener(type.toString(), listener ?? null, options);
|
29741
|
-
let list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(type);
|
29742
|
-
if (list == null) {
|
29743
|
-
return;
|
29744
|
-
}
|
29745
|
-
list = list.filter(({ callback }) => callback !== listener);
|
29746
|
-
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(type, list);
|
29747
|
-
}
|
29748
|
-
dispatchEvent(event) {
|
29749
|
-
const result = super.dispatchEvent(event);
|
29750
|
-
let list = __classPrivateFieldGet(this, _EventEmitter_listeners, "f").get(event.type);
|
29751
|
-
if (list == null) {
|
29752
|
-
return result;
|
29753
|
-
}
|
29754
|
-
list = list.filter(({ once }) => !once);
|
29755
|
-
__classPrivateFieldGet(this, _EventEmitter_listeners, "f").set(event.type, list);
|
29756
|
-
return result;
|
29757
|
-
}
|
29758
|
-
}
|
29759
|
-
_EventEmitter_listeners = new WeakMap();
|
29760
|
-
/**
|
29761
|
-
* CustomEvent is a standard event but it's not supported by node.
|
29762
|
-
*
|
29763
|
-
* Remove this when https://github.com/nodejs/node/issues/40678 is closed.
|
29764
|
-
*
|
29765
|
-
* Ref: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent
|
29766
|
-
*/
|
29767
|
-
class CustomEventPolyfill extends Event {
|
29768
|
-
constructor(message, data) {
|
29769
|
-
super(message, data);
|
29770
|
-
// @ts-expect-error could be undefined
|
29771
|
-
this.detail = data?.detail;
|
29772
|
-
}
|
29773
|
-
}
|
29774
|
-
const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill;
|
29775
|
-
|
29776
29780
|
class MessageCache {
|
29777
29781
|
/**
|
29778
29782
|
* Holds history of messages in timebounded history arrays
|
@@ -39314,8 +39318,8 @@ const log = debug("waku:wait-for-remote-peer");
|
|
39314
39318
|
/**
|
39315
39319
|
* Wait for a remote peer to be ready given the passed protocols.
|
39316
39320
|
* Must be used after attempting to connect to nodes, using
|
39317
|
-
* {@link
|
39318
|
-
* {@link
|
39321
|
+
* {@link @waku/core.WakuNode.dial} or a bootstrap method with
|
39322
|
+
* {@link @waku/create.createLightNode}.
|
39319
39323
|
*
|
39320
39324
|
* If the passed protocols is a GossipSub protocol, then it resolves only once
|
39321
39325
|
* a peer is in a mesh, to help ensure that other peers will send and receive
|
@@ -39419,10 +39423,7 @@ function getEnabledProtocols(waku) {
|
|
39419
39423
|
if (waku.lightPush) {
|
39420
39424
|
protocols.push(Protocols.LightPush);
|
39421
39425
|
}
|
39422
|
-
if (waku.peerExchange) {
|
39423
|
-
protocols.push(Protocols.PeerExchange);
|
39424
|
-
}
|
39425
39426
|
return protocols;
|
39426
39427
|
}
|
39427
39428
|
|
39428
|
-
export { DefaultPubSubTopic, DefaultUserAgent, LightPushCodec, PageDirection, StoreCodec, WakuNode, createCursor, waitForRemotePeer, waku, wakuFilter, wakuLightPush, wakuRelay, wakuStore, index$
|
39429
|
+
export { DefaultPubSubTopic, DefaultUserAgent, LightPushCodec, PageDirection, StoreCodec, WakuNode, createCursor, index$1 as message, waitForRemotePeer, waku, wakuFilter, wakuLightPush, wakuRelay, wakuStore, index$4 as waku_filter, index$3 as waku_light_push, index as waku_relay, index$2 as waku_store };
|
@@ -1,33 +1,2 @@
|
|
1
|
-
import
|
2
|
-
|
3
|
-
const log = debug("waku:message:topic-only");
|
4
|
-
class TopicOnlyMessage {
|
5
|
-
constructor(proto) {
|
6
|
-
this.proto = proto;
|
7
|
-
}
|
8
|
-
get contentTopic() {
|
9
|
-
return this.proto.contentTopic ?? "";
|
10
|
-
}
|
11
|
-
}
|
12
|
-
class TopicOnlyDecoder {
|
13
|
-
constructor() {
|
14
|
-
this.contentTopic = "";
|
15
|
-
}
|
16
|
-
fromWireToProtoObj(bytes) {
|
17
|
-
const protoMessage = TopicOnlyMessage$1.decode(bytes);
|
18
|
-
log("Message decoded", protoMessage);
|
19
|
-
return Promise.resolve({
|
20
|
-
contentTopic: protoMessage.contentTopic,
|
21
|
-
payload: undefined,
|
22
|
-
rateLimitProof: undefined,
|
23
|
-
timestamp: undefined,
|
24
|
-
version: undefined,
|
25
|
-
ephemeral: undefined,
|
26
|
-
});
|
27
|
-
}
|
28
|
-
async fromProtoObj(proto) {
|
29
|
-
return new TopicOnlyMessage(proto);
|
30
|
-
}
|
31
|
-
}
|
32
|
-
|
33
|
-
export { TopicOnlyDecoder, TopicOnlyMessage };
|
1
|
+
import '../../peer_exchange-53df2b11.js';
|
2
|
+
export { T as TopicOnlyDecoder, a as TopicOnlyMessage } from '../../topic_only_message-ece0fef9.js';
|
@@ -1,133 +1,2 @@
|
|
1
|
-
import { d as debug, W as WakuMessage } from '../../peer_exchange-53df2b11.js';
|
2
1
|
export { m as proto } from '../../peer_exchange-53df2b11.js';
|
3
|
-
|
4
|
-
const log = debug("waku:message:version-0");
|
5
|
-
const OneMillion = BigInt(1000000);
|
6
|
-
const Version = 0;
|
7
|
-
class DecodedMessage {
|
8
|
-
constructor(proto) {
|
9
|
-
this.proto = proto;
|
10
|
-
}
|
11
|
-
get _rawPayload() {
|
12
|
-
if (this.proto.payload) {
|
13
|
-
return new Uint8Array(this.proto.payload);
|
14
|
-
}
|
15
|
-
return;
|
16
|
-
}
|
17
|
-
get ephemeral() {
|
18
|
-
return Boolean(this.proto.ephemeral);
|
19
|
-
}
|
20
|
-
get payload() {
|
21
|
-
return this._rawPayload;
|
22
|
-
}
|
23
|
-
get contentTopic() {
|
24
|
-
return this.proto.contentTopic;
|
25
|
-
}
|
26
|
-
get _rawTimestamp() {
|
27
|
-
return this.proto.timestamp;
|
28
|
-
}
|
29
|
-
get timestamp() {
|
30
|
-
// In the case we receive a value that is bigger than JS's max number,
|
31
|
-
// we catch the error and return undefined.
|
32
|
-
try {
|
33
|
-
if (this.proto.timestamp) {
|
34
|
-
// nanoseconds 10^-9 to milliseconds 10^-3
|
35
|
-
const timestamp = this.proto.timestamp / OneMillion;
|
36
|
-
return new Date(Number(timestamp));
|
37
|
-
}
|
38
|
-
if (this.proto.timestampDeprecated) {
|
39
|
-
return new Date(this.proto.timestampDeprecated * 1000);
|
40
|
-
}
|
41
|
-
}
|
42
|
-
catch (e) {
|
43
|
-
return;
|
44
|
-
}
|
45
|
-
return;
|
46
|
-
}
|
47
|
-
get version() {
|
48
|
-
// https://github.com/status-im/js-waku/issues/921
|
49
|
-
return this.proto.version ?? 0;
|
50
|
-
}
|
51
|
-
get rateLimitProof() {
|
52
|
-
return this.proto.rateLimitProof;
|
53
|
-
}
|
54
|
-
}
|
55
|
-
class Encoder {
|
56
|
-
constructor(contentTopic, ephemeral = false) {
|
57
|
-
this.contentTopic = contentTopic;
|
58
|
-
this.ephemeral = ephemeral;
|
59
|
-
}
|
60
|
-
async toWire(message$1) {
|
61
|
-
return WakuMessage.encode(await this.toProtoObj(message$1));
|
62
|
-
}
|
63
|
-
async toProtoObj(message) {
|
64
|
-
const timestamp = message.timestamp ?? new Date();
|
65
|
-
return {
|
66
|
-
payload: message.payload,
|
67
|
-
version: Version,
|
68
|
-
contentTopic: this.contentTopic,
|
69
|
-
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
70
|
-
rateLimitProof: message.rateLimitProof,
|
71
|
-
ephemeral: this.ephemeral,
|
72
|
-
};
|
73
|
-
}
|
74
|
-
}
|
75
|
-
/**
|
76
|
-
* Creates an encoder that encode messages without Waku level encryption or signature.
|
77
|
-
*
|
78
|
-
* An encoder is used to encode messages in the [`14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
|
79
|
-
* format to be sent over the Waku network. The resulting encoder can then be
|
80
|
-
* pass to { @link @waku/interfaces.LightPush.push } or
|
81
|
-
* { @link @waku/interfaces.Relay.send } to automatically encode outgoing
|
82
|
-
* messages.
|
83
|
-
*
|
84
|
-
* @param contentTopic The content topic to set on outgoing messages.
|
85
|
-
* @param ephemeral An optional flag to mark message as ephemeral, ie, not to be stored by Waku Store nodes.
|
86
|
-
*/
|
87
|
-
function createEncoder(contentTopic, ephemeral = false) {
|
88
|
-
return new Encoder(contentTopic, ephemeral);
|
89
|
-
}
|
90
|
-
class Decoder {
|
91
|
-
constructor(contentTopic) {
|
92
|
-
this.contentTopic = contentTopic;
|
93
|
-
}
|
94
|
-
fromWireToProtoObj(bytes) {
|
95
|
-
const protoMessage = WakuMessage.decode(bytes);
|
96
|
-
log("Message decoded", protoMessage);
|
97
|
-
return Promise.resolve({
|
98
|
-
payload: protoMessage.payload ?? undefined,
|
99
|
-
contentTopic: protoMessage.contentTopic ?? undefined,
|
100
|
-
version: protoMessage.version ?? undefined,
|
101
|
-
timestamp: protoMessage.timestamp ?? undefined,
|
102
|
-
rateLimitProof: protoMessage.rateLimitProof ?? undefined,
|
103
|
-
ephemeral: protoMessage.ephemeral ?? false,
|
104
|
-
});
|
105
|
-
}
|
106
|
-
async fromProtoObj(proto) {
|
107
|
-
// https://github.com/status-im/js-waku/issues/921
|
108
|
-
if (proto.version === undefined) {
|
109
|
-
proto.version = 0;
|
110
|
-
}
|
111
|
-
if (proto.version !== Version) {
|
112
|
-
log("Failed to decode due to incorrect version, expected:", Version, ", actual:", proto.version);
|
113
|
-
return Promise.resolve(undefined);
|
114
|
-
}
|
115
|
-
return new DecodedMessage(proto);
|
116
|
-
}
|
117
|
-
}
|
118
|
-
/**
|
119
|
-
* Creates an decoder that decode messages without Waku level encryption.
|
120
|
-
*
|
121
|
-
* A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
|
122
|
-
* format when received from the Waku network. The resulting decoder can then be
|
123
|
-
* pass to { @link @waku/interfaces.Filter.subscribe } or
|
124
|
-
* { @link @waku/interfaces.Relay.subscribe } to automatically decode incoming
|
125
|
-
* messages.
|
126
|
-
*
|
127
|
-
* @param contentTopic The resulting decoder will only decode messages with this content topic.
|
128
|
-
*/
|
129
|
-
function createDecoder(contentTopic) {
|
130
|
-
return new Decoder(contentTopic);
|
131
|
-
}
|
132
|
-
|
133
|
-
export { DecodedMessage, Decoder, Encoder, Version, createDecoder, createEncoder };
|
2
|
+
export { D as DecodedMessage, b as Decoder, E as Encoder, V as Version, a as createDecoder, c as createEncoder } from '../../version_0-b1fc527d.js';
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { d as debug, T as TopicOnlyMessage$1 } from './peer_exchange-53df2b11.js';
|
2
|
+
|
3
|
+
const log = debug("waku:message:topic-only");
|
4
|
+
class TopicOnlyMessage {
|
5
|
+
constructor(proto) {
|
6
|
+
this.proto = proto;
|
7
|
+
}
|
8
|
+
get contentTopic() {
|
9
|
+
return this.proto.contentTopic ?? "";
|
10
|
+
}
|
11
|
+
}
|
12
|
+
class TopicOnlyDecoder {
|
13
|
+
constructor() {
|
14
|
+
this.contentTopic = "";
|
15
|
+
}
|
16
|
+
fromWireToProtoObj(bytes) {
|
17
|
+
const protoMessage = TopicOnlyMessage$1.decode(bytes);
|
18
|
+
log("Message decoded", protoMessage);
|
19
|
+
return Promise.resolve({
|
20
|
+
contentTopic: protoMessage.contentTopic,
|
21
|
+
payload: undefined,
|
22
|
+
rateLimitProof: undefined,
|
23
|
+
timestamp: undefined,
|
24
|
+
version: undefined,
|
25
|
+
ephemeral: undefined,
|
26
|
+
});
|
27
|
+
}
|
28
|
+
async fromProtoObj(proto) {
|
29
|
+
return new TopicOnlyMessage(proto);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
var topic_only_message = /*#__PURE__*/Object.freeze({
|
34
|
+
__proto__: null,
|
35
|
+
TopicOnlyMessage: TopicOnlyMessage,
|
36
|
+
TopicOnlyDecoder: TopicOnlyDecoder
|
37
|
+
});
|
38
|
+
|
39
|
+
export { TopicOnlyDecoder as T, TopicOnlyMessage as a, topic_only_message as t };
|
@@ -0,0 +1,143 @@
|
|
1
|
+
import { d as debug, W as WakuMessage, m as message } from './peer_exchange-53df2b11.js';
|
2
|
+
|
3
|
+
const log = debug("waku:message:version-0");
|
4
|
+
const OneMillion = BigInt(1000000);
|
5
|
+
const Version = 0;
|
6
|
+
class DecodedMessage {
|
7
|
+
constructor(proto) {
|
8
|
+
this.proto = proto;
|
9
|
+
}
|
10
|
+
get _rawPayload() {
|
11
|
+
if (this.proto.payload) {
|
12
|
+
return new Uint8Array(this.proto.payload);
|
13
|
+
}
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
get ephemeral() {
|
17
|
+
return Boolean(this.proto.ephemeral);
|
18
|
+
}
|
19
|
+
get payload() {
|
20
|
+
return this._rawPayload;
|
21
|
+
}
|
22
|
+
get contentTopic() {
|
23
|
+
return this.proto.contentTopic;
|
24
|
+
}
|
25
|
+
get _rawTimestamp() {
|
26
|
+
return this.proto.timestamp;
|
27
|
+
}
|
28
|
+
get timestamp() {
|
29
|
+
// In the case we receive a value that is bigger than JS's max number,
|
30
|
+
// we catch the error and return undefined.
|
31
|
+
try {
|
32
|
+
if (this.proto.timestamp) {
|
33
|
+
// nanoseconds 10^-9 to milliseconds 10^-3
|
34
|
+
const timestamp = this.proto.timestamp / OneMillion;
|
35
|
+
return new Date(Number(timestamp));
|
36
|
+
}
|
37
|
+
if (this.proto.timestampDeprecated) {
|
38
|
+
return new Date(this.proto.timestampDeprecated * 1000);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
catch (e) {
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
get version() {
|
47
|
+
// https://github.com/status-im/js-waku/issues/921
|
48
|
+
return this.proto.version ?? 0;
|
49
|
+
}
|
50
|
+
get rateLimitProof() {
|
51
|
+
return this.proto.rateLimitProof;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
class Encoder {
|
55
|
+
constructor(contentTopic, ephemeral = false) {
|
56
|
+
this.contentTopic = contentTopic;
|
57
|
+
this.ephemeral = ephemeral;
|
58
|
+
}
|
59
|
+
async toWire(message$1) {
|
60
|
+
return WakuMessage.encode(await this.toProtoObj(message$1));
|
61
|
+
}
|
62
|
+
async toProtoObj(message) {
|
63
|
+
const timestamp = message.timestamp ?? new Date();
|
64
|
+
return {
|
65
|
+
payload: message.payload,
|
66
|
+
version: Version,
|
67
|
+
contentTopic: this.contentTopic,
|
68
|
+
timestamp: BigInt(timestamp.valueOf()) * OneMillion,
|
69
|
+
rateLimitProof: message.rateLimitProof,
|
70
|
+
ephemeral: this.ephemeral,
|
71
|
+
};
|
72
|
+
}
|
73
|
+
}
|
74
|
+
/**
|
75
|
+
* Creates an encoder that encode messages without Waku level encryption or signature.
|
76
|
+
*
|
77
|
+
* An encoder is used to encode messages in the [`14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
|
78
|
+
* format to be sent over the Waku network. The resulting encoder can then be
|
79
|
+
* pass to { @link @waku/interfaces.LightPush.push } or
|
80
|
+
* { @link @waku/interfaces.Relay.send } to automatically encode outgoing
|
81
|
+
* messages.
|
82
|
+
*
|
83
|
+
* @param contentTopic The content topic to set on outgoing messages.
|
84
|
+
* @param ephemeral An optional flag to mark message as ephemeral, ie, not to be stored by Waku Store nodes.
|
85
|
+
*/
|
86
|
+
function createEncoder(contentTopic, ephemeral = false) {
|
87
|
+
return new Encoder(contentTopic, ephemeral);
|
88
|
+
}
|
89
|
+
class Decoder {
|
90
|
+
constructor(contentTopic) {
|
91
|
+
this.contentTopic = contentTopic;
|
92
|
+
}
|
93
|
+
fromWireToProtoObj(bytes) {
|
94
|
+
const protoMessage = WakuMessage.decode(bytes);
|
95
|
+
log("Message decoded", protoMessage);
|
96
|
+
return Promise.resolve({
|
97
|
+
payload: protoMessage.payload ?? undefined,
|
98
|
+
contentTopic: protoMessage.contentTopic ?? undefined,
|
99
|
+
version: protoMessage.version ?? undefined,
|
100
|
+
timestamp: protoMessage.timestamp ?? undefined,
|
101
|
+
rateLimitProof: protoMessage.rateLimitProof ?? undefined,
|
102
|
+
ephemeral: protoMessage.ephemeral ?? false,
|
103
|
+
});
|
104
|
+
}
|
105
|
+
async fromProtoObj(proto) {
|
106
|
+
// https://github.com/status-im/js-waku/issues/921
|
107
|
+
if (proto.version === undefined) {
|
108
|
+
proto.version = 0;
|
109
|
+
}
|
110
|
+
if (proto.version !== Version) {
|
111
|
+
log("Failed to decode due to incorrect version, expected:", Version, ", actual:", proto.version);
|
112
|
+
return Promise.resolve(undefined);
|
113
|
+
}
|
114
|
+
return new DecodedMessage(proto);
|
115
|
+
}
|
116
|
+
}
|
117
|
+
/**
|
118
|
+
* Creates an decoder that decode messages without Waku level encryption.
|
119
|
+
*
|
120
|
+
* A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
|
121
|
+
* format when received from the Waku network. The resulting decoder can then be
|
122
|
+
* pass to { @link @waku/interfaces.Filter.subscribe } or
|
123
|
+
* { @link @waku/interfaces.Relay.subscribe } to automatically decode incoming
|
124
|
+
* messages.
|
125
|
+
*
|
126
|
+
* @param contentTopic The resulting decoder will only decode messages with this content topic.
|
127
|
+
*/
|
128
|
+
function createDecoder(contentTopic) {
|
129
|
+
return new Decoder(contentTopic);
|
130
|
+
}
|
131
|
+
|
132
|
+
var version_0 = /*#__PURE__*/Object.freeze({
|
133
|
+
__proto__: null,
|
134
|
+
Version: Version,
|
135
|
+
proto: message,
|
136
|
+
DecodedMessage: DecodedMessage,
|
137
|
+
Encoder: Encoder,
|
138
|
+
createEncoder: createEncoder,
|
139
|
+
Decoder: Decoder,
|
140
|
+
createDecoder: createDecoder
|
141
|
+
});
|
142
|
+
|
143
|
+
export { DecodedMessage as D, Encoder as E, Version as V, createDecoder as a, Decoder as b, createEncoder as c, version_0 as v };
|
package/dist/index.d.ts
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
export { DefaultPubSubTopic } from "./lib/constants.js";
|
2
2
|
export { DefaultUserAgent } from "./lib/waku.js";
|
3
3
|
export { createEncoder, createDecoder, DecodedMessage, } from "./lib/message/version_0.js";
|
4
|
+
export * as message from "./lib/message/index.js";
|
4
5
|
export * as waku from "./lib/waku.js";
|
5
|
-
export { WakuNode } from "./lib/waku.js";
|
6
|
+
export { WakuNode, WakuOptions } from "./lib/waku.js";
|
6
7
|
export * as waku_filter from "./lib/filter/index.js";
|
7
8
|
export { wakuFilter } from "./lib/filter/index.js";
|
8
9
|
export * as waku_light_push from "./lib/light_push/index.js";
|
9
|
-
export { wakuLightPush, LightPushCodec
|
10
|
+
export { wakuLightPush, LightPushCodec } from "./lib/light_push/index.js";
|
10
11
|
export * as waku_relay from "./lib/relay/index.js";
|
11
|
-
export { wakuRelay } from "./lib/relay/index.js";
|
12
|
+
export { wakuRelay, RelayCreateOptions } from "./lib/relay/index.js";
|
12
13
|
export * as waku_store from "./lib/store/index.js";
|
13
14
|
export { PageDirection, wakuStore, StoreCodec, createCursor, } from "./lib/store/index.js";
|
14
15
|
export { waitForRemotePeer } from "./lib/wait_for_remote_peer.js";
|
package/dist/index.js
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
export { DefaultPubSubTopic } from "./lib/constants.js";
|
2
2
|
export { DefaultUserAgent } from "./lib/waku.js";
|
3
3
|
export { createEncoder, createDecoder, DecodedMessage, } from "./lib/message/version_0.js";
|
4
|
+
export * as message from "./lib/message/index.js";
|
4
5
|
export * as waku from "./lib/waku.js";
|
5
6
|
export { WakuNode } from "./lib/waku.js";
|
6
7
|
export * as waku_filter from "./lib/filter/index.js";
|
7
8
|
export { wakuFilter } from "./lib/filter/index.js";
|
8
9
|
export * as waku_light_push from "./lib/light_push/index.js";
|
9
|
-
export { wakuLightPush, LightPushCodec
|
10
|
+
export { wakuLightPush, LightPushCodec } from "./lib/light_push/index.js";
|
10
11
|
export * as waku_relay from "./lib/relay/index.js";
|
11
12
|
export { wakuRelay } from "./lib/relay/index.js";
|
12
13
|
export * as waku_store from "./lib/store/index.js";
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,4BAA4B,CAAC;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAElD,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,OAAO,KAAK,eAAe,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE1E,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAsB,MAAM,sBAAsB,CAAC;AAErE,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAC;AACnD,OAAO,EACL,aAAa,EACb,SAAS,EACT,UAAU,EACV,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/message/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAC"}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { IDecodedMessage, IDecoder, IProtoMessage } from "@waku/interfaces";
|
2
|
-
import {
|
2
|
+
import { TopicOnlyMessage as ProtoTopicOnlyMessage } from "@waku/proto";
|
3
3
|
export declare class TopicOnlyMessage implements IDecodedMessage {
|
4
4
|
private proto;
|
5
5
|
payload: undefined;
|
6
6
|
rateLimitProof: undefined;
|
7
7
|
timestamp: undefined;
|
8
8
|
ephemeral: undefined;
|
9
|
-
constructor(proto:
|
9
|
+
constructor(proto: ProtoTopicOnlyMessage);
|
10
10
|
get contentTopic(): string;
|
11
11
|
}
|
12
12
|
export declare class TopicOnlyDecoder implements IDecoder<TopicOnlyMessage> {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { TopicOnlyMessage as ProtoTopicOnlyMessage } from "@waku/proto";
|
2
2
|
import debug from "debug";
|
3
3
|
const log = debug("waku:message:topic-only");
|
4
4
|
export class TopicOnlyMessage {
|
@@ -14,7 +14,7 @@ export class TopicOnlyDecoder {
|
|
14
14
|
this.contentTopic = "";
|
15
15
|
}
|
16
16
|
fromWireToProtoObj(bytes) {
|
17
|
-
const protoMessage =
|
17
|
+
const protoMessage = ProtoTopicOnlyMessage.decode(bytes);
|
18
18
|
log("Message decoded", protoMessage);
|
19
19
|
return Promise.resolve({
|
20
20
|
contentTopic: protoMessage.contentTopic,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"topic_only_message.js","sourceRoot":"","sources":["../../../src/lib/message/topic_only_message.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"topic_only_message.js","sourceRoot":"","sources":["../../../src/lib/message/topic_only_message.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,IAAI,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,GAAG,GAAG,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAE7C,MAAM,OAAO,gBAAgB;IAM3B,YAAoB,KAA4B;QAA5B,UAAK,GAAL,KAAK,CAAuB;IAAG,CAAC;IAEpD,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;IACvC,CAAC;CACF;AAED,MAAM,OAAO,gBAAgB;IAA7B;QACS,iBAAY,GAAG,EAAE,CAAC;IAoB3B,CAAC;IAlBC,kBAAkB,CAAC,KAAiB;QAClC,MAAM,YAAY,GAAG,qBAAqB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzD,GAAG,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;QACrC,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,YAAY,EAAE,YAAY,CAAC,YAAY;YACvC,OAAO,EAAE,SAAS;YAClB,cAAc,EAAE,SAAS;YACzB,SAAS,EAAE,SAAS;YACpB,OAAO,EAAE,SAAS;YAClB,SAAS,EAAE,SAAS;SACrB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,KAAoB;QAEpB,OAAO,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;CACF"}
|
@@ -3,10 +3,7 @@ export const minute = 60 * second;
|
|
3
3
|
/**
|
4
4
|
* RelayCodec is the libp2p identifier for the waku relay protocol
|
5
5
|
*/
|
6
|
-
export const RelayCodecs = [
|
7
|
-
"/vac/waku/relay/2.0.0-beta2",
|
8
|
-
"/vac/waku/relay/2.0.0",
|
9
|
-
];
|
6
|
+
export const RelayCodecs = ["/vac/waku/relay/2.0.0"];
|
10
7
|
export const RelayPingContentTopic = "/relay-ping/1/ping/null";
|
11
8
|
/**
|
12
9
|
* RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/relay/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;AAC3B,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/relay/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC;AAC3B,MAAM,CAAC,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,CAAC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAErD,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAE/D;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AAEtC;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,EAAE,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC"}
|
@@ -5,7 +5,7 @@ export declare type Observer<T extends IDecodedMessage> = {
|
|
5
5
|
decoder: IDecoder<T>;
|
6
6
|
callback: Callback<T>;
|
7
7
|
};
|
8
|
-
export
|
8
|
+
export interface RelayCreateOptions extends GossipsubOpts {
|
9
9
|
/**
|
10
10
|
* The PubSub Topic to use. Defaults to {@link DefaultPubSubTopic}.
|
11
11
|
*
|
@@ -20,5 +20,5 @@ export declare type CreateOptions = {
|
|
20
20
|
* @default {@link DefaultPubSubTopic}
|
21
21
|
*/
|
22
22
|
pubSubTopic?: string;
|
23
|
-
}
|
24
|
-
export declare function wakuRelay(init?: Partial<
|
23
|
+
}
|
24
|
+
export declare function wakuRelay(init?: Partial<RelayCreateOptions>): (components: GossipSubComponents) => IRelay;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/relay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAIV,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAUpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAE5C,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AAwBhC;;;;;GAKG;AACH,MAAM,KAAM,SAAQ,SAAS;IAW3B,YACE,UAA+B,EAC/B,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/relay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAIV,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAUpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAE5C,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AAwBhC;;;;;GAKG;AACH,MAAM,KAAM,SAAQ,SAAS;IAW3B,YACE,UAA+B,EAC/B,OAAqC;QAErC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE;YACrC,qEAAqE;YACrE,q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AE,YAAY,CAAC,YAAY,CAAC,CAAC;iBAChE;YACH,CAAC,CAAC,CACH,CAAC;QACJ,CAAC,CACF,CAAC;QAEF,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED,YAAY,CAAC,KAAgB;QAC3B,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC;IACvD,CAAC;;AA9Ha,gBAAU,GAAW,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AAiI9D,KAAK,CAAC,UAAU,GAAG,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAE3E,MAAM,UAAU,SAAS,CACvB,OAAoC,EAAE;IAEtC,OAAO,CAAC,UAA+B,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAC1E,CAAC"}
|
@@ -3,8 +3,8 @@ import { Protocols } from "@waku/interfaces";
|
|
3
3
|
/**
|
4
4
|
* Wait for a remote peer to be ready given the passed protocols.
|
5
5
|
* Must be used after attempting to connect to nodes, using
|
6
|
-
* {@link
|
7
|
-
* {@link
|
6
|
+
* {@link @waku/core.WakuNode.dial} or a bootstrap method with
|
7
|
+
* {@link @waku/create.createLightNode}.
|
8
8
|
*
|
9
9
|
* If the passed protocols is a GossipSub protocol, then it resolves only once
|
10
10
|
* a peer is in a mesh, to help ensure that other peers will send and receive
|
@@ -9,8 +9,8 @@ const log = debug("waku:wait-for-remote-peer");
|
|
9
9
|
/**
|
10
10
|
* Wait for a remote peer to be ready given the passed protocols.
|
11
11
|
* Must be used after attempting to connect to nodes, using
|
12
|
-
* {@link
|
13
|
-
* {@link
|
12
|
+
* {@link @waku/core.WakuNode.dial} or a bootstrap method with
|
13
|
+
* {@link @waku/create.createLightNode}.
|
14
14
|
*
|
15
15
|
* If the passed protocols is a GossipSub protocol, then it resolves only once
|
16
16
|
* a peer is in a mesh, to help ensure that other peers will send and receive
|
@@ -114,9 +114,6 @@ function getEnabledProtocols(waku) {
|
|
114
114
|
if (waku.lightPush) {
|
115
115
|
protocols.push(Protocols.LightPush);
|
116
116
|
}
|
117
|
-
if (waku.peerExchange) {
|
118
|
-
protocols.push(Protocols.PeerExchange);
|
119
|
-
}
|
120
117
|
return protocols;
|
121
118
|
}
|
122
119
|
//# sourceMappingURL=wait_for_remote_peer.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"wait_for_remote_peer.js","sourceRoot":"","sources":["../../src/lib/wait_for_remote_peer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,GAAG,GAAG,KAAK,CAAC,2BAA2B,CAAC,CAAC;AAE/C;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAU,EACV,SAAuB,EACvB,SAAkB;IAElB,SAAS,GAAG,SAAS,IAAI,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAEnD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;QAAE,OAAO,OAAO,CAAC,MAAM,CAAC,0BAA0B,CAAC,CAAC;IAEzE,MAAM,QAAQ,GAAG,EAAE,CAAC;IAEpB,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QACvC,IAAI,CAAC,IAAI,CAAC,KAAK;YACb,MAAM,IAAI,KAAK,C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,CAAC,CAAC;KACjC;IAED,IAAI,IAAI,CAAC,MAAM,EAAE;QACf,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;KAClC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE;QACd,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;KACjC;IAED,IAAI,IAAI,CAAC,SAAS,EAAE;QAClB,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;KACrC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@waku/core",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.9",
|
4
4
|
"description": "TypeScript implementation of the Waku v2 protocol",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"module": "./dist/index.js",
|
@@ -90,11 +90,16 @@
|
|
90
90
|
"@noble/hashes": "^1.1.3",
|
91
91
|
"@waku/byte-utils": "*",
|
92
92
|
"@waku/interfaces": "*",
|
93
|
+
"@waku/libp2p-utils": "*",
|
94
|
+
"@waku/peer-exchange": "*",
|
95
|
+
"@waku/proto": "*",
|
93
96
|
"debug": "^4.3.4",
|
94
97
|
"it-all": "^1.0.6",
|
95
98
|
"it-length-prefixed": "^8.0.2",
|
96
99
|
"it-pipe": "^2.0.4",
|
97
100
|
"libp2p": "0.40.0",
|
101
|
+
"chai": "^4.3.4",
|
102
|
+
"fast-check": "^2.14.0",
|
98
103
|
"p-event": "^5.0.1",
|
99
104
|
"uint8arraylist": "^2.3.2",
|
100
105
|
"uint8arrays": "^4.0.2",
|
@@ -108,13 +113,12 @@
|
|
108
113
|
"@types/chai": "^4.2.15",
|
109
114
|
"@types/debug": "^4.1.7",
|
110
115
|
"@types/mocha": "^9.1.0",
|
111
|
-
"@types/node": "^
|
116
|
+
"@types/node": "^18.11.17",
|
112
117
|
"@types/tail": "^2.0.0",
|
113
118
|
"@types/uuid": "^8.3.0",
|
114
119
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
115
120
|
"@typescript-eslint/parser": "^5.8.1",
|
116
121
|
"app-root-path": "^3.0.0",
|
117
|
-
"chai": "^4.3.4",
|
118
122
|
"cspell": "^6.17.0",
|
119
123
|
"eslint": "^8.6.0",
|
120
124
|
"eslint-config-prettier": "^8.3.0",
|
@@ -122,7 +126,6 @@
|
|
122
126
|
"eslint-plugin-functional": "^4.0.2",
|
123
127
|
"eslint-plugin-import": "^2.25.3",
|
124
128
|
"eslint-plugin-prettier": "^4.0.0",
|
125
|
-
"fast-check": "^2.14.0",
|
126
129
|
"gh-pages": "^3.2.3",
|
127
130
|
"ignore-loader": "^0.1.2",
|
128
131
|
"isomorphic-fetch": "^3.0.0",
|
package/src/index.ts
CHANGED
@@ -6,22 +6,19 @@ export {
|
|
6
6
|
createDecoder,
|
7
7
|
DecodedMessage,
|
8
8
|
} from "./lib/message/version_0.js";
|
9
|
+
export * as message from "./lib/message/index.js";
|
9
10
|
|
10
11
|
export * as waku from "./lib/waku.js";
|
11
|
-
export { WakuNode } from "./lib/waku.js";
|
12
|
+
export { WakuNode, WakuOptions } from "./lib/waku.js";
|
12
13
|
|
13
14
|
export * as waku_filter from "./lib/filter/index.js";
|
14
15
|
export { wakuFilter } from "./lib/filter/index.js";
|
15
16
|
|
16
17
|
export * as waku_light_push from "./lib/light_push/index.js";
|
17
|
-
export {
|
18
|
-
wakuLightPush,
|
19
|
-
LightPushCodec,
|
20
|
-
PushResponse,
|
21
|
-
} from "./lib/light_push/index.js";
|
18
|
+
export { wakuLightPush, LightPushCodec } from "./lib/light_push/index.js";
|
22
19
|
|
23
20
|
export * as waku_relay from "./lib/relay/index.js";
|
24
|
-
export { wakuRelay } from "./lib/relay/index.js";
|
21
|
+
export { wakuRelay, RelayCreateOptions } from "./lib/relay/index.js";
|
25
22
|
|
26
23
|
export * as waku_store from "./lib/store/index.js";
|
27
24
|
export {
|
@@ -3,7 +3,7 @@ import type {
|
|
3
3
|
IDecoder,
|
4
4
|
IProtoMessage,
|
5
5
|
} from "@waku/interfaces";
|
6
|
-
import {
|
6
|
+
import { TopicOnlyMessage as ProtoTopicOnlyMessage } from "@waku/proto";
|
7
7
|
import debug from "debug";
|
8
8
|
|
9
9
|
const log = debug("waku:message:topic-only");
|
@@ -14,7 +14,7 @@ export class TopicOnlyMessage implements IDecodedMessage {
|
|
14
14
|
public timestamp: undefined;
|
15
15
|
public ephemeral: undefined;
|
16
16
|
|
17
|
-
constructor(private proto:
|
17
|
+
constructor(private proto: ProtoTopicOnlyMessage) {}
|
18
18
|
|
19
19
|
get contentTopic(): string {
|
20
20
|
return this.proto.contentTopic ?? "";
|
@@ -25,7 +25,7 @@ export class TopicOnlyDecoder implements IDecoder<TopicOnlyMessage> {
|
|
25
25
|
public contentTopic = "";
|
26
26
|
|
27
27
|
fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined> {
|
28
|
-
const protoMessage =
|
28
|
+
const protoMessage = ProtoTopicOnlyMessage.decode(bytes);
|
29
29
|
log("Message decoded", protoMessage);
|
30
30
|
return Promise.resolve({
|
31
31
|
contentTopic: protoMessage.contentTopic,
|
@@ -4,10 +4,7 @@ export const minute = 60 * second;
|
|
4
4
|
/**
|
5
5
|
* RelayCodec is the libp2p identifier for the waku relay protocol
|
6
6
|
*/
|
7
|
-
export const RelayCodecs = [
|
8
|
-
"/vac/waku/relay/2.0.0-beta2",
|
9
|
-
"/vac/waku/relay/2.0.0",
|
10
|
-
];
|
7
|
+
export const RelayCodecs = ["/vac/waku/relay/2.0.0"];
|
11
8
|
|
12
9
|
export const RelayPingContentTopic = "/relay-ping/1/ping/null";
|
13
10
|
|
package/src/lib/relay/index.ts
CHANGED
@@ -30,7 +30,7 @@ export type Observer<T extends IDecodedMessage> = {
|
|
30
30
|
callback: Callback<T>;
|
31
31
|
};
|
32
32
|
|
33
|
-
export
|
33
|
+
export interface RelayCreateOptions extends GossipsubOpts {
|
34
34
|
/**
|
35
35
|
* The PubSub Topic to use. Defaults to {@link DefaultPubSubTopic}.
|
36
36
|
*
|
@@ -45,7 +45,7 @@ export type CreateOptions = {
|
|
45
45
|
* @default {@link DefaultPubSubTopic}
|
46
46
|
*/
|
47
47
|
pubSubTopic?: string;
|
48
|
-
}
|
48
|
+
}
|
49
49
|
|
50
50
|
/**
|
51
51
|
* Implements the [Waku v2 Relay protocol](https://rfc.vac.dev/spec/11/).
|
@@ -66,7 +66,7 @@ class Relay extends GossipSub implements IRelay {
|
|
66
66
|
|
67
67
|
constructor(
|
68
68
|
components: GossipSubComponents,
|
69
|
-
options?: Partial<
|
69
|
+
options?: Partial<RelayCreateOptions>
|
70
70
|
) {
|
71
71
|
options = Object.assign(options ?? {}, {
|
72
72
|
// Ensure that no signature is included nor expected in the messages.
|
@@ -188,7 +188,7 @@ class Relay extends GossipSub implements IRelay {
|
|
188
188
|
Relay.multicodec = constants.RelayCodecs[constants.RelayCodecs.length - 1];
|
189
189
|
|
190
190
|
export function wakuRelay(
|
191
|
-
init: Partial<
|
191
|
+
init: Partial<RelayCreateOptions> = {}
|
192
192
|
): (components: GossipSubComponents) => IRelay {
|
193
193
|
return (components: GossipSubComponents) => new Relay(components, init);
|
194
194
|
}
|
@@ -14,8 +14,8 @@ const log = debug("waku:wait-for-remote-peer");
|
|
14
14
|
/**
|
15
15
|
* Wait for a remote peer to be ready given the passed protocols.
|
16
16
|
* Must be used after attempting to connect to nodes, using
|
17
|
-
* {@link
|
18
|
-
* {@link
|
17
|
+
* {@link @waku/core.WakuNode.dial} or a bootstrap method with
|
18
|
+
* {@link @waku/create.createLightNode}.
|
19
19
|
*
|
20
20
|
* If the passed protocols is a GossipSub protocol, then it resolves only once
|
21
21
|
* a peer is in a mesh, to help ensure that other peers will send and receive
|
@@ -155,9 +155,6 @@ function getEnabledProtocols(waku: Waku): Protocols[] {
|
|
155
155
|
if (waku.lightPush) {
|
156
156
|
protocols.push(Protocols.LightPush);
|
157
157
|
}
|
158
|
-
if (waku.peerExchange) {
|
159
|
-
protocols.push(Protocols.PeerExchange);
|
160
|
-
}
|
161
158
|
|
162
159
|
return protocols;
|
163
160
|
}
|