Add support for initiating and responding to user verification requests (#3759)

This commit is contained in:
Stefan Ceriu
2025-02-10 20:07:11 +02:00
committed by GitHub
parent 22d0fae423
commit 8680d8437b
94 changed files with 528 additions and 208 deletions
+1 -1
View File
@@ -8509,7 +8509,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 = 25.02.06; version = 25.02.07;
}; };
}; };
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" : "355364952fdd14a3e26b317180af89c79f9e03a5", "revision" : "bc819f09ac66bbe1adc2fde2afeb7ab023d1b909",
"version" : "25.2.6" "version" : "25.2.7"
} }
}, },
{ {
@@ -278,7 +278,9 @@ class OnboardingFlowCoordinator: FlowCoordinatorProtocol {
} }
let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController, let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController,
flow: .initiator) flow: .deviceInitiator,
appSettings: appSettings,
mediaProvider: userSession.mediaProvider)
let coordinator = SessionVerificationScreenCoordinator(parameters: parameters) let coordinator = SessionVerificationScreenCoordinator(parameters: parameters)
@@ -12,6 +12,7 @@ import UserNotifications
enum RoomFlowCoordinatorAction: Equatable { enum RoomFlowCoordinatorAction: Equatable {
case presentCallScreen(roomProxy: JoinedRoomProxyProtocol) case presentCallScreen(roomProxy: JoinedRoomProxyProtocol)
case verifyUser(userID: String)
case finished case finished
static func == (lhs: RoomFlowCoordinatorAction, rhs: RoomFlowCoordinatorAction) -> Bool { static func == (lhs: RoomFlowCoordinatorAction, rhs: RoomFlowCoordinatorAction) -> Bool {
@@ -1247,6 +1248,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.tryEvent(.startChildFlow(roomID: roomID, via: [], entryPoint: .room)) stateMachine.tryEvent(.startChildFlow(roomID: roomID, via: [], entryPoint: .room))
case .startCall(let roomID): case .startCall(let roomID):
Task { await self.presentCallScreen(roomID: roomID) } Task { await self.presentCallScreen(roomID: roomID) }
case .verifyUser(let userID):
actionsSubject.send(.verifyUser(userID: userID))
} }
} }
.store(in: &cancellables) .store(in: &cancellables)
@@ -1272,6 +1275,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.tryEvent(.startChildFlow(roomID: roomID, via: [], entryPoint: .room)) stateMachine.tryEvent(.startChildFlow(roomID: roomID, via: [], entryPoint: .room))
case .startCall(let roomID): case .startCall(let roomID):
Task { await self.presentCallScreen(roomID: roomID) } Task { await self.presentCallScreen(roomID: roomID) }
case .verifyUser(let userID):
actionsSubject.send(.verifyUser(userID: userID))
case .dismiss: case .dismiss:
break // Not supported when pushed. break // Not supported when pushed.
} }
@@ -1530,6 +1535,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
switch action { switch action {
case .presentCallScreen(let roomProxy): case .presentCallScreen(let roomProxy):
actionsSubject.send(.presentCallScreen(roomProxy: roomProxy)) actionsSubject.send(.presentCallScreen(roomProxy: roomProxy))
case .verifyUser(let userID):
actionsSubject.send(.verifyUser(userID: userID))
case .finished: case .finished:
stateMachine.tryEvent(.dismissChildFlow) stateMachine.tryEvent(.dismissChildFlow)
} }
@@ -440,18 +440,26 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
MXLog.info("Received session verification request") MXLog.info("Received session verification request")
presentSessionVerificationScreen(details: details) if details.senderProfile.userID == userSession.clientProxy.userID {
presentSessionVerificationScreen(flow: .deviceResponder(requestDetails: details))
} else {
presentSessionVerificationScreen(flow: .userResponder(requestDetails: details))
}
} }
.store(in: &cancellables) .store(in: &cancellables)
} }
private func presentSessionVerificationScreen(details: SessionVerificationRequestDetails) { private func presentSessionVerificationScreen(flow: SessionVerificationScreenFlow) {
guard let sessionVerificationController = userSession.clientProxy.sessionVerificationController else { guard let sessionVerificationController = userSession.clientProxy.sessionVerificationController else {
fatalError("The sessionVerificationController should aways be valid at this point") fatalError("The sessionVerificationController should aways be valid at this point")
} }
let navigationStackCoordinator = NavigationStackCoordinator()
let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController, let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationController,
flow: .responder(details: details)) flow: flow,
appSettings: appSettings,
mediaProvider: userSession.mediaProvider)
let coordinator = SessionVerificationScreenCoordinator(parameters: parameters) let coordinator = SessionVerificationScreenCoordinator(parameters: parameters)
@@ -464,7 +472,9 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
} }
.store(in: &cancellables) .store(in: &cancellables)
navigationSplitCoordinator.setSheetCoordinator(coordinator) navigationStackCoordinator.setRootCoordinator(coordinator)
navigationSplitCoordinator.setSheetCoordinator(navigationStackCoordinator)
} }
private func presentHomeScreen() { private func presentHomeScreen() {
@@ -590,6 +600,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
case .presentCallScreen(let roomProxy): case .presentCallScreen(let roomProxy):
// Here we assume that the app is running and the call state is already up to date // Here we assume that the app is running and the call state is already up to date
presentCallScreen(roomProxy: roomProxy, notifyOtherParticipants: !roomProxy.infoPublisher.value.hasRoomCall) presentCallScreen(roomProxy: roomProxy, notifyOtherParticipants: !roomProxy.infoPublisher.value.hasRoomCall)
case .verifyUser(let userID):
presentSessionVerificationScreen(flow: .userIntiator(userID: userID))
case .finished: case .finished:
stateMachine.processEvent(.deselectRoom) stateMachine.processEvent(.deselectRoom)
} }
@@ -911,6 +923,8 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.processEvent(.selectRoom(roomID: roomID, via: [], entryPoint: .room)) stateMachine.processEvent(.selectRoom(roomID: roomID, via: [], entryPoint: .room))
case .startCall(let roomID): case .startCall(let roomID):
Task { await self.presentCallScreen(roomID: roomID, notifyOtherParticipants: false) } Task { await self.presentCallScreen(roomID: roomID, notifyOtherParticipants: false) }
case .verifyUser(let userID):
presentSessionVerificationScreen(flow: .userIntiator(userID: userID))
case .dismiss: case .dismiss:
navigationSplitCoordinator.setSheetCoordinator(nil) navigationSplitCoordinator.setSheetCoordinator(nil)
} }
@@ -14105,17 +14105,17 @@ class SessionVerificationControllerProxyMock: SessionVerificationControllerProxy
return acceptVerificationRequestReturnValue return acceptVerificationRequestReturnValue
} }
} }
//MARK: - requestVerification //MARK: - requestDeviceVerification
var requestVerificationUnderlyingCallsCount = 0 var requestDeviceVerificationUnderlyingCallsCount = 0
var requestVerificationCallsCount: Int { var requestDeviceVerificationCallsCount: Int {
get { get {
if Thread.isMainThread { if Thread.isMainThread {
return requestVerificationUnderlyingCallsCount return requestDeviceVerificationUnderlyingCallsCount
} else { } else {
var returnValue: Int? = nil var returnValue: Int? = nil
DispatchQueue.main.sync { DispatchQueue.main.sync {
returnValue = requestVerificationUnderlyingCallsCount returnValue = requestDeviceVerificationUnderlyingCallsCount
} }
return returnValue! return returnValue!
@@ -14123,27 +14123,27 @@ class SessionVerificationControllerProxyMock: SessionVerificationControllerProxy
} }
set { set {
if Thread.isMainThread { if Thread.isMainThread {
requestVerificationUnderlyingCallsCount = newValue requestDeviceVerificationUnderlyingCallsCount = newValue
} else { } else {
DispatchQueue.main.sync { DispatchQueue.main.sync {
requestVerificationUnderlyingCallsCount = newValue requestDeviceVerificationUnderlyingCallsCount = newValue
} }
} }
} }
} }
var requestVerificationCalled: Bool { var requestDeviceVerificationCalled: Bool {
return requestVerificationCallsCount > 0 return requestDeviceVerificationCallsCount > 0
} }
var requestVerificationUnderlyingReturnValue: Result<Void, SessionVerificationControllerProxyError>! var requestDeviceVerificationUnderlyingReturnValue: Result<Void, SessionVerificationControllerProxyError>!
var requestVerificationReturnValue: Result<Void, SessionVerificationControllerProxyError>! { var requestDeviceVerificationReturnValue: Result<Void, SessionVerificationControllerProxyError>! {
get { get {
if Thread.isMainThread { if Thread.isMainThread {
return requestVerificationUnderlyingReturnValue return requestDeviceVerificationUnderlyingReturnValue
} else { } else {
var returnValue: Result<Void, SessionVerificationControllerProxyError>? = nil var returnValue: Result<Void, SessionVerificationControllerProxyError>? = nil
DispatchQueue.main.sync { DispatchQueue.main.sync {
returnValue = requestVerificationUnderlyingReturnValue returnValue = requestDeviceVerificationUnderlyingReturnValue
} }
return returnValue! return returnValue!
@@ -14151,22 +14151,92 @@ class SessionVerificationControllerProxyMock: SessionVerificationControllerProxy
} }
set { set {
if Thread.isMainThread { if Thread.isMainThread {
requestVerificationUnderlyingReturnValue = newValue requestDeviceVerificationUnderlyingReturnValue = newValue
} else { } else {
DispatchQueue.main.sync { DispatchQueue.main.sync {
requestVerificationUnderlyingReturnValue = newValue requestDeviceVerificationUnderlyingReturnValue = newValue
} }
} }
} }
} }
var requestVerificationClosure: (() async -> Result<Void, SessionVerificationControllerProxyError>)? var requestDeviceVerificationClosure: (() async -> Result<Void, SessionVerificationControllerProxyError>)?
func requestVerification() async -> Result<Void, SessionVerificationControllerProxyError> { func requestDeviceVerification() async -> Result<Void, SessionVerificationControllerProxyError> {
requestVerificationCallsCount += 1 requestDeviceVerificationCallsCount += 1
if let requestVerificationClosure = requestVerificationClosure { if let requestDeviceVerificationClosure = requestDeviceVerificationClosure {
return await requestVerificationClosure() return await requestDeviceVerificationClosure()
} else { } else {
return requestVerificationReturnValue return requestDeviceVerificationReturnValue
}
}
//MARK: - requestUserVerification
var requestUserVerificationUnderlyingCallsCount = 0
var requestUserVerificationCallsCount: Int {
get {
if Thread.isMainThread {
return requestUserVerificationUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = requestUserVerificationUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
requestUserVerificationUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
requestUserVerificationUnderlyingCallsCount = newValue
}
}
}
}
var requestUserVerificationCalled: Bool {
return requestUserVerificationCallsCount > 0
}
var requestUserVerificationReceivedUserID: String?
var requestUserVerificationReceivedInvocations: [String] = []
var requestUserVerificationUnderlyingReturnValue: Result<Void, SessionVerificationControllerProxyError>!
var requestUserVerificationReturnValue: Result<Void, SessionVerificationControllerProxyError>! {
get {
if Thread.isMainThread {
return requestUserVerificationUnderlyingReturnValue
} else {
var returnValue: Result<Void, SessionVerificationControllerProxyError>? = nil
DispatchQueue.main.sync {
returnValue = requestUserVerificationUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
requestUserVerificationUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
requestUserVerificationUnderlyingReturnValue = newValue
}
}
}
}
var requestUserVerificationClosure: ((String) async -> Result<Void, SessionVerificationControllerProxyError>)?
func requestUserVerification(_ userID: String) async -> Result<Void, SessionVerificationControllerProxyError> {
requestUserVerificationCallsCount += 1
requestUserVerificationReceivedUserID = userID
DispatchQueue.main.async {
self.requestUserVerificationReceivedInvocations.append(userID)
}
if let requestUserVerificationClosure = requestUserVerificationClosure {
return await requestUserVerificationClosure(userID)
} else {
return requestUserVerificationReturnValue
} }
} }
//MARK: - startSasVerification //MARK: - startSasVerification
@@ -24,7 +24,7 @@ extension SessionVerificationControllerProxyMock {
mock.acknowledgeVerificationRequestDetailsReturnValue = .success(()) mock.acknowledgeVerificationRequestDetailsReturnValue = .success(())
mock.requestVerificationClosure = { [unowned mock] in mock.requestDeviceVerificationClosure = { [unowned mock] in
Task.detached { Task.detached {
try await Task.sleep(for: requestDelay) try await Task.sleep(for: requestDelay)
mock.actions.send(.acceptedVerificationRequest) mock.actions.send(.acceptedVerificationRequest)
+3
View File
@@ -77,6 +77,7 @@ enum UserAvatarSizeOnScreen {
case knockingUserList case knockingUserList
case mediaPreviewDetails case mediaPreviewDetails
case sendInviteConfirmation case sendInviteConfirmation
case sessionVerification
var value: CGFloat { var value: CGFloat {
switch self { switch self {
@@ -116,6 +117,8 @@ enum UserAvatarSizeOnScreen {
return 32 return 32
case .sendInviteConfirmation: case .sendInviteConfirmation:
return 64 return 64
case .sessionVerification:
return 52
} }
} }
} }
@@ -14,13 +14,26 @@ enum SessionVerificationScreenCoordinatorAction {
} }
enum SessionVerificationScreenFlow { enum SessionVerificationScreenFlow {
case initiator case deviceInitiator
case responder(details: SessionVerificationRequestDetails) case deviceResponder(requestDetails: SessionVerificationRequestDetails)
case userIntiator(userID: String)
case userResponder(requestDetails: SessionVerificationRequestDetails)
var isResponder: Bool {
switch self {
case .deviceInitiator, .userIntiator:
false
case .deviceResponder, .userResponder:
true
}
}
} }
struct SessionVerificationScreenCoordinatorParameters { struct SessionVerificationScreenCoordinatorParameters {
let sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol let sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol
let flow: SessionVerificationScreenFlow let flow: SessionVerificationScreenFlow
let appSettings: AppSettings
let mediaProvider: MediaProviderProtocol
} }
final class SessionVerificationScreenCoordinator: CoordinatorProtocol { final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
@@ -35,7 +48,9 @@ final class SessionVerificationScreenCoordinator: CoordinatorProtocol {
init(parameters: SessionVerificationScreenCoordinatorParameters) { init(parameters: SessionVerificationScreenCoordinatorParameters) {
viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: parameters.sessionVerificationControllerProxy, viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: parameters.sessionVerificationControllerProxy,
flow: parameters.flow) flow: parameters.flow,
appSettings: parameters.appSettings,
mediaProvider: parameters.mediaProvider)
} }
// MARK: - Public // MARK: - Public
@@ -20,17 +20,25 @@ enum SessionVerificationScreenViewAction {
case restart case restart
case accept case accept
case decline case decline
case cancel
case done case done
} }
struct SessionVerificationScreenViewState: BindableState { struct SessionVerificationScreenViewState: BindableState {
let flow: SessionVerificationScreenFlow let flow: SessionVerificationScreenFlow
let learnMoreURL: URL
var verificationState: SessionVerificationScreenStateMachine.State var verificationState: SessionVerificationScreenStateMachine.State
var headerIcon: (keyPath: KeyPath<CompoundIcons, Image>, style: BigIcon.Style) { var headerIcon: (keyPath: KeyPath<CompoundIcons, Image>, style: BigIcon.Style) {
switch verificationState { switch verificationState {
case .initial: case .initial:
switch flow {
case .deviceInitiator, .deviceResponder:
return (\.devices, .defaultSolid) return (\.devices, .defaultSolid)
case .userIntiator, .userResponder:
return (\.userProfileSolid, .defaultSolid)
}
case .acceptingVerificationRequest: case .acceptingVerificationRequest:
return (\.devices, .defaultSolid) return (\.devices, .defaultSolid)
case .requestingVerification: case .requestingVerification:
@@ -56,25 +64,31 @@ struct SessionVerificationScreenViewState: BindableState {
} }
} }
var titleAccessibilityIdentifier: String {
verificationState == .verified ? A11yIdentifiers.sessionVerificationScreen.verificationComplete : ""
}
var title: String? { var title: String? {
switch verificationState { switch verificationState {
case .initial: case .initial:
switch flow { switch flow {
case .initiator: case .deviceInitiator:
return L10n.screenSessionVerificationUseAnotherDeviceTitle return L10n.screenSessionVerificationUseAnotherDeviceTitle
case .responder: case .userIntiator:
return L10n.screenSessionVerificationUserInitiatorTitle
case .deviceResponder, .userResponder:
return L10n.screenSessionVerificationRequestTitle return L10n.screenSessionVerificationRequestTitle
} }
case .acceptingVerificationRequest: case .acceptingVerificationRequest:
return L10n.screenSessionVerificationWaitingAnotherDeviceTitle return waitingTitle
case .requestingVerification: case .requestingVerification:
return L10n.screenSessionVerificationWaitingToAcceptTitle return waitingTitle
case .verificationRequestAccepted: case .verificationRequestAccepted:
return L10n.screenSessionVerificationCompareEmojisTitle return L10n.screenSessionVerificationCompareEmojisTitle
case .startingSasVerification: case .startingSasVerification:
return nil return waitingTitle
case .sasVerificationStarted: case .sasVerificationStarted:
return nil return waitingTitle
case .showingChallenge: case .showingChallenge:
return L10n.screenSessionVerificationCompareEmojisTitle return L10n.screenSessionVerificationCompareEmojisTitle
case .acceptingChallenge: case .acceptingChallenge:
@@ -84,47 +98,71 @@ struct SessionVerificationScreenViewState: BindableState {
case .verified: case .verified:
return L10n.commonVerificationComplete return L10n.commonVerificationComplete
case .cancelling: case .cancelling:
return nil return waitingTitle
case .cancelled: case .cancelled:
return L10n.commonVerificationFailed return L10n.commonVerificationFailed
} }
} }
var titleAccessibilityIdentifier: String { private var waitingTitle: String {
verificationState == .verified ? A11yIdentifiers.sessionVerificationScreen.verificationComplete : "" switch flow {
case .deviceInitiator, .deviceResponder:
return L10n.screenSessionVerificationWaitingOtherDeviceTitle
case .userIntiator, .userResponder:
return L10n.screenSessionVerificationWaitingOtherUserTitle
}
} }
var message: String { var message: String {
switch verificationState { switch verificationState {
case .initial: case .initial:
switch flow { switch flow {
case .initiator: case .deviceInitiator:
return L10n.screenSessionVerificationUseAnotherDeviceSubtitle return L10n.screenSessionVerificationUseAnotherDeviceSubtitle
case .responder: case .userIntiator:
return L10n.screenSessionVerificationUserInitiatorSubtitle
case .deviceResponder:
return L10n.screenSessionVerificationRequestSubtitle return L10n.screenSessionVerificationRequestSubtitle
case .userResponder:
return L10n.screenSessionVerificationUserResponderSubtitle
} }
case .acceptingVerificationRequest: case .acceptingVerificationRequest:
return L10n.screenSessionVerificationWaitingAnotherDeviceSubtitle return waitingMessage
case .requestingVerification: case .requestingVerification:
return L10n.screenSessionVerificationWaitingToAcceptSubtitle return waitingMessage
case .verificationRequestAccepted: case .verificationRequestAccepted:
return L10n.screenSessionVerificationRequestAcceptedSubtitle return L10n.screenSessionVerificationRequestAcceptedSubtitle
case .startingSasVerification: case .startingSasVerification:
return L10n.commonWaiting return waitingMessage
case .sasVerificationStarted: case .sasVerificationStarted:
return L10n.commonWaiting return waitingMessage
case .acceptingChallenge: case .acceptingChallenge:
return L10n.screenSessionVerificationCompareEmojisSubtitle return L10n.screenSessionVerificationCompareEmojisSubtitle
case .decliningChallenge: case .decliningChallenge:
return L10n.screenSessionVerificationCompareEmojisSubtitle return L10n.screenSessionVerificationCompareEmojisSubtitle
case .cancelling: case .cancelling:
return L10n.commonWaiting return waitingMessage
case .showingChallenge: case .showingChallenge:
switch flow {
case .deviceInitiator, .deviceResponder:
return L10n.screenSessionVerificationCompareEmojisSubtitle return L10n.screenSessionVerificationCompareEmojisSubtitle
case .userIntiator, .userResponder:
return L10n.screenSessionVerificationCompareEmojisUserSubtitle
}
case .verified: case .verified:
switch flow {
case .deviceInitiator, .deviceResponder:
return L10n.screenSessionVerificationCompleteSubtitle return L10n.screenSessionVerificationCompleteSubtitle
case .userIntiator, .userResponder:
return L10n.screenSessionVerificationCompleteUserSubtitle
}
case .cancelled: case .cancelled:
return L10n.screenSessionVerificationFailedSubtitle return L10n.screenSessionVerificationFailedSubtitle
} }
} }
private var waitingMessage: String {
L10n.screenSessionVerificationWaitingSubtitle
}
} }
@@ -24,13 +24,18 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
init(sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol, init(sessionVerificationControllerProxy: SessionVerificationControllerProxyProtocol,
flow: SessionVerificationScreenFlow, flow: SessionVerificationScreenFlow,
appSettings: AppSettings,
mediaProvider: MediaProviderProtocol,
verificationState: SessionVerificationScreenStateMachine.State = .initial) { verificationState: SessionVerificationScreenStateMachine.State = .initial) {
self.sessionVerificationControllerProxy = sessionVerificationControllerProxy self.sessionVerificationControllerProxy = sessionVerificationControllerProxy
self.flow = flow self.flow = flow
stateMachine = SessionVerificationScreenStateMachine(state: verificationState) stateMachine = SessionVerificationScreenStateMachine(state: verificationState)
super.init(initialViewState: .init(flow: flow, verificationState: verificationState)) super.init(initialViewState: .init(flow: flow,
learnMoreURL: appSettings.encryptionURL,
verificationState: verificationState),
mediaProvider: mediaProvider)
setupStateMachine() setupStateMachine()
@@ -63,10 +68,13 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
} }
.store(in: &cancellables) .store(in: &cancellables)
if case .responder(let details) = flow { switch flow {
case .deviceResponder(let details), .userResponder(let details):
Task { Task {
await self.sessionVerificationControllerProxy.acknowledgeVerificationRequest(details: details) await self.sessionVerificationControllerProxy.acknowledgeVerificationRequest(details: details)
} }
default:
break
} }
} }
@@ -86,6 +94,9 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
stateMachine.processEvent(.acceptChallenge) stateMachine.processEvent(.acceptChallenge)
case .decline: case .decline:
stateMachine.processEvent(.declineChallenge) stateMachine.processEvent(.declineChallenge)
case .cancel:
stateMachine.processEvent(.cancel)
actionsSubject.send(.finished)
case .done: case .done:
actionsSubject.send(.finished) actionsSubject.send(.finished)
} }
@@ -112,7 +123,15 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
case (.initial, .acceptVerificationRequest, .acceptingVerificationRequest): case (.initial, .acceptVerificationRequest, .acceptingVerificationRequest):
acceptVerificationRequest() acceptVerificationRequest()
case (.initial, .requestVerification, .requestingVerification): case (.initial, .requestVerification, .requestingVerification):
requestVerification() Task {
switch await self.requestVerification() {
case .success:
// Need to wait for the callback from the remote
break
case .failure:
self.stateMachine.processEvent(.didFail)
}
}
case (.verificationRequestAccepted, .startSasVerification, .startingSasVerification): case (.verificationRequestAccepted, .startSasVerification, .startingSasVerification):
startSasVerification() startSasVerification()
case (.showingChallenge, .acceptChallenge, .acceptingChallenge): case (.showingChallenge, .acceptChallenge, .acceptingChallenge):
@@ -124,8 +143,11 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
case (_, _, .verified): case (_, _, .verified):
actionsSubject.send(.finished) actionsSubject.send(.finished)
case (.initial, _, .cancelled): case (.initial, _, .cancelled):
if case .responder = flow { switch flow {
case .deviceResponder, .userResponder:
actionsSubject.send(.finished) actionsSubject.send(.finished)
default:
break
} }
default: default:
break break
@@ -139,7 +161,7 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
private func acceptVerificationRequest() { private func acceptVerificationRequest() {
Task { Task {
guard case .responder = flow else { guard flow.isResponder else {
fatalError("Incorrect API usage.") fatalError("Incorrect API usage.")
} }
@@ -152,15 +174,14 @@ class SessionVerificationScreenViewModel: SessionVerificationViewModelType, Sess
} }
} }
private func requestVerification() { private func requestVerification() async -> Result<Void, SessionVerificationControllerProxyError> {
Task { switch flow {
switch await sessionVerificationControllerProxy.requestVerification() { case .deviceInitiator:
case .success: return await sessionVerificationControllerProxy.requestDeviceVerification()
// Need to wait for the callback from the remote case .userIntiator(let userID):
break return await sessionVerificationControllerProxy.requestUserVerification(userID)
case .failure: default:
stateMachine.processEvent(.didFail) fatalError("Incorrect API usage.")
}
} }
} }
@@ -14,8 +14,44 @@ struct SessionVerificationRequestDetailsView: View {
private let outerShape = RoundedRectangle(cornerRadius: 8) private let outerShape = RoundedRectangle(cornerRadius: 8)
let details: SessionVerificationRequestDetails let details: SessionVerificationRequestDetails
let isUserVerification: Bool
let mediaProvider: MediaProviderProtocol?
var body: some View { var body: some View {
if isUserVerification {
userRequestDetails
} else {
deviceRequestDetails
}
}
private var userRequestDetails: some View {
HStack(spacing: 12) {
LoadableAvatarImage(url: details.senderProfile.avatarURL,
name: details.senderProfile.displayName,
contentID: details.senderProfile.userID,
avatarSize: .user(on: .sessionVerification),
mediaProvider: mediaProvider)
VStack(alignment: .leading, spacing: 0) {
Text(details.senderProfile.displayName ?? details.senderProfile.userID)
.font(.compound.bodySM)
.foregroundColor(.compound.textSecondary)
if details.senderProfile.displayName != nil {
Text(details.senderProfile.userID)
.font(.compound.bodyMD)
.foregroundColor(.compound.textPrimary)
}
}
}
.frame(maxWidth: .infinity, alignment: .leading)
.padding(12)
.background(.compound.bgSubtleSecondary)
.clipShape(outerShape)
}
private var deviceRequestDetails: some View {
VStack(spacing: 24) { VStack(spacing: 24) {
VStack(alignment: .leading, spacing: 12) { VStack(alignment: .leading, spacing: 12) {
HStack(spacing: 16) { HStack(spacing: 16) {
@@ -26,7 +62,8 @@ struct SessionVerificationRequestDetailsView: View {
.background(.compound.bgSubtleSecondary) .background(.compound.bgSubtleSecondary)
.clipShape(RoundedRectangle(cornerRadius: 8)) .clipShape(RoundedRectangle(cornerRadius: 8))
Text(details.displayName ?? details.senderID) let displayName = isUserVerification ? details.senderProfile.displayName : details.deviceDisplayName
Text(displayName ?? details.senderProfile.userID)
.font(.compound.bodyMDSemibold) .font(.compound.bodyMDSemibold)
.foregroundColor(.compound.textPrimary) .foregroundColor(.compound.textPrimary)
.frame(maxWidth: .infinity, alignment: .leading) .frame(maxWidth: .infinity, alignment: .leading)
@@ -60,6 +97,8 @@ struct SessionVerificationRequestDetailsView: View {
.stroke(.compound.borderDisabled) .stroke(.compound.borderDisabled)
} }
.font(.compound.bodyMDSemibold)
Text(L10n.screenSessionVerificationRequestFooter) Text(L10n.screenSessionVerificationRequestFooter)
.font(.compound.bodyMDSemibold) .font(.compound.bodyMDSemibold)
.foregroundColor(.compound.textPrimary) .foregroundColor(.compound.textPrimary)
@@ -68,13 +107,25 @@ struct SessionVerificationRequestDetailsView: View {
} }
struct SessionVerificationRequestDetailsView_Previews: PreviewProvider, TestablePreview { struct SessionVerificationRequestDetailsView_Previews: PreviewProvider, TestablePreview {
static var previews: some View { static let details = SessionVerificationRequestDetails(senderProfile: UserProfileProxy(userID: "@bob:matrix.org",
let details = SessionVerificationRequestDetails(senderID: "@bob:matrix.org", displayName: "Billy bob",
avatarURL: .mockMXCUserAvatar),
flowID: "123", flowID: "123",
deviceID: "CODEMISTAKE", deviceID: "CODEMISTAKE",
displayName: "Bob's Element X iOS", deviceDisplayName: "Bob's Element X iOS",
firstSeenDate: .init(timeIntervalSince1970: 0)) firstSeenDate: .init(timeIntervalSince1970: 0))
SessionVerificationRequestDetailsView(details: details) static var previews: some View {
SessionVerificationRequestDetailsView(details: details,
isUserVerification: true,
mediaProvider: MediaProviderMock(configuration: .init()))
.padding()
.previewDisplayName("User")
SessionVerificationRequestDetailsView(details: details,
isUserVerification: false,
mediaProvider: MediaProviderMock(configuration: .init()))
.padding()
.previewDisplayName("Device")
} }
} }
@@ -25,10 +25,24 @@ struct SessionVerificationScreen: View {
.backgroundStyle(.compound.bgCanvasDefault) .backgroundStyle(.compound.bgCanvasDefault)
.interactiveDismissDisabled() .interactiveDismissDisabled()
.navigationBarBackButtonHidden(context.viewState.verificationState == .verified) .navigationBarBackButtonHidden(context.viewState.verificationState == .verified)
.toolbar { toolbar }
} }
// MARK: - Private // MARK: - Private
private var toolbar: some ToolbarContent {
ToolbarItem(placement: .cancellationAction) {
switch context.viewState.flow {
case .userIntiator, .userResponder:
Button(L10n.actionCancel) {
context.send(viewAction: .cancel)
}
default:
EmptyView()
}
}
}
@ViewBuilder @ViewBuilder
private var screenHeader: some View { private var screenHeader: some View {
VStack(spacing: 0) { VStack(spacing: 0) {
@@ -55,11 +69,23 @@ struct SessionVerificationScreen: View {
switch context.viewState.verificationState { switch context.viewState.verificationState {
case .initial: case .initial:
switch context.viewState.flow { switch context.viewState.flow {
case .responder(let details): case .deviceResponder(let details):
SessionVerificationRequestDetailsView(details: details) SessionVerificationRequestDetailsView(details: details,
isUserVerification: false,
mediaProvider: context.mediaProvider)
case .userResponder(let details):
SessionVerificationRequestDetailsView(details: details,
isUserVerification: true,
mediaProvider: context.mediaProvider)
case .userIntiator:
Button(L10n.actionLearnMore) {
UIApplication.shared.open(context.viewState.learnMoreURL)
}
.buttonStyle(.compound(.plain))
default: default:
EmptyView() EmptyView()
} }
case .showingChallenge(let emojis), .acceptingChallenge(let emojis), .decliningChallenge(let emojis): case .showingChallenge(let emojis), .acceptingChallenge(let emojis), .decliningChallenge(let emojis):
emojisPanel(with: emojis) emojisPanel(with: emojis)
.accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.emojiWrapper) .accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.emojiWrapper)
@@ -89,13 +115,13 @@ struct SessionVerificationScreen: View {
switch context.viewState.verificationState { switch context.viewState.verificationState {
case .initial: case .initial:
switch context.viewState.flow { switch context.viewState.flow {
case .initiator: case .deviceInitiator, .userIntiator:
Button(L10n.actionStartVerification) { Button(L10n.actionStartVerification) {
context.send(viewAction: .requestVerification) context.send(viewAction: .requestVerification)
} }
.buttonStyle(.compound(.primary)) .buttonStyle(.compound(.primary))
.accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.requestVerification) .accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.requestVerification)
case .responder: case .deviceResponder, .userResponder:
VStack(spacing: 16) { VStack(spacing: 16) {
Button(L10n.actionStart) { Button(L10n.actionStart) {
context.send(viewAction: .acceptVerificationRequest) context.send(viewAction: .acceptVerificationRequest)
@@ -112,12 +138,12 @@ struct SessionVerificationScreen: View {
} }
case .cancelled: case .cancelled:
switch context.viewState.flow { switch context.viewState.flow {
case .initiator: case .deviceInitiator, .userIntiator:
Button(L10n.actionRetry) { Button(L10n.actionRetry) {
context.send(viewAction: .restart) context.send(viewAction: .restart)
} }
.buttonStyle(.compound(.primary)) .buttonStyle(.compound(.primary))
case .responder: case .deviceResponder, .userResponder:
Button(L10n.actionDone) { Button(L10n.actionDone) {
context.send(viewAction: .done) context.send(viewAction: .done)
} }
@@ -146,11 +172,6 @@ struct SessionVerificationScreen: View {
.accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.declineChallenge) .accessibilityIdentifier(A11yIdentifiers.sessionVerificationScreen.declineChallenge)
} }
case .acceptingVerificationRequest, .acceptingChallenge, .decliningChallenge, .requestingVerification:
Button(L10n.screenIdentityWaitingOnOtherDevice) { }
.buttonStyle(.compound(.primary))
.disabled(true)
default: default:
EmptyView() EmptyView()
} }
@@ -174,16 +195,25 @@ struct SessionVerificationScreen: View {
struct SessionVerification_Previews: PreviewProvider, TestablePreview { struct SessionVerification_Previews: PreviewProvider, TestablePreview {
static var previews: some View { static var previews: some View {
sessionVerificationScreen(state: .initial) sessionVerificationScreen(state: .initial, flow: .deviceInitiator)
.previewDisplayName("Initial - Initiator") .previewDisplayName("Initial - Device Initiator")
let details = SessionVerificationRequestDetails(senderID: "@bob:matrix.org", sessionVerificationScreen(state: .initial, flow: .userIntiator(userID: "@bob:matrix.org"))
.previewDisplayName("Initial - User Initiator")
let details = SessionVerificationRequestDetails(senderProfile: UserProfileProxy(userID: "@bob:matrix.org",
displayName: "Billy Bob",
avatarURL: .mockMXCUserAvatar),
flowID: "123", flowID: "123",
deviceID: "CODEMISTAKE", deviceID: "CODEMISTAKE",
displayName: "Bob's Element X iOS", deviceDisplayName: "Bob's Element X iOS",
firstSeenDate: .init(timeIntervalSince1970: 0)) firstSeenDate: .init(timeIntervalSince1970: 0))
sessionVerificationScreen(state: .initial, flow: .responder(details: details))
.previewDisplayName("Initial - Responder") sessionVerificationScreen(state: .initial, flow: .deviceResponder(requestDetails: details))
.previewDisplayName("Initial - Device Responder")
sessionVerificationScreen(state: .initial, flow: .userResponder(requestDetails: details))
.previewDisplayName("Initial - User Responder")
sessionVerificationScreen(state: .acceptingVerificationRequest) sessionVerificationScreen(state: .acceptingVerificationRequest)
.previewDisplayName("Accepting Verification Request") .previewDisplayName("Accepting Verification Request")
@@ -213,9 +243,11 @@ struct SessionVerification_Previews: PreviewProvider, TestablePreview {
} }
static func sessionVerificationScreen(state: SessionVerificationScreenStateMachine.State, static func sessionVerificationScreen(state: SessionVerificationScreenStateMachine.State,
flow: SessionVerificationScreenFlow = .initiator) -> some View { flow: SessionVerificationScreenFlow = .deviceInitiator) -> some View {
let viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: SessionVerificationControllerProxyMock.configureMock(), let viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: SessionVerificationControllerProxyMock.configureMock(),
flow: flow, flow: flow,
appSettings: AppSettings(),
mediaProvider: MediaProviderMock(configuration: .init()),
verificationState: state) verificationState: state)
return SessionVerificationScreen(context: viewModel.context) return SessionVerificationScreen(context: viewModel.context)
@@ -21,6 +21,7 @@ enum RoomMemberDetailsScreenCoordinatorAction {
case openUserProfile case openUserProfile
case openDirectChat(roomID: String) case openDirectChat(roomID: String)
case startCall(roomID: String) case startCall(roomID: String)
case verifyUser(userID: String)
} }
final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol { final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
@@ -53,6 +54,8 @@ final class RoomMemberDetailsScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.openDirectChat(roomID: roomID)) actionsSubject.send(.openDirectChat(roomID: roomID))
case .startCall(let roomID): case .startCall(let roomID):
actionsSubject.send(.startCall(roomID: roomID)) actionsSubject.send(.startCall(roomID: roomID))
case .verifyUser(let userID):
actionsSubject.send(.verifyUser(userID: userID))
} }
} }
.store(in: &cancellables) .store(in: &cancellables)
@@ -11,6 +11,7 @@ enum RoomMemberDetailsScreenViewModelAction {
case openUserProfile case openUserProfile
case openDirectChat(roomID: String) case openDirectChat(roomID: String)
case startCall(roomID: String) case startCall(roomID: String)
case verifyUser(userID: String)
} }
struct RoomMemberDetailsScreenViewState: BindableState { struct RoomMemberDetailsScreenViewState: BindableState {
@@ -88,6 +89,7 @@ enum RoomMemberDetailsScreenViewAction {
case openDirectChat case openDirectChat
case createDirectChat case createDirectChat
case startCall(roomID: String) case startCall(roomID: String)
case verifyUser
} }
enum RoomMemberDetailsScreenAlertType: Hashable { enum RoomMemberDetailsScreenAlertType: Hashable {
@@ -75,6 +75,8 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
Task { await createDirectChat() } Task { await createDirectChat() }
case .startCall(let roomID): case .startCall(let roomID):
actionsSubject.send(.startCall(roomID: roomID)) actionsSubject.send(.startCall(roomID: roomID))
case .verifyUser:
actionsSubject.send(.verifyUser(userID: state.userID))
} }
} }
@@ -91,11 +91,10 @@ struct RoomMemberDetailsScreen: View {
var verificationSection: some View { var verificationSection: some View {
if context.viewState.showVerificationSection { if context.viewState.showVerificationSection {
Section { Section {
ListRow(label: .default(title: L10n.commonVerifyIdentity, ListRow(label: .default(title: L10n.commonVerifyUser, icon: \.lock),
description: L10n.screenRoomMemberDetailsVerifyButtonSubtitle, kind: .button {
icon: \.lock), context.send(viewAction: .verifyUser)
kind: .button { }) })
.disabled(true)
} }
} }
} }
@@ -20,6 +20,7 @@ struct UserProfileScreenCoordinatorParameters {
enum UserProfileScreenCoordinatorAction { enum UserProfileScreenCoordinatorAction {
case openDirectChat(roomID: String) case openDirectChat(roomID: String)
case startCall(roomID: String) case startCall(roomID: String)
case verifyUser(userID: String)
case dismiss case dismiss
} }
@@ -51,6 +52,8 @@ final class UserProfileScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.openDirectChat(roomID: roomID)) actionsSubject.send(.openDirectChat(roomID: roomID))
case .startCall(let roomID): case .startCall(let roomID):
actionsSubject.send(.startCall(roomID: roomID)) actionsSubject.send(.startCall(roomID: roomID))
case .verifyUser(let userID):
actionsSubject.send(.verifyUser(userID: userID))
case .dismiss: case .dismiss:
actionsSubject.send(.dismiss) actionsSubject.send(.dismiss)
} }
@@ -10,6 +10,7 @@ import Foundation
enum UserProfileScreenViewModelAction { enum UserProfileScreenViewModelAction {
case openDirectChat(roomID: String) case openDirectChat(roomID: String)
case startCall(roomID: String) case startCall(roomID: String)
case verifyUser(userID: String)
case dismiss case dismiss
} }
@@ -47,6 +48,7 @@ enum UserProfileScreenViewAction {
case openDirectChat case openDirectChat
case createDirectChat case createDirectChat
case startCall(roomID: String) case startCall(roomID: String)
case verifyUser
case dismiss case dismiss
} }
@@ -66,6 +66,8 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
Task { await createDirectChat() } Task { await createDirectChat() }
case .startCall(let roomID): case .startCall(let roomID):
actionsSubject.send(.startCall(roomID: roomID)) actionsSubject.send(.startCall(roomID: roomID))
case .verifyUser:
actionsSubject.send(.verifyUser(userID: state.userID))
case .dismiss: case .dismiss:
actionsSubject.send(.dismiss) actionsSubject.send(.dismiss)
} }
@@ -88,11 +88,10 @@ struct UserProfileScreen: View {
var verificationSection: some View { var verificationSection: some View {
if context.viewState.showVerificationSection { if context.viewState.showVerificationSection {
Section { Section {
ListRow(label: .default(title: L10n.commonVerifyIdentity, ListRow(label: .default(title: L10n.commonVerifyUser, icon: \.lock),
description: L10n.screenRoomMemberDetailsVerifyButtonSubtitle, kind: .button {
icon: \.lock), context.send(viewAction: .verifyUser)
kind: .button { }) })
.disabled(true)
} }
} }
} }
@@ -71,7 +71,7 @@ class SessionVerificationControllerProxy: SessionVerificationControllerProxyProt
MXLog.info("Acknowledging verification request") MXLog.info("Acknowledging verification request")
do { do {
try await sessionVerificationController.acknowledgeVerificationRequest(senderId: details.senderID, flowId: details.flowID) try await sessionVerificationController.acknowledgeVerificationRequest(senderId: details.senderProfile.userID, flowId: details.flowID)
return .success(()) return .success(())
} catch { } catch {
MXLog.error("Failed requesting session verification with error: \(error)") MXLog.error("Failed requesting session verification with error: \(error)")
@@ -91,14 +91,26 @@ class SessionVerificationControllerProxy: SessionVerificationControllerProxyProt
} }
} }
func requestVerification() async -> Result<Void, SessionVerificationControllerProxyError> { func requestDeviceVerification() async -> Result<Void, SessionVerificationControllerProxyError> {
MXLog.info("Requesting session verification") MXLog.info("Requesting device verification")
do { do {
try await sessionVerificationController.requestDeviceVerification() try await sessionVerificationController.requestDeviceVerification()
return .success(()) return .success(())
} catch { } catch {
MXLog.error("Failed requesting session verification with error: \(error)") MXLog.error("Failed requesting device verification with error: \(error)")
return .failure(.failedRequestingVerification)
}
}
func requestUserVerification(_ userID: String) async -> Result<Void, SessionVerificationControllerProxyError> {
MXLog.info("Requesting user verification")
do {
try await sessionVerificationController.requestUserVerification(userId: userID)
return .success(())
} catch {
MXLog.error("Failed requesting verification for user \(userID) with error: \(error)")
return .failure(.failedRequestingVerification) return .failure(.failedRequestingVerification)
} }
} }
@@ -156,10 +168,10 @@ class SessionVerificationControllerProxy: SessionVerificationControllerProxyProt
fileprivate func didReceiveVerificationRequest(details: MatrixRustSDK.SessionVerificationRequestDetails) { fileprivate func didReceiveVerificationRequest(details: MatrixRustSDK.SessionVerificationRequestDetails) {
MXLog.info("Received verification request \(details)") MXLog.info("Received verification request \(details)")
let details = SessionVerificationRequestDetails(senderID: details.senderId, let details = SessionVerificationRequestDetails(senderProfile: UserProfileProxy(sdkUserProfile: details.senderProfile),
flowID: details.flowId, flowID: details.flowId,
deviceID: details.deviceId, deviceID: details.deviceId,
displayName: details.deviceDisplayName, deviceDisplayName: details.deviceDisplayName,
firstSeenDate: Date(timeIntervalSince1970: TimeInterval(details.firstSeenTimestamp / 1000))) firstSeenDate: Date(timeIntervalSince1970: TimeInterval(details.firstSeenTimestamp / 1000)))
actions.send(.receivedVerificationRequest(details: details)) actions.send(.receivedVerificationRequest(details: details))
@@ -30,10 +30,10 @@ enum SessionVerificationControllerProxyAction {
} }
struct SessionVerificationRequestDetails { struct SessionVerificationRequestDetails {
let senderID: String let senderProfile: UserProfileProxy
let flowID: String let flowID: String
let deviceID: String let deviceID: String
let displayName: String? let deviceDisplayName: String?
let firstSeenDate: Date let firstSeenDate: Date
} }
@@ -54,7 +54,9 @@ protocol SessionVerificationControllerProxyProtocol {
func acceptVerificationRequest() async -> Result<Void, SessionVerificationControllerProxyError> func acceptVerificationRequest() async -> Result<Void, SessionVerificationControllerProxyError>
func requestVerification() async -> Result<Void, SessionVerificationControllerProxyError> func requestDeviceVerification() async -> Result<Void, SessionVerificationControllerProxyError>
func requestUserVerification(_ userID: String) async -> Result<Void, SessionVerificationControllerProxyError>
func startSasVerification() async -> Result<Void, SessionVerificationControllerProxyError> func startSasVerification() async -> Result<Void, SessionVerificationControllerProxyError>
@@ -533,7 +533,9 @@ class MockScreen: Identifiable {
case .sessionVerification: case .sessionVerification:
var sessionVerificationControllerProxy = SessionVerificationControllerProxyMock.configureMock(requestDelay: .seconds(5)) var sessionVerificationControllerProxy = SessionVerificationControllerProxyMock.configureMock(requestDelay: .seconds(5))
let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationControllerProxy, let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationControllerProxy,
flow: .initiator) flow: .deviceInitiator,
appSettings: ServiceLocator.shared.settings,
mediaProvider: MediaProviderMock(configuration: .init()))
return SessionVerificationScreenCoordinator(parameters: parameters) return SessionVerificationScreenCoordinator(parameters: parameters)
case .userSessionScreen, .userSessionScreenReply: case .userSessionScreen, .userSessionScreenReply:
let appSettings: AppSettings = ServiceLocator.shared.settings let appSettings: AppSettings = ServiceLocator.shared.settings
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1ec63ab41577f807b574db65d04cad3e7274d7b684ed5c922103f2d21e79190e oid sha256:bc7992df6c2b7227c500f84531bdac9577db2cf067cb6aa9a81b81a8936771e4
size 121087 size 114445
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c6c4bb8c600440bfca120792553a0aba22f0d2da96a402b6451b9850d40a5f85 oid sha256:eb8a03e056c72838db67ac97b012792f1d98985952dcaeffe80455363b729a5a
size 120759 size 114232
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c12ffa3f032de0f340ad726938cab004203baf478830ed862862e2ff8566c435 oid sha256:26810d28eb8d22229c2fb6259d44182e8f459efc13d3da72af855c3bd217894c
size 125206 size 116662
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:4585da982eba8c37919fba2f006bbe2e37b206704691b61bcaf06e3ed7cb47a7 oid sha256:4deab2abb40430b6c26169284463fcb45ca30f93b703906e83a7a80b0dd44085
size 124706 size 116224
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:5fa4b9ddeef05139339a3e604e1567178cce02c3c03d19b309b2c9d8af441010 oid sha256:99d9738fe1e134a9570a510ee4e0a7622bccc0edda2316d7e083cb6800f47567
size 71684 size 66185
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:dfde43627b92944423a6f1f2754fe5de95810aa2812576ec3225dcefb91e068e oid sha256:2890c691ada40cd89e8659f9e4397e5f2e0958cc3a7540d7f42f0d525fda4f46
size 70821 size 65267
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:7bae3f0db0d77faae018f19ace01ce3cde202db0fad1a2bc4618de37eba08aa8 oid sha256:4a076ef632d402d507a09abaa38822a81a2a1a094aaee6de62e2aed796478266
size 83579 size 74470
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:4fb14af69f8a5d606ab5375d35d04ce5da7fa8af581b439f61a18fdb7b10e448 oid sha256:c796a02083a8469da92b6d764092caf259a0f6ee4ff52baf7851e5fcfa2be76d
size 82951 size 73660
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:093952c8bbb20d47d49770aba04081684d057a5b5f149055e90e78677a2a59ec oid sha256:8b84ace7ee894cd804be13c83511aeef7b3f4c26cddd8d4ece52f828828a843c
size 162220 size 152955
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:d34314c93b65050cf9a196b831aea3255d836a4f064602757924c10725e6a50d oid sha256:df1a86cc1d1521f7c6acdf921a26f575f7138c8065e54e3780868cd9bb1b6c99
size 98778 size 87743
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:093952c8bbb20d47d49770aba04081684d057a5b5f149055e90e78677a2a59ec oid sha256:8b84ace7ee894cd804be13c83511aeef7b3f4c26cddd8d4ece52f828828a843c
size 162220 size 152955
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0596907b03d8927f0807797acb379febe8aa7a8079cb2df3edc577d809263fd1
size 107231
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6a6cfe5a81a1d7eba134ae70ec1ef789a4b68b8baf23346b97865255859cac37
size 136266
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:0ec30edbbc01c05deafe947f7c3f334fc4482aff926adf68d7a9d2e71bf3bc7d oid sha256:df1a86cc1d1521f7c6acdf921a26f575f7138c8065e54e3780868cd9bb1b6c99
size 97729 size 87743
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:84dab505b5ded1fba821d93c460239fc3b8ba156b3f261f9391c36227c65062d oid sha256:df1a86cc1d1521f7c6acdf921a26f575f7138c8065e54e3780868cd9bb1b6c99
size 71434 size 87743
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:84dab505b5ded1fba821d93c460239fc3b8ba156b3f261f9391c36227c65062d oid sha256:df1a86cc1d1521f7c6acdf921a26f575f7138c8065e54e3780868cd9bb1b6c99
size 71434 size 87743
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:e196922c62442c910c38dc097bb2a0b7529079a0aa002bfeec3a673925f6dcc4 oid sha256:d4fed542a215435fb78a295ff7c444b8314f614b9ecae0e4751219f4a2fbe7bb
size 180582 size 170328
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:5ae01c6fc18e49c952ad0202540abbdd959bb01264e6c682b835a93c3254a21f oid sha256:79475962cd7a752e2df9746ffa7e858a40409d9f52d151efab763838b2ba3bf2
size 118334 size 98777
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:e196922c62442c910c38dc097bb2a0b7529079a0aa002bfeec3a673925f6dcc4 oid sha256:d4fed542a215435fb78a295ff7c444b8314f614b9ecae0e4751219f4a2fbe7bb
size 180582 size 170328
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a83c3d60285d7de3568534a93eb3e00dbbb07a8cb2ef9303ab2ef4c620ced05f
size 128771
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3320f47894c21e21956f46f58ce5d0d32ccb7f1e0b9574a290043a5cb4f49e63
size 151735
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:d0eff524cd9d12cd7bf2a8e8984b2629a202a1d876cec64e9e80204e6a0aef13 oid sha256:79475962cd7a752e2df9746ffa7e858a40409d9f52d151efab763838b2ba3bf2
size 110488 size 98777
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2547e9244d4b77e2f9f14a76e6953de43854b2714a747081cc96b07619fb5263 oid sha256:79475962cd7a752e2df9746ffa7e858a40409d9f52d151efab763838b2ba3bf2
size 71096 size 98777
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2547e9244d4b77e2f9f14a76e6953de43854b2714a747081cc96b07619fb5263 oid sha256:79475962cd7a752e2df9746ffa7e858a40409d9f52d151efab763838b2ba3bf2
size 71096 size 98777
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c103377195f66d616a0494c3a8875e57267ce2b4e40c3f4b8ec8decd4a86f6f7 oid sha256:80c45c14dfd2e30fb120a9ee10372caa9c62884837c881f63467c5df708de5dd
size 113100 size 105600
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:59787c26b565686c7df1be3abd74df657b8b1dd57045ba322991492d19a03073 oid sha256:4c02ac0a4f6c05c80534e5f591c443a7198dcafdfd74e710457dbb1a77bd9b1b
size 58033 size 45660
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c103377195f66d616a0494c3a8875e57267ce2b4e40c3f4b8ec8decd4a86f6f7 oid sha256:80c45c14dfd2e30fb120a9ee10372caa9c62884837c881f63467c5df708de5dd
size 113100 size 105600
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:79eee63e783291b77fcbc69a36e17b1a95ea645836f4679ef7e4c36c283407bc
size 65183
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d408ee9328fc4db9823699521b2dd7462a37131cf5ca55359f07abee1441b652
size 86328
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:fae4c9c5121b82e082366b1d7ae71276831a7d40df94d138329c3c134769bc5a oid sha256:4c02ac0a4f6c05c80534e5f591c443a7198dcafdfd74e710457dbb1a77bd9b1b
size 55510 size 45660
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1e16a425e3fb0c4946932d50e94fa103dee23bc4366f68c66d813fb790242174 oid sha256:4c02ac0a4f6c05c80534e5f591c443a7198dcafdfd74e710457dbb1a77bd9b1b
size 31094 size 45660
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1e16a425e3fb0c4946932d50e94fa103dee23bc4366f68c66d813fb790242174 oid sha256:4c02ac0a4f6c05c80534e5f591c443a7198dcafdfd74e710457dbb1a77bd9b1b
size 31094 size 45660
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:560c79a382fc2e7154e764b49eeb443d771fd28c47d3a77f04d705c45d4064a0 oid sha256:507df30f49d2a2f688195e668c399e40bf2db537c3c3a17372c82ec607026be7
size 134554 size 121304
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1e7835d5c27384b6fef3f9d6fc675f4d960124d1bc525857222955b61a389a4b oid sha256:f98fdfdeca99bc45e2247a3d6db244765460eb0291f9071159ed3d851a351634
size 82012 size 61301
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:560c79a382fc2e7154e764b49eeb443d771fd28c47d3a77f04d705c45d4064a0 oid sha256:507df30f49d2a2f688195e668c399e40bf2db537c3c3a17372c82ec607026be7
size 134554 size 121304
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2b9d92608775d8f55e2a0da4178364c2d41751471331fe971c3d646a028ecc9b
size 87568
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6959ea579872e782f1716243646750a9a7028d66ef4fcba05df609a7e8a3a342
size 106747
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:82ce8b845e4da08a1128dbbd2b5329dded3db3b66889c19ef040e74deb0438a1 oid sha256:f98fdfdeca99bc45e2247a3d6db244765460eb0291f9071159ed3d851a351634
size 78555 size 61301
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c4436735155f7c4fc8e89c4e1763870ce160d02bf33ed0be7de8f1a7290469d8 oid sha256:f98fdfdeca99bc45e2247a3d6db244765460eb0291f9071159ed3d851a351634
size 32044 size 61301
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c4436735155f7c4fc8e89c4e1763870ce160d02bf33ed0be7de8f1a7290469d8 oid sha256:f98fdfdeca99bc45e2247a3d6db244765460eb0291f9071159ed3d851a351634
size 32044 size 61301
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:db9bed799aae9732c42fc1361e72064f0b25e90abb4d8d07ec9cdc8441c8481e
size 92806
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8ff548761c5ae8e6987657ea24fb9b60d60ee586c361e0a855613302ebaac2ea
size 94375
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b782162b02f2c1e40cf970dd62c5f33e8db64fa39b737c0f5263f4dd1d34f1d0
size 100219
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6d9d00be62424b27994eff708c279596bd6e3e64cdf733c9e350a4c21247db4c
size 101514
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1fc4a362554236648306b49ea1127b60acafb5905814d1099768dbf016099d88
size 103033
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b782162b02f2c1e40cf970dd62c5f33e8db64fa39b737c0f5263f4dd1d34f1d0
size 100219
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c77f8338cafa5cb5f14fdc64e9855a78088bffc7d0017ccea69035417532693b
size 50064
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ff063c2dab712e1a94c0ce21c7d76086bb61d3526284c7e6434017080beb530c
size 51303
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2b8bd7869efd8ac2bb29eb2c4e90c2b43fbaa74015b562bf113b7f1f42d14af8
size 54638
@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fe6709b8a05591a74557ed266f980dfb9c8fcfd7b4d2ed94b5cd35dd692dd45e
size 59494
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:28b4a4b5d44dd63ca00fd561b9cc2955eb4ebff3df39b13810a22e792b05cd7c
size 60750
@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2b8bd7869efd8ac2bb29eb2c4e90c2b43fbaa74015b562bf113b7f1f42d14af8
size 54638
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:32284dfef4f33396c9ef71ede00a533537f2af1c23b0c17778946d5d833bd72d oid sha256:50695c29b17006f678a1b40028323a1c2f61769aeaf9785677a48197d6d39ade
size 94033 size 94053
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:94d690d16fdb9960e4da643bf30c63b9836ab15beac644e27ddd4bda28a01038 oid sha256:7c79cf23a403a1a8f7f870c5bc1b076d7db8fdc5306f8e2d570481b04f53243c
size 114661 size 108340
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:1bd63fa3ba2aa94c2c50a8a63535d3fd818479850986164610b4540e8b4a551f oid sha256:5e5938b83a98fd1e5da611fa57003e2f3b63b1d926d433c7216809cce3d45368
size 94314 size 94323
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c4eec79fbfc398d28032b5911b48b04a0ece228eeb77f24068437a0cfb8cb9da oid sha256:12b13a72d49eed5e18f72dc9f9fe38e030e30cce68fa3e2ff0cf30f5fbe8967d
size 118148 size 110043
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:e1f95a655d3c7b2ebaf00a1f4babaa74ef8e870342c124ae2f7e43c9d0997765 oid sha256:0699768a4c2b4bb4930afe83f0d5089eac83d7f0623196443ecc246da5192920
size 46337 size 46351
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:7979a1a28cc4bbe57e4b45db8278bcc8ddd2618b40985e22e473c9c49c3fef6d oid sha256:cf92dab653565f100a445d2e8231e984761644436f2c9f565823f5c5730a0e28
size 65179 size 59553
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:2fc47d1fde37c2bc2fcb13a7fd99f535c0ff29f36009c46d25ddf002bb48767f oid sha256:0cf68695dcc01e825fdab7c2e23dc12bc4bcdda2f80788ed12757e448e31ca0f
size 46957 size 46975
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:6b6ecdb7a7b7bcacf5c8aa3b0c083453fde5fa7ddd65c98e9d8ea33eb540cddc oid sha256:516372c5b8db4c73878cbce0be4015381446623317529c1a44a30fb114efd277
size 77283 size 66599
@@ -18,7 +18,10 @@ class SessionVerificationViewModelTests: XCTestCase {
override func setUpWithError() throws { override func setUpWithError() throws {
sessionVerificationController = SessionVerificationControllerProxyMock.configureMock() sessionVerificationController = SessionVerificationControllerProxyMock.configureMock()
viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: sessionVerificationController, flow: .initiator) viewModel = SessionVerificationScreenViewModel(sessionVerificationControllerProxy: sessionVerificationController,
flow: .deviceInitiator,
appSettings: AppSettings(),
mediaProvider: MediaProviderMock(configuration: .init()))
context = viewModel.context context = viewModel.context
} }
@@ -28,7 +31,7 @@ class SessionVerificationViewModelTests: XCTestCase {
context.send(viewAction: .requestVerification) context.send(viewAction: .requestVerification)
try await Task.sleep(for: .milliseconds(100)) try await Task.sleep(for: .milliseconds(100))
XCTAssert(sessionVerificationController.requestVerificationCallsCount == 1) XCTAssert(sessionVerificationController.requestDeviceVerificationCallsCount == 1)
XCTAssertEqual(context.viewState.verificationState, .requestingVerification) XCTAssertEqual(context.viewState.verificationState, .requestingVerification)
} }
@@ -53,7 +56,7 @@ class SessionVerificationViewModelTests: XCTestCase {
XCTAssertEqual(context.viewState.verificationState, .initial) XCTAssertEqual(context.viewState.verificationState, .initial)
XCTAssert(sessionVerificationController.requestVerificationCallsCount == 1) XCTAssert(sessionVerificationController.requestDeviceVerificationCallsCount == 1)
XCTAssert(sessionVerificationController.cancelVerificationCallsCount == 1) XCTAssert(sessionVerificationController.cancelVerificationCallsCount == 1)
} }
@@ -154,7 +157,7 @@ class SessionVerificationViewModelTests: XCTestCase {
wait(for: [verificationDataReceivalExpectation], timeout: 10.0) wait(for: [verificationDataReceivalExpectation], timeout: 10.0)
XCTAssertEqual(context.viewState.verificationState, .showingChallenge(emojis: SessionVerificationControllerProxyMock.emojis)) XCTAssertEqual(context.viewState.verificationState, .showingChallenge(emojis: SessionVerificationControllerProxyMock.emojis))
XCTAssert(sessionVerificationController.requestVerificationCallsCount == 1) XCTAssert(sessionVerificationController.requestDeviceVerificationCallsCount == 1)
XCTAssert(sessionVerificationController.startSasVerificationCallsCount == 1) XCTAssert(sessionVerificationController.startSasVerificationCallsCount == 1)
} }
} }
+1 -1
View File
@@ -61,7 +61,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: 25.02.06 exactVersion: 25.02.07
# 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