Skip to content

Commit

Permalink
fix: remove uuid dependency (#35)
Browse files Browse the repository at this point in the history
remove dependency on uuid v4 (as it's built in since node 14)

Co-authored-by: Alex Potsides <[email protected]>
  • Loading branch information
jimmywarting and achingbrain authored Apr 27, 2023
1 parent 9464950 commit 4daa741
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,10 @@
"event-iterator": "^2.0.0",
"freeport-promise": "^2.0.0",
"merge-options": "^3.0.4",
"uuid": "^8.3.2",
"xml2js": "^0.5.0"
},
"devDependencies": {
"@types/sinon": "^10.0.14",
"@types/uuid": "^8.3.4",
"@types/xml2js": "^0.4.11",
"aegir": "^39.0.2",
"it-first": "^3.0.1",
Expand Down
9 changes: 4 additions & 5 deletions src/default-ssdp-options.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@

import { webcrypto as crypto } from 'crypto' // remove when having crypto global
import { createRequire } from 'module'
import util from 'util'
import mergeOptions from 'merge-options'
import { v4 } from 'uuid'
import { defaultSocketOptions } from './default-socket-options.js'
import type { SSDPOptions } from './index.js'

const req = createRequire(import.meta.url)
const pkg = req('../../package.json')
const { name, version } = req('../../package.json')

const DEFAULT_SSDP_SIGNATURE = util.format('node.js/%s UPnP/1.1 %s/%s', process.version.substring(1), pkg.name, pkg.version)
const DEFAULT_SSDP_SIGNATURE = `node.js/${process.version.substring(1)} UPnP/1.1 ${name}/${version}`

export function defaultSsdpOptions (options?: Partial<SSDPOptions>): SSDPOptions {
return mergeOptions(options ?? {}, {
usn: `uuid:${v4()}`, // eslint-disable-line @typescript-eslint/restrict-template-expressions
usn: `uuid:${crypto.randomUUID()}`, // eslint-disable-line @typescript-eslint/restrict-template-expressions
signature: DEFAULT_SSDP_SIGNATURE,
sockets: [{}].map(defaultSocketOptions),
retry: {
Expand Down

0 comments on commit 4daa741

Please sign in to comment.