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

Expo-Crypto for RN #154

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

FerVillanuevas
Copy link

@FerVillanuevas FerVillanuevas commented May 17, 2024

For RN there is not a Crypto library.

So we should use expo-crypto and make an alias to crypto

RN Config

Install Bable Module Resolver

Update babel.config.js

module.exports = function (api) { api.cache(true); return { presets: ["babel-preset-expo"], plugins: [ [ "module-resolver", { alias: { crypto: "expo-crypto", }, }, ], ], }; };

So we are telling to RN that the crypto lib is expo-crypto insted of crypto, the fact is expo-crypto has different methods, so we need to verify if is RN or Brower/Node then if is react native call the methods from expo.

There is an issue, navigator.product its depreacted, but other that this config works as expect and all test passed

@FerVillanuevas
Copy link
Author

Fix crypto on RN

#108

@joeluong-sfcc
Copy link
Contributor

Hi @FerVillanuevas, just to clarify, adding this fix does not work with react native out of the box, is that correct? Additional configuration is needed on the react native side on top of this fix in order for the commerce-sdk-isomorphic to work with react native.

Ideally things would work out of the box for all environments, browser/node/react native without additional configuration. In your manual testing, were you able to find a library that provides the same functionality as crypto that works on all environments, potentially something like crypto-js?

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.

2 participants