Skip to content

🎉 Add support for Expo SDK 48+ #45

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

Merged
merged 1 commit into from
May 18, 2023
Merged

🎉 Add support for Expo SDK 48+ #45

merged 1 commit into from
May 18, 2023

Conversation

LinusU
Copy link
Owner

@LinusU LinusU commented May 17, 2023

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

Copy link

@aleqsio aleqsio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you 💛

@@ -49,6 +49,13 @@ function getRandomValues (array) {
throw new QuotaExceededError('Can only request a maximum of 65536 bytes')
}

// Expo SDK 48+
if (global.expo && global.expo.modules && global.expo.modules.ExpoCrypto && global.expo.modules.ExpoCrypto.getRandomValues) {
// ExpoCrypto.getRandomValues doesn't return the array
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that was because we were limited in being able to return typedarrays from Expo modules back then. I'll check if we can't readd it so it matches the web spec

@LinusU LinusU merged commit c057a09 into master May 18, 2023
@LinusU LinusU deleted the expo-crypto branch May 18, 2023 02:56
@LinusU
Copy link
Owner Author

LinusU commented May 18, 2023

Released as 🚢 1.9.0 / 2023-05-18

@adamhari
Copy link

adamhari commented May 19, 2023

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
Copy link
Owner Author

LinusU commented May 22, 2023

@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
Copy link

@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
Copy link
Owner Author

LinusU commented May 23, 2023

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
Copy link

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
Copy link
Owner Author

LinusU commented May 24, 2023

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
Copy link

aleqsio commented May 24, 2023

@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
Copy link

efstathiosntonas commented Jun 15, 2023

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 [email protected] using "expo": "48.0.19",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

expo-random deprecated
4 participants