@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.
- package/dist/index.min.js +14 -28
- package/dist/src/constants.d.ts +4 -1
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +5 -7
- package/dist/src/constants.js.map +1 -1
- package/dist/src/error.d.ts +2 -2
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +3 -3
- package/dist/src/error.js.map +1 -1
- package/dist/src/private-to-private/transport.d.ts +3 -3
- package/dist/src/private-to-private/transport.d.ts.map +1 -1
- package/dist/src/private-to-private/transport.js.map +1 -1
- package/dist/src/private-to-public/options.d.ts +2 -2
- package/dist/src/private-to-public/options.d.ts.map +1 -1
- package/dist/src/private-to-public/sdp.d.ts +4 -10
- package/dist/src/private-to-public/sdp.d.ts.map +1 -1
- package/dist/src/private-to-public/sdp.js +15 -16
- package/dist/src/private-to-public/sdp.js.map +1 -1
- package/dist/src/private-to-public/transport.js +4 -4
- package/dist/src/private-to-public/transport.js.map +1 -1
- package/package.json +12 -13
- package/src/constants.ts +5 -7
- package/src/error.ts +4 -4
- package/src/private-to-private/transport.ts +3 -3
- package/src/private-to-public/options.ts +2 -2
- package/src/private-to-public/sdp.ts +17 -19
- package/src/private-to-public/transport.ts +5 -5
@@ -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
|
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.
|
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:
|
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 =
|
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
|
}
|