Merge branch 'develop' into single-server-2

This commit is contained in:
Diego Mello 2020-03-11 16:08:13 -03:00
commit 26209a197e
11 changed files with 54 additions and 32 deletions

View File

@ -605,9 +605,6 @@ export default class Root extends React.Component {
} }
init = async() => { init = async() => {
if (isIOS) {
await RNUserDefaults.setName('group.ios.chat.rocket');
}
RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme); RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme);
const [notification, deepLinking] = await Promise.all([initializePushNotifications(), Linking.getInitialURL()]); const [notification, deepLinking] = await Promise.all([initializePushNotifications(), Linking.getInitialURL()]);
const parsedDeepLinkingURL = parseDeepLinking(deepLinking); const parsedDeepLinkingURL = parseDeepLinking(deepLinking);

View File

@ -15,7 +15,7 @@ import {
import Navigation from './lib/ShareNavigation'; import Navigation from './lib/ShareNavigation';
import store from './lib/createStore'; import store from './lib/createStore';
import sharedStyles from './views/Styles'; import sharedStyles from './views/Styles';
import { isNotch, isIOS, supportSystemTheme } from './utils/deviceInfo'; import { isNotch, supportSystemTheme } from './utils/deviceInfo';
import { defaultHeader, onNavigationStateChange, cardStyle } from './utils/navigation'; import { defaultHeader, onNavigationStateChange, cardStyle } from './utils/navigation';
import RocketChat, { THEME_PREFERENCES_KEY } from './lib/rocketchat'; import RocketChat, { THEME_PREFERENCES_KEY } from './lib/rocketchat';
import { ThemeContext } from './theme'; import { ThemeContext } from './theme';
@ -77,9 +77,6 @@ class Root extends React.Component {
} }
init = async() => { init = async() => {
if (isIOS) {
await RNUserDefaults.setName('group.ios.chat.rocket');
}
RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme); RNUserDefaults.objectForKey(THEME_PREFERENCES_KEY).then(this.setTheme);
const currentServer = await RNUserDefaults.get('currentServer'); const currentServer = await RNUserDefaults.get('currentServer');
const token = await RNUserDefaults.get(RocketChat.TOKEN_KEY); const token = await RNUserDefaults.get(RocketChat.TOKEN_KEY);

View File

@ -397,7 +397,7 @@ PODS:
- React - React
- RNScreens (2.0.0-alpha.3): - RNScreens (2.0.0-alpha.3):
- React - React
- RNUserDefaults (1.7.0): - RNUserDefaults (1.8.1):
- React - React
- RNVectorIcons (6.6.0): - RNVectorIcons (6.6.0):
- React - React
@ -786,7 +786,7 @@ SPEC CHECKSUMS:
RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c
RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494 RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494
RNScreens: 402a99b0a27c0c32f079cec12d3ccbd35e20cd7f RNScreens: 402a99b0a27c0c32f079cec12d3ccbd35e20cd7f
RNUserDefaults: af71a1cdf1c12baf8210bc741c65f5faba9826d6 RNUserDefaults: c421fd97ad06b35c16608c5d0fe675db353f632d
RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4 RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4
RSKImageCropper: a446db0e8444a036b34f3c43db01b2373baa4b2a RSKImageCropper: a446db0e8444a036b34f3c43db01b2373baa4b2a
SDWebImage: 4d5c027c935438f341ed33dbac53ff9f479922ca SDWebImage: 4d5c027c935438f341ed33dbac53ff9f479922ca

View File

@ -1,6 +1,6 @@
{ {
"name": "RNUserDefaults", "name": "RNUserDefaults",
"version": "1.7.0", "version": "1.8.1",
"summary": "Use `UserDefaults` (iOS) with React Native and `SharedPreferences` on AndroidOS.", "summary": "Use `UserDefaults` (iOS) with React Native and `SharedPreferences` on AndroidOS.",
"description": "Use `UserDefaults` (iOS) with React Native and `SharedPreferences` on AndroidOS.", "description": "Use `UserDefaults` (iOS) with React Native and `SharedPreferences` on AndroidOS.",
"license": "MIT", "license": "MIT",

View File

@ -397,7 +397,7 @@ PODS:
- React - React
- RNScreens (2.0.0-alpha.3): - RNScreens (2.0.0-alpha.3):
- React - React
- RNUserDefaults (1.7.0): - RNUserDefaults (1.8.1):
- React - React
- RNVectorIcons (6.6.0): - RNVectorIcons (6.6.0):
- React - React
@ -786,7 +786,7 @@ SPEC CHECKSUMS:
RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c RNReanimated: b2ab0b693dddd2339bd2f300e770f6302d2e960c
RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494 RNRootView: 895a4813dedeaca82db2fa868ca1c333d790e494
RNScreens: 402a99b0a27c0c32f079cec12d3ccbd35e20cd7f RNScreens: 402a99b0a27c0c32f079cec12d3ccbd35e20cd7f
RNUserDefaults: af71a1cdf1c12baf8210bc741c65f5faba9826d6 RNUserDefaults: c421fd97ad06b35c16608c5d0fe675db353f632d
RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4 RNVectorIcons: 0bb4def82230be1333ddaeee9fcba45f0b288ed4
RSKImageCropper: a446db0e8444a036b34f3c43db01b2373baa4b2a RSKImageCropper: a446db0e8444a036b34f3c43db01b2373baa4b2a
SDWebImage: 4d5c027c935438f341ed33dbac53ff9f479922ca SDWebImage: 4d5c027c935438f341ed33dbac53ff9f479922ca

View File

@ -67,7 +67,7 @@
<key>NSMicrophoneUsageDescription</key> <key>NSMicrophoneUsageDescription</key>
<string>Use your microphone to record audio messages</string> <string>Use your microphone to record audio messages</string>
<key>NSMotionUsageDescription</key> <key>NSMotionUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to access your device's accelerometer</string> <string>Allow $(PRODUCT_NAME) to access your device&apos;s accelerometer</string>
<key>NSPhotoLibraryAddUsageDescription</key> <key>NSPhotoLibraryAddUsageDescription</key>
<string>Give $(PRODUCT_NAME) permission to save photos</string> <string>Give $(PRODUCT_NAME) permission to save photos</string>
<key>NSPhotoLibraryUsageDescription</key> <key>NSPhotoLibraryUsageDescription</key>
@ -110,5 +110,7 @@
<string>firefox</string> <string>firefox</string>
<string>brave</string> <string>brave</string>
</array> </array>
<key>AppGroup</key>
<string>group.ios.chat.rocket</string>
</dict> </dict>
</plist> </plist>

View File

@ -60,5 +60,7 @@
<array> <array>
<string>custom.ttf</string> <string>custom.ttf</string>
</array> </array>
<key>AppGroup</key>
<string>group.ios.chat.rocket</string>
</dict> </dict>
</plist> </plist>

View File

@ -105,7 +105,7 @@
"rn-extensions-share": "^2.3.10", "rn-extensions-share": "^2.3.10",
"rn-fetch-blob": "0.11.2", "rn-fetch-blob": "0.11.2",
"rn-root-view": "^1.0.3", "rn-root-view": "^1.0.3",
"rn-user-defaults": "1.7.0", "rn-user-defaults": "^1.8.1",
"semver": "6.3.0", "semver": "6.3.0",
"snyk": "1.210.0", "snyk": "1.210.0",
"strip-ansi": "5.2.0", "strip-ansi": "5.2.0",

View File

@ -1,8 +1,16 @@
diff --git a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm diff --git a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm
index e72e943..ec0a0ba 100644 index e72e943..ee0c7a1 100644
--- a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm --- a/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm
+++ b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm +++ b/node_modules/react-native/Libraries/Network/RCTHTTPRequestHandler.mm
@@ -55,6 +55,59 @@ - (BOOL)canHandleRequest:(NSURLRequest *)request @@ -10,6 +10,7 @@
#import <mutex>
#import <React/RCTNetworking.h>
+#import "RNUserDefaults.h"
@interface RCTHTTPRequestHandler () <NSURLSessionDataDelegate>
@@ -55,6 +56,59 @@ - (BOOL)canHandleRequest:(NSURLRequest *)request
return [schemes containsObject:request.URL.scheme.lowercaseString]; return [schemes containsObject:request.URL.scheme.lowercaseString];
} }
@ -62,14 +70,14 @@ index e72e943..ec0a0ba 100644
- (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request - (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request
withDelegate:(id<RCTURLRequestDelegate>)delegate withDelegate:(id<RCTURLRequestDelegate>)delegate
{ {
@@ -171,4 +224,20 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp @@ -171,4 +225,20 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp
[delegate URLRequest:task didCompleteWithError:error]; [delegate URLRequest:task didCompleteWithError:error];
} }
+-(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler { +-(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler {
+ +
+ NSString *host = challenge.protectionSpace.host; + NSString *host = challenge.protectionSpace.host;
+ NSDictionary *clientSSL = [[[NSUserDefaults alloc] initWithSuiteName:@"group.ios.chat.rocket"] objectForKey:host]; + NSDictionary *clientSSL = [[RNUserDefaults getDefaultUser] objectForKey:host];
+ +
+ NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]; + NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
+ +
@ -84,10 +92,19 @@ index e72e943..ec0a0ba 100644
+ +
@end @end
diff --git a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m diff --git a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m
index a134d2e..a88c099 100644 index a134d2e..1526d60 100644
--- a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m --- a/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m
+++ b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m +++ b/node_modules/react-native/Libraries/WebSocket/RCTSRWebSocket.m
@@ -481,6 +481,29 @@ - (void)didConnect @@ -27,6 +27,8 @@
#import <React/RCTAssert.h>
#import <React/RCTLog.h>
+#import "RNUserDefaults.h"
+
typedef NS_ENUM(NSInteger, RCTSROpCode) {
RCTSROpCodeTextFrame = 0x1,
RCTSROpCodeBinaryFrame = 0x2,
@@ -481,6 +483,29 @@ - (void)didConnect
[self _readHTTPHeader]; [self _readHTTPHeader];
} }
@ -117,12 +134,12 @@ index a134d2e..a88c099 100644
- (void)_initializeStreams; - (void)_initializeStreams;
{ {
assert(_url.port.unsignedIntValue <= UINT32_MAX); assert(_url.port.unsignedIntValue <= UINT32_MAX);
@@ -518,6 +541,15 @@ - (void)_initializeStreams; @@ -518,6 +543,15 @@ - (void)_initializeStreams;
RCTLogInfo(@"SocketRocket: In debug mode. Allowing connection to any root cert"); RCTLogInfo(@"SocketRocket: In debug mode. Allowing connection to any root cert");
#endif #endif
+ // SSL Pinning + // SSL Pinning
+ NSDictionary *clientSSL = [[[NSUserDefaults alloc] initWithSuiteName:@"group.ios.chat.rocket"] objectForKey:host]; + NSDictionary *clientSSL = [[RNUserDefaults getDefaultUser] objectForKey:host];
+ if (clientSSL != (id)[NSNull null]) { + if (clientSSL != (id)[NSNull null]) {
+ NSString *path = [clientSSL objectForKey:@"path"]; + NSString *path = [clientSSL objectForKey:@"path"];
+ NSString *password = [clientSSL objectForKey:@"password"]; + NSString *password = [clientSSL objectForKey:@"password"];
@ -133,7 +150,7 @@ index a134d2e..a88c099 100644
[_outputStream setProperty:SSLOptions [_outputStream setProperty:SSLOptions
forKey:(__bridge id)kCFStreamPropertySSLSettings]; forKey:(__bridge id)kCFStreamPropertySSLSettings];
} }
@@ -597,6 +629,7 @@ - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason; @@ -597,6 +631,7 @@ - (void)closeWithCode:(NSInteger)code reason:(NSString *)reason;
} }
} }

View File

@ -1,8 +1,16 @@
diff --git a/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m b/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m diff --git a/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m b/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m
index edc4fd4..aeb5eaa 100644 index edc4fd4..7cd77f6 100644
--- a/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m --- a/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m
+++ b/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m +++ b/node_modules/react-native-notifications/RNNotifications/RNNotificationEventHandler.m
@@ -28,9 +28,92 @@ - (void)didReceiveForegroundNotification:(UNNotification *)notification withComp @@ -3,6 +3,7 @@
#import "RNNotificationUtils.h"
#import "RCTConvert+RNNotifications.h"
#import "RNNotificationParser.h"
+#import "RNUserDefaults.h"
@implementation RNNotificationEventHandler {
RNNotificationsStore* _store;
@@ -28,9 +29,91 @@ - (void)didReceiveForegroundNotification:(UNNotification *)notification withComp
[RNEventEmitter sendEvent:RNNotificationReceivedForeground body:[RNNotificationParser parseNotification:notification]]; [RNEventEmitter sendEvent:RNNotificationReceivedForeground body:[RNNotificationParser parseNotification:notification]];
} }
@ -54,10 +62,9 @@ index edc4fd4..aeb5eaa 100644
+ NSString *msg = [(UNTextInputNotificationResponse *)response userText]; + NSString *msg = [(UNTextInputNotificationResponse *)response userText];
+ +
+ // get credentials + // get credentials
+ NSUserDefaults *userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"group.ios.chat.rocket"];
+ NSString *TOKEN_KEY = @"reactnativemeteor_usertoken"; + NSString *TOKEN_KEY = @"reactnativemeteor_usertoken";
+ NSString *userId = [userDefaults stringForKey:[NSString stringWithFormat:@"%@-%@", TOKEN_KEY, [self serverURL:host]]]; + NSString *userId = [[RNUserDefaults getDefaultUser] stringForKey:[NSString stringWithFormat:@"%@-%@", TOKEN_KEY, [self serverURL:host]]];
+ NSString *token = [userDefaults stringForKey:[NSString stringWithFormat:@"%@-%@", TOKEN_KEY, userId]]; + NSString *token = [[RNUserDefaults getDefaultUser] stringForKey:[NSString stringWithFormat:@"%@-%@", TOKEN_KEY, userId]];
+ +
+ // background task - we need this because fetch doesn't work if app is closed/killed + // background task - we need this because fetch doesn't work if app is closed/killed
+ UIApplication *app = [UIApplication sharedApplication]; + UIApplication *app = [UIApplication sharedApplication];

View File

@ -10379,10 +10379,10 @@ rn-root-view@^1.0.3:
resolved "https://registry.yarnpkg.com/rn-root-view/-/rn-root-view-1.0.3.tgz#a2cddc717278cb2175fb29b7c006e407b7f0d0e2" resolved "https://registry.yarnpkg.com/rn-root-view/-/rn-root-view-1.0.3.tgz#a2cddc717278cb2175fb29b7c006e407b7f0d0e2"
integrity sha512-BIKm8hY5q8+pxK9B5ugYjqutoI9xn2JfxIZKWoaFmAl1bOIM4oXjwFQrRM1e6lFgzz99MN6Mf2dK3Alsywnvvw== integrity sha512-BIKm8hY5q8+pxK9B5ugYjqutoI9xn2JfxIZKWoaFmAl1bOIM4oXjwFQrRM1e6lFgzz99MN6Mf2dK3Alsywnvvw==
rn-user-defaults@1.7.0: rn-user-defaults@^1.8.1:
version "1.7.0" version "1.8.1"
resolved "https://registry.yarnpkg.com/rn-user-defaults/-/rn-user-defaults-1.7.0.tgz#8d1b79657dec3977e8f8983814b8591821f77236" resolved "https://registry.yarnpkg.com/rn-user-defaults/-/rn-user-defaults-1.8.1.tgz#ccb8048f3ce43388ae40ac33eb063bfa93071702"
integrity sha512-Qo6sIH8wldmQ0oOMMvljec4WOa/a1Up1pdatoXZGaPG1gl8OKgKH5HPKyddcABYtxPeBUTPVzCxP/6S6wPCqGQ== integrity sha512-pnUiB6Xn++5YGzSA1BKOsRAdz/GPkW3MViN5Yii6XGp5d6arcP4pOVIGmiFlOfxIFrHD3GU440WFnt5L7ogMSg==
rsvp@^3.3.3: rsvp@^3.3.3:
version "3.6.2" version "3.6.2"