@libp2p/webtransport 3.1.10 → 4.0.0-06e6d235f
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/README.md +1 -5
- package/dist/index.min.js +10 -10
- package/dist/src/index.d.ts +2 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +28 -21
- package/dist/src/index.js.map +1 -1
- package/dist/src/stream.d.ts +2 -2
- package/dist/src/stream.d.ts.map +1 -1
- package/dist/src/stream.js +4 -4
- package/dist/src/stream.js.map +1 -1
- package/dist/src/utils/parse-multiaddr.d.ts +1 -1
- package/dist/src/utils/parse-multiaddr.d.ts.map +1 -1
- package/dist/src/utils/parse-multiaddr.js +1 -1
- package/dist/src/utils/parse-multiaddr.js.map +1 -1
- package/package.json +15 -27
- package/src/index.ts +44 -27
- package/src/stream.ts +5 -7
- package/src/utils/parse-multiaddr.ts +2 -2
- package/dist/typedoc-urls.json +0 -10
package/dist/src/index.d.ts
CHANGED
|
@@ -20,15 +20,14 @@
|
|
|
20
20
|
* })
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
import { type Transport } from '@libp2p/interface
|
|
24
|
-
import type { CounterGroup, Metrics } from '@libp2p/interface/metrics';
|
|
25
|
-
import type { PeerId } from '@libp2p/interface/peer-id';
|
|
23
|
+
import { type Transport, type ComponentLogger, type CounterGroup, type Metrics, type PeerId } from '@libp2p/interface';
|
|
26
24
|
export interface WebTransportInit {
|
|
27
25
|
maxInboundStreams?: number;
|
|
28
26
|
}
|
|
29
27
|
export interface WebTransportComponents {
|
|
30
28
|
peerId: PeerId;
|
|
31
29
|
metrics?: Metrics;
|
|
30
|
+
logger: ComponentLogger;
|
|
32
31
|
}
|
|
33
32
|
export interface WebTransportMetrics {
|
|
34
33
|
dialerEvents: CounterGroup;
|
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;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,KAAK,SAAS,EAAgF,KAAK,eAAe,EAAuE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,MAAM,EAAmE,MAAM,mBAAmB,CAAA;AAe1U,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,EAAE,eAAe,CAAA;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,YAAY,CAAA;CAC3B;AAqUD,wBAAgB,YAAY,CAAE,IAAI,GAAE,gBAAqB,GAAG,CAAC,UAAU,EAAE,sBAAsB,KAAK,SAAS,CAE5G"}
|
package/dist/src/index.js
CHANGED
|
@@ -21,20 +21,20 @@
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
import { noise } from '@chainsafe/libp2p-noise';
|
|
24
|
-
import {
|
|
25
|
-
import { logger } from '@libp2p/logger';
|
|
24
|
+
import { transportSymbol } from '@libp2p/interface';
|
|
26
25
|
import {} from '@multiformats/multiaddr';
|
|
27
26
|
import { WebTransport as WebTransportMatcher } from '@multiformats/multiaddr-matcher';
|
|
28
27
|
import { webtransportBiDiStreamToStream } from './stream.js';
|
|
29
28
|
import { inertDuplex } from './utils/inert-duplex.js';
|
|
30
29
|
import { isSubset } from './utils/is-subset.js';
|
|
31
30
|
import { parseMultiaddr } from './utils/parse-multiaddr.js';
|
|
32
|
-
const log = logger('libp2p:webtransport');
|
|
33
31
|
class WebTransportTransport {
|
|
32
|
+
log;
|
|
34
33
|
components;
|
|
35
34
|
config;
|
|
36
35
|
metrics;
|
|
37
36
|
constructor(components, init = {}) {
|
|
37
|
+
this.log = components.logger.forComponent('libp2p:webtransport');
|
|
38
38
|
this.components = components;
|
|
39
39
|
this.config = {
|
|
40
40
|
maxInboundStreams: init.maxInboundStreams ?? 1000
|
|
@@ -49,10 +49,10 @@ class WebTransportTransport {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
[Symbol.toStringTag] = '@libp2p/webtransport';
|
|
52
|
-
[
|
|
52
|
+
[transportSymbol] = true;
|
|
53
53
|
async dial(ma, options) {
|
|
54
54
|
options?.signal?.throwIfAborted();
|
|
55
|
-
log('dialing %s', ma);
|
|
55
|
+
this.log('dialing %s', ma);
|
|
56
56
|
const localPeer = this.components.peerId;
|
|
57
57
|
if (localPeer === undefined) {
|
|
58
58
|
throw new Error('Need a local peerid');
|
|
@@ -89,7 +89,7 @@ class WebTransportTransport {
|
|
|
89
89
|
wt.close();
|
|
90
90
|
}
|
|
91
91
|
catch (err) {
|
|
92
|
-
log.error('error closing wt session', err);
|
|
92
|
+
this.log.error('error closing wt session', err);
|
|
93
93
|
}
|
|
94
94
|
finally {
|
|
95
95
|
// This is how we specify the connection is closed and shouldn't be used.
|
|
@@ -119,7 +119,7 @@ class WebTransportTransport {
|
|
|
119
119
|
this.metrics?.dialerEvents.increment({ ready: true });
|
|
120
120
|
// this promise resolves/throws when the session is closed
|
|
121
121
|
wt.closed.catch((err) => {
|
|
122
|
-
log.error('error on remote wt session close', err);
|
|
122
|
+
this.log.error('error on remote wt session close', err);
|
|
123
123
|
})
|
|
124
124
|
.finally(() => {
|
|
125
125
|
cleanUpWTSession('remote_close');
|
|
@@ -130,17 +130,18 @@ class WebTransportTransport {
|
|
|
130
130
|
this.metrics?.dialerEvents.increment({ open: true });
|
|
131
131
|
maConn = {
|
|
132
132
|
close: async () => {
|
|
133
|
-
log('Closing webtransport');
|
|
133
|
+
this.log('Closing webtransport');
|
|
134
134
|
cleanUpWTSession('close');
|
|
135
135
|
},
|
|
136
136
|
abort: (err) => {
|
|
137
|
-
log('aborting webtransport due to passed err', err);
|
|
137
|
+
this.log('aborting webtransport due to passed err', err);
|
|
138
138
|
cleanUpWTSession('abort');
|
|
139
139
|
},
|
|
140
140
|
remoteAddr: ma,
|
|
141
141
|
timeline: {
|
|
142
142
|
open: Date.now()
|
|
143
143
|
},
|
|
144
|
+
log: this.components.logger.forComponent('libp2p:webtransport:maconn'),
|
|
144
145
|
// This connection is never used directly since webtransport supports native streams.
|
|
145
146
|
...inertDuplex()
|
|
146
147
|
};
|
|
@@ -148,7 +149,7 @@ class WebTransportTransport {
|
|
|
148
149
|
return await options.upgrader.upgradeOutbound(maConn, { skipEncryption: true, muxerFactory: this.webtransportMuxer(wt), skipProtection: true });
|
|
149
150
|
}
|
|
150
151
|
catch (err) {
|
|
151
|
-
log.error('caught wt session err', err);
|
|
152
|
+
this.log.error('caught wt session err', err);
|
|
152
153
|
if (authenticated) {
|
|
153
154
|
cleanUpWTSession('upgrade_error');
|
|
154
155
|
}
|
|
@@ -185,18 +186,23 @@ class WebTransportTransport {
|
|
|
185
186
|
})(),
|
|
186
187
|
sink: async function (source) {
|
|
187
188
|
for await (const chunk of source) {
|
|
188
|
-
|
|
189
|
+
if (chunk instanceof Uint8Array) {
|
|
190
|
+
await writer.write(chunk);
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
await writer.write(chunk.subarray());
|
|
194
|
+
}
|
|
189
195
|
}
|
|
190
196
|
}
|
|
191
197
|
};
|
|
192
|
-
const n = noise()();
|
|
198
|
+
const n = noise()(this.components);
|
|
193
199
|
const { remoteExtensions } = await n.secureOutbound(localPeer, duplex, remotePeer);
|
|
194
200
|
// We're done with this authentication stream
|
|
195
201
|
writer.close().catch((err) => {
|
|
196
|
-
log.error(`Failed to close authentication stream writer: ${err.message}`);
|
|
202
|
+
this.log.error(`Failed to close authentication stream writer: ${err.message}`);
|
|
197
203
|
});
|
|
198
204
|
reader.cancel().catch((err) => {
|
|
199
|
-
log.error(`Failed to close authentication stream reader: ${err.message}`);
|
|
205
|
+
this.log.error(`Failed to close authentication stream reader: ${err.message}`);
|
|
200
206
|
});
|
|
201
207
|
// Verify the certhashes we used when dialing are a subset of the certhashes relayed by the remote peer
|
|
202
208
|
if (!isSubset(remoteExtensions?.webtransportCerthashes ?? [], certhashes.map(ch => ch.bytes))) {
|
|
@@ -207,6 +213,7 @@ class WebTransportTransport {
|
|
|
207
213
|
webtransportMuxer(wt) {
|
|
208
214
|
let streamIDCounter = 0;
|
|
209
215
|
const config = this.config;
|
|
216
|
+
const self = this;
|
|
210
217
|
return {
|
|
211
218
|
protocol: 'webtransport',
|
|
212
219
|
createStreamMuxer: (init) => {
|
|
@@ -227,27 +234,27 @@ class WebTransportTransport {
|
|
|
227
234
|
if (activeStreams.length >= config.maxInboundStreams) {
|
|
228
235
|
// We've reached our limit, close this stream.
|
|
229
236
|
wtStream.writable.close().catch((err) => {
|
|
230
|
-
log.error(`Failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`);
|
|
237
|
+
self.log.error(`Failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`);
|
|
231
238
|
});
|
|
232
239
|
wtStream.readable.cancel().catch((err) => {
|
|
233
|
-
log.error(`Failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`);
|
|
240
|
+
self.log.error(`Failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`);
|
|
234
241
|
});
|
|
235
242
|
}
|
|
236
243
|
else {
|
|
237
|
-
const stream = await webtransportBiDiStreamToStream(wtStream, String(streamIDCounter++), 'inbound', activeStreams, init?.onStreamEnd);
|
|
244
|
+
const stream = await webtransportBiDiStreamToStream(wtStream, String(streamIDCounter++), 'inbound', activeStreams, init?.onStreamEnd, self.components.logger);
|
|
238
245
|
activeStreams.push(stream);
|
|
239
246
|
init?.onIncomingStream?.(stream);
|
|
240
247
|
}
|
|
241
248
|
}
|
|
242
249
|
})().catch(() => {
|
|
243
|
-
log.error('WebTransport failed to receive incoming stream');
|
|
250
|
+
this.log.error('WebTransport failed to receive incoming stream');
|
|
244
251
|
});
|
|
245
252
|
const muxer = {
|
|
246
253
|
protocol: 'webtransport',
|
|
247
254
|
streams: activeStreams,
|
|
248
255
|
newStream: async (name) => {
|
|
249
256
|
const wtStream = await wt.createBidirectionalStream();
|
|
250
|
-
const stream = await webtransportBiDiStreamToStream(wtStream, String(streamIDCounter++), init?.direction ?? 'outbound', activeStreams, init?.onStreamEnd);
|
|
257
|
+
const stream = await webtransportBiDiStreamToStream(wtStream, String(streamIDCounter++), init?.direction ?? 'outbound', activeStreams, init?.onStreamEnd, self.components.logger);
|
|
251
258
|
activeStreams.push(stream);
|
|
252
259
|
return stream;
|
|
253
260
|
},
|
|
@@ -255,11 +262,11 @@ class WebTransportTransport {
|
|
|
255
262
|
* Close or abort all tracked streams and stop the muxer
|
|
256
263
|
*/
|
|
257
264
|
close: async (options) => {
|
|
258
|
-
log('Closing webtransport muxer');
|
|
265
|
+
this.log('Closing webtransport muxer');
|
|
259
266
|
await Promise.all(activeStreams.map(async (s) => s.close(options)));
|
|
260
267
|
},
|
|
261
268
|
abort: (err) => {
|
|
262
|
-
log('Aborting webtransport muxer with err:', err);
|
|
269
|
+
this.log('Aborting webtransport muxer with err:', err);
|
|
263
270
|
for (const stream of activeStreams) {
|
|
264
271
|
stream.abort(err);
|
|
265
272
|
}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC/C,OAAO,EAAkB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAA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D,KAAK,MAAM,MAAM,IAAI,aAAa,EAAE,CAAC;4BACnC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;wBACnB,CAAC;oBACH,CAAC;oBACD,gGAAgG;oBAChG,GAAG,WAAW,EAAE;iBACjB,CAAA;gBAED,OAAO,KAAK,CAAA;YACd,CAAC;SACF,CAAA;IACH,CAAC;IAED,cAAc,CAAE,OAA8B;QAC5C,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;IAClF,CAAC;IAED;;OAEG;IACH,MAAM,CAAE,UAAuB;QAC7B,OAAO,UAAU,CAAC,MAAM,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAC1D,CAAC;CACF;AAED,MAAM,UAAU,YAAY,CAAE,OAAyB,EAAE;IACvD,OAAO,CAAC,UAAkC,EAAE,EAAE,CAAC,IAAI,qBAAqB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAC5F,CAAC"}
|
package/dist/src/stream.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Direction, Stream } from '@libp2p/interface
|
|
2
|
-
export declare function webtransportBiDiStreamToStream(bidiStream: WebTransportBidirectionalStream, streamId: string, direction: Direction, activeStreams: Stream[], onStreamEnd: undefined | ((s: Stream) => void)): Promise<Stream>;
|
|
1
|
+
import type { ComponentLogger, Direction, Stream } from '@libp2p/interface';
|
|
2
|
+
export declare function webtransportBiDiStreamToStream(bidiStream: WebTransportBidirectionalStream, streamId: string, direction: Direction, activeStreams: Stream[], onStreamEnd: undefined | ((s: Stream) => void), logger: ComponentLogger): Promise<Stream>;
|
|
3
3
|
//# sourceMappingURL=stream.d.ts.map
|
package/dist/src/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAgB,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAGzF,wBAAsB,8BAA8B,CAAE,UAAU,EAAE,+BAA+B,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAmL5P"}
|
package/dist/src/stream.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { logger } from '@libp2p/logger';
|
|
2
1
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export async function webtransportBiDiStreamToStream(bidiStream, streamId, direction, activeStreams, onStreamEnd, logger) {
|
|
3
|
+
const log = logger.forComponent(`libp2p:webtransport:stream:${direction}:${streamId}`);
|
|
5
4
|
const writer = bidiStream.writable.getWriter();
|
|
6
5
|
const reader = bidiStream.readable.getReader();
|
|
7
6
|
await writer.ready;
|
|
@@ -154,7 +153,8 @@ export async function webtransportBiDiStreamToStream(bidiStream, streamId, direc
|
|
|
154
153
|
this.writeStatus = 'closed';
|
|
155
154
|
await stream.closeWrite();
|
|
156
155
|
}
|
|
157
|
-
}
|
|
156
|
+
},
|
|
157
|
+
log
|
|
158
158
|
};
|
|
159
159
|
return stream;
|
|
160
160
|
}
|
package/dist/src/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAI/C,MAAM,CAAC,KA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AAC;QACH,CAAC,CAAC,EAAE;QACJ,IAAI,EAAE,KAAK,WAAW,MAA2C;YAC/D,IAAI,QAAQ,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;YAClD,CAAC;YACD,QAAQ,GAAG,IAAI,CAAA;YACf,IAAI,CAAC;gBACH,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;gBAE5B,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,MAAM,EAAE,CAAC;oBAClC,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;wBACjC,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;oBAC5B,CAAC;yBAAM,CAAC;wBACN,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;4BACzB,MAAM,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;wBACzB,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,IAAI,CAAC,WAAW,GAAG,MAAM,CAAA;YAC3B,CAAC;oBAAS,CAAC;gBACT,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;gBACrC,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAA;gBAE3B,MAAM,MAAM,CAAC,UAAU,EAAE,CAAA;YAC3B,CAAC;QACH,CAAC;QACD,GAAG;KACJ,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Multiaddr } from '@multiformats/multiaddr';
|
|
2
|
-
import type { PeerId } from '@libp2p/interface
|
|
2
|
+
import type { PeerId } from '@libp2p/interface';
|
|
3
3
|
import type { MultihashDigest } from 'multiformats/hashes/interface';
|
|
4
4
|
export interface ParsedMultiaddr {
|
|
5
5
|
url: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-multiaddr.d.ts","sourceRoot":"","sources":["../../../src/utils/parse-multiaddr.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,yBAAyB,CAAA;AAGnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"parse-multiaddr.d.ts","sourceRoot":"","sources":["../../../src/utils/parse-multiaddr.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,yBAAyB,CAAA;AAGnE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AASpE,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,eAAe,EAAE,CAAA;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,wBAAgB,cAAc,CAAE,EAAE,EAAE,SAAS,GAAG,eAAe,CAoC9D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
1
|
+
import { CodeError } from '@libp2p/interface';
|
|
2
2
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
3
3
|
import { protocols } from '@multiformats/multiaddr';
|
|
4
4
|
import { WebTransport } from '@multiformats/multiaddr-matcher';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-multiaddr.js","sourceRoot":"","sources":["../../../src/utils/parse-multiaddr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"parse-multiaddr.js","sourceRoot":"","sources":["../../../src/utils/parse-multiaddr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAkB,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,iC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C,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAExD,MAAM,IAAI,GAAG,EAAE,CAAC,SAAS,EAAE,CAAA;IAC3B,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;IAEpB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C;;;;;;;WAOG;QACH,IAAI,GAAG,IAAI,IAAI,GAAG,CAAA;IACpB,CAAC;IAED,OAAO;QACL,kCAAkC;QAClC,GAAG,EAAE,WAAW,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE;QACnC,UAAU;QACV,UAAU;KACX,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/webtransport",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-06e6d235f",
|
|
4
4
|
"description": "JavaScript implementation of the WebTransport module that libp2p uses and that implements the interface-transport spec",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
|
-
"homepage": "https://github.com/libp2p/js-libp2p/tree/
|
|
6
|
+
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-webtransport#readme",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/libp2p/js-libp2p.git"
|
|
@@ -11,27 +11,15 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/libp2p/js-libp2p/issues"
|
|
13
13
|
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": true
|
|
17
|
+
},
|
|
14
18
|
"keywords": [
|
|
15
19
|
"IPFS"
|
|
16
20
|
],
|
|
17
21
|
"type": "module",
|
|
18
22
|
"types": "./dist/src/index.d.ts",
|
|
19
|
-
"typesVersions": {
|
|
20
|
-
"*": {
|
|
21
|
-
"*": [
|
|
22
|
-
"*",
|
|
23
|
-
"dist/*",
|
|
24
|
-
"dist/src/*",
|
|
25
|
-
"dist/src/*/index"
|
|
26
|
-
],
|
|
27
|
-
"src/*": [
|
|
28
|
-
"*",
|
|
29
|
-
"dist/*",
|
|
30
|
-
"dist/src/*",
|
|
31
|
-
"dist/src/*/index"
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
23
|
"files": [
|
|
36
24
|
"src",
|
|
37
25
|
"dist",
|
|
@@ -61,21 +49,21 @@
|
|
|
61
49
|
"test:chrome-webworker": "aegir test -t webworker"
|
|
62
50
|
},
|
|
63
51
|
"dependencies": {
|
|
64
|
-
"@chainsafe/libp2p-noise": "^
|
|
65
|
-
"@libp2p/interface": "
|
|
66
|
-
"@libp2p/
|
|
67
|
-
"@
|
|
68
|
-
"@multiformats/multiaddr": "^
|
|
69
|
-
"@multiformats/multiaddr-matcher": "^1.0.1",
|
|
52
|
+
"@chainsafe/libp2p-noise": "^14.0.0",
|
|
53
|
+
"@libp2p/interface": "1.0.0-06e6d235f",
|
|
54
|
+
"@libp2p/peer-id": "4.0.0-06e6d235f",
|
|
55
|
+
"@multiformats/multiaddr": "^12.1.10",
|
|
56
|
+
"@multiformats/multiaddr-matcher": "^1.1.0",
|
|
70
57
|
"it-stream-types": "^2.0.1",
|
|
71
|
-
"multiformats": "^12.
|
|
58
|
+
"multiformats": "^12.1.3",
|
|
72
59
|
"uint8arraylist": "^2.4.3",
|
|
73
60
|
"uint8arrays": "^4.0.6"
|
|
74
61
|
},
|
|
75
62
|
"devDependencies": {
|
|
76
|
-
"@libp2p/
|
|
63
|
+
"@libp2p/logger": "4.0.0-06e6d235f",
|
|
64
|
+
"@libp2p/peer-id-factory": "3.0.9-06e6d235f",
|
|
77
65
|
"aegir": "^41.0.2",
|
|
78
|
-
"libp2p": "
|
|
66
|
+
"libp2p": "1.0.0-06e6d235f",
|
|
79
67
|
"p-defer": "^4.0.0"
|
|
80
68
|
},
|
|
81
69
|
"browser": {
|
package/src/index.ts
CHANGED
|
@@ -22,27 +22,21 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { noise } from '@chainsafe/libp2p-noise'
|
|
25
|
-
import { type Transport,
|
|
26
|
-
import { logger } from '@libp2p/logger'
|
|
25
|
+
import { type Transport, transportSymbol, type CreateListenerOptions, type DialOptions, type Listener, type ComponentLogger, type Logger, type Connection, type MultiaddrConnection, type Stream, type CounterGroup, type Metrics, type PeerId, type StreamMuxerFactory, type StreamMuxerInit, type StreamMuxer } from '@libp2p/interface'
|
|
27
26
|
import { type Multiaddr, type AbortOptions } from '@multiformats/multiaddr'
|
|
28
27
|
import { WebTransport as WebTransportMatcher } from '@multiformats/multiaddr-matcher'
|
|
29
28
|
import { webtransportBiDiStreamToStream } from './stream.js'
|
|
30
29
|
import { inertDuplex } from './utils/inert-duplex.js'
|
|
31
30
|
import { isSubset } from './utils/is-subset.js'
|
|
32
31
|
import { parseMultiaddr } from './utils/parse-multiaddr.js'
|
|
33
|
-
import type { Connection, MultiaddrConnection, Stream } from '@libp2p/interface/connection'
|
|
34
|
-
import type { CounterGroup, Metrics } from '@libp2p/interface/metrics'
|
|
35
|
-
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
36
|
-
import type { StreamMuxerFactory, StreamMuxerInit, StreamMuxer } from '@libp2p/interface/stream-muxer'
|
|
37
32
|
import type { Source } from 'it-stream-types'
|
|
38
33
|
import type { MultihashDigest } from 'multiformats/hashes/interface'
|
|
34
|
+
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
39
35
|
|
|
40
36
|
interface WebTransportSessionCleanup {
|
|
41
37
|
(metric: string): void
|
|
42
38
|
}
|
|
43
39
|
|
|
44
|
-
const log = logger('libp2p:webtransport')
|
|
45
|
-
|
|
46
40
|
export interface WebTransportInit {
|
|
47
41
|
maxInboundStreams?: number
|
|
48
42
|
}
|
|
@@ -50,6 +44,7 @@ export interface WebTransportInit {
|
|
|
50
44
|
export interface WebTransportComponents {
|
|
51
45
|
peerId: PeerId
|
|
52
46
|
metrics?: Metrics
|
|
47
|
+
logger: ComponentLogger
|
|
53
48
|
}
|
|
54
49
|
|
|
55
50
|
export interface WebTransportMetrics {
|
|
@@ -57,11 +52,13 @@ export interface WebTransportMetrics {
|
|
|
57
52
|
}
|
|
58
53
|
|
|
59
54
|
class WebTransportTransport implements Transport {
|
|
55
|
+
private readonly log: Logger
|
|
60
56
|
private readonly components: WebTransportComponents
|
|
61
57
|
private readonly config: Required<WebTransportInit>
|
|
62
58
|
private readonly metrics?: WebTransportMetrics
|
|
63
59
|
|
|
64
60
|
constructor (components: WebTransportComponents, init: WebTransportInit = {}) {
|
|
61
|
+
this.log = components.logger.forComponent('libp2p:webtransport')
|
|
65
62
|
this.components = components
|
|
66
63
|
this.config = {
|
|
67
64
|
maxInboundStreams: init.maxInboundStreams ?? 1000
|
|
@@ -79,12 +76,12 @@ class WebTransportTransport implements Transport {
|
|
|
79
76
|
|
|
80
77
|
readonly [Symbol.toStringTag] = '@libp2p/webtransport'
|
|
81
78
|
|
|
82
|
-
readonly [
|
|
79
|
+
readonly [transportSymbol] = true
|
|
83
80
|
|
|
84
81
|
async dial (ma: Multiaddr, options: DialOptions): Promise<Connection> {
|
|
85
82
|
options?.signal?.throwIfAborted()
|
|
86
83
|
|
|
87
|
-
log('dialing %s', ma)
|
|
84
|
+
this.log('dialing %s', ma)
|
|
88
85
|
const localPeer = this.components.peerId
|
|
89
86
|
if (localPeer === undefined) {
|
|
90
87
|
throw new Error('Need a local peerid')
|
|
@@ -131,7 +128,7 @@ class WebTransportTransport implements Transport {
|
|
|
131
128
|
this.metrics?.dialerEvents.increment({ [metric]: true })
|
|
132
129
|
wt.close()
|
|
133
130
|
} catch (err) {
|
|
134
|
-
log.error('error closing wt session', err)
|
|
131
|
+
this.log.error('error closing wt session', err)
|
|
135
132
|
} finally {
|
|
136
133
|
// This is how we specify the connection is closed and shouldn't be used.
|
|
137
134
|
if (maConn != null) {
|
|
@@ -164,7 +161,7 @@ class WebTransportTransport implements Transport {
|
|
|
164
161
|
|
|
165
162
|
// this promise resolves/throws when the session is closed
|
|
166
163
|
wt.closed.catch((err: Error) => {
|
|
167
|
-
log.error('error on remote wt session close', err)
|
|
164
|
+
this.log.error('error on remote wt session close', err)
|
|
168
165
|
})
|
|
169
166
|
.finally(() => {
|
|
170
167
|
cleanUpWTSession('remote_close')
|
|
@@ -178,17 +175,18 @@ class WebTransportTransport implements Transport {
|
|
|
178
175
|
|
|
179
176
|
maConn = {
|
|
180
177
|
close: async () => {
|
|
181
|
-
log('Closing webtransport')
|
|
178
|
+
this.log('Closing webtransport')
|
|
182
179
|
cleanUpWTSession('close')
|
|
183
180
|
},
|
|
184
181
|
abort: (err: Error) => {
|
|
185
|
-
log('aborting webtransport due to passed err', err)
|
|
182
|
+
this.log('aborting webtransport due to passed err', err)
|
|
186
183
|
cleanUpWTSession('abort')
|
|
187
184
|
},
|
|
188
185
|
remoteAddr: ma,
|
|
189
186
|
timeline: {
|
|
190
187
|
open: Date.now()
|
|
191
188
|
},
|
|
189
|
+
log: this.components.logger.forComponent('libp2p:webtransport:maconn'),
|
|
192
190
|
// This connection is never used directly since webtransport supports native streams.
|
|
193
191
|
...inertDuplex()
|
|
194
192
|
}
|
|
@@ -197,7 +195,7 @@ class WebTransportTransport implements Transport {
|
|
|
197
195
|
|
|
198
196
|
return await options.upgrader.upgradeOutbound(maConn, { skipEncryption: true, muxerFactory: this.webtransportMuxer(wt), skipProtection: true })
|
|
199
197
|
} catch (err: any) {
|
|
200
|
-
log.error('caught wt session err', err)
|
|
198
|
+
this.log.error('caught wt session err', err)
|
|
201
199
|
|
|
202
200
|
if (authenticated) {
|
|
203
201
|
cleanUpWTSession('upgrade_error')
|
|
@@ -235,24 +233,28 @@ class WebTransportTransport implements Transport {
|
|
|
235
233
|
}
|
|
236
234
|
}
|
|
237
235
|
})(),
|
|
238
|
-
sink: async function (source: Source<Uint8Array>) {
|
|
236
|
+
sink: async function (source: Source<Uint8Array | Uint8ArrayList>) {
|
|
239
237
|
for await (const chunk of source) {
|
|
240
|
-
|
|
238
|
+
if (chunk instanceof Uint8Array) {
|
|
239
|
+
await writer.write(chunk)
|
|
240
|
+
} else {
|
|
241
|
+
await writer.write(chunk.subarray())
|
|
242
|
+
}
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
246
|
|
|
245
|
-
const n = noise()()
|
|
247
|
+
const n = noise()(this.components)
|
|
246
248
|
|
|
247
249
|
const { remoteExtensions } = await n.secureOutbound(localPeer, duplex, remotePeer)
|
|
248
250
|
|
|
249
251
|
// We're done with this authentication stream
|
|
250
252
|
writer.close().catch((err: Error) => {
|
|
251
|
-
log.error(`Failed to close authentication stream writer: ${err.message}`)
|
|
253
|
+
this.log.error(`Failed to close authentication stream writer: ${err.message}`)
|
|
252
254
|
})
|
|
253
255
|
|
|
254
256
|
reader.cancel().catch((err: Error) => {
|
|
255
|
-
log.error(`Failed to close authentication stream reader: ${err.message}`)
|
|
257
|
+
this.log.error(`Failed to close authentication stream reader: ${err.message}`)
|
|
256
258
|
})
|
|
257
259
|
|
|
258
260
|
// Verify the certhashes we used when dialing are a subset of the certhashes relayed by the remote peer
|
|
@@ -266,6 +268,7 @@ class WebTransportTransport implements Transport {
|
|
|
266
268
|
webtransportMuxer (wt: WebTransport): StreamMuxerFactory {
|
|
267
269
|
let streamIDCounter = 0
|
|
268
270
|
const config = this.config
|
|
271
|
+
const self = this
|
|
269
272
|
return {
|
|
270
273
|
protocol: 'webtransport',
|
|
271
274
|
createStreamMuxer: (init?: StreamMuxerInit): StreamMuxer => {
|
|
@@ -292,19 +295,26 @@ class WebTransportTransport implements Transport {
|
|
|
292
295
|
if (activeStreams.length >= config.maxInboundStreams) {
|
|
293
296
|
// We've reached our limit, close this stream.
|
|
294
297
|
wtStream.writable.close().catch((err: Error) => {
|
|
295
|
-
log.error(`Failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`)
|
|
298
|
+
self.log.error(`Failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`)
|
|
296
299
|
})
|
|
297
300
|
wtStream.readable.cancel().catch((err: Error) => {
|
|
298
|
-
log.error(`Failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`)
|
|
301
|
+
self.log.error(`Failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`)
|
|
299
302
|
})
|
|
300
303
|
} else {
|
|
301
|
-
const stream = await webtransportBiDiStreamToStream(
|
|
304
|
+
const stream = await webtransportBiDiStreamToStream(
|
|
305
|
+
wtStream,
|
|
306
|
+
String(streamIDCounter++),
|
|
307
|
+
'inbound',
|
|
308
|
+
activeStreams,
|
|
309
|
+
init?.onStreamEnd,
|
|
310
|
+
self.components.logger
|
|
311
|
+
)
|
|
302
312
|
activeStreams.push(stream)
|
|
303
313
|
init?.onIncomingStream?.(stream)
|
|
304
314
|
}
|
|
305
315
|
}
|
|
306
316
|
})().catch(() => {
|
|
307
|
-
log.error('WebTransport failed to receive incoming stream')
|
|
317
|
+
this.log.error('WebTransport failed to receive incoming stream')
|
|
308
318
|
})
|
|
309
319
|
|
|
310
320
|
const muxer: StreamMuxer = {
|
|
@@ -313,7 +323,14 @@ class WebTransportTransport implements Transport {
|
|
|
313
323
|
newStream: async (name?: string): Promise<Stream> => {
|
|
314
324
|
const wtStream = await wt.createBidirectionalStream()
|
|
315
325
|
|
|
316
|
-
const stream = await webtransportBiDiStreamToStream(
|
|
326
|
+
const stream = await webtransportBiDiStreamToStream(
|
|
327
|
+
wtStream,
|
|
328
|
+
String(streamIDCounter++),
|
|
329
|
+
init?.direction ?? 'outbound',
|
|
330
|
+
activeStreams,
|
|
331
|
+
init?.onStreamEnd,
|
|
332
|
+
self.components.logger
|
|
333
|
+
)
|
|
317
334
|
activeStreams.push(stream)
|
|
318
335
|
|
|
319
336
|
return stream
|
|
@@ -323,14 +340,14 @@ class WebTransportTransport implements Transport {
|
|
|
323
340
|
* Close or abort all tracked streams and stop the muxer
|
|
324
341
|
*/
|
|
325
342
|
close: async (options?: AbortOptions) => {
|
|
326
|
-
log('Closing webtransport muxer')
|
|
343
|
+
this.log('Closing webtransport muxer')
|
|
327
344
|
|
|
328
345
|
await Promise.all(
|
|
329
346
|
activeStreams.map(async s => s.close(options))
|
|
330
347
|
)
|
|
331
348
|
},
|
|
332
349
|
abort: (err: Error) => {
|
|
333
|
-
log('Aborting webtransport muxer with err:', err)
|
|
350
|
+
this.log('Aborting webtransport muxer with err:', err)
|
|
334
351
|
|
|
335
352
|
for (const stream of activeStreams) {
|
|
336
353
|
stream.abort(err)
|