From 38819c6ef38d9dbf0591f65adad4a9ae354afa12 Mon Sep 17 00:00:00 2001 From: MohamadJaara Date: Thu, 2 May 2024 21:45:19 +0200 Subject: [PATCH 1/3] chore: cc to rc.59 --- .../CoreCryptoCentral.kt | 8 ++++---- gradle/libs.versions.toml | 2 +- .../kalium/logic/CoreCryptoExceptionMapper.kt | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/CoreCryptoCentral.kt b/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/CoreCryptoCentral.kt index 5eefcb16f63..b3e831bf892 100644 --- a/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/CoreCryptoCentral.kt +++ b/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/CoreCryptoCentral.kt @@ -34,7 +34,7 @@ actual suspend fun coreCryptoCentral( ): CoreCryptoCentral { val path = "$rootDir/${CoreCryptoCentralImpl.KEYSTORE_NAME}" File(rootDir).mkdirs() - val coreCrypto = coreCryptoDeferredInit(path, databaseKey, allowedCipherSuites, null) + val coreCrypto = coreCryptoDeferredInit(path, databaseKey) coreCrypto.setCallbacks(Callbacks()) return CoreCryptoCentralImpl( cc = coreCrypto, @@ -46,12 +46,12 @@ actual suspend fun coreCryptoCentral( private class Callbacks : CoreCryptoCallbacks { - override fun authorize(conversationId: ByteArray, clientId: ClientId): Boolean { + override suspend fun authorize(conversationId: ByteArray, clientId: ClientId): Boolean { // We always return true because our BE is currently enforcing that this constraint is always true return true } - override fun clientIsExistingGroupUser( + override suspend fun clientIsExistingGroupUser( conversationId: ConversationId, clientId: ClientId, existingClients: List, @@ -61,7 +61,7 @@ private class Callbacks : CoreCryptoCallbacks { return true } - override fun userAuthorize( + override suspend fun userAuthorize( conversationId: ConversationId, externalClientId: ClientId, existingClients: List diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 56277f7296b..9aa75fe1766 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -37,7 +37,7 @@ pbandk = "0.14.2" turbine = "1.0.0" avs = "9.6.13" jna = "5.14.0" -core-crypto = "1.0.0-rc.56-hotfix.1" +core-crypto = "1.0.0-rc.59" core-crypto-multiplatform = "0.6.0-rc.3-multiplatform-pre1" completeKotlin = "1.1.0" desugar-jdk = "2.0.4" diff --git a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt index c67d4c181f0..78f27826907 100644 --- a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt +++ b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt @@ -23,15 +23,15 @@ import uniffi.core_crypto.CryptoError actual fun mapMLSException(exception: Exception): MLSFailure = if (exception is CoreCryptoException.CryptoException) { when (exception.error) { - is CryptoError.WrongEpoch -> MLSFailure.WrongEpoch - is CryptoError.DuplicateMessage -> MLSFailure.DuplicateMessage - is CryptoError.BufferedFutureMessage -> MLSFailure.BufferedFutureMessage - is CryptoError.SelfCommitIgnored -> MLSFailure.SelfCommitIgnored - is CryptoError.UnmergedPendingGroup -> MLSFailure.UnmergedPendingGroup - is CryptoError.StaleProposal -> MLSFailure.StaleProposal - is CryptoError.StaleCommit -> MLSFailure.StaleCommit - is CryptoError.ConversationAlreadyExists -> MLSFailure.ConversationAlreadyExists - is CryptoError.MessageEpochTooOld -> MLSFailure.MessageEpochTooOld + CryptoError.WRONG_EPOCH -> MLSFailure.WrongEpoch + CryptoError.DUPLICATE_MESSAGE -> MLSFailure.DuplicateMessage + CryptoError.BUFFERED_FUTURE_MESSAGE -> MLSFailure.BufferedFutureMessage + CryptoError.SELF_COMMIT_IGNORED -> MLSFailure.SelfCommitIgnored + CryptoError.UNMERGED_PENDING_GROUP -> MLSFailure.UnmergedPendingGroup + CryptoError.STALE_PROPOSAL -> MLSFailure.StaleProposal + CryptoError.STALE_COMMIT -> MLSFailure.StaleCommit + CryptoError.CONVERSATION_ALREADY_EXISTS -> MLSFailure.ConversationAlreadyExists + CryptoError.MESSAGE_EPOCH_TOO_OLD -> MLSFailure.MessageEpochTooOld else -> MLSFailure.Generic(exception) } } else { From fe8cf4ffe722de589bb4d2302a4a20dfb070a361 Mon Sep 17 00:00:00 2001 From: MohamadJaara Date: Mon, 6 May 2024 12:43:16 +0200 Subject: [PATCH 2/3] fix test --- .../kotlin/com/wire/kalium/cryptography/ProteusClientTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptography/src/commonTest/kotlin/com/wire/kalium/cryptography/ProteusClientTest.kt b/cryptography/src/commonTest/kotlin/com/wire/kalium/cryptography/ProteusClientTest.kt index 82eca15fece..ec4f95be564 100644 --- a/cryptography/src/commonTest/kotlin/com/wire/kalium/cryptography/ProteusClientTest.kt +++ b/cryptography/src/commonTest/kotlin/com/wire/kalium/cryptography/ProteusClientTest.kt @@ -39,7 +39,7 @@ class ProteusClientTest : BaseProteusClientTest() { private val alice = SampleUser(CryptoUserID("aliceId", "aliceDomain"), "Alice") private val bob = SampleUser(CryptoUserID("bobId", "bobDomain"), "Bob") private val aliceSessionId = CryptoSessionId(alice.id, CryptoClientId("aliceClient")) - private val bobSessionId = CryptoSessionId(alice.id, CryptoClientId("aliceClient")) + private val bobSessionId = CryptoSessionId(bob.id, CryptoClientId("bobClient")) @BeforeTest fun before() { From a50a9298c07676f709d6b060cee6c1791896f4a6 Mon Sep 17 00:00:00 2001 From: MohamadJaara Date: Mon, 6 May 2024 20:51:52 +0200 Subject: [PATCH 3/3] use CC vrc.56.hotfix.2 --- .../CoreCryptoCentral.kt | 8 ++--- gradle/libs.versions.toml | 2 +- .../kalium/logic/CoreCryptoExceptionMapper.kt | 30 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/CoreCryptoCentral.kt b/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/CoreCryptoCentral.kt index b3e831bf892..5eefcb16f63 100644 --- a/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/CoreCryptoCentral.kt +++ b/cryptography/src/commonJvmAndroid/kotlin/com.wire.kalium.cryptography/CoreCryptoCentral.kt @@ -34,7 +34,7 @@ actual suspend fun coreCryptoCentral( ): CoreCryptoCentral { val path = "$rootDir/${CoreCryptoCentralImpl.KEYSTORE_NAME}" File(rootDir).mkdirs() - val coreCrypto = coreCryptoDeferredInit(path, databaseKey) + val coreCrypto = coreCryptoDeferredInit(path, databaseKey, allowedCipherSuites, null) coreCrypto.setCallbacks(Callbacks()) return CoreCryptoCentralImpl( cc = coreCrypto, @@ -46,12 +46,12 @@ actual suspend fun coreCryptoCentral( private class Callbacks : CoreCryptoCallbacks { - override suspend fun authorize(conversationId: ByteArray, clientId: ClientId): Boolean { + override fun authorize(conversationId: ByteArray, clientId: ClientId): Boolean { // We always return true because our BE is currently enforcing that this constraint is always true return true } - override suspend fun clientIsExistingGroupUser( + override fun clientIsExistingGroupUser( conversationId: ConversationId, clientId: ClientId, existingClients: List, @@ -61,7 +61,7 @@ private class Callbacks : CoreCryptoCallbacks { return true } - override suspend fun userAuthorize( + override fun userAuthorize( conversationId: ConversationId, externalClientId: ClientId, existingClients: List diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9aa75fe1766..25b0685c396 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -37,7 +37,7 @@ pbandk = "0.14.2" turbine = "1.0.0" avs = "9.6.13" jna = "5.14.0" -core-crypto = "1.0.0-rc.59" +core-crypto = "1.0.0-rc.56-hotfix.2" core-crypto-multiplatform = "0.6.0-rc.3-multiplatform-pre1" completeKotlin = "1.1.0" desugar-jdk = "2.0.4" diff --git a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt index 78f27826907..d4ba1b1e45e 100644 --- a/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt +++ b/logic/src/commonJvmAndroid/kotlin/com/wire/kalium/logic/CoreCryptoExceptionMapper.kt @@ -21,19 +21,19 @@ import com.wire.crypto.CoreCryptoException import uniffi.core_crypto.CryptoError actual fun mapMLSException(exception: Exception): MLSFailure = - if (exception is CoreCryptoException.CryptoException) { - when (exception.error) { - CryptoError.WRONG_EPOCH -> MLSFailure.WrongEpoch - CryptoError.DUPLICATE_MESSAGE -> MLSFailure.DuplicateMessage - CryptoError.BUFFERED_FUTURE_MESSAGE -> MLSFailure.BufferedFutureMessage - CryptoError.SELF_COMMIT_IGNORED -> MLSFailure.SelfCommitIgnored - CryptoError.UNMERGED_PENDING_GROUP -> MLSFailure.UnmergedPendingGroup - CryptoError.STALE_PROPOSAL -> MLSFailure.StaleProposal - CryptoError.STALE_COMMIT -> MLSFailure.StaleCommit - CryptoError.CONVERSATION_ALREADY_EXISTS -> MLSFailure.ConversationAlreadyExists - CryptoError.MESSAGE_EPOCH_TOO_OLD -> MLSFailure.MessageEpochTooOld - else -> MLSFailure.Generic(exception) - } - } else { - MLSFailure.Generic(exception) + if (exception is CoreCryptoException.CryptoException) { + when (exception.error) { + is CryptoError.WrongEpoch -> MLSFailure.WrongEpoch + is CryptoError.DuplicateMessage -> MLSFailure.DuplicateMessage + is CryptoError.BufferedFutureMessage -> MLSFailure.BufferedFutureMessage + is CryptoError.SelfCommitIgnored -> MLSFailure.SelfCommitIgnored + is CryptoError.UnmergedPendingGroup -> MLSFailure.UnmergedPendingGroup + is CryptoError.StaleProposal -> MLSFailure.StaleProposal + is CryptoError.StaleCommit -> MLSFailure.StaleCommit + is CryptoError.ConversationAlreadyExists -> MLSFailure.ConversationAlreadyExists + is CryptoError.MessageEpochTooOld -> MLSFailure.MessageEpochTooOld + else -> MLSFailure.Generic(exception) } + } else { + MLSFailure.Generic(exception) + }