Rocket.Chat.ReactNative/patches/react-native-mmkv-storage+0...

115 lines
4.9 KiB
Diff
Raw Normal View History

diff --git a/node_modules/react-native-mmkv-storage/ios/MMKVNative.h b/node_modules/react-native-mmkv-storage/ios/MMKVNative.h
index 60a2a03..ca6fdfd 100644
--- a/node_modules/react-native-mmkv-storage/ios/MMKVNative.h
+++ b/node_modules/react-native-mmkv-storage/ios/MMKVNative.h
@@ -1,6 +1,6 @@
-#if __has_include("RCTBridgeModule.h")
-#import "RCTBridgeModule.h"
+#if __has_include(<React/RCTBridgeModule.h>)
+#import <React/RCTBridgeModule.h>
#else
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
diff --git a/node_modules/react-native-mmkv-storage/ios/MMKVStorage.h b/node_modules/react-native-mmkv-storage/ios/MMKVStorage.h
index b5f5823..62e2afa 100644
--- a/node_modules/react-native-mmkv-storage/ios/MMKVStorage.h
+++ b/node_modules/react-native-mmkv-storage/ios/MMKVStorage.h
@@ -1,6 +1,6 @@
-#if __has_include("RCTBridgeModule.h")
-#import "RCTBridgeModule.h"
+#if __has_include(<React/RCTBridgeModule.h>)
+#import <React/RCTBridgeModule.h>
#else
#import <React/RCTBridgeModule.h>
#import <React/RCTEventEmitter.h>
diff --git a/node_modules/react-native-mmkv-storage/ios/SecureStorage.h b/node_modules/react-native-mmkv-storage/ios/SecureStorage.h
index b804a64..291cc7e 100644
--- a/node_modules/react-native-mmkv-storage/ios/SecureStorage.h
+++ b/node_modules/react-native-mmkv-storage/ios/SecureStorage.h
@@ -1,6 +1,6 @@
-#if __has_include("RCTBridgeModule.h")
-#import "RCTBridgeModule.h"
+#if __has_include(<React/RCTBridgeModule.h>)
+#import <React/RCTBridgeModule.h>
#else
#import <React/RCTBridgeModule.h>
#endif
diff --git a/node_modules/react-native-mmkv-storage/ios/SecureStorage.m b/node_modules/react-native-mmkv-storage/ios/SecureStorage.m
index 1c4e1c2..fd6ef68 100644
--- a/node_modules/react-native-mmkv-storage/ios/SecureStorage.m
+++ b/node_modules/react-native-mmkv-storage/ios/SecureStorage.m
@@ -1,5 +1,5 @@
-#if __has_include("RCTBridgeModule.h")
-#import "RCTBridgeModule.h"
+#if __has_include(<React/RCTBridgeModule.h>)
+#import <React/RCTBridgeModule.h>
#else
#import <React/RCTBridgeModule.h>
#endif
@@ -45,14 +45,14 @@ - (NSString *) getSecureKey:(NSString *)key
@try {
[self handleAppUninstallation];
NSString *value = [self searchKeychainCopyMatching:key];
- dispatch_sync(dispatch_get_main_queue(), ^{
- int readAttempts = 0;
- // See: https://github.com/ammarahm-ed/react-native-mmkv-storage/issues/195
- while (![[UIApplication sharedApplication] isProtectedDataAvailable] && readAttempts++ < 100) {
- // sleep 25ms before another attempt
- usleep(25000);
- }
- });
+// dispatch_sync(dispatch_get_main_queue(), ^{
+// int readAttempts = 0;
+// // See: https://github.com/ammarahm-ed/react-native-mmkv-storage/issues/195
+// while (![[UIApplication sharedApplication] isProtectedDataAvailable] && readAttempts++ < 100) {
+// // sleep 25ms before another attempt
+// usleep(25000);
+// }
+// });
if (value == nil) {
NSString* errorMessage = @"key does not present";
@@ -105,6 +105,9 @@ - (void) removeSecureKey:(NSString *)key
- (NSMutableDictionary *)newSearchDictionary:(NSString *)identifier {
NSMutableDictionary *searchDictionary = [[NSMutableDictionary alloc] init];
+ // this value is shared by main app and extensions, so, is the best to be used here
+ serviceName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroup"];
+
if(serviceName == nil){
serviceName = [[NSBundle mainBundle] bundleIdentifier];
}
@@ -116,6 +119,9 @@ - (NSMutableDictionary *)newSearchDictionary:(NSString *)identifier {
[searchDictionary setObject:encodedIdentifier forKey:(id)kSecAttrAccount];
[searchDictionary setObject:serviceName forKey:(id)kSecAttrService];
+ NSString *keychainGroup = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"KeychainGroup"];
+ [searchDictionary setObject:keychainGroup forKey:(id)kSecAttrAccessGroup];
+
return searchDictionary;
}
@@ -217,11 +223,14 @@ - (void)clearSecureKeyStore
- (void)handleAppUninstallation
{
- // if (![[NSUserDefaults standardUserDefaults] boolForKey:@"RnSksIsAppInstalled"]) {
- // [self clearSecureKeyStore];
- //[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"IsAppInstalled"];
- [[NSUserDefaults standardUserDefaults] synchronize];
- // }
+ // use app group user defaults to prevent clear when it's share extension
+ NSString *suiteName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroup"];
+ NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:suiteName];
+ if (![userDefaults boolForKey:@"RnSksIsAppInstalled"]) {
+ [self clearSecureKeyStore];
+ [userDefaults setBool:YES forKey:@"RnSksIsAppInstalled"];
+ [userDefaults synchronize];
+ }
}
- (void) setServiceName:(NSString *)_serviceName