From da08ed89006be1f683916608718227c8250d4b32 Mon Sep 17 00:00:00 2001 From: Bruno Muniz Azevedo Filho <bruno@elixxir.io> Date: Tue, 25 Oct 2022 17:07:35 -0300 Subject: [PATCH] working on backup/restore account --- App/client-ios.xcodeproj/project.pbxproj | 8 ++++---- App/client-ios/Resources/Info.plist | 2 +- Sources/App/AppDelegate.swift | 2 -- .../BackupFeature/Service/BackupService.swift | 8 +++++++- Sources/InputField/Validator.swift | 2 +- .../ViewModels/RestoreListViewModel.swift | 2 ++ .../ViewModels/RestoreViewModel.swift | 19 +++++++++++++++++++ .../xcshareddata/swiftpm/Package.resolved | 9 --------- 8 files changed, 34 insertions(+), 18 deletions(-) diff --git a/App/client-ios.xcodeproj/project.pbxproj b/App/client-ios.xcodeproj/project.pbxproj index df25d856..5a37a1fd 100644 --- a/App/client-ios.xcodeproj/project.pbxproj +++ b/App/client-ios.xcodeproj/project.pbxproj @@ -448,7 +448,7 @@ CODE_SIGN_ENTITLEMENTS = "client-ios/Resources/client-ios.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 283; + CURRENT_PROJECT_VERSION = 288; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = S6JDM2WW29; ENABLE_BITCODE = NO; @@ -487,7 +487,7 @@ CODE_SIGN_ENTITLEMENTS = "client-ios/Resources/client-ios.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 283; + CURRENT_PROJECT_VERSION = 288; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = S6JDM2WW29; ENABLE_BITCODE = NO; @@ -522,7 +522,7 @@ CODE_SIGN_ENTITLEMENTS = NotificationExtension/NotificationExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 283; + CURRENT_PROJECT_VERSION = 288; DEVELOPMENT_TEAM = S6JDM2WW29; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( @@ -553,7 +553,7 @@ CODE_SIGN_ENTITLEMENTS = NotificationExtension/NotificationExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 283; + CURRENT_PROJECT_VERSION = 288; DEVELOPMENT_TEAM = S6JDM2WW29; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/App/client-ios/Resources/Info.plist b/App/client-ios/Resources/Info.plist index ee4d813d..d8cb845b 100644 --- a/App/client-ios/Resources/Info.plist +++ b/App/client-ios/Resources/Info.plist @@ -105,6 +105,6 @@ <key>UIViewControllerBasedStatusBarAppearance</key> <true/> <key>isReportingOptional</key> - <true/> + <false/> </dict> </plist> diff --git a/Sources/App/AppDelegate.swift b/Sources/App/AppDelegate.swift index 365a5874..9b7e3844 100644 --- a/Sources/App/AppDelegate.swift +++ b/Sources/App/AppDelegate.swift @@ -15,7 +15,6 @@ import XXClient import XXMessengerClient import CloudFiles -import CloudFilesDrive import CloudFilesDropbox public class AppDelegate: UIResponder, UIApplicationDelegate { @@ -64,7 +63,6 @@ public class AppDelegate: UIResponder, UIApplicationDelegate { PushRouter.live(navigationController: navController) ) - restoreIfPossible() return true } diff --git a/Sources/BackupFeature/Service/BackupService.swift b/Sources/BackupFeature/Service/BackupService.swift index 72cbe7fe..1599a423 100644 --- a/Sources/BackupFeature/Service/BackupService.swift +++ b/Sources/BackupFeature/Service/BackupService.swift @@ -26,6 +26,8 @@ public final class BackupService { @Dependency var messenger: Messenger @Dependency var networkManager: NetworkMonitoring + @KeyObject(.email, defaultValue: nil) var email: String? + @KeyObject(.phone, defaultValue: nil) var phone: String? @KeyObject(.username, defaultValue: nil) var username: String? @KeyObject(.backupSettings, defaultValue: nil) var storedSettings: Data? @@ -76,7 +78,11 @@ extension BackupService { public func initializeBackup(passphrase: String) { try! messenger.startBackup( password: passphrase, - params: .init(username: username!) + params: .init( + username: username!, + email: email, + phone: phone + ) ) } diff --git a/Sources/InputField/Validator.swift b/Sources/InputField/Validator.swift index 042916f3..b649bd5d 100644 --- a/Sources/InputField/Validator.swift +++ b/Sources/InputField/Validator.swift @@ -58,7 +58,7 @@ public extension Validator where T == String { return .failure("") } - let regex = try? NSRegularExpression(pattern: "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d!@#$%^&*]{8,}$") + let regex = try? NSRegularExpression(pattern: "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d\\W_]{8,}$") guard let regex = regex, regex.firstMatch(in: passphrase, options: [], range: passphrase.fullRange()) != nil else { return .failure("") diff --git a/Sources/RestoreFeature/ViewModels/RestoreListViewModel.swift b/Sources/RestoreFeature/ViewModels/RestoreListViewModel.swift index f9b252fa..ec247ddc 100644 --- a/Sources/RestoreFeature/ViewModels/RestoreListViewModel.swift +++ b/Sources/RestoreFeature/ViewModels/RestoreListViewModel.swift @@ -96,6 +96,7 @@ final class RestoreListViewModel { guard let manager = managers[provider] else { return } + hudSubject.send(.on) do { try manager.fetch { [weak self] in guard let self else { return } @@ -108,6 +109,7 @@ final class RestoreListViewModel { provider: provider, metadata: metadata )) + self.hudSubject.send(.none) case .failure(let error): self.hudSubject.send(.error(.init(with: error))) } diff --git a/Sources/RestoreFeature/ViewModels/RestoreViewModel.swift b/Sources/RestoreFeature/ViewModels/RestoreViewModel.swift index bda1797a..390c756d 100644 --- a/Sources/RestoreFeature/ViewModels/RestoreViewModel.swift +++ b/Sources/RestoreFeature/ViewModels/RestoreViewModel.swift @@ -127,6 +127,21 @@ final class RestoreViewModel { onProgress: { print(">>> \($0)") } ) + try self.database.saveContact(.init( + id: self.messenger.e2e.get()!.getContact().getId(), + marshaled: self.messenger.e2e.get()!.getContact().data, + username: self.username!, + email: self.email, + phone: self.phone, + nickname: nil, + photo: nil, + authStatus: .friend, + isRecent: false, + isBlocked: false, + isBanned: false, + createdAt: Date() + )) + print(">>> Calling multilookup") let multilookup = try self.messenger.lookupContacts(ids: result.restoredContacts) @@ -147,8 +162,12 @@ final class RestoreViewModel { isBanned: false, createdAt: Date() )) + + let _ = try! self.messenger.e2e.get()!.resetAuthenticatedChannel(partner: $0) } + try self.messenger.start() + multilookup.errors.forEach { print(">>> Error: \($0.localizedDescription)") } diff --git a/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved b/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved index 3bca0daa..b1975fc1 100644 --- a/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/client-ios.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -99,15 +99,6 @@ "version" : "1.3.0" } }, - { - "identity" : "fileprovider", - "kind" : "remoteSourceControl", - "location" : "https://github.com/amosavian/FileProvider.git", - "state" : { - "revision" : "abf68a62541a4193c8d106367ddb3648e8ab693f", - "version" : "0.26.0" - } - }, { "identity" : "firebase-ios-sdk", "kind" : "remoteSourceControl", -- GitLab