@waku/core 0.0.22 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/bundle/base_protocol-2a0c882e.js +1250 -0
  3. package/bundle/{browser-bde977a3.js → browser-90197c87.js} +26 -1
  4. package/bundle/index.js +20048 -3236
  5. package/bundle/lib/base_protocol.js +2 -116
  6. package/bundle/lib/message/version_0.js +2 -2
  7. package/bundle/lib/predefined_bootstrap_nodes.js +6 -6
  8. package/bundle/{version_0-86411fdf.js → version_0-f4afd324.js} +907 -814
  9. package/dist/.tsbuildinfo +1 -0
  10. package/dist/index.d.ts +5 -4
  11. package/dist/index.js +4 -3
  12. package/dist/index.js.map +1 -1
  13. package/dist/lib/base_protocol.d.ts +18 -5
  14. package/dist/lib/base_protocol.js +25 -8
  15. package/dist/lib/base_protocol.js.map +1 -1
  16. package/dist/lib/connection_manager.d.ts +15 -3
  17. package/dist/lib/connection_manager.js +92 -34
  18. package/dist/lib/connection_manager.js.map +1 -1
  19. package/dist/lib/filter/filter_rpc.js +4 -4
  20. package/dist/lib/filter/index.d.ts +4 -0
  21. package/dist/lib/filter/index.js +38 -29
  22. package/dist/lib/filter/index.js.map +1 -1
  23. package/dist/lib/filterPeers.d.ts +10 -0
  24. package/dist/lib/filterPeers.js +31 -0
  25. package/dist/lib/filterPeers.js.map +1 -0
  26. package/dist/lib/keep_alive_manager.d.ts +4 -2
  27. package/dist/lib/keep_alive_manager.js +62 -19
  28. package/dist/lib/keep_alive_manager.js.map +1 -1
  29. package/dist/lib/light_push/index.js +85 -38
  30. package/dist/lib/light_push/index.js.map +1 -1
  31. package/dist/lib/light_push/push_rpc.d.ts +1 -1
  32. package/dist/lib/light_push/push_rpc.js +3 -3
  33. package/dist/lib/message/version_0.d.ts +13 -13
  34. package/dist/lib/message/version_0.js +21 -18
  35. package/dist/lib/message/version_0.js.map +1 -1
  36. package/dist/lib/predefined_bootstrap_nodes.js +6 -6
  37. package/dist/lib/store/history_rpc.d.ts +1 -1
  38. package/dist/lib/store/history_rpc.js +4 -4
  39. package/dist/lib/store/index.d.ts +1 -6
  40. package/dist/lib/store/index.js +91 -47
  41. package/dist/lib/store/index.js.map +1 -1
  42. package/dist/lib/stream_manager.d.ts +15 -0
  43. package/dist/lib/stream_manager.js +56 -0
  44. package/dist/lib/stream_manager.js.map +1 -0
  45. package/dist/lib/to_proto_message.js +1 -1
  46. package/dist/lib/wait_for_remote_peer.d.ts +2 -2
  47. package/dist/lib/wait_for_remote_peer.js +10 -7
  48. package/dist/lib/wait_for_remote_peer.js.map +1 -1
  49. package/dist/lib/waku.d.ts +6 -5
  50. package/dist/lib/waku.js +6 -4
  51. package/dist/lib/waku.js.map +1 -1
  52. package/package.json +17 -33
  53. package/src/index.ts +6 -9
  54. package/src/lib/base_protocol.ts +49 -18
  55. package/src/lib/connection_manager.ts +132 -41
  56. package/src/lib/filter/filter_rpc.ts +4 -4
  57. package/src/lib/filter/index.ts +53 -41
  58. package/src/lib/filterPeers.ts +43 -0
  59. package/src/lib/keep_alive_manager.ts +79 -22
  60. package/src/lib/light_push/index.ts +132 -51
  61. package/src/lib/light_push/push_rpc.ts +3 -3
  62. package/src/lib/message/version_0.ts +27 -15
  63. package/src/lib/predefined_bootstrap_nodes.ts +7 -7
  64. package/src/lib/store/history_rpc.ts +6 -6
  65. package/src/lib/store/index.ts +121 -63
  66. package/src/lib/stream_manager.ts +72 -0
  67. package/src/lib/to_proto_message.ts +1 -1
  68. package/src/lib/wait_for_remote_peer.ts +11 -8
  69. package/src/lib/waku.ts +7 -4
  70. package/dist/lib/push_or_init_map.d.ts +0 -1
  71. package/dist/lib/push_or_init_map.js +0 -9
  72. package/dist/lib/push_or_init_map.js.map +0 -1
  73. package/src/lib/push_or_init_map.ts +0 -13
@@ -1,6 +1,6 @@
1
- import { SendError, } from "@waku/interfaces";
1
+ import { SendError } from "@waku/interfaces";
2
2
  import { PushResponse } from "@waku/proto";
3
- import { isSizeValid } from "@waku/utils";
3
+ import { ensurePubsubTopicIsConfigured, isSizeValid } from "@waku/utils";
4
4
  import debug from "debug";
5
5
  import all from "it-all";
6
6
  import * as lp from "it-length-prefixed";
@@ -16,61 +16,108 @@ export { PushResponse };
16
16
  * Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
17
17
  */
18
18
  class LightPush extends BaseProtocol {
19
- options;
19
+ pubsubTopics;
20
+ NUM_PEERS_PROTOCOL = 1;
20
21
  constructor(libp2p, options) {
21
22
  super(LightPushCodec, libp2p.components);
22
- this.options = options || {};
23
+ this.pubsubTopics = options?.pubsubTopics ?? [DefaultPubSubTopic];
23
24
  }
24
- async send(encoder, message, opts) {
25
- const { pubSubTopic = DefaultPubSubTopic } = this.options;
26
- const peer = await this.getPeer(opts?.peerId);
27
- const stream = await this.newStream(peer);
28
- const recipients = [];
29
- let error = undefined;
25
+ async preparePushMessage(encoder, message, pubsubTopic) {
30
26
  try {
31
27
  if (!isSizeValid(message.payload)) {
32
- log("Failed to send waku light push: message is bigger that 1MB");
33
- return {
34
- recipients,
35
- error: SendError.SIZE_TOO_BIG,
36
- };
28
+ log("Failed to send waku light push: message is bigger than 1MB");
29
+ return { query: null, error: SendError.SIZE_TOO_BIG };
37
30
  }
38
31
  const protoMessage = await encoder.toProtoObj(message);
39
32
  if (!protoMessage) {
40
33
  log("Failed to encode to protoMessage, aborting push");
41
34
  return {
42
- recipients,
43
- error: SendError.ENCODE_FAILED,
35
+ query: null,
36
+ error: SendError.ENCODE_FAILED
44
37
  };
45
38
  }
46
- const query = PushRpc.createRequest(protoMessage, pubSubTopic);
47
- const res = await pipe([query.encode()], lp.encode, stream, lp.decode, async (source) => await all(source));
39
+ const query = PushRpc.createRequest(protoMessage, pubsubTopic);
40
+ return { query, error: null };
41
+ }
42
+ catch (error) {
43
+ log("Failed to prepare push message", error);
44
+ return {
45
+ query: null,
46
+ error: SendError.GENERIC_FAIL
47
+ };
48
+ }
49
+ }
50
+ async send(encoder, message) {
51
+ const { pubsubTopic } = encoder;
52
+ ensurePubsubTopicIsConfigured(pubsubTopic, this.pubsubTopics);
53
+ const recipients = [];
54
+ const { query, error: preparationError } = await this.preparePushMessage(encoder, message, pubsubTopic);
55
+ if (preparationError || !query) {
56
+ return {
57
+ recipients,
58
+ errors: [preparationError]
59
+ };
60
+ }
61
+ //TODO: get a relevant peer for the topic/shard
62
+ const peers = await this.getPeers({
63
+ maxBootstrapPeers: 1,
64
+ numPeers: this.NUM_PEERS_PROTOCOL
65
+ });
66
+ if (!peers.length) {
67
+ return {
68
+ recipients,
69
+ errors: [SendError.NO_PEER_AVAILABLE]
70
+ };
71
+ }
72
+ const promises = peers.map(async (peer) => {
73
+ let stream;
48
74
  try {
49
- const bytes = new Uint8ArrayList();
50
- res.forEach((chunk) => {
51
- bytes.append(chunk);
52
- });
53
- const response = PushRpc.decode(bytes).response;
54
- if (response?.isSuccess) {
55
- recipients.push(peer.id);
56
- }
57
- else {
58
- log("No response in PushRPC");
59
- error = SendError.NO_RPC_RESPONSE;
60
- }
75
+ stream = await this.getStream(peer);
76
+ }
77
+ catch (err) {
78
+ log(`Failed to get a stream for remote peer${peer.id.toString()}`, err);
79
+ return { recipients, error: SendError.REMOTE_PEER_FAULT };
80
+ }
81
+ let res;
82
+ try {
83
+ res = await pipe([query.encode()], lp.encode, stream, lp.decode, async (source) => await all(source));
84
+ }
85
+ catch (err) {
86
+ log("Failed to send waku light push request", err);
87
+ return { recipients, error: SendError.GENERIC_FAIL };
88
+ }
89
+ const bytes = new Uint8ArrayList();
90
+ res.forEach((chunk) => {
91
+ bytes.append(chunk);
92
+ });
93
+ let response;
94
+ try {
95
+ response = PushRpc.decode(bytes).response;
61
96
  }
62
97
  catch (err) {
63
98
  log("Failed to decode push reply", err);
64
- error = SendError.DECODE_FAILED;
99
+ return { recipients, error: SendError.DECODE_FAILED };
65
100
  }
66
- }
67
- catch (err) {
68
- log("Failed to send waku light push request", err);
69
- error = SendError.GENERIC_FAIL;
70
- }
101
+ if (!response) {
102
+ log("Remote peer fault: No response in PushRPC");
103
+ return { recipients, error: SendError.REMOTE_PEER_FAULT };
104
+ }
105
+ if (!response.isSuccess) {
106
+ log("Remote peer rejected the message: ", response.info);
107
+ return { recipients, error: SendError.REMOTE_PEER_REJECTED };
108
+ }
109
+ recipients.some((recipient) => recipient.equals(peer.id)) ||
110
+ recipients.push(peer.id);
111
+ return { recipients };
112
+ });
113
+ const results = await Promise.allSettled(promises);
114
+ const errors = results
115
+ .filter((result) => result.status === "fulfilled")
116
+ .map((result) => result.value.error)
117
+ .filter((error) => error !== undefined);
71
118
  return {
72
- error,
73
119
  recipients,
120
+ errors
74
121
  };
75
122
  }
76
123
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/light_push/index.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,SAAS,GAEV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,QAAQ,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,GAAG,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAErC,MAAM,CAAC,MAAM,cAAc,GAAG,iCAAiC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB;;GAEG;AACH,M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AAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,iBAAiB,EAAE,CAAC;aAC3D;YAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE;gBACvB,GAAG,CAAC,oCAAoC,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACzD,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,CAAC,oBAAoB,EAAE,CAAC;aAC9D;YAED,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACvD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAE3B,OAAO,EAAE,UAAU,EAAE,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACnD,MAAM,MAAM,GAAG,OAAO;aACnB,MAAM,CACL,CACE,MAAM,EAIL,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,WAAW,CACpC;aACA,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;aACnC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAgB,CAAC;QAEzD,OAAO;YACL,UAAU;YACV,MAAM;SACP,CAAC;IACJ,CAAC;CACF;AAED,MAAM,UAAU,aAAa,CAC3B,OAAuC,EAAE;IAEzC,OAAO,CAAC,MAAc,EAAE,EAAE,CAAC,IAAI,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AACzD,CAAC"}
@@ -3,7 +3,7 @@ import type { Uint8ArrayList } from "uint8arraylist";
3
3
  export declare class PushRpc {
4
4
  proto: proto.PushRpc;
5
5
  constructor(proto: proto.PushRpc);
6
- static createRequest(message: proto.WakuMessage, pubSubTopic: string): PushRpc;
6
+ static createRequest(message: proto.WakuMessage, pubsubTopic: string): PushRpc;
7
7
  static decode(bytes: Uint8ArrayList): PushRpc;
8
8
  encode(): Uint8Array;
9
9
  get query(): proto.PushRequest | undefined;
@@ -5,14 +5,14 @@ export class PushRpc {
5
5
  constructor(proto) {
6
6
  this.proto = proto;
7
7
  }
8
- static createRequest(message, pubSubTopic) {
8
+ static createRequest(message, pubsubTopic) {
9
9
  return new PushRpc({
10
10
  requestId: uuid(),
11
11
  request: {
12
12
  message: message,
13
- pubsubTopic: pubSubTopic,
13
+ pubsubTopic: pubsubTopic
14
14
  },
15
- response: undefined,
15
+ response: undefined
16
16
  });
17
17
  }
18
18
  static decode(bytes) {
@@ -1,11 +1,11 @@
1
- import type { EncoderOptions, IDecodedMessage, IDecoder, IEncoder, IMessage, IMetaSetter, IProtoMessage, IRateLimitProof } from "@waku/interfaces";
1
+ import type { EncoderOptions, IDecodedMessage, IDecoder, IEncoder, IMessage, IMetaSetter, IProtoMessage, IRateLimitProof, PubSubTopic } from "@waku/interfaces";
2
2
  import { proto_message as proto } from "@waku/proto";
3
3
  export declare const Version = 0;
4
4
  export { proto };
5
5
  export declare class DecodedMessage implements IDecodedMessage {
6
- pubSubTopic: string;
6
+ pubsubTopic: string;
7
7
  protected proto: proto.WakuMessage;
8
- constructor(pubSubTopic: string, proto: proto.WakuMessage);
8
+ constructor(pubsubTopic: string, proto: proto.WakuMessage);
9
9
  get ephemeral(): boolean;
10
10
  get payload(): Uint8Array;
11
11
  get contentTopic(): string;
@@ -18,36 +18,36 @@ export declare class DecodedMessage implements IDecodedMessage {
18
18
  export declare class Encoder implements IEncoder {
19
19
  contentTopic: string;
20
20
  ephemeral: boolean;
21
+ pubsubTopic: PubSubTopic;
21
22
  metaSetter?: IMetaSetter | undefined;
22
- constructor(contentTopic: string, ephemeral?: boolean, metaSetter?: IMetaSetter | undefined);
23
+ constructor(contentTopic: string, ephemeral: boolean, pubsubTopic: PubSubTopic, metaSetter?: IMetaSetter | undefined);
23
24
  toWire(message: IMessage): Promise<Uint8Array>;
24
25
  toProtoObj(message: IMessage): Promise<IProtoMessage>;
25
26
  }
26
27
  /**
27
28
  * Creates an encoder that encode messages without Waku level encryption or signature.
28
29
  *
29
- * An encoder is used to encode messages in the [`14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
30
+ * An encoder is used to encode messages in the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
30
31
  * format to be sent over the Waku network. The resulting encoder can then be
31
- * pass to { @link @waku/interfaces.LightPush.push } or
32
- * { @link @waku/interfaces.Relay.send } to automatically encode outgoing
32
+ * pass to { @link @waku/interfaces!ISender.send } to automatically encode outgoing
33
33
  * messages.
34
34
  */
35
- export declare function createEncoder({ contentTopic, ephemeral, metaSetter, }: EncoderOptions): Encoder;
35
+ export declare function createEncoder({ pubsubTopic, contentTopic, ephemeral, metaSetter }: EncoderOptions): Encoder;
36
36
  export declare class Decoder implements IDecoder<DecodedMessage> {
37
+ pubsubTopic: PubSubTopic;
37
38
  contentTopic: string;
38
- constructor(contentTopic: string);
39
+ constructor(pubsubTopic: PubSubTopic, contentTopic: string);
39
40
  fromWireToProtoObj(bytes: Uint8Array): Promise<IProtoMessage | undefined>;
40
- fromProtoObj(pubSubTopic: string, proto: IProtoMessage): Promise<DecodedMessage | undefined>;
41
+ fromProtoObj(pubsubTopic: string, proto: IProtoMessage): Promise<DecodedMessage | undefined>;
41
42
  }
42
43
  /**
43
44
  * Creates a decoder that decode messages without Waku level encryption.
44
45
  *
45
46
  * A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
46
47
  * format when received from the Waku network. The resulting decoder can then be
47
- * pass to { @link @waku/interfaces.Filter.subscribe } or
48
- * { @link @waku/interfaces.Relay.subscribe } to automatically decode incoming
48
+ * pass to { @link @waku/interfaces!IReceiver.subscribe } to automatically decode incoming
49
49
  * messages.
50
50
  *
51
51
  * @param contentTopic The resulting decoder will only decode messages with this content topic.
52
52
  */
53
- export declare function createDecoder(contentTopic: string): Decoder;
53
+ export declare function createDecoder(contentTopic: string, pubsubTopic?: PubSubTopic): Decoder;
@@ -1,14 +1,15 @@
1
1
  import { proto_message as proto } from "@waku/proto";
2
2
  import debug from "debug";
3
+ import { DefaultPubSubTopic } from "../constants.js";
3
4
  const log = debug("waku:message:version-0");
4
5
  const OneMillion = BigInt(1000000);
5
6
  export const Version = 0;
6
7
  export { proto };
7
8
  export class DecodedMessage {
8
- pubSubTopic;
9
+ pubsubTopic;
9
10
  proto;
10
- constructor(pubSubTopic, proto) {
11
- this.pubSubTopic = pubSubTopic;
11
+ constructor(pubsubTopic, proto) {
12
+ this.pubsubTopic = pubsubTopic;
12
13
  this.proto = proto;
13
14
  }
14
15
  get ephemeral() {
@@ -53,10 +54,12 @@ export class DecodedMessage {
53
54
  export class Encoder {
54
55
  contentTopic;
55
56
  ephemeral;
57
+ pubsubTopic;
56
58
  metaSetter;
57
- constructor(contentTopic, ephemeral = false, metaSetter) {
59
+ constructor(contentTopic, ephemeral = false, pubsubTopic, metaSetter) {
58
60
  this.contentTopic = contentTopic;
59
61
  this.ephemeral = ephemeral;
62
+ this.pubsubTopic = pubsubTopic;
60
63
  this.metaSetter = metaSetter;
61
64
  if (!contentTopic || contentTopic === "") {
62
65
  throw new Error("Content topic must be specified");
@@ -74,7 +77,7 @@ export class Encoder {
74
77
  timestamp: BigInt(timestamp.valueOf()) * OneMillion,
75
78
  meta: undefined,
76
79
  rateLimitProof: message.rateLimitProof,
77
- ephemeral: this.ephemeral,
80
+ ephemeral: this.ephemeral
78
81
  };
79
82
  if (this.metaSetter) {
80
83
  const meta = this.metaSetter(protoMessage);
@@ -86,18 +89,19 @@ export class Encoder {
86
89
  /**
87
90
  * Creates an encoder that encode messages without Waku level encryption or signature.
88
91
  *
89
- * An encoder is used to encode messages in the [`14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
92
+ * An encoder is used to encode messages in the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
90
93
  * format to be sent over the Waku network. The resulting encoder can then be
91
- * pass to { @link @waku/interfaces.LightPush.push } or
92
- * { @link @waku/interfaces.Relay.send } to automatically encode outgoing
94
+ * pass to { @link @waku/interfaces!ISender.send } to automatically encode outgoing
93
95
  * messages.
94
96
  */
95
- export function createEncoder({ contentTopic, ephemeral, metaSetter, }) {
96
- return new Encoder(contentTopic, ephemeral, metaSetter);
97
+ export function createEncoder({ pubsubTopic = DefaultPubSubTopic, contentTopic, ephemeral, metaSetter }) {
98
+ return new Encoder(contentTopic, ephemeral, pubsubTopic, metaSetter);
97
99
  }
98
100
  export class Decoder {
101
+ pubsubTopic;
99
102
  contentTopic;
100
- constructor(contentTopic) {
103
+ constructor(pubsubTopic, contentTopic) {
104
+ this.pubsubTopic = pubsubTopic;
101
105
  this.contentTopic = contentTopic;
102
106
  if (!contentTopic || contentTopic === "") {
103
107
  throw new Error("Content topic must be specified");
@@ -113,17 +117,17 @@ export class Decoder {
113
117
  timestamp: protoMessage.timestamp ?? undefined,
114
118
  meta: protoMessage.meta ?? undefined,
115
119
  rateLimitProof: protoMessage.rateLimitProof ?? undefined,
116
- ephemeral: protoMessage.ephemeral ?? false,
120
+ ephemeral: protoMessage.ephemeral ?? false
117
121
  });
118
122
  }
119
- async fromProtoObj(pubSubTopic, proto) {
123
+ async fromProtoObj(pubsubTopic, proto) {
120
124
  // https://rfc.vac.dev/spec/14/
121
125
  // > If omitted, the value SHOULD be interpreted as version 0.
122
126
  if (proto.version ?? 0 !== Version) {
123
127
  log("Failed to decode due to incorrect version, expected:", Version, ", actual:", proto.version);
124
128
  return Promise.resolve(undefined);
125
129
  }
126
- return new DecodedMessage(pubSubTopic, proto);
130
+ return new DecodedMessage(pubsubTopic, proto);
127
131
  }
128
132
  }
129
133
  /**
@@ -131,13 +135,12 @@ export class Decoder {
131
135
  *
132
136
  * A decoder is used to decode messages from the [14/WAKU2-MESSAGE](https://rfc.vac.dev/spec/14/)
133
137
  * format when received from the Waku network. The resulting decoder can then be
134
- * pass to { @link @waku/interfaces.Filter.subscribe } or
135
- * { @link @waku/interfaces.Relay.subscribe } to automatically decode incoming
138
+ * pass to { @link @waku/interfaces!IReceiver.subscribe } to automatically decode incoming
136
139
  * messages.
137
140
  *
138
141
  * @param contentTopic The resulting decoder will only decode messages with this content topic.
139
142
  */
140
- export function createDecoder(contentTopic) {
141
- return new Decoder(contentTopic);
143
+ export function createDecoder(contentTopic, pubsubTopic = DefaultPubSubTopic) {
144
+ return new Decoder(pubsubTopic, contentTopic);
142
145
  }
143
146
  //# sourceMappingURL=version_0.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version_0.js","sourceRoot":"","sources":["../../../src/lib/message/version_0.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,GAAG,GAAG,KAAK,CAAC,wBAAwB,CAAC,CAAC;AAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,OAAS,CAAC,CAAC;AAErC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AACzB,OAAO,EAAE,KAAK,EAAE,CAAC;AAEjB,MAAM,OAAO,cAAc;IACN;IAA+B;IAAlD,YAAmB,WAAmB,EAAY,KAAwB;QAAvD,gBAAW,GAAX,WAAW,CAAQ;QAAY,UAAK,GAAL,KAAK,CAAmB;IAAG,CAAC;IAE9E,IAAI,SAAS;QACX,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;IAC5B,CAAC;IAED,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;IACjC,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;IAC9B,CAAC;IAED,IAAI,SAAS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QpSN5Qa992BCjjwgrD",
41
41
  "node-01.do-ams3.wakuv2.prod": "/dns4/node-01.do-ams3.wakuv2.prod.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmL5okWopX7NqZWBUKVqW8iUxCEmd5GMHLVPwCgzYzQv3e",
42
- "node-01.gc-us-central1-a.wakuv2.prod": "/dns4/node-01.gc-us-central1-a.wakuv2.prod.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA",
43
- },
42
+ "node-01.gc-us-central1-a.wakuv2.prod": "/dns4/node-01.gc-us-central1-a.wakuv2.prod.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmVkKntsECaYfefR1V2yCR79CegLATuTPE6B9TxgxBiiiA"
43
+ }
44
44
  },
45
45
  "wakuv2.test": {
46
46
  "waku-websocket": {
47
47
  "node-01.ac-cn-hongkong-c.wakuv2.test": "/dns4/node-01.ac-cn-hongkong-c.wakuv2.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAkvWiyFsgRhuJEb9JfjYxEkoHLgnUQmr1N5mKWnYjxYRVm",
48
48
  "node-01.do-ams3.wakuv2.test": "/dns4/node-01.do-ams3.wakuv2.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmPLe7Mzm8TsYUubgCAW1aJoeFScxrLj8ppHFivPo97bUZ",
49
- "node-01.gc-us-central1-a.wakuv2.test": "/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS",
50
- },
51
- },
52
- },
49
+ "node-01.gc-us-central1-a.wakuv2.test": "/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/8000/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS"
50
+ }
51
+ }
52
+ }
53
53
  };
54
54
  //# sourceMappingURL=predefined_bootstrap_nodes.js.map
@@ -6,7 +6,7 @@ export declare enum PageDirection {
6
6
  }
7
7
  export interface Params {
8
8
  contentTopics: string[];
9
- pubSubTopic: string;
9
+ pubsubTopic: string;
10
10
  pageDirection: PageDirection;
11
11
  pageSize: number;
12
12
  startTime?: Date;
@@ -28,7 +28,7 @@ export class HistoryRpc {
28
28
  const pagingInfo = {
29
29
  pageSize: BigInt(params.pageSize),
30
30
  cursor: params.cursor,
31
- direction,
31
+ direction
32
32
  };
33
33
  let startTime, endTime;
34
34
  if (params.startTime) {
@@ -42,13 +42,13 @@ export class HistoryRpc {
42
42
  return new HistoryRpc({
43
43
  requestId: uuid(),
44
44
  query: {
45
- pubsubTopic: params.pubSubTopic,
45
+ pubsubTopic: params.pubsubTopic,
46
46
  contentFilters,
47
47
  pagingInfo,
48
48
  startTime,
49
- endTime,
49
+ endTime
50
50
  },
51
- response: undefined,
51
+ response: undefined
52
52
  });
53
53
  }
54
54
  decode(bytes) {
@@ -1,4 +1,3 @@
1
- import type { PeerId } from "@libp2p/interface-peer-id";
2
1
  import { Cursor, IDecodedMessage, IStore, Libp2p, ProtocolCreateOptions } from "@waku/interfaces";
3
2
  import { PageDirection } from "./history_rpc.js";
4
3
  export declare const StoreCodec = "/vac/waku/store/2.0.0-beta4";
@@ -9,10 +8,6 @@ export interface TimeFilter {
9
8
  endTime: Date;
10
9
  }
11
10
  export interface QueryOptions {
12
- /**
13
- * The peer to query. If undefined, a pseudo-random peer is selected from the connected Waku Store peers.
14
- */
15
- peerId?: PeerId;
16
11
  /**
17
12
  * The direction in which pages are retrieved:
18
13
  * - { @link PageDirection.BACKWARD }: Most recent page first.
@@ -41,5 +36,5 @@ export interface QueryOptions {
41
36
  */
42
37
  cursor?: Cursor;
43
38
  }
44
- export declare function createCursor(message: IDecodedMessage, pubsubTopic?: string): Promise<Cursor>;
39
+ export declare function createCursor(message: IDecodedMessage): Promise<Cursor>;
45
40
  export declare function wakuStore(init?: Partial<ProtocolCreateOptions>): (libp2p: Libp2p) => IStore;