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

fix: Add polyfill for crypto.getRandomValues in React Native #952

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Arshiash80
Copy link

This PR adds a polyfill for the global crypto.getRandomValues method in React Native by installing react-native-get-random-values. This polyfill is required because React Native does not natively support crypto.getRandomValues, which is used by uuid and other libraries that rely on it for random ID generation.

The polyfill ensures that these libraries can function correctly in a React Native environment without causing the "Error: crypto.getRandomValues() not supported" issue.

Fixes #950.

Copy link

@josedelapazjr josedelapazjr left a comment

Choose a reason for hiding this comment

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

Code LGTM! But not sure how to test it and I need this fix asap, please. 🙏

@Arshiash80
Copy link
Author

Code LGTM! But not sure how to test it and I need this fix asap, please. 🙏

Thanks for the review.

Since this change is just importing the react-native-get-random-values polyfill, you can test it by running the app on a React Native platform (iOS or Android) and verifying that UUID generation works without errors.

For example, you can check any feature that uses uuid to ensure it doesn't throw a "crypto.getRandomValues() not supported" error anymore.

@govi218
Copy link

govi218 commented Oct 24, 2024

Should fix #953 as well

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.

uuid library doesn't work well with expo
3 participants