Skip to content

Commit

Permalink
Merge branch 'release/1.11.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobihagemann committed Sep 12, 2024
2 parents 9a7743f + 6106af1 commit ff48ad0
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 17 deletions.
6 changes: 5 additions & 1 deletion CryptomatorCloudAccess.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
748BD4CC24B4D3820001CA8C /* Date+RFC822.swift in Sources */ = {isa = PBXBuildFile; fileRef = 748BD4CB24B4D3820001CA8C /* Date+RFC822.swift */; };
7494505F24BC5C3300149816 /* PropfindResponseParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7494505E24BC5C3300149816 /* PropfindResponseParserTests.swift */; };
7494B06D249CEAC500430610 /* VaultFormat7ShorteningProviderDecoratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7494B06C249CEAC500430610 /* VaultFormat7ShorteningProviderDecoratorTests.swift */; };
749D91152C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749D91142C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift */; };
749F59A52BD1211500AB299A /* PCloudSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749F59A42BD1211500AB299A /* PCloudSetup.swift */; };
74B321E42923F979008E7C01 /* HTTPDebugLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B321E32923F979008E7C01 /* HTTPDebugLogger.swift */; };
74C0FB2729B209B6008EF811 /* S3Authenticator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C0FB2629B209B6008EF811 /* S3Authenticator.swift */; };
Expand Down Expand Up @@ -357,6 +358,7 @@
748BD4CB24B4D3820001CA8C /* Date+RFC822.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+RFC822.swift"; sourceTree = "<group>"; };
7494505E24BC5C3300149816 /* PropfindResponseParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PropfindResponseParserTests.swift; sourceTree = "<group>"; };
7494B06C249CEAC500430610 /* VaultFormat7ShorteningProviderDecoratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VaultFormat7ShorteningProviderDecoratorTests.swift; sourceTree = "<group>"; };
749D91142C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MSClientFactory+UnauthenticatedClient.swift"; sourceTree = "<group>"; };
749F59A42BD1211500AB299A /* PCloudSetup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PCloudSetup.swift; sourceTree = "<group>"; };
74B321E32923F979008E7C01 /* HTTPDebugLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPDebugLogger.swift; sourceTree = "<group>"; };
74C0FB2629B209B6008EF811 /* S3Authenticator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = S3Authenticator.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -530,6 +532,7 @@
4A1A11692629A53300DAF62F /* OneDrive */ = {
isa = PBXGroup;
children = (
749D91142C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift */,
4AD55338263ABA4200126046 /* MSGraphDriveItem+CloudItemType.swift */,
4A3896CD2632D65B00BA3E88 /* OneDriveAuthenticationProvider.swift */,
4A1A11782629ACD500DAF62F /* OneDriveAuthenticator.swift */,
Expand Down Expand Up @@ -1332,6 +1335,7 @@
9ECEC0AF246ED1FB00151299 /* DirectoryIdCache.swift in Sources */,
4A77390D286DB5A00006B3C3 /* AWSS3TransferUtility+ForegroundSession.swift in Sources */,
745949E225F22F4D00B7B28C /* VaultFormat8ProviderDecorator.swift in Sources */,
749D91152C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift in Sources */,
745949E625F2326D00B7B28C /* VaultFormat8ShorteningProviderDecorator.swift in Sources */,
4A628EB8252F610C0097DE94 /* URLSession+Promises.swift in Sources */,
4A567B692615D64E002C4D82 /* GoogleDriveSetup.swift in Sources */,
Expand Down Expand Up @@ -1889,7 +1893,7 @@
repositoryURL = "https://github.com/box/box-swift-sdk-gen.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.3.0;
minimumVersion = 0.5.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/box/box-swift-sdk-gen.git",
"state" : {
"revision" : "7b2e3963a4f9d7c608ba9176fa3c32d260599906",
"version" : "0.3.1"
"revision" : "a6b5793ab4053f9b55b840245ad07c9e3fdae344",
"version" : "0.5.0"
}
},
{
Expand Down Expand Up @@ -141,8 +141,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pCloud/pcloud-sdk-swift.git",
"state" : {
"revision" : "6da4ca6bb4e7068145d9325988e29862d26300ba",
"version" : "3.2.0"
"revision" : "ad1a7d8b3a59f12185d7bc89ff7a1b8c087ed0c0",
"version" : "3.2.2"
}
},
{
Expand Down
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/box/box-swift-sdk-gen.git",
"state" : {
"revision" : "7b2e3963a4f9d7c608ba9176fa3c32d260599906",
"version" : "0.3.1"
"revision" : "a6b5793ab4053f9b55b840245ad07c9e3fdae344",
"version" : "0.5.0"
}
},
{
Expand Down Expand Up @@ -140,8 +140,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pCloud/pcloud-sdk-swift.git",
"state" : {
"revision" : "6da4ca6bb4e7068145d9325988e29862d26300ba",
"version" : "3.2.0"
"revision" : "ad1a7d8b3a59f12185d7bc89ff7a1b8c087ed0c0",
"version" : "3.2.2"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/AzureAD/microsoft-authentication-library-for-objc.git", .upToNextMinor(from: "1.3.0")),
.package(url: "https://github.com/aws-amplify/aws-sdk-ios-spm.git", .upToNextMinor(from: "2.34.0")),
.package(url: "https://github.com/box/box-swift-sdk-gen.git", .upToNextMinor(from: "0.3.0")),
.package(url: "https://github.com/box/box-swift-sdk-gen.git", .upToNextMinor(from: "0.5.0")),
.package(url: "https://github.com/cryptomator/cryptolib-swift.git", .upToNextMinor(from: "1.1.0")),
.package(url: "https://github.com/CocoaLumberjack/CocoaLumberjack.git", .upToNextMinor(from: "3.8.0")),
.package(url: "https://github.com/google/google-api-objectivec-client-for-rest.git", .upToNextMinor(from: "3.4.0")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class VaultFormat6ShortenedNameCache {
return Promise(originalName)
} else {
return loadLngFile(shortenedName).then { data -> String in
let originalName = String(decoding: data, as: UTF8.self)
let originalName = String(data: data, encoding: .utf8)!
try? self.addToCache(shortenedName, originalName: originalName)
return originalName
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class VaultFormat7ShortenedNameCache {
return Promise(originalName)
} else {
return loadNameC9S(c9sDirPath).then { data -> String in
let originalName = String(decoding: data, as: UTF8.self)
let originalName = String(data: data, encoding: .utf8)!
try? self.addToCache(shortenedName, originalName: originalName)
return originalName
}
Expand Down
2 changes: 0 additions & 2 deletions Sources/CryptomatorCloudAccess/Logging/HTTPDebugLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ enum HTTPDebugLogger {
guard let bodyData = request.httpBody else {
return .none
}
// swiftlint:disable:next non_optional_string_data_conversion
if let body = String(data: bodyData, encoding: .utf8) {
if body.isEmpty {
return .empty
Expand Down Expand Up @@ -103,7 +102,6 @@ enum HTTPDebugLogger {
if let contentEncodingHeaderField = response.value(forHTTPHeaderField: "Content-Encoding"), contentEncodingHeaderField.caseInsensitiveCompare("identity") != .orderedSame {
return .encoded
}
// swiftlint:disable:next non_optional_string_data_conversion
if let body = String(data: bodyData, encoding: .utf8) {
if body.isEmpty {
return .empty
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// MSClientFactory+UnauthenticatedClient.swift
// CryptomatorCloudAccess
//
// Created by Tobias Hagemann on 12.09.24.
// Copyright © 2024 Skymatic GmbH. All rights reserved.
//

import MSGraphClientSDK

extension MSClientFactory {
static func createUnauthenticatedHTTPClient(with urlSessionConfiguration: URLSessionConfiguration) -> MSHTTPClient {
let redirectHandler = MSMiddlewareFactory.createMiddleware(.redirect) as MSGraphMiddleware
let retryHandler = MSMiddlewareFactory.createMiddleware(.retry) as MSGraphMiddleware
let sessionManager = MSURLSessionManager(sessionConfiguration: urlSessionConfiguration)
redirectHandler.setNext(retryHandler)
retryHandler.setNext(sessionManager)
return MSClientFactory.createHTTPClient(with: redirectHandler)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ public class OneDriveCloudProvider: CloudProvider {
private static let maxUploadFileChunkLength = 16 * 320 * 1024 // 5MiB

private let client: MSHTTPClient
private let unauthenticatedClient: MSHTTPClient
private let identifierCache: OneDriveIdentifierCache
private let tmpDirURL: URL
private let maxPageSize: Int

init(credential: OneDriveCredential, maxPageSize: Int = .max, urlSessionConfiguration: URLSessionConfiguration) throws {
self.client = MSClientFactory.createHTTPClient(with: credential.authProvider, andSessionConfiguration: urlSessionConfiguration)
self.unauthenticatedClient = MSClientFactory.createUnauthenticatedHTTPClient(with: urlSessionConfiguration)
self.identifierCache = try OneDriveIdentifierCache()
self.tmpDirURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true)
self.maxPageSize = min(max(1, maxPageSize), 1000)
Expand Down Expand Up @@ -483,7 +485,9 @@ public class OneDriveCloudProvider: CloudProvider {
private func executeMSURLSessionUploadTask(with request: NSMutableURLRequest, localURL: URL) -> Promise<(Data, HTTPURLResponse)> {
HTTPDebugLogger.logRequest(request as URLRequest)
return Promise<(Data, HTTPURLResponse)> { fulfill, reject in
let task = MSURLSessionUploadTask(request: request, fromFile: localURL, client: self.client) { data, response, error in
// We have to use an unauthenticated client, because the PUT request shouldn't contain an Authorization header.
// https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#remarks
let task = MSURLSessionUploadTask(request: request, fromFile: localURL, client: self.unauthenticatedClient) { data, response, error in
if let response = response {
HTTPDebugLogger.logResponse(response, with: data, or: nil)
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/CryptomatorCloudAccessTests/Crypto/CryptorMock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public class CryptorMock: Cryptor {
}

override public func encryptDirId(_ dirId: Data) throws -> String {
if let dirId = dirIds[String(decoding: dirId, as: UTF8.self)] {
if let dirId = dirIds[String(data: dirId, encoding: .utf8)!] {
return dirId
} else {
return "99ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class VaultConfigTests: XCTestCase {
let vaultConfig = VaultConfig(id: "ABB9F673-F3E8-41A7-A43B-D29F5DA65068", format: 8, cipherCombo: .sivCtrMac, shorteningThreshold: 220)
let rawKey = [UInt8](repeating: 0x55, count: 64)
let token = try vaultConfig.toToken(keyId: "masterkeyfile:masterkey.cryptomator", rawKey: rawKey)
let tokenComponents = String(decoding: token, as: UTF8.self).split(separator: ".")
let tokenComponents = String(data: token, encoding: .utf8)!.split(separator: ".")
// check header
let header: [String: String] = try decodeTokenComponent(String(tokenComponents[0]))
XCTAssertEqual(["typ": "JWT", "alg": "HS256", "kid": "masterkeyfile:masterkey.cryptomator"], header)
Expand Down

0 comments on commit ff48ad0

Please sign in to comment.