@waku/core 0.0.1

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 (235) hide show
  1. package/CHANGELOG.md +614 -0
  2. package/README.md +56 -0
  3. package/bundle/browser-1e1a2f27.js +722 -0
  4. package/bundle/crypto-8551d579.js +2585 -0
  5. package/bundle/crypto-b00764b7.js +1772 -0
  6. package/bundle/enr-564d4a51.js +20785 -0
  7. package/bundle/enr-9fc5eed8.js +20786 -0
  8. package/bundle/enr-f6e82a53.js +20785 -0
  9. package/bundle/events-158407bb.js +1929 -0
  10. package/bundle/events-fcbda4dc.js +76 -0
  11. package/bundle/index-02d21809.js +20 -0
  12. package/bundle/index-0a4bdddc.js +2976 -0
  13. package/bundle/index-2ae915be.js +1854 -0
  14. package/bundle/index-64ce43f0.js +69 -0
  15. package/bundle/index-691c0be6.js +4059 -0
  16. package/bundle/index-a013a259.js +20 -0
  17. package/bundle/index-ba42b4fc.js +862 -0
  18. package/bundle/index.js +13428 -0
  19. package/bundle/lib/enr.js +8 -0
  20. package/bundle/lib/peer_discovery_dns.js +5018 -0
  21. package/bundle/lib/peer_discovery_static_list.js +75 -0
  22. package/bundle/lib/predefined_bootstrap_nodes.js +59 -0
  23. package/bundle/lib/utils.js +1 -0
  24. package/bundle/lib/wait_for_remote_peer.js +327 -0
  25. package/bundle/lib/waku_message/topic_only_message.js +4 -0
  26. package/bundle/lib/waku_message/version_0.js +4 -0
  27. package/bundle/lib/waku_message/version_1.js +463 -0
  28. package/bundle/message-e2db79d7.js +8393 -0
  29. package/bundle/multiaddr_to_peer_info-c406b1e1.js +19 -0
  30. package/bundle/multiaddr_to_peer_info-fd1de516.js +19 -0
  31. package/bundle/random_subset-75d1c511.js +26 -0
  32. package/bundle/topic_only_message-34f36fa6.js +82 -0
  33. package/bundle/utils-9a3221f2.js +815 -0
  34. package/bundle/version_0-e6fe440c.js +317 -0
  35. package/dist/index.d.ts +16 -0
  36. package/dist/index.js +17 -0
  37. package/dist/index.js.map +1 -0
  38. package/dist/lib/constants.d.ts +4 -0
  39. package/dist/lib/constants.js +5 -0
  40. package/dist/lib/constants.js.map +1 -0
  41. package/dist/lib/crypto.d.ts +34 -0
  42. package/dist/lib/crypto.js +79 -0
  43. package/dist/lib/crypto.js.map +1 -0
  44. package/dist/lib/enr/constants.d.ts +4 -0
  45. package/dist/lib/enr/constants.js +8 -0
  46. package/dist/lib/enr/constants.js.map +1 -0
  47. package/dist/lib/enr/enr.d.ts +90 -0
  48. package/dist/lib/enr/enr.js +432 -0
  49. package/dist/lib/enr/enr.js.map +1 -0
  50. package/dist/lib/enr/index.d.ts +5 -0
  51. package/dist/lib/enr/index.js +6 -0
  52. package/dist/lib/enr/index.js.map +1 -0
  53. package/dist/lib/enr/keypair/index.d.ts +8 -0
  54. package/dist/lib/enr/keypair/index.js +53 -0
  55. package/dist/lib/enr/keypair/index.js.map +1 -0
  56. package/dist/lib/enr/keypair/secp256k1.d.ts +13 -0
  57. package/dist/lib/enr/keypair/secp256k1.js +57 -0
  58. package/dist/lib/enr/keypair/secp256k1.js.map +1 -0
  59. package/dist/lib/enr/keypair/types.d.ts +13 -0
  60. package/dist/lib/enr/keypair/types.js +7 -0
  61. package/dist/lib/enr/keypair/types.js.map +1 -0
  62. package/dist/lib/enr/multiaddr_from_fields.d.ts +2 -0
  63. package/dist/lib/enr/multiaddr_from_fields.js +8 -0
  64. package/dist/lib/enr/multiaddr_from_fields.js.map +1 -0
  65. package/dist/lib/enr/multiaddrs_codec.d.ts +3 -0
  66. package/dist/lib/enr/multiaddrs_codec.js +32 -0
  67. package/dist/lib/enr/multiaddrs_codec.js.map +1 -0
  68. package/dist/lib/enr/types.d.ts +8 -0
  69. package/dist/lib/enr/types.js +3 -0
  70. package/dist/lib/enr/types.js.map +1 -0
  71. package/dist/lib/enr/v4.d.ts +3 -0
  72. package/dist/lib/enr/v4.js +14 -0
  73. package/dist/lib/enr/v4.js.map +1 -0
  74. package/dist/lib/enr/waku2_codec.d.ts +8 -0
  75. package/dist/lib/enr/waku2_codec.js +36 -0
  76. package/dist/lib/enr/waku2_codec.js.map +1 -0
  77. package/dist/lib/group_by.d.ts +3 -0
  78. package/dist/lib/group_by.js +13 -0
  79. package/dist/lib/group_by.js.map +1 -0
  80. package/dist/lib/multiaddr_to_peer_info.d.ts +3 -0
  81. package/dist/lib/multiaddr_to_peer_info.js +15 -0
  82. package/dist/lib/multiaddr_to_peer_info.js.map +1 -0
  83. package/dist/lib/peer_discovery_dns/dns.d.ts +48 -0
  84. package/dist/lib/peer_discovery_dns/dns.js +158 -0
  85. package/dist/lib/peer_discovery_dns/dns.js.map +1 -0
  86. package/dist/lib/peer_discovery_dns/dns_over_https.d.ts +32 -0
  87. package/dist/lib/peer_discovery_dns/dns_over_https.js +87 -0
  88. package/dist/lib/peer_discovery_dns/dns_over_https.js.map +1 -0
  89. package/dist/lib/peer_discovery_dns/enrtree.d.ts +33 -0
  90. package/dist/lib/peer_discovery_dns/enrtree.js +76 -0
  91. package/dist/lib/peer_discovery_dns/enrtree.js.map +1 -0
  92. package/dist/lib/peer_discovery_dns/fetch_nodes.d.ts +14 -0
  93. package/dist/lib/peer_discovery_dns/fetch_nodes.js +133 -0
  94. package/dist/lib/peer_discovery_dns/fetch_nodes.js.map +1 -0
  95. package/dist/lib/peer_discovery_dns/index.d.ts +30 -0
  96. package/dist/lib/peer_discovery_dns/index.js +54 -0
  97. package/dist/lib/peer_discovery_dns/index.js.map +1 -0
  98. package/dist/lib/peer_discovery_static_list.d.ts +44 -0
  99. package/dist/lib/peer_discovery_static_list.js +72 -0
  100. package/dist/lib/peer_discovery_static_list.js.map +1 -0
  101. package/dist/lib/predefined_bootstrap_nodes.d.ts +35 -0
  102. package/dist/lib/predefined_bootstrap_nodes.js +56 -0
  103. package/dist/lib/predefined_bootstrap_nodes.js.map +1 -0
  104. package/dist/lib/push_or_init_map.d.ts +1 -0
  105. package/dist/lib/push_or_init_map.js +9 -0
  106. package/dist/lib/push_or_init_map.js.map +1 -0
  107. package/dist/lib/random_subset.d.ts +4 -0
  108. package/dist/lib/random_subset.js +25 -0
  109. package/dist/lib/random_subset.js.map +1 -0
  110. package/dist/lib/select_connection.d.ts +2 -0
  111. package/dist/lib/select_connection.js +19 -0
  112. package/dist/lib/select_connection.js.map +1 -0
  113. package/dist/lib/select_peer.d.ts +15 -0
  114. package/dist/lib/select_peer.js +59 -0
  115. package/dist/lib/select_peer.js.map +1 -0
  116. package/dist/lib/to_proto_message.d.ts +3 -0
  117. package/dist/lib/to_proto_message.js +11 -0
  118. package/dist/lib/to_proto_message.js.map +1 -0
  119. package/dist/lib/utils.d.ts +22 -0
  120. package/dist/lib/utils.js +40 -0
  121. package/dist/lib/utils.js.map +1 -0
  122. package/dist/lib/wait_for_remote_peer.d.ts +22 -0
  123. package/dist/lib/wait_for_remote_peer.js +113 -0
  124. package/dist/lib/wait_for_remote_peer.js.map +1 -0
  125. package/dist/lib/waku.d.ts +61 -0
  126. package/dist/lib/waku.js +174 -0
  127. package/dist/lib/waku.js.map +1 -0
  128. package/dist/lib/waku_filter/filter_rpc.d.ts +25 -0
  129. package/dist/lib/waku_filter/filter_rpc.js +44 -0
  130. package/dist/lib/waku_filter/filter_rpc.js.map +1 -0
  131. package/dist/lib/waku_filter/index.d.ts +50 -0
  132. package/dist/lib/waku_filter/index.js +181 -0
  133. package/dist/lib/waku_filter/index.js.map +1 -0
  134. package/dist/lib/waku_light_push/index.d.ts +38 -0
  135. package/dist/lib/waku_light_push/index.js +83 -0
  136. package/dist/lib/waku_light_push/index.js.map +1 -0
  137. package/dist/lib/waku_light_push/push_rpc.d.ts +11 -0
  138. package/dist/lib/waku_light_push/push_rpc.js +31 -0
  139. package/dist/lib/waku_light_push/push_rpc.js.map +1 -0
  140. package/dist/lib/waku_message/constants.d.ts +12 -0
  141. package/dist/lib/waku_message/constants.js +10 -0
  142. package/dist/lib/waku_message/constants.js.map +1 -0
  143. package/dist/lib/waku_message/ecies.d.ts +17 -0
  144. package/dist/lib/waku_message/ecies.js +126 -0
  145. package/dist/lib/waku_message/ecies.js.map +1 -0
  146. package/dist/lib/waku_message/symmetric.d.ts +3 -0
  147. package/dist/lib/waku_message/symmetric.js +18 -0
  148. package/dist/lib/waku_message/symmetric.js.map +1 -0
  149. package/dist/lib/waku_message/topic_only_message.d.ts +15 -0
  150. package/dist/lib/waku_message/topic_only_message.js +31 -0
  151. package/dist/lib/waku_message/topic_only_message.js.map +1 -0
  152. package/dist/lib/waku_message/version_0.d.ts +26 -0
  153. package/dist/lib/waku_message/version_0.js +96 -0
  154. package/dist/lib/waku_message/version_0.js.map +1 -0
  155. package/dist/lib/waku_message/version_1.d.ts +93 -0
  156. package/dist/lib/waku_message/version_1.js +325 -0
  157. package/dist/lib/waku_message/version_1.js.map +1 -0
  158. package/dist/lib/waku_relay/constants.d.ts +63 -0
  159. package/dist/lib/waku_relay/constants.js +67 -0
  160. package/dist/lib/waku_relay/constants.js.map +1 -0
  161. package/dist/lib/waku_relay/index.d.ts +65 -0
  162. package/dist/lib/waku_relay/index.js +111 -0
  163. package/dist/lib/waku_relay/index.js.map +1 -0
  164. package/dist/lib/waku_store/history_rpc.d.ts +27 -0
  165. package/dist/lib/waku_store/history_rpc.js +71 -0
  166. package/dist/lib/waku_store/history_rpc.js.map +1 -0
  167. package/dist/lib/waku_store/index.d.ts +126 -0
  168. package/dist/lib/waku_store/index.js +218 -0
  169. package/dist/lib/waku_store/index.js.map +1 -0
  170. package/dist/proto/filter.d.ts +65 -0
  171. package/dist/proto/filter.js +425 -0
  172. package/dist/proto/filter.js.map +1 -0
  173. package/dist/proto/light_push.d.ts +57 -0
  174. package/dist/proto/light_push.js +369 -0
  175. package/dist/proto/light_push.js.map +1 -0
  176. package/dist/proto/message.d.ts +29 -0
  177. package/dist/proto/message.js +215 -0
  178. package/dist/proto/message.js.map +1 -0
  179. package/dist/proto/store.d.ts +104 -0
  180. package/dist/proto/store.js +602 -0
  181. package/dist/proto/store.js.map +1 -0
  182. package/dist/proto/topic_only_message.d.ts +10 -0
  183. package/dist/proto/topic_only_message.js +46 -0
  184. package/dist/proto/topic_only_message.js.map +1 -0
  185. package/package.json +292 -0
  186. package/src/index.ts +33 -0
  187. package/src/lib/constants.ts +4 -0
  188. package/src/lib/crypto.ts +100 -0
  189. package/src/lib/enr/constants.ts +10 -0
  190. package/src/lib/enr/enr.ts +516 -0
  191. package/src/lib/enr/index.ts +5 -0
  192. package/src/lib/enr/keypair/index.ts +76 -0
  193. package/src/lib/enr/keypair/secp256k1.ts +69 -0
  194. package/src/lib/enr/keypair/types.ts +14 -0
  195. package/src/lib/enr/multiaddr_from_fields.ts +18 -0
  196. package/src/lib/enr/multiaddrs_codec.ts +50 -0
  197. package/src/lib/enr/types.ts +11 -0
  198. package/src/lib/enr/v4.ts +22 -0
  199. package/src/lib/enr/waku2_codec.ts +39 -0
  200. package/src/lib/group_by.ts +14 -0
  201. package/src/lib/multiaddr_to_peer_info.ts +17 -0
  202. package/src/lib/peer_discovery_dns/dns.ts +223 -0
  203. package/src/lib/peer_discovery_dns/dns_over_https.ts +98 -0
  204. package/src/lib/peer_discovery_dns/enrtree.ts +123 -0
  205. package/src/lib/peer_discovery_dns/fetch_nodes.ts +180 -0
  206. package/src/lib/peer_discovery_dns/index.ts +84 -0
  207. package/src/lib/peer_discovery_static_list.ts +118 -0
  208. package/src/lib/predefined_bootstrap_nodes.ts +72 -0
  209. package/src/lib/push_or_init_map.ts +13 -0
  210. package/src/lib/random_subset.ts +30 -0
  211. package/src/lib/select_connection.ts +24 -0
  212. package/src/lib/select_peer.ts +77 -0
  213. package/src/lib/to_proto_message.ts +15 -0
  214. package/src/lib/utils.ts +50 -0
  215. package/src/lib/wait_for_remote_peer.ts +151 -0
  216. package/src/lib/waku.ts +258 -0
  217. package/src/lib/waku_filter/filter_rpc.ts +57 -0
  218. package/src/lib/waku_filter/index.ts +291 -0
  219. package/src/lib/waku_light_push/index.ts +137 -0
  220. package/src/lib/waku_light_push/push_rpc.ts +39 -0
  221. package/src/lib/waku_message/constants.ts +10 -0
  222. package/src/lib/waku_message/ecies.ts +194 -0
  223. package/src/lib/waku_message/symmetric.ts +33 -0
  224. package/src/lib/waku_message/topic_only_message.ts +40 -0
  225. package/src/lib/waku_message/version_0.ts +121 -0
  226. package/src/lib/waku_message/version_1.ts +457 -0
  227. package/src/lib/waku_relay/constants.ts +77 -0
  228. package/src/lib/waku_relay/index.ts +189 -0
  229. package/src/lib/waku_store/history_rpc.ts +94 -0
  230. package/src/lib/waku_store/index.ts +372 -0
  231. package/src/proto/filter.ts +602 -0
  232. package/src/proto/light_push.ts +526 -0
  233. package/src/proto/message.ts +304 -0
  234. package/src/proto/store.ts +844 -0
  235. package/src/proto/topic_only_message.ts +67 -0
@@ -0,0 +1,67 @@
1
+ export const second = 1000;
2
+ export const minute = 60 * second;
3
+ /**
4
+ * RelayCodec is the libp2p identifier for the waku relay protocol
5
+ */
6
+ export const RelayCodecs = [
7
+ "/vac/waku/relay/2.0.0-beta2",
8
+ "/vac/waku/relay/2.0.0",
9
+ ];
10
+ export const RelayPingContentTopic = "/relay-ping/1/ping/null";
11
+ /**
12
+ * RelayGossipFactor affects how many peers we will emit gossip to at each heartbeat.
13
+ * We will send gossip to RelayGossipFactor * (total number of non-mesh peers), or
14
+ * RelayDlazy, whichever is greater.
15
+ */
16
+ export const RelayGossipFactor = 0.25;
17
+ /**
18
+ * GossipsubHeartbeatInitialDelay is the short delay before the heartbeat timer begins
19
+ * after the router is initialized.
20
+ */
21
+ export const RelayHeartbeatInitialDelay = 100;
22
+ /**
23
+ * RelayHeartbeatInterval controls the time between heartbeats.
24
+ */
25
+ export const RelayHeartbeatInterval = second;
26
+ /**
27
+ * RelayPrunePeers controls the number of peers to include in prune Peer eXchange.
28
+ * When we prune a peer that's eligible for PX (has a good score, etc), we will try to
29
+ * send them signed peer records for up to RelayPrunePeers other peers that we
30
+ * know of.
31
+ */
32
+ export const RelayPrunePeers = 16;
33
+ /**
34
+ * RelayPruneBackoff controls the backoff time for pruned peers. This is how long
35
+ * a peer must wait before attempting to graft into our mesh again after being pruned.
36
+ * When pruning a peer, we send them our value of RelayPruneBackoff so they know
37
+ * the minimum time to wait. Peers running older versions may not send a backoff time,
38
+ * so if we receive a prune message without one, we will wait at least RelayPruneBackoff
39
+ * before attempting to re-graft.
40
+ */
41
+ export const RelayPruneBackoff = minute;
42
+ /**
43
+ * RelayFanoutTTL controls how long we keep track of the fanout state. If it's been
44
+ * RelayFanoutTTL since we've published to a topic that we're not subscribed to,
45
+ * we'll delete the fanout map for that topic.
46
+ */
47
+ export const RelayFanoutTTL = minute;
48
+ /**
49
+ * RelayOpportunisticGraftTicks is the number of heartbeat ticks for attempting to improve the mesh
50
+ * with opportunistic grafting. Every RelayOpportunisticGraftTicks we will attempt to select some
51
+ * high-scoring mesh peers to replace lower-scoring ones, if the median score of our mesh peers falls
52
+ * below a threshold
53
+ */
54
+ export const RelayOpportunisticGraftTicks = 60;
55
+ /**
56
+ * RelayOpportunisticGraftPeers is the number of peers to opportunistically graft.
57
+ */
58
+ export const RelayOpportunisticGraftPeers = 2;
59
+ /**
60
+ * RelayMaxIHaveLength is the maximum number of messages to include in an IHAVE message.
61
+ * Also controls the maximum number of IHAVE ids we will accept and request with IWANT from a
62
+ * peer within a heartbeat, to protect from IHAVE floods. You should adjust this value from the
63
+ * default if your system is pushing more than 5000 messages in GossipsubHistoryGossip heartbeats;
64
+ * with the defaults this is 1666 messages/s.
65
+ */
66
+ export const RelayMaxIHaveLength = 5000;
67
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/waku_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;IACzB,6BAA6B;IAC7B,uBAAuB;CACxB,CAAC;AAEF,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"}
@@ -0,0 +1,65 @@
1
+ import { GossipSub, GossipsubOpts } from "@chainsafe/libp2p-gossipsub";
2
+ import { PeerIdStr, TopicStr } from "@chainsafe/libp2p-gossipsub/dist/src/types";
3
+ import type { Callback, Decoder, Encoder, Message, Relay, SendResult } from "@waku/interfaces";
4
+ export declare type Observer<T extends Message> = {
5
+ decoder: Decoder<T>;
6
+ callback: Callback<T>;
7
+ };
8
+ export declare type CreateOptions = {
9
+ /**
10
+ * The PubSub Topic to use. Defaults to {@link DefaultPubSubTopic}.
11
+ *
12
+ * One and only one pubsub topic is used by Waku. This is used by:
13
+ * - WakuRelay to receive, route and send messages,
14
+ * - WakuLightPush to send messages,
15
+ * - WakuStore to retrieve messages.
16
+ *
17
+ * The usage of the default pubsub topic is recommended.
18
+ * See [Waku v2 Topic Usage Recommendations](https://rfc.vac.dev/spec/23/) for details.
19
+ *
20
+ * @default {@link DefaultPubSubTopic}
21
+ */
22
+ pubSubTopic?: string;
23
+ } & GossipsubOpts;
24
+ /**
25
+ * Implements the [Waku v2 Relay protocol](https://rfc.vac.dev/spec/11/).
26
+ * Must be passed as a `pubsub` module to a `Libp2p` instance.
27
+ *
28
+ * @implements {require('libp2p-interfaces/src/pubsub')}
29
+ */
30
+ export declare class WakuRelay extends GossipSub implements Relay {
31
+ pubSubTopic: string;
32
+ defaultDecoder: Decoder<Message>;
33
+ static multicodec: string;
34
+ /**
35
+ * observers called when receiving new message.
36
+ * Observers under key `""` are always called.
37
+ */
38
+ observers: Map<string, Set<Observer<any>>>;
39
+ constructor(options?: Partial<CreateOptions>);
40
+ /**
41
+ * Mounts the gossipsub protocol onto the libp2p node
42
+ * and subscribes to the default topic.
43
+ *
44
+ * @override
45
+ * @returns {void}
46
+ */
47
+ start(): Promise<void>;
48
+ /**
49
+ * Send Waku message.
50
+ */
51
+ send(encoder: Encoder, message: Partial<Message>): Promise<SendResult>;
52
+ /**
53
+ * Add an observer and associated Decoder to process incoming messages on a given content topic.
54
+ *
55
+ * @returns Function to delete the observer
56
+ */
57
+ addObserver<T extends Message>(decoder: Decoder<T>, callback: Callback<T>): () => void;
58
+ /**
59
+ * Subscribe to a pubsub topic and start emitting Waku messages to observers.
60
+ *
61
+ * @override
62
+ */
63
+ subscribe(pubSubTopic: string): void;
64
+ getMeshPeers(topic?: TopicStr): PeerIdStr[];
65
+ }
@@ -0,0 +1,111 @@
1
+ import { GossipSub, } from "@chainsafe/libp2p-gossipsub";
2
+ import { SignaturePolicy } from "@chainsafe/libp2p-gossipsub/types";
3
+ import debug from "debug";
4
+ import { DefaultPubSubTopic } from "../constants.js";
5
+ import { pushOrInitMapSet } from "../push_or_init_map.js";
6
+ import { TopicOnlyDecoder } from "../waku_message/topic_only_message.js";
7
+ import * as constants from "./constants.js";
8
+ const log = debug("waku:relay");
9
+ /**
10
+ * Implements the [Waku v2 Relay protocol](https://rfc.vac.dev/spec/11/).
11
+ * Must be passed as a `pubsub` module to a `Libp2p` instance.
12
+ *
13
+ * @implements {require('libp2p-interfaces/src/pubsub')}
14
+ */
15
+ export class WakuRelay extends GossipSub {
16
+ constructor(options) {
17
+ options = Object.assign(options ?? {}, {
18
+ // Ensure that no signature is included nor expected in the messages.
19
+ globalSignaturePolicy: SignaturePolicy.StrictNoSign,
20
+ fallbackToFloodsub: false,
21
+ });
22
+ super(options);
23
+ this.multicodecs = constants.RelayCodecs;
24
+ this.observers = new Map();
25
+ this.pubSubTopic = options?.pubSubTopic ?? DefaultPubSubTopic;
26
+ // TODO: User might want to decide what decoder should be used (e.g. for RLN)
27
+ this.defaultDecoder = new TopicOnlyDecoder();
28
+ }
29
+ /**
30
+ * Mounts the gossipsub protocol onto the libp2p node
31
+ * and subscribes to the default topic.
32
+ *
33
+ * @override
34
+ * @returns {void}
35
+ */
36
+ async start() {
37
+ await super.start();
38
+ this.subscribe(this.pubSubTopic);
39
+ }
40
+ /**
41
+ * Send Waku message.
42
+ */
43
+ async send(encoder, message) {
44
+ const msg = await encoder.toWire(message);
45
+ if (!msg) {
46
+ log("Failed to encode message, aborting publish");
47
+ return { recipients: [] };
48
+ }
49
+ return this.publish(this.pubSubTopic, msg);
50
+ }
51
+ /**
52
+ * Add an observer and associated Decoder to process incoming messages on a given content topic.
53
+ *
54
+ * @returns Function to delete the observer
55
+ */
56
+ addObserver(decoder, callback) {
57
+ const observer = {
58
+ decoder,
59
+ callback,
60
+ };
61
+ pushOrInitMapSet(this.observers, decoder.contentTopic, observer);
62
+ return () => {
63
+ const observers = this.observers.get(decoder.contentTopic);
64
+ if (observers) {
65
+ observers.delete(observer);
66
+ }
67
+ };
68
+ }
69
+ /**
70
+ * Subscribe to a pubsub topic and start emitting Waku messages to observers.
71
+ *
72
+ * @override
73
+ */
74
+ subscribe(pubSubTopic) {
75
+ this.addEventListener("gossipsub:message", async (event) => {
76
+ if (event.detail.msg.topic !== pubSubTopic)
77
+ return;
78
+ log(`Message received on ${pubSubTopic}`);
79
+ const topicOnlyMsg = await this.defaultDecoder.fromWireToProtoObj(event.detail.msg.data);
80
+ if (!topicOnlyMsg || !topicOnlyMsg.contentTopic) {
81
+ log("Message does not have a content topic, skipping");
82
+ return;
83
+ }
84
+ const observers = this.observers.get(topicOnlyMsg.contentTopic);
85
+ if (!observers) {
86
+ return;
87
+ }
88
+ await Promise.all(Array.from(observers).map(async ({ decoder, callback }) => {
89
+ const protoMsg = await decoder.fromWireToProtoObj(event.detail.msg.data);
90
+ if (!protoMsg) {
91
+ log("Internal error: message previously decoded failed on 2nd pass.");
92
+ return;
93
+ }
94
+ const msg = await decoder.fromProtoObj(protoMsg);
95
+ if (msg) {
96
+ callback(msg);
97
+ }
98
+ else {
99
+ log("Failed to decode messages on", topicOnlyMsg.contentTopic);
100
+ }
101
+ }));
102
+ });
103
+ super.subscribe(pubSubTopic);
104
+ }
105
+ getMeshPeers(topic) {
106
+ return super.getMeshPeers(topic ?? this.pubSubTopic);
107
+ }
108
+ }
109
+ WakuRelay.multicodec = constants.RelayCodecs[0];
110
+ WakuRelay.multicodec = constants.RelayCodecs[constants.RelayCodecs.length - 1];
111
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/waku_relay/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,GAGV,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AASpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,MAAM,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;AAwBhC;;;;;GAKG;AACH,MA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QAAQ,CAAC,CAAC;gBACjD,IAAI,GAAG,EAAE;oBACP,QAAQ,CAAC,GAAG,CAAC,CAAC;iBACf;qBAAM;oBACL,GAAG,CAAC,8BAA8B,EAAE,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,oBAAU,GAAW,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;AAiI9D,SAAS,CAAC,UAAU,GAAG,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { Uint8ArrayList } from "uint8arraylist";
2
+ import * as proto from "../../proto/store";
3
+ export declare enum PageDirection {
4
+ BACKWARD = "backward",
5
+ FORWARD = "forward"
6
+ }
7
+ export interface Params {
8
+ contentTopics: string[];
9
+ pubSubTopic: string;
10
+ pageDirection: PageDirection;
11
+ pageSize: number;
12
+ startTime?: Date;
13
+ endTime?: Date;
14
+ cursor?: proto.Index;
15
+ }
16
+ export declare class HistoryRPC {
17
+ readonly proto: proto.HistoryRPC;
18
+ private constructor();
19
+ get query(): proto.HistoryQuery | undefined;
20
+ get response(): proto.HistoryResponse | undefined;
21
+ /**
22
+ * Create History Query.
23
+ */
24
+ static createQuery(params: Params): HistoryRPC;
25
+ decode(bytes: Uint8ArrayList): HistoryRPC;
26
+ encode(): Uint8Array;
27
+ }
@@ -0,0 +1,71 @@
1
+ import { v4 as uuid } from "uuid";
2
+ import * as proto from "../../proto/store.js";
3
+ const OneMillion = BigInt(1000000);
4
+ export var PageDirection;
5
+ (function (PageDirection) {
6
+ PageDirection["BACKWARD"] = "backward";
7
+ PageDirection["FORWARD"] = "forward";
8
+ })(PageDirection || (PageDirection = {}));
9
+ export class HistoryRPC {
10
+ constructor(proto) {
11
+ this.proto = proto;
12
+ }
13
+ get query() {
14
+ return this.proto.query;
15
+ }
16
+ get response() {
17
+ return this.proto.response;
18
+ }
19
+ /**
20
+ * Create History Query.
21
+ */
22
+ static createQuery(params) {
23
+ const contentFilters = params.contentTopics.map((contentTopic) => {
24
+ return { contentTopic };
25
+ });
26
+ const direction = directionToProto(params.pageDirection);
27
+ const pagingInfo = {
28
+ pageSize: BigInt(params.pageSize),
29
+ cursor: params.cursor,
30
+ direction,
31
+ };
32
+ let startTime, endTime;
33
+ if (params.startTime) {
34
+ // milliseconds 10^-3 to nanoseconds 10^-9
35
+ startTime = BigInt(params.startTime.valueOf()) * OneMillion;
36
+ }
37
+ if (params.endTime) {
38
+ // milliseconds 10^-3 to nanoseconds 10^-9
39
+ endTime = BigInt(params.endTime.valueOf()) * OneMillion;
40
+ }
41
+ return new HistoryRPC({
42
+ requestId: uuid(),
43
+ query: {
44
+ pubSubTopic: params.pubSubTopic,
45
+ contentFilters,
46
+ pagingInfo,
47
+ startTime,
48
+ endTime,
49
+ },
50
+ response: undefined,
51
+ });
52
+ }
53
+ decode(bytes) {
54
+ const res = proto.HistoryRPC.decode(bytes);
55
+ return new HistoryRPC(res);
56
+ }
57
+ encode() {
58
+ return proto.HistoryRPC.encode(this.proto);
59
+ }
60
+ }
61
+ function directionToProto(pageDirection) {
62
+ switch (pageDirection) {
63
+ case PageDirection.BACKWARD:
64
+ return proto.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED;
65
+ case PageDirection.FORWARD:
66
+ return proto.PagingInfo.Direction.DIRECTION_FORWARD;
67
+ default:
68
+ return proto.PagingInfo.Direction.DIRECTION_BACKWARD_UNSPECIFIED;
69
+ }
70
+ }
71
+ //# sourceMappingURL=history_rpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history_rpc.js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A0C;YAC1C,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,UAAU,CAAC;SACzD;QACD,OAAO,IAAI,UAAU,CAAC;YACpB,SAAS,EAAE,IAAI,EAAE;YACjB,KAAK,EAAE;gBACL,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,cAAc;gBACd,UAAU;gBACV,SAAS;gBACT,OAAO;aACR;YACD,QAAQ,EAAE,SAAS;SACpB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,KAAqB;QAC1B,MAAM,GAAG,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC3C,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM;QACJ,OAAO,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;CACF;AAED,SAAS,gBAAgB,CACvB,aAA4B;IAE5B,QAAQ,aAAa,EAAE;QACrB,KAAK,aAAa,CAAC,QAAQ;YACzB,OAAO,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,8BAA8B,CAAC;QACnE,KAAK,aAAa,CAAC,OAAO;YACxB,OAAO,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,iBAAiB,CAAC;QACtD;YACE,OAAO,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,8BAA8B,CAAC;KACpE;AACH,CAAC"}
@@ -0,0 +1,126 @@
1
+ import type { PeerId } from "@libp2p/interface-peer-id";
2
+ import { Peer } from "@libp2p/interface-peer-store";
3
+ import { Decoder, Message } from "@waku/interfaces";
4
+ import { Libp2p } from "libp2p";
5
+ import { PageDirection } from "./history_rpc";
6
+ export declare const StoreCodec = "/vac/waku/store/2.0.0-beta4";
7
+ export declare const DefaultPageSize = 10;
8
+ export { PageDirection };
9
+ export interface CreateOptions {
10
+ /**
11
+ * The PubSub Topic to use. Defaults to {@link DefaultPubSubTopic}.
12
+ *
13
+ * The usage of the default pubsub topic is recommended.
14
+ * See [Waku v2 Topic Usage Recommendations](https://rfc.vac.dev/spec/23/) for details.
15
+ *
16
+ * @default {@link DefaultPubSubTopic}
17
+ */
18
+ pubSubTopic?: string;
19
+ }
20
+ export interface TimeFilter {
21
+ startTime: Date;
22
+ endTime: Date;
23
+ }
24
+ export interface QueryOptions {
25
+ /**
26
+ * The peer to query. If undefined, a pseudo-random peer is selected from the connected Waku Store peers.
27
+ */
28
+ peerId?: PeerId;
29
+ /**
30
+ * The pubsub topic to pass to the query.
31
+ * See [Waku v2 Topic Usage Recommendations](https://rfc.vac.dev/spec/23/).
32
+ */
33
+ pubSubTopic?: string;
34
+ /**
35
+ * The direction in which pages are retrieved:
36
+ * - { @link PageDirection.BACKWARD }: Most recent page first.
37
+ * - { @link PageDirection.FORWARD }: Oldest page first.
38
+ *
39
+ * Note: This does not affect the ordering of messages with the page
40
+ * (the oldest message is always first).
41
+ *
42
+ * @default { @link PageDirection.BACKWARD }
43
+ */
44
+ pageDirection?: PageDirection;
45
+ /**
46
+ * The number of message per page.
47
+ *
48
+ * @default { @link DefaultPageSize }
49
+ */
50
+ pageSize?: number;
51
+ /**
52
+ * Retrieve messages with a timestamp within the provided values.
53
+ */
54
+ timeFilter?: TimeFilter;
55
+ }
56
+ /**
57
+ * Implements the [Waku v2 Store protocol](https://rfc.vac.dev/spec/13/).
58
+ *
59
+ * The Waku Store protocol can be used to retrieved historical messages.
60
+ */
61
+ export declare class WakuStore {
62
+ libp2p: Libp2p;
63
+ pubSubTopic: string;
64
+ constructor(libp2p: Libp2p, options?: CreateOptions);
65
+ /**
66
+ * Do a query to a Waku Store to retrieve historical/missed messages.
67
+ *
68
+ * The callback function takes a `WakuMessage` in input,
69
+ * messages are processed in order:
70
+ * - oldest to latest if `options.pageDirection` == { @link PageDirection.FORWARD }
71
+ * - latest to oldest if `options.pageDirection` == { @link PageDirection.BACKWARD }
72
+ *
73
+ * The ordering may affect performance.
74
+ * The ordering depends on the behavior of the remote store node.
75
+ * If strong ordering is needed, you may need to handle this at application level
76
+ * and set your own timestamps too (the WakuMessage timestamps are not certified).
77
+ *
78
+ * @throws If not able to reach a Waku Store peer to query,
79
+ * or if an error is encountered when processing the reply,
80
+ * or if two decoders with the same content topic are passed.
81
+ */
82
+ queryOrderedCallback<T extends Message>(decoders: Decoder<T>[], callback: (message: T) => Promise<void | boolean> | boolean | void, options?: QueryOptions): Promise<void>;
83
+ /**
84
+ * Do a query to a Waku Store to retrieve historical/missed messages.
85
+ *
86
+ * The callback function takes a `Promise<WakuMessage>` in input,
87
+ * useful if messages needs to be decrypted and performance matters.
88
+ *
89
+ * The order of the messages passed to the callback is as follows:
90
+ * - within a page, messages are expected to be ordered from oldest to most recent
91
+ * - pages direction depends on { @link QueryOptions.pageDirection }
92
+ *
93
+ * Do note that the resolution of the `Promise<WakuMessage | undefined` may
94
+ * break the order as it may rely on the browser decryption API, which in turn,
95
+ * may have a different speed depending on the type of decryption.
96
+ *
97
+ * @throws If not able to reach a Waku Store peer to query,
98
+ * or if an error is encountered when processing the reply,
99
+ * or if two decoders with the same content topic are passed.
100
+ */
101
+ queryCallbackOnPromise<T extends Message>(decoders: Decoder<T>[], callback: (message: Promise<T | undefined>) => Promise<void | boolean> | boolean | void, options?: QueryOptions): Promise<void>;
102
+ /**
103
+ * Do a query to a Waku Store to retrieve historical/missed messages.
104
+ *
105
+ * This is a generator, useful if you want most control on how messages
106
+ * are processed.
107
+ *
108
+ * The order of the messages returned by the remote Waku node SHOULD BE
109
+ * as follows:
110
+ * - within a page, messages SHOULD be ordered from oldest to most recent
111
+ * - pages direction depends on { @link QueryOptions.pageDirection }
112
+ *
113
+ * However, there is no way to guarantee the behavior of the remote node.
114
+ *
115
+ * @throws If not able to reach a Waku Store peer to query,
116
+ * or if an error is encountered when processing the reply,
117
+ * or if two decoders with the same content topic are passed.
118
+ */
119
+ queryGenerator<T extends Message>(decoders: Decoder<T>[], options?: QueryOptions): AsyncGenerator<Promise<T | undefined>[]>;
120
+ /**
121
+ * Returns known peers from the address book (`libp2p.peerStore`) that support
122
+ * store protocol. Waku may or may not be currently connected to these peers.
123
+ */
124
+ peers(): Promise<Peer[]>;
125
+ }
126
+ export declare function isDefined<T>(msg: T | undefined): msg is T;