From 5a71f1b982b9abcdcf2f2426a11c1bf513d42851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimmy=20Wa=CC=88rting?= Date: Mon, 20 Feb 2023 01:30:07 +0100 Subject: [PATCH] fix: remove uuid --- package.json | 2 -- src/default-ssdp-options.ts | 11 +++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 0afad18..91358e3 100644 --- a/package.json +++ b/package.json @@ -137,11 +137,9 @@ "event-iterator": "^2.0.0", "freeport-promise": "^2.0.0", "merge-options": "^3.0.4", - "uuid": "^8.3.2", "xml2js": "^0.4.23" }, "devDependencies": { - "@types/uuid": "^8.3.4", "@types/xml2js": "^0.4.9", "aegir": "^37.0.15", "it-first": "^1.0.7", diff --git a/src/default-ssdp-options.ts b/src/default-ssdp-options.ts index 4cb4f02..7d5a7c4 100644 --- a/src/default-ssdp-options.ts +++ b/src/default-ssdp-options.ts @@ -1,19 +1,18 @@ -import { v4 } from 'uuid' -import { defaultSocketOptions } from './default-socket-options.js' -import util from 'util' +import { webcrypto as crypto } from 'crypto' // remove when having crypto global import { createRequire } from 'module' import mergeOptions from 'merge-options' +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 { 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: {