-
Notifications
You must be signed in to change notification settings - Fork 190
Generate UID without randombytes dependency #196
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
Conversation
Since I was planning to bump the major version anyway when removing By the way, is my understanding correct that this patch also resolves the browser support issue? |
I've updated the PR to use the
I haven't tested it in the browser, but it should. We're not accessing |
Got it. Let’s give it a try. Could you remove Node.js v18 from the GitHub Actions config? |
Whoops; just did that. Node 24 is out, should I add that to the test matrix? |
Yeah, please go ahead and add 24 as well 🙏 |
Added it; still needs approval to run but everything passes locally (as expected) |
Could you try running |
Huh, I didn't know the |
As far as I can tell, this... never did anything? My guess is that `crypto.randomBytes = oldRandom;` was supposed to come *after* we require()'d `serialize`, but it just didn't, so it ended up doing nothing.
Thanks! We’ve released v7.0.0, so please give it a try. Let us know if you run into any issues. |
I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.
Resolves #134. Instead of taking an external dependency on
randombytes
, which accessesglobal
(doesn't work in the browser) and depends on aBuffer
polyfill, we check first forcrypto.getRandomValues
support and only import Node'scrypto
module if it's not found.If you're OK with dropping support for Node <19, the
crypto
global is available in newer versions of Node (it technically didn't stop being "experimental" until Node 23, but I don't get any annoyingExperimentalWarning
messages when trying to access it in older versions).An alternative option would be to add separate browser and Node entrypoints; this would avoid the dynamic
require
that might(?) cause trouble for some bundlers. I have that code in a separate branch if you'd prefer it.