From 5bd329acb9cd9ba296f82d611706f9bfe857efad Mon Sep 17 00:00:00 2001 From: Alex Bumbu Date: Thu, 2 Sep 2021 15:17:08 +0300 Subject: [PATCH] feat(ios) update dropbox authentication to PKCE flow --- ios/Podfile | 2 +- ios/Podfile.lock | 8 ++--- ios/app/app.xcodeproj/project.pbxproj | 49 +++++++++++-------------- ios/sdk/src/dropbox/Dropbox.m | 51 ++++++++++++++++----------- 4 files changed, 56 insertions(+), 54 deletions(-) diff --git a/ios/Podfile b/ios/Podfile index d32552ebce..ea571891b5 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -76,7 +76,7 @@ target 'JitsiMeetSDK' do # pod 'CocoaLumberjack', '~>3.5.3' - pod 'ObjectiveDropboxOfficial', '~> 3.9.4' + pod 'ObjectiveDropboxOfficial', '~>6.1.0' use_native_modules! end diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 1bd9f8db1a..0762913363 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -115,7 +115,7 @@ PODS: - nanopb/encode (= 1.30906.0) - nanopb/decode (1.30906.0) - nanopb/encode (1.30906.0) - - ObjectiveDropboxOfficial (3.9.4) + - ObjectiveDropboxOfficial (6.1.0) - PromisesObjC (1.2.12) - RCTRequired (0.61.5-jitsi.2) - RCTTypeSafety (0.61.5-jitsi.2): @@ -386,7 +386,7 @@ DEPENDENCIES: - Firebase/DynamicLinks (~> 6.33.0) - Folly (from `../node_modules/react-native/third-party-podspecs/Folly.podspec`) - glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`) - - ObjectiveDropboxOfficial (~> 3.9.4) + - ObjectiveDropboxOfficial (~> 6.1.0) - RCTRequired (from `../node_modules/react-native/Libraries/RCTRequired/`) - RCTTypeSafety (from `../node_modules/react-native/Libraries/TypeSafety/`) - React (from `../node_modules/react-native/`) @@ -560,7 +560,7 @@ SPEC CHECKSUMS: GTMAppAuth: ad5c2b70b9a8689e1a04033c9369c4915bfcbe89 GTMSessionFetcher: 36689134877faeb055b27dfa4ccc9ceaa42e029e nanopb: 59317e09cf1f1a0af72f12af412d54edf52603fc - ObjectiveDropboxOfficial: a5afefc83f6467c42c45f2253f583f2ad1ffc701 + ObjectiveDropboxOfficial: b4765572e334d6fc6214b43a7595510324bbbbaa PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97 RCTRequired: a686731276578c125dff205f08b6ec9cee6ede32 RCTTypeSafety: 88e5500e801c00d16a3d1895e3470d13beed6584 @@ -599,6 +599,6 @@ SPEC CHECKSUMS: RNWatch: a5320c959c75e72845c07985f3e935e58998f1d3 Yoga: 96b469c5e81ff51b917b92e8c3390642d4ded30c -PODFILE CHECKSUM: 1ae1a9823f3eab0b6e735b9637ba7588e0890d08 +PODFILE CHECKSUM: 6f4485ed41286517917d47d2170b0de97d32bbfb COCOAPODS: 1.10.1 diff --git a/ios/app/app.xcodeproj/project.pbxproj b/ios/app/app.xcodeproj/project.pbxproj index c0d5d9be2b..6c474557d1 100644 --- a/ios/app/app.xcodeproj/project.pbxproj +++ b/ios/app/app.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; + 2681BB562C7A0B42CFBA6719 /* libPods-JitsiMeet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D6152FF9E9F7B0E86F70A21D /* libPods-JitsiMeet.a */; }; 4E90F9402632D1AB001102D4 /* Atomic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E90F93F2632D1AB001102D4 /* Atomic.swift */; }; 4EB06024260E026600F524C5 /* ReplayKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4EC49B8625BED71300E76218 /* ReplayKit.framework */; }; 4EB06027260E026600F524C5 /* SampleHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB06026260E026600F524C5 /* SampleHandler.swift */; }; @@ -30,7 +31,6 @@ 4EB0603C260E09D000F524C5 /* SocketConnection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB06039260E09D000F524C5 /* SocketConnection.swift */; }; 4EB0603D260E09D000F524C5 /* DarwinNotificationCenter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0603A260E09D000F524C5 /* DarwinNotificationCenter.swift */; }; 4EB0603E260E09D000F524C5 /* SampleUploader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4EB0603B260E09D000F524C5 /* SampleUploader.swift */; }; - 55BEDABDA92D47D399A70A5E /* libPods-JitsiMeet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D878B07B3FBD6E305EAA6B27 /* libPods-JitsiMeet.a */; }; DE050389256E904600DEE3A5 /* WebRTC.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE050388256E904600DEE3A5 /* WebRTC.xcframework */; }; DE05038A256E904600DEE3A5 /* WebRTC.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DE050388256E904600DEE3A5 /* WebRTC.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; DE4C456121DE1E4E00EA0709 /* FIRUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = DE4C455F21DE1E4E00EA0709 /* FIRUtilities.m */; }; @@ -113,7 +113,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 09AA3B93E4CC62D84B424690 /* Pods-jitsi-meet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-jitsi-meet.release.xcconfig"; path = "../Pods/Target Support Files/Pods-jitsi-meet/Pods-jitsi-meet.release.xcconfig"; sourceTree = ""; }; 0B26BE6D1EC5BC3C00EEFB41 /* JitsiMeet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = JitsiMeet.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 0B412F1D1EDEE6E800B1A0A6 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 0B412F1E1EDEE6E800B1A0A6 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; @@ -139,7 +138,7 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; - 4670A512A688E2DC34528282 /* Pods-jitsi-meet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-jitsi-meet.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-jitsi-meet/Pods-jitsi-meet.debug.xcconfig"; sourceTree = ""; }; + 3E0F4ED943C0B12BE77F6B45 /* Pods-JitsiMeet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.release.xcconfig"; path = "Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.release.xcconfig"; sourceTree = ""; }; 4E90F93F2632D1AB001102D4 /* Atomic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Atomic.swift; sourceTree = ""; }; 4EB06023260E026600F524C5 /* JitsiMeetBroadcastExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = JitsiMeetBroadcastExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 4EB06026260E026600F524C5 /* SampleHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleHandler.swift; sourceTree = ""; }; @@ -149,11 +148,9 @@ 4EB0603A260E09D000F524C5 /* DarwinNotificationCenter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DarwinNotificationCenter.swift; sourceTree = ""; }; 4EB0603B260E09D000F524C5 /* SampleUploader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SampleUploader.swift; sourceTree = ""; }; 4EC49B8625BED71300E76218 /* ReplayKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReplayKit.framework; path = System/Library/Frameworks/ReplayKit.framework; sourceTree = SDKROOT; }; - 5FEF9D87A4D2A38AD7193308 /* Pods-JitsiMeet-JitsiMeetBroadcastExtension.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet-JitsiMeetBroadcastExtension.release.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet-JitsiMeetBroadcastExtension/Pods-JitsiMeet-JitsiMeetBroadcastExtension.release.xcconfig"; sourceTree = ""; }; - 609CB2080B75F75A89923F3D /* Pods-JitsiMeet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.debug.xcconfig"; sourceTree = ""; }; - A7B2827E068A0E05260054AC /* Pods-JitsiMeet-JitsiMeetBroadcastExtension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet-JitsiMeetBroadcastExtension.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet-JitsiMeetBroadcastExtension/Pods-JitsiMeet-JitsiMeetBroadcastExtension.debug.xcconfig"; sourceTree = ""; }; + 756FCE06C08D9B947653C98A /* Pods-JitsiMeet.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.debug.xcconfig"; path = "Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.debug.xcconfig"; sourceTree = ""; }; B3B083EB1D4955FF0069CEE7 /* app.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = app.entitlements; sourceTree = ""; }; - D878B07B3FBD6E305EAA6B27 /* libPods-JitsiMeet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-JitsiMeet.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + D6152FF9E9F7B0E86F70A21D /* libPods-JitsiMeet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-JitsiMeet.a"; sourceTree = BUILT_PRODUCTS_DIR; }; DE050388256E904600DEE3A5 /* WebRTC.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = WebRTC.xcframework; path = "../../node_modules/react-native-webrtc/apple/WebRTC.xcframework"; sourceTree = ""; }; DE4C455F21DE1E4E00EA0709 /* FIRUtilities.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRUtilities.m; sourceTree = ""; }; DE4C456021DE1E4E00EA0709 /* FIRUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FIRUtilities.h; sourceTree = ""; }; @@ -161,7 +158,6 @@ DEFDBBDB25656E3B00344B23 /* WebRTC.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = WebRTC.xcframework; path = "../../node_modules/react-native-webrtc/ios/WebRTC.xcframework"; sourceTree = ""; }; E58801132278944E008B0561 /* JitsiMeetContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JitsiMeetContext.swift; sourceTree = ""; }; E5C97B62227A1EB400199214 /* JitsiMeetCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JitsiMeetCommands.swift; sourceTree = ""; }; - FC040BBED70876444D89E91C /* Pods-JitsiMeet.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JitsiMeet.release.xcconfig"; path = "../Pods/Target Support Files/Pods-JitsiMeet/Pods-JitsiMeet.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -178,7 +174,7 @@ files = ( DE050389256E904600DEE3A5 /* WebRTC.xcframework in Frameworks */, DEA9F289258A6EA800D4CD74 /* JitsiMeetSDK.framework in Frameworks */, - 55BEDABDA92D47D399A70A5E /* libPods-JitsiMeet.a in Frameworks */, + 2681BB562C7A0B42CFBA6719 /* libPods-JitsiMeet.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -208,8 +204,8 @@ 0B26BE6D1EC5BC3C00EEFB41 /* JitsiMeet.framework */, DEFDBBDB25656E3B00344B23 /* WebRTC.xcframework */, 0BD6B4361EF82A6B00D1F4CD /* WebRTC.framework */, - D878B07B3FBD6E305EAA6B27 /* libPods-JitsiMeet.a */, 4EC49B8625BED71300E76218 /* ReplayKit.framework */, + D6152FF9E9F7B0E86F70A21D /* libPods-JitsiMeet.a */, ); name = Frameworks; sourceTree = ""; @@ -278,19 +274,6 @@ sourceTree = ""; tabWidth = 4; }; - 5E96ADD5E49F3B3822EF9A52 /* Pods */ = { - isa = PBXGroup; - children = ( - 4670A512A688E2DC34528282 /* Pods-jitsi-meet.debug.xcconfig */, - 09AA3B93E4CC62D84B424690 /* Pods-jitsi-meet.release.xcconfig */, - 609CB2080B75F75A89923F3D /* Pods-JitsiMeet.debug.xcconfig */, - FC040BBED70876444D89E91C /* Pods-JitsiMeet.release.xcconfig */, - A7B2827E068A0E05260054AC /* Pods-JitsiMeet-JitsiMeetBroadcastExtension.debug.xcconfig */, - 5FEF9D87A4D2A38AD7193308 /* Pods-JitsiMeet-JitsiMeetBroadcastExtension.release.xcconfig */, - ); - name = Pods; - sourceTree = ""; - }; 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( @@ -298,10 +281,10 @@ 0B26BE711EC5BC4D00EEFB41 /* Frameworks */, 83CBBA001A601CBA00E9B192 /* Products */, 13B07FAE1A68108700A75B9A /* src */, - 5E96ADD5E49F3B3822EF9A52 /* Pods */, 0BEA5C261F7B8F73000D0AB4 /* Watch app */, 0BEA5C351F7B8F73000D0AB4 /* WatchKit extension */, 4EB06025260E026600F524C5 /* JitsiMeetBroadcast Extension */, + CDD71F5E1157E9F283DF92A8 /* Pods */, ); indentWidth = 2; sourceTree = ""; @@ -318,6 +301,16 @@ name = Products; sourceTree = ""; }; + CDD71F5E1157E9F283DF92A8 /* Pods */ = { + isa = PBXGroup; + children = ( + 756FCE06C08D9B947653C98A /* Pods-JitsiMeet.debug.xcconfig */, + 3E0F4ED943C0B12BE77F6B45 /* Pods-JitsiMeet.release.xcconfig */, + ); + name = Pods; + path = ../Pods; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -360,7 +353,7 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "JitsiMeet" */; buildPhases = ( - B6607F42A5CF0C76E98929E2 /* [CP] Check Pods Manifest.lock */, + 69BC5020DBE393B56BD76636 /* [CP] Check Pods Manifest.lock */, 0BBA83C41EC9F7600075A103 /* Run React packager */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, @@ -523,7 +516,7 @@ shellPath = /bin/sh; shellScript = "../scripts/run-packager.sh\n"; }; - B6607F42A5CF0C76E98929E2 /* [CP] Check Pods Manifest.lock */ = { + 69BC5020DBE393B56BD76636 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -825,7 +818,7 @@ }; 13B07F941A680F5B00A75B9A /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 609CB2080B75F75A89923F3D /* Pods-JitsiMeet.debug.xcconfig */; + baseConfigurationReference = 756FCE06C08D9B947653C98A /* Pods-JitsiMeet.debug.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIconDebug; @@ -855,7 +848,7 @@ }; 13B07F951A680F5B00A75B9A /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = FC040BBED70876444D89E91C /* Pods-JitsiMeet.release.xcconfig */; + baseConfigurationReference = 3E0F4ED943C0B12BE77F6B45 /* Pods-JitsiMeet.release.xcconfig */; buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIconRelease; diff --git a/ios/sdk/src/dropbox/Dropbox.m b/ios/sdk/src/dropbox/Dropbox.m index 9d231bda28..87b6eb8c7d 100644 --- a/ios/sdk/src/dropbox/Dropbox.m +++ b/ios/sdk/src/dropbox/Dropbox.m @@ -63,11 +63,14 @@ RCT_EXPORT_METHOD(authorize:(RCTPromiseResolveBlock)resolve currentReject = reject; dispatch_async(dispatch_get_main_queue(), ^{ - [DBClientsManager authorizeFromController:[UIApplication sharedApplication] - controller:[[self class] topMostController] - openURL:^(NSURL *url) { - [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; - }]; + DBScopeRequest *scopeRequest = [[DBScopeRequest alloc] initWithScopeType:DBScopeTypeUser + scopes:@[] + includeGrantedScopes:NO]; + [DBClientsManager authorizeFromControllerV2:[UIApplication sharedApplication] + controller:[[self class] topMostController] + loadingStatusDelegate:nil + openURL:^(NSURL *url) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; } + scopeRequest:scopeRequest]; }); } @@ -128,25 +131,31 @@ RCT_EXPORT_METHOD(getSpaceUsage: (NSString *)token if (currentReject == nil || currentResolve == nil) { return NO; } - DBOAuthResult *authResult = [DBClientsManager handleRedirectURL:url]; - if (authResult) { - if ([authResult isSuccess]) { - currentResolve(authResult.accessToken.accessToken); - } else { - NSString *msg; - if ([authResult isError]) { - msg = [NSString stringWithFormat:@"%@, error type: %zd",[authResult errorDescription], [authResult errorType]]; + + BOOL canHandle = [DBClientsManager handleRedirectURL:url completion:^(DBOAuthResult *authResult) { + if (authResult) { + if ([authResult isSuccess]) { + NSInteger msTimestamp = authResult.accessToken.tokenExpirationTimestamp * 1000; + NSDictionary *authInfo = @{@"token": authResult.accessToken.accessToken, + @"rToken": authResult.accessToken.refreshToken, + @"expireDate": @(msTimestamp) + }; + currentResolve(authInfo); } else { - msg = @"OAuth canceled!"; + NSString *msg; + if ([authResult isError]) { + msg = [NSString stringWithFormat:@"%@, error type: %zd", [authResult errorDescription], [authResult errorType]]; + } else { + msg = @"OAuth canceled!"; + } + currentReject(@"authorize", msg, nil); } - currentReject(@"authorize", msg, nil); + currentResolve = nil; + currentReject = nil; } - currentResolve = nil; - currentReject = nil; - - return YES; - } - return NO; + }]; + + return canHandle; } + (UIViewController *)topMostController {