-
-
Notifications
You must be signed in to change notification settings - Fork 907
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
getRandomValues couldn't be found from a WebWorker in Edge18 #392
Comments
@evertbouw can you please provide steps to reproduce as requested by the issue template? Thanks! |
I thought that would look a little bit silly as it's just repeating |
Edge does not appear to make a global `crypto` variable available in WebWorkers however the WebCrypto seems to be exposed on the `self` variable, see sodium-friends/sodium-javascript#8 Since window.self also points to the window object in browsers checking self should work both, in the browser as well as in WebWorkers. Fixes #392
Thank you for the reproduction code, that was really helpful! Unfortunately, according to https://caniuse.com/#feat=cryptography, the WebCrypto API is not supported in WebWorkers in Edge<=18. There was an issue regarding that problem on the old Edge Issuetracker which is no longer available: https://web.archive.org/web/20171210184325/https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/7607496/ Unfortunately this means that if you want to continue to support pre-Chromium Edge Versions you will either have to continue to use You could take a look at the old version of this library where we were shipping an insecure fallback random number generator for environments that do not support proper cryptographically secure random number generators: https://github.com/uuidjs/uuid/blob/v3.4.0/lib/rng-browser.js#L24-L33 However, please be aware that using a flawed random number generator might lead to unexpected consequences, see https://github.com/tc39/proposal-uuid#how-unique-are-v4-uuids for examples. |
@ctavan 'worth noting that this a perfect example of why Math.getRandomValues() is needed. |
Thanks! I wasn't sure if this was intended because I couldn't really find anything on Google. In my worker I guess I used uuid out of habit but an auto increment id should suffice so I'm doing that now. |
Describe the bug
I've used uuid v4 in a webworker but now I'm seeing error logs from Edge18.
Runtime
The text was updated successfully, but these errors were encountered: