@libp2p/webrtc 5.2.24-a02cb0461 → 5.2.24-f5932c294

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 (87) hide show
  1. package/README.md +20 -10
  2. package/dist/index.min.js +14 -14
  3. package/dist/index.min.js.map +4 -4
  4. package/dist/src/constants.d.ts +15 -0
  5. package/dist/src/constants.d.ts.map +1 -1
  6. package/dist/src/constants.js +15 -0
  7. package/dist/src/constants.js.map +1 -1
  8. package/dist/src/index.d.ts +22 -12
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/index.js +22 -12
  11. package/dist/src/index.js.map +1 -1
  12. package/dist/src/maconn.d.ts +58 -0
  13. package/dist/src/maconn.d.ts.map +1 -0
  14. package/dist/src/maconn.js +56 -0
  15. package/dist/src/maconn.js.map +1 -0
  16. package/dist/src/muxer.d.ts +46 -14
  17. package/dist/src/muxer.d.ts.map +1 -1
  18. package/dist/src/muxer.js +135 -32
  19. package/dist/src/muxer.js.map +1 -1
  20. package/dist/src/private-to-private/initiate-connection.d.ts +4 -3
  21. package/dist/src/private-to-private/initiate-connection.d.ts.map +1 -1
  22. package/dist/src/private-to-private/initiate-connection.js +5 -23
  23. package/dist/src/private-to-private/initiate-connection.js.map +1 -1
  24. package/dist/src/private-to-private/signaling-stream-handler.d.ts +4 -4
  25. package/dist/src/private-to-private/signaling-stream-handler.d.ts.map +1 -1
  26. package/dist/src/private-to-private/signaling-stream-handler.js +6 -10
  27. package/dist/src/private-to-private/signaling-stream-handler.js.map +1 -1
  28. package/dist/src/private-to-private/transport.d.ts +2 -2
  29. package/dist/src/private-to-private/transport.d.ts.map +1 -1
  30. package/dist/src/private-to-private/transport.js +15 -30
  31. package/dist/src/private-to-private/transport.js.map +1 -1
  32. package/dist/src/private-to-private/util.d.ts +1 -3
  33. package/dist/src/private-to-private/util.d.ts.map +1 -1
  34. package/dist/src/private-to-private/util.js +3 -15
  35. package/dist/src/private-to-private/util.js.map +1 -1
  36. package/dist/src/private-to-public/listener.js +2 -2
  37. package/dist/src/private-to-public/listener.js.map +1 -1
  38. package/dist/src/private-to-public/transport.js +1 -1
  39. package/dist/src/private-to-public/transport.js.map +1 -1
  40. package/dist/src/private-to-public/utils/connect.d.ts +1 -1
  41. package/dist/src/private-to-public/utils/connect.d.ts.map +1 -1
  42. package/dist/src/private-to-public/utils/connect.js +14 -17
  43. package/dist/src/private-to-public/utils/connect.js.map +1 -1
  44. package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts +4 -4
  45. package/dist/src/private-to-public/utils/get-rtcpeerconnection.d.ts.map +1 -1
  46. package/dist/src/private-to-public/utils/get-rtcpeerconnection.js +2 -13
  47. package/dist/src/private-to-public/utils/get-rtcpeerconnection.js.map +1 -1
  48. package/dist/src/private-to-public/utils/sdp.d.ts.map +1 -1
  49. package/dist/src/private-to-public/utils/sdp.js +3 -8
  50. package/dist/src/private-to-public/utils/sdp.js.map +1 -1
  51. package/dist/src/private-to-public/utils/stun-listener.js +1 -1
  52. package/dist/src/private-to-public/utils/stun-listener.js.map +1 -1
  53. package/dist/src/stream.d.ts +26 -13
  54. package/dist/src/stream.d.ts.map +1 -1
  55. package/dist/src/stream.js +166 -64
  56. package/dist/src/stream.js.map +1 -1
  57. package/dist/src/util.d.ts +1 -3
  58. package/dist/src/util.d.ts.map +1 -1
  59. package/dist/src/util.js +0 -19
  60. package/dist/src/util.js.map +1 -1
  61. package/dist/src/webrtc/index.d.ts +1 -1
  62. package/dist/src/webrtc/index.d.ts.map +1 -1
  63. package/dist/src/webrtc/index.js +1 -1
  64. package/dist/src/webrtc/index.js.map +1 -1
  65. package/package.json +29 -26
  66. package/src/constants.ts +18 -0
  67. package/src/index.ts +22 -12
  68. package/src/maconn.ts +101 -0
  69. package/src/muxer.ts +166 -43
  70. package/src/private-to-private/initiate-connection.ts +9 -31
  71. package/src/private-to-private/signaling-stream-handler.ts +9 -12
  72. package/src/private-to-private/transport.ts +17 -33
  73. package/src/private-to-private/util.ts +4 -21
  74. package/src/private-to-public/listener.ts +2 -2
  75. package/src/private-to-public/transport.ts +1 -1
  76. package/src/private-to-public/utils/connect.ts +15 -18
  77. package/src/private-to-public/utils/get-rtcpeerconnection.ts +4 -16
  78. package/src/private-to-public/utils/sdp.ts +3 -8
  79. package/src/private-to-public/utils/stun-listener.ts +1 -1
  80. package/src/stream.ts +194 -74
  81. package/src/util.ts +1 -22
  82. package/src/webrtc/index.ts +1 -1
  83. package/dist/src/rtcpeerconnection-to-conn.d.ts +0 -12
  84. package/dist/src/rtcpeerconnection-to-conn.d.ts.map +0 -1
  85. package/dist/src/rtcpeerconnection-to-conn.js +0 -43
  86. package/dist/src/rtcpeerconnection-to-conn.js.map +0 -1
  87. package/src/rtcpeerconnection-to-conn.ts +0 -62
@@ -4,16 +4,15 @@ import { multiaddr } from '@multiformats/multiaddr'
4
4
  import { WebRTC } from '@multiformats/multiaddr-matcher'
5
5
  import { setMaxListeners } from 'main-event'
6
6
  import { SIGNALING_PROTOCOL } from '../constants.js'
7
+ import { WebRTCMultiaddrConnection } from '../maconn.js'
7
8
  import { DataChannelMuxerFactory } from '../muxer.js'
8
- import { toMultiaddrConnection } from '../rtcpeerconnection-to-conn.ts'
9
9
  import { getRtcConfiguration } from '../util.js'
10
10
  import { RTCPeerConnection } from '../webrtc/index.js'
11
11
  import { initiateConnection } from './initiate-connection.js'
12
12
  import { WebRTCPeerListener } from './listener.js'
13
13
  import { handleIncomingStream } from './signaling-stream-handler.js'
14
- import { getRemotePeer } from './util.ts'
15
14
  import type { DataChannelOptions } from '../index.js'
16
- import type { OutboundConnectionUpgradeEvents, CreateListenerOptions, DialTransportOptions, Transport, Listener, Upgrader, ComponentLogger, Logger, Connection, PeerId, CounterGroup, Metrics, Startable, OpenConnectionProgressEvents, Libp2pEvents, MultiaddrConnection, Stream } from '@libp2p/interface'
15
+ import type { OutboundConnectionUpgradeEvents, CreateListenerOptions, DialTransportOptions, Transport, Listener, Upgrader, ComponentLogger, Logger, Connection, PeerId, CounterGroup, Metrics, Startable, OpenConnectionProgressEvents, IncomingStreamData, Libp2pEvents } from '@libp2p/interface'
17
16
  import type { Registrar, ConnectionManager, TransportManager } from '@libp2p/interface-internal'
18
17
  import type { Multiaddr } from '@multiformats/multiaddr'
19
18
  import type { TypedEventTarget } from 'main-event'
@@ -116,13 +115,13 @@ export class WebRTCTransport implements Transport<WebRTCDialEvents>, Startable {
116
115
  }
117
116
 
118
117
  async start (): Promise<void> {
119
- await this.components.registrar.handle(SIGNALING_PROTOCOL, (stream: Stream, connection: Connection) => {
118
+ await this.components.registrar.handle(SIGNALING_PROTOCOL, (data: IncomingStreamData) => {
120
119
  // ensure we don't try to upgrade forever
121
120
  const signal = this.components.upgrader.createInboundAbortSignal(this.shutdownController.signal)
122
121
 
123
- this._onProtocol(stream, connection, signal)
122
+ this._onProtocol(data, signal)
124
123
  .catch(err => {
125
- this.log.error('failed to handle incoming connect from %p', connection.remotePeer, err)
124
+ this.log.error('failed to handle incoming connect from %p', data.connection.remotePeer, err)
126
125
  })
127
126
  .finally(() => {
128
127
  signal.clear()
@@ -181,18 +180,16 @@ export class WebRTCTransport implements Transport<WebRTCDialEvents>, Startable {
181
180
  onProgress: options.onProgress
182
181
  })
183
182
 
184
- const webRTCConn = toMultiaddrConnection({
183
+ const webRTCConn = new WebRTCMultiaddrConnection(this.components, {
185
184
  peerConnection,
185
+ timeline: { open: Date.now() },
186
186
  remoteAddr: remoteAddress,
187
- metrics: this.metrics?.dialerEvents,
188
- direction: 'outbound',
189
- log: this.components.logger.forComponent('libp2p:webrtc:connection')
187
+ metrics: this.metrics?.dialerEvents
190
188
  })
191
189
 
192
190
  const connection = await options.upgrader.upgradeOutbound(webRTCConn, {
193
191
  skipProtection: true,
194
192
  skipEncryption: true,
195
- remotePeer: getRemotePeer(ma),
196
193
  muxerFactory,
197
194
  onProgress: options.onProgress,
198
195
  signal: options.signal
@@ -204,29 +201,18 @@ export class WebRTCTransport implements Transport<WebRTCDialEvents>, Startable {
204
201
  return connection
205
202
  }
206
203
 
207
- async _onProtocol (stream: Stream, connection: Connection, signal: AbortSignal): Promise<void> {
204
+ async _onProtocol ({ connection, stream }: IncomingStreamData, signal: AbortSignal): Promise<void> {
208
205
  const peerConnection = new RTCPeerConnection(await getRtcConfiguration(this.init.rtcConfiguration))
209
-
210
- // make sure C++ peer connection is garbage collected
211
- // https://github.com/murat-dogan/node-datachannel/issues/366#issuecomment-3228453155
212
- peerConnection.addEventListener('connectionstatechange', () => {
213
- switch (peerConnection.connectionState) {
214
- case 'closed':
215
- peerConnection.close()
216
- break
217
- default:
218
- break
219
- }
220
- })
221
- const muxerFactory = new DataChannelMuxerFactory({
222
- // @ts-expect-error https://github.com/murat-dogan/node-datachannel/pull/370
206
+ const muxerFactory = new DataChannelMuxerFactory(this.components, {
223
207
  peerConnection,
224
208
  dataChannelOptions: this.init.dataChannel
225
209
  })
226
210
 
227
211
  try {
228
- const { remoteAddress, remotePeer } = await handleIncomingStream(stream, connection, {
212
+ const { remoteAddress } = await handleIncomingStream({
229
213
  peerConnection,
214
+ connection,
215
+ stream,
230
216
  signal,
231
217
  log: this.log
232
218
  })
@@ -236,18 +222,16 @@ export class WebRTCTransport implements Transport<WebRTCDialEvents>, Startable {
236
222
  signal
237
223
  })
238
224
 
239
- const webRTCConn = toMultiaddrConnection({
225
+ const webRTCConn = new WebRTCMultiaddrConnection(this.components, {
240
226
  peerConnection,
227
+ timeline: { open: (new Date()).getTime() },
241
228
  remoteAddr: remoteAddress,
242
- metrics: this.metrics?.listenerEvents,
243
- direction: 'inbound',
244
- log: this.components.logger.forComponent('libp2p:webrtc:connection')
229
+ metrics: this.metrics?.listenerEvents
245
230
  })
246
231
 
247
232
  await this.components.upgrader.upgradeInbound(webRTCConn, {
248
233
  skipEncryption: true,
249
234
  skipProtection: true,
250
- remotePeer,
251
235
  muxerFactory,
252
236
  signal
253
237
  })
@@ -263,7 +247,7 @@ export class WebRTCTransport implements Transport<WebRTCDialEvents>, Startable {
263
247
  }
264
248
  }
265
249
 
266
- private _closeOnShutdown (pc: RTCPeerConnection, webRTCConn: MultiaddrConnection): void {
250
+ private _closeOnShutdown (pc: RTCPeerConnection, webRTCConn: WebRTCMultiaddrConnection): void {
267
251
  // close the connection on shut down
268
252
  const shutDownListener = (): void => {
269
253
  webRTCConn.close()
@@ -1,13 +1,12 @@
1
- import { ConnectionFailedError, InvalidMessageError, InvalidMultiaddrError } from '@libp2p/interface'
2
- import { peerIdFromString } from '@libp2p/peer-id'
1
+ import { ConnectionFailedError, InvalidMessageError } from '@libp2p/interface'
2
+ import pDefer from 'p-defer'
3
3
  import { CustomProgressEvent } from 'progress-events'
4
4
  import { isFirefox } from '../util.js'
5
5
  import { RTCIceCandidate } from '../webrtc/index.js'
6
6
  import { Message } from './pb/message.js'
7
7
  import type { WebRTCDialEvents } from './transport.js'
8
8
  import type { RTCPeerConnection } from '../webrtc/index.js'
9
- import type { AbortOptions, LoggerOptions, PeerId, Stream } from '@libp2p/interface'
10
- import type { Multiaddr } from '@multiformats/multiaddr'
9
+ import type { AbortOptions, LoggerOptions, Stream } from '@libp2p/interface'
11
10
  import type { MessageStream } from 'it-protobuf-stream'
12
11
  import type { DeferredPromise } from 'p-defer'
13
12
  import type { ProgressOptions } from 'progress-events'
@@ -18,7 +17,7 @@ export interface ReadCandidatesOptions extends AbortOptions, LoggerOptions, Prog
18
17
 
19
18
  export const readCandidatesUntilConnected = async (pc: RTCPeerConnection, stream: MessageStream<Message, Stream>, options: ReadCandidatesOptions): Promise<void> => {
20
19
  try {
21
- const connectedPromise = Promise.withResolvers<void>()
20
+ const connectedPromise: DeferredPromise<void> = pDefer()
22
21
  resolveOnConnected(pc, connectedPromise)
23
22
 
24
23
  // read candidates until we are connected or we reach the end of the stream
@@ -95,19 +94,3 @@ function resolveOnConnected (pc: RTCPeerConnection, promise: DeferredPromise<voi
95
94
  }
96
95
  }
97
96
  }
98
-
99
- export function getRemotePeer (ma: Multiaddr): PeerId {
100
- let remotePeer: PeerId | undefined
101
-
102
- for (const component of ma.getComponents()) {
103
- if (component.name === 'p2p') {
104
- remotePeer = peerIdFromString(component.value ?? '')
105
- }
106
- }
107
-
108
- if (remotePeer == null) {
109
- throw new InvalidMultiaddrError('Remote peerId must be present in multiaddr')
110
- }
111
-
112
- return remotePeer
113
- }
@@ -1,6 +1,6 @@
1
1
  import { isIPv4 } from '@chainsafe/is-ip'
2
2
  import { InvalidParametersError } from '@libp2p/interface'
3
- import { getThinWaistAddresses } from '@libp2p/utils'
3
+ import { getThinWaistAddresses } from '@libp2p/utils/get-thin-waist-addresses'
4
4
  import { multiaddr, fromStringTuples } from '@multiformats/multiaddr'
5
5
  import { WebRTCDirect } from '@multiformats/multiaddr-matcher'
6
6
  import getPort from 'get-port'
@@ -205,7 +205,7 @@ export class WebRTCDirectListener extends TypedEventEmitter<ListenerEvents> impl
205
205
  metrics: this.components.metrics,
206
206
  events: this.metrics?.listenerEvents,
207
207
  signal,
208
- remoteAddr: multiaddr(`/ip${isIPv4(remoteHost) ? 4 : 6}/${remoteHost}/udp/${remotePort}/webrtc-direct`),
208
+ remoteAddr: multiaddr(`/ip${isIPv4(remoteHost) ? 4 : 6}/${remoteHost}/udp/${remotePort}`),
209
209
  dataChannel: this.init.dataChannel,
210
210
  upgrader: this.init.upgrader,
211
211
  peerId: this.components.peerId,
@@ -186,7 +186,7 @@ export class WebRTCDirectTransport implements Transport, Startable {
186
186
  dataChannel: this.init.dataChannel,
187
187
  upgrader: options.upgrader,
188
188
  peerId: this.components.peerId,
189
- remotePeer: theirPeerId,
189
+ remotePeerId: theirPeerId,
190
190
  privateKey: this.components.privateKey
191
191
  })
192
192
  } catch (err) {
@@ -1,8 +1,8 @@
1
- import { noise } from '@libp2p/noise'
2
- import { pEvent } from 'p-event'
1
+ import { noise } from '@chainsafe/libp2p-noise'
2
+ import { raceEvent } from 'race-event'
3
3
  import { WebRTCTransportError } from '../../error.js'
4
+ import { WebRTCMultiaddrConnection } from '../../maconn.js'
4
5
  import { DataChannelMuxerFactory } from '../../muxer.js'
5
- import { toMultiaddrConnection } from '../../rtcpeerconnection-to-conn.ts'
6
6
  import { createStream } from '../../stream.js'
7
7
  import { isFirefox } from '../../util.js'
8
8
  import { generateNoisePrologue } from './generate-noise-prologue.js'
@@ -22,7 +22,7 @@ export interface ConnectOptions {
22
22
  dataChannel?: DataChannelOptions
23
23
  upgrader: Upgrader
24
24
  peerId: PeerId
25
- remotePeer?: PeerId
25
+ remotePeerId?: PeerId
26
26
  signal: AbortSignal
27
27
  privateKey: PrivateKey
28
28
  }
@@ -83,7 +83,7 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
83
83
 
84
84
  if (handshakeDataChannel.readyState !== 'open') {
85
85
  options.log.trace('%s wait for handshake channel to open, starting status %s', options.role, handshakeDataChannel.readyState)
86
- await pEvent(handshakeDataChannel, 'open', options)
86
+ await raceEvent(handshakeDataChannel, 'open', options.signal)
87
87
  }
88
88
 
89
89
  options.log.trace('%s handshake channel opened', options.role)
@@ -116,19 +116,20 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
116
116
  const handshakeStream = createStream({
117
117
  channel: handshakeDataChannel,
118
118
  direction: 'outbound',
119
- isHandshake: true,
119
+ handshake: true,
120
120
  log: options.log,
121
121
  ...(options.dataChannel ?? {})
122
122
  })
123
123
 
124
124
  // Creating the connection before completion of the noise
125
125
  // handshake ensures that the stream opening callback is set up
126
- const maConn = toMultiaddrConnection({
126
+ const maConn = new WebRTCMultiaddrConnection(options, {
127
127
  peerConnection,
128
128
  remoteAddr: options.remoteAddr,
129
- metrics: options.events,
130
- direction: options.role === 'client' ? 'outbound' : 'inbound',
131
- log: options.logger.forComponent('libp2p:webrtc-direct:connection')
129
+ timeline: {
130
+ open: Date.now()
131
+ },
132
+ metrics: options.events
132
133
  })
133
134
 
134
135
  peerConnection.addEventListener(CONNECTION_STATE_CHANGE_EVENT, () => {
@@ -149,8 +150,7 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
149
150
  // Track opened peer connection
150
151
  options.events?.increment({ peer_connection: true })
151
152
 
152
- const muxerFactory = new DataChannelMuxerFactory({
153
- // @ts-expect-error https://github.com/murat-dogan/node-datachannel/pull/370
153
+ const muxerFactory = new DataChannelMuxerFactory(options, {
154
154
  peerConnection,
155
155
  metrics: options.events,
156
156
  dataChannelOptions: options.dataChannel
@@ -161,8 +161,8 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
161
161
  // handshake. Therefore, we need to secure an inbound noise connection
162
162
  // from the server.
163
163
  options.log.trace('%s secure inbound', options.role)
164
- const result = await connectionEncrypter.secureInbound(handshakeStream, {
165
- remotePeer: options.remotePeer,
164
+ await connectionEncrypter.secureInbound(handshakeStream, {
165
+ remotePeer: options.remotePeerId,
166
166
  signal: options.signal,
167
167
  skipStreamMuxerNegotiation: true
168
168
  })
@@ -171,7 +171,6 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
171
171
  return await options.upgrader.upgradeOutbound(maConn, {
172
172
  skipProtection: true,
173
173
  skipEncryption: true,
174
- remotePeer: result.remotePeer,
175
174
  muxerFactory,
176
175
  signal: options.signal
177
176
  })
@@ -182,7 +181,7 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
182
181
  // the client.
183
182
  options.log.trace('%s secure outbound', options.role)
184
183
  const result = await connectionEncrypter.secureOutbound(handshakeStream, {
185
- remotePeer: options.remotePeer,
184
+ remotePeer: options.remotePeerId,
186
185
  signal: options.signal,
187
186
  skipStreamMuxerNegotiation: true
188
187
  })
@@ -194,13 +193,11 @@ export async function connect (peerConnection: DirectRTCPeerConnection, ufrag: s
194
193
  await options.upgrader.upgradeInbound(maConn, {
195
194
  skipProtection: true,
196
195
  skipEncryption: true,
197
- remotePeer: result.remotePeer,
198
196
  muxerFactory,
199
197
  signal: options.signal
200
198
  })
201
199
  } catch (err) {
202
200
  handshakeDataChannel.close()
203
- peerConnection.close()
204
201
 
205
202
  throw err
206
203
  }
@@ -1,10 +1,10 @@
1
+ import { PeerConnection } from '@ipshipyard/node-datachannel'
2
+ import { RTCPeerConnection } from '@ipshipyard/node-datachannel/polyfill'
1
3
  import { Crypto } from '@peculiar/webcrypto'
2
- import { PeerConnection } from 'node-datachannel'
3
- import { RTCPeerConnection } from 'node-datachannel/polyfill'
4
4
  import { DEFAULT_ICE_SERVERS, MAX_MESSAGE_SIZE } from '../../constants.js'
5
5
  import { generateTransportCertificate } from './generate-certificates.js'
6
6
  import type { TransportCertificate } from '../../index.js'
7
- import type { CertificateFingerprint } from 'node-datachannel'
7
+ import type { CertificateFingerprint } from '@ipshipyard/node-datachannel'
8
8
 
9
9
  const crypto = new Crypto()
10
10
 
@@ -14,7 +14,7 @@ interface DirectRTCPeerConnectionInit extends RTCConfiguration {
14
14
  }
15
15
 
16
16
  export class DirectRTCPeerConnection extends RTCPeerConnection {
17
- private peerConnection: PeerConnection
17
+ private readonly peerConnection: PeerConnection
18
18
  private readonly ufrag: string
19
19
 
20
20
  constructor (init: DirectRTCPeerConnectionInit) {
@@ -22,18 +22,6 @@ export class DirectRTCPeerConnection extends RTCPeerConnection {
22
22
 
23
23
  this.peerConnection = init.peerConnection
24
24
  this.ufrag = init.ufrag
25
-
26
- // make sure C++ peer connection is garbage collected
27
- // https://github.com/murat-dogan/node-datachannel/issues/366#issuecomment-3228453155
28
- this.addEventListener('connectionstatechange', () => {
29
- switch (this.connectionState) {
30
- case 'closed':
31
- this.peerConnection.close()
32
- break
33
- default:
34
- break
35
- }
36
- })
37
25
  }
38
26
 
39
27
  async createOffer (): Promise<globalThis.RTCSessionDescriptionInit | any> {
@@ -166,13 +166,8 @@ export function munge (desc: RTCSessionDescriptionInit, ufrag: string): RTCSessi
166
166
 
167
167
  const lineBreak = desc.sdp.includes('\r\n') ? '\r\n' : '\n'
168
168
 
169
- try {
170
- desc.sdp = desc.sdp
171
- .replace(/\na=ice-ufrag:[^\n]*\n/, '\na=ice-ufrag:' + ufrag + lineBreak)
172
- .replace(/\na=ice-pwd:[^\n]*\n/, '\na=ice-pwd:' + ufrag + lineBreak)
173
- } catch {
174
- // fails under Node.js
175
- }
176
-
169
+ desc.sdp = desc.sdp
170
+ .replace(/\na=ice-ufrag:[^\n]*\n/, '\na=ice-ufrag:' + ufrag + lineBreak)
171
+ .replace(/\na=ice-pwd:[^\n]*\n/, '\na=ice-pwd:' + ufrag + lineBreak)
177
172
  return desc
178
173
  }
@@ -1,5 +1,5 @@
1
1
  import { isIPv4 } from '@chainsafe/is-ip'
2
- import { IceUdpMuxListener } from 'node-datachannel'
2
+ import { IceUdpMuxListener } from '@ipshipyard/node-datachannel'
3
3
  import type { Logger } from '@libp2p/interface'
4
4
  import type { AddressInfo } from 'node:net'
5
5