@libp2p/interface 0.0.1 → 0.1.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/src/connection/index.d.ts +152 -53
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection/index.js.map +1 -1
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js.map +1 -1
- package/dist/src/index.d.ts +8 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/keys/index.d.ts.map +1 -1
- package/dist/src/keys/index.js.map +1 -1
- package/dist/src/peer-store/tags.d.ts.map +1 -1
- package/dist/src/peer-store/tags.js.map +1 -1
- package/dist/src/pubsub/index.d.ts +236 -0
- package/dist/src/pubsub/index.d.ts.map +1 -0
- package/dist/src/pubsub/index.js +36 -0
- package/dist/src/pubsub/index.js.map +1 -0
- package/dist/src/startable.d.ts.map +1 -1
- package/dist/src/startable.js.map +1 -1
- package/dist/src/stream-handler/index.d.ts +5 -0
- package/dist/src/stream-handler/index.d.ts.map +1 -1
- package/dist/src/stream-muxer/index.d.ts +6 -2
- package/dist/src/stream-muxer/index.d.ts.map +1 -1
- package/dist/src/stream-muxer/stream.d.ts +80 -21
- package/dist/src/stream-muxer/stream.d.ts.map +1 -1
- package/dist/src/stream-muxer/stream.js +224 -168
- package/dist/src/stream-muxer/stream.js.map +1 -1
- package/dist/src/transport/index.d.ts +5 -0
- package/dist/src/transport/index.d.ts.map +1 -1
- package/package.json +8 -11
- package/src/connection/index.ts +180 -59
- package/src/errors.ts +0 -1
- package/src/index.ts +8 -4
- package/src/keys/index.ts +0 -1
- package/src/peer-store/tags.ts +0 -1
- package/src/pubsub/index.ts +269 -0
- package/src/startable.ts +0 -1
- package/src/stream-handler/index.ts +6 -0
- package/src/stream-muxer/index.ts +7 -2
- package/src/stream-muxer/stream.ts +295 -186
- package/src/transport/index.ts +6 -0
- package/dist/src/connection/status.d.ts +0 -4
- package/dist/src/connection/status.d.ts.map +0 -1
- package/dist/src/connection/status.js +0 -4
- package/dist/src/connection/status.js.map +0 -1
- package/src/connection/status.ts +0 -4
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
import type * as Status from './status.js';
|
|
2
1
|
import type { AbortOptions } from '../index.js';
|
|
3
2
|
import type { PeerId } from '../peer-id/index.js';
|
|
4
3
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
5
4
|
import type { Duplex, Source } from 'it-stream-types';
|
|
6
5
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
7
6
|
export interface ConnectionTimeline {
|
|
8
|
-
open: number;
|
|
9
|
-
upgraded?: number;
|
|
10
|
-
close?: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Outbound conections are opened by the local node, inbound streams are opened by the remote
|
|
14
|
-
*/
|
|
15
|
-
export type Direction = 'inbound' | 'outbound';
|
|
16
|
-
export interface ConnectionStat {
|
|
17
|
-
/**
|
|
18
|
-
* Outbound conections are opened by the local node, inbound streams are opened by the remote
|
|
19
|
-
*/
|
|
20
|
-
direction: Direction;
|
|
21
|
-
/**
|
|
22
|
-
* Lifecycle times for the connection
|
|
23
|
-
*/
|
|
24
|
-
timeline: ConnectionTimeline;
|
|
25
7
|
/**
|
|
26
|
-
*
|
|
8
|
+
* When the connection was opened
|
|
27
9
|
*/
|
|
28
|
-
|
|
10
|
+
open: number;
|
|
29
11
|
/**
|
|
30
|
-
*
|
|
12
|
+
* When the MultiaddrConnection was upgraded to a Connection - e.g. the type
|
|
13
|
+
* of connection encryption and multiplexing was negotiated.
|
|
31
14
|
*/
|
|
32
|
-
|
|
15
|
+
upgraded?: number;
|
|
33
16
|
/**
|
|
34
|
-
*
|
|
17
|
+
* When the connection was closed.
|
|
35
18
|
*/
|
|
36
|
-
|
|
19
|
+
close?: number;
|
|
37
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Outbound connections are opened by the local node, inbound streams are opened by the remote
|
|
23
|
+
*/
|
|
24
|
+
export type Direction = 'inbound' | 'outbound';
|
|
38
25
|
export interface StreamTimeline {
|
|
39
26
|
/**
|
|
40
27
|
* A timestamp of when the stream was opened
|
|
@@ -56,21 +43,33 @@ export interface StreamTimeline {
|
|
|
56
43
|
* A timestamp of when the stream was reset
|
|
57
44
|
*/
|
|
58
45
|
reset?: number;
|
|
59
|
-
}
|
|
60
|
-
export interface StreamStat {
|
|
61
|
-
/**
|
|
62
|
-
* Outbound streams are opened by the local node, inbound streams are opened by the remote
|
|
63
|
-
*/
|
|
64
|
-
direction: Direction;
|
|
65
46
|
/**
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
timeline: StreamTimeline;
|
|
69
|
-
/**
|
|
70
|
-
* Once a protocol has been negotiated for this stream, it will be set on the stat object
|
|
47
|
+
* A timestamp of when the stream was aborted
|
|
71
48
|
*/
|
|
72
|
-
|
|
49
|
+
abort?: number;
|
|
73
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* The states a stream can be in
|
|
53
|
+
*/
|
|
54
|
+
export type StreamStatus = 'open' | 'closing' | 'closed' | 'aborted' | 'reset';
|
|
55
|
+
/**
|
|
56
|
+
* The states the readable end of a stream can be in
|
|
57
|
+
*
|
|
58
|
+
* ready - the readable end is ready for reading
|
|
59
|
+
* closing - the readable end is closing
|
|
60
|
+
* closed - the readable end has closed
|
|
61
|
+
*/
|
|
62
|
+
export type ReadStatus = 'ready' | 'closing' | 'closed';
|
|
63
|
+
/**
|
|
64
|
+
* The states the writable end of a stream can be in
|
|
65
|
+
*
|
|
66
|
+
* ready - the writable end is ready for writing
|
|
67
|
+
* writing - the writable end is in the process of being written to
|
|
68
|
+
* done - the source passed to the `.sink` function yielded all values without error
|
|
69
|
+
* closing - the writable end is closing
|
|
70
|
+
* closed - the writable end has closed
|
|
71
|
+
*/
|
|
72
|
+
export type WriteStatus = 'ready' | 'writing' | 'done' | 'closing' | 'closed';
|
|
74
73
|
/**
|
|
75
74
|
* A Stream is a data channel between two peers that
|
|
76
75
|
* can be written to and read from at both ends.
|
|
@@ -88,7 +87,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
88
87
|
*
|
|
89
88
|
* The sink and the source will return normally.
|
|
90
89
|
*/
|
|
91
|
-
close: () => void
|
|
90
|
+
close: (options?: AbortOptions) => Promise<void>;
|
|
92
91
|
/**
|
|
93
92
|
* Closes the stream for **reading**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
|
|
94
93
|
*
|
|
@@ -96,13 +95,13 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
96
95
|
*
|
|
97
96
|
* The source will return normally, the sink will continue to consume.
|
|
98
97
|
*/
|
|
99
|
-
closeRead: () => void
|
|
98
|
+
closeRead: (options?: AbortOptions) => Promise<void>;
|
|
100
99
|
/**
|
|
101
100
|
* Closes the stream for **writing**. If iterating over the source of this stream in a `for await of` loop, it will return (exit the loop) after any buffered data has been consumed.
|
|
102
101
|
*
|
|
103
102
|
* The source will return normally, the sink will continue to consume.
|
|
104
103
|
*/
|
|
105
|
-
closeWrite: () => void
|
|
104
|
+
closeWrite: (options?: AbortOptions) => Promise<void>;
|
|
106
105
|
/**
|
|
107
106
|
* Closes the stream for **reading** *and* **writing**. This should be called when a *local error* has occurred.
|
|
108
107
|
*
|
|
@@ -113,26 +112,38 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
113
112
|
* The sink will return and the source will throw if an error is passed or return normally if not.
|
|
114
113
|
*/
|
|
115
114
|
abort: (err: Error) => void;
|
|
116
|
-
/**
|
|
117
|
-
* Closes the stream *immediately* for **reading** *and* **writing**. This should be called when a *remote error* has occurred.
|
|
118
|
-
*
|
|
119
|
-
* This function is called automatically by the muxer when it receives a `RESET` message from the remote.
|
|
120
|
-
*
|
|
121
|
-
* The sink will return and the source will throw.
|
|
122
|
-
*/
|
|
123
|
-
reset: () => void;
|
|
124
115
|
/**
|
|
125
116
|
* Unique identifier for a stream. Identifiers are not unique across muxers.
|
|
126
117
|
*/
|
|
127
118
|
id: string;
|
|
128
119
|
/**
|
|
129
|
-
*
|
|
120
|
+
* Outbound streams are opened by the local node, inbound streams are opened by the remote
|
|
121
|
+
*/
|
|
122
|
+
direction: Direction;
|
|
123
|
+
/**
|
|
124
|
+
* Lifecycle times for the stream
|
|
130
125
|
*/
|
|
131
|
-
|
|
126
|
+
timeline: StreamTimeline;
|
|
127
|
+
/**
|
|
128
|
+
* Once a protocol has been negotiated for this stream, it will be set on the stat object
|
|
129
|
+
*/
|
|
130
|
+
protocol?: string;
|
|
132
131
|
/**
|
|
133
132
|
* User defined stream metadata
|
|
134
133
|
*/
|
|
135
134
|
metadata: Record<string, any>;
|
|
135
|
+
/**
|
|
136
|
+
* The current status of the stream
|
|
137
|
+
*/
|
|
138
|
+
status: StreamStatus;
|
|
139
|
+
/**
|
|
140
|
+
* The current status of the readable end of the stream
|
|
141
|
+
*/
|
|
142
|
+
readStatus: ReadStatus;
|
|
143
|
+
/**
|
|
144
|
+
* The current status of the writable end of the stream
|
|
145
|
+
*/
|
|
146
|
+
writeStatus: WriteStatus;
|
|
136
147
|
}
|
|
137
148
|
export interface NewStreamOptions extends AbortOptions {
|
|
138
149
|
/**
|
|
@@ -141,7 +152,13 @@ export interface NewStreamOptions extends AbortOptions {
|
|
|
141
152
|
* for the protocol
|
|
142
153
|
*/
|
|
143
154
|
maxOutboundStreams?: number;
|
|
155
|
+
/**
|
|
156
|
+
* Opt-in to running over a transient connection - one that has time/data limits
|
|
157
|
+
* placed on it.
|
|
158
|
+
*/
|
|
159
|
+
runOnTransientConnection?: boolean;
|
|
144
160
|
}
|
|
161
|
+
export type ConnectionStatus = 'open' | 'closing' | 'closed';
|
|
145
162
|
/**
|
|
146
163
|
* A Connection is a high-level representation of a connection
|
|
147
164
|
* to a remote peer that may have been secured by encryption and
|
|
@@ -149,16 +166,74 @@ export interface NewStreamOptions extends AbortOptions {
|
|
|
149
166
|
* between which the connection is made.
|
|
150
167
|
*/
|
|
151
168
|
export interface Connection {
|
|
169
|
+
/**
|
|
170
|
+
* The unique identifier for this connection
|
|
171
|
+
*/
|
|
152
172
|
id: string;
|
|
153
|
-
|
|
173
|
+
/**
|
|
174
|
+
* The address of the remote end of the connection
|
|
175
|
+
*/
|
|
154
176
|
remoteAddr: Multiaddr;
|
|
177
|
+
/**
|
|
178
|
+
* The id of the peer at the remote end of the connection
|
|
179
|
+
*/
|
|
155
180
|
remotePeer: PeerId;
|
|
181
|
+
/**
|
|
182
|
+
* A list of tags applied to this connection
|
|
183
|
+
*/
|
|
156
184
|
tags: string[];
|
|
185
|
+
/**
|
|
186
|
+
* A list of open streams on this connection
|
|
187
|
+
*/
|
|
157
188
|
streams: Stream[];
|
|
158
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Outbound conections are opened by the local node, inbound streams are opened by the remote
|
|
191
|
+
*/
|
|
192
|
+
direction: Direction;
|
|
193
|
+
/**
|
|
194
|
+
* Lifecycle times for the connection
|
|
195
|
+
*/
|
|
196
|
+
timeline: ConnectionTimeline;
|
|
197
|
+
/**
|
|
198
|
+
* Once a multiplexer has been negotiated for this stream, it will be set on the stat object
|
|
199
|
+
*/
|
|
200
|
+
multiplexer?: string;
|
|
201
|
+
/**
|
|
202
|
+
* Once a connection encrypter has been negotiated for this stream, it will be set on the stat object
|
|
203
|
+
*/
|
|
204
|
+
encryption?: string;
|
|
205
|
+
/**
|
|
206
|
+
* The current status of the connection
|
|
207
|
+
*/
|
|
208
|
+
status: ConnectionStatus;
|
|
209
|
+
/**
|
|
210
|
+
* A transient connection is one that is not expected to be open for very long
|
|
211
|
+
* or one that cannot transfer very much data, such as one being used as a
|
|
212
|
+
* circuit relay connection. Protocols need to explicitly opt-in to being run
|
|
213
|
+
* over transient connections.
|
|
214
|
+
*/
|
|
215
|
+
transient: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Create a new stream on this connection and negotiate one of the passed protocols
|
|
218
|
+
*/
|
|
219
|
+
newStream: (protocols: string | string[], options?: NewStreamOptions) => Promise<Stream>;
|
|
220
|
+
/**
|
|
221
|
+
* Add a stream to this connection
|
|
222
|
+
*/
|
|
159
223
|
addStream: (stream: Stream) => void;
|
|
224
|
+
/**
|
|
225
|
+
* Remove a stream from this connection
|
|
226
|
+
*/
|
|
160
227
|
removeStream: (id: string) => void;
|
|
161
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Gracefully close the connection. All queued data will be written to the
|
|
230
|
+
* underlying transport.
|
|
231
|
+
*/
|
|
232
|
+
close: (options?: AbortOptions) => Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Immediately close the connection, any queued data will be discarded
|
|
235
|
+
*/
|
|
236
|
+
abort: (err: Error) => void;
|
|
162
237
|
}
|
|
163
238
|
export declare const symbol: unique symbol;
|
|
164
239
|
export declare function isConnection(other: any): other is Connection;
|
|
@@ -171,8 +246,18 @@ export interface ConnectionProtector {
|
|
|
171
246
|
protect: (connection: MultiaddrConnection) => Promise<MultiaddrConnection>;
|
|
172
247
|
}
|
|
173
248
|
export interface MultiaddrConnectionTimeline {
|
|
249
|
+
/**
|
|
250
|
+
* When the connection was opened
|
|
251
|
+
*/
|
|
174
252
|
open: number;
|
|
253
|
+
/**
|
|
254
|
+
* When the MultiaddrConnection was upgraded to a Connection - the type of
|
|
255
|
+
* connection encryption and multiplexing was negotiated.
|
|
256
|
+
*/
|
|
175
257
|
upgraded?: number;
|
|
258
|
+
/**
|
|
259
|
+
* When the connection was closed.
|
|
260
|
+
*/
|
|
176
261
|
close?: number;
|
|
177
262
|
}
|
|
178
263
|
/**
|
|
@@ -181,8 +266,22 @@ export interface MultiaddrConnectionTimeline {
|
|
|
181
266
|
* without encryption or stream multiplexing.
|
|
182
267
|
*/
|
|
183
268
|
export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>> {
|
|
184
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Gracefully close the connection. All queued data will be written to the
|
|
271
|
+
* underlying transport.
|
|
272
|
+
*/
|
|
273
|
+
close: (options?: AbortOptions) => Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Immediately close the connection, any queued data will be discarded
|
|
276
|
+
*/
|
|
277
|
+
abort: (err: Error) => void;
|
|
278
|
+
/**
|
|
279
|
+
* The address of the remote end of the connection
|
|
280
|
+
*/
|
|
185
281
|
remoteAddr: Multiaddr;
|
|
282
|
+
/**
|
|
283
|
+
* When connection lifecycle events occurred
|
|
284
|
+
*/
|
|
186
285
|
timeline: MultiaddrConnectionTimeline;
|
|
187
286
|
}
|
|
188
287
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AAE9C,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,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AY,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IAElC;;;OAGG;IACH,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhD;;OAEG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;CAC5B;AAED,eAAO,MAAM,MAAM,eAAmC,CAAA;AAEtD,wBAAgB,YAAY,CAAE,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,UAAU,CAE7D;AAED,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,OAAO,EAAE,CAAC,UAAU,EAAE,mBAAmB,KAAK,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAC3E;AAED,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAChH;;;OAGG;IACH,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhD;;OAEG;IACH,KAAK,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;IAE3B;;OAEG;IACH,UAAU,EAAE,SAAS,CAAA;IAErB;;OAEG;IACH,QAAQ,EAAE,2BAA2B,CAAA;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AA0RA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAEtD,MAAM,UAAU,YAAY,CAAE,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC"}
|
package/dist/src/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,SAAgB,IAAI,EAAE,MAAM,CAAA;gBAEf,OAAO,GAAE,MAAoC;IAM1D,MAAM,CAAC,QAAQ,CAAC,IAAI,eAAc;IAElC,MAAM,CAAC,QAAQ,CAAC,IAAI,aAAY;CACjC;AAED,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAE,SAAQ,KAAK;aAKvE,IAAI,EAAE,MAAM;IAJ9B,SAAgB,KAAK,EAAE,CAAC,CAAA;gBAGtB,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EAC5B,KAAK,CAAC,EAAE,CAAC;CAOZ;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IACrC,IAAI,EAAE,MAAM,CAAA;gBAEN,OAAO,SAAoB;IAKxC,MAAM,CAAC,QAAQ,CAAC,IAAI,yBAAwB;CAC7C;AAED,qBAAa,0BAA2B,SAAQ,KAAK;IAC5C,IAAI,EAAE,MAAM,CAAA;gBAEN,OAAO,SAA4B;IAKhD,MAAM,CAAC,QAAQ,CAAC,IAAI,iCAAgC;CACrD;AAED,qBAAa,8BAA+B,SAAQ,KAAK;IAChD,IAAI,EAAE,MAAM,CAAA;gBAEN,OAAO,SAAgC;IAKpD,MAAM,CAAC,QAAQ,CAAC,IAAI,qCAAoC;CACzD"}
|
package/dist/src/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnB,IAAI,CAAQ;IACZ,IAAI,CAAQ;IAE5B,YAAa,UAAkB,2BAA2B;QACxD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;IAC7B,CAAC;IAED,MAAM,CAAU,IAAI,GAAG,WAAW,CAAA;IAElC,MAAM,CAAU,IAAI,GAAG,SAAS,CAAA;;AAGlC,MAAM,OAAO,SAAiE,SAAQ,KAAK;IAKvE;IAJF,KAAK,CAAG;IAExB,YACE,OAAe,EACC,IAAY,EAC5B,KAAS;QAET,KAAK,CAAC,OAAO,CAAC,CAAA;QAHE,SAAI,GAAJ,IAAI,CAAQ;QAK5B,IAAI,CAAC,IAAI,GAAG,KAAK,EAAE,IAAI,IAAI,WAAW,CAAA;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,EAAO,CAAA,CAAC,oEAAoE;IACpG,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACrC,IAAI,CAAQ;IAEnB,YAAa,OAAO,GAAG,iBAAiB;QACtC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAA;IACtC,CAAC;IAED,MAAM,CAAU,IAAI,GAAG,qBAAqB,CAAA;;AAG9C,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC5C,IAAI,CAAQ;IAEnB,YAAa,OAAO,GAAG,yBAAyB;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC,IAAI,CAAA;IAC7C,CAAC;IAED,MAAM,CAAU,IAAI,GAAG,6BAA6B,CAAA;;AAGtD,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IAChD,IAAI,CAAQ;IAEnB,YAAa,OAAO,GAAG,6BAA6B;QAClD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC,IAAI,CAAA;IACjD,CAAC;IAED,MAAM,CAAU,IAAI,GAAG,iCAAiC,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* }
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
import type { Connection, Stream } from './connection/index.js';
|
|
16
|
+
import type { Connection, NewStreamOptions, Stream } from './connection/index.js';
|
|
17
17
|
import type { ContentRouting } from './content-routing/index.js';
|
|
18
18
|
import type { EventEmitter } from './events.js';
|
|
19
19
|
import type { KeyChain } from './keychain/index.js';
|
|
@@ -459,9 +459,13 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
459
459
|
* pipe([1, 2, 3], stream, consume)
|
|
460
460
|
* ```
|
|
461
461
|
*/
|
|
462
|
-
dialProtocol: (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?:
|
|
462
|
+
dialProtocol: (peer: PeerId | Multiaddr | Multiaddr[], protocols: string | string[], options?: NewStreamOptions) => Promise<Stream>;
|
|
463
463
|
/**
|
|
464
|
-
* Attempts to gracefully close an open connection to the given peer. If the
|
|
464
|
+
* Attempts to gracefully close an open connection to the given peer. If the
|
|
465
|
+
* connection is not closed in the grace period, it will be forcefully closed.
|
|
466
|
+
*
|
|
467
|
+
* An AbortSignal can optionally be passed to control when the connection is
|
|
468
|
+
* forcefully closed.
|
|
465
469
|
*
|
|
466
470
|
* @example
|
|
467
471
|
*
|
|
@@ -469,7 +473,7 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ev
|
|
|
469
473
|
* await libp2p.hangUp(remotePeerId)
|
|
470
474
|
* ```
|
|
471
475
|
*/
|
|
472
|
-
hangUp: (peer: PeerId | Multiaddr) => Promise<void>;
|
|
476
|
+
hangUp: (peer: PeerId | Multiaddr, options?: AbortOptions) => Promise<void>;
|
|
473
477
|
/**
|
|
474
478
|
* Sets up [multistream-select routing](https://github.com/multiformats/multistream-select) of protocols to their application handlers. Whenever a stream is opened on one of the provided protocols, the handler will be called. `handle` must be called in order to register a handler and support for a given protocol. This also informs other peers of the protocols you support.
|
|
475
479
|
*
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AACh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MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACjJ,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,MAAM,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/D,OAAO,EAAE,MAAM,UAAU,CAAA;IACzB,MAAM,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,OAAO,CAAA;IACnC,IAAI,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAA;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAC1B,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAC/C,OAAO,EAAE,MAAM,UAAU,CAAA;IACzB,MAAM,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAA;IACpC,IAAI,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAA;IAC/B;;;;;;OAMG;IACH,EAAE,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAA;IACzB;;OAEG;IACH,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,GAAG,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAC1E;AAED,eAAO,MAAM,OAAO,YAAY,CAAA;AAChC,eAAO,MAAM,GAAG,QAAQ,CAAA;AACxB,eAAO,MAAM,SAAS,cAAc,CAAA;AAEpC,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,GAAG,OAAO,GAAG,GAAG,OAAO,SAAS,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/keys/index.ts"],"names":[],"mappings":"AAgCA,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAA;AAChC,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAA;AACxB,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../src/peer-store/tags.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../../src/peer-store/tags.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,eAAe,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../src/peer-store/tags.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../../src/peer-store/tags.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAA"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { Stream } from '../connection/index.js';
|
|
2
|
+
import type { EventEmitter } from '../events.js';
|
|
3
|
+
import type { PeerId } from '../peer-id/index.js';
|
|
4
|
+
import type { Pushable } from 'it-pushable';
|
|
5
|
+
import type { Uint8ArrayList } from 'uint8arraylist';
|
|
6
|
+
/**
|
|
7
|
+
* On the producing side:
|
|
8
|
+
* * Build messages with the signature, key (from may be enough for certain inlineable public key types), from and seqno fields.
|
|
9
|
+
*
|
|
10
|
+
* On the consuming side:
|
|
11
|
+
* * Enforce the fields to be present, reject otherwise.
|
|
12
|
+
* * Propagate only if the fields are valid and signature can be verified, reject otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export declare const StrictSign = "StrictSign";
|
|
15
|
+
/**
|
|
16
|
+
* On the producing side:
|
|
17
|
+
* * Build messages without the signature, key, from and seqno fields.
|
|
18
|
+
* * The corresponding protobuf key-value pairs are absent from the marshalled message, not just empty.
|
|
19
|
+
*
|
|
20
|
+
* On the consuming side:
|
|
21
|
+
* * Enforce the fields to be absent, reject otherwise.
|
|
22
|
+
* * Propagate only if the fields are absent, reject otherwise.
|
|
23
|
+
* * A message_id function will not be able to use the above fields, and should instead rely on the data field. A commonplace strategy is to calculate a hash.
|
|
24
|
+
*/
|
|
25
|
+
export declare const StrictNoSign = "StrictNoSign";
|
|
26
|
+
export type SignaturePolicy = typeof StrictSign | typeof StrictNoSign;
|
|
27
|
+
export interface SignedMessage {
|
|
28
|
+
type: 'signed';
|
|
29
|
+
from: PeerId;
|
|
30
|
+
topic: string;
|
|
31
|
+
data: Uint8Array;
|
|
32
|
+
sequenceNumber: bigint;
|
|
33
|
+
signature: Uint8Array;
|
|
34
|
+
key: Uint8Array;
|
|
35
|
+
}
|
|
36
|
+
export interface UnsignedMessage {
|
|
37
|
+
type: 'unsigned';
|
|
38
|
+
topic: string;
|
|
39
|
+
data: Uint8Array;
|
|
40
|
+
}
|
|
41
|
+
export type Message = SignedMessage | UnsignedMessage;
|
|
42
|
+
export interface PubSubRPCMessage {
|
|
43
|
+
from?: Uint8Array;
|
|
44
|
+
topic?: string;
|
|
45
|
+
data?: Uint8Array;
|
|
46
|
+
sequenceNumber?: Uint8Array;
|
|
47
|
+
signature?: Uint8Array;
|
|
48
|
+
key?: Uint8Array;
|
|
49
|
+
}
|
|
50
|
+
export interface PubSubRPCSubscription {
|
|
51
|
+
subscribe?: boolean;
|
|
52
|
+
topic?: string;
|
|
53
|
+
}
|
|
54
|
+
export interface PubSubRPC {
|
|
55
|
+
subscriptions: PubSubRPCSubscription[];
|
|
56
|
+
messages: PubSubRPCMessage[];
|
|
57
|
+
}
|
|
58
|
+
export interface PeerStreams extends EventEmitter<PeerStreamEvents> {
|
|
59
|
+
id: PeerId;
|
|
60
|
+
protocol: string;
|
|
61
|
+
outboundStream?: Pushable<Uint8ArrayList>;
|
|
62
|
+
inboundStream?: AsyncIterable<Uint8ArrayList>;
|
|
63
|
+
isWritable: boolean;
|
|
64
|
+
close: () => void;
|
|
65
|
+
write: (buf: Uint8Array | Uint8ArrayList) => void;
|
|
66
|
+
attachInboundStream: (stream: Stream) => AsyncIterable<Uint8ArrayList>;
|
|
67
|
+
attachOutboundStream: (stream: Stream) => Promise<Pushable<Uint8ArrayList>>;
|
|
68
|
+
}
|
|
69
|
+
export interface PubSubInit {
|
|
70
|
+
enabled?: boolean;
|
|
71
|
+
multicodecs?: string[];
|
|
72
|
+
/**
|
|
73
|
+
* defines how signatures should be handled
|
|
74
|
+
*/
|
|
75
|
+
globalSignaturePolicy?: SignaturePolicy;
|
|
76
|
+
/**
|
|
77
|
+
* if can relay messages not subscribed
|
|
78
|
+
*/
|
|
79
|
+
canRelayMessage?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* if publish should emit to self, if subscribed
|
|
82
|
+
*/
|
|
83
|
+
emitSelf?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* handle this many incoming pubsub messages concurrently
|
|
86
|
+
*/
|
|
87
|
+
messageProcessingConcurrency?: number;
|
|
88
|
+
/**
|
|
89
|
+
* How many parallel incoming streams to allow on the pubsub protocol per-connection
|
|
90
|
+
*/
|
|
91
|
+
maxInboundStreams?: number;
|
|
92
|
+
/**
|
|
93
|
+
* How many parallel outgoing streams to allow on the pubsub protocol per-connection
|
|
94
|
+
*/
|
|
95
|
+
maxOutboundStreams?: number;
|
|
96
|
+
}
|
|
97
|
+
interface Subscription {
|
|
98
|
+
topic: string;
|
|
99
|
+
subscribe: boolean;
|
|
100
|
+
}
|
|
101
|
+
export interface SubscriptionChangeData {
|
|
102
|
+
peerId: PeerId;
|
|
103
|
+
subscriptions: Subscription[];
|
|
104
|
+
}
|
|
105
|
+
export interface PubSubEvents {
|
|
106
|
+
'subscription-change': CustomEvent<SubscriptionChangeData>;
|
|
107
|
+
'message': CustomEvent<Message>;
|
|
108
|
+
}
|
|
109
|
+
export interface PublishResult {
|
|
110
|
+
recipients: PeerId[];
|
|
111
|
+
}
|
|
112
|
+
export declare enum TopicValidatorResult {
|
|
113
|
+
/**
|
|
114
|
+
* The message is considered valid, and it should be delivered and forwarded to the network
|
|
115
|
+
*/
|
|
116
|
+
Accept = "accept",
|
|
117
|
+
/**
|
|
118
|
+
* The message is neither delivered nor forwarded to the network
|
|
119
|
+
*/
|
|
120
|
+
Ignore = "ignore",
|
|
121
|
+
/**
|
|
122
|
+
* The message is considered invalid, and it should be rejected
|
|
123
|
+
*/
|
|
124
|
+
Reject = "reject"
|
|
125
|
+
}
|
|
126
|
+
export interface TopicValidatorFn {
|
|
127
|
+
(peer: PeerId, message: Message): TopicValidatorResult | Promise<TopicValidatorResult>;
|
|
128
|
+
}
|
|
129
|
+
export interface PubSub<Events extends Record<string, any> = PubSubEvents> extends EventEmitter<Events> {
|
|
130
|
+
/**
|
|
131
|
+
* The global signature policy controls whether or not we sill send and receive
|
|
132
|
+
* signed or unsigned messages.
|
|
133
|
+
*
|
|
134
|
+
* Signed messages prevent spoofing message senders and should be preferred to
|
|
135
|
+
* using unsigned messages.
|
|
136
|
+
*/
|
|
137
|
+
globalSignaturePolicy: typeof StrictSign | typeof StrictNoSign;
|
|
138
|
+
/**
|
|
139
|
+
* A list of multicodecs that contain the pubsub protocol name.
|
|
140
|
+
*/
|
|
141
|
+
multicodecs: string[];
|
|
142
|
+
/**
|
|
143
|
+
* Pubsub routers support message validators per topic, which will validate the message
|
|
144
|
+
* before its propagations. They are stored in a map where keys are the topic name and
|
|
145
|
+
* values are the validators.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
*
|
|
149
|
+
* ```js
|
|
150
|
+
* const topic = 'topic'
|
|
151
|
+
* const validateMessage = (msgTopic, msg) => {
|
|
152
|
+
* const input = uint8ArrayToString(msg.data)
|
|
153
|
+
* const validInputs = ['a', 'b', 'c']
|
|
154
|
+
*
|
|
155
|
+
* if (!validInputs.includes(input)) {
|
|
156
|
+
* throw new Error('no valid input received')
|
|
157
|
+
* }
|
|
158
|
+
* }
|
|
159
|
+
* libp2p.pubsub.topicValidators.set(topic, validateMessage)
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
topicValidators: Map<string, TopicValidatorFn>;
|
|
163
|
+
getPeers: () => PeerId[];
|
|
164
|
+
/**
|
|
165
|
+
* Gets a list of topics the node is subscribed to.
|
|
166
|
+
*
|
|
167
|
+
* ```js
|
|
168
|
+
* const topics = libp2p.pubsub.getTopics()
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
getTopics: () => string[];
|
|
172
|
+
/**
|
|
173
|
+
* Subscribes to a pubsub topic.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
*
|
|
177
|
+
* ```js
|
|
178
|
+
* const topic = 'topic'
|
|
179
|
+
* const handler = (msg) => {
|
|
180
|
+
* if (msg.topic === topic) {
|
|
181
|
+
* // msg.data - pubsub data received
|
|
182
|
+
* }
|
|
183
|
+
* }
|
|
184
|
+
*
|
|
185
|
+
* libp2p.pubsub.addEventListener('message', handler)
|
|
186
|
+
* libp2p.pubsub.subscribe(topic)
|
|
187
|
+
* ```
|
|
188
|
+
*/
|
|
189
|
+
subscribe: (topic: string) => void;
|
|
190
|
+
/**
|
|
191
|
+
* Unsubscribes from a pubsub topic.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
*
|
|
195
|
+
* ```js
|
|
196
|
+
* const topic = 'topic'
|
|
197
|
+
* const handler = (msg) => {
|
|
198
|
+
* // msg.data - pubsub data received
|
|
199
|
+
* }
|
|
200
|
+
*
|
|
201
|
+
* libp2p.pubsub.removeEventListener(topic handler)
|
|
202
|
+
* libp2p.pubsub.unsubscribe(topic)
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
unsubscribe: (topic: string) => void;
|
|
206
|
+
/**
|
|
207
|
+
* Gets a list of the PeerIds that are subscribed to one topic.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
*
|
|
211
|
+
* ```js
|
|
212
|
+
* const peerIds = libp2p.pubsub.getSubscribers(topic)
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
getSubscribers: (topic: string) => PeerId[];
|
|
216
|
+
/**
|
|
217
|
+
* Publishes messages to the given topic.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
*
|
|
221
|
+
* ```js
|
|
222
|
+
* const topic = 'topic'
|
|
223
|
+
* const data = uint8ArrayFromString('data')
|
|
224
|
+
*
|
|
225
|
+
* await libp2p.pubsub.publish(topic, data)
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
publish: (topic: string, data: Uint8Array) => Promise<PublishResult>;
|
|
229
|
+
}
|
|
230
|
+
export interface PeerStreamEvents {
|
|
231
|
+
'stream:inbound': CustomEvent<never>;
|
|
232
|
+
'stream:outbound': CustomEvent<never>;
|
|
233
|
+
'close': CustomEvent<never>;
|
|
234
|
+
}
|
|
235
|
+
export {};
|
|
236
|
+
//# sourceMappingURL=index.d.ts.map
|