react-native-quick-crypto
react-native-quick-crypto copied to clipboard
ERROR Error: Exception in HostFunction: <unknown>, js engine: hermes
i am seeing exception
ERROR Error: Exception in HostFunction:
, js engine: hermes
i have a hash created with java code but need to verfiy with reat-native in java we are using SHA256withRSA
exception is coming with below code
pubKey = `MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAskBomu02R4n6GTY/36+3
DKQOE2BAL9NR4142LnBsqa5wsDxj7y742aBVxcm0KCeuKq1Tkh/344PHoWiohuHG
70Q1YSzzRiaCxfeOtDKITWCHOsdCUMvrNESZCy5giFU4DeXPn1YFwKKAmAtAxyRc
dVb2DyJn4V0aUVP/QvP3JXqL+HN0kj3gqIVmIMalMD0vgo5LI1fJYu/6skaX+SZn
/suCGDAtTr7i4vx2qnCdMlnYtFbclSrh/h96/q/g0P8VIEZvrZZZUNF32rkVofCS
YciP/JaS580I8a6kHe61is+gyn/6ugL5ea066u6bIEj80oC202e/qih01pJSceuR
awIDAQAB`
console.log(base64ToBytes(response.payload))
verifyResult = rnqc.createVerify("RSA-SHA256").update(base64ToBytes(response.payload)).verify({
key: base64ToBytes(pubKey),
//padding: rnqc.constants.RSA_PKCS1_PADDING,
//saltLength: 32,
}, base64ToBytes(response.signature))
I am also facing the same error
ERROR Error: Exception in HostFunction: <unknown>, js engine: hermes
ERROR Invariant Violation: "main" has not been registered. This can happen if:
* Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
* A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
I am also facing the same error
ERROR Error: Exception in HostFunction: <unknown>, js engine: hermes ERROR Invariant Violation: "main" has not been registered. This can happen if: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project. * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
Hi have you got the fix, I am also facing this issue.
I have the same issue.
This in my code.
export const encryptData = async (data) => { try { const publicKeyRF = await RNFS.readFile(publicKeyFilePath, "utf8"); const bufferVal = Buffer.from(data, "utf8") const dataEncryp = Crypto.publicEncrypt( { key: publicKeyRF, padding: Crypto.constants.RSA_PKCS1_PADDING, }, bufferVal ).toString("base64"); return dataEncryp; } catch (error) { console.log("Error") console.log(error) return null; } };
The console show this error:
[Error: Exception in HostFunction:
i don't remember how i actually fixed this worked for me.
import { RSA, RSAKeychain } from "react-native-rsa-native";
const publicKey = `-----BEGIN PUBLIC KEY-----
YourPubKey
-----END PUBLIC KEY-----`;
const valid = await RSA.verifyWithAlgorithm(
signedPayload.signature,
signedPayload.payload,
publicKey,
RSA.SHA256withRSA
);
I am also facing the same error
ERROR Error: Exception in HostFunction: <unknown>, js engine: hermes ERROR Invariant Violation: "main" has not been registered. This can happen if: * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project. * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called., js engine: hermes
Hi have you got the fix, I am also facing this issue.
I encountered a similar issue, which turned out to be related to a package problem specifically with react-native-reanimated. For troubleshooting steps, you can refer to: https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting/#failed-to-create-a-worklet
I got the same error and was able to resolve it. The error was with react-native-reanimated.
Follow the installation section on this link - https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/#step-2-add-reanimateds-babel-plugin
Step 1: Install the package Install react-native-reanimated package from npm:
EXPO NPM YARN npx expo install react-native-reanimated
Step 2: Add Reanimated's babel plugin Add react-native-reanimated/plugin plugin to your babel.config.js.
module.exports = { presets: [ ... // don't add it here :) ], plugins: [ ... 'react-native-reanimated/plugin', ], };
CAUTION react-native-reanimated/plugin has to be listed last.
Why do I need this?
Step 3: Clear Metro bundler cache (recommended) EXPO NPM YARN npx expo start -c
I also had this error which seemed to be a result of being on expo 50 and react-native-reanimated 3.8.1. I was able to resolve it by downgrading to react-native-reanimated 3.6.3 and was then able to open and run my app on Expo Go
Thank you @sethfriman this works...
Is this still broken with 0.7.0-rc.x
release candidates?
Is this still broken with
0.7.0-rc.x
release candidates?
on 0.7.0-rc.4
I get this:
❌ (node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10)
#include <string>
#include "base64.h"
^ 'base64.h' file not found
on the current version I get the error same as OP.
"react-native": "0.73.4" "react-native-quick-base64": "2.1.2",
removing react-native-reanimated doesn't fix the issue for me.
@boorad also can't run the package on a fresh react native setup (without expo). Same error as above on 0.7.0-rc.4, both ios and android:
node_modules/react-native-quick-crypto/cpp/Utils/MGLUtils.cpp:9:10: fatal error: 'base64.h' file not found
#include "base64.h"
^~~~~~~~~~
1 error generated.
[13/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/Random/MGLRandomHostObject.cpp.o
[14/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/fastpbkdf2/MGLPbkdf2HostObject.cpp.o
[15/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/JSIUtils/MGLTypedArray.cpp.o
[16/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/Cipher/MGLRsa.cpp.o
[17/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.cpp.o
[18/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/Sig/MGLSignInstaller.cpp.o
[19/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/Cipher/MGLCipherHostObject.cpp.o
[20/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/MGLQuickCryptoHostObject.cpp.o
[21/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/Sig/MGLVerifyInstaller.cpp.o
[22/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/webcrypto/MGLWebCrypto.cpp.o
[23/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/Cipher/MGLGenerateKeyPairInstaller.cpp.o
[24/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/Sig/MGLSignHostObjects.cpp.o
[25/27] Building CXX object CMakeFiles/reactnativequickcrypto.dir/Users/x_modules/react-native-quick-crypto/cpp/MGLKeys.cpp.o
ninja: build stopped: subcommand failed.
C++ build system [build] failed while executing:
/Users/x/Library/Android/sdk/cmake/3.22.1/bin/ninja \
-C \
/Users/x/node_modules/react-native-quick-crypto/android/.cxx/Debug/51zm2n4k/arm64-v8a \
reactnativequickcrypto
from /Users/x/node_modules/react-native-quick-crypto/android
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
I can probably close this because you're seeing the same thing as #291. Reopen if the HostFunction msg is still present.
i am seeing exception
ERROR Error: Exception in HostFunction: , js engine: hermes
i have a hash created with java code but need to verfiy with reat-native in java we are using SHA256withRSA
exception is coming with below code
pubKey = `MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAskBomu02R4n6GTY/36+3 DKQOE2BAL9NR4142LnBsqa5wsDxj7y742aBVxcm0KCeuKq1Tkh/344PHoWiohuHG 70Q1YSzzRiaCxfeOtDKITWCHOsdCUMvrNESZCy5giFU4DeXPn1YFwKKAmAtAxyRc dVb2DyJn4V0aUVP/QvP3JXqL+HN0kj3gqIVmIMalMD0vgo5LI1fJYu/6skaX+SZn /suCGDAtTr7i4vx2qnCdMlnYtFbclSrh/h96/q/g0P8VIEZvrZZZUNF32rkVofCS YciP/JaS580I8a6kHe61is+gyn/6ugL5ea066u6bIEj80oC202e/qih01pJSceuR awIDAQAB` console.log(base64ToBytes(response.payload)) verifyResult = rnqc.createVerify("RSA-SHA256").update(base64ToBytes(response.payload)).verify({ key: base64ToBytes(pubKey), //padding: rnqc.constants.RSA_PKCS1_PADDING, //saltLength: 32, }, base64ToBytes(response.signature))
Hello everyone,
I just found out that on my side, this happened because I was inputting Uint8Array into the .update function of createVerify, it also happened when decrypting with RSA
@margelo solution: Looking at the code in Util.ts (binaryLikeToArrayBuffer) you try to return an ArrayBuffer
// TODO add further binary types to BinaryLike, UInt8Array and so for have this array as property
if (ArrayBuffer.isView(input)) {
return input.buffer;
}
This works for the browser and NodeJS but in react-native there is no .buffer property(at least on my version - 0.72.7)
Temporary workaround I did a Buffer.from in front of all binary inputs e.g.
const data = Uint8Array.from([1,2,3])
const verify = createVerify(alg)
verify.update(Buffer.from(data))
...