diff --git a/WireDomain/Sources/WireDomain/Needle.generated.swift b/WireDomain/Sources/WireDomain/Needle.generated.swift index f775293e91b..fd9b927d207 100644 --- a/WireDomain/Sources/WireDomain/Needle.generated.swift +++ b/WireDomain/Sources/WireDomain/Needle.generated.swift @@ -85,9 +85,6 @@ private class NSEClientScopeDependencyfc368141c1425b82ae14Provider: NSEClientSco var cookieStorage: CookieStorage { return nSEUserScope.cookieStorage } - var cryptoboxMigrationManager: CryptoboxMigrationManager { - return nSEUserScope.cryptoboxMigrationManager - } private let nSEFlow: NSEFlow private let nSEUserScope: NSEUserScope init(nSEFlow: NSEFlow, nSEUserScope: NSEUserScope) { @@ -116,7 +113,6 @@ extension NSEUserScope: NeedleFoundation.Registration { localTable["userAccountDataURL-URL"] = { [unowned self] in self.userAccountDataURL as Any } localTable["journal-Journal"] = { [unowned self] in self.journal as Any } localTable["cookieStorage-CookieStorage"] = { [unowned self] in self.cookieStorage as Any } - localTable["cryptoboxMigrationManager-CryptoboxMigrationManager"] = { [unowned self] in self.cryptoboxMigrationManager as Any } } } extension NSEClientScope: NeedleFoundation.Registration { @@ -129,7 +125,6 @@ extension NSEClientScope: NeedleFoundation.Registration { keyPathToName[\NSEClientScopeDependency.journal] = "journal-Journal" keyPathToName[\NSEClientScopeDependency.sharedUserDefaults] = "sharedUserDefaults-UserDefaults" keyPathToName[\NSEClientScopeDependency.cookieStorage] = "cookieStorage-CookieStorage" - keyPathToName[\NSEClientScopeDependency.cryptoboxMigrationManager] = "cryptoboxMigrationManager-CryptoboxMigrationManager" } } extension NSEFlow: NeedleFoundation.Registration { diff --git a/WireDomain/Sources/WireDomain/Notifications/Components/NSEClientScope.swift b/WireDomain/Sources/WireDomain/Notifications/Components/NSEClientScope.swift index aa7d4bdf982..49c518e2570 100644 --- a/WireDomain/Sources/WireDomain/Notifications/Components/NSEClientScope.swift +++ b/WireDomain/Sources/WireDomain/Notifications/Components/NSEClientScope.swift @@ -32,7 +32,6 @@ protocol NSEClientScopeDependency: Dependency { var journal: Journal { get } var sharedUserDefaults: UserDefaults { get } var cookieStorage: CookieStorage { get } - var cryptoboxMigrationManager: CryptoboxMigrationManager { get } } @@ -253,7 +252,6 @@ final class NSEClientScope: Component { accountDirectory: dependency.userAccountDataURL, sharedUserDefaults: dependency.sharedUserDefaults, syncContext: coreDataStack.syncContext, - cryptoboxMigrationManager: dependency.cryptoboxMigrationManager, coreCryptoKeyMigrationManager: coreCryptoMigrationManager, allowCreation: false, localDomain: localDomain diff --git a/WireDomain/Sources/WireDomain/Notifications/Components/NSEUserScope.swift b/WireDomain/Sources/WireDomain/Notifications/Components/NSEUserScope.swift index 13531609f30..c5f6a40b34b 100644 --- a/WireDomain/Sources/WireDomain/Notifications/Components/NSEUserScope.swift +++ b/WireDomain/Sources/WireDomain/Notifications/Components/NSEUserScope.swift @@ -90,8 +90,6 @@ final class NSEUserScope: Component { } } - public let cryptoboxMigrationManager: CryptoboxMigrationManager = .init() - init( parent: any Scope, account: Account @@ -143,10 +141,6 @@ final class NSEUserScope: Component { throw Failure.userNotAuthenticated } - guard !cryptoboxMigrationManager.isMigrationNeeded(accountDirectory: userAccountDataURL) else { - throw Failure.mainAppRequired(message: "cryptobox migration required") - } - guard !coreCryptoKeyMigrationManager.isAnyMigrationRequired else { throw Failure.mainAppRequired(message: "core crypto key migration required") } diff --git a/wire-ios-data-model/Source/Core Crypto/CoreCryptoProvider.swift b/wire-ios-data-model/Source/Core Crypto/CoreCryptoProvider.swift index 23a4fb8482f..cfeb5f80ebe 100644 --- a/wire-ios-data-model/Source/Core Crypto/CoreCryptoProvider.swift +++ b/wire-ios-data-model/Source/Core Crypto/CoreCryptoProvider.swift @@ -62,7 +62,6 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol { private let sharedContainerURL: URL private let accountDirectory: URL private let sharedUserDefaults: UserDefaultsProtocol - private let cryptoboxMigrationManager: CryptoboxMigrationManagerInterface private var coreCryptoKeyMigrationManager: CoreCryptoKeyMigrationManagerProtocol private let featureRespository: LegacyFeatureRepositoryInterface private let syncContext: NSManagedObjectContext @@ -84,7 +83,6 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol { accountDirectory: URL, sharedUserDefaults: UserDefaultsProtocol, syncContext: NSManagedObjectContext, - cryptoboxMigrationManager: CryptoboxMigrationManagerInterface, coreCryptoKeyMigrationManager: CoreCryptoKeyMigrationManagerProtocol, allowCreation: Bool = true, localDomain: String? @@ -95,7 +93,6 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol { self.sharedUserDefaults = sharedUserDefaults self.syncContext = syncContext self.allowCreation = allowCreation - self.cryptoboxMigrationManager = cryptoboxMigrationManager self.coreCryptoKeyMigrationManager = coreCryptoKeyMigrationManager self.featureRespository = LegacyFeatureRepository(context: syncContext) self.localDomain = localDomain @@ -236,7 +233,6 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol { ) updateKeychainItemAccess() - await migrateCryptoboxSessionsIfNeeded(with: coreCrypto) try await configureProteusClient(coreCrypto: coreCrypto) try await configureMLSClient(coreCrypto: coreCrypto) @@ -362,27 +358,4 @@ public actor CoreCryptoProvider: CoreCryptoProviderProtocol { } } - private func migrateCryptoboxSessionsIfNeeded(with coreCrypto: SafeCoreCrypto) async { - guard cryptoboxMigrationManager.isMigrationNeeded(accountDirectory: accountDirectory) else { - WireLogger.proteus.info("cryptobox migration is not needed") - return - } - - WireLogger.proteus.info("preparing for cryptobox migration...") - - do { - try await cryptoboxMigrationManager.performMigration( - accountDirectory: accountDirectory, - coreCrypto: coreCrypto - ) - } catch { - WireLogger.proteus.critical("cryptobox migration failed: \(error.localizedDescription)") - fatalError( - "Failed to migrate data from CryptoBox to CoreCrypto keystore, error : \(error.localizedDescription)" - ) - } - - WireLogger.proteus.info("cryptobox migration success") - } - } diff --git a/wire-ios-data-model/Source/Proteus/CryptoboxMigrationManager.swift b/wire-ios-data-model/Source/Proteus/CryptoboxMigrationManager.swift deleted file mode 100644 index 453264656b9..00000000000 --- a/wire-ios-data-model/Source/Proteus/CryptoboxMigrationManager.swift +++ /dev/null @@ -1,127 +0,0 @@ -// -// Wire -// Copyright (C) 2025 Wire Swiss GmbH -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/. -// - -import Foundation -import WireLogging -import WireSystem - -// sourcery: AutoMockable -public protocol CryptoboxMigrationManagerInterface { - - func isMigrationNeeded(accountDirectory: URL) -> Bool - - func performMigration( - accountDirectory: URL, - coreCrypto: SafeCoreCryptoProtocol - ) async throws -} - -public class CryptoboxMigrationManager: CryptoboxMigrationManagerInterface { - - // MARK: - Properties - - let fileManager: FileManagerInterface - - // MARK: - Life cycle - - public convenience init() { - self.init(fileManager: FileManager.default) - } - - init(fileManager: FileManagerInterface) { - self.fileManager = fileManager - } - - // MARK: - Failure - - enum Failure: Error { - - case failedToMigrateData - case failedToDeleteLegacyData - case proteusServiceUnavailable - - } - - // MARK: - Methods - - public func isMigrationNeeded(accountDirectory: URL) -> Bool { - // disabling migration. This will be removed completely in https://wearezeta.atlassian.net/browse/WPB-22227 - false - } - - public func performMigration( - accountDirectory: URL, - coreCrypto: SafeCoreCryptoProtocol - ) async throws { - do { - WireLogger.proteus.info("migrating cryptobox data...") - let cryptoboxDirectory = fileManager.cryptoboxDirectory(in: accountDirectory) - try await coreCrypto.perform { try await $0.proteusCryptoboxMigrate(path: cryptoboxDirectory.path) } - WireLogger.proteus.info("migrating cryptobox data... success") - } catch { - throw Failure.failedToMigrateData - } - - do { - WireLogger.proteus.info("removing legacy cryptobox data...") - try removeDirectory(in: accountDirectory) - WireLogger.proteus.info("removing legacy cryptobox data... success") - } catch { - throw Failure.failedToDeleteLegacyData - } - } - - // MARK: - Helpers - - private func removeDirectory(in accountDirectory: URL) throws { - let cryptoboxDirectory = fileManager.cryptoboxDirectory(in: accountDirectory) - guard fileManager.fileExists(atPath: cryptoboxDirectory.path) else { return } - try fileManager.removeItem(at: cryptoboxDirectory) - } - -} - -// sourcery: AutoMockable -protocol FileManagerInterface { - - func fileExists(atPath path: String) -> Bool - func removeItem(at url: URL) throws - func cryptoboxDirectory(in accountDirectory: URL) -> URL - -} - -extension FileManager: FileManagerInterface { - - private static let keyStoreFolderPrefix = "otr" - - func cryptoboxDirectory(in accountDirectory: URL) -> URL { - keyStoreURL( - accountDirectory: accountDirectory, - createParentIfNeeded: false - ) - } - - /// Returns the URL for the keyStore - private func keyStoreURL(accountDirectory: URL, createParentIfNeeded: Bool) -> URL { - if createParentIfNeeded { - try! FileManager.default.createAndProtectDirectory(at: accountDirectory) - } - return accountDirectory.appendingPathComponent(FileManager.keyStoreFolderPrefix) - } - -} diff --git a/wire-ios-data-model/Support/Sourcery/generated/AutoMockable.generated.swift b/wire-ios-data-model/Support/Sourcery/generated/AutoMockable.generated.swift index b6cc314e035..0a86e2cbc8f 100644 --- a/wire-ios-data-model/Support/Sourcery/generated/AutoMockable.generated.swift +++ b/wire-ios-data-model/Support/Sourcery/generated/AutoMockable.generated.swift @@ -2196,53 +2196,6 @@ public class MockCoreDataStackProtocol: CoreDataStackProtocol { } -public class MockCryptoboxMigrationManagerInterface: CryptoboxMigrationManagerInterface { - - // MARK: - Life cycle - - public init() {} - - - // MARK: - isMigrationNeeded - - public var isMigrationNeededAccountDirectory_Invocations: [URL] = [] - public var isMigrationNeededAccountDirectory_MockMethod: ((URL) -> Bool)? - public var isMigrationNeededAccountDirectory_MockValue: Bool? - - public func isMigrationNeeded(accountDirectory: URL) -> Bool { - isMigrationNeededAccountDirectory_Invocations.append(accountDirectory) - - if let mock = isMigrationNeededAccountDirectory_MockMethod { - return mock(accountDirectory) - } else if let mock = isMigrationNeededAccountDirectory_MockValue { - return mock - } else { - fatalError("no mock for `isMigrationNeededAccountDirectory`") - } - } - - // MARK: - performMigration - - public var performMigrationAccountDirectoryCoreCrypto_Invocations: [(accountDirectory: URL, coreCrypto: SafeCoreCryptoProtocol)] = [] - public var performMigrationAccountDirectoryCoreCrypto_MockError: Error? - public var performMigrationAccountDirectoryCoreCrypto_MockMethod: ((URL, SafeCoreCryptoProtocol) async throws -> Void)? - - public func performMigration(accountDirectory: URL, coreCrypto: SafeCoreCryptoProtocol) async throws { - performMigrationAccountDirectoryCoreCrypto_Invocations.append((accountDirectory: accountDirectory, coreCrypto: coreCrypto)) - - if let error = performMigrationAccountDirectoryCoreCrypto_MockError { - throw error - } - - guard let mock = performMigrationAccountDirectoryCoreCrypto_MockMethod else { - fatalError("no mock for `performMigrationAccountDirectoryCoreCrypto`") - } - - try await mock(accountDirectory, coreCrypto) - } - -} - public class MockE2EIServiceInterface: E2EIServiceInterface { // MARK: - Life cycle @@ -3090,70 +3043,6 @@ public class MockEARServiceInterface: EARServiceInterface { } -class MockFileManagerInterface: FileManagerInterface { - - // MARK: - Life cycle - - - - // MARK: - fileExists - - var fileExistsAtPath_Invocations: [String] = [] - var fileExistsAtPath_MockMethod: ((String) -> Bool)? - var fileExistsAtPath_MockValue: Bool? - - func fileExists(atPath path: String) -> Bool { - fileExistsAtPath_Invocations.append(path) - - if let mock = fileExistsAtPath_MockMethod { - return mock(path) - } else if let mock = fileExistsAtPath_MockValue { - return mock - } else { - fatalError("no mock for `fileExistsAtPath`") - } - } - - // MARK: - removeItem - - var removeItemAt_Invocations: [URL] = [] - var removeItemAt_MockError: Error? - var removeItemAt_MockMethod: ((URL) throws -> Void)? - - func removeItem(at url: URL) throws { - removeItemAt_Invocations.append(url) - - if let error = removeItemAt_MockError { - throw error - } - - guard let mock = removeItemAt_MockMethod else { - fatalError("no mock for `removeItemAt`") - } - - try mock(url) - } - - // MARK: - cryptoboxDirectory - - var cryptoboxDirectoryIn_Invocations: [URL] = [] - var cryptoboxDirectoryIn_MockMethod: ((URL) -> URL)? - var cryptoboxDirectoryIn_MockValue: URL? - - func cryptoboxDirectory(in accountDirectory: URL) -> URL { - cryptoboxDirectoryIn_Invocations.append(accountDirectory) - - if let mock = cryptoboxDirectoryIn_MockMethod { - return mock(accountDirectory) - } else if let mock = cryptoboxDirectoryIn_MockValue { - return mock - } else { - fatalError("no mock for `cryptoboxDirectoryIn`") - } - } - -} - public class MockIsSelfUserE2EICertifiedUseCaseProtocol: IsSelfUserE2EICertifiedUseCaseProtocol { // MARK: - Life cycle diff --git a/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj b/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj index 660f5cf119e..5a0014edfc5 100644 --- a/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj +++ b/wire-ios-data-model/WireDataModel.xcodeproj/project.pbxproj @@ -529,7 +529,6 @@ EE74E4DE2A37B28C00B63E6E /* SubconversationGroupIDRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE74E4DD2A37B28C00B63E6E /* SubconversationGroupIDRepository.swift */; }; EE74E4E02A37B3BF00B63E6E /* SubconversationGroupIDRepositoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE74E4DF2A37B3BF00B63E6E /* SubconversationGroupIDRepositoryTests.swift */; }; EE770DAF25344B4F00163C4A /* NotificationDispatcher.OperationMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE770DAE25344B4F00163C4A /* NotificationDispatcher.OperationMode.swift */; }; - EE79699629D4684C00075E38 /* CryptoboxMigrationManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE79699529D4684C00075E38 /* CryptoboxMigrationManager.swift */; }; EE7A90EC2B21CADD00B58E84 /* LegacyOneOnOneResolverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE7A90EB2B21CADD00B58E84 /* LegacyOneOnOneResolverTests.swift */; }; EE7A90EE2B21DE3B00B58E84 /* OneOnOneProtocolSelectorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE7A90ED2B21DE3B00B58E84 /* OneOnOneProtocolSelectorTests.swift */; }; EE7A90F02B21E29E00B58E84 /* OneOnOneMigratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE7A90EF2B21E29E00B58E84 /* OneOnOneMigratorTests.swift */; }; @@ -1263,7 +1262,6 @@ EE74E4DD2A37B28C00B63E6E /* SubconversationGroupIDRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubconversationGroupIDRepository.swift; sourceTree = ""; }; EE74E4DF2A37B3BF00B63E6E /* SubconversationGroupIDRepositoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SubconversationGroupIDRepositoryTests.swift; sourceTree = ""; }; EE770DAE25344B4F00163C4A /* NotificationDispatcher.OperationMode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NotificationDispatcher.OperationMode.swift; sourceTree = ""; }; - EE79699529D4684C00075E38 /* CryptoboxMigrationManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoboxMigrationManager.swift; sourceTree = ""; }; EE7A90EB2B21CADD00B58E84 /* LegacyOneOnOneResolverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyOneOnOneResolverTests.swift; sourceTree = ""; }; EE7A90ED2B21DE3B00B58E84 /* OneOnOneProtocolSelectorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OneOnOneProtocolSelectorTests.swift; sourceTree = ""; }; EE7A90EF2B21E29E00B58E84 /* OneOnOneMigratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OneOnOneMigratorTests.swift; sourceTree = ""; }; @@ -1896,7 +1894,6 @@ 63B1333729A503D000009D84 /* ProteusServiceInterface.swift */, 63B1333829A503D000009D84 /* ProteusService.swift */, EE032B2F29A62CA600E1DDF3 /* ProteusSessionID.swift */, - EE79699529D4684C00075E38 /* CryptoboxMigrationManager.swift */, ); path = Proteus; sourceTree = ""; @@ -3650,7 +3647,6 @@ 013887AC2B9A5C8B00323DD0 /* CoreDataMigrationAction.swift in Sources */, 068DCC5729BB816300F7E4F1 /* ZMOTRMessage+FailedToSendReason.swift in Sources */, F963E9811D9C09E700098AD3 /* ZMMessageTimer.m in Sources */, - EE79699629D4684C00075E38 /* CryptoboxMigrationManager.swift in Sources */, 4058AAA22AA76BFA0013DE71 /* ReactionData.swift in Sources */, 6326E4762AEBB946006EEA28 /* ProteusToMLSMigrationStorage.swift in Sources */, 0129E7FB29A520EB0065E6DB /* SafeFileContext.swift in Sources */, diff --git a/wire-ios-request-strategy/Tests/Helpers/MessagingTestBase.swift b/wire-ios-request-strategy/Tests/Helpers/MessagingTestBase.swift index d9178c01748..83297f344df 100644 --- a/wire-ios-request-strategy/Tests/Helpers/MessagingTestBase.swift +++ b/wire-ios-request-strategy/Tests/Helpers/MessagingTestBase.swift @@ -623,7 +623,6 @@ extension MessagingTestBase { accountDirectory: accountDir, sharedUserDefaults: UserDefaults.standard, syncContext: syncMOC, - cryptoboxMigrationManager: CryptoboxMigrationManager(), coreCryptoKeyMigrationManager: mockKeyMigrationManager, allowCreation: true, localDomain: owningDomain diff --git a/wire-ios-request-strategy/Tests/Helpers/ProteusClientSimulator.swift b/wire-ios-request-strategy/Tests/Helpers/ProteusClientSimulator.swift index 759f094beee..f4f70cdb58e 100644 --- a/wire-ios-request-strategy/Tests/Helpers/ProteusClientSimulator.swift +++ b/wire-ios-request-strategy/Tests/Helpers/ProteusClientSimulator.swift @@ -81,7 +81,6 @@ final class ProteusClientSimulator { accountDirectory: clientDirectory, sharedUserDefaults: UserDefaults.standard, syncContext: syncMOC, - cryptoboxMigrationManager: CryptoboxMigrationManager(), coreCryptoKeyMigrationManager: mockKeyMigrationManager, allowCreation: true, localDomain: owningDomain diff --git a/wire-ios-share-engine/Sources/SharingSession.swift b/wire-ios-share-engine/Sources/SharingSession.swift index 6cab6f429a3..427f0039d11 100644 --- a/wire-ios-share-engine/Sources/SharingSession.swift +++ b/wire-ios-share-engine/Sources/SharingSession.swift @@ -42,7 +42,6 @@ public final class SharingSession { case needsMigration case loggedOut case missingSharedContainer - case pendingCryptoboxMigration } /// The `NSManagedObjectContext` used to retrieve the conversations @@ -259,7 +258,6 @@ public final class SharingSession { operationLoop: RequestGeneratingOperationLoop, strategyFactory: StrategyFactory, appLockConfig: AppLockController.LegacyConfig?, - cryptoboxMigrationManager: CryptoboxMigrationManagerInterface, earService: EARServiceInterface, contextStorage: LAContextStorable, proteusService: ProteusServiceInterface, @@ -290,11 +288,6 @@ public final class SharingSession { guard applicationStatusDirectory.authenticationStatus.state == .authenticated else { throw InitializationError.loggedOut } - let accountDirectory = coreDataStack.accountContainer - guard !cryptoboxMigrationManager.isMigrationNeeded(accountDirectory: accountDirectory) else { - throw InitializationError.pendingCryptoboxMigration - } - coreDataStack.syncContext.performAndWait { if coreDataStack.syncContext.proteusService == nil { coreDataStack.syncContext.proteusService = proteusService @@ -373,7 +366,6 @@ public final class SharingSession { let saveNotificationPersistence = ContextDidSaveNotificationPersistence(accountContainer: accountContainer) let analyticsEventPersistence = ShareExtensionAnalyticsPersistence(accountContainer: accountContainer) - let cryptoboxMigrationManager = CryptoboxMigrationManager() let journal = Journal( userID: accountIdentifier, storage: sharedUserDefaults @@ -384,7 +376,6 @@ public final class SharingSession { accountDirectory: coreDataStack.accountContainer, sharedUserDefaults: sharedUserDefaults, syncContext: coreDataStack.syncContext, - cryptoboxMigrationManager: cryptoboxMigrationManager, coreCryptoKeyMigrationManager: CoreCryptoKeyMigrationManager(journal: journal), allowCreation: false, localDomain: localDomain @@ -497,7 +488,6 @@ public final class SharingSession { operationLoop: operationLoop, strategyFactory: strategyFactory, appLockConfig: appLockConfig, - cryptoboxMigrationManager: cryptoboxMigrationManager, earService: earService, contextStorage: contextStorage, proteusService: proteusService, diff --git a/wire-ios-share-engine/Sources/SharingSessionLoader.swift b/wire-ios-share-engine/Sources/SharingSessionLoader.swift index 703b53149fc..24a75fc232d 100644 --- a/wire-ios-share-engine/Sources/SharingSessionLoader.swift +++ b/wire-ios-share-engine/Sources/SharingSessionLoader.swift @@ -324,10 +324,6 @@ public struct SharingSessionLoader { requestGeneratorStore: requestGeneratorStore, transportSession: transportSession ) - let cryptoboxMigrationManager = CryptoboxMigrationManager() - guard !cryptoboxMigrationManager.isMigrationNeeded(accountDirectory: userAccountDataURL) else { - throw Failure.mainAppRequired(message: "cryptobox migration required") - } let contextStorage = LAContextStorage() let earService = EARService( accountID: accountID, @@ -344,7 +340,6 @@ public struct SharingSessionLoader { accountDirectory: userAccountDataURL, sharedUserDefaults: sharedUserDefaults, syncContext: coreDataStack.syncContext, - cryptoboxMigrationManager: cryptoboxMigrationManager, coreCryptoKeyMigrationManager: CoreCryptoKeyMigrationManager(journal: journal), allowCreation: false, localDomain: backendMetadata.domain @@ -413,7 +408,6 @@ public struct SharingSessionLoader { operationLoop: operationLoop, strategyFactory: strategyFactory, appLockConfig: nil, - cryptoboxMigrationManager: cryptoboxMigrationManager, earService: earService, contextStorage: contextStorage, proteusService: proteusService, diff --git a/wire-ios-share-engine/WireShareEngineTests/BaseSharingSessionTests.swift b/wire-ios-share-engine/WireShareEngineTests/BaseSharingSessionTests.swift index 7c57dc118bb..eeb31b51c42 100644 --- a/wire-ios-share-engine/WireShareEngineTests/BaseSharingSessionTests.swift +++ b/wire-ios-share-engine/WireShareEngineTests/BaseSharingSessionTests.swift @@ -60,7 +60,6 @@ class BaseTest: ZMTBaseTest { var applicationStatusDirectory: ApplicationStatusDirectory! var operationLoop: RequestGeneratingOperationLoop! var strategyFactory: StrategyFactory! - var mockCryptoboxMigrationManager: MockCryptoboxMigrationManagerInterface! var mockEARService: MockEARServiceInterface! var mockProteusService: MockProteusServiceInterface! var mockMLSService: MockMLSServiceInterface! @@ -147,9 +146,6 @@ class BaseTest: ZMTBaseTest { context.saveOrRollback() } - mockCryptoboxMigrationManager = MockCryptoboxMigrationManagerInterface() - mockCryptoboxMigrationManager.isMigrationNeededAccountDirectory_MockValue = false - mockEARService = MockEARServiceInterface() mockEARService.enableEncryptionAtRestContextSkipMigration_MockMethod = { _, _ in } mockEARService.disableEncryptionAtRestContextSkipMigration_MockMethod = { _, _ in } @@ -173,7 +169,6 @@ class BaseTest: ZMTBaseTest { applicationStatusDirectory = nil operationLoop = nil strategyFactory = nil - mockCryptoboxMigrationManager = nil mockEARService = nil mockProteusService = nil mockMLSDecryptionService = nil @@ -198,7 +193,6 @@ class BaseTest: ZMTBaseTest { operationLoop: operationLoop, strategyFactory: strategyFactory, appLockConfig: AppLockController.LegacyConfig(), - cryptoboxMigrationManager: mockCryptoboxMigrationManager, earService: earService, contextStorage: MockLAContextStorable(), proteusService: mockProteusService, diff --git a/wire-ios-share-engine/WireShareEngineTests/SharingSessionTests.swift b/wire-ios-share-engine/WireShareEngineTests/SharingSessionTests.swift index e926d9f96d6..5e149e5ee55 100644 --- a/wire-ios-share-engine/WireShareEngineTests/SharingSessionTests.swift +++ b/wire-ios-share-engine/WireShareEngineTests/SharingSessionTests.swift @@ -69,19 +69,4 @@ final class SharingSessionTests: BaseSharingSessionTests { // MARK: - Init - func test_ItDoesNotInit_WhenCryptoboxMigrationIsPending() async throws { - do { - // Given - mockCryptoboxMigrationManager.isMigrationNeededAccountDirectory_MockValue = true - - // When - _ = try await createSharingSession() - XCTFail("unexpected success") - } catch SharingSession.InitializationError.pendingCryptoboxMigration { - // Then - } catch { - XCTFail("unexpected error: \(error.localizedDescription)") - } - } - } diff --git a/wire-ios-sync-engine/Source/SessionManager/SessionFactories.swift b/wire-ios-sync-engine/Source/SessionManager/SessionFactories.swift index 2acb2710965..1e21c081f33 100644 --- a/wire-ios-sync-engine/Source/SessionManager/SessionFactories.swift +++ b/wire-ios-sync-engine/Source/SessionManager/SessionFactories.swift @@ -105,7 +105,6 @@ open class AuthenticatedSessionFactory { isSyncV2Enabled: journal[.isSyncV2Enabled] ) - let cryptoboxMigrationManager = CryptoboxMigrationManager() let coreCryptoKeyMigrationManager = CoreCryptoKeyMigrationManager(journal: journal) let coreCryptoProvider = CoreCryptoProvider( @@ -114,7 +113,6 @@ open class AuthenticatedSessionFactory { accountDirectory: coreDataStack.accountContainer, sharedUserDefaults: sharedUserDefaults, syncContext: coreDataStack.syncContext, - cryptoboxMigrationManager: cryptoboxMigrationManager, coreCryptoKeyMigrationManager: coreCryptoKeyMigrationManager, localDomain: BackendInfo.domain ) @@ -126,7 +124,6 @@ open class AuthenticatedSessionFactory { currentAppVersion: currentAppVersion, currentBuildNumber: currentBuildNumber, application: application, - cryptoboxMigrationManager: CryptoboxMigrationManager(), coreDataStack: coreDataStack, coreCryptoProvider: coreCryptoProvider, configuration: configuration, diff --git a/wire-ios-sync-engine/Source/SessionManager/UserSessionLoader.swift b/wire-ios-sync-engine/Source/SessionManager/UserSessionLoader.swift index bd3265f9199..15d20c629d0 100644 --- a/wire-ios-sync-engine/Source/SessionManager/UserSessionLoader.swift +++ b/wire-ios-sync-engine/Source/SessionManager/UserSessionLoader.swift @@ -419,7 +419,6 @@ final class UserSessionLoader { isSyncV2Enabled: journal[.isSyncV2Enabled] ) - let cryptoboxMigrationManager = CryptoboxMigrationManager() let coreCryptoKeyMigrationManager = CoreCryptoKeyMigrationManager(journal: journal) let coreCryptoProvider = CoreCryptoProvider( @@ -428,7 +427,6 @@ final class UserSessionLoader { accountDirectory: coreDataStack.accountContainer, sharedUserDefaults: sharedUserDefaults, syncContext: coreDataStack.syncContext, - cryptoboxMigrationManager: cryptoboxMigrationManager, coreCryptoKeyMigrationManager: coreCryptoKeyMigrationManager, localDomain: backendMetadata.domain ) @@ -537,7 +535,6 @@ final class UserSessionLoader { coreDataStack: coreDataStack, earService: earService, mlsService: mlsService, - cryptoboxMigrationManager: cryptoboxMigrationManager, proteusToMLSMigrationCoordinator: proteusToMLSMigrationCoordinator, sharedUserDefaults: sharedUserDefaults, sharedContainerURL: sharedContainerURL, diff --git a/wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSession.swift b/wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSession.swift index c4299b14568..62555eb7838 100644 --- a/wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSession.swift +++ b/wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSession.swift @@ -78,7 +78,6 @@ public final class ZMUserSession: NSObject { var recurringActionService: any RecurringActionServiceInterface - var cryptoboxMigrationManager: CryptoboxMigrationManagerInterface private(set) var coreCryptoProvider: CoreCryptoProviderProtocol private(set) var userId: UUID let proteusService: ProteusServiceInterface @@ -447,7 +446,6 @@ public final class ZMUserSession: NSObject { coreDataStack: CoreDataStack, earService: any EARServiceInterface, mlsService: any MLSServiceInterface, - cryptoboxMigrationManager: any CryptoboxMigrationManagerInterface, proteusToMLSMigrationCoordinator: any ProteusToMLSMigrationCoordinating, sharedUserDefaults: UserDefaults, sharedContainerURL: URL, @@ -488,7 +486,6 @@ public final class ZMUserSession: NSObject { self.earService = earService self.mlsService = mlsService self.proteusService = ProteusService(coreCryptoProvider: coreCryptoProvider) - self.cryptoboxMigrationManager = cryptoboxMigrationManager self.proteusToMLSMigrationCoordinator = proteusToMLSMigrationCoordinator self.contextStorage = contextStorage self.recurringActionService = recurringActionService diff --git a/wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSessionBuilder.swift b/wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSessionBuilder.swift index c510d519f42..0dcdf8d9212 100644 --- a/wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSessionBuilder.swift +++ b/wire-ios-sync-engine/Source/UserSession/ZMUserSession/ZMUserSessionBuilder.swift @@ -39,7 +39,6 @@ struct ZMUserSessionBuilder { private var contextStorage: (any LAContextStorable)? private var coreCryptoProvider: (any CoreCryptoProviderProtocol)? private var coreDataStack: CoreDataStack? - private var cryptoboxMigrationManager: (any CryptoboxMigrationManagerInterface)? private var dependencies: UserSessionDependencies? private var e2eiActivationDateRepository: (any E2EIActivationDateRepositoryProtocol)? private var earService: (any EARServiceInterface)? @@ -75,7 +74,6 @@ struct ZMUserSessionBuilder { let contextStorage, let coreCryptoProvider, let coreDataStack, - let cryptoboxMigrationManager, let e2eiActivationDateRepository, let dependencies, let earService, @@ -172,7 +170,6 @@ struct ZMUserSessionBuilder { coreDataStack: coreDataStack, earService: earService, mlsService: mlsService, - cryptoboxMigrationManager: cryptoboxMigrationManager, proteusToMLSMigrationCoordinator: proteusToMLSMigrationCoordinator, sharedUserDefaults: sharedUserDefaults, sharedContainerURL: sharedContainerURL, @@ -199,7 +196,6 @@ struct ZMUserSessionBuilder { currentAppVersion: String, currentBuildNumber: String, application: any ZMApplication, - cryptoboxMigrationManager: any CryptoboxMigrationManagerInterface, coreDataStack: CoreDataStack, coreCryptoProvider: CoreCryptoProviderProtocol, configuration: ZMUserSession.Configuration, @@ -300,7 +296,6 @@ struct ZMUserSessionBuilder { self.contextStorage = contextStorage self.coreCryptoProvider = coreCryptoProvider self.coreDataStack = coreDataStack - self.cryptoboxMigrationManager = cryptoboxMigrationManager dependencies = buildUserSessionDependencies(coreDataStack: coreDataStack) self.e2eiActivationDateRepository = e2eiActivationDateRepository self.earService = earService diff --git a/wire-ios-sync-engine/Tests/Source/Integration/IntegrationTest.swift b/wire-ios-sync-engine/Tests/Source/Integration/IntegrationTest.swift index f364df0cf4a..cd80289cb12 100644 --- a/wire-ios-sync-engine/Tests/Source/Integration/IntegrationTest.swift +++ b/wire-ios-sync-engine/Tests/Source/Integration/IntegrationTest.swift @@ -71,7 +71,6 @@ final class MockAuthenticatedSessionFactory: AuthenticatedSessionFactory { builder.withAllDependencies( appVersion: appVersion, application: application, - cryptoboxMigrationManager: CryptoboxMigrationManager(), coreDataStack: coreDataStack, configuration: configuration, contextStorage: mockContextStorage, diff --git a/wire-ios-sync-engine/Tests/Source/SessionManager/APIMigrationManagerTests.swift b/wire-ios-sync-engine/Tests/Source/SessionManager/APIMigrationManagerTests.swift index 1b05a21172b..4b88645a583 100644 --- a/wire-ios-sync-engine/Tests/Source/SessionManager/APIMigrationManagerTests.swift +++ b/wire-ios-sync-engine/Tests/Source/SessionManager/APIMigrationManagerTests.swift @@ -251,8 +251,6 @@ final class APIMigrationManagerTests: MessagingTest { mockCoreCryptoProvider.registerMlsTransport_MockMethod = { _ in } mockCoreCryptoProvider.registerEpochObserver_MockMethod = { _ in } - let mockCryptoboxMigrationManager = MockCryptoboxMigrationManagerInterface() - let cookieStorage = ZMPersistentCookieStorage( forServerName: "test.example.com", userIdentifier: .create(), @@ -314,7 +312,6 @@ final class APIMigrationManagerTests: MessagingTest { currentAppVersion: "3.120.0", currentBuildNumber: "999", application: application, - cryptoboxMigrationManager: mockCryptoboxMigrationManager, coreDataStack: coreDataStack, coreCryptoProvider: mockCoreCryptoProvider, configuration: configuration, diff --git a/wire-ios-sync-engine/Tests/Source/SessionManager/Mocks/MockCryptoboxMigrationManagerInterface.swift b/wire-ios-sync-engine/Tests/Source/SessionManager/Mocks/MockCryptoboxMigrationManagerInterface.swift deleted file mode 100644 index 4595dd61c5e..00000000000 --- a/wire-ios-sync-engine/Tests/Source/SessionManager/Mocks/MockCryptoboxMigrationManagerInterface.swift +++ /dev/null @@ -1,71 +0,0 @@ -// -// Wire -// Copyright (C) 2025 Wire Swiss GmbH -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see http://www.gnu.org/licenses/. -// - -import Foundation -import WireDataModel - -public class MockCryptoboxMigrationManagerInterface: CryptoboxMigrationManagerInterface { - - // MARK: - Life cycle - - public init() {} - - // MARK: - isMigrationNeeded - - public var isMigrationNeededAccountDirectory_Invocations: [URL] = [] - public var isMigrationNeededAccountDirectory_MockMethod: ((URL) -> Bool)? - public var isMigrationNeededAccountDirectory_MockValue: Bool? - - public func isMigrationNeeded(accountDirectory: URL) -> Bool { - isMigrationNeededAccountDirectory_Invocations.append(accountDirectory) - - if let mock = isMigrationNeededAccountDirectory_MockMethod { - return mock(accountDirectory) - } else if let mock = isMigrationNeededAccountDirectory_MockValue { - return mock - } else { - fatalError("no mock for `isMigrationNeededAccountDirectory`") - } - } - - // MARK: - performMigration - - public var performMigrationAccountDirectorySyncContext_Invocations: [( - accountDirectory: URL, - coreCrypto: SafeCoreCryptoProtocol - )] = [] - public var performMigrationAccountDirectorySyncContext_MockError: Error? - public var performMigrationAccountDirectorySyncContext_MockMethod: ((URL, SafeCoreCryptoProtocol) throws -> Void)? - - public func performMigration(accountDirectory: URL, coreCrypto: SafeCoreCryptoProtocol) throws { - performMigrationAccountDirectorySyncContext_Invocations.append(( - accountDirectory: accountDirectory, - coreCrypto: coreCrypto - )) - - if let error = performMigrationAccountDirectorySyncContext_MockError { - throw error - } - - guard let mock = performMigrationAccountDirectorySyncContext_MockMethod else { - fatalError("no mock for `performMigrationAccountDirectorySyncContext`") - } - - try mock(accountDirectory, coreCrypto) - } -} diff --git a/wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTestsBase.swift b/wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTestsBase.swift index 20054bcac4d..0a93b1426b0 100644 --- a/wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTestsBase.swift +++ b/wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTestsBase.swift @@ -163,9 +163,6 @@ class ZMUserSessionTestsBase: MessagingTest { mockCoreCryptoProvider = MockCoreCryptoProviderProtocol() mockCoreCryptoProvider.coreCrypto_MockValue = mockSafeCoreCrypto - let mockCryptoboxMigrationManager = MockCryptoboxMigrationManagerInterface() - mockCryptoboxMigrationManager.isMigrationNeededAccountDirectory_MockValue = false - let mockContextStorable = MockLAContextStorable() mockContextStorable.clear_MockMethod = {} @@ -184,7 +181,6 @@ class ZMUserSessionTestsBase: MessagingTest { currentAppVersion: "3.120.0", currentBuildNumber: "00000", application: application, - cryptoboxMigrationManager: mockCryptoboxMigrationManager, coreDataStack: coreDataStack, coreCryptoProvider: mockCoreCryptoProvider, configuration: configuration, diff --git a/wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTests_NetworkState.swift b/wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTests_NetworkState.swift index 1a9453f94b2..91a9d271de8 100644 --- a/wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTests_NetworkState.swift +++ b/wire-ios-sync-engine/Tests/Source/UserSession/ZMUserSessionTests_NetworkState.swift @@ -46,7 +46,6 @@ final class ZMUserSessionTests_NetworkState: ZMUserSessionTestsBase { coreCryptoProvider.coreCrypto_MockValue = mockSafeCoreCrypto coreCryptoProvider.registerMlsTransport_MockMethod = { _ in } coreCryptoProvider.registerEpochObserver_MockMethod = { _ in } - let mockCryptoboxMigrationManager = MockCryptoboxMigrationManagerInterface() let coreDataStack = try await createCoreDataStack() let selfClient = coreDataStack.syncContext.performAndWait { self.setupSelfClient(inMoc: coreDataStack.syncContext) @@ -70,7 +69,6 @@ final class ZMUserSessionTests_NetworkState: ZMUserSessionTestsBase { currentAppVersion: "3.120.0", currentBuildNumber: "00000", application: application, - cryptoboxMigrationManager: mockCryptoboxMigrationManager, coreDataStack: coreDataStack, coreCryptoProvider: coreCryptoProvider, configuration: configuration, diff --git a/wire-ios-sync-engine/WireSyncEngine.xcodeproj/project.pbxproj b/wire-ios-sync-engine/WireSyncEngine.xcodeproj/project.pbxproj index efcb43d9df9..9635f78fc18 100644 --- a/wire-ios-sync-engine/WireSyncEngine.xcodeproj/project.pbxproj +++ b/wire-ios-sync-engine/WireSyncEngine.xcodeproj/project.pbxproj @@ -146,7 +146,6 @@ 16D0A11D234C8CD700A83F87 /* LabelUpstreamRequestStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16D0A11C234C8CD700A83F87 /* LabelUpstreamRequestStrategy.swift */; }; 16D3FCDF1E365ABC0052A535 /* CallStateObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16D3FCDE1E365ABC0052A535 /* CallStateObserverTests.swift */; }; 16D3FD021E3A5C0D0052A535 /* ZMConversationVoiceChannelRouterTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16D3FD011E3A5C0D0052A535 /* ZMConversationVoiceChannelRouterTests.swift */; }; - 16D66D6A2B0789F500CB237D /* MockCryptoboxMigrationManagerInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE0BA28F29D5DBD6004E93B5 /* MockCryptoboxMigrationManagerInterface.swift */; }; 16D9E8BA22BCD39200FA463F /* LegalHoldRequestStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16D9E8B922BCD39200FA463F /* LegalHoldRequestStrategy.swift */; }; 16DABFAE1DCF98D3001973E3 /* CallingRequestStrategy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16DABFAD1DCF98D3001973E3 /* CallingRequestStrategy.swift */; }; 16DCB91C213449620002E910 /* ZMOperationLoop+PushChannel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16DCB91B213449620002E910 /* ZMOperationLoop+PushChannel.swift */; }; @@ -1036,7 +1035,6 @@ EBD7B55754FDA4E74F1006FD /* ZMOperationLoopTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZMOperationLoopTests.h; sourceTree = ""; }; EE01E0361F90DABC001AA33C /* audio.m4a */ = {isa = PBXFileReference; lastKnownFileType = file; path = audio.m4a; sourceTree = ""; }; EE01E0381F90FEC1001AA33C /* ZMLocalNotificationTests_ExpiredMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZMLocalNotificationTests_ExpiredMessage.swift; sourceTree = ""; }; - EE0BA28F29D5DBD6004E93B5 /* MockCryptoboxMigrationManagerInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockCryptoboxMigrationManagerInterface.swift; sourceTree = ""; }; EE0CAEAE2AAF2E8E00BD2DB7 /* URLSession+MinTLSVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSession+MinTLSVersion.swift"; sourceTree = ""; }; EE1108F823D1F945005DC663 /* TypingUsersTimeout.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TypingUsersTimeout.swift; sourceTree = ""; }; EE1108FA23D2087F005DC663 /* Typing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Typing.swift; sourceTree = ""; }; @@ -2214,14 +2212,6 @@ path = Dependencies; sourceTree = ""; }; - E6A55E2B2B762ED80020818D /* Mocks */ = { - isa = PBXGroup; - children = ( - EE0BA28F29D5DBD6004E93B5 /* MockCryptoboxMigrationManagerInterface.swift */, - ); - path = Mocks; - sourceTree = ""; - }; E6C983EF2B986B2900D55177 /* ZMUserSession */ = { isa = PBXGroup; children = ( @@ -2293,7 +2283,6 @@ F159F4121F1E310C001B7D80 /* SessionManager */ = { isa = PBXGroup; children = ( - E6A55E2B2B762ED80020818D /* Mocks */, 63CD59542964332B00385037 /* AccessTokenMigrationTests.swift */, 636826FB2954550900D904C2 /* APIMigrationManagerTests.swift */, EE9CDE9127DA05D100C4DAC8 /* APIVersionResolverTests.swift */, @@ -2758,7 +2747,6 @@ 7635D6932D031F0600E13F57 /* MockAPIService.swift in Sources */, 54A170691B300717001B41A5 /* ProxiedRequestStrategyTests.swift in Sources */, 1660AA111ECE3C1C0056D403 /* SearchTaskTests.swift in Sources */, - 16D66D6A2B0789F500CB237D /* MockCryptoboxMigrationManagerInterface.swift in Sources */, 873B893E20445F4400FBE254 /* ZMConversationAccessModeTests.swift in Sources */, 543ED0011D79E0EE00A9CDF3 /* ApplicationMock.swift in Sources */, 160C314A1E82AC170012E4BC /* OperationStatusTests.swift in Sources */,