@libp2p/webrtc 4.1.1 → 4.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ import { transportSymbol, serviceCapabilities } from '@libp2p/interface'
3
3
  import * as p from '@libp2p/peer-id'
4
4
  import { protocols } from '@multiformats/multiaddr'
5
5
  import { WebRTCDirect } from '@multiformats/multiaddr-matcher'
6
- import * as multihashes from 'multihashes'
6
+ import * as Digest from 'multiformats/hashes/digest'
7
7
  import { concat } from 'uint8arrays/concat'
8
8
  import { fromString as uint8arrayFromString } from 'uint8arrays/from-string'
9
9
  import { dataChannelError, inappropriateMultiaddr, unimplemented, invalidArgument } from '../error.js'
@@ -135,7 +135,7 @@ export class WebRTCDirectTransport implements Transport {
135
135
  const certificate = await RTCPeerConnection.generateCertificate({
136
136
  name: 'ECDSA',
137
137
  namedCurve: 'P-256',
138
- hash: sdp.toSupportedHashFunction(remoteCerthash.name)
138
+ hash: sdp.toSupportedHashFunction(remoteCerthash.code)
139
139
  } as any)
140
140
 
141
141
  const peerConnection = new RTCPeerConnection({
@@ -273,7 +273,7 @@ export class WebRTCDirectTransport implements Transport {
273
273
  * Generate a noise prologue from the peer connection's certificate.
274
274
  * noise prologue = bytes('libp2p-webrtc-noise:') + noise-responder fingerprint + noise-initiator fingerprint
275
275
  */
276
- private generateNoisePrologue (pc: RTCPeerConnection, hashCode: multihashes.HashCode, ma: Multiaddr): Uint8Array {
276
+ private generateNoisePrologue (pc: RTCPeerConnection, hashCode: number, ma: Multiaddr): Uint8Array {
277
277
  if (pc.getConfiguration().certificates?.length === 0) {
278
278
  throw invalidArgument('no local certificate')
279
279
  }
@@ -287,10 +287,10 @@ export class WebRTCDirectTransport implements Transport {
287
287
 
288
288
  const localFpString = localFingerprint.trim().toLowerCase().replaceAll(':', '')
289
289
  const localFpArray = uint8arrayFromString(localFpString, 'hex')
290
- const local = multihashes.encode(localFpArray, hashCode)
290
+ const local = Digest.create(hashCode, localFpArray)
291
291
  const remote: Uint8Array = sdp.mbdecoder.decode(sdp.certhash(ma))
292
292
  const prefix = uint8arrayFromString('libp2p-webrtc-noise:')
293
293
 
294
- return concat([prefix, local, remote])
294
+ return concat([prefix, local.bytes, remote])
295
295
  }
296
296
  }