@libp2p/interface 0.1.2 → 0.1.3-68504939
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 +13 -13
- package/dist/src/connection/index.d.ts.map +1 -1
- package/dist/src/connection-encrypter/index.d.ts +2 -2
- package/dist/src/connection-encrypter/index.d.ts.map +1 -1
- package/dist/src/connection-gater/index.d.ts +12 -12
- package/dist/src/connection-gater/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.d.ts +4 -4
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/index.d.ts +13 -13
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/keychain/index.d.ts +11 -11
- package/dist/src/keychain/index.d.ts.map +1 -1
- package/dist/src/keys/index.d.ts +10 -10
- package/dist/src/keys/index.d.ts.map +1 -1
- package/dist/src/metrics/index.d.ts +16 -16
- package/dist/src/metrics/index.d.ts.map +1 -1
- package/dist/src/peer-id/index.d.ts +4 -4
- package/dist/src/peer-id/index.d.ts.map +1 -1
- package/dist/src/peer-routing/index.d.ts +2 -2
- package/dist/src/peer-routing/index.d.ts.map +1 -1
- package/dist/src/peer-store/index.d.ts +9 -9
- package/dist/src/peer-store/index.d.ts.map +1 -1
- package/dist/src/pubsub/index.d.ts +10 -10
- package/dist/src/pubsub/index.d.ts.map +1 -1
- package/dist/src/record/index.d.ts +5 -5
- package/dist/src/record/index.d.ts.map +1 -1
- package/dist/src/startable.d.ts +7 -7
- package/dist/src/startable.d.ts.map +1 -1
- package/dist/src/stream-muxer/index.d.ts +6 -6
- package/dist/src/stream-muxer/index.d.ts.map +1 -1
- package/dist/src/stream-muxer/stream.d.ts +13 -7
- package/dist/src/stream-muxer/stream.d.ts.map +1 -1
- package/dist/src/stream-muxer/stream.js +31 -19
- package/dist/src/stream-muxer/stream.js.map +1 -1
- package/dist/src/topology/index.d.ts +2 -2
- package/dist/src/topology/index.d.ts.map +1 -1
- package/dist/src/transport/index.d.ts +7 -7
- package/dist/src/transport/index.d.ts.map +1 -1
- package/package.json +8 -3
- package/src/connection/index.ts +13 -13
- package/src/connection-encrypter/index.ts +2 -2
- package/src/connection-gater/index.ts +12 -12
- package/src/content-routing/index.ts +4 -4
- package/src/index.ts +13 -13
- package/src/keychain/index.ts +11 -11
- package/src/keys/index.ts +10 -10
- package/src/metrics/index.ts +16 -16
- package/src/peer-id/index.ts +4 -4
- package/src/peer-routing/index.ts +2 -2
- package/src/peer-store/index.ts +9 -9
- package/src/pubsub/index.ts +10 -10
- package/src/record/index.ts +5 -5
- package/src/startable.ts +7 -7
- package/src/stream-muxer/index.ts +6 -6
- package/src/stream-muxer/stream.ts +52 -30
- package/src/topology/index.ts +2 -2
- package/src/transport/index.ts +7 -7
- package/dist/typedoc-urls.json +0 -133
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { abortableSource } from 'abortable-iterator';
|
|
2
2
|
import { pushable } from 'it-pushable';
|
|
3
3
|
import defer, {} from 'p-defer';
|
|
4
|
+
import { raceSignal } from 'race-signal';
|
|
4
5
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
5
6
|
import { CodeError } from '../errors.js';
|
|
6
7
|
const ERR_STREAM_RESET = 'ERR_STREAM_RESET';
|
|
7
8
|
const ERR_SINK_INVALID_STATE = 'ERR_SINK_INVALID_STATE';
|
|
9
|
+
const DEFAULT_SEND_CLOSE_WRITE_TIMEOUT = 5000;
|
|
8
10
|
function isPromise(res) {
|
|
9
11
|
return res != null && typeof res.then === 'function';
|
|
10
12
|
}
|
|
@@ -27,6 +29,7 @@ export class AbstractStream {
|
|
|
27
29
|
onCloseWrite;
|
|
28
30
|
onReset;
|
|
29
31
|
onAbort;
|
|
32
|
+
sendCloseWriteTimeout;
|
|
30
33
|
log;
|
|
31
34
|
constructor(init) {
|
|
32
35
|
this.sinkController = new AbortController();
|
|
@@ -42,6 +45,7 @@ export class AbstractStream {
|
|
|
42
45
|
this.timeline = {
|
|
43
46
|
open: Date.now()
|
|
44
47
|
};
|
|
48
|
+
this.sendCloseWriteTimeout = init.sendCloseWriteTimeout ?? DEFAULT_SEND_CLOSE_WRITE_TIMEOUT;
|
|
45
49
|
this.onEnd = init.onEnd;
|
|
46
50
|
this.onCloseRead = init?.onCloseRead;
|
|
47
51
|
this.onCloseWrite = init?.onCloseWrite;
|
|
@@ -55,7 +59,6 @@ export class AbstractStream {
|
|
|
55
59
|
else {
|
|
56
60
|
this.log.trace('source ended');
|
|
57
61
|
}
|
|
58
|
-
this.readStatus = 'closed';
|
|
59
62
|
this.onSourceEnd(err);
|
|
60
63
|
}
|
|
61
64
|
});
|
|
@@ -88,10 +91,15 @@ export class AbstractStream {
|
|
|
88
91
|
await res;
|
|
89
92
|
}
|
|
90
93
|
}
|
|
91
|
-
this.log.trace('sink finished reading from source');
|
|
92
|
-
this.writeStatus
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
this.log.trace('sink finished reading from source, write status is "%s"', this.writeStatus);
|
|
95
|
+
if (this.writeStatus === 'writing') {
|
|
96
|
+
this.writeStatus = 'closing';
|
|
97
|
+
this.log.trace('send close write to remote');
|
|
98
|
+
await this.sendCloseWrite({
|
|
99
|
+
signal: AbortSignal.timeout(this.sendCloseWriteTimeout)
|
|
100
|
+
});
|
|
101
|
+
this.writeStatus = 'closed';
|
|
102
|
+
}
|
|
95
103
|
this.onSinkEnd();
|
|
96
104
|
}
|
|
97
105
|
catch (err) {
|
|
@@ -109,6 +117,7 @@ export class AbstractStream {
|
|
|
109
117
|
return;
|
|
110
118
|
}
|
|
111
119
|
this.timeline.closeRead = Date.now();
|
|
120
|
+
this.readStatus = 'closed';
|
|
112
121
|
if (err != null && this.endErr == null) {
|
|
113
122
|
this.endErr = err;
|
|
114
123
|
}
|
|
@@ -116,6 +125,9 @@ export class AbstractStream {
|
|
|
116
125
|
if (this.timeline.closeWrite != null) {
|
|
117
126
|
this.log.trace('source and sink ended');
|
|
118
127
|
this.timeline.close = Date.now();
|
|
128
|
+
if (this.status !== 'aborted' && this.status !== 'reset') {
|
|
129
|
+
this.status = 'closed';
|
|
130
|
+
}
|
|
119
131
|
if (this.onEnd != null) {
|
|
120
132
|
this.onEnd(this.endErr);
|
|
121
133
|
}
|
|
@@ -129,6 +141,7 @@ export class AbstractStream {
|
|
|
129
141
|
return;
|
|
130
142
|
}
|
|
131
143
|
this.timeline.closeWrite = Date.now();
|
|
144
|
+
this.writeStatus = 'closed';
|
|
132
145
|
if (err != null && this.endErr == null) {
|
|
133
146
|
this.endErr = err;
|
|
134
147
|
}
|
|
@@ -136,6 +149,9 @@ export class AbstractStream {
|
|
|
136
149
|
if (this.timeline.closeRead != null) {
|
|
137
150
|
this.log.trace('sink and source ended');
|
|
138
151
|
this.timeline.close = Date.now();
|
|
152
|
+
if (this.status !== 'aborted' && this.status !== 'reset') {
|
|
153
|
+
this.status = 'closed';
|
|
154
|
+
}
|
|
139
155
|
if (this.onEnd != null) {
|
|
140
156
|
this.onEnd(this.endErr);
|
|
141
157
|
}
|
|
@@ -162,14 +178,14 @@ export class AbstractStream {
|
|
|
162
178
|
this.log.trace('closing readable end of stream with starting read status "%s"', this.readStatus);
|
|
163
179
|
const readStatus = this.readStatus;
|
|
164
180
|
this.readStatus = 'closing';
|
|
165
|
-
if (readStatus === 'ready') {
|
|
166
|
-
this.log.trace('ending internal source queue');
|
|
167
|
-
this.streamSource.end();
|
|
168
|
-
}
|
|
169
181
|
if (this.status !== 'reset' && this.status !== 'aborted' && this.timeline.closeRead == null) {
|
|
170
182
|
this.log.trace('send close read to remote');
|
|
171
183
|
await this.sendCloseRead(options);
|
|
172
184
|
}
|
|
185
|
+
if (readStatus === 'ready') {
|
|
186
|
+
this.log.trace('ending internal source queue');
|
|
187
|
+
this.streamSource.end();
|
|
188
|
+
}
|
|
173
189
|
this.log.trace('closed readable end of stream');
|
|
174
190
|
}
|
|
175
191
|
async closeWrite(options = {}) {
|
|
@@ -177,13 +193,11 @@ export class AbstractStream {
|
|
|
177
193
|
return;
|
|
178
194
|
}
|
|
179
195
|
this.log.trace('closing writable end of stream with starting write status "%s"', this.writeStatus);
|
|
180
|
-
const writeStatus = this.writeStatus;
|
|
181
196
|
if (this.writeStatus === 'ready') {
|
|
182
197
|
this.log.trace('sink was never sunk, sink an empty array');
|
|
183
|
-
await this.sink([]);
|
|
198
|
+
await raceSignal(this.sink([]), options.signal);
|
|
184
199
|
}
|
|
185
|
-
this.writeStatus
|
|
186
|
-
if (writeStatus === 'writing') {
|
|
200
|
+
if (this.writeStatus === 'writing') {
|
|
187
201
|
// stop reading from the source passed to `.sink` in the microtask queue
|
|
188
202
|
// - this lets any data queued by the user in the current tick get read
|
|
189
203
|
// before we exit
|
|
@@ -191,14 +205,11 @@ export class AbstractStream {
|
|
|
191
205
|
queueMicrotask(() => {
|
|
192
206
|
this.log.trace('aborting source passed to .sink');
|
|
193
207
|
this.sinkController.abort();
|
|
194
|
-
this.sinkEnd.promise
|
|
208
|
+
raceSignal(this.sinkEnd.promise, options.signal)
|
|
209
|
+
.then(resolve, reject);
|
|
195
210
|
});
|
|
196
211
|
});
|
|
197
212
|
}
|
|
198
|
-
if (this.status !== 'reset' && this.status !== 'aborted' && this.timeline.closeWrite == null) {
|
|
199
|
-
this.log.trace('send close write to remote');
|
|
200
|
-
await this.sendCloseWrite(options);
|
|
201
|
-
}
|
|
202
213
|
this.writeStatus = 'closed';
|
|
203
214
|
this.log.trace('closed writable end of stream');
|
|
204
215
|
}
|
|
@@ -234,6 +245,7 @@ export class AbstractStream {
|
|
|
234
245
|
}
|
|
235
246
|
const err = new CodeError('stream reset', ERR_STREAM_RESET);
|
|
236
247
|
this.status = 'reset';
|
|
248
|
+
this.timeline.reset = Date.now();
|
|
237
249
|
this._closeSinkAndSource(err);
|
|
238
250
|
this.onReset?.();
|
|
239
251
|
}
|
|
@@ -290,7 +302,7 @@ export class AbstractStream {
|
|
|
290
302
|
this.log('received destroy but we are already closed');
|
|
291
303
|
return;
|
|
292
304
|
}
|
|
293
|
-
this.log.trace('
|
|
305
|
+
this.log.trace('stream destroyed');
|
|
294
306
|
this._closeSinkAndSource();
|
|
295
307
|
}
|
|
296
308
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/stream-muxer/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,EAAwB,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/stream-muxer/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,EAAwB,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAaxC,MAAM,gBAAgB,GAAG,kBAAkB,CAAA;AAC3C,MAAM,sBAAsB,GAAG,wBAAwB,CAAA;AACvD,MAAM,gCAAgC,GAAG,IAAI,CAAA;AA6D7C,SAAS,SAAS,CAAE,GAAS;IAC3B,OAAO,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAA;AACtD,CAAC;AAED,MAAM,OAAgB,cAAc;IAC3B,EAAE,CAAQ;IACV,SAAS,CAAW;IACpB,QAAQ,CAAgB;IACxB,QAAQ,CAAS;IACjB,QAAQ,CAAyB;IACjC,MAAM,CAA+C;IACrD,MAAM,CAAc;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CAAC,YAAY,EAAE,CAAA;IACrB,CAAC;IAED;;;OAGG;IACH,eAAe;QACb,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,IAAI,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE;YACnE,IAAI,CAAC,GAAG,CAAC,6DAA6D,CAAC,CAAA;YACvE,OAAM;SACP;QAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;QACnC,IAAI,CAAC,UAAU,EAAE,CAAA;IACnB,CAAC;IAED;;;OAGG;IACH,OAAO;QACL,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,MAAM,KAAK,OAAO,EAAE;YACpF,IAAI,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAA;YACtD,OAAM;SACP;QAED,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAA;QAElC,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAED;;;OAGG;IACH,UAAU,CAAE,IAAoB;QAC9B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAED;;;OAGG;IACH,oBAAoB;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,CAAA;IACzC,CAAC;CA6BF"}
|
|
@@ -3,7 +3,7 @@ import type { PeerId } from '../peer-id/index.js';
|
|
|
3
3
|
export interface Topology {
|
|
4
4
|
min?: number;
|
|
5
5
|
max?: number;
|
|
6
|
-
onConnect
|
|
7
|
-
onDisconnect
|
|
6
|
+
onConnect?(peerId: PeerId, conn: Connection): void;
|
|
7
|
+
onDisconnect?(peerId: PeerId): void;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/topology/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/topology/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAClD,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC"}
|
|
@@ -13,17 +13,17 @@ export interface Listener extends EventEmitter<ListenerEvents> {
|
|
|
13
13
|
/**
|
|
14
14
|
* Start a listener
|
|
15
15
|
*/
|
|
16
|
-
listen
|
|
16
|
+
listen(multiaddr: Multiaddr): Promise<void>;
|
|
17
17
|
/**
|
|
18
18
|
* Get listen addresses
|
|
19
19
|
*/
|
|
20
|
-
getAddrs
|
|
20
|
+
getAddrs(): Multiaddr[];
|
|
21
21
|
/**
|
|
22
22
|
* Close listener
|
|
23
23
|
*
|
|
24
24
|
* @returns {Promise<void>}
|
|
25
25
|
*/
|
|
26
|
-
close
|
|
26
|
+
close(): Promise<void>;
|
|
27
27
|
}
|
|
28
28
|
export declare const symbol: unique symbol;
|
|
29
29
|
export interface ConnectionHandler {
|
|
@@ -54,11 +54,11 @@ export interface Transport {
|
|
|
54
54
|
/**
|
|
55
55
|
* Dial a given multiaddr.
|
|
56
56
|
*/
|
|
57
|
-
dial
|
|
57
|
+
dial(ma: Multiaddr, options: DialOptions): Promise<Connection>;
|
|
58
58
|
/**
|
|
59
59
|
* Create transport listeners.
|
|
60
60
|
*/
|
|
61
|
-
createListener
|
|
61
|
+
createListener(options: CreateListenerOptions): Listener;
|
|
62
62
|
/**
|
|
63
63
|
* Takes a list of `Multiaddr`s and returns only valid addresses for the transport
|
|
64
64
|
*/
|
|
@@ -92,10 +92,10 @@ export interface Upgrader {
|
|
|
92
92
|
/**
|
|
93
93
|
* Upgrades an outbound connection on `transport.dial`.
|
|
94
94
|
*/
|
|
95
|
-
upgradeOutbound
|
|
95
|
+
upgradeOutbound(maConn: MultiaddrConnection, opts?: UpgraderOptions): Promise<Connection>;
|
|
96
96
|
/**
|
|
97
97
|
* Upgrades an inbound connection on transport listener.
|
|
98
98
|
*/
|
|
99
|
-
upgradeInbound
|
|
99
|
+
upgradeInbound(maConn: MultiaddrConnection, opts?: UpgraderOptions): Promise<Connection>;
|
|
100
100
|
}
|
|
101
101
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,WAAW,CAAC,UAAU,CAAC,CAAA;IACrC,WAAW,EAAE,WAAW,CAAA;IACxB,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,CAAA;IAC3B,OAAO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939",
|
|
4
4
|
"description": "The interface implemented by a libp2p node",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/interface#readme",
|
|
@@ -140,6 +140,7 @@
|
|
|
140
140
|
"eslintConfig": {
|
|
141
141
|
"extends": "ipfs",
|
|
142
142
|
"parserOptions": {
|
|
143
|
+
"project": true,
|
|
143
144
|
"sourceType": "module"
|
|
144
145
|
}
|
|
145
146
|
},
|
|
@@ -163,12 +164,16 @@
|
|
|
163
164
|
"it-stream-types": "^2.0.1",
|
|
164
165
|
"multiformats": "^12.0.1",
|
|
165
166
|
"p-defer": "^4.0.0",
|
|
167
|
+
"race-signal": "^1.0.0",
|
|
166
168
|
"uint8arraylist": "^2.4.3"
|
|
167
169
|
},
|
|
168
170
|
"devDependencies": {
|
|
169
171
|
"@types/sinon": "^10.0.15",
|
|
170
|
-
"aegir": "^
|
|
171
|
-
"
|
|
172
|
+
"aegir": "^41.0.2",
|
|
173
|
+
"delay": "^6.0.0",
|
|
174
|
+
"it-all": "^3.0.3",
|
|
175
|
+
"it-drain": "^3.0.3",
|
|
176
|
+
"sinon": "^17.0.0",
|
|
172
177
|
"sinon-ts": "^1.0.0"
|
|
173
178
|
}
|
|
174
179
|
}
|
package/src/connection/index.ts
CHANGED
|
@@ -101,7 +101,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
101
101
|
*
|
|
102
102
|
* The sink and the source will return normally.
|
|
103
103
|
*/
|
|
104
|
-
close
|
|
104
|
+
close(options?: AbortOptions): Promise<void>
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* 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.
|
|
@@ -110,14 +110,14 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
110
110
|
*
|
|
111
111
|
* The source will return normally, the sink will continue to consume.
|
|
112
112
|
*/
|
|
113
|
-
closeRead
|
|
113
|
+
closeRead(options?: AbortOptions): Promise<void>
|
|
114
114
|
|
|
115
115
|
/**
|
|
116
116
|
* 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.
|
|
117
117
|
*
|
|
118
118
|
* The source will return normally, the sink will continue to consume.
|
|
119
119
|
*/
|
|
120
|
-
closeWrite
|
|
120
|
+
closeWrite(options?: AbortOptions): Promise<void>
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* Closes the stream for **reading** *and* **writing**. This should be called when a *local error* has occurred.
|
|
@@ -128,7 +128,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
128
128
|
*
|
|
129
129
|
* The sink will return and the source will throw if an error is passed or return normally if not.
|
|
130
130
|
*/
|
|
131
|
-
abort
|
|
131
|
+
abort(err: Error): void
|
|
132
132
|
|
|
133
133
|
/**
|
|
134
134
|
* Unique identifier for a stream. Identifiers are not unique across muxers.
|
|
@@ -146,7 +146,7 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
|
|
|
146
146
|
timeline: StreamTimeline
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
149
|
+
* The protocol negotiated for this stream
|
|
150
150
|
*/
|
|
151
151
|
protocol?: string
|
|
152
152
|
|
|
@@ -231,12 +231,12 @@ export interface Connection {
|
|
|
231
231
|
timeline: ConnectionTimeline
|
|
232
232
|
|
|
233
233
|
/**
|
|
234
|
-
*
|
|
234
|
+
* The multiplexer negotiated for this connection
|
|
235
235
|
*/
|
|
236
236
|
multiplexer?: string
|
|
237
237
|
|
|
238
238
|
/**
|
|
239
|
-
*
|
|
239
|
+
* The encryption protocol negotiated for this connection
|
|
240
240
|
*/
|
|
241
241
|
encryption?: string
|
|
242
242
|
|
|
@@ -256,18 +256,18 @@ export interface Connection {
|
|
|
256
256
|
/**
|
|
257
257
|
* Create a new stream on this connection and negotiate one of the passed protocols
|
|
258
258
|
*/
|
|
259
|
-
newStream
|
|
259
|
+
newStream(protocols: string | string[], options?: NewStreamOptions): Promise<Stream>
|
|
260
260
|
|
|
261
261
|
/**
|
|
262
262
|
* Gracefully close the connection. All queued data will be written to the
|
|
263
263
|
* underlying transport.
|
|
264
264
|
*/
|
|
265
|
-
close
|
|
265
|
+
close(options?: AbortOptions): Promise<void>
|
|
266
266
|
|
|
267
267
|
/**
|
|
268
268
|
* Immediately close the connection, any queued data will be discarded
|
|
269
269
|
*/
|
|
270
|
-
abort
|
|
270
|
+
abort(err: Error): void
|
|
271
271
|
}
|
|
272
272
|
|
|
273
273
|
export const symbol = Symbol.for('@libp2p/connection')
|
|
@@ -282,7 +282,7 @@ export interface ConnectionProtector {
|
|
|
282
282
|
* between its two peers from the PSK the Protector instance was
|
|
283
283
|
* created with.
|
|
284
284
|
*/
|
|
285
|
-
protect
|
|
285
|
+
protect(connection: MultiaddrConnection): Promise<MultiaddrConnection>
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
export interface MultiaddrConnectionTimeline {
|
|
@@ -313,12 +313,12 @@ export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>,
|
|
|
313
313
|
* Gracefully close the connection. All queued data will be written to the
|
|
314
314
|
* underlying transport.
|
|
315
315
|
*/
|
|
316
|
-
close
|
|
316
|
+
close(options?: AbortOptions): Promise<void>
|
|
317
317
|
|
|
318
318
|
/**
|
|
319
319
|
* Immediately close the connection, any queued data will be discarded
|
|
320
320
|
*/
|
|
321
|
-
abort
|
|
321
|
+
abort(err: Error): void
|
|
322
322
|
|
|
323
323
|
/**
|
|
324
324
|
* The address of the remote end of the connection
|
|
@@ -13,14 +13,14 @@ export interface ConnectionEncrypter<Extension = unknown> {
|
|
|
13
13
|
* pass it for extra verification, otherwise it will be determined during
|
|
14
14
|
* the handshake.
|
|
15
15
|
*/
|
|
16
|
-
secureOutbound
|
|
16
|
+
secureOutbound(localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId): Promise<SecuredConnection<Extension>>
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Decrypt incoming data. If the remote PeerId is known,
|
|
20
20
|
* pass it for extra verification, otherwise it will be determined during
|
|
21
21
|
* the handshake
|
|
22
22
|
*/
|
|
23
|
-
secureInbound
|
|
23
|
+
secureInbound(localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId): Promise<SecuredConnection<Extension>>
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface SecuredConnection<Extension = unknown> {
|
|
@@ -12,7 +12,7 @@ export interface ConnectionGater {
|
|
|
12
12
|
*
|
|
13
13
|
* Return true to prevent dialing the passed peer.
|
|
14
14
|
*/
|
|
15
|
-
denyDialPeer
|
|
15
|
+
denyDialPeer?(peerId: PeerId): Promise<boolean>
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* denyDialMultiaddr tests whether we're permitted to dial the specified
|
|
@@ -23,7 +23,7 @@ export interface ConnectionGater {
|
|
|
23
23
|
*
|
|
24
24
|
* Return true to prevent dialing the passed peer on the passed multiaddr.
|
|
25
25
|
*/
|
|
26
|
-
denyDialMultiaddr
|
|
26
|
+
denyDialMultiaddr?(multiaddr: Multiaddr): Promise<boolean>
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* denyInboundConnection tests whether an incipient inbound connection is allowed.
|
|
@@ -33,7 +33,7 @@ export interface ConnectionGater {
|
|
|
33
33
|
*
|
|
34
34
|
* Return true to deny the incoming passed connection.
|
|
35
35
|
*/
|
|
36
|
-
denyInboundConnection
|
|
36
|
+
denyInboundConnection?(maConn: MultiaddrConnection): Promise<boolean>
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* denyOutboundConnection tests whether an incipient outbound connection is allowed.
|
|
@@ -43,7 +43,7 @@ export interface ConnectionGater {
|
|
|
43
43
|
*
|
|
44
44
|
* Return true to deny the incoming passed connection.
|
|
45
45
|
*/
|
|
46
|
-
denyOutboundConnection
|
|
46
|
+
denyOutboundConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* denyInboundEncryptedConnection tests whether a given connection, now encrypted,
|
|
@@ -55,7 +55,7 @@ export interface ConnectionGater {
|
|
|
55
55
|
*
|
|
56
56
|
* Return true to deny the passed secured connection.
|
|
57
57
|
*/
|
|
58
|
-
denyInboundEncryptedConnection
|
|
58
|
+
denyInboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* denyOutboundEncryptedConnection tests whether a given connection, now encrypted,
|
|
@@ -67,7 +67,7 @@ export interface ConnectionGater {
|
|
|
67
67
|
*
|
|
68
68
|
* Return true to deny the passed secured connection.
|
|
69
69
|
*/
|
|
70
|
-
denyOutboundEncryptedConnection
|
|
70
|
+
denyOutboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* denyInboundUpgradedConnection tests whether a fully capable connection is allowed.
|
|
@@ -77,7 +77,7 @@ export interface ConnectionGater {
|
|
|
77
77
|
*
|
|
78
78
|
* Return true to deny the passed upgraded connection.
|
|
79
79
|
*/
|
|
80
|
-
denyInboundUpgradedConnection
|
|
80
|
+
denyInboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* denyOutboundUpgradedConnection tests whether a fully capable connection is allowed.
|
|
@@ -87,7 +87,7 @@ export interface ConnectionGater {
|
|
|
87
87
|
*
|
|
88
88
|
* Return true to deny the passed upgraded connection.
|
|
89
89
|
*/
|
|
90
|
-
denyOutboundUpgradedConnection
|
|
90
|
+
denyOutboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* denyInboundRelayReservation tests whether a remote peer is allowed make a
|
|
@@ -95,7 +95,7 @@ export interface ConnectionGater {
|
|
|
95
95
|
*
|
|
96
96
|
* Return true to deny the relay reservation.
|
|
97
97
|
*/
|
|
98
|
-
denyInboundRelayReservation
|
|
98
|
+
denyInboundRelayReservation?(source: PeerId): Promise<boolean>
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* denyOutboundRelayedConnection tests whether a remote peer is allowed to open a relayed
|
|
@@ -106,7 +106,7 @@ export interface ConnectionGater {
|
|
|
106
106
|
*
|
|
107
107
|
* Return true to deny the relayed connection.
|
|
108
108
|
*/
|
|
109
|
-
denyOutboundRelayedConnection
|
|
109
|
+
denyOutboundRelayedConnection?(source: PeerId, destination: PeerId): Promise<boolean>
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* denyInboundRelayedConnection tests whether a remote peer is allowed to open a relayed
|
|
@@ -117,12 +117,12 @@ export interface ConnectionGater {
|
|
|
117
117
|
*
|
|
118
118
|
* Return true to deny the relayed connection.
|
|
119
119
|
*/
|
|
120
|
-
denyInboundRelayedConnection
|
|
120
|
+
denyInboundRelayedConnection?(relay: PeerId, remotePeer: PeerId): Promise<boolean>
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* Used by the address book to filter passed addresses.
|
|
124
124
|
*
|
|
125
125
|
* Return true to allow storing the passed multiaddr for the passed peer.
|
|
126
126
|
*/
|
|
127
|
-
filterMultiaddrForPeer
|
|
127
|
+
filterMultiaddrForPeer?(peer: PeerId, multiaddr: Multiaddr): Promise<boolean>
|
|
128
128
|
}
|
|
@@ -35,7 +35,7 @@ export interface ContentRouting {
|
|
|
35
35
|
* await contentRouting.provide(cid)
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
provide
|
|
38
|
+
provide(cid: CID, options?: AbortOptions): Promise<void>
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Find the providers of the passed CID.
|
|
@@ -49,7 +49,7 @@ export interface ContentRouting {
|
|
|
49
49
|
* }
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
|
-
findProviders
|
|
52
|
+
findProviders(cid: CID, options?: AbortOptions): AsyncIterable<PeerInfo>
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Puts a value corresponding to the passed key in a way that can later be
|
|
@@ -65,7 +65,7 @@ export interface ContentRouting {
|
|
|
65
65
|
* await contentRouting.put(key, value)
|
|
66
66
|
* ```
|
|
67
67
|
*/
|
|
68
|
-
put
|
|
68
|
+
put(key: Uint8Array, value: Uint8Array, options?: AbortOptions): Promise<void>
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Retrieves a value from the network corresponding to the passed key.
|
|
@@ -79,5 +79,5 @@ export interface ContentRouting {
|
|
|
79
79
|
* const value = await contentRouting.get(key)
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
|
-
get
|
|
82
|
+
get(key: Uint8Array, options?: AbortOptions): Promise<Uint8Array>
|
|
83
83
|
}
|