Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace uuid package with built-in crypto.randomUUID() #1140

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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: 2 additions & 2 deletions node/src/PipeTransport.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'crypto';
import { Logger } from './Logger';
import * as ortc from './ortc';
import {
Expand Down Expand Up @@ -322,7 +322,7 @@ export class PipeTransport<PipeTransportAppData extends AppData = AppData>

const reqData =
{
consumerId : uuidv4(),
consumerId : randomUUID(),
producerId,
kind : producer.kind,
rtpParameters,
Expand Down
14 changes: 7 additions & 7 deletions node/src/Router.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'crypto';
import { Logger } from './Logger';
import { EnhancedEventEmitter } from './EnhancedEventEmitter';
import * as ortc from './ortc';
Expand Down Expand Up @@ -413,7 +413,7 @@ export class Router<RouterAppData extends AppData = AppData>

const reqData =
{
transportId : uuidv4(),
transportId : randomUUID(),
webRtcServerId : webRtcServer ? webRtcServer.id : undefined,
listenIps,
port,
Expand Down Expand Up @@ -525,7 +525,7 @@ export class Router<RouterAppData extends AppData = AppData>

const reqData =
{
transportId : uuidv4(),
transportId : randomUUID(),
listenIp,
port,
rtcpMux,
Expand Down Expand Up @@ -627,7 +627,7 @@ export class Router<RouterAppData extends AppData = AppData>

const reqData =
{
transportId : uuidv4(),
transportId : randomUUID(),
listenIp,
port,
enableSctp,
Expand Down Expand Up @@ -697,7 +697,7 @@ export class Router<RouterAppData extends AppData = AppData>

const reqData =
{
transportId : uuidv4(),
transportId : randomUUID(),
direct : true,
maxMessageSize
};
Expand Down Expand Up @@ -1083,7 +1083,7 @@ export class Router<RouterAppData extends AppData = AppData>

const reqData =
{
rtpObserverId : uuidv4(),
rtpObserverId : randomUUID(),
interval
};

Expand Down Expand Up @@ -1137,7 +1137,7 @@ export class Router<RouterAppData extends AppData = AppData>

const reqData =
{
rtpObserverId : uuidv4(),
rtpObserverId : randomUUID(),
maxEntries,
threshold,
interval
Expand Down
12 changes: 6 additions & 6 deletions node/src/Transport.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'crypto';
import { Logger } from './Logger';
import { EnhancedEventEmitter } from './EnhancedEventEmitter';
import * as utils from './utils';
Expand Down Expand Up @@ -595,7 +595,7 @@ export class Transport
// do not include CNAME, create a random one.
else if (!this.#cnameForProducers)
{
this.#cnameForProducers = uuidv4().substr(0, 8);
this.#cnameForProducers = randomUUID().substring(0, 8);
}

// Override Producer's CNAME.
Expand All @@ -615,7 +615,7 @@ export class Transport

const reqData =
{
producerId : id || uuidv4(),
producerId : id ?? randomUUID(),
kind,
rtpParameters,
rtpMapping,
Expand Down Expand Up @@ -747,7 +747,7 @@ export class Transport

const reqData =
{
consumerId : uuidv4(),
consumerId : randomUUID(),
producerId,
kind : producer.kind,
rtpParameters,
Expand Down Expand Up @@ -844,7 +844,7 @@ export class Transport

const reqData =
{
dataProducerId : id || uuidv4(),
dataProducerId : id ?? randomUUID(),
type,
sctpStreamParameters,
label,
Expand Down Expand Up @@ -967,7 +967,7 @@ export class Transport

const reqData =
{
dataConsumerId : uuidv4(),
dataConsumerId : randomUUID(),
dataProducerId,
type,
sctpStreamParameters,
Expand Down
6 changes: 3 additions & 3 deletions node/src/Worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as process from 'process';
import * as path from 'path';
import { spawn, ChildProcess } from 'child_process';
import { v4 as uuidv4 } from 'uuid';
import { randomUUID } from 'crypto';
import { Logger } from './Logger';
import { EnhancedEventEmitter } from './EnhancedEventEmitter';
import * as ortc from './ortc';
Expand Down Expand Up @@ -635,7 +635,7 @@ export class Worker<WorkerAppData extends AppData = AppData>

const reqData =
{
webRtcServerId : uuidv4(),
webRtcServerId : randomUUID(),
listenInfos
};

Expand Down Expand Up @@ -676,7 +676,7 @@ export class Worker<WorkerAppData extends AppData = AppData>
// This may throw.
const rtpCapabilities = ortc.generateRouterRtpCapabilities(mediaCodecs);

const reqData = { routerId: uuidv4() };
const reqData = { routerId: randomUUID() };

await this.#channel.request('worker.createRouter', undefined, reqData);

Expand Down
29 changes: 1 addition & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,13 @@
"h264-profile-level-id": "^1.0.1",
"node-fetch": "^3.3.2",
"supports-color": "^9.4.0",
"tar": "^6.1.15",
"uuid": "^9.0.0"
"tar": "^6.1.15"
},
"devDependencies": {
"@octokit/rest": "^20.0.1",
"@types/debug": "^4.1.8",
"@types/jest": "^29.5.3",
"@types/node": "^20.4.9",
"@types/uuid": "^9.0.2",
"@typescript-eslint/eslint-plugin": "^6.3.0",
"@typescript-eslint/parser": "^6.3.0",
"eslint": "^8.46.0",
Expand Down
13 changes: 7 additions & 6 deletions worker/scripts/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions worker/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
"clang-tools-prebuilt": "^0.1.4",
"gulp": "^4.0.2",
"gulp-clang-format": "^1.0.27"
},
"peerDependencies": {
"uuid": "^3.3.2"
}
}