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

Conversation

piranna
Copy link
Contributor

@piranna piranna commented Aug 9, 2023

This PR replace uuid package with Node.js built-in crypto.randomUUID() function. Also, it fixes a couple of typos where the random UUID would be generated if an empty string would be provided as id, now only it's being generated if undefined is provided (note, we should validate the provided id is an UUID instead of a random string, though).

OTOH, I've found that the id field of DataProducerOptions is not documented. Not fully sure if it makes sense to provide it all, since bandwidth and CPU are low, or it's just there only to mimic Producer API...

@nazar-pc
Copy link
Collaborator

nazar-pc commented Aug 9, 2023

This is not mergable, crypto.randomUUID is only supported starting Node.js 19

node/src/PipeTransport.ts Outdated Show resolved Hide resolved
node/src/Transport.ts Outdated Show resolved Hide resolved
@piranna
Copy link
Contributor Author

piranna commented Aug 9, 2023

This is not mergable, crypto.randomUUID is only supported starting Node.js 19

According to https://nodejs.org/api/crypto.html#cryptorandomuuidoptions, it's available since v14.17.0... :-/

@nazar-pc
Copy link
Collaborator

nazar-pc commented Aug 9, 2023

Please use reviews for comments both ways 🙏 I have 7 notifications already within minutes here.

@ibc
Copy link
Member

ibc commented Aug 9, 2023

CI fails because uuid is still being imported in worker/scripts/xxxx files.

@piranna piranna force-pushed the uuidv4 branch 2 times, most recently from 690cf82 to fd8968f Compare August 11, 2023 21:44
@piranna
Copy link
Contributor Author

piranna commented Aug 11, 2023

I've fixed all the concerns.

uuid package in worker/scripts is a transitive dependency of request package, that's deprecated, and it's a dependency itself of nugget, that's a dependency itself of clang-tools-prebuilt. Proper fix should be done there, meanwhile I've set uuid as peerDependency of worker scripts so tests can pass.

@versatica versatica deleted a comment from Zobbobb Oct 20, 2023
ibc added a commit that referenced this pull request Oct 25, 2023
- Add `node:` prefix to all built-in Node imports (replaces PR #1142).
- Replace `uuid` package with built-in `crypto.randomUUID()`(replaces PR #1140).
- Cosmetic changes in TS files:
  - Avoid unnecessary `const { createWorker } = mediasoup` in almost all tests.
  - Move all FBS related imports to the bottom.
  - Some formating fixes that bypassed our ESLint rules.
@ibc
Copy link
Member

ibc commented Oct 25, 2023

Replacing this PR with #1193 which targets flatbuffers branch instead. Thanks.

@ibc ibc closed this Oct 25, 2023
ibc added a commit that referenced this pull request Oct 25, 2023
- Add `node:` prefix to all built-in Node imports (replaces PR #1142).
- Replace `uuid` package with built-in `crypto.randomUUID()`(replaces PR #1140).
- Cosmetic changes in TS files:
  - Avoid unnecessary `const { createWorker } = mediasoup` in almost all tests.
  - Move all FBS related imports to the bottom.
  - Some formating fixes that bypassed our ESLint rules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants