🐛 Bug Report
Environment
Expo CLI 3.13.1 environment info:
System:
OS: macOS 10.15.2
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.12.0 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.6 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
npmGlobalPackages:
expo-cli: 3.13.1
Steps to Reproduce
There are a lot of libraries that requires synchronous random values. Many of those libraries are moving away from Math.random() because of the numerous issues with them.
The new standard web platforms api is the crypto.getRandomValues API, and this is what e.g. uuid and nanoid uses. This is an excellent API that gives you secure random values. The newly released version 7.x of uuid does no longer work without this API.
I've previously tried to add crypto.getRandomValues into React Native itself, but unfortunately that never came to fruition. I still think that that would be the absolut best approach.
The next best approach for vanilla React Native is a polyfill! So that's why I wrote: react-native-get-random-values.
Unfortunately this polyfill doesn't work in Expo since it requires native code.
My proposal is to add the package to Expo as with other native packages, but also go one step further and adding the require of the polyfill to Expo itself, so that crypto.getRandomValues() will just work out of the box for everyone!
We've already heard from a few users that are having problem with uuid in React Native/Expo, see some previous discussions: uuidjs/uuid#375 uuidjs/uuid#385
What we did for now was add instructions to React Native users to use the polyfill, but unfortunately we cannot offer a solution to Expo users right now 😱
As always I'm willing to submit PRs for this 👍
🐛 Bug Report
Environment
Steps to Reproduce
There are a lot of libraries that requires synchronous random values. Many of those libraries are moving away from
Math.random()because of the numerous issues with them.The new standard web platforms api is the
crypto.getRandomValuesAPI, and this is what e.g. uuid and nanoid uses. This is an excellent API that gives you secure random values. The newly released version 7.x of uuid does no longer work without this API.I've previously tried to add
crypto.getRandomValuesinto React Native itself, but unfortunately that never came to fruition. I still think that that would be the absolut best approach.The next best approach for vanilla React Native is a polyfill! So that's why I wrote: react-native-get-random-values.
Unfortunately this polyfill doesn't work in Expo since it requires native code.
My proposal is to add the package to Expo as with other native packages, but also go one step further and adding the
requireof the polyfill to Expo itself, so thatcrypto.getRandomValues()will just work out of the box for everyone!We've already heard from a few users that are having problem with uuid in React Native/Expo, see some previous discussions: uuidjs/uuid#375 uuidjs/uuid#385
What we did for now was add instructions to React Native users to use the polyfill, but unfortunately we cannot offer a solution to Expo users right now 😱
As always I'm willing to submit PRs for this 👍