@waku/core 0.0.8 → 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 +14 -1
- package/bundle/index.js +97 -95
- package/bundle/lib/message/topic_only_message.js +2 -33
- package/bundle/lib/message/version_0.js +2 -133
- package/bundle/{peer_exchange-df95c3a7.js → peer_exchange-53df2b11.js} +276 -253
- package/bundle/topic_only_message-ece0fef9.js +39 -0
- package/bundle/version_0-b1fc527d.js +143 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- 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 +4 -4
- package/src/index.ts +3 -2
- 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
@@ -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
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,6 +1,7 @@
|
|
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";
|
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,C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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,CAAC,kDAAkD,CAAC,CAAC;QACtE,QAAQ,CAAC,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KACvD;IAED,IAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QACvC,IAAI,CAAC,IAAI,CAAC,KAAK;YACb,MAAM,IAAI,KAAK,CAAC,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AS,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",
|
@@ -98,6 +98,8 @@
|
|
98
98
|
"it-length-prefixed": "^8.0.2",
|
99
99
|
"it-pipe": "^2.0.4",
|
100
100
|
"libp2p": "0.40.0",
|
101
|
+
"chai": "^4.3.4",
|
102
|
+
"fast-check": "^2.14.0",
|
101
103
|
"p-event": "^5.0.1",
|
102
104
|
"uint8arraylist": "^2.3.2",
|
103
105
|
"uint8arrays": "^4.0.2",
|
@@ -111,13 +113,12 @@
|
|
111
113
|
"@types/chai": "^4.2.15",
|
112
114
|
"@types/debug": "^4.1.7",
|
113
115
|
"@types/mocha": "^9.1.0",
|
114
|
-
"@types/node": "^
|
116
|
+
"@types/node": "^18.11.17",
|
115
117
|
"@types/tail": "^2.0.0",
|
116
118
|
"@types/uuid": "^8.3.0",
|
117
119
|
"@typescript-eslint/eslint-plugin": "^5.8.1",
|
118
120
|
"@typescript-eslint/parser": "^5.8.1",
|
119
121
|
"app-root-path": "^3.0.0",
|
120
|
-
"chai": "^4.3.4",
|
121
122
|
"cspell": "^6.17.0",
|
122
123
|
"eslint": "^8.6.0",
|
123
124
|
"eslint-config-prettier": "^8.3.0",
|
@@ -125,7 +126,6 @@
|
|
125
126
|
"eslint-plugin-functional": "^4.0.2",
|
126
127
|
"eslint-plugin-import": "^2.25.3",
|
127
128
|
"eslint-plugin-prettier": "^4.0.0",
|
128
|
-
"fast-check": "^2.14.0",
|
129
129
|
"gh-pages": "^3.2.3",
|
130
130
|
"ignore-loader": "^0.1.2",
|
131
131
|
"isomorphic-fetch": "^3.0.0",
|
package/src/index.ts
CHANGED
@@ -6,9 +6,10 @@ 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";
|
@@ -17,7 +18,7 @@ export * as waku_light_push from "./lib/light_push/index.js";
|
|
17
18
|
export { wakuLightPush, LightPushCodec } from "./lib/light_push/index.js";
|
18
19
|
|
19
20
|
export * as waku_relay from "./lib/relay/index.js";
|
20
|
-
export { wakuRelay } from "./lib/relay/index.js";
|
21
|
+
export { wakuRelay, RelayCreateOptions } from "./lib/relay/index.js";
|
21
22
|
|
22
23
|
export * as waku_store from "./lib/store/index.js";
|
23
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
|
}
|