question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Regression in support for react-native-get-random-values

See original GitHub issue

Summary

react-native-get-random-values uses NativeModules.ExpoRandom.getRandomBase64String(byteLength) to polyfill crypto.getRandomValues() in Expo Go:

https://github.com/LinusU/react-native-get-random-values/blob/455f9dbbedad370c094090615b4c88031a09191b/index.js#L26-L34

In converting expo-random to use JSI, we break this polyfill. We should fix this because it is documented in the extremely popular uuid package.

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

iOS

SDK Version (managed workflow only)

45

Environment

  expo-env-info 1.0.3 environment info:
    System:
      OS: macOS 12.2.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
      Watchman: 2022.01.24.00 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.11.2 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
      Android SDK:
        Android NDK: 21.0.6113669
    IDEs:
      Android Studio: 4.1 AI-201.8743.12.41.7042882
      Xcode: 13.3.1/13E500a - /usr/bin/xcodebuild
    npmPackages:
      expo: ~45.0.0-beta.9 => 45.0.0-beta.9
      react: 17.0.2 => 17.0.2
      react-dom: 17.0.2 => 17.0.2
      react-native: 0.68.1 => 0.68.1
      react-native-web: 0.17.1 => 0.17.1
    npmGlobalPackages:
      eas-cli: 0.50.0
      expo-cli: 5.4.2
    Expo Workflow: managed

Reproducible demo

https://github.com/brentvatne/secure-random-example-45

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
LinusUcommented, May 2, 2022

Thanks for the PR! This is fixed in the following release of react-native-get-random-values:

🚢 1.8.0 / 2022-05-02

2reactions
tsapetacommented, Apr 29, 2022

To clarify, the regression wasn’t introduced by the migration to JSI, but by making expo-random an Expo module in general (it was a standard React Native module before). The polyfill assumes expo-random is accessible from NativeModules object, but now it should also look for it in global.ExpoModules. I’ll make a PR in react-native-get-random-values to fix this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use Jest to test functions using crypto or window. ...
This seems so straightfoward but isn't working for me; my test continues to fail with the same crypto.getRandomValues()-not-supported message.
Read more >
Firebase JavaScript SDK Release Notes - Google
Fixed a regression that prevented Cloud Firestore from detecting the Authentication service during initialization, which prevented some writes from being sent.
Read more >
We're Building a Visual Regression Testing Library for ...
This is a library that enables developers to introduce visual regression tests to their apps for iOS and Android (react-native-web is not ...
Read more >
Cross Browser Compatibility of crypto.getRandomValues() ...
Web Technology Support of Internet Explorer 10. To create a automation testing strategy for checking your webapps on Internet Explorer 10, you ...
Read more >
node-uuid
"Error: Native module not found" error when using uuidv4 in React Native app (non ... Starting on Node.js 15.6, there's support for a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found