Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

fix: remove uuid dependency #68

Merged
merged 3 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,13 @@
"multihashes": "^4.0.3",
"p-defer": "^4.0.0",
"uint8arraylist": "^2.3.3",
"uint8arrays": "^4.0.2",
"uuid": "^9.0.0"
"uint8arrays": "^4.0.2"
},
"devDependencies": {
"@libp2p/interface-mocks": "^8.0.1",
"@libp2p/peer-id-factory": "^1.0.19",
"@protobuf-ts/plugin": "^2.8.0",
"@protobuf-ts/protoc": "^2.8.0",
"@types/uuid": "^8.3.4",
"aegir": "^37.6.6",
"it-first": "^2.0.0",
"libp2p": "^0.40.0"
Expand Down
5 changes: 2 additions & 3 deletions src/transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import * as p from '@libp2p/peer-id'
import type { Multiaddr } from '@multiformats/multiaddr'
import * as multihashes from 'multihashes'
import defer from 'p-defer'
import { v4 as genUuid } from 'uuid'
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string'
import { concat } from 'uint8arrays/concat'

import { dataChannelError, inappropriateMultiaddr, unimplemented, invalidArgument } from './error.js'
import { WebRTCMultiaddrConnection } from './maconn.js'
import { DataChannelMuxerFactory } from './muxer.js'
import type { WebRTCDialOptions } from './options.js'
import * as sdp from './sdp.js'
import { WebRTCStream } from './stream.js'
import { genUfrag } from './util.js'

const log = logger('libp2p:webrtc:transport')

Expand Down Expand Up @@ -142,7 +141,7 @@ export class WebRTCTransport implements Transport {
dataChannelOpenPromise.reject(dataChannelError('data', error))
}

const ufrag = 'libp2p+webrtc+v1/' + genUuid().replaceAll('-', '')
const ufrag = 'libp2p+webrtc+v1/' + genUfrag(20)
ckousik marked this conversation as resolved.
Show resolved Hide resolved

// Create offer and munge sdp with ufrag = pwd. This allows the remote to
// respond to STUN messages without performing an actual SDP exchange.
Expand Down
3 changes: 3 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ export const nopSource = {
}

export const nopSink = async (_: any) => {}

const charset = Array.from('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/')
ckousik marked this conversation as resolved.
Show resolved Hide resolved
export const genUfrag = (len: number): string => [...Array(len)].map(() => charset.at(Math.floor(Math.random() * charset.length))).join('')