mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Enable OIDC token refresh in the NSE. (#1711)
Update the SDK and handle API changes.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
import Foundation
|
||||
import KeychainAccess
|
||||
import MatrixRustSDK
|
||||
|
||||
enum KeychainControllerService: String {
|
||||
case sessions
|
||||
@@ -86,4 +87,20 @@ class KeychainController: KeychainControllerProtocol {
|
||||
MXLog.error("Failed removing all tokens")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - ClientSessionDelegate
|
||||
|
||||
func retrieveSessionFromKeychain(userId: String) throws -> Session {
|
||||
MXLog.info("Retrieving an updated Session from the keychain.")
|
||||
guard let session = restorationTokenForUsername(userId)?.session else {
|
||||
throw ClientError.Generic(msg: "Failed to find RestorationToken in the Keychain.")
|
||||
}
|
||||
return session
|
||||
}
|
||||
|
||||
func saveSessionInKeychain(session: Session) {
|
||||
MXLog.info("Saving session changes in the keychain.")
|
||||
let restorationToken = RestorationToken(session: session)
|
||||
setRestorationToken(restorationToken, forUsername: session.userId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
struct KeychainCredentials {
|
||||
let userID: String
|
||||
let restorationToken: RestorationToken
|
||||
}
|
||||
|
||||
protocol KeychainControllerProtocol {
|
||||
protocol KeychainControllerProtocol: ClientSessionDelegate {
|
||||
func setRestorationToken(_ restorationToken: RestorationToken, forUsername: String)
|
||||
func restorationTokenForUsername(_ username: String) -> RestorationToken?
|
||||
func restorationTokens() -> [KeychainCredentials]
|
||||
|
||||
Reference in New Issue
Block a user