Skip to content

Commit

Permalink
Merge pull request #333 from cryptomator/feature/hub-subscription-header
Browse files Browse the repository at this point in the history
Use hub subscription header
  • Loading branch information
tobihagemann authored Jan 16, 2024
2 parents 50fd566 + 7b2b97e commit 10511d4
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ public class CryptomatorHubAuthenticator: HubDeviceRegistering, HubKeyReceiving
webAppURL: webAppURL)

let encryptedVaultKey: String
let unlockHeader: [AnyHashable: Any]
switch retrieveMasterkeyResponse {
case let .success(key):
case let .success(key, header):
encryptedVaultKey = key
unlockHeader = header
case .accessNotGranted:
return .accessNotGranted
case .licenseExceeded:
Expand All @@ -93,7 +95,7 @@ public class CryptomatorHubAuthenticator: HubDeviceRegistering, HubKeyReceiving
let encryptedUserKeyJWE = try JWE(compactSerialization: encryptedUserKey)
let encryptedVaultKeyJWE = try JWE(compactSerialization: encryptedVaultKey)

return .success(.init(encryptedUserKey: encryptedUserKeyJWE, encryptedVaultKey: encryptedVaultKeyJWE, header: [:]))
return .success(.init(encryptedUserKey: encryptedUserKeyJWE, encryptedVaultKey: encryptedVaultKeyJWE, header: unlockHeader))
}

/**
Expand Down Expand Up @@ -240,7 +242,7 @@ public class CryptomatorHubAuthenticator: HubDeviceRegistering, HubKeyReceiving
guard let body = String(data: data, encoding: .utf8) else {
throw CryptomatorHubAuthenticatorError.unexpectedResponse
}
return .success(encryptedVaultKey: body)
return .success(encryptedVaultKey: body, header: httpResponse?.allHeaderFields ?? [:])
case 402:
return .licenseExceeded
case 403, 410:
Expand Down Expand Up @@ -299,7 +301,7 @@ public class CryptomatorHubAuthenticator: HubDeviceRegistering, HubKeyReceiving

private enum RetrieveVaultMasterkeyEncryptedForUserResponse {
// 200
case success(encryptedVaultKey: String)
case success(encryptedVaultKey: String, header: [AnyHashable: Any])
// 403, 410
case accessNotGranted
// 402
Expand Down

0 comments on commit 10511d4

Please sign in to comment.