Skip to content
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

crypto.getRandomValues is not defined #108

Open
snikoletopoulos opened this issue Jan 3, 2025 · 6 comments
Open

crypto.getRandomValues is not defined #108

snikoletopoulos opened this issue Jan 3, 2025 · 6 comments

Comments

@snikoletopoulos
Copy link

snikoletopoulos commented Jan 3, 2025

On Android I get a crypto.getRandomValues is not defined error.
iOS seems to work fine.

The error started when I upgraded from 2.1.0 to 2.2.0.
With 2.1.0 everything is working fine.

As for the environment and setup
I am on the latest Expo SDK (52)
I have the import "react-native-get-random-values"; before any call to @noble packages
And the polyfills are used

Dependencies versions:
react-native-get-random-values: 1.11.0
@noble/hashes: 1.7.0

Repository owner deleted a comment Jan 3, 2025
@paulmillr
Copy link
Owner

I have no android, you will need to debug the issue yourself

@snikoletopoulos
Copy link
Author

Can you give me some suggestions as to what might be wrong?

@paulmillr
Copy link
Owner

I think we have changed the logic lf checking if crypto exists. So, see how it works in 2.1 and diff with 2.2. Maybe it’s related to crypto.subtle

@paulmillr
Copy link
Owner

see if reverting 57c1d9e helps

@snikoletopoulos
Copy link
Author

Can confirm after reverting this commit it works as expected again.
Turns out this error is on iOS as well. My bad.

react-native-get-random-values does not implement crypto.subtle so a polyfill for that is needed.

Alternatively, I see that there are checks in place where crypto.subtle is needed so maybe we can revert the checks in 57c1d9e. That we result in better error messages describing what is actually missing.

@snikoletopoulos snikoletopoulos changed the title crypto.getRandomValues is not defined on Android crypto.getRandomValues is not defined Jan 7, 2025
@paulmillr
Copy link
Owner

I assume you are using noble hashes to get sync methods?

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

No branches or pull requests

2 participants