mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Session verification fixes and bump SDK to v0.0.1-october23 (#1954)
* Fixes vector-im/element-x-ios/issues/1868 Incorrect `is_verified` flag after successfully running verification flow - the inner user_identity isn't automatically updated when the flow finishes, needs to be fetched again from encryption - also replaces `UserIdentity.is_verified` with `Device.is_cross_signed_by_owner` - depends on matrix-org/matrix-rust-sdk/pull/2775 --------- Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
@@ -6588,7 +6588,7 @@
|
|||||||
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
|
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
|
||||||
requirement = {
|
requirement = {
|
||||||
kind = exactVersion;
|
kind = exactVersion;
|
||||||
version = 1.1.26;
|
version = "0.0.1-october23";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = {
|
821C67C9A7F8CC3FD41B28B4 /* XCRemoteSwiftPackageReference "emojibase-bindings" */ = {
|
||||||
|
|||||||
@@ -129,8 +129,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
|
"location" : "https://github.com/matrix-org/matrix-rust-components-swift",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "e7bacee684806d125077b032e3848189ad370f3b",
|
"revision" : "f53f5302ddcd81e4134fa7437fedd5c33cd7c1bf",
|
||||||
"version" : "1.1.26"
|
"version" : "0.0.1-october23"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -262,7 +262,7 @@
|
|||||||
{
|
{
|
||||||
"identity" : "swiftui-introspect",
|
"identity" : "swiftui-introspect",
|
||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
|
"location" : "https://github.com/siteline/SwiftUI-Introspect",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "b94da693e57eaf79d16464b8b7c90d09cba4e290",
|
"revision" : "b94da693e57eaf79d16464b8b7c90d09cba4e290",
|
||||||
"version" : "0.9.2"
|
"version" : "0.9.2"
|
||||||
|
|||||||
@@ -2704,12 +2704,24 @@ class SessionVerificationControllerProxyMock: SessionVerificationControllerProxy
|
|||||||
set(value) { underlyingCallbacks = value }
|
set(value) { underlyingCallbacks = value }
|
||||||
}
|
}
|
||||||
var underlyingCallbacks: PassthroughSubject<SessionVerificationControllerProxyCallback, Never>!
|
var underlyingCallbacks: PassthroughSubject<SessionVerificationControllerProxyCallback, Never>!
|
||||||
var isVerified: Bool {
|
|
||||||
get { return underlyingIsVerified }
|
|
||||||
set(value) { underlyingIsVerified = value }
|
|
||||||
}
|
|
||||||
var underlyingIsVerified: Bool!
|
|
||||||
|
|
||||||
|
//MARK: - isVerified
|
||||||
|
|
||||||
|
var isVerifiedCallsCount = 0
|
||||||
|
var isVerifiedCalled: Bool {
|
||||||
|
return isVerifiedCallsCount > 0
|
||||||
|
}
|
||||||
|
var isVerifiedReturnValue: Result<Bool, SessionVerificationControllerProxyError>!
|
||||||
|
var isVerifiedClosure: (() async -> Result<Bool, SessionVerificationControllerProxyError>)?
|
||||||
|
|
||||||
|
func isVerified() async -> Result<Bool, SessionVerificationControllerProxyError> {
|
||||||
|
isVerifiedCallsCount += 1
|
||||||
|
if let isVerifiedClosure = isVerifiedClosure {
|
||||||
|
return await isVerifiedClosure()
|
||||||
|
} else {
|
||||||
|
return isVerifiedReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
//MARK: - requestVerification
|
//MARK: - requestVerification
|
||||||
|
|
||||||
var requestVerificationCallsCount = 0
|
var requestVerificationCallsCount = 0
|
||||||
|
|||||||
@@ -165,6 +165,23 @@ class SDKClientMock: SDKClientProtocol {
|
|||||||
return displayNameReturnValue
|
return displayNameReturnValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//MARK: - encryption
|
||||||
|
|
||||||
|
public var encryptionCallsCount = 0
|
||||||
|
public var encryptionCalled: Bool {
|
||||||
|
return encryptionCallsCount > 0
|
||||||
|
}
|
||||||
|
public var encryptionReturnValue: Encryption!
|
||||||
|
public var encryptionClosure: (() -> Encryption)?
|
||||||
|
|
||||||
|
public func encryption() -> Encryption {
|
||||||
|
encryptionCallsCount += 1
|
||||||
|
if let encryptionClosure = encryptionClosure {
|
||||||
|
return encryptionClosure()
|
||||||
|
} else {
|
||||||
|
return encryptionReturnValue
|
||||||
|
}
|
||||||
|
}
|
||||||
//MARK: - getDmRoom
|
//MARK: - getDmRoom
|
||||||
|
|
||||||
public var getDmRoomUserIdThrowableError: Error?
|
public var getDmRoomUserIdThrowableError: Error?
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ extension SessionVerificationControllerProxyMock {
|
|||||||
requestDelay: Duration = .seconds(1)) -> SessionVerificationControllerProxyMock {
|
requestDelay: Duration = .seconds(1)) -> SessionVerificationControllerProxyMock {
|
||||||
let mock = SessionVerificationControllerProxyMock()
|
let mock = SessionVerificationControllerProxyMock()
|
||||||
mock.underlyingCallbacks = callbacks
|
mock.underlyingCallbacks = callbacks
|
||||||
mock.underlyingIsVerified = isVerified
|
mock.isVerifiedReturnValue = .success(isVerified)
|
||||||
|
|
||||||
mock.requestVerificationClosure = { [unowned mock] in
|
mock.requestVerificationClosure = { [unowned mock] in
|
||||||
Task.detached {
|
Task.detached {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ struct SettingsScreenViewState: BindableState {
|
|||||||
var accountSessionsListURL: URL?
|
var accountSessionsListURL: URL?
|
||||||
var userAvatarURL: URL?
|
var userAvatarURL: URL?
|
||||||
var userDisplayName: String?
|
var userDisplayName: String?
|
||||||
var isSessionVerified: Bool
|
var isSessionVerified = false
|
||||||
var chatBackupEnabled = false
|
var chatBackupEnabled = false
|
||||||
var showSecureBackupBadge = false
|
var showSecureBackupBadge = false
|
||||||
var showAppLockSettings: Bool
|
var showAppLockSettings: Bool
|
||||||
|
|||||||
@@ -33,16 +33,10 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
|||||||
self.userSession = userSession
|
self.userSession = userSession
|
||||||
self.appSettings = appSettings
|
self.appSettings = appSettings
|
||||||
|
|
||||||
var isSessionVerified = true
|
|
||||||
if let sessionVerificationController = userSession.sessionVerificationController {
|
|
||||||
isSessionVerified = sessionVerificationController.isVerified
|
|
||||||
}
|
|
||||||
|
|
||||||
super.init(initialViewState: .init(deviceID: userSession.deviceID,
|
super.init(initialViewState: .init(deviceID: userSession.deviceID,
|
||||||
userID: userSession.userID,
|
userID: userSession.userID,
|
||||||
accountProfileURL: userSession.clientProxy.accountURL(action: .profile),
|
accountProfileURL: userSession.clientProxy.accountURL(action: .profile),
|
||||||
accountSessionsListURL: userSession.clientProxy.accountURL(action: .sessionsList),
|
accountSessionsListURL: userSession.clientProxy.accountURL(action: .sessionsList),
|
||||||
isSessionVerified: isSessionVerified,
|
|
||||||
showAppLockSettings: appSettings.appLockFlowEnabled,
|
showAppLockSettings: appSettings.appLockFlowEnabled,
|
||||||
showDeveloperOptions: appSettings.canShowDeveloperOptions),
|
showDeveloperOptions: appSettings.canShowDeveloperOptions),
|
||||||
imageProvider: userSession.mediaProvider)
|
imageProvider: userSession.mediaProvider)
|
||||||
@@ -77,6 +71,11 @@ class SettingsScreenViewModel: SettingsScreenViewModelType, SettingsScreenViewMo
|
|||||||
Task {
|
Task {
|
||||||
await userSession.clientProxy.loadUserAvatarURL()
|
await userSession.clientProxy.loadUserAvatarURL()
|
||||||
await userSession.clientProxy.loadUserDisplayName()
|
await userSession.clientProxy.loadUserDisplayName()
|
||||||
|
|
||||||
|
if let sessionVerificationController = userSession.sessionVerificationController,
|
||||||
|
case let .success(isVerified) = await sessionVerificationController.isVerified() {
|
||||||
|
state.isSessionVerified = isVerified
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
userSession.callbacks
|
userSession.callbacks
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ private extension TimelineStyle {
|
|||||||
struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
|
struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||||
static let viewModel = {
|
static let viewModel = {
|
||||||
let verificationController = SessionVerificationControllerProxyMock()
|
let verificationController = SessionVerificationControllerProxyMock()
|
||||||
verificationController.isVerified = false
|
verificationController.isVerifiedReturnValue = .success(false)
|
||||||
let userSession = MockUserSession(sessionVerificationController: verificationController,
|
let userSession = MockUserSession(sessionVerificationController: verificationController,
|
||||||
clientProxy: MockClientProxy(userID: "@userid:example.com",
|
clientProxy: MockClientProxy(userID: "@userid:example.com",
|
||||||
deviceID: "AAAAAAAAAAA"),
|
deviceID: "AAAAAAAAAAA"),
|
||||||
|
|||||||
@@ -57,9 +57,14 @@ class UserSession: UserSessionProtocol {
|
|||||||
Task {
|
Task {
|
||||||
switch await clientProxy.sessionVerificationControllerProxy() {
|
switch await clientProxy.sessionVerificationControllerProxy() {
|
||||||
case .success(let sessionVerificationController):
|
case .success(let sessionVerificationController):
|
||||||
|
guard case let .success(isVerified) = await sessionVerificationController.isVerified() else {
|
||||||
|
MXLog.error("Failed checking verification state. Will retry on the next sync update.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
tearDownSessionVerificationControllerWatchdog()
|
tearDownSessionVerificationControllerWatchdog()
|
||||||
|
|
||||||
if !sessionVerificationController.isVerified {
|
if !isVerified {
|
||||||
callbacks.send(.sessionVerificationNeeded)
|
callbacks.send(.sessionVerificationNeeded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-2
@@ -65,8 +65,13 @@ class SessionVerificationControllerProxy: SessionVerificationControllerProxyProt
|
|||||||
|
|
||||||
let callbacks = PassthroughSubject<SessionVerificationControllerProxyCallback, Never>()
|
let callbacks = PassthroughSubject<SessionVerificationControllerProxyCallback, Never>()
|
||||||
|
|
||||||
var isVerified: Bool {
|
func isVerified() async -> Result<Bool, SessionVerificationControllerProxyError> {
|
||||||
sessionVerificationController.isVerified()
|
do {
|
||||||
|
let result = try await sessionVerificationController.isVerified()
|
||||||
|
return .success(result)
|
||||||
|
} catch {
|
||||||
|
return .failure(.failedCheckingVerificationState)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestVerification() async -> Result<Void, SessionVerificationControllerProxyError> {
|
func requestVerification() async -> Result<Void, SessionVerificationControllerProxyError> {
|
||||||
|
|||||||
+2
-1
@@ -18,6 +18,7 @@ import Combine
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum SessionVerificationControllerProxyError: Error {
|
enum SessionVerificationControllerProxyError: Error {
|
||||||
|
case failedCheckingVerificationState
|
||||||
case failedRequestingVerification
|
case failedRequestingVerification
|
||||||
case failedStartingSasVerification
|
case failedStartingSasVerification
|
||||||
case failedApprovingVerification
|
case failedApprovingVerification
|
||||||
@@ -43,7 +44,7 @@ struct SessionVerificationEmoji: Hashable {
|
|||||||
protocol SessionVerificationControllerProxyProtocol {
|
protocol SessionVerificationControllerProxyProtocol {
|
||||||
var callbacks: PassthroughSubject<SessionVerificationControllerProxyCallback, Never> { get }
|
var callbacks: PassthroughSubject<SessionVerificationControllerProxyCallback, Never> { get }
|
||||||
|
|
||||||
var isVerified: Bool { get }
|
func isVerified() async -> Result<Bool, SessionVerificationControllerProxyError>
|
||||||
|
|
||||||
func requestVerification() async -> Result<Void, SessionVerificationControllerProxyError>
|
func requestVerification() async -> Result<Void, SessionVerificationControllerProxyError>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ packages:
|
|||||||
# Element/Matrix dependencies
|
# Element/Matrix dependencies
|
||||||
MatrixRustSDK:
|
MatrixRustSDK:
|
||||||
url: https://github.com/matrix-org/matrix-rust-components-swift
|
url: https://github.com/matrix-org/matrix-rust-components-swift
|
||||||
exactVersion: 1.1.26
|
exactVersion: 0.0.1-october23
|
||||||
# path: ../matrix-rust-sdk
|
# path: ../matrix-rust-sdk
|
||||||
Compound:
|
Compound:
|
||||||
url: https://github.com/vector-im/compound-ios
|
url: https://github.com/vector-im/compound-ios
|
||||||
|
|||||||
Reference in New Issue
Block a user