mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Automatically sign out when toggling the SSS feature flag. (#3071)
This commit is contained in:
@@ -7501,7 +7501,7 @@
|
|||||||
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
|
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = exactVersion;
|
kind = exactVersion;
|
||||||
version = 1.0.27;
|
version = 1.0.28;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
|
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
|
||||||
|
|||||||
@@ -149,8 +149,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
|
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "3a1f56a8dc2b14c93e562ece82fbf780d2f79704",
|
"revision" : "1a1cbc9d9d43a188d9b07fe00a141d02f7c43c7c",
|
||||||
"version" : "1.0.27"
|
"version" : "1.0.28"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ final class AppSettings {
|
|||||||
static func resetSessionSpecificSettings() {
|
static func resetSessionSpecificSettings() {
|
||||||
MXLog.warning("Resetting the user session specific AppSettings.")
|
MXLog.warning("Resetting the user session specific AppSettings.")
|
||||||
store.removeObject(forKey: UserDefaultsKeys.hasRunIdentityConfirmationOnboarding.rawValue)
|
store.removeObject(forKey: UserDefaultsKeys.hasRunIdentityConfirmationOnboarding.rawValue)
|
||||||
store.removeObject(forKey: UserDefaultsKeys.simplifiedSlidingSyncEnabled.rawValue)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static func configureWithSuiteName(_ name: String) {
|
static func configureWithSuiteName(_ name: String) {
|
||||||
|
|||||||
@@ -233,6 +233,8 @@ class SettingsFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
switch action {
|
switch action {
|
||||||
case .clearCache:
|
case .clearCache:
|
||||||
actionsSubject.send(.clearCache)
|
actionsSubject.send(.clearCache)
|
||||||
|
case .forceLogout:
|
||||||
|
actionsSubject.send(.forceLogout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|||||||
@@ -21,15 +21,20 @@ extension ClientBuilder {
|
|||||||
/// A helper method that applies the common builder modifiers needed for the app.
|
/// A helper method that applies the common builder modifiers needed for the app.
|
||||||
static func baseBuilder(setupEncryption: Bool = true,
|
static func baseBuilder(setupEncryption: Bool = true,
|
||||||
httpProxy: String? = nil,
|
httpProxy: String? = nil,
|
||||||
|
slidingSync: ClientBuilderSlidingSync,
|
||||||
slidingSyncProxy: URL? = nil,
|
slidingSyncProxy: URL? = nil,
|
||||||
sessionDelegate: ClientSessionDelegate,
|
sessionDelegate: ClientSessionDelegate,
|
||||||
simplifiedSlidingSyncEnabled: Bool,
|
|
||||||
appHooks: AppHooks) -> ClientBuilder {
|
appHooks: AppHooks) -> ClientBuilder {
|
||||||
var builder = ClientBuilder()
|
var builder = ClientBuilder()
|
||||||
.slidingSyncProxy(slidingSyncProxy: slidingSyncProxy?.absoluteString)
|
.slidingSyncProxy(slidingSyncProxy: slidingSyncProxy?.absoluteString)
|
||||||
.enableCrossProcessRefreshLock(processId: InfoPlistReader.main.bundleIdentifier, sessionDelegate: sessionDelegate)
|
.enableCrossProcessRefreshLock(processId: InfoPlistReader.main.bundleIdentifier, sessionDelegate: sessionDelegate)
|
||||||
.userAgent(userAgent: UserAgentBuilder.makeASCIIUserAgent())
|
.userAgent(userAgent: UserAgentBuilder.makeASCIIUserAgent())
|
||||||
.simplifiedSlidingSync(enable: simplifiedSlidingSyncEnabled)
|
|
||||||
|
builder = switch slidingSync {
|
||||||
|
case .restored: builder
|
||||||
|
case .discovered: builder.requiresSlidingSync()
|
||||||
|
case .simplified: builder.simplifiedSlidingSync(enable: true)
|
||||||
|
}
|
||||||
|
|
||||||
if setupEncryption {
|
if setupEncryption {
|
||||||
builder = builder
|
builder = builder
|
||||||
@@ -45,3 +50,12 @@ extension ClientBuilder {
|
|||||||
return appHooks.clientBuilderHook.configure(builder)
|
return appHooks.clientBuilderHook.configure(builder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ClientBuilderSlidingSync {
|
||||||
|
/// The proxy will be supplied when restoring the Session.
|
||||||
|
case restored
|
||||||
|
/// A proxy must be discovered whilst building the session.
|
||||||
|
case discovered
|
||||||
|
/// Use Simplified Sliding Sync (discovery isn't a thing yet).
|
||||||
|
case simplified
|
||||||
|
}
|
||||||
|
|||||||
+4
@@ -19,6 +19,8 @@ import SwiftUI
|
|||||||
|
|
||||||
enum DeveloperOptionsScreenCoordinatorAction {
|
enum DeveloperOptionsScreenCoordinatorAction {
|
||||||
case clearCache
|
case clearCache
|
||||||
|
/// Logout without a confirmation to avoid losing keys when trying SSS.
|
||||||
|
case forceLogout
|
||||||
}
|
}
|
||||||
|
|
||||||
final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
||||||
@@ -42,6 +44,8 @@ final class DeveloperOptionsScreenCoordinator: CoordinatorProtocol {
|
|||||||
switch action {
|
switch action {
|
||||||
case .clearCache:
|
case .clearCache:
|
||||||
actionsSubject.send(.clearCache)
|
actionsSubject.send(.clearCache)
|
||||||
|
case .forceLogout:
|
||||||
|
actionsSubject.send(.forceLogout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|||||||
+2
@@ -18,6 +18,8 @@ import Foundation
|
|||||||
|
|
||||||
enum DeveloperOptionsScreenViewModelAction {
|
enum DeveloperOptionsScreenViewModelAction {
|
||||||
case clearCache
|
case clearCache
|
||||||
|
/// Logout without a confirmation to avoid losing keys when trying SSS.
|
||||||
|
case forceLogout
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DeveloperOptionsScreenViewState: BindableState {
|
struct DeveloperOptionsScreenViewState: BindableState {
|
||||||
|
|||||||
+10
@@ -31,6 +31,16 @@ class DeveloperOptionsScreenViewModel: DeveloperOptionsScreenViewModelType, Deve
|
|||||||
let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, bindings: bindings)
|
let state = DeveloperOptionsScreenViewState(elementCallBaseURL: elementCallBaseURL, bindings: bindings)
|
||||||
|
|
||||||
super.init(initialViewState: state)
|
super.init(initialViewState: state)
|
||||||
|
|
||||||
|
context.$viewState
|
||||||
|
.map(\.bindings.simplifiedSlidingSyncEnabled)
|
||||||
|
.removeDuplicates()
|
||||||
|
.dropFirst() // Ignore the initial value received when opening the screen.
|
||||||
|
.sink { [weak self] isEnabled in
|
||||||
|
MXLog.error("Toggled simplifiedSlidingSyncEnabled: \(isEnabled). Signing out.")
|
||||||
|
self?.actionsSubject.send(.forceLogout)
|
||||||
|
}
|
||||||
|
.store(in: &cancellables)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func process(viewAction: DeveloperOptionsScreenViewAction) {
|
override func process(viewAction: DeveloperOptionsScreenViewAction) {
|
||||||
|
|||||||
+1
-1
@@ -30,7 +30,7 @@ struct DeveloperOptionsScreen: View {
|
|||||||
Section("Sliding Sync") {
|
Section("Sliding Sync") {
|
||||||
Toggle(isOn: $context.simplifiedSlidingSyncEnabled) {
|
Toggle(isOn: $context.simplifiedSlidingSyncEnabled) {
|
||||||
Text("Simplified Sliding Sync")
|
Text("Simplified Sliding Sync")
|
||||||
Text("Requires app reboot")
|
Text("When toggled you'll be logged out of the app and will need to log in again.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -141,13 +141,12 @@ class AuthenticationService: AuthenticationServiceProtocol {
|
|||||||
private func makeClientBuilder() -> ClientBuilder {
|
private func makeClientBuilder() -> ClientBuilder {
|
||||||
ClientBuilder
|
ClientBuilder
|
||||||
.baseBuilder(httpProxy: appSettings.websiteURL.globalProxy,
|
.baseBuilder(httpProxy: appSettings.websiteURL.globalProxy,
|
||||||
|
slidingSync: appSettings.simplifiedSlidingSyncEnabled ? .simplified : .discovered,
|
||||||
slidingSyncProxy: appSettings.slidingSyncProxyURL,
|
slidingSyncProxy: appSettings.slidingSyncProxyURL,
|
||||||
sessionDelegate: userSessionStore.clientSessionDelegate,
|
sessionDelegate: userSessionStore.clientSessionDelegate,
|
||||||
simplifiedSlidingSyncEnabled: appSettings.simplifiedSlidingSyncEnabled,
|
|
||||||
appHooks: appHooks)
|
appHooks: appHooks)
|
||||||
.sessionPath(path: sessionDirectory.path(percentEncoded: false))
|
.sessionPath(path: sessionDirectory.path(percentEncoded: false))
|
||||||
.passphrase(passphrase: passphrase)
|
.passphrase(passphrase: passphrase)
|
||||||
.requiresSlidingSync()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func userSession(for client: Client) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
|
private func userSession(for client: Client) async -> Result<UserSessionProtocol, AuthenticationServiceError> {
|
||||||
|
|||||||
@@ -59,13 +59,12 @@ final class QRCodeLoginService: QRCodeLoginServiceProtocol {
|
|||||||
do {
|
do {
|
||||||
let client = try await ClientBuilder
|
let client = try await ClientBuilder
|
||||||
.baseBuilder(httpProxy: appSettings.websiteURL.globalProxy,
|
.baseBuilder(httpProxy: appSettings.websiteURL.globalProxy,
|
||||||
|
slidingSync: appSettings.simplifiedSlidingSyncEnabled ? .simplified : .discovered,
|
||||||
slidingSyncProxy: appSettings.slidingSyncProxyURL,
|
slidingSyncProxy: appSettings.slidingSyncProxyURL,
|
||||||
sessionDelegate: userSessionStore.clientSessionDelegate,
|
sessionDelegate: userSessionStore.clientSessionDelegate,
|
||||||
simplifiedSlidingSyncEnabled: appSettings.simplifiedSlidingSyncEnabled,
|
|
||||||
appHooks: appHooks)
|
appHooks: appHooks)
|
||||||
.sessionPath(path: sessionDirectory.path(percentEncoded: false))
|
.sessionPath(path: sessionDirectory.path(percentEncoded: false))
|
||||||
.passphrase(passphrase: passphrase)
|
.passphrase(passphrase: passphrase)
|
||||||
.requiresSlidingSync()
|
|
||||||
.buildWithQrCode(qrCodeData: qrData, oidcConfiguration: appSettings.oidcConfiguration.rustValue, progressListener: listener)
|
.buildWithQrCode(qrCodeData: qrData, oidcConfiguration: appSettings.oidcConfiguration.rustValue, progressListener: listener)
|
||||||
return await login(client: client)
|
return await login(client: client)
|
||||||
} catch let error as HumanQrLoginError {
|
} catch let error as HumanQrLoginError {
|
||||||
|
|||||||
@@ -124,8 +124,8 @@ class UserSessionStore: UserSessionStoreProtocol {
|
|||||||
|
|
||||||
let builder = ClientBuilder
|
let builder = ClientBuilder
|
||||||
.baseBuilder(httpProxy: URL(string: homeserverURL)?.globalProxy,
|
.baseBuilder(httpProxy: URL(string: homeserverURL)?.globalProxy,
|
||||||
|
slidingSync: appSettings.simplifiedSlidingSyncEnabled ? .simplified : .restored,
|
||||||
sessionDelegate: keychainController,
|
sessionDelegate: keychainController,
|
||||||
simplifiedSlidingSyncEnabled: appSettings.simplifiedSlidingSyncEnabled,
|
|
||||||
appHooks: appHooks)
|
appHooks: appHooks)
|
||||||
.sessionPath(path: credentials.restorationToken.sessionDirectory.path(percentEncoded: false))
|
.sessionPath(path: credentials.restorationToken.sessionDirectory.path(percentEncoded: false))
|
||||||
.username(username: credentials.userID)
|
.username(username: credentials.userID)
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ final class NSEUserSession {
|
|||||||
let clientBuilder = ClientBuilder
|
let clientBuilder = ClientBuilder
|
||||||
.baseBuilder(setupEncryption: false,
|
.baseBuilder(setupEncryption: false,
|
||||||
httpProxy: URL(string: homeserverURL)?.globalProxy,
|
httpProxy: URL(string: homeserverURL)?.globalProxy,
|
||||||
|
slidingSync: simplifiedSlidingSyncEnabled ? .simplified : .restored,
|
||||||
sessionDelegate: clientSessionDelegate,
|
sessionDelegate: clientSessionDelegate,
|
||||||
simplifiedSlidingSyncEnabled: simplifiedSlidingSyncEnabled,
|
|
||||||
appHooks: appHooks)
|
appHooks: appHooks)
|
||||||
.sessionPath(path: credentials.restorationToken.sessionDirectory.path(percentEncoded: false))
|
.sessionPath(path: credentials.restorationToken.sessionDirectory.path(percentEncoded: false))
|
||||||
.username(username: credentials.userID)
|
.username(username: credentials.userID)
|
||||||
|
|||||||
+1
-1
@@ -60,7 +60,7 @@ packages:
|
|||||||
# Element/Matrix dependencies
|
# Element/Matrix dependencies
|
||||||
MatrixRustSDK:
|
MatrixRustSDK:
|
||||||
url: https://github.com/element-hq/matrix-rust-components-swift
|
url: https://github.com/element-hq/matrix-rust-components-swift
|
||||||
exactVersion: 1.0.27
|
exactVersion: 1.0.28
|
||||||
# path: ../matrix-rust-sdk
|
# path: ../matrix-rust-sdk
|
||||||
Compound:
|
Compound:
|
||||||
url: https://github.com/element-hq/compound-ios
|
url: https://github.com/element-hq/compound-ios
|
||||||
|
|||||||
Reference in New Issue
Block a user