@libp2p/webrtc 6.0.33 → 6.1.0-5c4cdb2d6

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 (64) hide show
  1. package/README.md +35 -1
  2. package/dist/index.min.js +9 -9
  3. package/dist/index.min.js.map +4 -4
  4. package/dist/src/constants.d.ts +2 -1
  5. package/dist/src/constants.d.ts.map +1 -1
  6. package/dist/src/constants.js +2 -1
  7. package/dist/src/constants.js.map +1 -1
  8. package/dist/src/index.d.ts +35 -1
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/index.js +35 -1
  11. package/dist/src/index.js.map +1 -1
  12. package/dist/src/private-to-public/listener.d.ts.map +1 -1
  13. package/dist/src/private-to-public/listener.js +9 -7
  14. package/dist/src/private-to-public/listener.js.map +1 -1
  15. package/dist/src/private-to-public/transport.browser.d.ts +9 -0
  16. package/dist/src/private-to-public/transport.browser.d.ts.map +1 -1
  17. package/dist/src/private-to-public/transport.browser.js +33 -5
  18. package/dist/src/private-to-public/transport.browser.js.map +1 -1
  19. package/dist/src/private-to-public/utils/connect.d.ts +16 -0
  20. package/dist/src/private-to-public/utils/connect.d.ts.map +1 -1
  21. package/dist/src/private-to-public/utils/connect.js +77 -16
  22. package/dist/src/private-to-public/utils/connect.js.map +1 -1
  23. package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts +4 -1
  24. package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts.map +1 -1
  25. package/dist/src/private-to-public/utils/get-rtcpeerconnection.js +18 -11
  26. package/dist/src/private-to-public/utils/get-rtcpeerconnection.js.map +1 -1
  27. package/dist/src/private-to-public/utils/sdp.d.ts +3 -1
  28. package/dist/src/private-to-public/utils/sdp.d.ts.map +1 -1
  29. package/dist/src/private-to-public/utils/sdp.js +16 -2
  30. package/dist/src/private-to-public/utils/sdp.js.map +1 -1
  31. package/dist/src/private-to-public/utils/stun-listener.browser.d.ts +9 -0
  32. package/dist/src/private-to-public/utils/stun-listener.browser.d.ts.map +1 -0
  33. package/dist/src/private-to-public/utils/stun-listener.browser.js +6 -0
  34. package/dist/src/private-to-public/utils/stun-listener.browser.js.map +1 -0
  35. package/dist/src/private-to-public/utils/stun-listener.d.ts +2 -4
  36. package/dist/src/private-to-public/utils/stun-listener.d.ts.map +1 -1
  37. package/dist/src/private-to-public/utils/stun-listener.js +8 -2
  38. package/dist/src/private-to-public/utils/stun-listener.js.map +1 -1
  39. package/dist/src/private-to-public/utils/stun.d.ts +34 -0
  40. package/dist/src/private-to-public/utils/stun.d.ts.map +1 -0
  41. package/dist/src/private-to-public/utils/stun.js +107 -0
  42. package/dist/src/private-to-public/utils/stun.js.map +1 -0
  43. package/dist/src/util.d.ts +3 -5
  44. package/dist/src/util.d.ts.map +1 -1
  45. package/dist/src/util.js +3 -24
  46. package/dist/src/util.js.map +1 -1
  47. package/dist/src/webrtc/node-datachannel.browser.d.ts +7 -0
  48. package/dist/src/webrtc/node-datachannel.browser.d.ts.map +1 -0
  49. package/dist/src/webrtc/node-datachannel.browser.js +16 -0
  50. package/dist/src/webrtc/node-datachannel.browser.js.map +1 -0
  51. package/package.json +22 -11
  52. package/src/constants.ts +2 -1
  53. package/src/index.ts +35 -1
  54. package/src/private-to-public/listener.ts +9 -7
  55. package/src/private-to-public/transport.browser.ts +48 -5
  56. package/src/private-to-public/utils/connect.ts +112 -17
  57. package/src/private-to-public/utils/get-rtcpeerconnection.ts +20 -11
  58. package/src/private-to-public/utils/sdp.ts +21 -2
  59. package/src/private-to-public/utils/stun-listener.browser.ts +14 -0
  60. package/src/private-to-public/utils/stun-listener.ts +9 -7
  61. package/src/private-to-public/utils/stun.ts +128 -0
  62. package/src/util.ts +5 -32
  63. package/src/webrtc/node-datachannel.browser.ts +17 -0
  64. 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 uses a technique known as [SDP munging](https://webrtchacks.com/not-a-guide-to-sdp-munging/) to skip 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.
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