Was struggling with some errors like:
TypeError: Cannot read property 'SECURITY_LEVEL_ANY' of undefined
or
null is not an object (evaluating 'RNKeychainManager.SECURITY_LEVEL_ANY')
(like https://github.com/oblador/react-native-keychain/issues/221)
The problem is within index.js:
export const SECURITY_LEVEL = Object.freeze({
ANY: RNKeychainManager.SECURITY_LEVEL_ANY,
SECURE_SOFTWARE: RNKeychainManager.SECURITY_LEVEL_SECURE_SOFTWARE,
SECURE_HARDWARE: RNKeychainManager.SECURITY_LEVEL_SECURE_HARDWARE,
});
It's not safe and should be changed to:
export const SECURITY_LEVEL = Object.freeze({
ANY: RNKeychainManager && RNKeychainManager.SECURITY_LEVEL_ANY,
SECURE_SOFTWARE: RNKeychainManager && RNKeychainManager.SECURITY_LEVEL_SECURE_SOFTWARE,
SECURE_HARDWARE: RNKeychainManager && RNKeychainManager.SECURITY_LEVEL_SECURE_HARDWARE, });
Please provide a PR for that. Im facing the same issue.
This worked for me (using react-native-pincode which relies on this). Please PR so that other repos that depend on this get the change!
Someone in the project can PR this pls ?
Please?!?!!
react-native-keychain+6.2.0.patch
diff --git a/node_modules/react-native-keychain/index.js b/node_modules/react-native-keychain/index.js
index e81235e..d412ebe 100644
--- a/node_modules/react-native-keychain/index.js
+++ b/node_modules/react-native-keychain/index.js
@@ -4,9 +4,9 @@ import { NativeModules, Platform } from 'react-native';
const { RNKeychainManager } = NativeModules;
export const SECURITY_LEVEL = Object.freeze({
- ANY: RNKeychainManager.SECURITY_LEVEL_ANY,
- SECURE_SOFTWARE: RNKeychainManager.SECURITY_LEVEL_SECURE_SOFTWARE,
- SECURE_HARDWARE: RNKeychainManager.SECURITY_LEVEL_SECURE_HARDWARE,
+ ANY: RNKeychainManager && RNKeychainManager.SECURITY_LEVEL_ANY,
+ SECURE_SOFTWARE: RNKeychainManager && RNKeychainManager.SECURITY_LEVEL_SECURE_SOFTWARE,
+ SECURE_HARDWARE: RNKeychainManager && RNKeychainManager.SECURITY_LEVEL_SECURE_HARDWARE,
});
export const ACCESSIBLE = Object.freeze({
please fix. thanks
Actually I move to https://docs.expo.io/versions/latest/sdk/securestore/ until this is not fixed. :'(
Any one of you people asking for a PR could make the PR for this. Take the time to support the library and make this PR. It's a great library and I'm sure it would be helpful :).
Submitted pull request with the suggested fix
Most helpful comment
Any one of you people asking for a PR could make the PR for this. Take the time to support the library and make this PR. It's a great library and I'm sure it would be helpful :).