@libp2p/webrtc 5.2.24-6059227cb → 5.2.24-87bc8d4fb
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 +20 -10
- package/dist/index.min.js +18 -18
- package/dist/index.min.js.map +4 -4
- package/dist/src/constants.d.ts +23 -4
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +23 -4
- package/dist/src/constants.js.map +1 -1
- package/dist/src/index.d.ts +22 -20
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +22 -12
- package/dist/src/index.js.map +1 -1
- package/dist/src/maconn.d.ts +58 -0
- package/dist/src/maconn.d.ts.map +1 -0
- package/dist/src/maconn.js +56 -0
- package/dist/src/maconn.js.map +1 -0
- package/dist/src/muxer.d.ts +46 -14
- package/dist/src/muxer.d.ts.map +1 -1
- package/dist/src/muxer.js +138 -30
- package/dist/src/muxer.js.map +1 -1
- package/dist/src/private-to-private/initiate-connection.d.ts +3 -2
- package/dist/src/private-to-private/initiate-connection.d.ts.map +1 -1
- package/dist/src/private-to-private/initiate-connection.js +5 -37
- 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 +7 -19
- package/dist/src/private-to-private/signaling-stream-handler.js.map +1 -1
- package/dist/src/private-to-private/transport.d.ts +9 -2
- package/dist/src/private-to-private/transport.d.ts.map +1 -1
- package/dist/src/private-to-private/transport.js +15 -30
- package/dist/src/private-to-private/transport.js.map +1 -1
- package/dist/src/private-to-private/util.d.ts +2 -3
- package/dist/src/private-to-private/util.d.ts.map +1 -1
- package/dist/src/private-to-private/util.js +14 -26
- 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 +15 -21
- package/dist/src/private-to-public/listener.js.map +1 -1
- package/dist/src/private-to-public/transport.d.ts +8 -0
- package/dist/src/private-to-public/transport.d.ts.map +1 -1
- package/dist/src/private-to-public/transport.js +2 -3
- 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 +14 -17
- 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 +2 -13
- 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 +13 -25
- 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/stream.d.ts +26 -14
- package/dist/src/stream.d.ts.map +1 -1
- package/dist/src/stream.js +204 -134
- package/dist/src/stream.js.map +1 -1
- package/dist/src/util.d.ts +1 -3
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js +0 -19
- 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 +29 -26
- package/src/constants.ts +28 -5
- package/src/index.ts +22 -21
- package/src/maconn.ts +101 -0
- package/src/muxer.ts +169 -39
- package/src/private-to-private/initiate-connection.ts +8 -46
- package/src/private-to-private/signaling-stream-handler.ts +10 -23
- package/src/private-to-private/transport.ts +25 -33
- package/src/private-to-private/util.ts +16 -33
- package/src/private-to-public/listener.ts +15 -22
- package/src/private-to-public/transport.ts +12 -3
- package/src/private-to-public/utils/connect.ts +15 -18
- package/src/private-to-public/utils/get-rtcpeerconnection.ts +4 -16
- package/src/private-to-public/utils/sdp.ts +13 -29
- package/src/private-to-public/utils/stun-listener.ts +1 -1
- package/src/stream.ts +237 -153
- package/src/util.ts +1 -22
- package/src/webrtc/index.ts +1 -1
- package/dist/src/rtcpeerconnection-to-conn.d.ts +0 -12
- package/dist/src/rtcpeerconnection-to-conn.d.ts.map +0 -1
- package/dist/src/rtcpeerconnection-to-conn.js +0 -46
- package/dist/src/rtcpeerconnection-to-conn.js.map +0 -1
- package/src/rtcpeerconnection-to-conn.ts +0 -66
package/dist/src/constants.d.ts
CHANGED
@@ -15,10 +15,22 @@ 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;
|
18
26
|
/**
|
19
27
|
* How much can be buffered to the DataChannel at once
|
20
28
|
*/
|
21
29
|
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;
|
22
34
|
/**
|
23
35
|
* Max message size that can be sent to the DataChannel. In browsers this is
|
24
36
|
* 256KiB but go-libp2p and rust-libp2p only support 16KiB at the time of
|
@@ -33,15 +45,22 @@ export declare const MAX_MESSAGE_SIZE: number;
|
|
33
45
|
* protobuf that aren't message field bytes
|
34
46
|
*/
|
35
47
|
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;
|
36
59
|
/**
|
37
60
|
* When closing a stream, we wait for `bufferedAmount` to become 0 before
|
38
61
|
* closing the underlying RTCDataChannel - this controls how long we wait in ms
|
39
62
|
*/
|
40
63
|
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;
|
45
64
|
/**
|
46
65
|
* Set as the 'negotiated' muxer protocol name
|
47
66
|
*/
|
@@ -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,QAAkB,CAAA;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,QAAY,CAAA;AAsBzC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,QAA8B,CAAA;AAE5D;;;GAGG;AACH,eAAO,MAAM,
|
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,0BAA0B,QAAS,CAAA;AAEhD;;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,10 +22,22 @@ 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;
|
25
33
|
/**
|
26
34
|
* How much can be buffered to the DataChannel at once
|
27
35
|
*/
|
28
36
|
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;
|
29
41
|
/**
|
30
42
|
* Max message size that can be sent to the DataChannel. In browsers this is
|
31
43
|
* 256KiB but go-libp2p and rust-libp2p only support 16KiB at the time of
|
@@ -57,15 +69,22 @@ function calculateProtobufOverhead(maxMessageSize = MAX_MESSAGE_SIZE) {
|
|
57
69
|
* protobuf that aren't message field bytes
|
58
70
|
*/
|
59
71
|
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;
|
60
83
|
/**
|
61
84
|
* When closing a stream, we wait for `bufferedAmount` to become 0 before
|
62
85
|
* closing the underlying RTCDataChannel - this controls how long we wait in ms
|
63
86
|
*/
|
64
87
|
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;
|
69
88
|
/**
|
70
89
|
* Set as the 'negotiated' muxer protocol name
|
71
90
|
*/
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names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SAAS,GAAG,cAAc,GAAG,aAAa,GAAG,SAAS,GAAG,kBAAkB,CAAA;IAEjF,+DAA+D;IAC/D,MAAM,wBAAwB,GAAG,cAAc,CAAC,SAAS,CAAC,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;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA;AAEpC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAA;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAA;AAEhD;;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 '@libp2p
|
30
|
-
* import { yamux } from '@libp2p
|
29
|
+
* import { noise } from '@chainsafe/libp2p-noise'
|
30
|
+
* import { yamux } from '@chainsafe/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,6 +35,7 @@
|
|
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'
|
38
39
|
* import { createLibp2p } from 'libp2p'
|
39
40
|
* import type { Multiaddr } from '@multiformats/multiaddr'
|
40
41
|
*
|
@@ -133,11 +134,15 @@
|
|
133
134
|
* await relay.stop()
|
134
135
|
*
|
135
136
|
* // send/receive some data from the remote peer via a direct connection
|
136
|
-
*
|
137
|
-
*
|
138
|
-
*
|
139
|
-
*
|
140
|
-
*
|
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
|
+
* )
|
141
146
|
* ```
|
142
147
|
*
|
143
148
|
* @example WebRTC Direct
|
@@ -162,6 +167,7 @@
|
|
162
167
|
* ```TypeScript
|
163
168
|
* import { createLibp2p } from 'libp2p'
|
164
169
|
* import { multiaddr } from '@multiformats/multiaddr'
|
170
|
+
* import { pipe } from 'it-pipe'
|
165
171
|
* import { fromString, toString } from 'uint8arrays'
|
166
172
|
* import { webRTCDirect } from '@libp2p/webrtc'
|
167
173
|
*
|
@@ -190,11 +196,15 @@
|
|
190
196
|
* signal: AbortSignal.timeout(10_000)
|
191
197
|
* })
|
192
198
|
*
|
193
|
-
*
|
194
|
-
*
|
195
|
-
*
|
196
|
-
*
|
197
|
-
*
|
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
|
+
* )
|
198
208
|
* ```
|
199
209
|
*
|
200
210
|
* ## WebRTC Direct certificate hashes
|
@@ -299,14 +309,6 @@ export interface DataChannelOptions {
|
|
299
309
|
* @default 5_000
|
300
310
|
*/
|
301
311
|
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;
|
310
312
|
}
|
311
313
|
/**
|
312
314
|
* 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsQG;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;CACrB;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 '@libp2p
|
30
|
-
* import { yamux } from '@libp2p
|
29
|
+
* import { noise } from '@chainsafe/libp2p-noise'
|
30
|
+
* import { yamux } from '@chainsafe/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,6 +35,7 @@
|
|
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'
|
38
39
|
* import { createLibp2p } from 'libp2p'
|
39
40
|
* import type { Multiaddr } from '@multiformats/multiaddr'
|
40
41
|
*
|
@@ -133,11 +134,15 @@
|
|
133
134
|
* await relay.stop()
|
134
135
|
*
|
135
136
|
* // send/receive some data from the remote peer via a direct connection
|
136
|
-
*
|
137
|
-
*
|
138
|
-
*
|
139
|
-
*
|
140
|
-
*
|
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
|
+
* )
|
141
146
|
* ```
|
142
147
|
*
|
143
148
|
* @example WebRTC Direct
|
@@ -162,6 +167,7 @@
|
|
162
167
|
* ```TypeScript
|
163
168
|
* import { createLibp2p } from 'libp2p'
|
164
169
|
* import { multiaddr } from '@multiformats/multiaddr'
|
170
|
+
* import { pipe } from 'it-pipe'
|
165
171
|
* import { fromString, toString } from 'uint8arrays'
|
166
172
|
* import { webRTCDirect } from '@libp2p/webrtc'
|
167
173
|
*
|
@@ -190,11 +196,15 @@
|
|
190
196
|
* signal: AbortSignal.timeout(10_000)
|
191
197
|
* })
|
192
198
|
*
|
193
|
-
*
|
194
|
-
*
|
195
|
-
*
|
196
|
-
*
|
197
|
-
*
|
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
|
+
* )
|
198
208
|
* ```
|
199
209
|
*
|
200
210
|
* ## 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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"}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import type { RTCPeerConnection } from './webrtc/index.js';
|
2
|
+
import type { ComponentLogger, Logger, MultiaddrConnection, MultiaddrConnectionTimeline, CounterGroup } from '@libp2p/interface';
|
3
|
+
import type { AbortOptions, Multiaddr } from '@multiformats/multiaddr';
|
4
|
+
import type { Source, Sink } from 'it-stream-types';
|
5
|
+
import type { Uint8ArrayList } from 'uint8arraylist';
|
6
|
+
interface WebRTCMultiaddrConnectionInit {
|
7
|
+
/**
|
8
|
+
* WebRTC Peer Connection
|
9
|
+
*/
|
10
|
+
peerConnection: RTCPeerConnection;
|
11
|
+
/**
|
12
|
+
* The multiaddr address used to communicate with the remote peer
|
13
|
+
*/
|
14
|
+
remoteAddr: Multiaddr;
|
15
|
+
/**
|
16
|
+
* Holds the relevant events timestamps of the connection
|
17
|
+
*/
|
18
|
+
timeline: MultiaddrConnectionTimeline;
|
19
|
+
/**
|
20
|
+
* Optional metrics counter group for this connection
|
21
|
+
*/
|
22
|
+
metrics?: CounterGroup;
|
23
|
+
}
|
24
|
+
export interface WebRTCMultiaddrConnectionComponents {
|
25
|
+
logger: ComponentLogger;
|
26
|
+
}
|
27
|
+
export declare class WebRTCMultiaddrConnection implements MultiaddrConnection {
|
28
|
+
readonly log: Logger;
|
29
|
+
/**
|
30
|
+
* WebRTC Peer Connection
|
31
|
+
*/
|
32
|
+
readonly peerConnection: RTCPeerConnection;
|
33
|
+
/**
|
34
|
+
* The multiaddr address used to communicate with the remote peer
|
35
|
+
*/
|
36
|
+
remoteAddr: Multiaddr;
|
37
|
+
/**
|
38
|
+
* Holds the life cycle times of the connection
|
39
|
+
*/
|
40
|
+
timeline: MultiaddrConnectionTimeline;
|
41
|
+
/**
|
42
|
+
* Optional metrics counter group for this connection
|
43
|
+
*/
|
44
|
+
metrics?: CounterGroup;
|
45
|
+
/**
|
46
|
+
* The stream source, a no-op as the transport natively supports multiplexing
|
47
|
+
*/
|
48
|
+
source: AsyncGenerator<Uint8Array, any, unknown>;
|
49
|
+
/**
|
50
|
+
* The stream destination, a no-op as the transport natively supports multiplexing
|
51
|
+
*/
|
52
|
+
sink: Sink<Source<Uint8Array | Uint8ArrayList>, Promise<void>>;
|
53
|
+
constructor(components: WebRTCMultiaddrConnectionComponents, init: WebRTCMultiaddrConnectionInit);
|
54
|
+
close(options?: AbortOptions): Promise<void>;
|
55
|
+
abort(err: Error): void;
|
56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E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAU;gBAE3D,UAAU,EAAE,mCAAmC,EAAE,IAAI,EAAE,6BAA6B;IAmB3F,KAAK,CAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnD,KAAK,CAAE,GAAG,EAAE,KAAK,GAAG,IAAI;CAOzB"}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { nopSink, nopSource } from './util.js';
|
2
|
+
export class WebRTCMultiaddrConnection {
|
3
|
+
log;
|
4
|
+
/**
|
5
|
+
* WebRTC Peer Connection
|
6
|
+
*/
|
7
|
+
peerConnection;
|
8
|
+
/**
|
9
|
+
* The multiaddr address used to communicate with the remote peer
|
10
|
+
*/
|
11
|
+
remoteAddr;
|
12
|
+
/**
|
13
|
+
* Holds the life cycle times of the connection
|
14
|
+
*/
|
15
|
+
timeline;
|
16
|
+
/**
|
17
|
+
* Optional metrics counter group for this connection
|
18
|
+
*/
|
19
|
+
metrics;
|
20
|
+
/**
|
21
|
+
* The stream source, a no-op as the transport natively supports multiplexing
|
22
|
+
*/
|
23
|
+
source = nopSource();
|
24
|
+
/**
|
25
|
+
* The stream destination, a no-op as the transport natively supports multiplexing
|
26
|
+
*/
|
27
|
+
sink = nopSink;
|
28
|
+
constructor(components, init) {
|
29
|
+
this.log = components.logger.forComponent('libp2p:webrtc:maconn');
|
30
|
+
this.remoteAddr = init.remoteAddr;
|
31
|
+
this.timeline = init.timeline;
|
32
|
+
this.peerConnection = init.peerConnection;
|
33
|
+
const peerConnection = this.peerConnection;
|
34
|
+
const initialState = peerConnection.connectionState;
|
35
|
+
this.peerConnection.onconnectionstatechange = () => {
|
36
|
+
this.log.trace('peer connection state change', peerConnection.connectionState, 'initial state', initialState);
|
37
|
+
if (peerConnection.connectionState === 'disconnected' || peerConnection.connectionState === 'failed' || peerConnection.connectionState === 'closed') {
|
38
|
+
// nothing else to do but close the connection
|
39
|
+
this.timeline.close = Date.now();
|
40
|
+
}
|
41
|
+
};
|
42
|
+
}
|
43
|
+
async close(options) {
|
44
|
+
this.log.trace('closing connection');
|
45
|
+
this.peerConnection.close();
|
46
|
+
this.timeline.close = Date.now();
|
47
|
+
this.metrics?.increment({ close: true });
|
48
|
+
}
|
49
|
+
abort(err) {
|
50
|
+
this.log.error('closing connection due to error', err);
|
51
|
+
this.peerConnection.close();
|
52
|
+
this.timeline.close = Date.now();
|
53
|
+
this.metrics?.increment({ abort: true });
|
54
|
+
}
|
55
|
+
}
|
56
|
+
//# sourceMappingURL=maconn.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"maconn.js","sourceRoot":"","sources":["../../src/maconn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAiC9C,MAAM,OAAO,yBAAyB;IAC3B,GAAG,CAAQ;IAEpB;;OAEG;IACM,cAAc,CAAmB;IAE1C;;OAEG;IACH,UAAU,CAAW;IAErB;;OAEG;IACH,QAAQ,CAA6B;IAErC;;OAEG;IACH,OAAO,CAAe;IAEtB;;OAEG;IACH,MAAM,GAA6C,SAAS,EAAE,CAAA;IAE9D;;OAEG;IACH,IAAI,GAA6D,OAAO,CAAA;IAExE,YAAa,UAA+C,EAAE,IAAmC;QAC/F,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAA;QACjE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAA;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC7B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QAEzC,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QAC1C,MAAM,YAAY,GAAG,cAAc,CAAC,eAAe,CAAA;QAEnD,IAAI,CAAC,cAAc,CAAC,uBAAuB,GAAG,GAAG,EAAE;YACjD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,8BAA8B,EAAE,cAAc,CAAC,eAAe,EAAE,eAAe,EAAE,YAAY,CAAC,CAAA;YAE7G,IAAI,cAAc,CAAC,eAAe,KAAK,cAAc,IAAI,cAAc,CAAC,eAAe,KAAK,QAAQ,IAAI,cAAc,CAAC,eAAe,KAAK,QAAQ,EAAE,CAAC;gBACpJ,8CAA8C;gBAC9C,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;YAClC,CAAC;QACH,CAAC,CAAA;IACH,CAAC;IAED,KAAK,CAAC,KAAK,CAAE,OAAsB;QACjC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAA;QAEpC,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAA;QAC3B,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAChC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED,KAAK,CAAE,GAAU;QACf,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,GAAG,CAAC,CAAA;QAEtD,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAA;QAC3B,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAChC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1C,CAAC;CACF"}
|
package/dist/src/muxer.d.ts
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import { AbstractStreamMuxer } from '@libp2p/utils';
|
2
|
-
import { WebRTCStream } from './stream.js';
|
3
1
|
import type { DataChannelOptions } from './index.js';
|
4
|
-
import type { ComponentLogger, CounterGroup, StreamMuxer, StreamMuxerFactory,
|
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';
|
5
6
|
export interface DataChannelMuxerFactoryInit {
|
6
7
|
/**
|
7
8
|
* WebRTC Peer Connection
|
@@ -15,27 +16,32 @@ export interface DataChannelMuxerFactoryInit {
|
|
15
16
|
* Optional metrics for this data channel muxer
|
16
17
|
*/
|
17
18
|
metrics?: CounterGroup;
|
18
|
-
/**
|
19
|
-
* Options used to create data channels
|
20
|
-
*/
|
21
19
|
dataChannelOptions?: DataChannelOptions;
|
22
20
|
}
|
23
21
|
export interface DataChannelMuxerFactoryComponents {
|
24
22
|
logger: ComponentLogger;
|
25
23
|
}
|
24
|
+
interface BufferedStream {
|
25
|
+
stream: Stream;
|
26
|
+
channel: RTCDataChannel;
|
27
|
+
onEnd(err?: Error): void;
|
28
|
+
}
|
26
29
|
export declare class DataChannelMuxerFactory implements StreamMuxerFactory {
|
27
30
|
readonly protocol: string;
|
28
31
|
/**
|
29
32
|
* WebRTC Peer Connection
|
30
33
|
*/
|
31
34
|
private readonly peerConnection;
|
35
|
+
private bufferedStreams;
|
32
36
|
private readonly metrics?;
|
33
37
|
private readonly dataChannelOptions?;
|
34
|
-
|
35
|
-
|
38
|
+
private readonly components;
|
39
|
+
private readonly log;
|
40
|
+
constructor(components: DataChannelMuxerFactoryComponents, init: DataChannelMuxerFactoryInit);
|
41
|
+
createStreamMuxer(init?: StreamMuxerInit): StreamMuxer;
|
36
42
|
}
|
37
|
-
export interface DataChannelMuxerInit extends DataChannelMuxerFactoryInit {
|
38
|
-
|
43
|
+
export interface DataChannelMuxerInit extends DataChannelMuxerFactoryInit, StreamMuxerInit {
|
44
|
+
streams: BufferedStream[];
|
39
45
|
}
|
40
46
|
export interface DataChannelMuxerComponents {
|
41
47
|
logger: ComponentLogger;
|
@@ -43,11 +49,37 @@ export interface DataChannelMuxerComponents {
|
|
43
49
|
/**
|
44
50
|
* A libp2p data channel stream muxer
|
45
51
|
*/
|
46
|
-
export declare class DataChannelMuxer
|
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;
|
47
61
|
private readonly peerConnection;
|
48
62
|
private readonly dataChannelOptions;
|
49
|
-
|
50
|
-
|
51
|
-
|
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;
|
52
83
|
}
|
84
|
+
export {};
|
53
85
|
//# 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":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,O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