@waku/interfaces 0.0.29-5674b0e.0 → 0.0.29-8a6571f.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/connection_manager.d.ts +27 -8
- package/dist/connection_manager.js.map +1 -1
- package/dist/filter.d.ts +24 -8
- package/dist/health_indicator.d.ts +18 -0
- package/dist/{health_manager.js → health_indicator.js} +5 -1
- package/dist/health_indicator.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/light_push.d.ts +16 -1
- package/dist/protocols.d.ts +68 -86
- package/dist/protocols.js +40 -45
- package/dist/protocols.js.map +1 -1
- package/dist/sender.d.ts +3 -3
- package/dist/store.d.ts +5 -2
- package/dist/waku.d.ts +9 -5
- package/package.json +1 -1
- package/src/connection_manager.ts +31 -8
- package/src/filter.ts +29 -17
- package/src/health_indicator.ts +24 -0
- package/src/index.ts +1 -2
- package/src/light_push.ts +21 -2
- package/src/protocols.ts +100 -88
- package/src/sender.ts +4 -3
- package/src/store.ts +6 -2
- package/src/waku.ts +10 -6
- package/dist/health_manager.d.ts +0 -21
- package/dist/health_manager.js.map +0 -1
- package/dist/keep_alive_manager.d.ts +0 -4
- package/dist/keep_alive_manager.js +0 -2
- package/dist/keep_alive_manager.js.map +0 -1
- package/src/health_manager.ts +0 -26
- package/src/keep_alive_manager.ts +0 -4
package/dist/protocols.d.ts
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
import type { Libp2p } from "@libp2p/interface";
|
2
2
|
import type { PeerId } from "@libp2p/interface";
|
3
|
-
import type {
|
3
|
+
import type { ConnectionManagerOptions } from "./connection_manager.js";
|
4
|
+
import type { FilterProtocolOptions } from "./filter.js";
|
4
5
|
import type { CreateLibp2pOptions } from "./libp2p.js";
|
6
|
+
import type { LightPushProtocolOptions } from "./light_push.js";
|
5
7
|
import type { IDecodedMessage } from "./message.js";
|
6
|
-
import { ThisAndThat, ThisOrThat } from "./misc.js";
|
7
|
-
import { AutoSharding, StaticSharding } from "./sharding.js";
|
8
|
+
import type { ThisAndThat, ThisOrThat } from "./misc.js";
|
9
|
+
import type { AutoSharding, StaticSharding } from "./sharding.js";
|
10
|
+
import type { StoreProtocolOptions } from "./store.js";
|
8
11
|
export declare enum Protocols {
|
9
12
|
Relay = "relay",
|
10
13
|
Store = "store",
|
@@ -13,43 +16,24 @@ export declare enum Protocols {
|
|
13
16
|
}
|
14
17
|
export type IBaseProtocolCore = {
|
15
18
|
multicodec: string;
|
16
|
-
allPeers: () => Promise<Peer[]>;
|
17
|
-
connectedPeers: () => Promise<Peer[]>;
|
18
19
|
addLibp2pEventListener: Libp2p["addEventListener"];
|
19
20
|
removeLibp2pEventListener: Libp2p["removeEventListener"];
|
20
21
|
};
|
21
|
-
export type IBaseProtocolSDK = {
|
22
|
-
readonly connectedPeers: Peer[];
|
23
|
-
renewPeer: (peerToDisconnect: PeerId) => Promise<Peer | undefined>;
|
24
|
-
readonly numPeersToUse: number;
|
25
|
-
};
|
26
22
|
export type NetworkConfig = StaticSharding | AutoSharding;
|
27
|
-
|
28
|
-
* Options for using LightPush and Filter
|
29
|
-
*/
|
30
|
-
export type ProtocolUseOptions = {
|
31
|
-
/**
|
32
|
-
* Optional flag to force using all available peers
|
33
|
-
*/
|
34
|
-
forceUseAllPeers?: boolean;
|
23
|
+
export type CreateNodeOptions = {
|
35
24
|
/**
|
36
|
-
*
|
25
|
+
* Set the user agent string to be used in identification of the node.
|
26
|
+
*
|
27
|
+
* @default "js-waku"
|
37
28
|
*/
|
38
|
-
|
39
|
-
};
|
40
|
-
export type ProtocolCreateOptions = {
|
29
|
+
userAgent?: string;
|
41
30
|
/**
|
42
|
-
*
|
31
|
+
* Starts Waku node automatically upon creations.
|
32
|
+
* Calls {@link @waku/sdk!WakuNode.start} before returning {@link @waku/sdk!WakuNode}
|
43
33
|
*
|
44
|
-
*
|
45
|
-
* Default value is configured for The Waku Network.
|
46
|
-
* The format to specify a shard is: clusterId: number, shards: number[]
|
47
|
-
* To learn more about the sharding specification, see [Relay Sharding](https://rfc.vac.dev/spec/51/).
|
48
|
-
*
|
49
|
-
* If using Auto Sharding:
|
50
|
-
* See [Waku v2 Topic Usage Recommendations](https://github.com/vacp2p/rfc-index/blob/main/waku/informational/23/topics.md#content-topics) for details.
|
51
|
-
* You cannot add or remove content topics after initialization of the node.
|
34
|
+
* @default true
|
52
35
|
*/
|
36
|
+
autoStart?: boolean;
|
53
37
|
/**
|
54
38
|
* Configuration for determining the network in use.
|
55
39
|
* Network configuration refers to the shards and clusters used in the network.
|
@@ -78,10 +62,9 @@ export type ProtocolCreateOptions = {
|
|
78
62
|
libp2p?: Partial<CreateLibp2pOptions>;
|
79
63
|
/**
|
80
64
|
* Number of peers to connect to, for the usage of the protocol.
|
81
|
-
* This is used by
|
82
|
-
*
|
83
|
-
*
|
84
|
-
* Defaults to 2.
|
65
|
+
* This is used by Filter to retrieve messages.
|
66
|
+
*
|
67
|
+
* @default 2.
|
85
68
|
*/
|
86
69
|
numPeersToUse?: number;
|
87
70
|
/**
|
@@ -99,52 +82,43 @@ export type ProtocolCreateOptions = {
|
|
99
82
|
*/
|
100
83
|
bootstrapPeers?: string[];
|
101
84
|
/**
|
102
|
-
*
|
103
|
-
*
|
85
|
+
* Configuration for connection manager.
|
86
|
+
* If not specified - default values are applied.
|
104
87
|
*/
|
105
|
-
|
106
|
-
store?: string;
|
107
|
-
};
|
108
|
-
};
|
109
|
-
export type Callback<T extends IDecodedMessage> = (msg: T) => void | Promise<void>;
|
110
|
-
export declare enum ProtocolError {
|
111
|
-
/** Could not determine the origin of the fault. Best to check connectivity and try again */
|
112
|
-
GENERIC_FAIL = "Generic error",
|
88
|
+
connectionManager?: Partial<ConnectionManagerOptions>;
|
113
89
|
/**
|
114
|
-
*
|
115
|
-
*
|
90
|
+
* Configuration for Filter protocol.
|
91
|
+
* If not specified - default values are applied.
|
116
92
|
*/
|
117
|
-
|
93
|
+
filter?: Partial<FilterProtocolOptions>;
|
118
94
|
/**
|
119
|
-
*
|
120
|
-
*
|
95
|
+
* Options for the Store protocol.
|
96
|
+
* If not specified - default values are applied.
|
121
97
|
*/
|
122
|
-
|
98
|
+
store?: Partial<StoreProtocolOptions>;
|
123
99
|
/**
|
124
|
-
*
|
125
|
-
*
|
126
|
-
*/
|
127
|
-
EMPTY_PAYLOAD = "Payload is empty",
|
128
|
-
/**
|
129
|
-
* The message size is above the maximum message size allowed on the Waku Network.
|
130
|
-
* Compressing the message or using an alternative strategy for large messages is recommended.
|
100
|
+
* Options for the LightPush protocol.
|
101
|
+
* If not specified - default values are applied.
|
131
102
|
*/
|
132
|
-
|
103
|
+
lightPush?: Partial<LightPushProtocolOptions>;
|
104
|
+
};
|
105
|
+
export type Callback<T extends IDecodedMessage> = (msg: T) => void | Promise<void>;
|
106
|
+
export declare enum ProtocolError {
|
133
107
|
/**
|
134
|
-
*
|
135
|
-
*
|
136
|
-
|
137
|
-
TOPIC_NOT_CONFIGURED = "Topic not configured",
|
108
|
+
* Could not determine the origin of the fault. Best to check connectivity and try again
|
109
|
+
* */
|
110
|
+
GENERIC_FAIL = "Generic error",
|
138
111
|
/**
|
139
|
-
* The
|
140
|
-
*
|
112
|
+
* The remote peer rejected the message. Information provided by the remote peer
|
113
|
+
* is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
|
114
|
+
* or `DECODE_FAILED` can be used.
|
141
115
|
*/
|
142
|
-
|
116
|
+
REMOTE_PEER_REJECTED = "Remote peer rejected",
|
143
117
|
/**
|
144
|
-
*
|
145
|
-
*
|
118
|
+
* Failure to protobuf decode the message. May be due to a remote peer issue,
|
119
|
+
* ensuring that messages are sent via several peer enable mitigation of this error.
|
146
120
|
*/
|
147
|
-
|
121
|
+
DECODE_FAILED = "Failed to decode",
|
148
122
|
/**
|
149
123
|
* Failure to find a peer with suitable protocols. This may due to a connection issue.
|
150
124
|
* Mitigation can be: retrying after a given time period, display connectivity issue
|
@@ -163,36 +137,44 @@ export declare enum ProtocolError {
|
|
163
137
|
*/
|
164
138
|
NO_RESPONSE = "No response received",
|
165
139
|
/**
|
166
|
-
*
|
167
|
-
*
|
168
|
-
* or `DECODE_FAILED` can be used.
|
140
|
+
* Failure to protobuf encode the message. This is not recoverable and needs
|
141
|
+
* further investigation.
|
169
142
|
*/
|
170
|
-
|
143
|
+
ENCODE_FAILED = "Failed to encode",
|
171
144
|
/**
|
172
|
-
* The
|
173
|
-
*
|
145
|
+
* The message payload is empty, making the message invalid. Ensure that a non-empty
|
146
|
+
* payload is set on the outgoing message.
|
174
147
|
*/
|
175
|
-
|
148
|
+
EMPTY_PAYLOAD = "Payload is empty",
|
176
149
|
/**
|
177
|
-
*
|
178
|
-
*
|
150
|
+
* The message size is above the maximum message size allowed on the Waku Network.
|
151
|
+
* Compressing the message or using an alternative strategy for large messages is recommended.
|
179
152
|
*/
|
180
|
-
|
153
|
+
SIZE_TOO_BIG = "Size is too big",
|
181
154
|
/**
|
182
|
-
*
|
183
|
-
*
|
155
|
+
* The PubsubTopic passed to the send function is not configured on the Waku node.
|
156
|
+
* Please ensure that the PubsubTopic is used when initializing the Waku node.
|
184
157
|
*/
|
185
|
-
|
158
|
+
TOPIC_NOT_CONFIGURED = "Topic not configured",
|
186
159
|
/**
|
187
|
-
*
|
188
|
-
* nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L190
|
160
|
+
* Fails when
|
189
161
|
*/
|
190
|
-
|
162
|
+
STREAM_ABORTED = "Stream aborted",
|
191
163
|
/**
|
192
164
|
* General proof generation error message.
|
193
165
|
* nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
|
194
166
|
*/
|
195
|
-
RLN_PROOF_GENERATION = "Proof generation failed"
|
167
|
+
RLN_PROOF_GENERATION = "Proof generation failed",
|
168
|
+
/**
|
169
|
+
* The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
|
170
|
+
* Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
|
171
|
+
*/
|
172
|
+
TOPIC_DECODER_MISMATCH = "Topic decoder mismatch",
|
173
|
+
/**
|
174
|
+
* The topics passed in the decoders do not match each other, or don't exist at all.
|
175
|
+
* Ensure that all the pubsub topics used in the decoders are valid and match each other.
|
176
|
+
*/
|
177
|
+
INVALID_DECODER_TOPICS = "Invalid decoder topics"
|
196
178
|
}
|
197
179
|
export interface Failure {
|
198
180
|
error: ProtocolError;
|
package/dist/protocols.js
CHANGED
@@ -7,43 +7,24 @@ export var Protocols;
|
|
7
7
|
})(Protocols || (Protocols = {}));
|
8
8
|
export var ProtocolError;
|
9
9
|
(function (ProtocolError) {
|
10
|
-
|
10
|
+
//
|
11
|
+
// GENERAL ERRORS SECTION
|
12
|
+
//
|
13
|
+
/**
|
14
|
+
* Could not determine the origin of the fault. Best to check connectivity and try again
|
15
|
+
* */
|
11
16
|
ProtocolError["GENERIC_FAIL"] = "Generic error";
|
12
17
|
/**
|
13
|
-
*
|
14
|
-
*
|
18
|
+
* The remote peer rejected the message. Information provided by the remote peer
|
19
|
+
* is logged. Review message validity, or mitigation for `NO_PEER_AVAILABLE`
|
20
|
+
* or `DECODE_FAILED` can be used.
|
15
21
|
*/
|
16
|
-
ProtocolError["
|
22
|
+
ProtocolError["REMOTE_PEER_REJECTED"] = "Remote peer rejected";
|
17
23
|
/**
|
18
24
|
* Failure to protobuf decode the message. May be due to a remote peer issue,
|
19
25
|
* ensuring that messages are sent via several peer enable mitigation of this error.
|
20
26
|
*/
|
21
27
|
ProtocolError["DECODE_FAILED"] = "Failed to decode";
|
22
|
-
/**
|
23
|
-
* The message payload is empty, making the message invalid. Ensure that a non-empty
|
24
|
-
* payload is set on the outgoing message.
|
25
|
-
*/
|
26
|
-
ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
|
27
|
-
/**
|
28
|
-
* The message size is above the maximum message size allowed on the Waku Network.
|
29
|
-
* Compressing the message or using an alternative strategy for large messages is recommended.
|
30
|
-
*/
|
31
|
-
ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
|
32
|
-
/**
|
33
|
-
* The PubsubTopic passed to the send function is not configured on the Waku node.
|
34
|
-
* Please ensure that the PubsubTopic is used when initializing the Waku node.
|
35
|
-
*/
|
36
|
-
ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
37
|
-
/**
|
38
|
-
* The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
|
39
|
-
* Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
|
40
|
-
*/
|
41
|
-
ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
|
42
|
-
/**
|
43
|
-
* The topics passed in the decoders do not match each other, or don't exist at all.
|
44
|
-
* Ensure that all the pubsub topics used in the decoders are valid and match each other.
|
45
|
-
*/
|
46
|
-
ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
|
47
28
|
/**
|
48
29
|
* Failure to find a peer with suitable protocols. This may due to a connection issue.
|
49
30
|
* Mitigation can be: retrying after a given time period, display connectivity issue
|
@@ -61,36 +42,50 @@ export var ProtocolError;
|
|
61
42
|
* or `DECODE_FAILED` can be used.
|
62
43
|
*/
|
63
44
|
ProtocolError["NO_RESPONSE"] = "No response received";
|
45
|
+
//
|
46
|
+
// SEND ERRORS SECTION
|
47
|
+
//
|
64
48
|
/**
|
65
|
-
*
|
66
|
-
*
|
67
|
-
* or `DECODE_FAILED` can be used.
|
49
|
+
* Failure to protobuf encode the message. This is not recoverable and needs
|
50
|
+
* further investigation.
|
68
51
|
*/
|
69
|
-
ProtocolError["
|
52
|
+
ProtocolError["ENCODE_FAILED"] = "Failed to encode";
|
70
53
|
/**
|
71
|
-
* The
|
72
|
-
*
|
54
|
+
* The message payload is empty, making the message invalid. Ensure that a non-empty
|
55
|
+
* payload is set on the outgoing message.
|
73
56
|
*/
|
74
|
-
ProtocolError["
|
57
|
+
ProtocolError["EMPTY_PAYLOAD"] = "Payload is empty";
|
75
58
|
/**
|
76
|
-
*
|
77
|
-
*
|
59
|
+
* The message size is above the maximum message size allowed on the Waku Network.
|
60
|
+
* Compressing the message or using an alternative strategy for large messages is recommended.
|
78
61
|
*/
|
79
|
-
ProtocolError["
|
62
|
+
ProtocolError["SIZE_TOO_BIG"] = "Size is too big";
|
80
63
|
/**
|
81
|
-
*
|
82
|
-
*
|
64
|
+
* The PubsubTopic passed to the send function is not configured on the Waku node.
|
65
|
+
* Please ensure that the PubsubTopic is used when initializing the Waku node.
|
83
66
|
*/
|
84
|
-
ProtocolError["
|
67
|
+
ProtocolError["TOPIC_NOT_CONFIGURED"] = "Topic not configured";
|
85
68
|
/**
|
86
|
-
*
|
87
|
-
* nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L190
|
69
|
+
* Fails when
|
88
70
|
*/
|
89
|
-
ProtocolError["
|
71
|
+
ProtocolError["STREAM_ABORTED"] = "Stream aborted";
|
90
72
|
/**
|
91
73
|
* General proof generation error message.
|
92
74
|
* nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
|
93
75
|
*/
|
94
76
|
ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
|
77
|
+
//
|
78
|
+
// RECEIVE ERRORS SECTION
|
79
|
+
//
|
80
|
+
/**
|
81
|
+
* The pubsub topic configured on the decoder does not match the pubsub topic setup on the protocol.
|
82
|
+
* Ensure that the pubsub topic used for decoder creation is the same as the one used for protocol.
|
83
|
+
*/
|
84
|
+
ProtocolError["TOPIC_DECODER_MISMATCH"] = "Topic decoder mismatch";
|
85
|
+
/**
|
86
|
+
* The topics passed in the decoders do not match each other, or don't exist at all.
|
87
|
+
* Ensure that all the pubsub topics used in the decoders are valid and match each other.
|
88
|
+
*/
|
89
|
+
ProtocolError["INVALID_DECODER_TOPICS"] = "Invalid decoder topics";
|
95
90
|
})(ProtocolError || (ProtocolError = {}));
|
96
91
|
//# sourceMappingURL=protocols.js.map
|
package/dist/protocols.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"AAYA,MAAM,CAAN,IAAY,SAKX;AALD,WAAY,SAAS;IACnB,4BAAe,CAAA;IACf,4BAAe,CAAA;IACf,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;AA4GD,MAAM,CAAN,IAAY,aA8FX;AA9FD,WAAY,aAAa;IACvB,EAAE;IACF,yBAAyB;IACzB,EAAE;IACF;;SAEK;IACL,+CAA8B,CAAA;IAE9B;;;;OAIG;IACH,8DAA6C,CAAA;IAE7C;;;OAGG;IACH,mDAAkC,CAAA;IAElC;;;;;OAKG;IACH,wDAAuC,CAAA;IAEvC;;;OAGG;IACH,4DAA2C,CAAA;IAE3C;;;OAGG;IACH,qDAAoC,CAAA;IAEpC,EAAE;IACF,sBAAsB;IACtB,EAAE;IACF;;;OAGG;IACH,mDAAkC,CAAA;IAElC;;;OAGG;IACH,mDAAkC,CAAA;IAElC;;;OAGG;IACH,iDAAgC,CAAA;IAEhC;;;OAGG;IACH,8DAA6C,CAAA;IAE7C;;OAEG;IACH,kDAAiC,CAAA;IAEjC;;;OAGG;IACH,iEAAgD,CAAA;IAEhD,EAAE;IACF,yBAAyB;IACzB,EAAE;IACF;;;OAGG;IACH,kEAAiD,CAAA;IAEjD;;;OAGG;IACH,kEAAiD,CAAA;AACnD,CAAC,EA9FW,aAAa,KAAb,aAAa,QA8FxB"}
|
package/dist/sender.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import type { IEncoder, IMessage } from "./message.js";
|
2
2
|
import { SDKProtocolResult } from "./protocols.js";
|
3
|
-
export type
|
3
|
+
export type ISendOptions = {
|
4
4
|
/**
|
5
5
|
* Enables retry of a message that was failed to be sent.
|
6
|
-
* @default
|
6
|
+
* @default true
|
7
7
|
*/
|
8
8
|
autoRetry?: boolean;
|
9
9
|
/**
|
@@ -13,5 +13,5 @@ export type ISenderOptions = {
|
|
13
13
|
maxAttempts?: number;
|
14
14
|
};
|
15
15
|
export interface ISender {
|
16
|
-
send: (encoder: IEncoder, message: IMessage, sendOptions?:
|
16
|
+
send: (encoder: IEncoder, message: IMessage, sendOptions?: ISendOptions) => Promise<SDKProtocolResult>;
|
17
17
|
}
|
package/dist/store.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { IDecodedMessage, IDecoder } from "./message.js";
|
2
|
-
import type { IBaseProtocolCore
|
2
|
+
import type { IBaseProtocolCore } from "./protocols.js";
|
3
3
|
export type StoreCursor = Uint8Array;
|
4
4
|
/**
|
5
5
|
* Parameters for a store query request, as specified in the Waku Store v3 RFC.
|
@@ -66,10 +66,13 @@ export type QueryRequestParams = {
|
|
66
66
|
paginationLimit?: number;
|
67
67
|
};
|
68
68
|
export type IStoreCore = IBaseProtocolCore;
|
69
|
-
export type IStore =
|
69
|
+
export type IStore = {
|
70
70
|
protocol: IBaseProtocolCore;
|
71
71
|
createCursor(message: IDecodedMessage): StoreCursor;
|
72
72
|
queryGenerator: <T extends IDecodedMessage>(decoders: IDecoder<T>[], options?: Partial<QueryRequestParams>) => AsyncGenerator<Promise<T | undefined>[]>;
|
73
73
|
queryWithOrderedCallback: <T extends IDecodedMessage>(decoders: IDecoder<T>[], callback: (message: T) => Promise<void | boolean> | boolean | void, options?: Partial<QueryRequestParams>) => Promise<void>;
|
74
74
|
queryWithPromiseCallback: <T extends IDecodedMessage>(decoders: IDecoder<T>[], callback: (message: Promise<T | undefined>) => Promise<void | boolean> | boolean | void, options?: Partial<QueryRequestParams>) => Promise<void>;
|
75
75
|
};
|
76
|
+
export type StoreProtocolOptions = {
|
77
|
+
peer: string;
|
78
|
+
};
|
package/dist/waku.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import type { PeerId, Stream } from "@libp2p/interface";
|
1
|
+
import type { Peer, PeerId, Stream } from "@libp2p/interface";
|
2
2
|
import type { MultiaddrInput } from "@multiformats/multiaddr";
|
3
|
-
import { IConnectionManager } from "./connection_manager.js";
|
3
|
+
import type { IConnectionManager } from "./connection_manager.js";
|
4
4
|
import type { IFilter } from "./filter.js";
|
5
|
-
import {
|
5
|
+
import type { IHealthIndicator } from "./health_indicator.js";
|
6
6
|
import type { Libp2p } from "./libp2p.js";
|
7
7
|
import type { ILightPush } from "./light_push.js";
|
8
|
-
import { Protocols } from "./protocols.js";
|
8
|
+
import type { Protocols } from "./protocols.js";
|
9
9
|
import type { IRelay } from "./relay.js";
|
10
10
|
import type { IStore } from "./store.js";
|
11
11
|
export interface IWaku {
|
@@ -14,8 +14,8 @@ export interface IWaku {
|
|
14
14
|
store?: IStore;
|
15
15
|
filter?: IFilter;
|
16
16
|
lightPush?: ILightPush;
|
17
|
-
health: IHealthManager;
|
18
17
|
connectionManager: IConnectionManager;
|
18
|
+
health: IHealthIndicator;
|
19
19
|
/**
|
20
20
|
* Returns a unique identifier for a node on the network.
|
21
21
|
*
|
@@ -110,6 +110,10 @@ export interface IWaku {
|
|
110
110
|
* @returns {boolean} `true` if the node has working connection and `false` otherwise
|
111
111
|
*/
|
112
112
|
isConnected(): boolean;
|
113
|
+
/**
|
114
|
+
* @returns {Peer[]} an array of all connected peers
|
115
|
+
*/
|
116
|
+
getConnectedPeers(): Promise<Peer[]>;
|
113
117
|
}
|
114
118
|
export interface LightNode extends IWaku {
|
115
119
|
relay: undefined;
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@waku/interfaces","version":"0.0.29-
|
1
|
+
{"name":"@waku/interfaces","version":"0.0.29-8a6571f.0","description":"Definition of Waku interfaces","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"type":"module","author":"Waku Team","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/interfaces#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","decentralized","secure","communication","web3","ethereum","dapps","privacy"],"scripts":{"build":"run-s build:**","build:esm":"tsc","fix":"run-s fix:*","fix:lint":"eslint src --fix","check":"run-s check:*","check:lint":"eslint src","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","check:tsc":"tsc -p tsconfig.dev.json","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build"},"engines":{"node":">=20"},"devDependencies":{"@chainsafe/libp2p-gossipsub":"^14.1.0","@multiformats/multiaddr":"^12.0.0","cspell":"^8.6.1","npm-run-all":"^4.1.5","libp2p":"2.1.8"},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"],"dependencies":{"@waku/proto":"0.0.9-8a6571f.0"}}
|
@@ -8,22 +8,44 @@ export enum Tags {
|
|
8
8
|
LOCAL = "local-peer-cache"
|
9
9
|
}
|
10
10
|
|
11
|
-
export
|
11
|
+
export type ConnectionManagerOptions = {
|
12
12
|
/**
|
13
|
-
* Number of attempts before a peer is considered non-dialable
|
14
|
-
* This is used to not spam a peer with dial attempts when it is not dialable
|
13
|
+
* Number of attempts before a peer is considered non-dialable.
|
14
|
+
* This is used to not spam a peer with dial attempts when it is not dialable.
|
15
|
+
*
|
16
|
+
* @default 3
|
15
17
|
*/
|
16
18
|
maxDialAttemptsForPeer: number;
|
19
|
+
|
17
20
|
/**
|
18
|
-
* Max number of bootstrap peers allowed to be connected to
|
19
|
-
* This is used to increase intention of dialing non-bootstrap peers, found using other discovery mechanisms (like Peer Exchange)
|
21
|
+
* Max number of bootstrap peers allowed to be connected to initially.
|
22
|
+
* This is used to increase intention of dialing non-bootstrap peers, found using other discovery mechanisms (like Peer Exchange).
|
23
|
+
*
|
24
|
+
* @default 1
|
20
25
|
*/
|
21
26
|
maxBootstrapPeersAllowed: number;
|
27
|
+
|
22
28
|
/**
|
23
|
-
* Max number of parallel dials allowed
|
29
|
+
* Max number of parallel dials allowed.
|
30
|
+
*
|
31
|
+
* @default 3
|
24
32
|
*/
|
25
33
|
maxParallelDials: number;
|
26
|
-
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Keep alive libp2p pings interval in seconds.
|
37
|
+
*
|
38
|
+
* @default 300 seconds
|
39
|
+
*/
|
40
|
+
pingKeepAlive: number;
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Gossip sub specific keep alive interval in seconds.
|
44
|
+
*
|
45
|
+
* @default 300 seconds
|
46
|
+
*/
|
47
|
+
relayKeepAlive: number;
|
48
|
+
};
|
27
49
|
|
28
50
|
export enum EPeersByDiscoveryEvents {
|
29
51
|
PEER_DISCOVERY_BOOTSTRAP = "peer:discovery:bootstrap",
|
@@ -63,7 +85,8 @@ export interface IConnectionStateEvents {
|
|
63
85
|
|
64
86
|
export interface IConnectionManager
|
65
87
|
extends TypedEventEmitter<IPeersByDiscoveryEvents & IConnectionStateEvents> {
|
66
|
-
|
88
|
+
pubsubTopics: PubsubTopic[];
|
89
|
+
getConnectedPeers(codec?: string): Promise<Peer[]>;
|
67
90
|
dropConnection(peerId: PeerId): Promise<void>;
|
68
91
|
getPeersByDiscovery(): Promise<PeersByDiscoveryResult>;
|
69
92
|
stop(): void;
|
package/src/filter.ts
CHANGED
@@ -5,9 +5,7 @@ import type { ContentTopic, ThisOrThat } from "./misc.js";
|
|
5
5
|
import type {
|
6
6
|
Callback,
|
7
7
|
IBaseProtocolCore,
|
8
|
-
IBaseProtocolSDK,
|
9
8
|
ProtocolError,
|
10
|
-
ProtocolUseOptions,
|
11
9
|
SDKProtocolResult
|
12
10
|
} from "./protocols.js";
|
13
11
|
import type { IReceiver } from "./receiver.js";
|
@@ -17,17 +15,34 @@ export type SubscriptionCallback<T extends IDecodedMessage> = {
|
|
17
15
|
callback: Callback<T>;
|
18
16
|
};
|
19
17
|
|
20
|
-
export type
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
export type FilterProtocolOptions = {
|
19
|
+
/**
|
20
|
+
* Interval with which Filter subscription will attempt to send ping requests to subscribed peers.
|
21
|
+
*
|
22
|
+
* @default 60_000
|
23
|
+
*/
|
24
|
+
keepAliveIntervalMs: number;
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Number of failed pings allowed to make to a remote peer before attempting to subscribe to a new one.
|
28
|
+
*
|
29
|
+
* @default 3
|
30
|
+
*/
|
31
|
+
pingsBeforePeerRenewed: number;
|
32
|
+
|
33
|
+
/**
|
34
|
+
* Enables js-waku to send probe LightPush message over subscribed pubsubTopics on created subscription.
|
35
|
+
* In case message won't be received back through Filter - js-waku will attempt to subscribe to another peer.
|
36
|
+
*
|
37
|
+
* @default false
|
38
|
+
*/
|
39
|
+
enableLightPushFilterCheck: boolean;
|
24
40
|
};
|
25
41
|
|
26
42
|
export interface ISubscription {
|
27
43
|
subscribe<T extends IDecodedMessage>(
|
28
44
|
decoders: IDecoder<T> | IDecoder<T>[],
|
29
|
-
callback: Callback<T
|
30
|
-
options?: SubscribeOptions
|
45
|
+
callback: Callback<T>
|
31
46
|
): Promise<SDKProtocolResult>;
|
32
47
|
|
33
48
|
unsubscribe(contentTopics: ContentTopic[]): Promise<SDKProtocolResult>;
|
@@ -37,15 +52,12 @@ export interface ISubscription {
|
|
37
52
|
unsubscribeAll(): Promise<SDKProtocolResult>;
|
38
53
|
}
|
39
54
|
|
40
|
-
export type IFilter = IReceiver &
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
subscribeOptions?: SubscribeOptions
|
47
|
-
): Promise<SubscribeResult>;
|
48
|
-
};
|
55
|
+
export type IFilter = IReceiver & { protocol: IBaseProtocolCore } & {
|
56
|
+
subscribe<T extends IDecodedMessage>(
|
57
|
+
decoders: IDecoder<T> | IDecoder<T>[],
|
58
|
+
callback: Callback<T>
|
59
|
+
): Promise<SubscribeResult>;
|
60
|
+
};
|
49
61
|
|
50
62
|
export type SubscribeResult = SubscriptionSuccess | SubscriptionError;
|
51
63
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { TypedEventEmitter } from "@libp2p/interface";
|
2
|
+
|
3
|
+
import { Libp2p } from "./libp2p.js";
|
4
|
+
|
5
|
+
export enum HealthStatusChangeEvents {
|
6
|
+
StatusChange = "health:change"
|
7
|
+
}
|
8
|
+
|
9
|
+
export enum HealthStatus {
|
10
|
+
Unhealthy = "Unhealthy",
|
11
|
+
MinimallyHealthy = "MinimallyHealthy",
|
12
|
+
SufficientlyHealthy = "SufficientlyHealthy"
|
13
|
+
}
|
14
|
+
|
15
|
+
export type HealthIndicatorEvents = {
|
16
|
+
[HealthStatusChangeEvents.StatusChange]: CustomEvent<HealthStatus>;
|
17
|
+
};
|
18
|
+
|
19
|
+
export interface IHealthIndicator
|
20
|
+
extends TypedEventEmitter<HealthIndicatorEvents> {}
|
21
|
+
|
22
|
+
export type HealthIndicatorParams = {
|
23
|
+
libp2p: Libp2p;
|
24
|
+
};
|
package/src/index.ts
CHANGED
@@ -12,10 +12,9 @@ export * from "./sender.js";
|
|
12
12
|
export * from "./receiver.js";
|
13
13
|
export * from "./misc.js";
|
14
14
|
export * from "./libp2p.js";
|
15
|
-
export * from "./keep_alive_manager.js";
|
16
15
|
export * from "./dns_discovery.js";
|
17
16
|
export * from "./metadata.js";
|
18
17
|
export * from "./constants.js";
|
19
18
|
export * from "./local_storage.js";
|
20
|
-
export * from "./health_manager.js";
|
21
19
|
export * from "./sharding.js";
|
20
|
+
export * from "./health_indicator.js";
|
package/src/light_push.ts
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
import { IBaseProtocolCore } from "./protocols.js";
|
2
|
-
import type { ISender } from "./sender.js";
|
2
|
+
import type { ISender, ISendOptions } from "./sender.js";
|
3
3
|
|
4
|
-
export type
|
4
|
+
export type LightPushProtocolOptions = ISendOptions & {
|
5
|
+
/**
|
6
|
+
* The interval in milliseconds to wait before retrying a failed push.
|
7
|
+
* @default 1000
|
8
|
+
*/
|
9
|
+
retryIntervalMs: number;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* Number of peers to send message to.
|
13
|
+
*
|
14
|
+
* @default 1
|
15
|
+
*/
|
16
|
+
numPeersToUse?: number;
|
17
|
+
};
|
18
|
+
|
19
|
+
export type ILightPush = ISender & {
|
20
|
+
start: () => void;
|
21
|
+
stop: () => void;
|
22
|
+
protocol: IBaseProtocolCore;
|
23
|
+
};
|