Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Box support #34

Open
wants to merge 23 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
62dbd68
Implemented the basic structure and key functionalities of BoxCloudPr…
iammajid Mar 26, 2024
e52202e
Add placeholder for developer token
iammajid Mar 26, 2024
afcdff9
Added BoxCloudProvider, authentication logic, tests, and credentials …
iammajid Apr 15, 2024
888bbb6
Added safe cast in BoxAuthenticator, remove userID from BoxCredential…
iammajid Apr 16, 2024
ce58f0a
Disable force_try in GoogleDriveIntegrationTests
iammajid Apr 16, 2024
db2e163
Downgraded Package.resolved to version 2
tobihagemann Apr 16, 2024
b8f691f
Merge branch 'develop' into feature/boxcloud-integration
tobihagemann Apr 17, 2024
4b7ec5b
Fixed 'getUsername'
iammajid Apr 18, 2024
4d99667
Merge branch 'develop' into feature/boxcloud-integration
tobihagemann Apr 18, 2024
79bb7cd
Removed unnecessary diff
tobihagemann Apr 23, 2024
ee39812
Reordered entries in Package.swift
tobihagemann Apr 23, 2024
0462aa1
Updated file header comments
tobihagemann Apr 23, 2024
c86a6c7
Fixed typo in debug logs
tobihagemann Apr 23, 2024
f995ff9
Removed unused Box error
tobihagemann Apr 23, 2024
eb9a34d
Fixed wrong usage of Box error
tobihagemann Apr 23, 2024
dab7df9
Updated READMEs
iammajid Apr 25, 2024
995defc
Added VaultFormatIntegrationsTests for box, improved README's and int…
iammajid Apr 29, 2024
b63b18d
Remove BoxAuthenticatorMock and fix README
iammajid Apr 29, 2024
05837ec
"Replaced old Box SDK with new Box SDK GENERATED"
iammajid May 23, 2024
23b077e
Merge branch 'develop' into feature/boxcloud-integration
tobihagemann May 23, 2024
17de27a
Add token storage in BoxAuthenticator and getUserId method in BoxCred…
iammajid May 27, 2024
0af03cd
Revert specific changes in Package.resolved and BoxIntegrationTests.x…
iammajid Jun 21, 2024
d544b20
Implement chunked upload, adjust authentication, and some improvements
iammajid Jun 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
78 changes: 78 additions & 0 deletions CryptomatorCloudAccess.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,16 @@
9ED0E624246198F600FDB438 /* VaultFormat7CloudProviderMockTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9ED0E623246198F600FDB438 /* VaultFormat7CloudProviderMockTests.swift */; };
9EE62A0D247D54760089DAF7 /* CloudProvider+Convenience.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EE62A0C247D54760089DAF7 /* CloudProvider+Convenience.swift */; };
9EE62A10247D54E90089DAF7 /* CloudProvider+ConvenienceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9EE62A0F247D54E90089DAF7 /* CloudProvider+ConvenienceTests.swift */; };
B3408AC82BCD32CA005271D2 /* BoxCredentialMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3408AC72BCD32CA005271D2 /* BoxCredentialMock.swift */; };
B3408ACA2BCDAA09005271D2 /* BoxError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3408AC92BCDAA09005271D2 /* BoxError.swift */; };
B3D513912BA9A32200DE0D36 /* BoxAuthenticator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D5138D2BA9A32200DE0D36 /* BoxAuthenticator.swift */; };
B3D513922BA9A32200DE0D36 /* BoxCredential.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D5138E2BA9A32200DE0D36 /* BoxCredential.swift */; };
B3D513932BA9A32200DE0D36 /* BoxSetup.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D5138F2BA9A32200DE0D36 /* BoxSetup.swift */; };
B3D513972BA9A44000DE0D36 /* BoxCloudProviderIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3D513952BA9A3BB00DE0D36 /* BoxCloudProviderIntegrationTests.swift */; };
B3FC94A42BA9A98200D1ECFD /* BoxSDK in Frameworks */ = {isa = PBXBuildFile; productRef = B3FC94A32BA9A98200D1ECFD /* BoxSDK */; };
B3FC94A62BA9AA4400D1ECFD /* BoxCloudProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FC94A52BA9AA4400D1ECFD /* BoxCloudProvider.swift */; };
B3FC94A82BA9AEEC00D1ECFD /* BoxIdentifierCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FC94A72BA9AEEC00D1ECFD /* BoxIdentifierCache.swift */; };
B3FC94AA2BA9AEFC00D1ECFD /* BoxItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = B3FC94A92BA9AEFC00D1ECFD /* BoxItem.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -374,6 +384,15 @@
9ED0E623246198F600FDB438 /* VaultFormat7CloudProviderMockTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VaultFormat7CloudProviderMockTests.swift; sourceTree = "<group>"; };
9EE62A0C247D54760089DAF7 /* CloudProvider+Convenience.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CloudProvider+Convenience.swift"; sourceTree = "<group>"; };
9EE62A0F247D54E90089DAF7 /* CloudProvider+ConvenienceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CloudProvider+ConvenienceTests.swift"; sourceTree = "<group>"; };
B3408AC72BCD32CA005271D2 /* BoxCredentialMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxCredentialMock.swift; sourceTree = "<group>"; };
B3408AC92BCDAA09005271D2 /* BoxError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxError.swift; sourceTree = "<group>"; };
B3D5138D2BA9A32200DE0D36 /* BoxAuthenticator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoxAuthenticator.swift; sourceTree = "<group>"; };
B3D5138E2BA9A32200DE0D36 /* BoxCredential.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoxCredential.swift; sourceTree = "<group>"; };
B3D5138F2BA9A32200DE0D36 /* BoxSetup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BoxSetup.swift; sourceTree = "<group>"; };
B3D513952BA9A3BB00DE0D36 /* BoxCloudProviderIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxCloudProviderIntegrationTests.swift; sourceTree = "<group>"; };
B3FC94A52BA9AA4400D1ECFD /* BoxCloudProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxCloudProvider.swift; sourceTree = "<group>"; };
B3FC94A72BA9AEEC00D1ECFD /* BoxIdentifierCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxIdentifierCache.swift; sourceTree = "<group>"; };
B3FC94A92BA9AEFC00D1ECFD /* BoxItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoxItem.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -382,6 +401,7 @@
buildActionMask = 2147483647;
files = (
4A75E1C428806F5800952FE6 /* MSGraphClientModels in Frameworks */,
B3FC94A42BA9A98200D1ECFD /* BoxSDK in Frameworks */,
4A75E1C728806FA100952FE6 /* MSGraphClientSDK in Frameworks */,
4AF0AA7C2844DDD200C20B75 /* AWSS3 in Frameworks */,
74F9355D251F67A3001F4ADA /* CryptomatorCryptoLib in Frameworks */,
Expand Down Expand Up @@ -424,6 +444,7 @@
74F9354B251F66EE001F4ADA /* Sources */,
74F9354C251F66F8001F4ADA /* Tests */,
4A058FF224519FFC008831F9 /* Products */,
B3FC94A22BA9A98200D1ECFD /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -443,6 +464,7 @@
4A058FF424519FFC008831F9 /* CryptomatorCloudAccess.h */,
4A058FF524519FFC008831F9 /* Info.plist */,
4A0590162451A1BB008831F9 /* API */,
B3D513902BA9A32200DE0D36 /* Box */,
4A741FF0287C696F00489C23 /* Common */,
7416F22424F658160074DA8E /* Crypto */,
4A567AF02615C2DE002C4D82 /* Dropbox */,
Expand Down Expand Up @@ -604,6 +626,7 @@
4ACA63B02615FE8000D19304 /* CloudAccessIntegrationTestWithAuthentication.swift */,
4ACA63A42615FE5700D19304 /* IntegrationTestError.swift */,
4ACA64252616054F00D19304 /* IntegrationTestSecrets.swift */,
B3D513942BA9A37A00DE0D36 /* Box */,
4ACA63BF2615FEB200D19304 /* CryptoDecorator */,
4ACA63F02615FF9700D19304 /* Dropbox */,
4ACA63F92615FF9700D19304 /* Extensions */,
Expand Down Expand Up @@ -968,6 +991,37 @@
path = API;
sourceTree = "<group>";
};
B3D513902BA9A32200DE0D36 /* Box */ = {
isa = PBXGroup;
children = (
B3D5138D2BA9A32200DE0D36 /* BoxAuthenticator.swift */,
B3FC94A52BA9AA4400D1ECFD /* BoxCloudProvider.swift */,
B3D5138E2BA9A32200DE0D36 /* BoxCredential.swift */,
B3408AC92BCDAA09005271D2 /* BoxError.swift */,
B3FC94A72BA9AEEC00D1ECFD /* BoxIdentifierCache.swift */,
B3FC94A92BA9AEFC00D1ECFD /* BoxItem.swift */,
B3D5138F2BA9A32200DE0D36 /* BoxSetup.swift */,
);
name = Box;
path = Sources/CryptomatorCloudAccess/Box;
sourceTree = SOURCE_ROOT;
};
B3D513942BA9A37A00DE0D36 /* Box */ = {
isa = PBXGroup;
children = (
B3D513952BA9A3BB00DE0D36 /* BoxCloudProviderIntegrationTests.swift */,
B3408AC72BCD32CA005271D2 /* BoxCredentialMock.swift */,
);
path = Box;
sourceTree = "<group>";
};
B3FC94A22BA9A98200D1ECFD /* Frameworks */ = {
isa = PBXGroup;
children = (
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -1014,6 +1068,7 @@
4A75E1C628806FA100952FE6 /* MSGraphClientSDK */,
4A75E1C928806FF000952FE6 /* ObjectiveDropboxOfficial */,
4A8B872E287D7E77002D676E /* CocoaLumberjackSwift */,
B3FC94A32BA9A98200D1ECFD /* BoxSDK */,
);
productName = CloudAccess;
productReference = 4A058FF124519FFC008831F9 /* CryptomatorCloudAccess.framework */;
Expand Down Expand Up @@ -1104,6 +1159,7 @@
4A75E1C528806FA100952FE6 /* XCRemoteSwiftPackageReference "msgraph-sdk-objc-spm" */,
4A75E1C828806FF000952FE6 /* XCRemoteSwiftPackageReference "dropbox-sdk-obj-c-spm" */,
4A8B872D287D7E77002D676E /* XCRemoteSwiftPackageReference "CocoaLumberjack" */,
B3FC94A12BA9A8E600D1ECFD /* XCRemoteSwiftPackageReference "box-ios-sdk" */,
);
productRefGroup = 4A058FF224519FFC008831F9 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -1224,9 +1280,12 @@
74C0FB2729B209B6008EF811 /* S3Authenticator.swift in Sources */,
747A77FF2698577E005E5AD4 /* GTLRDrive_File+CloudItemType.swift in Sources */,
4A1A1183262B078E00DAF62F /* OneDriveError.swift in Sources */,
B3D513922BA9A32200DE0D36 /* BoxCredential.swift in Sources */,
740C144E249B4F2B008CA3E0 /* VaultFormat7ShorteningProviderDecorator.swift in Sources */,
74FD6C4824F6F3AA00C8D3C4 /* VaultFormat6ShorteningProviderDecorator.swift in Sources */,
4A567B222615CA24002C4D82 /* GoogleDriveIdentifierCache.swift in Sources */,
B3D513912BA9A32200DE0D36 /* BoxAuthenticator.swift in Sources */,
B3FC94AA2BA9AEFC00D1ECFD /* BoxItem.swift in Sources */,
4A0421822642B9260033144A /* VaultProviderFactory.swift in Sources */,
4A567B102615C6F3002C4D82 /* DropboxError.swift in Sources */,
4A567AED2615C2D7002C4D82 /* DropboxAuthenticator.swift in Sources */,
Expand All @@ -1243,6 +1302,7 @@
7471BDAE24865B6F000D05FC /* LocalFileSystemProvider.swift in Sources */,
7484608729795421009933D8 /* VaultConfigHelper.swift in Sources */,
4ABE9AA32BCAC8FE00675D74 /* Promise+Async.swift in Sources */,
B3FC94A62BA9AA4400D1ECFD /* BoxCloudProvider.swift in Sources */,
74073D1927C9406000A86C9A /* Task+Promises.swift in Sources */,
4A1A1194262EC46E00DAF62F /* OneDriveIdentifierCache.swift in Sources */,
746F091327BC0DA2003FCD9F /* PCloudCredential.swift in Sources */,
Expand Down Expand Up @@ -1284,14 +1344,17 @@
4A1A11792629ACD500DAF62F /* OneDriveAuthenticator.swift in Sources */,
748BD4CA24B4B1D50001CA8C /* PropfindResponseParser.swift in Sources */,
4A567B322615CA6E002C4D82 /* GoogleDriveError.swift in Sources */,
B3FC94A82BA9AEEC00D1ECFD /* BoxIdentifierCache.swift in Sources */,
4A0785302859F4FE0015DAE1 /* S3Credential.swift in Sources */,
748A42B824AA231D00DEB6D0 /* WebDAVAuthenticator.swift in Sources */,
74F4AA1525ED3D2A00FDF2C6 /* VaultConfig.swift in Sources */,
4A567B262615CA34002C4D82 /* GoogleDriveCloudProvider.swift in Sources */,
4AD55339263ABA4200126046 /* MSGraphDriveItem+CloudItemType.swift in Sources */,
747A77FD269854A6005E5AD4 /* GoogleDriveItem.swift in Sources */,
748A42C024AB424500DEB6D0 /* WebDAVClient.swift in Sources */,
B3D513932BA9A32200DE0D36 /* BoxSetup.swift in Sources */,
4A567B082615C6AF002C4D82 /* DropboxCloudProvider.swift in Sources */,
B3408ACA2BCDAA09005271D2 /* BoxError.swift in Sources */,
74C596E824F022AF00FFD17E /* CloudPath.swift in Sources */,
4A05900C2451A107008831F9 /* CloudProvider.swift in Sources */,
4A567B142615C8B8002C4D82 /* GoogleDriveAuthenticator.swift in Sources */,
Expand Down Expand Up @@ -1370,6 +1433,8 @@
7467A0D627DF9A8000BCFDF8 /* VaultFormat6PCloudIntegrationTests.swift in Sources */,
4AC75F9C2861A6DE002731FE /* VaultFormat6S3IntegrationTests.swift in Sources */,
4ACA63A02615FE2C00D19304 /* CloudAccessIntegrationTest.swift in Sources */,
B3D513972BA9A44000DE0D36 /* BoxCloudProviderIntegrationTests.swift in Sources */,
B3408AC82BCD32CA005271D2 /* BoxCredentialMock.swift in Sources */,
4ACA64262616054F00D19304 /* IntegrationTestSecrets.swift in Sources */,
4A41D2432641938A00B5D787 /* VaultFormat6OneDriveIntegrationTests.swift in Sources */,
7470C54B26569A7E00E361B8 /* MSAuthenticationProviderMock.swift in Sources */,
Expand Down Expand Up @@ -1815,6 +1880,14 @@
minimumVersion = 2.3.0;
};
};
B3FC94A12BA9A8E600D1ECFD /* XCRemoteSwiftPackageReference "box-ios-sdk" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/box/box-ios-sdk.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.5.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand Down Expand Up @@ -1893,6 +1966,11 @@
package = 74F93565251F6863001F4ADA /* XCRemoteSwiftPackageReference "promises" */;
productName = Promises;
};
B3FC94A32BA9A98200D1ECFD /* BoxSDK */ = {
isa = XCSwiftPackageProductDependency;
package = B3FC94A12BA9A8E600D1ECFD /* XCRemoteSwiftPackageReference "box-ios-sdk" */;
productName = BoxSDK;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 4A058FE824519FFC008831F9 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"version" : "0.9.0"
}
},
{
"identity" : "box-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/box/box-ios-sdk.git",
"state" : {
"revision" : "daffd86b861a5f5882655bf7a01b891f6b808c1f",
"version" : "5.5.0"
}
},
{
"identity" : "cocoalumberjack",
"kind" : "remoteSourceControl",
Expand Down
9 changes: 9 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"version" : "0.9.0"
}
},
{
"identity" : "box-ios-sdk",
"kind" : "remoteSourceControl",
"location" : "https://github.com/box/box-ios-sdk.git",
"state" : {
"revision" : "daffd86b861a5f5882655bf7a01b891f6b808c1f",
"version" : "5.5.0"
}
},
{
"identity" : "cocoalumberjack",
"kind" : "remoteSourceControl",
Expand Down
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ let package = Package(
.library(name: "CryptomatorCloudAccessCore", targets: ["CryptomatorCloudAccessCore"])
],
dependencies: [
.package(url: "https://github.com/tobihagemann/JOSESwift.git", exact: "2.4.1-cryptomator"),
.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-ios-sdk.git", .upToNextMinor(from: "5.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 All @@ -41,14 +41,16 @@ let package = Package(
.package(url: "https://github.com/pCloud/pcloud-sdk-swift.git", .upToNextMinor(from: "3.2.0")),
.package(url: "https://github.com/phil1995/dropbox-sdk-obj-c-spm.git", .upToNextMinor(from: "7.2.0")),
.package(url: "https://github.com/phil1995/msgraph-sdk-objc-spm.git", .upToNextMinor(from: "1.0.0")),
.package(url: "https://github.com/phil1995/msgraph-sdk-objc-models-spm.git", .upToNextMinor(from: "1.3.0"))
.package(url: "https://github.com/phil1995/msgraph-sdk-objc-models-spm.git", .upToNextMinor(from: "1.3.0")),
.package(url: "https://github.com/tobihagemann/JOSESwift.git", exact: "2.4.1-cryptomator")
],
targets: [
.target(
name: "CryptomatorCloudAccessCore",
dependencies: [
.product(name: "AWSCore", package: "aws-sdk-ios-spm"),
.product(name: "AWSS3", package: "aws-sdk-ios-spm"),
.product(name: "BoxSDK", package: "box-ios-sdk"),
.product(name: "CocoaLumberjackSwift", package: "CocoaLumberjack"),
.product(name: "CryptomatorCryptoLib", package: "cryptolib-swift"),
.product(name: "GoogleAPIClientForREST_Drive", package: "google-api-objectivec-client-for-rest"),
Expand Down
50 changes: 50 additions & 0 deletions Sources/CryptomatorCloudAccess/Box/BoxAuthenticator.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// BoxAuthenticator.swift
// CryptomatorCloudAccess
//
// Created by Majid Achhoud on 18.03.24.
// Copyright © 2024 Skymatic GmbH. All rights reserved.
//

#if canImport(CryptomatorCloudAccessCore)
import CryptomatorCloudAccessCore
#endif
import AuthenticationServices
import BoxSDK
import Promises
import UIKit

public enum BoxAuthenticatorError: Error {
case authenticationFailed
case invalidContext
}

public enum BoxAuthenticator {
public static let sdk = BoxSDK(clientId: BoxSetup.constants.clientId, clientSecret: BoxSetup.constants.clientSecret)

public static func authenticate(from viewController: UIViewController, tokenStore: TokenStore) -> Promise<(BoxClient, String)> {
return Promise { fulfill, reject in

guard let context = viewController as? ASWebAuthenticationPresentationContextProviding else {
reject(BoxAuthenticatorError.invalidContext)
return
}

sdk.getOAuth2Client(tokenStore: tokenStore, context: context) { result in
switch result {
case let .success(client):
client.users.getCurrent(fields: ["id"]) { userResult in
switch userResult {
case let .success(user):
fulfill((client, user.id))
case .failure:
reject(BoxAuthenticatorError.authenticationFailed)
}
}
case .failure:
reject(BoxAuthenticatorError.authenticationFailed)
}
}
}
}
}