@libp2p/webrtc 6.0.32 → 6.0.33-183116ba0

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 +22 -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 +22 -1
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/index.js +22 -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 +13 -10
  52. package/src/constants.ts +2 -1
  53. package/src/index.ts +22 -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
@@ -38,7 +38,7 @@ A third party is usually necessary to carry out this handshake, forwarding messa
38
38
 
39
39
  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
40
 
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.
41
+ 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
42
 
43
43
  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
44
 
@@ -220,6 +220,27 @@ stream.addEventListener('message', (evt) => {
220
220
  })
221
221
  ```
222
222
 
223
+ ## WebRTC Direct versions
224
+
225
+ There are two versions of the WebRTC Direct connection flow. Both use the
226
+ same `/webrtc-direct` multiaddr and certificate hash; they differ in how the
227
+ client's ICE credentials reach the server.
228
+
229
+ Version 1 munges the client's SDP offer so that the server can predict the
230
+ client's ICE credentials. Browsers are removing the ability to do this, so
231
+ v1 will stop working for browser clients.
232
+
233
+ Version 2 leaves the local SDP offer untouched and instead carries the
234
+ client's ICE password in the ICE username fragment of the synthetic server
235
+ answer, where the server reads it back from the incoming STUN request.
236
+
237
+ No configuration is needed for either version. Listeners accept both on the
238
+ same port and select the version from the incoming username fragment prefix.
239
+ The first dial tries v1 and, if the runtime does not apply the munged ICE
240
+ credentials, continues as v2; later dials then start at v2. The
241
+ `dialerVersion` option skips this and forces one version, for example `2`
242
+ for a server known to support it (go-libp2p does from v0.49.0).
243
+
223
244
  ## WebRTC Direct certificate hashes
224
245
 
225
246
  WebRTC Direct listeners publish the hash of their TLS certificate as part of