Skip to content

Commit ff48ad0

Browse files
committed
Merge branch 'release/1.11.1'
2 parents 9a7743f + 6106af1 commit ff48ad0

File tree

11 files changed

+43
-17
lines changed

11 files changed

+43
-17
lines changed

CryptomatorCloudAccess.xcodeproj/project.pbxproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@
153153
748BD4CC24B4D3820001CA8C /* Date+RFC822.swift in Sources */ = {isa = PBXBuildFile; fileRef = 748BD4CB24B4D3820001CA8C /* Date+RFC822.swift */; };
154154
7494505F24BC5C3300149816 /* PropfindResponseParserTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7494505E24BC5C3300149816 /* PropfindResponseParserTests.swift */; };
155155
7494B06D249CEAC500430610 /* VaultFormat7ShorteningProviderDecoratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7494B06C249CEAC500430610 /* VaultFormat7ShorteningProviderDecoratorTests.swift */; };
156+
749D91152C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749D91142C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift */; };
156157
749F59A52BD1211500AB299A /* PCloudSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749F59A42BD1211500AB299A /* PCloudSetup.swift */; };
157158
74B321E42923F979008E7C01 /* HTTPDebugLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74B321E32923F979008E7C01 /* HTTPDebugLogger.swift */; };
158159
74C0FB2729B209B6008EF811 /* S3Authenticator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74C0FB2629B209B6008EF811 /* S3Authenticator.swift */; };
@@ -357,6 +358,7 @@
357358
748BD4CB24B4D3820001CA8C /* Date+RFC822.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+RFC822.swift"; sourceTree = "<group>"; };
358359
7494505E24BC5C3300149816 /* PropfindResponseParserTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PropfindResponseParserTests.swift; sourceTree = "<group>"; };
359360
7494B06C249CEAC500430610 /* VaultFormat7ShorteningProviderDecoratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VaultFormat7ShorteningProviderDecoratorTests.swift; sourceTree = "<group>"; };
361+
749D91142C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MSClientFactory+UnauthenticatedClient.swift"; sourceTree = "<group>"; };
360362
749F59A42BD1211500AB299A /* PCloudSetup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PCloudSetup.swift; sourceTree = "<group>"; };
361363
74B321E32923F979008E7C01 /* HTTPDebugLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPDebugLogger.swift; sourceTree = "<group>"; };
362364
74C0FB2629B209B6008EF811 /* S3Authenticator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = S3Authenticator.swift; sourceTree = "<group>"; };
@@ -530,6 +532,7 @@
530532
4A1A11692629A53300DAF62F /* OneDrive */ = {
531533
isa = PBXGroup;
532534
children = (
535+
749D91142C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift */,
533536
4AD55338263ABA4200126046 /* MSGraphDriveItem+CloudItemType.swift */,
534537
4A3896CD2632D65B00BA3E88 /* OneDriveAuthenticationProvider.swift */,
535538
4A1A11782629ACD500DAF62F /* OneDriveAuthenticator.swift */,
@@ -1332,6 +1335,7 @@
13321335
9ECEC0AF246ED1FB00151299 /* DirectoryIdCache.swift in Sources */,
13331336
4A77390D286DB5A00006B3C3 /* AWSS3TransferUtility+ForegroundSession.swift in Sources */,
13341337
745949E225F22F4D00B7B28C /* VaultFormat8ProviderDecorator.swift in Sources */,
1338+
749D91152C92EFA600FAD1A4 /* MSClientFactory+UnauthenticatedClient.swift in Sources */,
13351339
745949E625F2326D00B7B28C /* VaultFormat8ShorteningProviderDecorator.swift in Sources */,
13361340
4A628EB8252F610C0097DE94 /* URLSession+Promises.swift in Sources */,
13371341
4A567B692615D64E002C4D82 /* GoogleDriveSetup.swift in Sources */,
@@ -1889,7 +1893,7 @@
18891893
repositoryURL = "https://github.com/box/box-swift-sdk-gen.git";
18901894
requirement = {
18911895
kind = upToNextMinorVersion;
1892-
minimumVersion = 0.3.0;
1896+
minimumVersion = 0.5.0;
18931897
};
18941898
};
18951899
/* End XCRemoteSwiftPackageReference section */

CryptomatorCloudAccess.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
"kind" : "remoteSourceControl",
3434
"location" : "https://github.com/box/box-swift-sdk-gen.git",
3535
"state" : {
36-
"revision" : "7b2e3963a4f9d7c608ba9176fa3c32d260599906",
37-
"version" : "0.3.1"
36+
"revision" : "a6b5793ab4053f9b55b840245ad07c9e3fdae344",
37+
"version" : "0.5.0"
3838
}
3939
},
4040
{
@@ -141,8 +141,8 @@
141141
"kind" : "remoteSourceControl",
142142
"location" : "https://github.com/pCloud/pcloud-sdk-swift.git",
143143
"state" : {
144-
"revision" : "6da4ca6bb4e7068145d9325988e29862d26300ba",
145-
"version" : "3.2.0"
144+
"revision" : "ad1a7d8b3a59f12185d7bc89ff7a1b8c087ed0c0",
145+
"version" : "3.2.2"
146146
}
147147
},
148148
{

Package.resolved

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"kind" : "remoteSourceControl",
3333
"location" : "https://github.com/box/box-swift-sdk-gen.git",
3434
"state" : {
35-
"revision" : "7b2e3963a4f9d7c608ba9176fa3c32d260599906",
36-
"version" : "0.3.1"
35+
"revision" : "a6b5793ab4053f9b55b840245ad07c9e3fdae344",
36+
"version" : "0.5.0"
3737
}
3838
},
3939
{
@@ -140,8 +140,8 @@
140140
"kind" : "remoteSourceControl",
141141
"location" : "https://github.com/pCloud/pcloud-sdk-swift.git",
142142
"state" : {
143-
"revision" : "6da4ca6bb4e7068145d9325988e29862d26300ba",
144-
"version" : "3.2.0"
143+
"revision" : "ad1a7d8b3a59f12185d7bc89ff7a1b8c087ed0c0",
144+
"version" : "3.2.2"
145145
}
146146
},
147147
{

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let package = Package(
3030
dependencies: [
3131
.package(url: "https://github.com/AzureAD/microsoft-authentication-library-for-objc.git", .upToNextMinor(from: "1.3.0")),
3232
.package(url: "https://github.com/aws-amplify/aws-sdk-ios-spm.git", .upToNextMinor(from: "2.34.0")),
33-
.package(url: "https://github.com/box/box-swift-sdk-gen.git", .upToNextMinor(from: "0.3.0")),
33+
.package(url: "https://github.com/box/box-swift-sdk-gen.git", .upToNextMinor(from: "0.5.0")),
3434
.package(url: "https://github.com/cryptomator/cryptolib-swift.git", .upToNextMinor(from: "1.1.0")),
3535
.package(url: "https://github.com/CocoaLumberjack/CocoaLumberjack.git", .upToNextMinor(from: "3.8.0")),
3636
.package(url: "https://github.com/google/google-api-objectivec-client-for-rest.git", .upToNextMinor(from: "3.4.0")),

Sources/CryptomatorCloudAccess/Crypto/VaultFormat6/VaultFormat6ShortenedNameCache.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class VaultFormat6ShortenedNameCache {
121121
return Promise(originalName)
122122
} else {
123123
return loadLngFile(shortenedName).then { data -> String in
124-
let originalName = String(decoding: data, as: UTF8.self)
124+
let originalName = String(data: data, encoding: .utf8)!
125125
try? self.addToCache(shortenedName, originalName: originalName)
126126
return originalName
127127
}

Sources/CryptomatorCloudAccess/Crypto/VaultFormat7/VaultFormat7ShortenedNameCache.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class VaultFormat7ShortenedNameCache {
181181
return Promise(originalName)
182182
} else {
183183
return loadNameC9S(c9sDirPath).then { data -> String in
184-
let originalName = String(decoding: data, as: UTF8.self)
184+
let originalName = String(data: data, encoding: .utf8)!
185185
try? self.addToCache(shortenedName, originalName: originalName)
186186
return originalName
187187
}

Sources/CryptomatorCloudAccess/Logging/HTTPDebugLogger.swift

-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ enum HTTPDebugLogger {
4242
guard let bodyData = request.httpBody else {
4343
return .none
4444
}
45-
// swiftlint:disable:next non_optional_string_data_conversion
4645
if let body = String(data: bodyData, encoding: .utf8) {
4746
if body.isEmpty {
4847
return .empty
@@ -103,7 +102,6 @@ enum HTTPDebugLogger {
103102
if let contentEncodingHeaderField = response.value(forHTTPHeaderField: "Content-Encoding"), contentEncodingHeaderField.caseInsensitiveCompare("identity") != .orderedSame {
104103
return .encoded
105104
}
106-
// swiftlint:disable:next non_optional_string_data_conversion
107105
if let body = String(data: bodyData, encoding: .utf8) {
108106
if body.isEmpty {
109107
return .empty
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// MSClientFactory+UnauthenticatedClient.swift
3+
// CryptomatorCloudAccess
4+
//
5+
// Created by Tobias Hagemann on 12.09.24.
6+
// Copyright © 2024 Skymatic GmbH. All rights reserved.
7+
//
8+
9+
import MSGraphClientSDK
10+
11+
extension MSClientFactory {
12+
static func createUnauthenticatedHTTPClient(with urlSessionConfiguration: URLSessionConfiguration) -> MSHTTPClient {
13+
let redirectHandler = MSMiddlewareFactory.createMiddleware(.redirect) as MSGraphMiddleware
14+
let retryHandler = MSMiddlewareFactory.createMiddleware(.retry) as MSGraphMiddleware
15+
let sessionManager = MSURLSessionManager(sessionConfiguration: urlSessionConfiguration)
16+
redirectHandler.setNext(retryHandler)
17+
retryHandler.setNext(sessionManager)
18+
return MSClientFactory.createHTTPClient(with: redirectHandler)
19+
}
20+
}

Sources/CryptomatorCloudAccess/OneDrive/OneDriveCloudProvider.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ public class OneDriveCloudProvider: CloudProvider {
1515
private static let maxUploadFileChunkLength = 16 * 320 * 1024 // 5MiB
1616

1717
private let client: MSHTTPClient
18+
private let unauthenticatedClient: MSHTTPClient
1819
private let identifierCache: OneDriveIdentifierCache
1920
private let tmpDirURL: URL
2021
private let maxPageSize: Int
2122

2223
init(credential: OneDriveCredential, maxPageSize: Int = .max, urlSessionConfiguration: URLSessionConfiguration) throws {
2324
self.client = MSClientFactory.createHTTPClient(with: credential.authProvider, andSessionConfiguration: urlSessionConfiguration)
25+
self.unauthenticatedClient = MSClientFactory.createUnauthenticatedHTTPClient(with: urlSessionConfiguration)
2426
self.identifierCache = try OneDriveIdentifierCache()
2527
self.tmpDirURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, isDirectory: true)
2628
self.maxPageSize = min(max(1, maxPageSize), 1000)
@@ -483,7 +485,9 @@ public class OneDriveCloudProvider: CloudProvider {
483485
private func executeMSURLSessionUploadTask(with request: NSMutableURLRequest, localURL: URL) -> Promise<(Data, HTTPURLResponse)> {
484486
HTTPDebugLogger.logRequest(request as URLRequest)
485487
return Promise<(Data, HTTPURLResponse)> { fulfill, reject in
486-
let task = MSURLSessionUploadTask(request: request, fromFile: localURL, client: self.client) { data, response, error in
488+
// We have to use an unauthenticated client, because the PUT request shouldn't contain an Authorization header.
489+
// https://learn.microsoft.com/en-us/graph/api/driveitem-createuploadsession?view=graph-rest-1.0#remarks
490+
let task = MSURLSessionUploadTask(request: request, fromFile: localURL, client: self.unauthenticatedClient) { data, response, error in
487491
if let response = response {
488492
HTTPDebugLogger.logResponse(response, with: data, or: nil)
489493
}

Tests/CryptomatorCloudAccessTests/Crypto/CryptorMock.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class CryptorMock: Cryptor {
5555
}
5656

5757
override public func encryptDirId(_ dirId: Data) throws -> String {
58-
if let dirId = dirIds[String(decoding: dirId, as: UTF8.self)] {
58+
if let dirId = dirIds[String(data: dirId, encoding: .utf8)!] {
5959
return dirId
6060
} else {
6161
return "99ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"

Tests/CryptomatorCloudAccessTests/Crypto/VaultConfigTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class VaultConfigTests: XCTestCase {
8686
let vaultConfig = VaultConfig(id: "ABB9F673-F3E8-41A7-A43B-D29F5DA65068", format: 8, cipherCombo: .sivCtrMac, shorteningThreshold: 220)
8787
let rawKey = [UInt8](repeating: 0x55, count: 64)
8888
let token = try vaultConfig.toToken(keyId: "masterkeyfile:masterkey.cryptomator", rawKey: rawKey)
89-
let tokenComponents = String(decoding: token, as: UTF8.self).split(separator: ".")
89+
let tokenComponents = String(data: token, encoding: .utf8)!.split(separator: ".")
9090
// check header
9191
let header: [String: String] = try decodeTokenComponent(String(tokenComponents[0]))
9292
XCTAssertEqual(["typ": "JWT", "alg": "HS256", "kid": "masterkeyfile:masterkey.cryptomator"], header)

0 commit comments

Comments
 (0)