@libp2p/webrtc 6.0.33 → 6.1.0-974e63f20
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 +35 -1
- package/dist/index.min.js +9 -9
- package/dist/index.min.js.map +4 -4
- package/dist/src/constants.d.ts +2 -1
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +2 -1
- package/dist/src/constants.js.map +1 -1
- package/dist/src/index.d.ts +35 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +35 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/private-to-public/listener.d.ts.map +1 -1
- package/dist/src/private-to-public/listener.js +9 -7
- package/dist/src/private-to-public/listener.js.map +1 -1
- package/dist/src/private-to-public/transport.browser.d.ts +9 -0
- package/dist/src/private-to-public/transport.browser.d.ts.map +1 -1
- package/dist/src/private-to-public/transport.browser.js +33 -5
- package/dist/src/private-to-public/transport.browser.js.map +1 -1
- package/dist/src/private-to-public/utils/connect.d.ts +16 -0
- package/dist/src/private-to-public/utils/connect.d.ts.map +1 -1
- package/dist/src/private-to-public/utils/connect.js +77 -16
- package/dist/src/private-to-public/utils/connect.js.map +1 -1
- package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts +4 -1
- package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts.map +1 -1
- package/dist/src/private-to-public/utils/get-rtcpeerconnection.js +18 -11
- package/dist/src/private-to-public/utils/get-rtcpeerconnection.js.map +1 -1
- package/dist/src/private-to-public/utils/sdp.d.ts +3 -1
- package/dist/src/private-to-public/utils/sdp.d.ts.map +1 -1
- package/dist/src/private-to-public/utils/sdp.js +16 -2
- package/dist/src/private-to-public/utils/sdp.js.map +1 -1
- package/dist/src/private-to-public/utils/stun-listener.browser.d.ts +9 -0
- package/dist/src/private-to-public/utils/stun-listener.browser.d.ts.map +1 -0
- package/dist/src/private-to-public/utils/stun-listener.browser.js +6 -0
- package/dist/src/private-to-public/utils/stun-listener.browser.js.map +1 -0
- package/dist/src/private-to-public/utils/stun-listener.d.ts +2 -4
- package/dist/src/private-to-public/utils/stun-listener.d.ts.map +1 -1
- package/dist/src/private-to-public/utils/stun-listener.js +8 -2
- package/dist/src/private-to-public/utils/stun-listener.js.map +1 -1
- package/dist/src/private-to-public/utils/stun.d.ts +34 -0
- package/dist/src/private-to-public/utils/stun.d.ts.map +1 -0
- package/dist/src/private-to-public/utils/stun.js +107 -0
- package/dist/src/private-to-public/utils/stun.js.map +1 -0
- package/dist/src/util.d.ts +3 -5
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js +3 -24
- package/dist/src/util.js.map +1 -1
- package/dist/src/webrtc/node-datachannel.browser.d.ts +7 -0
- package/dist/src/webrtc/node-datachannel.browser.d.ts.map +1 -0
- package/dist/src/webrtc/node-datachannel.browser.js +16 -0
- package/dist/src/webrtc/node-datachannel.browser.js.map +1 -0
- package/package.json +22 -11
- package/src/constants.ts +2 -1
- package/src/index.ts +35 -1
- package/src/private-to-public/listener.ts +9 -7
- package/src/private-to-public/transport.browser.ts +48 -5
- package/src/private-to-public/utils/connect.ts +112 -17
- package/src/private-to-public/utils/get-rtcpeerconnection.ts +20 -11
- package/src/private-to-public/utils/sdp.ts +21 -2
- package/src/private-to-public/utils/stun-listener.browser.ts +14 -0
- package/src/private-to-public/utils/stun-listener.ts +9 -7
- package/src/private-to-public/utils/stun.ts +128 -0
- package/src/util.ts +5 -32
- package/src/webrtc/node-datachannel.browser.ts +17 -0
- package/dist/typedoc-urls.json +0 -14
package/README.md
CHANGED
|
@@ -30,6 +30,19 @@ A [libp2p transport](https://libp2p.io/docs/transports-overview/) based on [WebR
|
|
|
30
30
|
|
|
31
31
|
There are two transports exposed by this module, [webRTC](https://github.com/libp2p/specs/blob/master/webrtc/webrtc.md) and [webRTCDirect](https://github.com/libp2p/specs/blob/master/webrtc/webrtc-direct.md).
|
|
32
32
|
|
|
33
|
+
## React Native installation
|
|
34
|
+
|
|
35
|
+
React Native applications must install the optional `react-native-webrtc`
|
|
36
|
+
peer dependency explicitly:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm install @libp2p/webrtc react-native-webrtc@^124.0.6
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Follow the [react-native-webrtc installation instructions](https://github.com/react-native-webrtc/react-native-webrtc#getting-started)
|
|
43
|
+
to configure the native module. Node.js and browser applications do not
|
|
44
|
+
need this dependency.
|
|
45
|
+
|
|
33
46
|
## WebRTC vs WebRTC Direct
|
|
34
47
|
|
|
35
48
|
The connection establishment phase of WebRTC involves a handshake using [SDP](https://en.wikipedia.org/wiki/Session_Description_Protocol) during which two peers will exchange information such as open ports, network addresses and required capabilities.
|
|
@@ -38,7 +51,7 @@ A third party is usually necessary to carry out this handshake, forwarding messa
|
|
|
38
51
|
|
|
39
52
|
The WebRTC transport uses libp2p [Circuit Relay](https://libp2p.io/docs/circuit-relay/)s to forward SDP messages. Once a direct connection is formed the relay plays no further part in the exchange.
|
|
40
53
|
|
|
41
|
-
WebRTC Direct
|
|
54
|
+
WebRTC Direct skips the handshake step, instead encoding enough information in the connection request that the responder can derive what would have been in the handshake messages and so requires no third parties to establish a connection. Version 1 of the protocol does this with a technique known as [SDP munging](https://webrtchacks.com/not-a-guide-to-sdp-munging/); version 2 avoids munging, which browsers are removing support for. See WebRTC Direct versions below.
|
|
42
55
|
|
|
43
56
|
A WebRTC Direct multiaddr also includes a certhash of the target peer - this is used to allow opening a connection to the remote, which would otherwise be denied due to use of a self-signed certificate.
|
|
44
57
|
|
|
@@ -220,6 +233,27 @@ stream.addEventListener('message', (evt) => {
|
|
|
220
233
|
})
|
|
221
234
|
```
|
|
222
235
|
|
|
236
|
+
## WebRTC Direct versions
|
|
237
|
+
|
|
238
|
+
There are two versions of the WebRTC Direct connection flow. Both use the
|
|
239
|
+
same `/webrtc-direct` multiaddr and certificate hash; they differ in how the
|
|
240
|
+
client's ICE credentials reach the server.
|
|
241
|
+
|
|
242
|
+
Version 1 munges the client's SDP offer so that the server can predict the
|
|
243
|
+
client's ICE credentials. Browsers are removing the ability to do this, so
|
|
244
|
+
v1 will stop working for browser clients.
|
|
245
|
+
|
|
246
|
+
Version 2 leaves the local SDP offer untouched and instead carries the
|
|
247
|
+
client's ICE password in the ICE username fragment of the synthetic server
|
|
248
|
+
answer, where the server reads it back from the incoming STUN request.
|
|
249
|
+
|
|
250
|
+
No configuration is needed for either version. Listeners accept both on the
|
|
251
|
+
same port and select the version from the incoming username fragment prefix.
|
|
252
|
+
The first dial tries v1 and, if the runtime does not apply the munged ICE
|
|
253
|
+
credentials, continues as v2; later dials then start at v2. The
|
|
254
|
+
`dialerVersion` option skips this and forces one version, for example `2`
|
|
255
|
+
for a server known to support it (go-libp2p does from v0.49.0).
|
|
256
|
+
|
|
223
257
|
## WebRTC Direct certificate hashes
|
|
224
258
|
|
|
225
259
|
WebRTC Direct listeners publish the hash of their TLS certificate as part of
|