mattermost-mobile/patches/react-native-keychain+8.0.0.patch
Elias Nahum db86bbc42b
Bump build to 436 (#6746)
* Revert "Downgrade mmkv and bump to 435 (#6742)"

This reverts commit 66b469bb31.

* Revert "Bump Version to 1.56.0 and build to 431 (#6723)"

This reverts commit fdee027b4a.

* Revert "[V1] update deps (#6666)"

This reverts commit 8137241f12.

* bump build to 436

* update snapshots
2022-11-08 10:19:25 +02:00

62 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 6ca68cb..dacb1ed 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.text.TextUtils;
import android.util.Log;
@@ -129,6 +130,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
@@ -140,13 +142,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
super(reactContext);
prefsStorage = new PrefsStorage(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());
- }
}
/** Allow initialization in chain. */
@@ -278,6 +274,11 @@ 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) {
@@ -310,6 +311,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
credentials.putString(Maps.USERNAME, decryptionResult.username);
credentials.putString(Maps.PASSWORD, decryptionResult.password);
credentials.putString(Maps.STORAGE, cipher.getCipherStorageName());
+ cachedCredentialsMap.put(alias, Arguments.toBundle(credentials));
promise.resolve(credentials);
} catch (KeyStoreAccessException e) {
@@ -382,6 +384,7 @@ public class KeychainModule extends ReactContextBaseJavaModule {
}
// And then we remove the entry in the shared preferences
prefsStorage.removeEntry(alias);
+ cachedCredentialsMap.remove(alias);
promise.resolve(true);
} catch (KeyStoreAccessException e) {