diff --git a/Nextcloud.xcodeproj/project.pbxproj b/Nextcloud.xcodeproj/project.pbxproj index f4d11f634f..acbdb82576 100644 --- a/Nextcloud.xcodeproj/project.pbxproj +++ b/Nextcloud.xcodeproj/project.pbxproj @@ -5767,7 +5767,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEBUG_INFORMATION_FORMAT = dwarf; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -5833,7 +5833,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 2; + CURRENT_PROJECT_VERSION = 3; DEVELOPMENT_TEAM = NKUJUXUJ3B; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -6114,7 +6114,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/nextcloud/NextcloudKit"; requirement = { - branch = main; + branch = 7.2.7; kind = branch; }; }; diff --git a/iOSClient/GUI/Lucid Banner/AlertActionBannerView.swift b/iOSClient/GUI/Lucid Banner/AlertActionBannerView.swift index 31120dc8e3..7618a6d13c 100644 --- a/iOSClient/GUI/Lucid Banner/AlertActionBannerView.swift +++ b/iOSClient/GUI/Lucid Banner/AlertActionBannerView.swift @@ -7,17 +7,18 @@ import LucidBanner @MainActor func showAlertActionBanner(lucidBanner: LucidBanner?, + windowScene: UIWindowScene?, title: String? = nil, subtitle: String? = nil, onConfirm: (() -> Void)? = nil) { - guard let lucidBanner else { + guard let lucidBanner, + let windowScene, + let window = windowScene.windows.first(where: \.isKeyWindow) else { return } - let isPad = lucidBanner.windowScene.traitCollection.userInterfaceIdiom == .pad - let horizontalLayout: LucidBanner.HorizontalLayout = - isPad - ? .centered(width: 450) - : .stretch(margins: 20) + let horizontalLayout = horizontalLayoutBanner(bounds: window.bounds, + safeAreaInsets: window.safeAreaInsets, + idiom: window.traitCollection.userInterfaceIdiom) let payload = LucidBannerPayload( title: title, diff --git a/iOSClient/GUI/Lucid Banner/ErrorBannerView.swift b/iOSClient/GUI/Lucid Banner/ErrorBannerView.swift index 1934371411..95837f8fd8 100644 --- a/iOSClient/GUI/Lucid Banner/ErrorBannerView.swift +++ b/iOSClient/GUI/Lucid Banner/ErrorBannerView.swift @@ -23,7 +23,8 @@ func showErrorBanner(windowScene: UIWindowScene?, footnote: String? = nil, errorCode: Int? = nil, afError: AFError? = nil) async { - guard let windowScene, let window = windowScene.windows.first else { + guard let windowScene, + let window = windowScene.windows.first(where: \.isKeyWindow) else { return } diff --git a/iOSClient/GUI/Lucid Banner/HudBannerView.swift b/iOSClient/GUI/Lucid Banner/HudBannerView.swift index 40ab5a83d2..08f13b6c4b 100644 --- a/iOSClient/GUI/Lucid Banner/HudBannerView.swift +++ b/iOSClient/GUI/Lucid Banner/HudBannerView.swift @@ -11,18 +11,23 @@ func showHudBanner(windowScene: UIWindowScene?, subtitle: String? = nil, stage: LucidBanner.Stage? = nil, onButtonTap: (() -> Void)? = nil) -> (banner: LucidBanner?, token: Int?) { - guard let windowScene else { + guard let windowScene, + let window = windowScene.windows.first(where: \.isKeyWindow) else { return (nil, nil) } let localizedTitle = title.map { NSLocalizedString($0, comment: "") } let localizedSubTitle = subtitle.map { NSLocalizedString($0, comment: "") } let banner = LucidBannerRegistry.shared.banner(for: windowScene) + let horizontalLayout = horizontalLayoutBanner(bounds: window.bounds, + safeAreaInsets: window.safeAreaInsets, + idiom: window.traitCollection.userInterfaceIdiom) let payload = LucidBannerPayload( title: localizedTitle, subtitle: localizedSubTitle, stage: stage, vPosition: .center, + horizontalLayout: horizontalLayout, blocksTouches: true, ) diff --git a/iOSClient/GUI/Lucid Banner/HudIndeterminateBannerView.swift b/iOSClient/GUI/Lucid Banner/HudIndeterminateBannerView.swift index 8d12494170..8dc6fb1c43 100644 --- a/iOSClient/GUI/Lucid Banner/HudIndeterminateBannerView.swift +++ b/iOSClient/GUI/Lucid Banner/HudIndeterminateBannerView.swift @@ -11,18 +11,23 @@ func showHudIndeterminateBanner(windowScene: UIWindowScene?, subtitle: String? = nil, stage: LucidBanner.Stage? = nil, onButtonTap: (() -> Void)? = nil) -> (banner: LucidBanner?, token: Int?) { - guard let windowScene else { + guard let windowScene, + let window = windowScene.windows.first(where: \.isKeyWindow) else { return (nil, nil) } let localizedTitle = title.map { NSLocalizedString($0, comment: "") } let localizedSubTitle = subtitle.map { NSLocalizedString($0, comment: "") } let banner = LucidBannerRegistry.shared.banner(for: windowScene) + let horizontalLayout = horizontalLayoutBanner(bounds: window.bounds, + safeAreaInsets: window.safeAreaInsets, + idiom: window.traitCollection.userInterfaceIdiom) let payload = LucidBannerPayload( title: localizedTitle, subtitle: localizedSubTitle, stage: stage, vPosition: .center, + horizontalLayout: horizontalLayout, blocksTouches: true, ) diff --git a/iOSClient/GUI/Lucid Banner/InfoBannerView.swift b/iOSClient/GUI/Lucid Banner/InfoBannerView.swift index bba3e11f3a..86bc7144dc 100644 --- a/iOSClient/GUI/Lucid Banner/InfoBannerView.swift +++ b/iOSClient/GUI/Lucid Banner/InfoBannerView.swift @@ -13,7 +13,8 @@ func showInfoBanner(windowScene: UIWindowScene?, text: String, footnote: String? = nil, errorCode: Int? = nil) async { - guard let windowScene, let window = windowScene.windows.first else { + guard let windowScene, + let window = windowScene.windows.first(where: \.isKeyWindow) else { return } diff --git a/iOSClient/GUI/Lucid Banner/ShowBanner.swift b/iOSClient/GUI/Lucid Banner/ShowBanner.swift index 6c5cdc3bac..ce3d972e4e 100644 --- a/iOSClient/GUI/Lucid Banner/ShowBanner.swift +++ b/iOSClient/GUI/Lucid Banner/ShowBanner.swift @@ -26,7 +26,8 @@ func showBanner(windowScene: UIWindowScene?, swipeToDismiss: Bool = true, policy: LucidBanner.ShowPolicy = .replace, errorCode: Int? = nil) async -> (banner: LucidBanner?, token: Int?) { - guard let windowScene, let window = windowScene.windows.first else { + guard let windowScene, + let window = windowScene.windows.first(where: \.isKeyWindow) else { return(nil, nil) } diff --git a/iOSClient/GUI/Lucid Banner/UploadBannerView.swift b/iOSClient/GUI/Lucid Banner/UploadBannerView.swift index 5420664ce7..ac95cb749e 100644 --- a/iOSClient/GUI/Lucid Banner/UploadBannerView.swift +++ b/iOSClient/GUI/Lucid Banner/UploadBannerView.swift @@ -10,7 +10,8 @@ func showUploadBanner(windowScene: UIWindowScene?, payload: LucidBannerPayload, allowMinimizeOnTap: Bool, onButtonTap: (() -> Void)? = nil) -> (banner: LucidBanner?, token: Int?) { - guard let windowScene, let window = windowScene.windows.first else { + guard let windowScene, + let window = windowScene.windows.first(where: \.isKeyWindow) else { return (nil, nil) } let horizontalLayout = horizontalLayoutBanner(bounds: window.bounds, diff --git a/iOSClient/GUI/Lucid Banner/WarningBannerView.swift b/iOSClient/GUI/Lucid Banner/WarningBannerView.swift index adfc69b3a5..fbeced0226 100644 --- a/iOSClient/GUI/Lucid Banner/WarningBannerView.swift +++ b/iOSClient/GUI/Lucid Banner/WarningBannerView.swift @@ -15,7 +15,8 @@ func showWarningBanner(windowScene: UIWindowScene?, systemImage: String, imageAnimation: LucidBanner.LucidBannerAnimationStyle, errorCode: Int? = nil) async { - guard let windowScene, let window = windowScene.windows.first else { + guard let windowScene, + let window = windowScene.windows.first(where: \.isKeyWindow) else { return } diff --git a/iOSClient/Login/NCLogin.swift b/iOSClient/Login/NCLogin.swift index 00e22f3555..82f883069e 100644 --- a/iOSClient/Login/NCLogin.swift +++ b/iOSClient/Login/NCLogin.swift @@ -198,6 +198,7 @@ class NCLogin: UIViewController, UITextFieldDelegate, NCLoginQRCodeDelegate { self.banner = LucidBannerRegistry.shared.banner(for: windowScene) showAlertActionBanner(lucidBanner: banner, + windowScene: windowScene, title: title, subtitle: subtitle) { self.openShareAccountsViewController(nil) diff --git a/iOSClient/Networking/E2EE/NCEndToEndMetadata.swift b/iOSClient/Networking/E2EE/NCEndToEndMetadata.swift index 72ad17a38e..4ae73a5121 100644 --- a/iOSClient/Networking/E2EE/NCEndToEndMetadata.swift +++ b/iOSClient/Networking/E2EE/NCEndToEndMetadata.swift @@ -45,8 +45,8 @@ class NCEndToEndMetadata: NSObject { return await decodeMetadataV1(metadata, serverUrl: serverUrl, ocIdServerUrl: directory.ocId, session: session) } else if (try? JSONDecoder().decode(E2eeV12.self, from: data)) != nil { return await decodeMetadataV12(metadata, serverUrl: serverUrl, ocIdServerUrl: directory.ocId, session: session) - } else if (try? JSONDecoder().decode(E2eeV20.self, from: data)) != nil { - return await decodeMetadataV20(metadata, signature: signature, serverUrl: serverUrl, ocIdServerUrl: directory.ocId, session: session) + } else if (try? JSONDecoder().decode(E2eeV2.self, from: data)) != nil { + return await decodeMetadataV2(metadata, signature: signature, serverUrl: serverUrl, ocIdServerUrl: directory.ocId, session: session) } else { return NKError(errorCode: NCGlobal.shared.errorE2EEVersion, errorDescription: "Unable to decode the metadata file") } diff --git a/iOSClient/Networking/E2EE/NCEndToEndMetadataV2.swift b/iOSClient/Networking/E2EE/NCEndToEndMetadataV2.swift index 79d7471fb8..9b6d02f35e 100644 --- a/iOSClient/Networking/E2EE/NCEndToEndMetadataV2.swift +++ b/iOSClient/Networking/E2EE/NCEndToEndMetadataV2.swift @@ -8,7 +8,7 @@ import NextcloudKit import Gzip extension NCEndToEndMetadata { - struct E2eeV20: Codable { + struct E2eeV2: Codable { struct Metadata: Codable { let ciphertext: String @@ -56,7 +56,7 @@ extension NCEndToEndMetadata { let version: String } - struct E2eeV20Signature: Codable { + struct E2eeV2Signature: Codable { struct Metadata: Codable { let ciphertext: String @@ -95,8 +95,8 @@ extension NCEndToEndMetadata { var metadataKey: String? var keyChecksums: [String] = [] - var usersCodable: [E2eeV20.Users] = [] - var filesCodable: [String: E2eeV20.Metadata.ciphertext.Files] = [:] + var usersCodable: [E2eeV2.Users] = [] + var filesCodable: [String: E2eeV2.Metadata.ciphertext.Files] = [:] var folders: [String: String] = [:] var counter: Int = 1 @@ -151,7 +151,7 @@ extension NCEndToEndMetadata { let users = await self.database.getE2EUsersAsync(account: session.account, directoryTopOcId: directoryTopOcId) for user in users { if isDirectoryTop { - usersCodable.append(E2eeV20.Users(userId: user.userId, certificate: user.certificate, encryptedMetadataKey: user.encryptedMetadataKey)) + usersCodable.append(E2eeV2.Users(userId: user.userId, certificate: user.certificate, encryptedMetadataKey: user.encryptedMetadataKey)) } if let hash = NCEndToEndEncryption.shared().createSHA256(user.metadataKey) { keyChecksums.append(hash) @@ -172,7 +172,7 @@ extension NCEndToEndMetadata { if e2eEncryption.mimeType == "httpd/unix-directory" { folders[e2eEncryption.fileNameIdentifier] = e2eEncryption.fileName } else { - let file = E2eeV20.Metadata.ciphertext.Files(authenticationTag: e2eEncryption.authenticationTag, filename: e2eEncryption.fileName, key: e2eEncryption.key, mimetype: e2eEncryption.mimeType, nonce: e2eEncryption.initializationVector) + let file = E2eeV2.Metadata.ciphertext.Files(authenticationTag: e2eEncryption.authenticationTag, filename: e2eEncryption.fileName, key: e2eEncryption.key, mimetype: e2eEncryption.mimeType, nonce: e2eEncryption.initializationVector) filesCodable.updateValue(file, forKey: e2eEncryption.fileNameIdentifier) } } @@ -180,7 +180,7 @@ extension NCEndToEndMetadata { do { var authenticationTag: NSString? var initializationVector: NSString? - let json = try JSONEncoder().encode(E2eeV20.Metadata.ciphertext(counter: counter, deleted: false, keyChecksums: keyChecksums, files: filesCodable, folders: folders)) + let json = try JSONEncoder().encode(E2eeV2.Metadata.ciphertext(counter: counter, deleted: false, keyChecksums: keyChecksums, files: filesCodable, folders: folders)) let jsonZip = try json.gzipped() let ciphertextMetadata = NCEndToEndEncryption.shared().encryptPayloadFile(jsonZip, key: metadataKey, initializationVector: &initializationVector, authenticationTag: &authenticationTag) guard var ciphertextMetadata, let initializationVector = initializationVector as? String, let authenticationTag = authenticationTag as? String else { @@ -191,8 +191,8 @@ extension NCEndToEndMetadata { // Add initializationVector [ANDROID] ciphertextMetadata = ciphertextMetadata + "|" + initializationVector - let metadataCodable = E2eeV20.Metadata(ciphertext: ciphertextMetadata, nonce: initializationVector, authenticationTag: authenticationTag) - let e2eeCodable = E2eeV20(metadata: metadataCodable, users: usersCodable, filedrop: nil, version: capabilities.e2EEApiVersion) + let metadataCodable = E2eeV2.Metadata(ciphertext: ciphertextMetadata, nonce: initializationVector, authenticationTag: authenticationTag) + let e2eeCodable = E2eeV2(metadata: metadataCodable, users: usersCodable, filedrop: nil, version: capabilities.e2EEApiVersion) let e2eeData = try JSONEncoder().encode(e2eeCodable) e2eeData.printJson() @@ -210,7 +210,7 @@ extension NCEndToEndMetadata { // MARK: Decode JSON Metadata V2 // -------------------------------------------------------------------------------------------- - func decodeMetadataV20(_ json: String, signature: String?, serverUrl: String, ocIdServerUrl: String, session: NCSession.Session) async -> NKError { + func decodeMetadataV2(_ json: String, signature: String?, serverUrl: String, ocIdServerUrl: String, session: NCSession.Session) async -> NKError { let global = NCGlobal.shared guard let data = json.data(using: .utf8), let directoryTop = await utilityFileSystem.getMetadataE2EETopAsync(serverUrl: serverUrl, session: session) else { @@ -252,7 +252,7 @@ extension NCEndToEndMetadata { } do { - let json = try JSONDecoder().decode(E2eeV20.self, from: data) + let json = try JSONDecoder().decode(E2eeV2.self, from: data) let metadata = json.metadata let users = json.users let filesdrop = json.filedrop @@ -326,7 +326,7 @@ extension NCEndToEndMetadata { } let data = try decryptedFiledrop.gunzipped() if let jsonText = String(data: data, encoding: .utf8) { print(jsonText) } - let file = try JSONDecoder().decode(E2eeV20.Metadata.ciphertext.Files.self, from: data) + let file = try JSONDecoder().decode(E2eeV2.Metadata.ciphertext.Files.self, from: data) print(file) await addE2eEncryption(fileNameIdentifier: fileNameIdentifier, fileName: file.filename, authenticationTag: file.authenticationTag, key: file.key, initializationVector: file.nonce, metadataKey: filedropKey, mimetype: file.mimetype) } @@ -344,7 +344,7 @@ extension NCEndToEndMetadata { let data = try decryptedMetadata.gunzipped() // DEBUG // if let jsonText = String(data: data, encoding: .utf8) { print(jsonText) } - let jsonCiphertextMetadata = try JSONDecoder().decode(E2eeV20.Metadata.ciphertext.self, from: data) + let jsonCiphertextMetadata = try JSONDecoder().decode(E2eeV2.Metadata.ciphertext.self, from: data) // CHECKSUM CHECK // @@ -424,15 +424,15 @@ extension NCEndToEndMetadata { // MARK: - - func createSignature(metadata: E2eeV20.Metadata, users: [E2eeV20.Users]?, version: String, certificate: String, session: NCSession.Session) -> String? { + func createSignature(metadata: E2eeV2.Metadata, users: [E2eeV2.Users]?, version: String, certificate: String, session: NCSession.Session) -> String? { guard let users else { return nil } - var usersSignatureCodable: [E2eeV20Signature.Users] = [] + var usersSignatureCodable: [E2eeV2Signature.Users] = [] for user in users { - usersSignatureCodable.append(E2eeV20Signature.Users(userId: user.userId, certificate: user.certificate, encryptedMetadataKey: user.encryptedMetadataKey)) + usersSignatureCodable.append(E2eeV2Signature.Users(userId: user.userId, certificate: user.certificate, encryptedMetadataKey: user.encryptedMetadataKey)) } - let signatureCodable = E2eeV20Signature(metadata: E2eeV20Signature.Metadata(ciphertext: metadata.ciphertext, nonce: metadata.nonce, authenticationTag: metadata.authenticationTag), users: usersSignatureCodable, version: version) + let signatureCodable = E2eeV2Signature(metadata: E2eeV2Signature.Metadata(ciphertext: metadata.ciphertext, nonce: metadata.nonce, authenticationTag: metadata.authenticationTag), users: usersSignatureCodable, version: version) do { let jsonEncoder = JSONEncoder() @@ -451,19 +451,19 @@ extension NCEndToEndMetadata { return nil } - func verifySignature(account: String, signature: String, userId: String, metadata: E2eeV20.Metadata, users: [E2eeV20.Users]?, version: String, certificate: String) -> Bool { - var signatureCodable: E2eeV20Signature? + func verifySignature(account: String, signature: String, userId: String, metadata: E2eeV2.Metadata, users: [E2eeV2.Users]?, version: String, certificate: String) -> Bool { + var signatureCodable: E2eeV2Signature? var certificates: [String] = [] if let users { - var usersSignatureCodable: [E2eeV20Signature.Users] = [] + var usersSignatureCodable: [E2eeV2Signature.Users] = [] for user in users { - usersSignatureCodable.append(E2eeV20Signature.Users(userId: user.userId, certificate: user.certificate, encryptedMetadataKey: user.encryptedMetadataKey)) + usersSignatureCodable.append(E2eeV2Signature.Users(userId: user.userId, certificate: user.certificate, encryptedMetadataKey: user.encryptedMetadataKey)) } - signatureCodable = E2eeV20Signature(metadata: E2eeV20Signature.Metadata(ciphertext: metadata.ciphertext, nonce: metadata.nonce, authenticationTag: metadata.authenticationTag), users: usersSignatureCodable, version: version) + signatureCodable = E2eeV2Signature(metadata: E2eeV2Signature.Metadata(ciphertext: metadata.ciphertext, nonce: metadata.nonce, authenticationTag: metadata.authenticationTag), users: usersSignatureCodable, version: version) certificates = users.map { $0.certificate } } else { - signatureCodable = E2eeV20Signature(metadata: E2eeV20Signature.Metadata(ciphertext: metadata.ciphertext, nonce: metadata.nonce, authenticationTag: metadata.authenticationTag), users: nil, version: version) + signatureCodable = E2eeV2Signature(metadata: E2eeV2Signature.Metadata(ciphertext: metadata.ciphertext, nonce: metadata.nonce, authenticationTag: metadata.authenticationTag), users: nil, version: version) certificates = [certificate] } diff --git a/iOSClient/Networking/NCConfigServer.swift b/iOSClient/Networking/NCConfigServer.swift index 2e15bf68e9..f82b466647 100644 --- a/iOSClient/Networking/NCConfigServer.swift +++ b/iOSClient/Networking/NCConfigServer.swift @@ -41,7 +41,7 @@ final class NCConfigServer: NSObject, UIActionSheetDelegate, URLSessionDelegate dataTask.resume() } - func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { + func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping @Sendable (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { NCNetworking.shared.checkTrustedChallenge(session, didReceive: challenge, completionHandler: completionHandler) }