@libp2p/interface 0.0.1-daeb43d8 → 0.0.1-eabf6f36
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/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 +4 -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/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,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA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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;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,K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AAC,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startable.d.ts","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"startable.d.ts","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,OAAO,CAAA;IAExB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAExC;;;;OAIG;IACH,KAAK,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEjC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEvC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEvC;;;;OAIG;IACH,IAAI,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEhC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACvC;AAED,wBAAgB,WAAW,CAAE,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS,CAEvD;AAED,wBAAsB,KAAK,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B1D;AAED,wBAAsB,IAAI,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BzD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startable.js","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"startable.js","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],"mappings":"AAiDA,MAAM,UAAU,WAAW,CAAE,GAAQ;IACnC,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,UAAU,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAA;AACzF,CAAC;AAED,MAAM,CAAC,KAAK,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CAAC,CACH,CAAA;IAED,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;QACvB,MAAM,CAAC,CAAC,IAAI,EAAE,CAAA;IAChB,CAAC,CAAC,CACH,CAAA;IAED,MAAM,OAAO,CAAC,GAAG,CACf,UAAU,CAAC,GAAG,CAAC,KAAK,EAAC,CAAC,EAAC,EAAE;QACvB,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,EAAE;YACvB,MAAM,CAAC,CAAC,SAAS,EAAE,CAAA;SACpB;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC"}
|
|
@@ -15,6 +15,11 @@ export interface StreamHandlerOptions {
|
|
|
15
15
|
* How many outgoing streams can be open for this protocol at the same time on each connection (default: 64)
|
|
16
16
|
*/
|
|
17
17
|
maxOutboundStreams?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Opt-in to running over a transient connection - one that has time/data limits
|
|
20
|
+
* placed on it.
|
|
21
|
+
*/
|
|
22
|
+
runOnTransientConnection?: boolean;
|
|
18
23
|
}
|
|
19
24
|
export interface StreamHandlerRecord {
|
|
20
25
|
handler: StreamHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-handler/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEhE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-handler/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAEhE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,CAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;OAEG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;;OAGG;IACH,wBAAwB,CAAC,EAAE,OAAO,CAAA;CACnC;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,CAAA;IACtB,OAAO,EAAE,oBAAoB,CAAA;CAC9B"}
|
|
@@ -32,9 +32,13 @@ export interface StreamMuxer extends Duplex<AsyncGenerator<Uint8Array>, Source<U
|
|
|
32
32
|
/**
|
|
33
33
|
* Close or abort all tracked streams and stop the muxer
|
|
34
34
|
*/
|
|
35
|
-
close: (
|
|
35
|
+
close: (options?: AbortOptions) => Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Close or abort all tracked streams and stop the muxer
|
|
38
|
+
*/
|
|
39
|
+
abort: (err: Error) => void;
|
|
36
40
|
}
|
|
37
|
-
export interface StreamMuxerInit
|
|
41
|
+
export interface StreamMuxerInit {
|
|
38
42
|
/**
|
|
39
43
|
* A callback function invoked every time an incoming stream is opened
|
|
40
44
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-muxer/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aA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AY,SAAQ,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,cAAc,GAAG,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACzH;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAA;IAC1B;;;OAGG;IACH,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAEtD;;OAEG;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,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAE3C;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAEtC;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
2
|
-
import type { Direction, Stream,
|
|
2
|
+
import type { Direction, ReadStatus, Stream, StreamStatus, StreamTimeline, WriteStatus } from '../connection/index.js';
|
|
3
|
+
import type { AbortOptions } from '../index.js';
|
|
3
4
|
import type { Source } from 'it-stream-types';
|
|
5
|
+
interface Logger {
|
|
6
|
+
(formatter: any, ...args: any[]): void;
|
|
7
|
+
error: (formatter: any, ...args: any[]) => void;
|
|
8
|
+
trace: (formatter: any, ...args: any[]) => void;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
}
|
|
4
11
|
export interface AbstractStreamInit {
|
|
5
12
|
/**
|
|
6
13
|
* A unique identifier for this stream
|
|
@@ -11,10 +18,9 @@ export interface AbstractStreamInit {
|
|
|
11
18
|
*/
|
|
12
19
|
direction: Direction;
|
|
13
20
|
/**
|
|
14
|
-
*
|
|
15
|
-
* chunked and sent in multiple data messages
|
|
21
|
+
* A Logger implementation used to log stream-specific information
|
|
16
22
|
*/
|
|
17
|
-
|
|
23
|
+
log: Logger;
|
|
18
24
|
/**
|
|
19
25
|
* User specific stream metadata
|
|
20
26
|
*/
|
|
@@ -23,31 +29,83 @@ export interface AbstractStreamInit {
|
|
|
23
29
|
* Invoked when the stream ends
|
|
24
30
|
*/
|
|
25
31
|
onEnd?: (err?: Error | undefined) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Invoked when the readable end of the stream is closed
|
|
34
|
+
*/
|
|
35
|
+
onCloseRead?: () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Invoked when the writable end of the stream is closed
|
|
38
|
+
*/
|
|
39
|
+
onCloseWrite?: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Invoked when the the stream has been reset by the remote
|
|
42
|
+
*/
|
|
43
|
+
onReset?: () => void;
|
|
44
|
+
/**
|
|
45
|
+
* Invoked when the the stream has errored
|
|
46
|
+
*/
|
|
47
|
+
onAbort?: (err: Error) => void;
|
|
48
|
+
/**
|
|
49
|
+
* How long to wait in ms for stream data to be written to the underlying
|
|
50
|
+
* connection when closing the writable end of the stream. (default: 500)
|
|
51
|
+
*/
|
|
52
|
+
closeTimeout?: number;
|
|
26
53
|
}
|
|
27
54
|
export declare abstract class AbstractStream implements Stream {
|
|
28
55
|
id: string;
|
|
29
|
-
|
|
56
|
+
direction: Direction;
|
|
57
|
+
timeline: StreamTimeline;
|
|
58
|
+
protocol?: string;
|
|
30
59
|
metadata: Record<string, unknown>;
|
|
31
60
|
source: AsyncGenerator<Uint8ArrayList, void, unknown>;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
private sinkSunk;
|
|
61
|
+
status: StreamStatus;
|
|
62
|
+
readStatus: ReadStatus;
|
|
63
|
+
writeStatus: WriteStatus;
|
|
64
|
+
private readonly sinkController;
|
|
65
|
+
private readonly sinkEnd;
|
|
38
66
|
private endErr;
|
|
39
67
|
private readonly streamSource;
|
|
40
68
|
private readonly onEnd?;
|
|
41
|
-
private readonly
|
|
69
|
+
private readonly onCloseRead?;
|
|
70
|
+
private readonly onCloseWrite?;
|
|
71
|
+
private readonly onReset?;
|
|
72
|
+
private readonly onAbort?;
|
|
73
|
+
protected readonly log: Logger;
|
|
42
74
|
constructor(init: AbstractStreamInit);
|
|
75
|
+
sink(source: Source<Uint8ArrayList | Uint8Array>): Promise<void>;
|
|
43
76
|
protected onSourceEnd(err?: Error): void;
|
|
44
77
|
protected onSinkEnd(err?: Error): void;
|
|
45
|
-
close(): void
|
|
46
|
-
closeRead(): void
|
|
47
|
-
closeWrite(): void
|
|
78
|
+
close(options?: AbortOptions): Promise<void>;
|
|
79
|
+
closeRead(options?: AbortOptions): Promise<void>;
|
|
80
|
+
closeWrite(options?: AbortOptions): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Close immediately for reading and writing and send a reset message (local
|
|
83
|
+
* error)
|
|
84
|
+
*/
|
|
48
85
|
abort(err: Error): void;
|
|
86
|
+
/**
|
|
87
|
+
* Receive a reset message - close immediately for reading and writing (remote
|
|
88
|
+
* error)
|
|
89
|
+
*/
|
|
49
90
|
reset(): void;
|
|
50
|
-
|
|
91
|
+
_closeSinkAndSource(err?: Error): void;
|
|
92
|
+
_closeSink(err?: Error): void;
|
|
93
|
+
_closeSource(err?: Error): void;
|
|
94
|
+
/**
|
|
95
|
+
* The remote closed for writing so we should expect to receive no more
|
|
96
|
+
* messages
|
|
97
|
+
*/
|
|
98
|
+
remoteCloseWrite(): void;
|
|
99
|
+
/**
|
|
100
|
+
* The remote closed for reading so we should not send any more
|
|
101
|
+
* messages
|
|
102
|
+
*/
|
|
103
|
+
remoteCloseRead(): void;
|
|
104
|
+
/**
|
|
105
|
+
* The underlying muxer has closed, no more messages can be sent or will
|
|
106
|
+
* be received, close immediately to free up resources
|
|
107
|
+
*/
|
|
108
|
+
destroy(): void;
|
|
51
109
|
/**
|
|
52
110
|
* When an extending class reads data from it's implementation-specific source,
|
|
53
111
|
* call this method to allow the stream consumer to read the data.
|
|
@@ -62,24 +120,25 @@ export declare abstract class AbstractStream implements Stream {
|
|
|
62
120
|
* Send a message to the remote muxer informing them a new stream is being
|
|
63
121
|
* opened
|
|
64
122
|
*/
|
|
65
|
-
abstract sendNewStream(): void | Promise<void>;
|
|
123
|
+
abstract sendNewStream(options?: AbortOptions): void | Promise<void>;
|
|
66
124
|
/**
|
|
67
125
|
* Send a data message to the remote muxer
|
|
68
126
|
*/
|
|
69
|
-
abstract sendData(buf: Uint8ArrayList): void | Promise<void>;
|
|
127
|
+
abstract sendData(buf: Uint8ArrayList, options?: AbortOptions): void | Promise<void>;
|
|
70
128
|
/**
|
|
71
129
|
* Send a reset message to the remote muxer
|
|
72
130
|
*/
|
|
73
|
-
abstract sendReset(): void | Promise<void>;
|
|
131
|
+
abstract sendReset(options?: AbortOptions): void | Promise<void>;
|
|
74
132
|
/**
|
|
75
133
|
* Send a message to the remote muxer, informing them no more data messages
|
|
76
134
|
* will be sent by this end of the stream
|
|
77
135
|
*/
|
|
78
|
-
abstract sendCloseWrite(): void | Promise<void>;
|
|
136
|
+
abstract sendCloseWrite(options?: AbortOptions): void | Promise<void>;
|
|
79
137
|
/**
|
|
80
138
|
* Send a message to the remote muxer, informing them no more data messages
|
|
81
139
|
* will be read by this end of the stream
|
|
82
140
|
*/
|
|
83
|
-
abstract sendCloseRead(): void | Promise<void>;
|
|
141
|
+
abstract sendCloseRead(options?: AbortOptions): void | Promise<void>;
|
|
84
142
|
}
|
|
143
|
+
export {};
|
|
85
144
|
//# sourceMappingURL=stream.d.ts.map
|