From 288f6b29dd7da0706a7ba761ae6e225f66d28a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Coye=20de=20Brune=CC=81lis?= Date: Mon, 4 Sep 2023 14:53:20 +0200 Subject: [PATCH] chore: bump ios-Core --- .package.resolved | 2 +- .../API/MailApiFetcher/MailApiFetcher.swift | 63 ------------------- Project.swift | 2 +- 3 files changed, 2 insertions(+), 65 deletions(-) diff --git a/.package.resolved b/.package.resolved index 9d7c11d62..e775f9bd1 100644 --- a/.package.resolved +++ b/.package.resolved @@ -41,7 +41,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Infomaniak/ios-core", "state" : { - "revision" : "36296ffafcb03b382d2bc9eb060cba0b27a69e40" + "revision" : "73a982d892ce19966f7393f2093a1f0cc7731838" } }, { diff --git a/MailCore/API/MailApiFetcher/MailApiFetcher.swift b/MailCore/API/MailApiFetcher/MailApiFetcher.swift index ba2209057..a285f7507 100644 --- a/MailCore/API/MailApiFetcher/MailApiFetcher.swift +++ b/MailCore/API/MailApiFetcher/MailApiFetcher.swift @@ -21,72 +21,9 @@ import Foundation import InfomaniakCore import InfomaniakDI import InfomaniakLogin -import MachO import Sentry import UIKit -// TODO: move to Core and share with kDrive -/// Something to construct a standard Infomaniak User-Agent -public struct UserAgentBuilder { - func modelIdentifier() -> String? { - if let simulatorModelIdentifier = ProcessInfo() - .environment["SIMULATOR_MODEL_IDENTIFIER"] { return simulatorModelIdentifier } - var sysinfo = utsname() - uname(&sysinfo) // ignore return value - return String(bytes: Data(bytes: &sysinfo.machine, - count: Int(_SYS_NAMELEN)), encoding: .ascii)? - .trimmingCharacters(in: .controlCharacters) - } - - func microarchitecture() -> String? { - guard let archRaw = NXGetLocalArchInfo().pointee.name else { - return nil - } - return String(cString: archRaw) - } - - /// The standard infomaniak app user agent - public var userAgent: String { - let release = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "x.x.x" - let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "x" - - let executableName = Bundle.main.bundleIdentifier ?? "com.infomaniak.x" - let appVersion = "\(release)-\(build)" - let hardwareDevice = modelIdentifier() ?? "unknownModel" - - let operatingSystemVersion = ProcessInfo.processInfo.operatingSystemVersion - let OSNameAndVersion = - "\(UIDevice.current.systemName) \(operatingSystemVersion.majorVersion).\(operatingSystemVersion.minorVersion).\(operatingSystemVersion.patchVersion)" - - let cpuArchitecture = microarchitecture() ?? "unknownArch" - - /// Something like: - /// `com.infomaniak.mail/1.0.5-1 (iPhone15,2; iOS16.4.0; arm64e)` - /// `com.infomaniak.mail.ShareExtension/1.0.5-1 (iPhone15,2; iOS16.4.0; arm64e)` - let userAgent = "\(executableName)/\(appVersion) (\(hardwareDevice); \(OSNameAndVersion); \(cpuArchitecture))" - return userAgent - } -} - -/// Something to set the user agent for AF requests -public class UserAgentAdapter: RequestAdapter { - public static let userAgentKey = "User-Agent" - - public init() {} - - public func adapt( - _ urlRequest: URLRequest, - for session: Alamofire.Session, - completion: @escaping (Result) -> Void - ) { - var adaptedRequest = urlRequest - adaptedRequest.headers.remove(name: Self.userAgentKey) - adaptedRequest.headers.add(name: Self.userAgentKey, value: UserAgentBuilder().userAgent) - - completion(.success(adaptedRequest)) - } -} - public extension ApiFetcher { convenience init(token: ApiToken, delegate: RefreshTokenDelegate) { self.init() diff --git a/Project.swift b/Project.swift index e39dd50a1..a0b3bc33d 100644 --- a/Project.swift +++ b/Project.swift @@ -26,7 +26,7 @@ let project = Project(name: "Mail", .package(url: "https://github.com/Infomaniak/ios-dependency-injection", .upToNextMajor(from: "1.1.6")), .package( url: "https://github.com/Infomaniak/ios-core", - .revision("36296ffafcb03b382d2bc9eb060cba0b27a69e40") + .revision("73a982d892ce19966f7393f2093a1f0cc7731838") ), .package(url: "https://github.com/Infomaniak/ios-core-ui", .upToNextMajor(from: "2.5.3")), .package(url: "https://github.com/Infomaniak/ios-notifications", .upToNextMajor(from: "3.0.0")),