mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Expose the store passphrase as Data instead of a base64 string.
This commit is contained in:
@@ -16,7 +16,7 @@ enum RestorationTokenError: Error {
|
||||
nonisolated struct RestorationToken: Equatable {
|
||||
let session: MatrixRustSDK.Session
|
||||
let sessionDirectories: SessionDirectories
|
||||
let passphrase: String
|
||||
let passphrase: Data
|
||||
let pusherNotificationClientIdentifier: String?
|
||||
|
||||
enum CodingKeys: CodingKey {
|
||||
@@ -42,9 +42,14 @@ nonisolated extension RestorationToken: Codable {
|
||||
SessionDirectories(dataDirectory: dataDirectory)
|
||||
}
|
||||
|
||||
let base64Passphrase = try container.decode(String.self, forKey: .passphrase)
|
||||
guard let passphrase = Data(base64Encoded: base64Passphrase) else {
|
||||
throw DecodingError.dataCorruptedError(forKey: .passphrase, in: container, debugDescription: "The passphrase isn't valid base64.")
|
||||
}
|
||||
|
||||
self = try .init(session: session,
|
||||
sessionDirectories: sessionDirectories,
|
||||
passphrase: container.decode(String.self, forKey: .passphrase),
|
||||
passphrase: passphrase,
|
||||
pusherNotificationClientIdentifier: container.decodeIfPresent(String.self, forKey: .pusherNotificationClientIdentifier))
|
||||
}
|
||||
|
||||
@@ -53,7 +58,7 @@ nonisolated extension RestorationToken: Codable {
|
||||
try container.encode(session, forKey: .session)
|
||||
try container.encode(sessionDirectories.dataDirectory, forKey: .sessionDirectory)
|
||||
try container.encode(sessionDirectories.cacheDirectory, forKey: .cacheDirectory)
|
||||
try container.encode(passphrase, forKey: .passphrase)
|
||||
try container.encode(passphrase.base64EncodedString(), forKey: .passphrase)
|
||||
try container.encode(pusherNotificationClientIdentifier, forKey: .pusherNotificationClientIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class UserSessionStore: UserSessionStoreProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func userSession(for client: ClientProtocol, sessionDirectories: SessionDirectories, passphrase: String) async -> Result<UserSessionProtocol, UserSessionStoreError> {
|
||||
func userSession(for client: ClientProtocol, sessionDirectories: SessionDirectories, passphrase: Data) async -> Result<UserSessionProtocol, UserSessionStoreError> {
|
||||
do {
|
||||
let session = try client.session()
|
||||
let userID = try client.userId()
|
||||
|
||||
@@ -34,7 +34,7 @@ protocol UserSessionStoreProtocol {
|
||||
func restoreUserSession() async -> Result<UserSessionProtocol, UserSessionStoreError>
|
||||
|
||||
/// Creates a user session for a new client from the SDK along with the passphrase used for the data stores.
|
||||
func userSession(for client: ClientProtocol, sessionDirectories: SessionDirectories, passphrase: String) async -> Result<UserSessionProtocol, UserSessionStoreError>
|
||||
func userSession(for client: ClientProtocol, sessionDirectories: SessionDirectories, passphrase: Data) async -> Result<UserSessionProtocol, UserSessionStoreError>
|
||||
|
||||
/// Logs out of the specified session.
|
||||
func logout(userSession: UserSessionProtocol)
|
||||
|
||||
Reference in New Issue
Block a user