mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 03:16:02 +03:00
Keep on renaming
This commit is contained in:
parent
050eb0af9d
commit
345824daa2
18 changed files with 111 additions and 94 deletions
|
@ -51,8 +51,8 @@ class SASTest : InstrumentedTest {
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
val bobSession = cryptoTestData.secondSession
|
val bobSession = cryptoTestData.secondSession
|
||||||
|
|
||||||
val aliceSasMgr = aliceSession.getSasVerificationService()
|
val aliceVerificationService = aliceSession.getVerificationService()
|
||||||
val bobSasMgr = bobSession!!.getSasVerificationService()
|
val bobVerificationService = bobSession!!.getVerificationService()
|
||||||
|
|
||||||
val bobTxCreatedLatch = CountDownLatch(1)
|
val bobTxCreatedLatch = CountDownLatch(1)
|
||||||
val bobListener = object : VerificationService.VerificationListener {
|
val bobListener = object : VerificationService.VerificationListener {
|
||||||
|
@ -64,18 +64,18 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
bobSasMgr.addListener(bobListener)
|
bobVerificationService.addListener(bobListener)
|
||||||
|
|
||||||
val txID = aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobSession.myUserId, bobSession.getMyDevice().deviceId)
|
val txID = aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobSession.myUserId, bobSession.getMyDevice().deviceId)
|
||||||
assertNotNull("Alice should have a started transaction", txID)
|
assertNotNull("Alice should have a started transaction", txID)
|
||||||
|
|
||||||
val aliceKeyTx = aliceSasMgr.getExistingTransaction(bobSession.myUserId, txID!!)
|
val aliceKeyTx = aliceVerificationService.getExistingTransaction(bobSession.myUserId, txID!!)
|
||||||
assertNotNull("Alice should have a started transaction", aliceKeyTx)
|
assertNotNull("Alice should have a started transaction", aliceKeyTx)
|
||||||
|
|
||||||
mTestHelper.await(bobTxCreatedLatch)
|
mTestHelper.await(bobTxCreatedLatch)
|
||||||
bobSasMgr.removeListener(bobListener)
|
bobVerificationService.removeListener(bobListener)
|
||||||
|
|
||||||
val bobKeyTx = bobSasMgr.getExistingTransaction(aliceSession.myUserId, txID)
|
val bobKeyTx = bobVerificationService.getExistingTransaction(aliceSession.myUserId, txID)
|
||||||
|
|
||||||
assertNotNull("Bob should have started verif transaction", bobKeyTx)
|
assertNotNull("Bob should have started verif transaction", bobKeyTx)
|
||||||
assertTrue(bobKeyTx is SASDefaultVerificationTransaction)
|
assertTrue(bobKeyTx is SASDefaultVerificationTransaction)
|
||||||
|
@ -105,7 +105,7 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
bobSasMgr.addListener(bobListener2)
|
bobVerificationService.addListener(bobListener2)
|
||||||
|
|
||||||
aliceSasTx.cancel(CancelCode.User)
|
aliceSasTx.cancel(CancelCode.User)
|
||||||
mTestHelper.await(cancelLatch)
|
mTestHelper.await(cancelLatch)
|
||||||
|
@ -120,8 +120,8 @@ class SASTest : InstrumentedTest {
|
||||||
assertEquals("Should be User cancelled on bob side",
|
assertEquals("Should be User cancelled on bob side",
|
||||||
CancelCode.User, aliceSasTx.cancelledReason)
|
CancelCode.User, aliceSasTx.cancelledReason)
|
||||||
|
|
||||||
assertNull(bobSasMgr.getExistingTransaction(aliceSession.myUserId, txID))
|
assertNull(bobVerificationService.getExistingTransaction(aliceSession.myUserId, txID))
|
||||||
assertNull(aliceSasMgr.getExistingTransaction(bobSession.myUserId, txID))
|
assertNull(aliceVerificationService.getExistingTransaction(bobSession.myUserId, txID))
|
||||||
|
|
||||||
cryptoTestData.close()
|
cryptoTestData.close()
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
bobSession.getSasVerificationService().addListener(bobListener)
|
bobSession.getVerificationService().addListener(bobListener)
|
||||||
|
|
||||||
// TODO bobSession!!.dataHandler.addListener(object : MXEventListener() {
|
// TODO bobSession!!.dataHandler.addListener(object : MXEventListener() {
|
||||||
// TODO override fun onToDeviceEvent(event: Event?) {
|
// TODO override fun onToDeviceEvent(event: Event?) {
|
||||||
|
@ -179,7 +179,7 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
aliceSession.getSasVerificationService().addListener(aliceListener)
|
aliceSession.getVerificationService().addListener(aliceListener)
|
||||||
|
|
||||||
fakeBobStart(bobSession, aliceUserID, aliceDevice, tid, protocols = protocols)
|
fakeBobStart(bobSession, aliceUserID, aliceDevice, tid, protocols = protocols)
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ class SASTest : InstrumentedTest {
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
val bobSession = cryptoTestData.secondSession
|
val bobSession = cryptoTestData.secondSession
|
||||||
|
|
||||||
val aliceSasMgr = aliceSession.getSasVerificationService()
|
val aliceVerificationService = aliceSession.getVerificationService()
|
||||||
|
|
||||||
val aliceCreatedLatch = CountDownLatch(2)
|
val aliceCreatedLatch = CountDownLatch(2)
|
||||||
val aliceCancelledLatch = CountDownLatch(2)
|
val aliceCancelledLatch = CountDownLatch(2)
|
||||||
|
@ -322,12 +322,12 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
aliceSasMgr.addListener(aliceListener)
|
aliceVerificationService.addListener(aliceListener)
|
||||||
|
|
||||||
val bobUserId = bobSession!!.myUserId
|
val bobUserId = bobSession!!.myUserId
|
||||||
val bobDeviceId = bobSession.getMyDevice().deviceId
|
val bobDeviceId = bobSession.getMyDevice().deviceId
|
||||||
aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
||||||
aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
||||||
|
|
||||||
mTestHelper.await(aliceCreatedLatch)
|
mTestHelper.await(aliceCreatedLatch)
|
||||||
mTestHelper.await(aliceCancelledLatch)
|
mTestHelper.await(aliceCancelledLatch)
|
||||||
|
@ -345,8 +345,8 @@ class SASTest : InstrumentedTest {
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
val bobSession = cryptoTestData.secondSession
|
val bobSession = cryptoTestData.secondSession
|
||||||
|
|
||||||
val aliceSasMgr = aliceSession.getSasVerificationService()
|
val aliceVerificationService = aliceSession.getVerificationService()
|
||||||
val bobSasMgr = bobSession!!.getSasVerificationService()
|
val bobVerificationService = bobSession!!.getVerificationService()
|
||||||
|
|
||||||
var accepted: KeyVerificationAccept? = null
|
var accepted: KeyVerificationAccept? = null
|
||||||
var startReq: KeyVerificationStart? = null
|
var startReq: KeyVerificationStart? = null
|
||||||
|
@ -366,7 +366,7 @@ class SASTest : InstrumentedTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aliceSasMgr.addListener(aliceListener)
|
aliceVerificationService.addListener(aliceListener)
|
||||||
|
|
||||||
val bobListener = object : VerificationService.VerificationListener {
|
val bobListener = object : VerificationService.VerificationListener {
|
||||||
override fun transactionCreated(tx: VerificationTransaction) {}
|
override fun transactionCreated(tx: VerificationTransaction) {}
|
||||||
|
@ -380,11 +380,11 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
bobSasMgr.addListener(bobListener)
|
bobVerificationService.addListener(bobListener)
|
||||||
|
|
||||||
val bobUserId = bobSession.myUserId
|
val bobUserId = bobSession.myUserId
|
||||||
val bobDeviceId = bobSession.getMyDevice().deviceId
|
val bobDeviceId = bobSession.getMyDevice().deviceId
|
||||||
aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
||||||
mTestHelper.await(aliceAcceptedLatch)
|
mTestHelper.await(aliceAcceptedLatch)
|
||||||
|
|
||||||
assertTrue("Should have receive a commitment", accepted!!.commitment?.trim()?.isEmpty() == false)
|
assertTrue("Should have receive a commitment", accepted!!.commitment?.trim()?.isEmpty() == false)
|
||||||
|
@ -409,8 +409,8 @@ class SASTest : InstrumentedTest {
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
val bobSession = cryptoTestData.secondSession
|
val bobSession = cryptoTestData.secondSession
|
||||||
|
|
||||||
val aliceSasMgr = aliceSession.getSasVerificationService()
|
val aliceVerificationService = aliceSession.getVerificationService()
|
||||||
val bobSasMgr = bobSession!!.getSasVerificationService()
|
val bobVerificationService = bobSession!!.getVerificationService()
|
||||||
|
|
||||||
val aliceSASLatch = CountDownLatch(1)
|
val aliceSASLatch = CountDownLatch(1)
|
||||||
val aliceListener = object : VerificationService.VerificationListener {
|
val aliceListener = object : VerificationService.VerificationListener {
|
||||||
|
@ -428,7 +428,7 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
aliceSasMgr.addListener(aliceListener)
|
aliceVerificationService.addListener(aliceListener)
|
||||||
|
|
||||||
val bobSASLatch = CountDownLatch(1)
|
val bobSASLatch = CountDownLatch(1)
|
||||||
val bobListener = object : VerificationService.VerificationListener {
|
val bobListener = object : VerificationService.VerificationListener {
|
||||||
|
@ -449,16 +449,16 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
bobSasMgr.addListener(bobListener)
|
bobVerificationService.addListener(bobListener)
|
||||||
|
|
||||||
val bobUserId = bobSession.myUserId
|
val bobUserId = bobSession.myUserId
|
||||||
val bobDeviceId = bobSession.getMyDevice().deviceId
|
val bobDeviceId = bobSession.getMyDevice().deviceId
|
||||||
val verificationSAS = aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
val verificationSAS = aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
||||||
mTestHelper.await(aliceSASLatch)
|
mTestHelper.await(aliceSASLatch)
|
||||||
mTestHelper.await(bobSASLatch)
|
mTestHelper.await(bobSASLatch)
|
||||||
|
|
||||||
val aliceTx = aliceSasMgr.getExistingTransaction(bobUserId, verificationSAS!!) as SASDefaultVerificationTransaction
|
val aliceTx = aliceVerificationService.getExistingTransaction(bobUserId, verificationSAS!!) as SASDefaultVerificationTransaction
|
||||||
val bobTx = bobSasMgr.getExistingTransaction(aliceSession.myUserId, verificationSAS) as SASDefaultVerificationTransaction
|
val bobTx = bobVerificationService.getExistingTransaction(aliceSession.myUserId, verificationSAS) as SASDefaultVerificationTransaction
|
||||||
|
|
||||||
assertEquals("Should have same SAS", aliceTx.getShortCodeRepresentation(SasMode.DECIMAL),
|
assertEquals("Should have same SAS", aliceTx.getShortCodeRepresentation(SasMode.DECIMAL),
|
||||||
bobTx.getShortCodeRepresentation(SasMode.DECIMAL))
|
bobTx.getShortCodeRepresentation(SasMode.DECIMAL))
|
||||||
|
@ -473,8 +473,8 @@ class SASTest : InstrumentedTest {
|
||||||
val aliceSession = cryptoTestData.firstSession
|
val aliceSession = cryptoTestData.firstSession
|
||||||
val bobSession = cryptoTestData.secondSession
|
val bobSession = cryptoTestData.secondSession
|
||||||
|
|
||||||
val aliceSasMgr = aliceSession.getSasVerificationService()
|
val aliceVerificationService = aliceSession.getVerificationService()
|
||||||
val bobSasMgr = bobSession!!.getSasVerificationService()
|
val bobVerificationService = bobSession!!.getVerificationService()
|
||||||
|
|
||||||
val aliceSASLatch = CountDownLatch(1)
|
val aliceSASLatch = CountDownLatch(1)
|
||||||
val aliceListener = object : VerificationService.VerificationListener {
|
val aliceListener = object : VerificationService.VerificationListener {
|
||||||
|
@ -495,7 +495,7 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
aliceSasMgr.addListener(aliceListener)
|
aliceVerificationService.addListener(aliceListener)
|
||||||
|
|
||||||
val bobSASLatch = CountDownLatch(1)
|
val bobSASLatch = CountDownLatch(1)
|
||||||
val bobListener = object : VerificationService.VerificationListener {
|
val bobListener = object : VerificationService.VerificationListener {
|
||||||
|
@ -519,11 +519,11 @@ class SASTest : InstrumentedTest {
|
||||||
|
|
||||||
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
override fun markedAsManuallyVerified(userId: String, deviceId: String) {}
|
||||||
}
|
}
|
||||||
bobSasMgr.addListener(bobListener)
|
bobVerificationService.addListener(bobListener)
|
||||||
|
|
||||||
val bobUserId = bobSession.myUserId
|
val bobUserId = bobSession.myUserId
|
||||||
val bobDeviceId = bobSession.getMyDevice().deviceId
|
val bobDeviceId = bobSession.getMyDevice().deviceId
|
||||||
aliceSasMgr.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
aliceVerificationService.beginKeyVerification(VerificationMethod.SAS, bobUserId, bobDeviceId)
|
||||||
mTestHelper.await(aliceSASLatch)
|
mTestHelper.await(aliceSASLatch)
|
||||||
mTestHelper.await(bobSASLatch)
|
mTestHelper.await(bobSASLatch)
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ interface CryptoService {
|
||||||
|
|
||||||
fun isCryptoEnabled(): Boolean
|
fun isCryptoEnabled(): Boolean
|
||||||
|
|
||||||
fun getSasVerificationService(): VerificationService
|
fun getVerificationService(): VerificationService
|
||||||
|
|
||||||
fun getCrossSigningService(): CrossSigningService
|
fun getCrossSigningService(): CrossSigningService
|
||||||
|
|
||||||
|
@ -118,8 +118,9 @@ interface CryptoService {
|
||||||
|
|
||||||
fun downloadKeys(userIds: List<String>, forceDownload: Boolean, callback: MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>>)
|
fun downloadKeys(userIds: List<String>, forceDownload: Boolean, callback: MatrixCallback<MXUsersDevicesMap<CryptoDeviceInfo>>)
|
||||||
|
|
||||||
fun getCryptoDeviceInfo(userId: String) : List<CryptoDeviceInfo>
|
fun getCryptoDeviceInfo(userId: String): List<CryptoDeviceInfo>
|
||||||
fun getLiveCryptoDeviceInfo(userId: String) : LiveData<List<CryptoDeviceInfo>>
|
|
||||||
|
fun getLiveCryptoDeviceInfo(userId: String): LiveData<List<CryptoDeviceInfo>>
|
||||||
|
|
||||||
fun addNewSessionListener(newSessionListener: NewSessionListener)
|
fun addNewSessionListener(newSessionListener: NewSessionListener)
|
||||||
|
|
||||||
|
|
|
@ -24,8 +24,8 @@ import im.vector.matrix.android.internal.crypto.verification.PendingVerification
|
||||||
* https://matrix.org/docs/spec/client_server/r0.5.0#key-verification-framework
|
* https://matrix.org/docs/spec/client_server/r0.5.0#key-verification-framework
|
||||||
*
|
*
|
||||||
* Verifying keys manually by reading out the Ed25519 key is not very user friendly, and can lead to errors.
|
* Verifying keys manually by reading out the Ed25519 key is not very user friendly, and can lead to errors.
|
||||||
* SAS verification is a user-friendly key verification process.
|
* Verification is a user-friendly key verification process.
|
||||||
* SAS verification is intended to be a highly interactive process for users,
|
* Verification is intended to be a highly interactive process for users,
|
||||||
* and as such exposes verification methods which are easier for users to use.
|
* and as such exposes verification methods which are easier for users to use.
|
||||||
*/
|
*/
|
||||||
interface VerificationService {
|
interface VerificationService {
|
||||||
|
|
|
@ -1,8 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2020 New Vector Ltd
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
package im.vector.matrix.android.api.session.crypto.sas
|
package im.vector.matrix.android.api.session.crypto.sas
|
||||||
|
|
||||||
interface VerificationTransaction {
|
interface VerificationTransaction {
|
||||||
|
|
||||||
|
|
||||||
var state: VerificationTxState
|
var state: VerificationTxState
|
||||||
|
|
||||||
val cancelledReason: CancelCode?
|
val cancelledReason: CancelCode?
|
||||||
|
@ -14,6 +29,7 @@ interface VerificationTransaction {
|
||||||
* User wants to cancel the transaction
|
* User wants to cancel the transaction
|
||||||
*/
|
*/
|
||||||
fun cancel()
|
fun cancel()
|
||||||
|
|
||||||
fun cancel(code: CancelCode)
|
fun cancel(code: CancelCode)
|
||||||
|
|
||||||
fun isToDeviceTransport(): Boolean
|
fun isToDeviceTransport(): Boolean
|
||||||
|
|
|
@ -126,8 +126,8 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
private val oneTimeKeysUploader: OneTimeKeysUploader,
|
private val oneTimeKeysUploader: OneTimeKeysUploader,
|
||||||
//
|
//
|
||||||
private val roomDecryptorProvider: RoomDecryptorProvider,
|
private val roomDecryptorProvider: RoomDecryptorProvider,
|
||||||
// The SAS verification service.
|
// The verification service.
|
||||||
private val sasVerificationService: DefaultVerificationService,
|
private val verificationService: DefaultVerificationService,
|
||||||
|
|
||||||
private val crossSigningService: DefaultCrossSigningService,
|
private val crossSigningService: DefaultCrossSigningService,
|
||||||
//
|
//
|
||||||
|
@ -157,7 +157,7 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
sasVerificationService.cryptoService = this
|
verificationService.cryptoService = this
|
||||||
}
|
}
|
||||||
|
|
||||||
private val uiHandler = Handler(Looper.getMainLooper())
|
private val uiHandler = Handler(Looper.getMainLooper())
|
||||||
|
@ -343,7 +343,7 @@ internal class DefaultCryptoService @Inject constructor(
|
||||||
/**
|
/**
|
||||||
* @return the VerificationService
|
* @return the VerificationService
|
||||||
*/
|
*/
|
||||||
override fun getSasVerificationService() = sasVerificationService
|
override fun getVerificationService() = verificationService
|
||||||
|
|
||||||
override fun getCrossSigningService() = crossSigningService
|
override fun getCrossSigningService() = crossSigningService
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,8 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
private val deviceListManager: DeviceListManager,
|
private val deviceListManager: DeviceListManager,
|
||||||
private val setDeviceVerificationAction: SetDeviceVerificationAction,
|
private val setDeviceVerificationAction: SetDeviceVerificationAction,
|
||||||
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
private val coroutineDispatchers: MatrixCoroutineDispatchers,
|
||||||
private val sasTransportRoomMessageFactory: SasTransportRoomMessageFactory,
|
private val verificationTransportRoomMessageFactory: VerificationTransportRoomMessageFactory,
|
||||||
private val sasTransportToDeviceFactory: SasTransportToDeviceFactory,
|
private val verificationTransportToDeviceFactory: VerificationTransportToDeviceFactory,
|
||||||
private val crossSigningService: CrossSigningService
|
private val crossSigningService: CrossSigningService
|
||||||
) : DefaultVerificationTransaction.Listener, VerificationService {
|
) : DefaultVerificationTransaction.Listener, VerificationService {
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
if (startReq?.isValid()?.not() == true) {
|
if (startReq?.isValid()?.not() == true) {
|
||||||
Timber.e("## received invalid verification request")
|
Timber.e("## received invalid verification request")
|
||||||
if (startReq.transactionID != null) {
|
if (startReq.transactionID != null) {
|
||||||
sasTransportRoomMessageFactory.createTransport(event.roomId ?: "", null)
|
verificationTransportRoomMessageFactory.createTransport(event.roomId ?: "", null)
|
||||||
.cancelTransaction(
|
.cancelTransaction(
|
||||||
startReq.transactionID ?: "",
|
startReq.transactionID ?: "",
|
||||||
otherUserId!!,
|
otherUserId!!,
|
||||||
|
@ -301,9 +301,9 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
handleStart(otherUserId, startReq as VerificationInfoStart) {
|
handleStart(otherUserId, startReq as VerificationInfoStart) {
|
||||||
it.transport = sasTransportRoomMessageFactory.createTransport(event.roomId ?: "", it)
|
it.transport = verificationTransportRoomMessageFactory.createTransport(event.roomId ?: "", it)
|
||||||
}?.let {
|
}?.let {
|
||||||
sasTransportRoomMessageFactory.createTransport(event.roomId ?: "", null)
|
verificationTransportRoomMessageFactory.createTransport(event.roomId ?: "", null)
|
||||||
.cancelTransaction(
|
.cancelTransaction(
|
||||||
startReq.transactionID ?: "",
|
startReq.transactionID ?: "",
|
||||||
otherUserId!!,
|
otherUserId!!,
|
||||||
|
@ -322,7 +322,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
if (!startReq.isValid()) {
|
if (!startReq.isValid()) {
|
||||||
Timber.e("## SAS received invalid verification request")
|
Timber.e("## SAS received invalid verification request")
|
||||||
if (startReq.transactionID != null) {
|
if (startReq.transactionID != null) {
|
||||||
sasTransportToDeviceFactory.createTransport(null).cancelTransaction(
|
verificationTransportToDeviceFactory.createTransport(null).cancelTransaction(
|
||||||
startReq.transactionID,
|
startReq.transactionID,
|
||||||
otherUserId!!,
|
otherUserId!!,
|
||||||
startReq.fromDevice ?: event.getSenderKey()!!,
|
startReq.fromDevice ?: event.getSenderKey()!!,
|
||||||
|
@ -333,9 +333,9 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
}
|
}
|
||||||
// Download device keys prior to everything
|
// Download device keys prior to everything
|
||||||
handleStart(otherUserId, startReq) {
|
handleStart(otherUserId, startReq) {
|
||||||
it.transport = sasTransportToDeviceFactory.createTransport(it)
|
it.transport = verificationTransportToDeviceFactory.createTransport(it)
|
||||||
}?.let {
|
}?.let {
|
||||||
sasTransportToDeviceFactory.createTransport(null).cancelTransaction(
|
verificationTransportToDeviceFactory.createTransport(null).cancelTransaction(
|
||||||
startReq.transactionID ?: "",
|
startReq.transactionID ?: "",
|
||||||
otherUserId!!,
|
otherUserId!!,
|
||||||
startReq.fromDevice ?: event.getSenderKey()!!,
|
startReq.fromDevice ?: event.getSenderKey()!!,
|
||||||
|
@ -705,7 +705,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
txID,
|
txID,
|
||||||
userId,
|
userId,
|
||||||
deviceID)
|
deviceID)
|
||||||
tx.transport = sasTransportToDeviceFactory.createTransport(tx)
|
tx.transport = verificationTransportToDeviceFactory.createTransport(tx)
|
||||||
addTransaction(tx)
|
addTransaction(tx)
|
||||||
|
|
||||||
tx.start(method)
|
tx.start(method)
|
||||||
|
@ -724,7 +724,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
pendingRequests[userId] = it
|
pendingRequests[userId] = it
|
||||||
}
|
}
|
||||||
|
|
||||||
val transport = sasTransportRoomMessageFactory.createTransport(roomId, null)
|
val transport = verificationTransportRoomMessageFactory.createTransport(roomId, null)
|
||||||
|
|
||||||
// Cancel existing pending requests?
|
// Cancel existing pending requests?
|
||||||
requestsForUser.toImmutableList().forEach { existingRequest ->
|
requestsForUser.toImmutableList().forEach { existingRequest ->
|
||||||
|
@ -762,7 +762,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun declineVerificationRequestInDMs(otherUserId: String, otherDeviceId: String, transactionId: String, roomId: String) {
|
override fun declineVerificationRequestInDMs(otherUserId: String, otherDeviceId: String, transactionId: String, roomId: String) {
|
||||||
sasTransportRoomMessageFactory.createTransport(roomId, null)
|
verificationTransportRoomMessageFactory.createTransport(roomId, null)
|
||||||
.cancelTransaction(transactionId, otherUserId, otherDeviceId, CancelCode.User)
|
.cancelTransaction(transactionId, otherUserId, otherDeviceId, CancelCode.User)
|
||||||
|
|
||||||
getExistingVerificationRequest(otherUserId, transactionId)?.let {
|
getExistingVerificationRequest(otherUserId, transactionId)?.let {
|
||||||
|
@ -804,7 +804,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
transactionId,
|
transactionId,
|
||||||
otherUserId,
|
otherUserId,
|
||||||
otherDeviceId)
|
otherDeviceId)
|
||||||
tx.transport = sasTransportRoomMessageFactory.createTransport(roomId, tx)
|
tx.transport = verificationTransportRoomMessageFactory.createTransport(roomId, tx)
|
||||||
addTransaction(tx)
|
addTransaction(tx)
|
||||||
|
|
||||||
tx.start(method)
|
tx.start(method)
|
||||||
|
@ -820,7 +820,7 @@ internal class DefaultVerificationService @Inject constructor(
|
||||||
val existingRequest = getExistingVerificationRequest(otherUserId, transactionId)
|
val existingRequest = getExistingVerificationRequest(otherUserId, transactionId)
|
||||||
if (existingRequest != null) {
|
if (existingRequest != null) {
|
||||||
// we need to send a ready event, with matching methods
|
// we need to send a ready event, with matching methods
|
||||||
val transport = sasTransportRoomMessageFactory.createTransport(roomId, null)
|
val transport = verificationTransportRoomMessageFactory.createTransport(roomId, null)
|
||||||
// TODO We should not use supportedVerificationMethods here, because it depends on the client implementation
|
// TODO We should not use supportedVerificationMethods here, because it depends on the client implementation
|
||||||
val methods = existingRequest.requestInfo?.methods?.intersect(supportedVerificationMethods)?.toList()
|
val methods = existingRequest.requestInfo?.methods?.intersect(supportedVerificationMethods)?.toList()
|
||||||
if (methods.isNullOrEmpty()) {
|
if (methods.isNullOrEmpty()) {
|
||||||
|
|
|
@ -48,8 +48,8 @@ internal abstract class SASDefaultVerificationTransaction(
|
||||||
transactionId: String,
|
transactionId: String,
|
||||||
otherUserId: String,
|
otherUserId: String,
|
||||||
otherDevice: String?,
|
otherDevice: String?,
|
||||||
isIncoming: Boolean) :
|
isIncoming: Boolean
|
||||||
DefaultVerificationTransaction(transactionId, otherUserId, otherDevice, isIncoming), SasVerificationTransaction {
|
) : DefaultVerificationTransaction(transactionId, otherUserId, otherDevice, isIncoming), SasVerificationTransaction {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val SAS_MAC_SHA256_LONGKDF = "hmac-sha256"
|
const val SAS_MAC_SHA256_LONGKDF = "hmac-sha256"
|
||||||
|
|
|
@ -20,8 +20,8 @@ import im.vector.matrix.android.api.session.crypto.sas.VerificationTxState
|
||||||
import im.vector.matrix.android.api.session.room.model.message.MessageVerificationRequestContent
|
import im.vector.matrix.android.api.session.room.model.message.MessageVerificationRequestContent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SAS verification can be performed using toDevice events or via DM.
|
* Verification can be performed using toDevice events or via DM.
|
||||||
* This class abstracts the concept of transport for SAS
|
* This class abstracts the concept of transport for verification
|
||||||
*/
|
*/
|
||||||
internal interface VerificationTransport {
|
internal interface VerificationTransport {
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ internal interface VerificationTransport {
|
||||||
code: CancelCode)
|
code: CancelCode)
|
||||||
|
|
||||||
fun done(transactionId: String)
|
fun done(transactionId: String)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an accept message suitable for this transport
|
* Creates an accept message suitable for this transport
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -292,7 +292,7 @@ internal class VerificationTransportRoomMessage(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class SasTransportRoomMessageFactory @Inject constructor(
|
internal class VerificationTransportRoomMessageFactory @Inject constructor(
|
||||||
private val workManagerProvider: WorkManagerProvider,
|
private val workManagerProvider: WorkManagerProvider,
|
||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
private val monarchy: Monarchy,
|
private val monarchy: Monarchy,
|
||||||
|
|
|
@ -145,7 +145,7 @@ internal class VerificationTransportToDevice(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class SasTransportToDeviceFactory @Inject constructor(
|
internal class VerificationTransportToDeviceFactory @Inject constructor(
|
||||||
private val sendToDeviceTask: SendToDeviceTask,
|
private val sendToDeviceTask: SendToDeviceTask,
|
||||||
private val taskExecutor: TaskExecutor) {
|
private val taskExecutor: TaskExecutor) {
|
||||||
|
|
||||||
|
|
|
@ -64,12 +64,12 @@ class KeyRequestHandler @Inject constructor(private val context: Context)
|
||||||
|
|
||||||
fun start(session: Session) {
|
fun start(session: Session) {
|
||||||
this.session = session
|
this.session = session
|
||||||
session.getSasVerificationService().addListener(this)
|
session.getVerificationService().addListener(this)
|
||||||
session.addRoomKeysRequestListener(this)
|
session.addRoomKeysRequestListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
session?.getSasVerificationService()?.removeListener(this)
|
session?.getVerificationService()?.removeListener(this)
|
||||||
session?.removeRoomKeysRequestListener(this)
|
session?.removeRoomKeysRequestListener(this)
|
||||||
session = null
|
session = null
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,11 +40,11 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context
|
||||||
|
|
||||||
fun start(session: Session) {
|
fun start(session: Session) {
|
||||||
this.session = session
|
this.session = session
|
||||||
session.getSasVerificationService().addListener(this)
|
session.getVerificationService().addListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stop() {
|
fun stop() {
|
||||||
session?.getSasVerificationService()?.removeListener(this)
|
session?.getVerificationService()?.removeListener(this)
|
||||||
this.session = null
|
this.session = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ class IncomingVerificationRequestHandler @Inject constructor(private val context
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dismissedAction = Runnable {
|
dismissedAction = Runnable {
|
||||||
session?.getSasVerificationService()?.declineVerificationRequestInDMs(pr.otherUserId,
|
session?.getVerificationService()?.declineVerificationRequestInDMs(pr.otherUserId,
|
||||||
pr.requestInfo?.fromDevice ?: "",
|
pr.requestInfo?.fromDevice ?: "",
|
||||||
pr.transactionId ?: "",
|
pr.transactionId ?: "",
|
||||||
pr.roomId ?: ""
|
pr.roomId ?: ""
|
||||||
|
|
|
@ -68,11 +68,11 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||||
get() = _requestLiveData
|
get() = _requestLiveData
|
||||||
|
|
||||||
init {
|
init {
|
||||||
session.getSasVerificationService().addListener(this)
|
session.getVerificationService().addListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
session.getSasVerificationService().removeListener(this)
|
session.getVerificationService().removeListener(this)
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,10 +91,10 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||||
|
|
||||||
val userItem = session.getUser(args.otherUserId)
|
val userItem = session.getUser(args.otherUserId)
|
||||||
|
|
||||||
val pr = session.getSasVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
val pr = session.getVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
||||||
|
|
||||||
val sasTx = (pr?.transactionId ?: args.verificationId)?.let {
|
val sasTx = (pr?.transactionId ?: args.verificationId)?.let {
|
||||||
session.getSasVerificationService().getExistingTransaction(args.otherUserId, it)
|
session.getVerificationService().getExistingTransaction(args.otherUserId, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fragment.verificationViewModelFactory.create(VerificationBottomSheetViewState(
|
return fragment.verificationViewModelFactory.create(VerificationBottomSheetViewState(
|
||||||
|
@ -132,7 +132,7 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||||
copy(
|
copy(
|
||||||
roomId = data,
|
roomId = data,
|
||||||
pendingRequest = Success(
|
pendingRequest = Success(
|
||||||
session.getSasVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, data, pendingLocalId)
|
session.getVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, data, pendingLocalId)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -146,16 +146,16 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
setState {
|
setState {
|
||||||
copy(pendingRequest = Success(session.getSasVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, roomId)))
|
copy(pendingRequest = Success(session.getVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, otherUserId, roomId)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is VerificationAction.StartSASVerification -> {
|
is VerificationAction.StartSASVerification -> {
|
||||||
val request = session.getSasVerificationService().getExistingVerificationRequest(otherUserId, action.pendingRequestTransactionId)
|
val request = session.getVerificationService().getExistingVerificationRequest(otherUserId, action.pendingRequestTransactionId)
|
||||||
?: return@withState
|
?: return@withState
|
||||||
if (roomId == null) return@withState
|
if (roomId == null) return@withState
|
||||||
val otherDevice = if (request.isIncoming) request.requestInfo?.fromDevice else request.readyInfo?.fromDevice
|
val otherDevice = if (request.isIncoming) request.requestInfo?.fromDevice else request.readyInfo?.fromDevice
|
||||||
session.getSasVerificationService().beginKeyVerificationInDMs(
|
session.getVerificationService().beginKeyVerificationInDMs(
|
||||||
VerificationMethod.SAS,
|
VerificationMethod.SAS,
|
||||||
transactionId = action.pendingRequestTransactionId,
|
transactionId = action.pendingRequestTransactionId,
|
||||||
roomId = roomId,
|
roomId = roomId,
|
||||||
|
@ -165,19 +165,18 @@ class VerificationBottomSheetViewModel @AssistedInject constructor(@Assisted ini
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is VerificationAction.RemoteQrCodeScanned -> {
|
is VerificationAction.RemoteQrCodeScanned -> {
|
||||||
// TODO Use session.getCrossSigningService()?
|
val existingTransaction = session.getVerificationService()
|
||||||
val existingTransaction = session.getSasVerificationService()
|
|
||||||
.getExistingTransaction(action.userID, action.transactionId) as? QRVerificationTransaction
|
.getExistingTransaction(action.userID, action.transactionId) as? QRVerificationTransaction
|
||||||
existingTransaction
|
existingTransaction
|
||||||
?.userHasScannedRemoteQrCode(action.scannedData)
|
?.userHasScannedRemoteQrCode(action.scannedData)
|
||||||
}
|
}
|
||||||
is VerificationAction.SASMatchAction -> {
|
is VerificationAction.SASMatchAction -> {
|
||||||
(session.getSasVerificationService()
|
(session.getVerificationService()
|
||||||
.getExistingTransaction(action.userID, action.sasTransactionId)
|
.getExistingTransaction(action.userID, action.sasTransactionId)
|
||||||
as? SasVerificationTransaction)?.userHasVerifiedShortCode()
|
as? SasVerificationTransaction)?.userHasVerifiedShortCode()
|
||||||
}
|
}
|
||||||
is VerificationAction.SASDoNotMatchAction -> {
|
is VerificationAction.SASDoNotMatchAction -> {
|
||||||
(session.getSasVerificationService()
|
(session.getVerificationService()
|
||||||
.getExistingTransaction(action.userID, action.sasTransactionId)
|
.getExistingTransaction(action.userID, action.sasTransactionId)
|
||||||
as? SasVerificationTransaction)
|
as? SasVerificationTransaction)
|
||||||
?.shortCodeDoesNotMatch()
|
?.shortCodeDoesNotMatch()
|
||||||
|
|
|
@ -51,7 +51,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||||
override fun transactionUpdated(tx: VerificationTransaction) {}
|
override fun transactionUpdated(tx: VerificationTransaction) {}
|
||||||
|
|
||||||
override fun verificationRequestUpdated(pr: PendingVerificationRequest) = withState { state ->
|
override fun verificationRequestUpdated(pr: PendingVerificationRequest) = withState { state ->
|
||||||
val pvr = session.getSasVerificationService().getExistingVerificationRequest(state.otherUserId, state.transactionId)
|
val pvr = session.getVerificationService().getExistingVerificationRequest(state.otherUserId, state.transactionId)
|
||||||
|
|
||||||
setState {
|
setState {
|
||||||
copy(
|
copy(
|
||||||
|
@ -70,12 +70,12 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
session.getSasVerificationService().addListener(this)
|
session.getVerificationService().addListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
session.getSasVerificationService().removeListener(this)
|
session.getVerificationService().removeListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object : MvRxViewModelFactory<VerificationChooseMethodViewModel, VerificationChooseMethodViewState> {
|
companion object : MvRxViewModelFactory<VerificationChooseMethodViewModel, VerificationChooseMethodViewState> {
|
||||||
|
@ -87,7 +87,7 @@ class VerificationChooseMethodViewModel @AssistedInject constructor(
|
||||||
override fun initialState(viewModelContext: ViewModelContext): VerificationChooseMethodViewState? {
|
override fun initialState(viewModelContext: ViewModelContext): VerificationChooseMethodViewState? {
|
||||||
val args: VerificationBottomSheet.VerificationArgs = viewModelContext.args()
|
val args: VerificationBottomSheet.VerificationArgs = viewModelContext.args()
|
||||||
val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession()
|
val session = (viewModelContext.activity as HasScreenInjector).injector().activeSessionHolder().getActiveSession()
|
||||||
val pvr = session.getSasVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
val pvr = session.getVerificationService().getExistingVerificationRequest(args.otherUserId, args.verificationId)
|
||||||
|
|
||||||
return VerificationChooseMethodViewState(otherUserId = args.otherUserId,
|
return VerificationChooseMethodViewState(otherUserId = args.otherUserId,
|
||||||
transactionId = args.verificationId ?: "",
|
transactionId = args.verificationId ?: "",
|
||||||
|
|
|
@ -48,16 +48,16 @@ class VerificationEmojiCodeViewModel @AssistedInject constructor(
|
||||||
|
|
||||||
init {
|
init {
|
||||||
withState { state ->
|
withState { state ->
|
||||||
refreshStateFromTx(session.getSasVerificationService()
|
refreshStateFromTx(session.getVerificationService()
|
||||||
.getExistingTransaction(state.otherUser?.id ?: "", state.transactionId
|
.getExistingTransaction(state.otherUser?.id ?: "", state.transactionId
|
||||||
?: "") as? SasVerificationTransaction)
|
?: "") as? SasVerificationTransaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getSasVerificationService().addListener(this)
|
session.getVerificationService().addListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
session.getSasVerificationService().removeListener(this)
|
session.getVerificationService().removeListener(this)
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -411,7 +411,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||||
popDraft()
|
popDraft()
|
||||||
}
|
}
|
||||||
is ParsedCommand.VerifyUser -> {
|
is ParsedCommand.VerifyUser -> {
|
||||||
session.getSasVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, slashCommandResult.userId, room.roomId)
|
session.getVerificationService().requestKeyVerificationInDMs(supportedVerificationMethods, slashCommandResult.userId, room.roomId)
|
||||||
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled())
|
_sendMessageResultLiveData.postLiveEvent(SendMessageResult.SlashCommandHandled())
|
||||||
popDraft()
|
popDraft()
|
||||||
}
|
}
|
||||||
|
@ -809,14 +809,14 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||||
|
|
||||||
private fun handleAcceptVerification(action: RoomDetailAction.AcceptVerificationRequest) {
|
private fun handleAcceptVerification(action: RoomDetailAction.AcceptVerificationRequest) {
|
||||||
Timber.v("## SAS handleAcceptVerification ${action.otherUserId}, roomId:${room.roomId}, txId:${action.transactionId}")
|
Timber.v("## SAS handleAcceptVerification ${action.otherUserId}, roomId:${room.roomId}, txId:${action.transactionId}")
|
||||||
if (session.getSasVerificationService().readyPendingVerificationInDMs(action.otherUserId, room.roomId,
|
if (session.getVerificationService().readyPendingVerificationInDMs(action.otherUserId, room.roomId,
|
||||||
action.transactionId)) {
|
action.transactionId)) {
|
||||||
_requestLiveData.postValue(LiveEvent(Success(action)))
|
_requestLiveData.postValue(LiveEvent(Success(action)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleDeclineVerification(action: RoomDetailAction.DeclineVerificationRequest) {
|
private fun handleDeclineVerification(action: RoomDetailAction.DeclineVerificationRequest) {
|
||||||
session.getSasVerificationService().declineVerificationRequestInDMs(
|
session.getVerificationService().declineVerificationRequestInDMs(
|
||||||
action.otherUserId,
|
action.otherUserId,
|
||||||
action.otherdDeviceId,
|
action.otherdDeviceId,
|
||||||
action.transactionId,
|
action.transactionId,
|
||||||
|
@ -830,7 +830,7 @@ class RoomDetailViewModel @AssistedInject constructor(@Assisted initialState: Ro
|
||||||
|
|
||||||
private fun handleResumeRequestVerification(action: RoomDetailAction.ResumeVerification) {
|
private fun handleResumeRequestVerification(action: RoomDetailAction.ResumeVerification) {
|
||||||
// Check if this request is still active and handled by me
|
// Check if this request is still active and handled by me
|
||||||
session.getSasVerificationService().getExistingVerificationRequestInRoom(room.roomId, action.transactionId)?.let {
|
session.getVerificationService().getExistingVerificationRequestInRoom(room.roomId, action.transactionId)?.let {
|
||||||
if (it.handledByOtherSession) return
|
if (it.handledByOtherSession) return
|
||||||
if (!it.isFinished) {
|
if (!it.isFinished) {
|
||||||
_requestLiveData.postValue(LiveEvent(Success(action.copy(
|
_requestLiveData.postValue(LiveEvent(Success(action.copy(
|
||||||
|
|
|
@ -65,7 +65,7 @@ class DefaultNavigator @Inject constructor(
|
||||||
|
|
||||||
override fun performDeviceVerification(context: Context, otherUserId: String, sasTransationId: String) {
|
override fun performDeviceVerification(context: Context, otherUserId: String, sasTransationId: String) {
|
||||||
val session = sessionHolder.getSafeActiveSession() ?: return
|
val session = sessionHolder.getSafeActiveSession() ?: return
|
||||||
val tx = session.getSasVerificationService().getExistingTransaction(otherUserId, sasTransationId) ?: return
|
val tx = session.getVerificationService().getExistingTransaction(otherUserId, sasTransationId) ?: return
|
||||||
(tx as? IncomingSasVerificationTransaction)?.performAccept()
|
(tx as? IncomingSasVerificationTransaction)?.performAccept()
|
||||||
if (context is VectorBaseActivity) {
|
if (context is VectorBaseActivity) {
|
||||||
VerificationBottomSheet.withArgs(
|
VerificationBottomSheet.withArgs(
|
||||||
|
|
|
@ -86,11 +86,11 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||||
|
|
||||||
init {
|
init {
|
||||||
refreshDevicesList()
|
refreshDevicesList()
|
||||||
session.getSasVerificationService().addListener(this)
|
session.getVerificationService().addListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
session.getSasVerificationService().removeListener(this)
|
session.getVerificationService().removeListener(this)
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ class DevicesViewModel @AssistedInject constructor(@Assisted initialState: Devic
|
||||||
|
|
||||||
private fun handleVerify(action: DevicesAction.VerifyMyDevice) {
|
private fun handleVerify(action: DevicesAction.VerifyMyDevice) {
|
||||||
// TODO Implement request in to DEVICE!!!
|
// TODO Implement request in to DEVICE!!!
|
||||||
val txID = session.getSasVerificationService().beginKeyVerification(VerificationMethod.SAS, session.myUserId, action.deviceId)
|
val txID = session.getVerificationService().beginKeyVerification(VerificationMethod.SAS, session.myUserId, action.deviceId)
|
||||||
if (txID != null) {
|
if (txID != null) {
|
||||||
_requestLiveData.postValue(LiveEvent(Success(
|
_requestLiveData.postValue(LiveEvent(Success(
|
||||||
action.copy(
|
action.copy(
|
||||||
|
|
Loading…
Reference in a new issue