@libp2p/webtransport 4.0.32 → 4.0.33-863b3de03
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/index.min.js +3 -3
- package/dist/src/muxer.d.ts.map +1 -1
- package/dist/src/muxer.js +17 -3
- package/dist/src/muxer.js.map +1 -1
- package/package.json +9 -9
- package/src/muxer.ts +45 -31
- package/dist/typedoc-urls.json +0 -12
package/dist/src/muxer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"muxer.d.ts","sourceRoot":"","sources":["../../src/muxer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAuB,kBAAkB,EAAmB,MAAM,mBAAmB,CAAA;AAElH,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,EAAE,MAAM,CAAA;CAC1B;AAED,wBAAgB,iBAAiB,CAAE,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,2BAA2B,CAAC,EAAE,MAAM,EAAE,2BAA2B,CAAC,+BAA+B,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,qBAAqB,GAAG,kBAAkB,
|
|
1
|
+
{"version":3,"file":"muxer.d.ts","sourceRoot":"","sources":["../../src/muxer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAuB,kBAAkB,EAAmB,MAAM,mBAAmB,CAAA;AAElH,MAAM,WAAW,qBAAqB;IACpC,iBAAiB,EAAE,MAAM,CAAA;CAC1B;AAED,wBAAgB,iBAAiB,CAAE,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,2BAA2B,CAAC,EAAE,MAAM,EAAE,2BAA2B,CAAC,+BAA+B,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,qBAAqB,GAAG,kBAAkB,CAmGlP"}
|
package/dist/src/muxer.js
CHANGED
|
@@ -12,7 +12,8 @@ export function webtransportMuxer(wt, reader, logger, config) {
|
|
|
12
12
|
init = { onIncomingStream: init };
|
|
13
13
|
}
|
|
14
14
|
const activeStreams = [];
|
|
15
|
-
|
|
15
|
+
Promise.resolve()
|
|
16
|
+
.then(async () => {
|
|
16
17
|
//! TODO unclear how to add backpressure here?
|
|
17
18
|
while (true) {
|
|
18
19
|
const { done, value: wtStream } = await reader.read();
|
|
@@ -35,6 +36,9 @@ export function webtransportMuxer(wt, reader, logger, config) {
|
|
|
35
36
|
init?.onIncomingStream?.(stream);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
39
|
+
})
|
|
40
|
+
.catch(err => {
|
|
41
|
+
log.error('could not create a new stream', err);
|
|
38
42
|
});
|
|
39
43
|
const muxer = {
|
|
40
44
|
protocol: 'webtransport',
|
|
@@ -51,14 +55,24 @@ export function webtransportMuxer(wt, reader, logger, config) {
|
|
|
51
55
|
*/
|
|
52
56
|
close: async () => {
|
|
53
57
|
log('closing webtransport muxer gracefully');
|
|
54
|
-
|
|
58
|
+
try {
|
|
59
|
+
wt.close();
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
muxer.abort(err);
|
|
63
|
+
}
|
|
55
64
|
},
|
|
56
65
|
/**
|
|
57
66
|
* Abort all tracked streams and stop the muxer
|
|
58
67
|
*/
|
|
59
68
|
abort: (err) => {
|
|
60
69
|
log('closing webtransport muxer with err:', err);
|
|
61
|
-
|
|
70
|
+
try {
|
|
71
|
+
wt.close();
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
log.error('webtransport session threw error during close', err);
|
|
75
|
+
}
|
|
62
76
|
},
|
|
63
77
|
// This stream muxer is webtransport native. Therefore it doesn't plug in with any other duplex.
|
|
64
78
|
...inertDuplex()
|
package/dist/src/muxer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"muxer.js","sourceRoot":"","sources":["../../src/muxer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAQrD,MAAM,UAAU,iBAAiB,CAAE,EAA6D,EAAE,MAAoE,EAAE,MAAuB,EAAE,MAA6B;IAC5N,IAAI,eAAe,GAAG,CAAC,CAAA;IACvB,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,2BAA2B,CAAC,CAAA;IAE5D,OAAO;QACL,QAAQ,EAAE,cAAc;QACxB,iBAAiB,EAAE,CAAC,IAAsB,EAAe,EAAE;YACzD,6DAA6D;YAE7D,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;gBAC/B,+CAA+C;gBAC/C,IAAI,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAA;YACnC,CAAC;YAED,MAAM,aAAa,GAAa,EAAE,CAAA;YAElC,
|
|
1
|
+
{"version":3,"file":"muxer.js","sourceRoot":"","sources":["../../src/muxer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAQrD,MAAM,UAAU,iBAAiB,CAAE,EAA6D,EAAE,MAAoE,EAAE,MAAuB,EAAE,MAA6B;IAC5N,IAAI,eAAe,GAAG,CAAC,CAAA;IACvB,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,2BAA2B,CAAC,CAAA;IAE5D,OAAO;QACL,QAAQ,EAAE,cAAc;QACxB,iBAAiB,EAAE,CAAC,IAAsB,EAAe,EAAE;YACzD,6DAA6D;YAE7D,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;gBAC/B,+CAA+C;gBAC/C,IAAI,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,CAAA;YACnC,CAAC;YAED,MAAM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QACd,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/webtransport",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.33-863b3de03",
|
|
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
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-webtransport#readme",
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@chainsafe/libp2p-noise": "^15.0.0",
|
|
54
|
-
"@libp2p/interface": "
|
|
55
|
-
"@libp2p/peer-id": "
|
|
56
|
-
"@libp2p/utils": "
|
|
54
|
+
"@libp2p/interface": "1.4.1-863b3de03",
|
|
55
|
+
"@libp2p/peer-id": "4.1.3-863b3de03",
|
|
56
|
+
"@libp2p/utils": "5.4.3-863b3de03",
|
|
57
57
|
"@multiformats/multiaddr": "^12.2.3",
|
|
58
58
|
"@multiformats/multiaddr-matcher": "^1.2.1",
|
|
59
59
|
"it-stream-types": "^2.0.1",
|
|
@@ -64,16 +64,16 @@
|
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@libp2p/daemon-client": "^8.0.5",
|
|
67
|
-
"@libp2p/logger": "
|
|
68
|
-
"@libp2p/peer-id-factory": "
|
|
69
|
-
"@libp2p/ping": "
|
|
67
|
+
"@libp2p/logger": "4.0.14-863b3de03",
|
|
68
|
+
"@libp2p/peer-id-factory": "4.1.3-863b3de03",
|
|
69
|
+
"@libp2p/ping": "1.0.20-863b3de03",
|
|
70
70
|
"@noble/hashes": "^1.4.0",
|
|
71
|
-
"aegir": "^
|
|
71
|
+
"aegir": "^43.0.1",
|
|
72
72
|
"execa": "^9.1.0",
|
|
73
73
|
"go-libp2p": "^1.2.0",
|
|
74
74
|
"it-map": "^3.1.0",
|
|
75
75
|
"it-to-buffer": "^4.0.7",
|
|
76
|
-
"libp2p": "
|
|
76
|
+
"libp2p": "1.6.1-863b3de03",
|
|
77
77
|
"p-defer": "^4.0.1",
|
|
78
78
|
"p-wait-for": "^5.0.2"
|
|
79
79
|
},
|
package/src/muxer.ts
CHANGED
|
@@ -23,38 +23,42 @@ export function webtransportMuxer (wt: Pick<WebTransport, 'close' | 'createBidir
|
|
|
23
23
|
|
|
24
24
|
const activeStreams: Stream[] = []
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
Promise.resolve()
|
|
27
|
+
.then(async () => {
|
|
28
|
+
//! TODO unclear how to add backpressure here?
|
|
29
|
+
while (true) {
|
|
30
|
+
const { done, value: wtStream } = await reader.read()
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
if (done) {
|
|
33
|
+
break
|
|
34
|
+
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
if (activeStreams.length >= config.maxInboundStreams) {
|
|
37
|
+
log(`too many inbound streams open - ${activeStreams.length}/${config.maxInboundStreams}, closing new incoming stream`)
|
|
38
|
+
// We've reached our limit, close this stream.
|
|
39
|
+
wtStream.writable.close().catch((err: Error) => {
|
|
40
|
+
log.error(`failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`)
|
|
41
|
+
})
|
|
42
|
+
wtStream.readable.cancel().catch((err: Error) => {
|
|
43
|
+
log.error(`failed to close inbound stream that crossed our maxInboundStream limit: ${err.message}`)
|
|
44
|
+
})
|
|
45
|
+
} else {
|
|
46
|
+
const stream = await webtransportBiDiStreamToStream(
|
|
47
|
+
wtStream,
|
|
48
|
+
String(streamIDCounter++),
|
|
49
|
+
'inbound',
|
|
50
|
+
activeStreams,
|
|
51
|
+
init?.onStreamEnd,
|
|
52
|
+
logger
|
|
53
|
+
)
|
|
54
|
+
activeStreams.push(stream)
|
|
55
|
+
init?.onIncomingStream?.(stream)
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
+
})
|
|
59
|
+
.catch(err => {
|
|
60
|
+
log.error('could not create a new stream', err)
|
|
61
|
+
})
|
|
58
62
|
|
|
59
63
|
const muxer: StreamMuxer = {
|
|
60
64
|
protocol: 'webtransport',
|
|
@@ -74,7 +78,12 @@ export function webtransportMuxer (wt: Pick<WebTransport, 'close' | 'createBidir
|
|
|
74
78
|
*/
|
|
75
79
|
close: async () => {
|
|
76
80
|
log('closing webtransport muxer gracefully')
|
|
77
|
-
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
wt.close()
|
|
84
|
+
} catch (err: any) {
|
|
85
|
+
muxer.abort(err)
|
|
86
|
+
}
|
|
78
87
|
},
|
|
79
88
|
|
|
80
89
|
/**
|
|
@@ -82,7 +91,12 @@ export function webtransportMuxer (wt: Pick<WebTransport, 'close' | 'createBidir
|
|
|
82
91
|
*/
|
|
83
92
|
abort: (err: Error) => {
|
|
84
93
|
log('closing webtransport muxer with err:', err)
|
|
85
|
-
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
wt.close()
|
|
97
|
+
} catch (err: any) {
|
|
98
|
+
log.error('webtransport session threw error during close', err)
|
|
99
|
+
}
|
|
86
100
|
},
|
|
87
101
|
|
|
88
102
|
// This stream muxer is webtransport native. Therefore it doesn't plug in with any other duplex.
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"WebTransportCertificate": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webtransport.WebTransportCertificate.html",
|
|
3
|
-
".:WebTransportCertificate": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webtransport.WebTransportCertificate.html",
|
|
4
|
-
"WebTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webtransport.WebTransportComponents.html",
|
|
5
|
-
".:WebTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webtransport.WebTransportComponents.html",
|
|
6
|
-
"WebTransportInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webtransport.WebTransportInit.html",
|
|
7
|
-
".:WebTransportInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webtransport.WebTransportInit.html",
|
|
8
|
-
"WebTransportMetrics": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webtransport.WebTransportMetrics.html",
|
|
9
|
-
".:WebTransportMetrics": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webtransport.WebTransportMetrics.html",
|
|
10
|
-
"webTransport": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webtransport.webTransport.html",
|
|
11
|
-
".:webTransport": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webtransport.webTransport.html"
|
|
12
|
-
}
|