react-native-rsa-native icon indicating copy to clipboard operation
react-native-rsa-native copied to clipboard

[Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNativeRsaNative.RSA.generateKeys')]

Open sharif2008 opened this issue 2 years ago • 8 comments

It does not work with expo-

Errors [Unhandled promise rejection: TypeError: null is not an object (evaluating '_reactNativeRsaNative.RSA.generateKeys')] at src\utils\pki.ts:11:4 in createKeyPairRSA at node_modules@babel\runtime\helpers\regeneratorRuntime.js:86:13 in tryCatch at node_modules@babel\runtime\helpers\regeneratorRuntime.js:66:31 in at node_modules@babel\runtime\helpers\regeneratorRuntime.js:86:13 in tryCatch at node_modules@babel\runtime\helpers\regeneratorRuntime.js:124:27 in invoke

sharif2008 avatar Nov 14 '22 06:11 sharif2008

I had the same error. It works just fine after I ran npx expo run:android and ejected the native config. No other configuration was needed.

Any way of doing this without ejecting?

willpiam avatar Feb 22 '23 17:02 willpiam

I had the same error. It works just fine after I ran npx expo run:android and ejected the native config. No other configuration was needed.

Could you share more about how to do this? Thank you!

willpiam avatar Feb 22 '23 20:02 willpiam

@StrawberryChocolateFudge thank you so much for the tip! It saved my day.

@willpiam you need to run npx expo prebuild and then run your app using npx expo run:android. Take a backup of the folder before, just in case.

megothss avatar Sep 06 '23 23:09 megothss

Is there a way of making it work without ejecting it? In modern Expo, let's say SDK 48/49?

I tried to debug what is actually imported:

import * as RSA from "react-native-rsa-native"

If I log the value of RSA, this is the output:

{"RNRSA": null, "RNRSAKeychain": null, "RSA": null, "RSAKeychain": null, "default": null}

If possible I would like to fix it and submit a PR, if someone can give some guidance

alessandrocapra avatar Sep 27 '23 09:09 alessandrocapra

Any updates regarding the null issue without ejecting in expo mentioned by @alessandrocapra ?

RasVibe avatar Oct 06 '23 11:10 RasVibe

I ended up using node-forge instead, it works very well

alessandrocapra avatar Oct 06 '23 12:10 alessandrocapra

Alright - will look into it. Thanks.

RasVibe avatar Oct 06 '23 12:10 RasVibe