@libp2p/webrtc 5.2.24-87bc8d4fb → 5.2.24-9a9b11fd4

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.
Files changed (90) hide show
  1. package/README.md +10 -20
  2. package/dist/index.min.js +18 -18
  3. package/dist/index.min.js.map +4 -4
  4. package/dist/src/constants.d.ts +4 -23
  5. package/dist/src/constants.d.ts.map +1 -1
  6. package/dist/src/constants.js +4 -23
  7. package/dist/src/constants.js.map +1 -1
  8. package/dist/src/index.d.ts +20 -22
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/index.js +12 -22
  11. package/dist/src/index.js.map +1 -1
  12. package/dist/src/muxer.d.ts +14 -46
  13. package/dist/src/muxer.d.ts.map +1 -1
  14. package/dist/src/muxer.js +30 -138
  15. package/dist/src/muxer.js.map +1 -1
  16. package/dist/src/private-to-private/initiate-connection.d.ts +2 -3
  17. package/dist/src/private-to-private/initiate-connection.d.ts.map +1 -1
  18. package/dist/src/private-to-private/initiate-connection.js +37 -5
  19. package/dist/src/private-to-private/initiate-connection.js.map +1 -1
  20. package/dist/src/private-to-private/signaling-stream-handler.d.ts +4 -4
  21. package/dist/src/private-to-private/signaling-stream-handler.d.ts.map +1 -1
  22. package/dist/src/private-to-private/signaling-stream-handler.js +19 -7
  23. package/dist/src/private-to-private/signaling-stream-handler.js.map +1 -1
  24. package/dist/src/private-to-private/transport.d.ts +2 -9
  25. package/dist/src/private-to-private/transport.d.ts.map +1 -1
  26. package/dist/src/private-to-private/transport.js +30 -15
  27. package/dist/src/private-to-private/transport.js.map +1 -1
  28. package/dist/src/private-to-private/util.d.ts +3 -2
  29. package/dist/src/private-to-private/util.d.ts.map +1 -1
  30. package/dist/src/private-to-private/util.js +26 -14
  31. package/dist/src/private-to-private/util.js.map +1 -1
  32. package/dist/src/private-to-public/listener.d.ts.map +1 -1
  33. package/dist/src/private-to-public/listener.js +21 -15
  34. package/dist/src/private-to-public/listener.js.map +1 -1
  35. package/dist/src/private-to-public/transport.d.ts +0 -8
  36. package/dist/src/private-to-public/transport.d.ts.map +1 -1
  37. package/dist/src/private-to-public/transport.js +3 -2
  38. package/dist/src/private-to-public/transport.js.map +1 -1
  39. package/dist/src/private-to-public/utils/connect.d.ts +1 -1
  40. package/dist/src/private-to-public/utils/connect.d.ts.map +1 -1
  41. package/dist/src/private-to-public/utils/connect.js +17 -14
  42. package/dist/src/private-to-public/utils/connect.js.map +1 -1
  43. package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts +4 -4
  44. package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts.map +1 -1
  45. package/dist/src/private-to-public/utils/get-rtcpeerconnection.js +13 -2
  46. package/dist/src/private-to-public/utils/get-rtcpeerconnection.js.map +1 -1
  47. package/dist/src/private-to-public/utils/sdp.d.ts.map +1 -1
  48. package/dist/src/private-to-public/utils/sdp.js +25 -13
  49. package/dist/src/private-to-public/utils/sdp.js.map +1 -1
  50. package/dist/src/private-to-public/utils/stun-listener.js +1 -1
  51. package/dist/src/private-to-public/utils/stun-listener.js.map +1 -1
  52. package/dist/src/rtcpeerconnection-to-conn.d.ts +12 -0
  53. package/dist/src/rtcpeerconnection-to-conn.d.ts.map +1 -0
  54. package/dist/src/rtcpeerconnection-to-conn.js +46 -0
  55. package/dist/src/rtcpeerconnection-to-conn.js.map +1 -0
  56. package/dist/src/stream.d.ts +14 -26
  57. package/dist/src/stream.d.ts.map +1 -1
  58. package/dist/src/stream.js +134 -204
  59. package/dist/src/stream.js.map +1 -1
  60. package/dist/src/util.d.ts +3 -1
  61. package/dist/src/util.d.ts.map +1 -1
  62. package/dist/src/util.js +19 -0
  63. package/dist/src/util.js.map +1 -1
  64. package/dist/src/webrtc/index.d.ts +1 -1
  65. package/dist/src/webrtc/index.d.ts.map +1 -1
  66. package/dist/src/webrtc/index.js +1 -1
  67. package/dist/src/webrtc/index.js.map +1 -1
  68. package/package.json +26 -29
  69. package/src/constants.ts +5 -28
  70. package/src/index.ts +21 -22
  71. package/src/muxer.ts +39 -169
  72. package/src/private-to-private/initiate-connection.ts +46 -8
  73. package/src/private-to-private/signaling-stream-handler.ts +23 -10
  74. package/src/private-to-private/transport.ts +33 -25
  75. package/src/private-to-private/util.ts +33 -16
  76. package/src/private-to-public/listener.ts +22 -15
  77. package/src/private-to-public/transport.ts +3 -12
  78. package/src/private-to-public/utils/connect.ts +18 -15
  79. package/src/private-to-public/utils/get-rtcpeerconnection.ts +16 -4
  80. package/src/private-to-public/utils/sdp.ts +29 -13
  81. package/src/private-to-public/utils/stun-listener.ts +1 -1
  82. package/src/rtcpeerconnection-to-conn.ts +66 -0
  83. package/src/stream.ts +153 -237
  84. package/src/util.ts +22 -1
  85. package/src/webrtc/index.ts +1 -1
  86. package/dist/src/maconn.d.ts +0 -58
  87. package/dist/src/maconn.d.ts.map +0 -1
  88. package/dist/src/maconn.js +0 -56
  89. package/dist/src/maconn.js.map +0 -1
  90. package/src/maconn.ts +0 -101
@@ -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,MAAS,CAAA;AAEzC;;GAEG;AACH,eAAO,MAAM,cAAc,MAAS,CAAA;AAEpC;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAkB,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAAY,CAAA;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,QAAY,CAAA;AAsBzC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAA8B,CAAA;AAE5D;;;;GAIG;AACH,eAAO,MAAM,eAAe,OAAQ,CAAA;AAEpC;;;GAGG;AACH,eAAO,MAAM,YAAY,OAAQ,CAAA;AAEjC;;;GAGG;AACH,eAAO,MAAM,0BA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CAAqC,WAAa,CAAA"}
@@ -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 '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;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"}
@@ -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 '@chainsafe/libp2p-noise'
30
- * import { yamux } from '@chainsafe/libp2p-yamux'
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
- * await pipe(
138
- * [new TextEncoder().encode('hello world')],
139
- * stream,
140
- * async source => {
141
- * for await (const buf of source) {
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
- * await pipe(
200
- * [fromString(`Hello js-libp2p-webrtc\n`)],
201
- * stream,
202
- * async function (source) {
203
- * for await (const buf of source) {
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AyB,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 '@chainsafe/libp2p-noise'
30
- * import { yamux } from '@chainsafe/libp2p-yamux'
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
- * await pipe(
138
- * [new TextEncoder().encode('hello world')],
139
- * stream,
140
- * async source => {
141
- * for await (const buf of source) {
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
- * await pipe(
200
- * [fromString(`Hello js-libp2p-webrtc\n`)],
201
- * stream,
202
- * async function (source) {
203
- * for await (const buf of source) {
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AA+ExE,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"}
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"}
@@ -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, Stream, CounterGroup, StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface';
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
- private readonly components;
39
- private readonly log;
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, StreamMuxerInit {
44
- streams: BufferedStream[];
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
- private readonly metrics?;
64
- private readonly logger;
65
- constructor(components: DataChannelMuxerComponents, init: DataChannelMuxerInit);
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
@@ -1 +1 @@
1
- {"version":3,"file":"muxer.d.ts","sourceRoot":"","sources":["../../src/muxer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EAAE,eAAe,EAAU,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxI,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,cAAc,EAAE,iBAAiB,CAAA;IAEjC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;OAEG;IACH,OAAO,CAAC,EAAE,YAAY,CAAA;IAEtB,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;CACxC;AAED,MAAM,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AC,QAAQ,CAAC,OAAO,CAAC,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAoB;gBAE3C,IAAI,EAAE,2BAA2B;IAO9C,iBAAiB,CAAE,MAAM,EAAE,mBAAmB,GAAG,WAAW;CAQ7D;AAED,MAAM,WAAW,oBAAqB,SAAQ,2BAA2B;IACvE,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,eAAe,CAAA;CACxB;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,mBAAmB,CAAC,YAAY,CAAE,YAAW,WAAW,CAAC,YAAY,CAAC;IAC1G,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmB;IAClD,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;gBAE1C,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,oBAAoB;IAwC9D,cAAc,CAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,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
- components;
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(init) {
51
- return new DataChannelMuxer(this.components, {
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
- metrics;
75
- logger;
76
- constructor(components, init) {
77
- this.init = init;
78
- this.log = init.log?.newScope('muxer') ?? components.logger.forComponent('libp2p:webrtc:muxer');
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
- onEnd: () => {
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.streams.push(stream);
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
- #onStreamEnd(stream, channel) {
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
- // lib-datachannel throws if `.getId` is called on a closed channel so
175
- // memoize it
176
- const id = channel.id;
177
- this.log.trace('opened outgoing datachannel with channel id %s', id);
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
- onEnd: () => {
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
@@ -1 +1 @@
1
- {"version":3,"file":"muxer.js","sourceRoot":"","sources":["../../src/muxer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAoC7D,MAAM,OAAO,uBAAuB;IAClB,QAAQ,CAAQ;IAEhC;;OAEG;IACc,cAAc,CAAmB;IAC1C,eAAe,GAAqB,EAAE,CAAA;IAC7B,OAAO,CAAe;IACtB,kBAAkB,CAAqB;IACvC,UAAU,CAAmC;IAC7C,GAAG,CAAQ;IAE5B,YAAa,UAA6C,EAAE,IAAiC;QAC3F,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,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,CAAC,kBAAkB,IAAI,EAAE,CAAA;QACvD,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,4BAA4B,CAAC,CAAA;QAEvE,mEAAmE;QACnE,IAAI,CAAC,cAAc,CAAC,aAAa,GAAG,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;YAClD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,8DAA8D,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;YAE1F,8DAA8D;YA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