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

UUID v4 generator for non-secure contexts? #5156

Open
cshaa opened this issue Jun 26, 2024 · 3 comments
Open

UUID v4 generator for non-secure contexts? #5156

cshaa opened this issue Jun 26, 2024 · 3 comments
Labels
feedback welcome We want community's feedback on this issue or PR suggestion a suggestion yet to be agreed uuid

Comments

@cshaa
Copy link

cshaa commented Jun 26, 2024

Is your feature request related to a problem? Please describe.

I love how with jsr.io, Deno's std is on the way to become a true "standard library" for JavaScript. Not having to constantly search for (often abandoned) NPM packages for even the most basic stuff is huge. However, the fact that @std/uuid lacks a generator for v4 UUID (the most commonly generated one) is really annoying.

My team and I are developing a web app that needs to run on a company's intranet (HTTP on non-localhost address, therefore outside of secure context), so we cannot use crypto.randomUUID as recommended by the README.

Describe the solution you'd like

A "polyfill" implementation of v4/generate that falls back to crypto.randomUUID whenever it's available would be awesome.

EDIT: That's exactly what npm:uuid already does.

Describe alternatives you've considered

Right now we are forced to use the uuid NPM package for a feature that IMO should be "built in", at least in the standard library.

@cshaa
Copy link
Author

cshaa commented Jun 26, 2024

Also, if I interpret this thread correctly, the reasons for only exposing crypto.randomUUID in a secure context is purely "politics" (ie. corporations enforcing what they see as "good practice" on engineers), which kind of sucks IMHO.

@iuioiua iuioiua added suggestion a suggestion yet to be agreed uuid feedback welcome We want community's feedback on this issue or PR labels Jun 27, 2024
@kt3k
Copy link
Member

kt3k commented Jun 27, 2024

We used to have JS implementation of uuid v4, but switched to crypto.randomUUID() in #971. Maybe we can restore that logic as fallback path.

@kt3k
Copy link
Member

kt3k commented Jul 9, 2024

@lucacasonato Do you have opinions to the idea of adding back v4.generate() function with fallback to js implementation like npm:uuid does? (https://github.com/uuidjs/uuid/blob/main/src/v4.js)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback welcome We want community's feedback on this issue or PR suggestion a suggestion yet to be agreed uuid
Projects
None yet
Development

No branches or pull requests

3 participants