Skip to content

Commit

Permalink
Add handling for legacy hub
Browse files Browse the repository at this point in the history
  • Loading branch information
phil1995 committed Dec 28, 2023
1 parent e523906 commit 7b98ba3
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public class CryptomatorHubAuthenticator: HubDeviceRegistering, HubKeyReceiving
return digest.data.base16EncodedString
}

/** Checks if the Cryptomator Hub Instance at `apiBaseURL` has at least the API level of `minimumLevel`.

- Note: The legacy Hub which is not supported returns a 0
*/
private func hubInstanceHasMinimumAPILevel(of minimumLevel: Int, apiBaseURL: URL, authState: OIDAuthState) async throws -> Bool {
let url = apiBaseURL.appendingPathComponent("config")
let (accessToken, _) = try await authState.performAction()
Expand Down Expand Up @@ -355,7 +359,13 @@ extension String {

extension HubConfig {
func getAPIBaseURL() -> URL? {
return URL(string: apiBaseUrl)
if let apiBaseUrl {
return URL(string: apiBaseUrl)
}
guard let deviceResourceURL = URL(string: devicesResourceUrl) else {
return nil
}
return deviceResourceURL.deletingLastPathComponent()
}

func getWebAppURL() -> URL? {
Expand Down

0 comments on commit 7b98ba3

Please sign in to comment.