LinusU / react-native-get-random-values

A small implementation of `getRandomValues` for React Native
MIT License
354 stars 48 forks source link

🎉 Add support for Expo SDK 48+ #45

Closed LinusU closed 1 year ago

LinusU commented 1 year ago

The current code works but uses deprecated functions on SDK 48, this PR adds a code path that calls uses getRandomValues from expo-crypto.

Fixes #41

LinusU commented 1 year ago

Released as 🚢 1.9.0 / 2023-05-18

adamhari commented 1 year ago

Seeing The method or property expo-crypto.getRandomBytes is not available on android, are you sure you've linked all the native dependencies properly? after upgrading to 1.9.0 with Expo 48.

My android build logs suggest that expo-crypto is being linked

> Configure project :expo

Using expo modules
  - expo-application (5.1.1)
  - expo-camera (13.3.0)
  - expo-constants (14.2.1)
  - expo-crypto (12.2.1)
  ...
LinusU commented 1 year ago

@adamhari did this previously work on 1.8.0? Does this happen when you call the global crypto.getRandomValues? Are you building the app via EAS, or running with Expo Go?


@aleqsio is there a possibility that global.expo.modules.ExpoCrypto.getRandomValues could exists and logging/throwing the following when accessed? 🤔

The method or property expo-crypto.getRandomBytes is not available on android, are you sure you've linked all the native dependencies properly?

adamhari commented 1 year ago

@adamhari did this previously work on 1.8.0? Does this happen when you call the global crypto.getRandomValues? Are you building the app via EAS, or running with Expo Go?

@aleqsio is there a possibility that global.expo.modules.ExpoCrypto.getRandomValues could exists and logging/throwing the following when accessed? 🤔

The method or property expo-crypto.getRandomBytes is not available on android, are you sure you've linked all the native dependencies properly?

It works on 1.8.0, I reverted to using that. It happens because I'm using expo-auth-session which uses expo-crypto here. I'm building with EAS, not using Expo Go.

LinusU commented 1 year ago

It happens because I'm using expo-auth-session which uses expo-crypto here.

Hmm, I'm not sure I follow here, is it expo-auth-session that gives you the error? And you can work around it by downgrading react-native-get-random-values to 1.8.0? 🤔

adamhari commented 1 year ago

It happens because I'm using expo-auth-session which uses expo-crypto here.

Hmm, I'm not sure I follow here, is it expo-auth-session that gives you the error? And you can work around it by downgrading react-native-get-random-values to 1.8.0? 🤔

Yeah, I'm not using expo-crypto directly, it's through the latest expo-auth-session (4.0.3)

LinusU commented 1 year ago

expo-auth-session shouldn't be dependent on react-native-get-random-values though? So I'm not sure how that relates to this package... 🤔

aleqsio commented 1 year ago

@aleqsio is there a possibility that global.expo.modules.ExpoCrypto.getRandomValues could exists and logging/throwing the following when accessed? 🤔

Hmm, not sure why this would happen, we didn't touch getRandomBytes other than moving it to a different package and I can't see anything in the code that would indicate it can break.

@adamhari If you can provide a minimal reproduction I can take a look 🙏

efstathiosntonas commented 1 year ago

Hey folks, The method or property expo-crypto.getRandomBytes is not available on android, are you sure you've linked all the native dependencies properly? is fixed on expo-crypto@12.4.0 using "expo": "48.0.19",