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

Support native randomUUID() #554

Closed
piranna opened this issue Jan 31, 2021 · 6 comments
Closed

Support native randomUUID() #554

piranna opened this issue Jan 31, 2021 · 6 comments

Comments

@piranna
Copy link
Member

piranna commented Jan 31, 2021

Starting on Node.js 15.6, there's support for a native randomUUID() implementation, that implements UUID v4. What about checking for its support on https://github.com/uuidjs/uuid/blob/master/src/v4.js and use it when available?

@ctavan
Copy link
Member

ctavan commented Jan 31, 2021

It's certainly on my list but I'm not sure if and when I'll manage to work on it. But happy to review a pull request if you are interested in working on it.

@piranna
Copy link
Member Author

piranna commented Feb 1, 2021

#555

Here you have it :-)

@ctavan
Copy link
Member

ctavan commented Feb 6, 2021

Following the discussion in #555 I think we could provide maybe even more value by providing an actual polyfill-package for the new API which works both, in Node.js and in the browser. For this purpose we've created https://github.com/uuidjs/randomUUID and reserved the npm package name: https://www.npmjs.com/package/randomuuid

As a big disclaimer I have to say though that I can't tell when I will find the time to personally work on that. If you want, feel free to give it a try contribute to it!

@piranna
Copy link
Member Author

piranna commented Feb 6, 2021

Following the discussion in #555 I think we could provide maybe even more value by providing an actual polyfill-package for the new API which works both, in Node.js and in the browser. For this purpose we've created uuidjs/randomUUID and reserved the npm package name: npmjs.com/package/randomuuid

Interesting aproach, definitely would be useful at least for my use case (I'm a bit TOC about using w3c or browsers APIs if possible). We can just copy Node.js implementation, and do two polyfills, one for Node.js crypto module using require() (not sure how we could do it with ESM imports) and another for browser. Main problem would be SecureBuffer() function since it's a native one, but for a first PoC implementation, although less secure, we could omit it. How do you see it?

@piranna
Copy link
Member Author

piranna commented Feb 8, 2021

Following the discussion in #555 I think we could provide maybe even more value by providing an actual polyfill-package for the new API which works both, in Node.js and in the browser. For this purpose we've created uuidjs/randomUUID and reserved the npm package name: npmjs.com/package/randomuuid

I have done a first implementation in uuidjs/randomUUID#1 based on code from Node.js. It works and have tests, but lacks documentation.

@ctavan
Copy link
Member

ctavan commented Dec 2, 2021

Using native randomUUID unter the hood was added in #600.

@ctavan ctavan closed this as completed Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants