@libp2p/webrtc 5.2.24 → 6.0.0-049bfa0fa
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 +10 -20
- package/dist/index.min.js +17 -17
- package/dist/index.min.js.map +4 -4
- package/dist/src/constants.d.ts +4 -23
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +4 -23
- package/dist/src/constants.js.map +1 -1
- package/dist/src/index.d.ts +20 -22
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +12 -22
- package/dist/src/index.js.map +1 -1
- package/dist/src/muxer.d.ts +14 -46
- package/dist/src/muxer.d.ts.map +1 -1
- package/dist/src/muxer.js +30 -138
- package/dist/src/muxer.js.map +1 -1
- package/dist/src/private-to-private/initiate-connection.d.ts +2 -3
- package/dist/src/private-to-private/initiate-connection.d.ts.map +1 -1
- package/dist/src/private-to-private/initiate-connection.js +37 -5
- package/dist/src/private-to-private/initiate-connection.js.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.d.ts +4 -4
- package/dist/src/private-to-private/signaling-stream-handler.d.ts.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.js +19 -7
- package/dist/src/private-to-private/signaling-stream-handler.js.map +1 -1
- package/dist/src/private-to-private/transport.d.ts +2 -9
- package/dist/src/private-to-private/transport.d.ts.map +1 -1
- package/dist/src/private-to-private/transport.js +30 -15
- package/dist/src/private-to-private/transport.js.map +1 -1
- package/dist/src/private-to-private/util.d.ts +3 -2
- package/dist/src/private-to-private/util.d.ts.map +1 -1
- package/dist/src/private-to-private/util.js +26 -14
- package/dist/src/private-to-private/util.js.map +1 -1
- package/dist/src/private-to-public/listener.d.ts.map +1 -1
- package/dist/src/private-to-public/listener.js +21 -15
- package/dist/src/private-to-public/listener.js.map +1 -1
- package/dist/src/private-to-public/transport.d.ts +0 -8
- package/dist/src/private-to-public/transport.d.ts.map +1 -1
- package/dist/src/private-to-public/transport.js +3 -2
- package/dist/src/private-to-public/transport.js.map +1 -1
- package/dist/src/private-to-public/utils/connect.d.ts +1 -1
- package/dist/src/private-to-public/utils/connect.d.ts.map +1 -1
- package/dist/src/private-to-public/utils/connect.js +17 -14
- package/dist/src/private-to-public/utils/connect.js.map +1 -1
- package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts +4 -4
- package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts.map +1 -1
- package/dist/src/private-to-public/utils/get-rtcpeerconnection.js +13 -2
- package/dist/src/private-to-public/utils/get-rtcpeerconnection.js.map +1 -1
- package/dist/src/private-to-public/utils/sdp.d.ts.map +1 -1
- package/dist/src/private-to-public/utils/sdp.js +25 -13
- package/dist/src/private-to-public/utils/sdp.js.map +1 -1
- package/dist/src/private-to-public/utils/stun-listener.js +1 -1
- package/dist/src/private-to-public/utils/stun-listener.js.map +1 -1
- package/dist/src/rtcpeerconnection-to-conn.d.ts +12 -0
- package/dist/src/rtcpeerconnection-to-conn.d.ts.map +1 -0
- package/dist/src/rtcpeerconnection-to-conn.js +46 -0
- package/dist/src/rtcpeerconnection-to-conn.js.map +1 -0
- package/dist/src/stream.d.ts +14 -26
- package/dist/src/stream.d.ts.map +1 -1
- package/dist/src/stream.js +134 -204
- package/dist/src/stream.js.map +1 -1
- package/dist/src/util.d.ts +3 -1
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js +19 -0
- package/dist/src/util.js.map +1 -1
- package/dist/src/webrtc/index.d.ts +1 -1
- package/dist/src/webrtc/index.d.ts.map +1 -1
- package/dist/src/webrtc/index.js +1 -1
- package/dist/src/webrtc/index.js.map +1 -1
- package/package.json +26 -29
- package/src/constants.ts +5 -28
- package/src/index.ts +21 -22
- package/src/muxer.ts +39 -169
- package/src/private-to-private/initiate-connection.ts +46 -8
- package/src/private-to-private/signaling-stream-handler.ts +23 -10
- package/src/private-to-private/transport.ts +33 -25
- package/src/private-to-private/util.ts +33 -16
- package/src/private-to-public/listener.ts +22 -15
- package/src/private-to-public/transport.ts +3 -12
- package/src/private-to-public/utils/connect.ts +18 -15
- package/src/private-to-public/utils/get-rtcpeerconnection.ts +16 -4
- package/src/private-to-public/utils/sdp.ts +29 -13
- package/src/private-to-public/utils/stun-listener.ts +1 -1
- package/src/rtcpeerconnection-to-conn.ts +66 -0
- package/src/stream.ts +153 -237
- package/src/util.ts +22 -1
- package/src/webrtc/index.ts +1 -1
- package/dist/src/maconn.d.ts +0 -58
- package/dist/src/maconn.d.ts.map +0 -1
- package/dist/src/maconn.js +0 -56
- package/dist/src/maconn.js.map +0 -1
- package/dist/typedoc-urls.json +0 -14
- package/src/maconn.ts +0 -101
package/dist/src/constants.d.ts
CHANGED
@@ -15,22 +15,10 @@ export declare const UFRAG_ALPHABET: string[];
|
|
15
15
|
* Used to detect the version of the WebRTC Direct connection protocol in use
|
16
16
|
*/
|
17
17
|
export declare const UFRAG_PREFIX = "libp2p+webrtc+v1/";
|
18
|
-
/**
|
19
|
-
* The multicodec code for webrtc-direct tuples
|
20
|
-
*/
|
21
|
-
export declare const CODEC_WEBRTC_DIRECT = 280;
|
22
|
-
/**
|
23
|
-
* The multicodec code for certhash tuples
|
24
|
-
*/
|
25
|
-
export declare const CODEC_CERTHASH = 466;
|
26
18
|
/**
|
27
19
|
* How much can be buffered to the DataChannel at once
|
28
20
|
*/
|
29
21
|
export declare const MAX_BUFFERED_AMOUNT: number;
|
30
|
-
/**
|
31
|
-
* How long time we wait for the 'bufferedamountlow' event to be emitted
|
32
|
-
*/
|
33
|
-
export declare const BUFFERED_AMOUNT_LOW_TIMEOUT: number;
|
34
22
|
/**
|
35
23
|
* Max message size that can be sent to the DataChannel. In browsers this is
|
36
24
|
* 256KiB but go-libp2p and rust-libp2p only support 16KiB at the time of
|
@@ -45,22 +33,15 @@ export declare const MAX_MESSAGE_SIZE: number;
|
|
45
33
|
* protobuf that aren't message field bytes
|
46
34
|
*/
|
47
35
|
export declare const PROTOBUF_OVERHEAD: number;
|
48
|
-
/**
|
49
|
-
* When closing streams we send a FIN then wait for the remote to
|
50
|
-
* reply with a FIN_ACK. If that does not happen within this timeout
|
51
|
-
* we close the stream anyway.
|
52
|
-
*/
|
53
|
-
export declare const FIN_ACK_TIMEOUT = 5000;
|
54
|
-
/**
|
55
|
-
* When sending data messages, if the channel is not in the "open" state, wait
|
56
|
-
* this long for the "open" event to fire.
|
57
|
-
*/
|
58
|
-
export declare const OPEN_TIMEOUT = 5000;
|
59
36
|
/**
|
60
37
|
* When closing a stream, we wait for `bufferedAmount` to become 0 before
|
61
38
|
* closing the underlying RTCDataChannel - this controls how long we wait in ms
|
62
39
|
*/
|
63
40
|
export declare const DATA_CHANNEL_DRAIN_TIMEOUT = 30000;
|
41
|
+
/**
|
42
|
+
* Wait for the remote to acknowledge our FIN for this long
|
43
|
+
*/
|
44
|
+
export declare const DEFAULT_FIN_ACK_TIMEOUT = 10000;
|
64
45
|
/**
|
65
46
|
* Set as the 'negotiated' muxer protocol name
|
66
47
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,UAK/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,UAA+E,CAAA;AAE1G;;GAEG;AACH,eAAO,MAAM,YAAY,sBAAsB,CAAA;AAE/C;;GAEG;AACH,eAAO,MAAM,mBAAmB,
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,UAK/B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,UAA+E,CAAA;AAE1G;;GAEG;AACH,eAAO,MAAM,YAAY,sBAAsB,CAAA;AAE/C;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAkB,CAAA;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,QAAY,CAAA;AAsBzC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAA8B,CAAA;AAE5D;;;GAGG;AACH,eAAO,MAAM,0BAA0B,QAAS,CAAA;AAEhD;;GAEG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAA;AAE7C;;GAEG;AACH,eAAO,MAAM,cAAc,YAAY,CAAA;AAEvC;;GAEG;AACH,eAAO,MAAM,kBAAkB,4BAA4B,CAAA;AAE3D;;GAEG;AACH,eAAO,MAAM,iCAAiC,sCAAsC,CAAA;AAEpF;;GAEG;AACH,eAAO,MAAM,oCAAoC,0CAA0C,CAAA;AAE3F;;GAEG;AACH,eAAO,MAAM,oCAAoC,UAAU,CAAA;AAE3D;;GAEG;AACH,eAAO,MAAM,4BAA4B,aAAgB,CAAA;AAEzD;;GAEG;AACH,eAAO,MAAM,qCAAqC,WAAa,CAAA"}
|
package/dist/src/constants.js
CHANGED
@@ -22,22 +22,10 @@ export const UFRAG_ALPHABET = Array.from('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKL
|
|
22
22
|
* Used to detect the version of the WebRTC Direct connection protocol in use
|
23
23
|
*/
|
24
24
|
export const UFRAG_PREFIX = 'libp2p+webrtc+v1/';
|
25
|
-
/**
|
26
|
-
* The multicodec code for webrtc-direct tuples
|
27
|
-
*/
|
28
|
-
export const CODEC_WEBRTC_DIRECT = 0x0118;
|
29
|
-
/**
|
30
|
-
* The multicodec code for certhash tuples
|
31
|
-
*/
|
32
|
-
export const CODEC_CERTHASH = 0x01d2;
|
33
25
|
/**
|
34
26
|
* How much can be buffered to the DataChannel at once
|
35
27
|
*/
|
36
28
|
export const MAX_BUFFERED_AMOUNT = 2 * 1024 * 1024;
|
37
|
-
/**
|
38
|
-
* How long time we wait for the 'bufferedamountlow' event to be emitted
|
39
|
-
*/
|
40
|
-
export const BUFFERED_AMOUNT_LOW_TIMEOUT = 30 * 1000;
|
41
29
|
/**
|
42
30
|
* Max message size that can be sent to the DataChannel. In browsers this is
|
43
31
|
* 256KiB but go-libp2p and rust-libp2p only support 16KiB at the time of
|
@@ -69,22 +57,15 @@ function calculateProtobufOverhead(maxMessageSize = MAX_MESSAGE_SIZE) {
|
|
69
57
|
* protobuf that aren't message field bytes
|
70
58
|
*/
|
71
59
|
export const PROTOBUF_OVERHEAD = calculateProtobufOverhead();
|
72
|
-
/**
|
73
|
-
* When closing streams we send a FIN then wait for the remote to
|
74
|
-
* reply with a FIN_ACK. If that does not happen within this timeout
|
75
|
-
* we close the stream anyway.
|
76
|
-
*/
|
77
|
-
export const FIN_ACK_TIMEOUT = 5_000;
|
78
|
-
/**
|
79
|
-
* When sending data messages, if the channel is not in the "open" state, wait
|
80
|
-
* this long for the "open" event to fire.
|
81
|
-
*/
|
82
|
-
export const OPEN_TIMEOUT = 5_000;
|
83
60
|
/**
|
84
61
|
* When closing a stream, we wait for `bufferedAmount` to become 0 before
|
85
62
|
* closing the underlying RTCDataChannel - this controls how long we wait in ms
|
86
63
|
*/
|
87
64
|
export const DATA_CHANNEL_DRAIN_TIMEOUT = 30_000;
|
65
|
+
/**
|
66
|
+
* Wait for the remote to acknowledge our FIN for this long
|
67
|
+
*/
|
68
|
+
export const DEFAULT_FIN_ACK_TIMEOUT = 10_000;
|
88
69
|
/**
|
89
70
|
* Set as the 'negotiated' muxer protocol name
|
90
71
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAA;AAE3D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,8BAA8B;IAC9B,kCAAkC;IAClC,+BAA+B;IAC/B,qCAAqC;CACtC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAA;AAE1G;;GAEG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CAAA;IAE1D,OAAO,aAAa,GAAG,SAAS,GAAG,kBAAkB,GAAG,wBAAwB,CAAA;AAClF,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,yBAAyB,EAAE,CAAA;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAA;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAA;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,mCAAmC,CAAA;AAEpF;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,uCAAuC,CAAA;AAE3F;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,OAAO,CAAA;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,aAAa,CAAA;AAEzD;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,UAAU,CAAA"}
|
package/dist/src/index.d.ts
CHANGED
@@ -26,8 +26,8 @@
|
|
26
26
|
* WebRTC requires use of a relay to connect two nodes. The listener first discovers a relay server and makes a reservation, then the dialer can connect via the relayed address.
|
27
27
|
*
|
28
28
|
* ```TypeScript
|
29
|
-
* import { noise } from '@
|
30
|
-
* import { yamux } from '@
|
29
|
+
* import { noise } from '@libp2p/noise'
|
30
|
+
* import { yamux } from '@libp2p/yamux'
|
31
31
|
* import { echo } from '@libp2p/echo'
|
32
32
|
* import { circuitRelayTransport, circuitRelayServer } from '@libp2p/circuit-relay-v2'
|
33
33
|
* import { identify } from '@libp2p/identify'
|
@@ -35,7 +35,6 @@
|
|
35
35
|
* import { webSockets } from '@libp2p/websockets'
|
36
36
|
* import { WebRTC } from '@multiformats/multiaddr-matcher'
|
37
37
|
* import delay from 'delay'
|
38
|
-
* import { pipe } from 'it-pipe'
|
39
38
|
* import { createLibp2p } from 'libp2p'
|
40
39
|
* import type { Multiaddr } from '@multiformats/multiaddr'
|
41
40
|
*
|
@@ -134,15 +133,11 @@
|
|
134
133
|
* await relay.stop()
|
135
134
|
*
|
136
135
|
* // send/receive some data from the remote peer via a direct connection
|
137
|
-
*
|
138
|
-
*
|
139
|
-
*
|
140
|
-
*
|
141
|
-
*
|
142
|
-
* console.info(new TextDecoder().decode(buf.subarray()))
|
143
|
-
* }
|
144
|
-
* }
|
145
|
-
* )
|
136
|
+
* stream.send(new TextEncoder().encode('hello world'))
|
137
|
+
*
|
138
|
+
* stream.addEventListener('message', (evt) => {
|
139
|
+
* console.info(new TextDecoder().decode(evt.data.subarray()))
|
140
|
+
* })
|
146
141
|
* ```
|
147
142
|
*
|
148
143
|
* @example WebRTC Direct
|
@@ -167,7 +162,6 @@
|
|
167
162
|
* ```TypeScript
|
168
163
|
* import { createLibp2p } from 'libp2p'
|
169
164
|
* import { multiaddr } from '@multiformats/multiaddr'
|
170
|
-
* import { pipe } from 'it-pipe'
|
171
165
|
* import { fromString, toString } from 'uint8arrays'
|
172
166
|
* import { webRTCDirect } from '@libp2p/webrtc'
|
173
167
|
*
|
@@ -196,15 +190,11 @@
|
|
196
190
|
* signal: AbortSignal.timeout(10_000)
|
197
191
|
* })
|
198
192
|
*
|
199
|
-
*
|
200
|
-
*
|
201
|
-
*
|
202
|
-
*
|
203
|
-
*
|
204
|
-
* console.info(toString(buf.subarray()))
|
205
|
-
* }
|
206
|
-
* }
|
207
|
-
* )
|
193
|
+
* stream.send(new TextEncoder().encode('hello world'))
|
194
|
+
*
|
195
|
+
* stream.addEventListener('message', (evt) => {
|
196
|
+
* console.info(new TextDecoder().decode(evt.data.subarray()))
|
197
|
+
* })
|
208
198
|
* ```
|
209
199
|
*
|
210
200
|
* ## WebRTC Direct certificate hashes
|
@@ -309,6 +299,14 @@ export interface DataChannelOptions {
|
|
309
299
|
* @default 5_000
|
310
300
|
*/
|
311
301
|
openTimeout?: number;
|
302
|
+
/**
|
303
|
+
* Due to bugs in WebRTC implementations it's necessary for the remote end of
|
304
|
+
* the connection to acknowledge the FIN message we send during stream
|
305
|
+
* closing. A stream will wait for this many ms.
|
306
|
+
*
|
307
|
+
* @default 10_000
|
308
|
+
*/
|
309
|
+
finAckTimeout?: number;
|
312
310
|
}
|
313
311
|
/**
|
314
312
|
* PEM format server certificate and private key
|
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
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4PG;AAIH,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvG,OAAO,KAAK,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAA;AAClH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;;;;OAMG;IACH,6BAA6B,CAAC,EAAE,MAAM,CAAA;IAEtC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAA;IAEX;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,YAAY,EAAE,yBAAyB,EAAE,+BAA+B,EAAE,CAAA;AAE1E,iBAAS,YAAY,CAAE,IAAI,CAAC,EAAE,yBAAyB,GAAG,CAAC,UAAU,EAAE,+BAA+B,KAAK,SAAS,CAEnH;AAED,YAAY,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,CAAA;AAE9D,iBAAS,MAAM,CAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,CAAC,UAAU,EAAE,yBAAyB,KAAK,SAAS,CAEjG;AAED,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/src/index.js
CHANGED
@@ -26,8 +26,8 @@
|
|
26
26
|
* WebRTC requires use of a relay to connect two nodes. The listener first discovers a relay server and makes a reservation, then the dialer can connect via the relayed address.
|
27
27
|
*
|
28
28
|
* ```TypeScript
|
29
|
-
* import { noise } from '@
|
30
|
-
* import { yamux } from '@
|
29
|
+
* import { noise } from '@libp2p/noise'
|
30
|
+
* import { yamux } from '@libp2p/yamux'
|
31
31
|
* import { echo } from '@libp2p/echo'
|
32
32
|
* import { circuitRelayTransport, circuitRelayServer } from '@libp2p/circuit-relay-v2'
|
33
33
|
* import { identify } from '@libp2p/identify'
|
@@ -35,7 +35,6 @@
|
|
35
35
|
* import { webSockets } from '@libp2p/websockets'
|
36
36
|
* import { WebRTC } from '@multiformats/multiaddr-matcher'
|
37
37
|
* import delay from 'delay'
|
38
|
-
* import { pipe } from 'it-pipe'
|
39
38
|
* import { createLibp2p } from 'libp2p'
|
40
39
|
* import type { Multiaddr } from '@multiformats/multiaddr'
|
41
40
|
*
|
@@ -134,15 +133,11 @@
|
|
134
133
|
* await relay.stop()
|
135
134
|
*
|
136
135
|
* // send/receive some data from the remote peer via a direct connection
|
137
|
-
*
|
138
|
-
*
|
139
|
-
*
|
140
|
-
*
|
141
|
-
*
|
142
|
-
* console.info(new TextDecoder().decode(buf.subarray()))
|
143
|
-
* }
|
144
|
-
* }
|
145
|
-
* )
|
136
|
+
* stream.send(new TextEncoder().encode('hello world'))
|
137
|
+
*
|
138
|
+
* stream.addEventListener('message', (evt) => {
|
139
|
+
* console.info(new TextDecoder().decode(evt.data.subarray()))
|
140
|
+
* })
|
146
141
|
* ```
|
147
142
|
*
|
148
143
|
* @example WebRTC Direct
|
@@ -167,7 +162,6 @@
|
|
167
162
|
* ```TypeScript
|
168
163
|
* import { createLibp2p } from 'libp2p'
|
169
164
|
* import { multiaddr } from '@multiformats/multiaddr'
|
170
|
-
* import { pipe } from 'it-pipe'
|
171
165
|
* import { fromString, toString } from 'uint8arrays'
|
172
166
|
* import { webRTCDirect } from '@libp2p/webrtc'
|
173
167
|
*
|
@@ -196,15 +190,11 @@
|
|
196
190
|
* signal: AbortSignal.timeout(10_000)
|
197
191
|
* })
|
198
192
|
*
|
199
|
-
*
|
200
|
-
*
|
201
|
-
*
|
202
|
-
*
|
203
|
-
*
|
204
|
-
* console.info(toString(buf.subarray()))
|
205
|
-
* }
|
206
|
-
* }
|
207
|
-
* )
|
193
|
+
* stream.send(new TextEncoder().encode('hello world'))
|
194
|
+
*
|
195
|
+
* stream.addEventListener('message', (evt) => {
|
196
|
+
* console.info(new TextDecoder().decode(evt.data.subarray()))
|
197
|
+
* })
|
208
198
|
* ```
|
209
199
|
*
|
210
200
|
* ## WebRTC Direct certificate hashes
|
package/dist/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4PG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAwFxE,SAAS,YAAY,CAAE,IAAgC;IACrD,OAAO,CAAC,UAA2C,EAAE,EAAE,CAAC,IAAI,qBAAqB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACrG,CAAC;AAID,SAAS,MAAM,CAAE,IAA0B;IACzC,OAAO,CAAC,UAAqC,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACzF,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/src/muxer.d.ts
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
+
import { AbstractStreamMuxer } from '@libp2p/utils';
|
2
|
+
import { WebRTCStream } from './stream.js';
|
1
3
|
import type { DataChannelOptions } from './index.js';
|
2
|
-
import type { ComponentLogger,
|
3
|
-
import type { AbortOptions } from '@multiformats/multiaddr';
|
4
|
-
import type { Source, Sink } from 'it-stream-types';
|
5
|
-
import type { Uint8ArrayList } from 'uint8arraylist';
|
4
|
+
import type { ComponentLogger, CounterGroup, StreamMuxer, StreamMuxerFactory, CreateStreamOptions, MultiaddrConnection } from '@libp2p/interface';
|
6
5
|
export interface DataChannelMuxerFactoryInit {
|
7
6
|
/**
|
8
7
|
* WebRTC Peer Connection
|
@@ -16,32 +15,27 @@ export interface DataChannelMuxerFactoryInit {
|
|
16
15
|
* Optional metrics for this data channel muxer
|
17
16
|
*/
|
18
17
|
metrics?: CounterGroup;
|
18
|
+
/**
|
19
|
+
* Options used to create data channels
|
20
|
+
*/
|
19
21
|
dataChannelOptions?: DataChannelOptions;
|
20
22
|
}
|
21
23
|
export interface DataChannelMuxerFactoryComponents {
|
22
24
|
logger: ComponentLogger;
|
23
25
|
}
|
24
|
-
interface BufferedStream {
|
25
|
-
stream: Stream;
|
26
|
-
channel: RTCDataChannel;
|
27
|
-
onEnd(err?: Error): void;
|
28
|
-
}
|
29
26
|
export declare class DataChannelMuxerFactory implements StreamMuxerFactory {
|
30
27
|
readonly protocol: string;
|
31
28
|
/**
|
32
29
|
* WebRTC Peer Connection
|
33
30
|
*/
|
34
31
|
private readonly peerConnection;
|
35
|
-
private bufferedStreams;
|
36
32
|
private readonly metrics?;
|
37
33
|
private readonly dataChannelOptions?;
|
38
|
-
|
39
|
-
|
40
|
-
constructor(components: DataChannelMuxerFactoryComponents, init: DataChannelMuxerFactoryInit);
|
41
|
-
createStreamMuxer(init?: StreamMuxerInit): StreamMuxer;
|
34
|
+
constructor(init: DataChannelMuxerFactoryInit);
|
35
|
+
createStreamMuxer(maConn: MultiaddrConnection): StreamMuxer;
|
42
36
|
}
|
43
|
-
export interface DataChannelMuxerInit extends DataChannelMuxerFactoryInit
|
44
|
-
|
37
|
+
export interface DataChannelMuxerInit extends DataChannelMuxerFactoryInit {
|
38
|
+
protocol: string;
|
45
39
|
}
|
46
40
|
export interface DataChannelMuxerComponents {
|
47
41
|
logger: ComponentLogger;
|
@@ -49,37 +43,11 @@ export interface DataChannelMuxerComponents {
|
|
49
43
|
/**
|
50
44
|
* A libp2p data channel stream muxer
|
51
45
|
*/
|
52
|
-
export declare class DataChannelMuxer implements StreamMuxer {
|
53
|
-
#private;
|
54
|
-
readonly init: DataChannelMuxerInit;
|
55
|
-
/**
|
56
|
-
* Array of streams in the data channel
|
57
|
-
*/
|
58
|
-
streams: Stream[];
|
59
|
-
protocol: string;
|
60
|
-
private readonly log;
|
46
|
+
export declare class DataChannelMuxer extends AbstractStreamMuxer<WebRTCStream> implements StreamMuxer<WebRTCStream> {
|
61
47
|
private readonly peerConnection;
|
62
48
|
private readonly dataChannelOptions;
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
/**
|
67
|
-
* Gracefully close all tracked streams and stop the muxer
|
68
|
-
*/
|
69
|
-
close(options?: AbortOptions): Promise<void>;
|
70
|
-
/**
|
71
|
-
* Abort all tracked streams and stop the muxer
|
72
|
-
*/
|
73
|
-
abort(err: Error): void;
|
74
|
-
/**
|
75
|
-
* The stream source, a no-op as the transport natively supports multiplexing
|
76
|
-
*/
|
77
|
-
source: AsyncGenerator<Uint8Array, any, unknown>;
|
78
|
-
/**
|
79
|
-
* The stream destination, a no-op as the transport natively supports multiplexing
|
80
|
-
*/
|
81
|
-
sink: Sink<Source<Uint8Array | Uint8ArrayList>, Promise<void>>;
|
82
|
-
newStream(): Stream;
|
49
|
+
constructor(maConn: MultiaddrConnection, init: DataChannelMuxerInit);
|
50
|
+
onCreateStream(options?: CreateStreamOptions): Promise<WebRTCStream>;
|
51
|
+
onData(): void;
|
83
52
|
}
|
84
|
-
export {};
|
85
53
|
//# sourceMappingURL=muxer.d.ts.map
|
package/dist/src/muxer.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"muxer.d.ts","sourceRoot":"","sources":["../../src/muxer.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"muxer.d.ts","sourceRoot":"","sources":["../../src/muxer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAgB,YAAY,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,K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AAC,YAAY,CAAC;IAoB3E,MAAM,IAAK,IAAI;CAGhB"}
|
package/dist/src/muxer.js
CHANGED
@@ -1,59 +1,25 @@
|
|
1
|
+
import { AbstractStreamMuxer } from '@libp2p/utils';
|
1
2
|
import { MUXER_PROTOCOL } from './constants.js';
|
2
|
-
import { createStream } from './stream.js';
|
3
|
-
import { drainAndClose, nopSink, nopSource } from './util.js';
|
3
|
+
import { createStream, WebRTCStream } from './stream.js';
|
4
4
|
export class DataChannelMuxerFactory {
|
5
5
|
protocol;
|
6
6
|
/**
|
7
7
|
* WebRTC Peer Connection
|
8
8
|
*/
|
9
9
|
peerConnection;
|
10
|
-
bufferedStreams = [];
|
11
10
|
metrics;
|
12
11
|
dataChannelOptions;
|
13
|
-
|
14
|
-
log;
|
15
|
-
constructor(components, init) {
|
16
|
-
this.components = components;
|
12
|
+
constructor(init) {
|
17
13
|
this.peerConnection = init.peerConnection;
|
18
14
|
this.metrics = init.metrics;
|
19
15
|
this.protocol = init.protocol ?? MUXER_PROTOCOL;
|
20
16
|
this.dataChannelOptions = init.dataChannelOptions ?? {};
|
21
|
-
this.log = components.logger.forComponent('libp2p:webrtc:muxerfactory');
|
22
|
-
// store any data channels opened before upgrade has been completed
|
23
|
-
this.peerConnection.ondatachannel = ({ channel }) => {
|
24
|
-
this.log.trace('incoming early datachannel with channel id %d and label "%s"', channel.id);
|
25
|
-
// 'init' channel is only used during connection establishment
|
26
|
-
if (channel.label === 'init') {
|
27
|
-
this.log.trace('closing early init channel');
|
28
|
-
channel.close();
|
29
|
-
return;
|
30
|
-
}
|
31
|
-
// @ts-expect-error fields are set below
|
32
|
-
const bufferedStream = {};
|
33
|
-
const stream = createStream({
|
34
|
-
channel,
|
35
|
-
direction: 'inbound',
|
36
|
-
onEnd: (err) => {
|
37
|
-
bufferedStream.onEnd(err);
|
38
|
-
},
|
39
|
-
log: this.log,
|
40
|
-
...this.dataChannelOptions
|
41
|
-
});
|
42
|
-
bufferedStream.stream = stream;
|
43
|
-
bufferedStream.channel = channel;
|
44
|
-
bufferedStream.onEnd = () => {
|
45
|
-
this.bufferedStreams = this.bufferedStreams.filter(s => s.stream.id !== stream.id);
|
46
|
-
};
|
47
|
-
this.bufferedStreams.push(bufferedStream);
|
48
|
-
};
|
49
17
|
}
|
50
|
-
createStreamMuxer(
|
51
|
-
return new DataChannelMuxer(
|
52
|
-
...init,
|
18
|
+
createStreamMuxer(maConn) {
|
19
|
+
return new DataChannelMuxer(maConn, {
|
53
20
|
peerConnection: this.peerConnection,
|
54
21
|
dataChannelOptions: this.dataChannelOptions,
|
55
22
|
metrics: this.metrics,
|
56
|
-
streams: this.bufferedStreams,
|
57
23
|
protocol: this.protocol
|
58
24
|
});
|
59
25
|
}
|
@@ -61,26 +27,16 @@ export class DataChannelMuxerFactory {
|
|
61
27
|
/**
|
62
28
|
* A libp2p data channel stream muxer
|
63
29
|
*/
|
64
|
-
export class DataChannelMuxer {
|
65
|
-
init;
|
66
|
-
/**
|
67
|
-
* Array of streams in the data channel
|
68
|
-
*/
|
69
|
-
streams;
|
70
|
-
protocol;
|
71
|
-
log;
|
30
|
+
export class DataChannelMuxer extends AbstractStreamMuxer {
|
72
31
|
peerConnection;
|
73
32
|
dataChannelOptions;
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
this.logger = components.logger;
|
80
|
-
this.streams = init.streams.map(s => s.stream);
|
33
|
+
constructor(maConn, init) {
|
34
|
+
super(maConn, {
|
35
|
+
...init,
|
36
|
+
name: 'muxer'
|
37
|
+
});
|
81
38
|
this.peerConnection = init.peerConnection;
|
82
39
|
this.protocol = init.protocol ?? MUXER_PROTOCOL;
|
83
|
-
this.metrics = init.metrics;
|
84
40
|
this.dataChannelOptions = init.dataChannelOptions ?? {};
|
85
41
|
/**
|
86
42
|
* Fired when a data channel has been added to the connection has been
|
@@ -89,105 +45,41 @@ export class DataChannelMuxer {
|
|
89
45
|
* {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/datachannel_event}
|
90
46
|
*/
|
91
47
|
this.peerConnection.ondatachannel = ({ channel }) => {
|
92
|
-
this.log.trace('incoming datachannel with channel id %d', channel.id);
|
93
|
-
// 'init' channel is only used during connection establishment
|
48
|
+
this.log.trace('incoming %s datachannel with channel id %d, protocol %s and status %s', channel.protocol, channel.id, channel.protocol, channel.readyState);
|
49
|
+
// 'init' channel is only used during connection establishment, it is
|
50
|
+
// closed by the initiator
|
94
51
|
if (channel.label === 'init') {
|
95
|
-
this.log.trace('closing init channel');
|
52
|
+
this.log.trace('closing init channel %d', channel.id);
|
96
53
|
channel.close();
|
97
54
|
return;
|
98
55
|
}
|
99
|
-
// lib-datachannel throws if `.getId` is called on a closed channel so
|
100
|
-
// memoize it
|
101
|
-
const id = channel.id;
|
102
56
|
const stream = createStream({
|
57
|
+
...this.streamOptions,
|
58
|
+
...this.dataChannelOptions,
|
103
59
|
channel,
|
104
60
|
direction: 'inbound',
|
105
|
-
|
106
|
-
this.#onStreamEnd(stream, channel);
|
107
|
-
this.log('incoming channel %s ended', id);
|
108
|
-
},
|
109
|
-
log: this.log,
|
110
|
-
...this.dataChannelOptions
|
61
|
+
log: this.log
|
111
62
|
});
|
112
|
-
this.
|
113
|
-
this.metrics?.increment({ incoming_stream: true });
|
114
|
-
init?.onIncomingStream?.(stream);
|
63
|
+
this.onRemoteStream(stream);
|
115
64
|
};
|
116
|
-
// the DataChannelMuxer constructor is called during set up of the
|
117
|
-
// connection by the upgrader.
|
118
|
-
//
|
119
|
-
// If we invoke `init.onIncomingStream` immediately, the connection object
|
120
|
-
// will not be set up yet so add a tiny delay before letting the
|
121
|
-
// connection know about early streams
|
122
|
-
if (this.init.streams.length > 0) {
|
123
|
-
queueMicrotask(() => {
|
124
|
-
this.init.streams.forEach(bufferedStream => {
|
125
|
-
bufferedStream.onEnd = () => {
|
126
|
-
this.log('incoming early channel %s ended with state %s', bufferedStream.channel.id, bufferedStream.channel.readyState);
|
127
|
-
this.#onStreamEnd(bufferedStream.stream, bufferedStream.channel);
|
128
|
-
};
|
129
|
-
this.metrics?.increment({ incoming_stream: true });
|
130
|
-
this.init?.onIncomingStream?.(bufferedStream.stream);
|
131
|
-
});
|
132
|
-
});
|
133
|
-
}
|
134
65
|
}
|
135
|
-
|
136
|
-
this.log.trace('stream %s %s %s onEnd', stream.direction, stream.id, stream.protocol);
|
137
|
-
drainAndClose(channel, `${stream.direction} ${stream.id} ${stream.protocol}`, this.dataChannelOptions.drainTimeout, {
|
138
|
-
log: this.log
|
139
|
-
});
|
140
|
-
this.streams = this.streams.filter(s => s.id !== stream.id);
|
141
|
-
this.metrics?.increment({ stream_end: true });
|
142
|
-
this.init?.onStreamEnd?.(stream);
|
143
|
-
}
|
144
|
-
/**
|
145
|
-
* Gracefully close all tracked streams and stop the muxer
|
146
|
-
*/
|
147
|
-
async close(options) {
|
148
|
-
try {
|
149
|
-
await Promise.all(this.streams.map(async (stream) => stream.close(options)));
|
150
|
-
}
|
151
|
-
catch (err) {
|
152
|
-
this.abort(err);
|
153
|
-
}
|
154
|
-
}
|
155
|
-
/**
|
156
|
-
* Abort all tracked streams and stop the muxer
|
157
|
-
*/
|
158
|
-
abort(err) {
|
159
|
-
for (const stream of this.streams) {
|
160
|
-
stream.abort(err);
|
161
|
-
}
|
162
|
-
}
|
163
|
-
/**
|
164
|
-
* The stream source, a no-op as the transport natively supports multiplexing
|
165
|
-
*/
|
166
|
-
source = nopSource();
|
167
|
-
/**
|
168
|
-
* The stream destination, a no-op as the transport natively supports multiplexing
|
169
|
-
*/
|
170
|
-
sink = nopSink;
|
171
|
-
newStream() {
|
66
|
+
async onCreateStream(options) {
|
172
67
|
// The spec says the label MUST be an empty string: https://github.com/libp2p/specs/blob/master/webrtc/README.md#rtcdatachannel-label
|
173
|
-
const channel = this.peerConnection.createDataChannel(''
|
174
|
-
//
|
175
|
-
//
|
176
|
-
|
177
|
-
this.log
|
68
|
+
const channel = this.peerConnection.createDataChannel('', {
|
69
|
+
// TODO: pre-negotiate stream protocol
|
70
|
+
// protocol: options?.protocol
|
71
|
+
});
|
72
|
+
this.log('open channel %d for protocol %s', channel.id, options?.protocol);
|
178
73
|
const stream = createStream({
|
74
|
+
...options,
|
75
|
+
...this.dataChannelOptions,
|
179
76
|
channel,
|
180
77
|
direction: 'outbound',
|
181
|
-
|
182
|
-
this.#onStreamEnd(stream, channel);
|
183
|
-
this.log('outgoing channel %s ended', id);
|
184
|
-
},
|
185
|
-
log: this.log,
|
186
|
-
...this.dataChannelOptions
|
78
|
+
log: this.log
|
187
79
|
});
|
188
|
-
this.streams.push(stream);
|
189
|
-
this.metrics?.increment({ outgoing_stream: true });
|
190
80
|
return stream;
|
191
81
|
}
|
82
|
+
onData() {
|
83
|
+
}
|
192
84
|
}
|
193
85
|
//# sourceMappingURL=muxer.js.map
|
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,
|
1
|
+
{"version":3,"file":"muxer.js","sourceRoot":"","sources":["../../src/muxer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AA8BxD,MAAM,OAAO,uBAAuB;IAClB,QAAQ,CAAQ;IAEhC;;OAEG;IACc,cAAc,CAAmB;IACjC,OAAO,CAAe;IACtB,kBAAkB,CAAqB;IAExD,YAAa,IAAiC;QAC5C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,cAAc,CAAA;QAC/C,IAAI,CAAC,kBAAkB,GAAG,IAAI,C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