59 lines
2.8 KiB
Diff
59 lines
2.8 KiB
Diff
diff --git a/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java b/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java
|
|
index d4ded69..af35eaa 100644
|
|
--- a/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java
|
|
+++ b/node_modules/react-native-keychain/android/src/main/java/com/oblador/keychain/KeychainModule.java
|
|
@@ -1,6 +1,7 @@
|
|
package com.oblador.keychain;
|
|
|
|
import android.os.Build;
|
|
+import android.os.Bundle;
|
|
import android.os.Looper;
|
|
import android.text.TextUtils;
|
|
import android.util.Log;
|
|
@@ -128,6 +129,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
|
|
//region Members
|
|
/** Name-to-instance lookup map. */
|
|
private final Map<String, CipherStorage> cipherStorageMap = new HashMap<>();
|
|
+ private final Map<String, Bundle> cachedCredentialsMap = new HashMap<>();
|
|
/** Shared preferences storage. */
|
|
private final PrefsStorage prefsStorage;
|
|
//endregion
|
|
@@ -139,13 +141,13 @@ public class KeychainModule extends ReactContextBaseJavaModule {
|
|
super(reactContext);
|
|
prefsStorage = new PrefsStorage(reactContext);
|
|
|
|
- addCipherStorageToMap(new CipherStorageFacebookConceal(reactContext));
|
|
+ // addCipherStorageToMap(new CipherStorageFacebookConceal(reactContext));
|
|
addCipherStorageToMap(new CipherStorageKeystoreAesCbc());
|
|
|
|
// we have a references to newer api that will fail load of app classes in old androids OS
|
|
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
- addCipherStorageToMap(new CipherStorageKeystoreRsaEcb());
|
|
- }
|
|
+ // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
+ // addCipherStorageToMap(new CipherStorageKeystoreRsaEcb());
|
|
+ // }
|
|
}
|
|
|
|
/** Allow initialization in chain. */
|
|
@@ -277,6 +279,12 @@ public class KeychainModule extends ReactContextBaseJavaModule {
|
|
@Nullable final ReadableMap options,
|
|
@NonNull final Promise promise) {
|
|
try {
|
|
+ Bundle cached = cachedCredentialsMap.get(alias);
|
|
+ if (cached != null) {
|
|
+ promise.resolve(Arguments.fromBundle(cached));
|
|
+ return;
|
|
+ }
|
|
+
|
|
final ResultSet resultSet = prefsStorage.getEncryptedEntry(alias);
|
|
|
|
if (resultSet == null) {
|
|
@@ -299,6 +307,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
|
|
credentials.putString(Maps.USERNAME, decryptionResult.username);
|
|
credentials.putString(Maps.PASSWORD, decryptionResult.password);
|
|
credentials.putString(Maps.STORAGE, current.getCipherStorageName());
|
|
+ cachedCredentialsMap.put(alias, Arguments.toBundle(credentials));
|
|
|
|
promise.resolve(credentials);
|
|
} catch (KeyStoreAccessException e) {
|