diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/event/Event.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/event/Event.kt index 8a580fd5514..a97e8d89511 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/event/Event.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/data/event/Event.kt @@ -390,14 +390,16 @@ sealed class Event(open val id: String) { val uri: String?, val isPasswordProtected: Boolean, ) : Conversation(id, conversationId) { - override fun toLogMap(): Map = mapOf(typeKey to "Conversation.CodeUpdated") + override fun toLogMap(): Map = + mapOf(typeKey to "Conversation.CodeUpdated") } data class CodeDeleted( override val id: String, override val conversationId: ConversationId, ) : Conversation(id, conversationId) { - override fun toLogMap(): Map = mapOf(typeKey to "Conversation.CodeDeleted") + override fun toLogMap(): Map = + mapOf(typeKey to "Conversation.CodeDeleted") } data class TypingIndicator( diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandler.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandler.kt index b1db1765b00..fea1b061e74 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandler.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/sync/receiver/conversation/NewConversationEventHandler.kt @@ -59,10 +59,17 @@ internal class NewConversationEventHandlerImpl( .flatMap { isNewUnhandledConversation -> resolveConversationIfOneOnOne(selfUserTeamId, event) .flatMap { - conversationRepository.updateConversationModifiedDate(event.conversationId, DateTimeUtil.currentInstant()) + conversationRepository.updateConversationModifiedDate( + event.conversationId, + DateTimeUtil.currentInstant() + ) } .flatMap { - userRepository.fetchUsersIfUnknownByIds(event.conversation.members.otherMembers.map { it.id.toModel() }.toSet()) + userRepository.fetchUsersIfUnknownByIds( + event.conversation.members.otherMembers.map { + it.id.toModel() + }.toSet() + ) } .map { isNewUnhandledConversation } }.onSuccess { isNewUnhandledConversation -> @@ -73,9 +80,13 @@ internal class NewConversationEventHandlerImpl( } } - private suspend fun resolveConversationIfOneOnOne(selfUserTeamId: TeamId?, event: Event.Conversation.NewConversation) = + private suspend fun resolveConversationIfOneOnOne( + selfUserTeamId: TeamId?, + event: Event.Conversation.NewConversation + ) = if (event.conversation.toConversationType(selfUserTeamId) == ConversationEntity.Type.ONE_ON_ONE) { - val otherUserId = event.conversation.members.otherMembers.first().id.toModel() + val otherUserId = + event.conversation.members.otherMembers.first().id.toModel() oneOnOneResolver.resolveOneOnOneConversationWithUserId( userId = otherUserId, invalidateCurrentKnownProtocols = true @@ -94,13 +105,20 @@ internal class NewConversationEventHandlerImpl( event: Event.Conversation.NewConversation ) { if (isNewUnhandledConversation) { - newGroupConversationSystemMessagesCreator.conversationStarted(event.senderUserId, event.conversation, event.dateTime) + newGroupConversationSystemMessagesCreator.conversationStarted( + event.senderUserId, + event.conversation, + event.dateTime + ) newGroupConversationSystemMessagesCreator.conversationResolvedMembersAdded( event.conversationId.toDao(), event.conversation.members.otherMembers.map { it.id.toModel() }, event.dateTime ) - newGroupConversationSystemMessagesCreator.conversationReadReceiptStatus(event.conversation, event.dateTime) + newGroupConversationSystemMessagesCreator.conversationReadReceiptStatus( + event.conversation, + event.dateTime + ) newGroupConversationSystemMessagesCreator.conversationStartedUnverifiedWarning( event.conversation.id.toModel(), event.dateTime diff --git a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/client/ClientRepositoryTest.kt b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/client/ClientRepositoryTest.kt index 8263608edf6..4999236394a 100644 --- a/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/client/ClientRepositoryTest.kt +++ b/logic/src/commonTest/kotlin/com/wire/kalium/logic/data/client/ClientRepositoryTest.kt @@ -36,11 +36,11 @@ import com.wire.kalium.logic.framework.TestEvent import com.wire.kalium.logic.functional.Either import com.wire.kalium.logic.util.shouldFail import com.wire.kalium.logic.util.shouldSucceed -import com.wire.kalium.network.api.base.authenticated.client.ClientApi import com.wire.kalium.network.api.authenticated.client.ClientDTO import com.wire.kalium.network.api.authenticated.client.ClientTypeDTO import com.wire.kalium.network.api.authenticated.client.DeviceTypeDTO import com.wire.kalium.network.api.authenticated.client.SimpleClientResponse +import com.wire.kalium.network.api.base.authenticated.client.ClientApi import com.wire.kalium.network.api.model.ErrorResponse import com.wire.kalium.network.exceptions.KaliumException import com.wire.kalium.network.utils.NetworkResponse @@ -257,7 +257,7 @@ class ClientRepositoryTest { deviceType = DeviceTypeDTO.Desktop, label = null, model = "Mac ox", - capabilities = null, + capabilities = listOf(), mlsPublicKeys = null, cookie = null ), @@ -269,7 +269,7 @@ class ClientRepositoryTest { deviceType = DeviceTypeDTO.Phone, label = null, model = "iphone 15", - capabilities = null, + capabilities = listOf(), mlsPublicKeys = null, cookie = null ) diff --git a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/mocks/client/ClientMocks.kt b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/mocks/client/ClientMocks.kt deleted file mode 100644 index 94c7f1fe86c..00000000000 --- a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/mocks/client/ClientMocks.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Wire - * Copyright (C) 2024 Wire Swiss GmbH - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ -package com.wire.kalium.mocks.mocks.client - -import com.wire.kalium.network.api.authenticated.client.Capabilities -import com.wire.kalium.network.api.authenticated.client.ClientCapabilityDTO -import com.wire.kalium.network.api.authenticated.client.ClientDTO -import com.wire.kalium.network.api.authenticated.client.ClientTypeDTO -import com.wire.kalium.network.api.authenticated.client.DeviceTypeDTO - -object ClientMocks { - - const val selfClientId = "defkrr8e7grgsoufhg8" - - val selfClient = ClientDTO( - clientId = selfClientId, - type = ClientTypeDTO.Permanent, - deviceType = DeviceTypeDTO.Phone, - registrationTime = "2021-05-12T10:52:02.671Z", - lastActive = "2021-05-12T10:52:02.671Z", - label = "label", - cookie = "sldkfmdeklmwldwlek23kl44mntiuepfojfndkjd", - capabilities = Capabilities(listOf(ClientCapabilityDTO.LegalHoldImplicitConsent)), - model = "model", - mlsPublicKeys = null - ) -} diff --git a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/ClientResponseJson.kt b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/ClientResponseJson.kt index 6b5f180ec67..d3d7e0010e1 100644 --- a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/ClientResponseJson.kt +++ b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/ClientResponseJson.kt @@ -18,7 +18,6 @@ package com.wire.kalium.mocks.responses -import com.wire.kalium.network.api.authenticated.client.Capabilities import com.wire.kalium.network.api.authenticated.client.ClientCapabilityDTO import com.wire.kalium.network.api.authenticated.client.ClientDTO import com.wire.kalium.network.api.authenticated.client.ClientTypeDTO @@ -26,6 +25,26 @@ import com.wire.kalium.network.api.authenticated.client.DeviceTypeDTO object ClientResponseJson { private val jsonProvider = { serializable: ClientDTO -> + """ + |{ + | "id": "${serializable.clientId}", + | "type": "${serializable.type}", + | "time": "${serializable.registrationTime}", + | "last_active": "${serializable.lastActive}", + | "class": "${serializable.deviceType}", + | "label": "${serializable.label}", + | "cookie": "${serializable.cookie}", + | "model": "${serializable.model}", + | "capabilities": [ + | "${serializable.capabilities[0]}" + | ], + | "mls_public_keys": ${serializable.mlsPublicKeys} + |} + """.trimMargin() + } + + // This is backwards compatible with the old format till v5 API get deprecated + private val jsonProviderCapabilitiesObject = { serializable: ClientDTO -> """ |{ | "id": "${serializable.clientId}", @@ -38,13 +57,30 @@ object ClientResponseJson { | "model": "${serializable.model}", | "capabilities": { | "capabilities": [ - | "${serializable.capabilities!!.capabilities[0]}" + | "${serializable.capabilities[0]}" | ] | } + | "mls_public_keys": ${serializable.mlsPublicKeys} |} """.trimMargin() } + val validCapabilitiesObject = ValidJsonProvider( + ClientDTO( + clientId = "defkrr8e7grgsoufhg8", + type = ClientTypeDTO.Permanent, + deviceType = DeviceTypeDTO.Phone, + registrationTime = "2021-05-12T10:52:02.671Z", + lastActive = "2021-05-12T10:52:02.671Z", + label = "label", + cookie = "sldkfmdeklmwldwlek23kl44mntiuepfojfndkjd", + capabilities = listOf(ClientCapabilityDTO.LegalHoldImplicitConsent), + model = "model", + mlsPublicKeys = null + ), + jsonProviderCapabilitiesObject + ) + val valid = ValidJsonProvider( ClientDTO( clientId = "defkrr8e7grgsoufhg8", @@ -54,7 +90,7 @@ object ClientResponseJson { lastActive = "2021-05-12T10:52:02.671Z", label = "label", cookie = "sldkfmdeklmwldwlek23kl44mntiuepfojfndkjd", - capabilities = Capabilities(listOf(ClientCapabilityDTO.LegalHoldImplicitConsent)), + capabilities = listOf(ClientCapabilityDTO.LegalHoldImplicitConsent), model = "model", mlsPublicKeys = null ), diff --git a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/ListOfClientsResponseJson.kt b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/ListOfClientsResponseJson.kt index 944d1a4506f..242ce69b754 100644 --- a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/ListOfClientsResponseJson.kt +++ b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/ListOfClientsResponseJson.kt @@ -18,7 +18,6 @@ package com.wire.kalium.mocks.responses -import com.wire.kalium.network.api.authenticated.client.Capabilities import com.wire.kalium.network.api.authenticated.client.ClientCapabilityDTO import com.wire.kalium.network.api.authenticated.client.ClientDTO import com.wire.kalium.network.api.authenticated.client.ClientTypeDTO @@ -38,7 +37,7 @@ object ListOfClientsResponseJson { | "model": "${serializable.model}", | "capabilities": { | "capabilities": [ - | "${serializable.capabilities!!.capabilities[0]}" + | "${serializable.capabilities[0]}" | ] | } |}] @@ -54,7 +53,7 @@ object ListOfClientsResponseJson { lastActive = "2023-05-12T10:52:02.671Z", label = "label", cookie = "sldkfmdeklmwldwlek23kl44mntiuepfojfndkjd", - capabilities = Capabilities(listOf(ClientCapabilityDTO.LegalHoldImplicitConsent)), + capabilities = listOf(ClientCapabilityDTO.LegalHoldImplicitConsent), model = "model", mlsPublicKeys = null ), diff --git a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/NotificationEventsResponseJson.kt b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/NotificationEventsResponseJson.kt index b80008137f6..2d5458837f0 100644 --- a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/NotificationEventsResponseJson.kt +++ b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/NotificationEventsResponseJson.kt @@ -77,7 +77,7 @@ object NotificationEventsResponseJson { type = ClientTypeDTO.Permanent, deviceType = DeviceTypeDTO.Desktop, label = "OS X 10.15 10.15", - capabilities = null, + capabilities = listOf(), mlsPublicKeys = mapOf(Pair("key_variant", "public_key")), ) ), @@ -157,7 +157,7 @@ object NotificationEventsResponseJson { | "id" : "${eventData.qualifiedFrom.value}", | "domain" : "${eventData.qualifiedFrom.domain}" | }, - | "data" : ${ConversationResponseJson.conversationResponseSerializer(eventData.data)}, + | "data" : ${ConversationResponseJson.conversationResponseSerializerV3(eventData.data)}, | "time" : "2022-04-12T13:57:02.414Z", | "type" : "conversation.create" |} diff --git a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/conversation/ConversationResponseJson.kt b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/conversation/ConversationResponseJson.kt index d8a59679053..8fbd78dff25 100644 --- a/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/conversation/ConversationResponseJson.kt +++ b/mocks/src/commonMain/kotlin/com/wire/kalium/mocks/responses/conversation/ConversationResponseJson.kt @@ -24,9 +24,11 @@ import com.wire.kalium.network.api.authenticated.conversation.ConvProtocol import com.wire.kalium.network.api.authenticated.conversation.ConversationMemberDTO import com.wire.kalium.network.api.authenticated.conversation.ConversationMembersResponse import com.wire.kalium.network.api.authenticated.conversation.ConversationResponse +import com.wire.kalium.network.api.authenticated.conversation.ConversationResponseV6 import com.wire.kalium.network.api.authenticated.conversation.MutedStatus import com.wire.kalium.network.api.authenticated.conversation.ReceiptMode import com.wire.kalium.network.api.authenticated.conversation.ServiceReferenceDTO +import com.wire.kalium.network.api.authenticated.serverpublickey.MLSPublicKeysDTO import com.wire.kalium.network.api.model.ConversationAccessDTO import com.wire.kalium.network.api.model.ConversationAccessRoleDTO import com.wire.kalium.network.api.model.QualifiedID @@ -41,95 +43,136 @@ import kotlinx.serialization.json.putJsonObject object ConversationResponseJson { - val conversationResponseSerializer = { it: ConversationResponse -> - buildConversationResponse(it).toString() + val conversationResponseSerializerV6 = { it: ConversationResponseV6 -> + buildConversationResponseV6(it).toString() + } + + val conversationResponseSerializerV3 = { it: ConversationResponse -> + buildConversationResponseV3(it).toString() } val conversationResponseSerializerWithDeprecatedAccessRole = { it: ConversationResponse -> - buildConversationResponse(it, useDeprecatedAccessRole = true).toString() + buildConversationResponseV3(it, useDeprecatedAccessRole = true).toString() } - private val conversationResponse = ConversationResponse( - "fdf23116-42a5-472c-8316-e10655f5d11e", - ConversationMembersResponse( - ConversationMemberDTO.Self( - QualifiedIDSamples.one, - "wire_admin", - otrMutedRef = "2022-04-11T14:15:48.044Z", - otrMutedStatus = MutedStatus.fromOrdinal(0) + private val conversationResponseV6 = ConversationResponseV6( + conversation = ConversationResponse( + "fdf23116-42a5-472c-8316-e10655f5d11e", + ConversationMembersResponse( + ConversationMemberDTO.Self( + QualifiedIDSamples.one, + "wire_admin", + otrMutedRef = "2022-04-11T14:15:48.044Z", + otrMutedStatus = MutedStatus.fromOrdinal(0) + ), + listOf( + ConversationMemberDTO.Other( + id = QualifiedIDSamples.two, + conversationRole = "wire_member" + ) + ) ), - listOf( -// ConversationMemberDTO.Other(id = QualifiedIDSamples.two, conversationRole = "wire_member") - ) - ), - "group name", - QualifiedIDSamples.one, - "groupID", - 0UL, - ConversationResponse.Type.GROUP, - null, - "teamID", - ConvProtocol.PROTEUS, - lastEventTime = "2022-03-30T15:36:00.000Z", - access = setOf(ConversationAccessDTO.INVITE, ConversationAccessDTO.CODE), - accessRole = setOf( - ConversationAccessRoleDTO.GUEST, - ConversationAccessRoleDTO.TEAM_MEMBER, - ConversationAccessRoleDTO.NON_TEAM_MEMBER - ), - mlsCipherSuiteTag = null, - receiptMode = ReceiptMode.DISABLED + "group name", + QualifiedIDSamples.one, + "groupID", + 0UL, + ConversationResponse.Type.GROUP, + null, + "teamID", + ConvProtocol.PROTEUS, + lastEventTime = "2022-03-30T15:36:00.000Z", + access = setOf(ConversationAccessDTO.INVITE, ConversationAccessDTO.CODE), + accessRole = setOf( + ConversationAccessRoleDTO.GUEST, + ConversationAccessRoleDTO.TEAM_MEMBER, + ConversationAccessRoleDTO.NON_TEAM_MEMBER + ), + mlsCipherSuiteTag = null, + receiptMode = ReceiptMode.DISABLED, + + ), + publicKeys = MLSPublicKeysDTO( + removal = mapOf("ecdsa_secp256r1_sha256" to "string", "ed25519" to "string") + ) + ) + + val v6 = ValidJsonProvider( + conversationResponseV6, + conversationResponseSerializerV6 ) val v3 = ValidJsonProvider( - conversationResponse, conversationResponseSerializer + conversationResponseV6.conversation, + conversationResponseSerializerV3 ) fun v0(accessRole: Set? = null) = ValidJsonProvider( - conversationResponse.copy( - accessRole = accessRole ?: conversationResponse.accessRole + conversationResponseV6.conversation.copy( + accessRole = accessRole ?: conversationResponseV6.conversation.accessRole ), conversationResponseSerializerWithDeprecatedAccessRole ) } -fun buildConversationResponse( +fun buildConversationResponseV6( + conversationResponse: ConversationResponseV6, + useDeprecatedAccessRole: Boolean = false, +): JsonObject = buildJsonObject { + putJsonObject("conversation") { + putConversation(conversationResponse.conversation, useDeprecatedAccessRole) + } + putJsonObject("public_keys") { + conversationResponse.publicKeys.removal?.forEach { (key, value) -> + put(key, value) + } + } + +} + +fun buildConversationResponseV3( conversationResponse: ConversationResponse, useDeprecatedAccessRole: Boolean = false -): JsonObject = - buildJsonObject { - put("creator", conversationResponse.creator) - putQualifiedId(conversationResponse.id) - conversationResponse.groupId?.let { put("group_id", it) } - putJsonObject("members") { - putSelfMember(conversationResponse.members.self) - putJsonArray("others") { - conversationResponse.members.otherMembers.forEach { otherMember -> - addJsonObject { - putOtherMember(otherMember) - } +): JsonObject = buildJsonObject { + putConversation(conversationResponse, useDeprecatedAccessRole) +} + +private fun JsonObjectBuilder.putConversation( + conversationResponse: ConversationResponse, + useDeprecatedAccessRole: Boolean +) { + put("creator", conversationResponse.creator) + putQualifiedId(conversationResponse.id) + conversationResponse.groupId?.let { put("group_id", it) } + putJsonObject("members") { + putSelfMember(conversationResponse.members.self) + putJsonArray("others") { + conversationResponse.members.otherMembers.forEach { otherMember -> + addJsonObject { + putOtherMember(otherMember) } } } - put("type", conversationResponse.type.ordinal) - put("protocol", conversationResponse.protocol.toString()) - put("last_event_time", conversationResponse.lastEventTime) - putAccessSet(conversationResponse.access) - if (useDeprecatedAccessRole) { - conversationResponse.accessRole?.let { putDeprecatedAccessRoleSet(it) } - } else { - conversationResponse.accessRole?.let { putAccessRoleSet(it) } - } - conversationResponse.messageTimer?.let { put("message_timer", it) } - conversationResponse.name?.let { put("name", it) } - conversationResponse.teamId?.let { put("team", it) } - conversationResponse.mlsCipherSuiteTag?.let { put("cipher_suite", it) } } - -fun JsonObjectBuilder.putAccessRoleSet(accessRole: Set) = putJsonArray("access_role") { - accessRole.forEach { add(it.toString()) } + put("type", conversationResponse.type.ordinal) + put("protocol", conversationResponse.protocol.toString()) + put("last_event_time", conversationResponse.lastEventTime) + putAccessSet(conversationResponse.access) + if (useDeprecatedAccessRole) { + conversationResponse.accessRole?.let { putDeprecatedAccessRoleSet(it) } + } else { + conversationResponse.accessRole?.let { putAccessRoleSet(it) } + } + conversationResponse.messageTimer?.let { put("message_timer", it) } + conversationResponse.name?.let { put("name", it) } + conversationResponse.teamId?.let { put("team", it) } + conversationResponse.mlsCipherSuiteTag?.let { put("cipher_suite", it) } } +fun JsonObjectBuilder.putAccessRoleSet(accessRole: Set) = + putJsonArray("access_role") { + accessRole.forEach { add(it.toString()) } + } + fun JsonObjectBuilder.putDeprecatedAccessRoleSet(accessRole: Set) = putJsonArray("access_role_v2") { accessRole.forEach { add(it.toString()) } diff --git a/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/client/CapabilitiesDeserializer.kt b/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/client/CapabilitiesDeserializer.kt new file mode 100644 index 00000000000..165eb7c1b0c --- /dev/null +++ b/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/client/CapabilitiesDeserializer.kt @@ -0,0 +1,40 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ +package com.wire.kalium.network.api.authenticated.client + +import kotlinx.serialization.SerializationException +import kotlinx.serialization.builtins.ListSerializer +import kotlinx.serialization.json.JsonArray +import kotlinx.serialization.json.JsonElement +import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.JsonTransformingSerializer + +/** + * Sometimes the capabilities are wrapped in an object, sometimes they are just an array. + * See [documentation](https://wearezeta.atlassian.net/wiki/spaces/ENGINEERIN/pages/1309868033/API+changes+v6+v7) + */ +object CapabilitiesDeserializer : + JsonTransformingSerializer>(ListSerializer(ClientCapabilityDTO.serializer())) { + override fun transformDeserialize(element: JsonElement): JsonElement { + return when { + element is JsonObject && element.containsKey("capabilities") -> element["capabilities"]!! + element is JsonArray -> element + else -> throw SerializationException("Unexpected JSON format for capabilities") + } + } +} diff --git a/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/client/ClientDTO.kt b/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/client/ClientDTO.kt index 9d070bfa2bd..c8253498b87 100644 --- a/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/client/ClientDTO.kt +++ b/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/client/ClientDTO.kt @@ -30,7 +30,9 @@ data class ClientDTO( @SerialName("id") val clientId: String, @SerialName("type") val type: ClientTypeDTO, @SerialName("class") val deviceType: DeviceTypeDTO = DeviceTypeDTO.Unknown, - @SerialName("capabilities") val capabilities: Capabilities?, + @SerialName("capabilities") + @Serializable(with = CapabilitiesDeserializer::class) + val capabilities: List, @SerialName("label") val label: String?, @SerialName("mls_public_keys") val mlsPublicKeys: Map? ) diff --git a/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/conversation/ConversationResponse.kt b/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/conversation/ConversationResponse.kt index 1b017ee34cf..71452d4f8b8 100644 --- a/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/conversation/ConversationResponse.kt +++ b/network-model/src/commonMain/kotlin/com/wire/kalium/network/api/authenticated/conversation/ConversationResponse.kt @@ -106,6 +106,9 @@ data class ConversationResponse( fun fromId(id: Int): Type = values().first { type -> type.id == id } } } + + fun toV6(): ConversationResponseV6 = + ConversationResponseV6(this, publicKeys ?: MLSPublicKeysDTO(null)) } @Serializable diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/BackendMetaDataUtil.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/BackendMetaDataUtil.kt index 1053fd2ecdc..4ddf1328f87 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/BackendMetaDataUtil.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/BackendMetaDataUtil.kt @@ -25,7 +25,7 @@ import com.wire.kalium.network.api.unbound.configuration.ServerConfigDTO import com.wire.kalium.network.api.unbound.versioning.VersionInfoDTO val SupportedApiVersions = setOf(0, 1, 2, 4, 5) -val DevelopmentApiVersions = setOf(6) +val DevelopmentApiVersions = setOf(6, 7) interface BackendMetaDataUtil { fun calculateApiVersion( diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/KaliumHttpLogger.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/KaliumHttpLogger.kt index e4593409cf7..e42ee3431d5 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/KaliumHttpLogger.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/KaliumHttpLogger.kt @@ -24,7 +24,6 @@ import com.wire.kalium.network.utils.obfuscatePath import com.wire.kalium.network.utils.obfuscatedJsonMessage import com.wire.kalium.util.serialization.toJsonElement import io.ktor.client.plugins.logging.LogLevel -import io.ktor.client.plugins.logging.Logger import io.ktor.client.request.HttpRequest import io.ktor.client.request.HttpRequestBuilder import io.ktor.client.statement.HttpResponse @@ -41,7 +40,6 @@ import kotlinx.coroutines.Job internal class KaliumHttpLogger( private val level: LogLevel, - private val logger: Logger, private val kaliumLogger: KaliumLogger, ) { private val requestLog = mutableMapOf() @@ -134,7 +132,7 @@ internal class KaliumHttpLogger( } } - suspend fun logResponseBody(contentType: ContentType?, content: ByteReadChannel): Unit = with(logger) { + suspend fun logResponseBody(contentType: ContentType?, content: ByteReadChannel) { responseHeaderMonitor.join() val text = content.tryReadText(contentType?.charset() ?: Charsets.UTF_8) ?: "\"response body omitted\"" diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/KaliumKtorCustomLogging.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/KaliumKtorCustomLogging.kt index 30a88e2b376..36681582bca 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/KaliumKtorCustomLogging.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/KaliumKtorCustomLogging.kt @@ -49,17 +49,17 @@ private val DisableLogging = AttributeKey("DisableLogging") * A client's logging plugin. */ @Suppress("TooGenericExceptionCaught", "EmptyFinallyBlock") -public class KaliumKtorCustomLogging private constructor( - public val logger: Logger, - public val kaliumLogger: KaliumLogger, - public var level: LogLevel, - public var filters: List<(HttpRequestBuilder) -> Boolean> = emptyList() +class KaliumKtorCustomLogging private constructor( + val logger: Logger, + val kaliumLogger: KaliumLogger, + var level: LogLevel, + var filters: List<(HttpRequestBuilder) -> Boolean> = emptyList() ) { /** * [Logging] plugin configuration */ - public class Config { + class Config { /** * filters */ @@ -70,7 +70,7 @@ public class KaliumKtorCustomLogging private constructor( /** * [Logger] instance to use */ - public var logger: Logger + var logger: Logger get() = _logger ?: Logger.DEFAULT set(value) { _logger = value @@ -79,7 +79,7 @@ public class KaliumKtorCustomLogging private constructor( /** * log [LogLevel] */ - public var level: LogLevel = LogLevel.HEADERS + var level: LogLevel = LogLevel.HEADERS /** * [KaliumLogger] instance to use @@ -89,7 +89,7 @@ public class KaliumKtorCustomLogging private constructor( /** * Log messages for calls matching a [predicate] */ - public fun filter(predicate: (HttpRequestBuilder) -> Boolean) { + fun filter(predicate: (HttpRequestBuilder) -> Boolean) { filters.add(predicate) } } @@ -171,7 +171,7 @@ public class KaliumKtorCustomLogging private constructor( } private fun logRequest(request: HttpRequestBuilder): OutgoingContent? { - val logger = KaliumHttpLogger(level, logger, kaliumLogger) + val logger = KaliumHttpLogger(level, kaliumLogger) request.attributes.put(KaliumHttpCustomLogger, logger) logger.logRequest(request) @@ -181,7 +181,7 @@ public class KaliumKtorCustomLogging private constructor( return null } - public companion object : HttpClientPlugin { + companion object : HttpClientPlugin { override val key: AttributeKey = AttributeKey("ClientLogging") override fun prepare(block: Config.() -> Unit): KaliumKtorCustomLogging { @@ -214,7 +214,7 @@ public class KaliumKtorCustomLogging private constructor( * Configure and install [Logging] in [HttpClient]. */ @Suppress("FunctionNaming") -public fun HttpClientConfig<*>.Logging(block: Logging.Config.() -> Unit = {}) { +fun HttpClientConfig<*>.Logging(block: Logging.Config.() -> Unit = {}) { install(Logging, block) } diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/conversation/ConversationApi.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/conversation/ConversationApi.kt index 28fd67cb099..22bc70f3a0d 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/conversation/ConversationApi.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/conversation/ConversationApi.kt @@ -18,23 +18,12 @@ package com.wire.kalium.network.api.base.authenticated.conversation -import com.wire.kalium.network.api.base.authenticated.BaseApi import com.wire.kalium.network.api.authenticated.conversation.AddConversationMembersRequest -import com.wire.kalium.network.api.authenticated.conversation.guestroomlink.ConversationInviteLinkResponse -import com.wire.kalium.network.api.authenticated.conversation.model.ConversationCodeInfo -import com.wire.kalium.network.api.authenticated.conversation.model.ConversationMemberRoleDTO -import com.wire.kalium.network.api.authenticated.conversation.model.ConversationReceiptModeDTO -import com.wire.kalium.network.api.authenticated.notification.EventContentDTO -import com.wire.kalium.network.api.model.ConversationId -import com.wire.kalium.network.api.model.QualifiedID -import com.wire.kalium.network.api.model.ServiceAddedResponse import com.wire.kalium.network.api.authenticated.conversation.AddServiceRequest import com.wire.kalium.network.api.authenticated.conversation.ConvProtocol import com.wire.kalium.network.api.authenticated.conversation.ConversationMemberAddedResponse import com.wire.kalium.network.api.authenticated.conversation.ConversationMemberRemovedResponse import com.wire.kalium.network.api.authenticated.conversation.ConversationPagingResponse -import com.wire.kalium.network.api.model.SubconversationId -import com.wire.kalium.network.api.model.UserId import com.wire.kalium.network.api.authenticated.conversation.ConversationRenameResponse import com.wire.kalium.network.api.authenticated.conversation.ConversationResponse import com.wire.kalium.network.api.authenticated.conversation.ConversationResponseDTO @@ -47,6 +36,17 @@ import com.wire.kalium.network.api.authenticated.conversation.UpdateConversation import com.wire.kalium.network.api.authenticated.conversation.UpdateConversationAccessResponse import com.wire.kalium.network.api.authenticated.conversation.UpdateConversationProtocolResponse import com.wire.kalium.network.api.authenticated.conversation.UpdateConversationReceiptModeResponse +import com.wire.kalium.network.api.authenticated.conversation.guestroomlink.ConversationInviteLinkResponse +import com.wire.kalium.network.api.authenticated.conversation.model.ConversationCodeInfo +import com.wire.kalium.network.api.authenticated.conversation.model.ConversationMemberRoleDTO +import com.wire.kalium.network.api.authenticated.conversation.model.ConversationReceiptModeDTO +import com.wire.kalium.network.api.authenticated.notification.EventContentDTO +import com.wire.kalium.network.api.base.authenticated.BaseApi +import com.wire.kalium.network.api.model.ConversationId +import com.wire.kalium.network.api.model.QualifiedID +import com.wire.kalium.network.api.model.ServiceAddedResponse +import com.wire.kalium.network.api.model.SubconversationId +import com.wire.kalium.network.api.model.UserId import com.wire.kalium.network.exceptions.APINotSupported import com.wire.kalium.network.utils.NetworkResponse @@ -75,10 +75,6 @@ interface ConversationApi : BaseApi { createConversationRequest: CreateConversationRequest ): NetworkResponse - suspend fun createOne2OneConversation( - createConversationRequest: CreateConversationRequest - ): NetworkResponse - suspend fun addMember( addParticipantRequest: AddConversationMembersRequest, conversationId: ConversationId diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/notification/NotificationApi.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/notification/NotificationApi.kt index 999f8abf99f..35586b6ab6c 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/notification/NotificationApi.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/notification/NotificationApi.kt @@ -35,9 +35,7 @@ sealed class WebSocketEvent { other as NonBinaryPayloadReceived<*> - if (!payload.contentEquals(other.payload)) return false - - return true + return payload.contentEquals(other.payload) } override fun hashCode(): Int { diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/ConversationApiV0.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/ConversationApiV0.kt index 5d2f3963694..145a833620f 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/ConversationApiV0.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/ConversationApiV0.kt @@ -22,7 +22,6 @@ import com.wire.kalium.network.AuthenticatedNetworkClient import com.wire.kalium.network.api.authenticated.conversation.AddConversationMembersRequest import com.wire.kalium.network.api.authenticated.conversation.AddServiceRequest import com.wire.kalium.network.api.authenticated.conversation.ConvProtocol -import com.wire.kalium.network.api.base.authenticated.conversation.ConversationApi import com.wire.kalium.network.api.authenticated.conversation.ConversationMemberAddedResponse import com.wire.kalium.network.api.authenticated.conversation.ConversationMemberRemovedResponse import com.wire.kalium.network.api.authenticated.conversation.ConversationPagingResponse @@ -46,6 +45,7 @@ import com.wire.kalium.network.api.authenticated.conversation.model.Conversation import com.wire.kalium.network.api.authenticated.conversation.model.ConversationMemberRoleDTO import com.wire.kalium.network.api.authenticated.conversation.model.ConversationReceiptModeDTO import com.wire.kalium.network.api.authenticated.notification.EventContentDTO +import com.wire.kalium.network.api.base.authenticated.conversation.ConversationApi import com.wire.kalium.network.api.model.AddServiceResponse import com.wire.kalium.network.api.model.ConversationId import com.wire.kalium.network.api.model.JoinConversationRequestV0 @@ -115,14 +115,6 @@ internal open class ConversationApiV0 internal constructor( } } - override suspend fun createOne2OneConversation( - createConversationRequest: CreateConversationRequest - ): NetworkResponse = wrapKaliumResponse { - httpClient.post("$PATH_CONVERSATIONS/$PATH_ONE_2_ONE") { - setBody(createConversationRequest) - } - } - /** * returns 200 conversation created or 204 conversation unchanged */ @@ -407,7 +399,6 @@ internal open class ConversationApiV0 internal constructor( const val PATH_CONVERSATIONS = "conversations" const val PATH_SELF = "self" const val PATH_MEMBERS = "members" - const val PATH_ONE_2_ONE = "one2one" const val PATH_V2 = "v2" const val PATH_CONVERSATIONS_LIST = "list" const val PATH_LIST_IDS = "list-ids" diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/PreKeyApiV2.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/PreKeyApiV2.kt index e643102c839..a1d8b277740 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/PreKeyApiV2.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/PreKeyApiV2.kt @@ -22,5 +22,5 @@ import com.wire.kalium.network.AuthenticatedNetworkClient import com.wire.kalium.network.api.v0.authenticated.PreKeyApiV0 internal open class PreKeyApiV2 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient + authenticatedNetworkClient: AuthenticatedNetworkClient ) : PreKeyApiV0(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/PropertiesApiV2.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/PropertiesApiV2.kt index 9abc1d89dbb..107d524c138 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/PropertiesApiV2.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v2/authenticated/PropertiesApiV2.kt @@ -22,5 +22,5 @@ import com.wire.kalium.network.AuthenticatedNetworkClient import com.wire.kalium.network.api.v0.authenticated.PropertiesApiV0 internal open class PropertiesApiV2 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient, + authenticatedNetworkClient: AuthenticatedNetworkClient, ) : PropertiesApiV0(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/ConversationApiV3.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/ConversationApiV3.kt index f70aed1e7a2..1e2c7052f33 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/ConversationApiV3.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/ConversationApiV3.kt @@ -77,16 +77,6 @@ internal open class ConversationApiV3 internal constructor( apiModelMapper.fromApiV3(it) } - override suspend fun createOne2OneConversation( - createConversationRequest: CreateConversationRequest - ): NetworkResponse = wrapKaliumResponse { - httpClient.post("$PATH_CONVERSATIONS/$PATH_ONE_2_ONE") { - setBody(apiModelMapper.toApiV3(createConversationRequest)) - } - }.mapSuccess { - apiModelMapper.fromApiV3(it) - } - override suspend fun updateAccess( conversationId: ConversationId, updateConversationAccessRequest: UpdateConversationAccessRequest diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/PropertiesApiV3.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/PropertiesApiV3.kt index ebf2fbe0489..b77b93f3767 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/PropertiesApiV3.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v3/authenticated/PropertiesApiV3.kt @@ -22,5 +22,5 @@ import com.wire.kalium.network.AuthenticatedNetworkClient import com.wire.kalium.network.api.v2.authenticated.PropertiesApiV2 internal open class PropertiesApiV3 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient, + authenticatedNetworkClient: AuthenticatedNetworkClient, ) : PropertiesApiV2(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/AccessTokenApiV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/AccessTokenApiV4.kt index d600fb6f3fb..f72a7fc0c28 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/AccessTokenApiV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/AccessTokenApiV4.kt @@ -22,5 +22,5 @@ import com.wire.kalium.network.api.v3.authenticated.AccessTokenApiV3 import io.ktor.client.HttpClient internal open class AccessTokenApiV4 internal constructor( - private val httpClient: HttpClient + httpClient: HttpClient ) : AccessTokenApiV3(httpClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/NotificationApiV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/NotificationApiV4.kt index 708ab68f776..11b383fbd2c 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/NotificationApiV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/NotificationApiV4.kt @@ -24,7 +24,7 @@ import com.wire.kalium.network.api.unbound.configuration.ServerConfigDTO import com.wire.kalium.network.api.v3.authenticated.NotificationApiV3 internal open class NotificationApiV4 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient, + authenticatedNetworkClient: AuthenticatedNetworkClient, authenticatedWebSocketClient: AuthenticatedWebSocketClient, serverLinks: ServerConfigDTO.Links ) : NotificationApiV3(authenticatedNetworkClient, authenticatedWebSocketClient, serverLinks) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/PropertiesApiV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/PropertiesApiV4.kt index 2bfa3a5fa7c..9333d602a4f 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/PropertiesApiV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/PropertiesApiV4.kt @@ -22,5 +22,5 @@ import com.wire.kalium.network.AuthenticatedNetworkClient import com.wire.kalium.network.api.v3.authenticated.PropertiesApiV3 internal open class PropertiesApiV4 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient, + authenticatedNetworkClient: AuthenticatedNetworkClient, ) : PropertiesApiV3(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AccessTokenApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AccessTokenApiV5.kt index 6dc480fd107..927a1919dc1 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AccessTokenApiV5.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AccessTokenApiV5.kt @@ -22,5 +22,5 @@ import com.wire.kalium.network.api.v4.authenticated.AccessTokenApiV4 import io.ktor.client.HttpClient internal open class AccessTokenApiV5 internal constructor( - private val httpClient: HttpClient + httpClient: HttpClient ) : AccessTokenApiV4(httpClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/NotificationApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/NotificationApiV5.kt index cb50ef1396a..52e0e02168b 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/NotificationApiV5.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/NotificationApiV5.kt @@ -24,7 +24,7 @@ import com.wire.kalium.network.api.unbound.configuration.ServerConfigDTO import com.wire.kalium.network.api.v4.authenticated.NotificationApiV4 internal open class NotificationApiV5 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient, + authenticatedNetworkClient: AuthenticatedNetworkClient, authenticatedWebSocketClient: AuthenticatedWebSocketClient, serverLinks: ServerConfigDTO.Links ) : NotificationApiV4(authenticatedNetworkClient, authenticatedWebSocketClient, serverLinks) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/AccessTokenApiV6.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/AccessTokenApiV6.kt index a37f21cd1a8..6818f2f8384 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/AccessTokenApiV6.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/AccessTokenApiV6.kt @@ -21,6 +21,6 @@ package com.wire.kalium.network.api.v6.authenticated import com.wire.kalium.network.api.v5.authenticated.AccessTokenApiV5 import io.ktor.client.HttpClient -internal class AccessTokenApiV6 internal constructor( - private val httpClient: HttpClient +internal open class AccessTokenApiV6 internal constructor( + httpClient: HttpClient ) : AccessTokenApiV5(httpClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/E2EIApiV6.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/E2EIApiV6.kt index 62c439c72c8..b11c94f0729 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/E2EIApiV6.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/E2EIApiV6.kt @@ -21,5 +21,5 @@ import com.wire.kalium.network.AuthenticatedNetworkClient import com.wire.kalium.network.api.v5.authenticated.E2EIApiV5 internal open class E2EIApiV6 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient + authenticatedNetworkClient: AuthenticatedNetworkClient ) : E2EIApiV5(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/KeyPackageApiV6.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/KeyPackageApiV6.kt index f4c82848c04..57405a23ff6 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/KeyPackageApiV6.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/KeyPackageApiV6.kt @@ -22,5 +22,5 @@ import com.wire.kalium.network.AuthenticatedNetworkClient import com.wire.kalium.network.api.v5.authenticated.KeyPackageApiV5 internal open class KeyPackageApiV6 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient + authenticatedNetworkClient: AuthenticatedNetworkClient ) : KeyPackageApiV5(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSMessageApiV6.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSMessageApiV6.kt index 00a28b82330..11aaa5924a0 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSMessageApiV6.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSMessageApiV6.kt @@ -22,5 +22,5 @@ import com.wire.kalium.network.AuthenticatedNetworkClient import com.wire.kalium.network.api.v5.authenticated.MLSMessageApiV5 internal open class MLSMessageApiV6 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient + authenticatedNetworkClient: AuthenticatedNetworkClient ) : MLSMessageApiV5(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSPublicKeyApiV6.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSPublicKeyApiV6.kt index 2657848f35d..2f4978f8d53 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSPublicKeyApiV6.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/MLSPublicKeyApiV6.kt @@ -22,5 +22,5 @@ import com.wire.kalium.network.AuthenticatedNetworkClient import com.wire.kalium.network.api.v5.authenticated.MLSPublicKeyApiV5 internal open class MLSPublicKeyApiV6 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient + authenticatedNetworkClient: AuthenticatedNetworkClient ) : MLSPublicKeyApiV5(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/NotificationApiV6.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/NotificationApiV6.kt index efe6083f0a4..e5883353969 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/NotificationApiV6.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v6/authenticated/NotificationApiV6.kt @@ -24,7 +24,7 @@ import com.wire.kalium.network.api.unbound.configuration.ServerConfigDTO import com.wire.kalium.network.api.v5.authenticated.NotificationApiV5 internal open class NotificationApiV6 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient, + authenticatedNetworkClient: AuthenticatedNetworkClient, authenticatedWebSocketClient: AuthenticatedWebSocketClient, serverLinks: ServerConfigDTO.Links ) : NotificationApiV5(authenticatedNetworkClient, authenticatedWebSocketClient, serverLinks) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/AccessTokenApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/AccessTokenApiV7.kt new file mode 100644 index 00000000000..cd092f4574e --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/AccessTokenApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.api.v6.authenticated.AccessTokenApiV6 +import io.ktor.client.HttpClient + +internal open class AccessTokenApiV7 internal constructor( + httpClient: HttpClient +) : AccessTokenApiV6(httpClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/AssetApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/AssetApiV7.kt new file mode 100644 index 00000000000..8777e69fdc1 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/AssetApiV7.kt @@ -0,0 +1,28 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.model.UserId +import com.wire.kalium.network.api.v6.authenticated.AssetApiV6 + +internal open class AssetApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + selfUserId: UserId +) : AssetApiV6(authenticatedNetworkClient, selfUserId) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/CallApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/CallApiV7.kt new file mode 100644 index 00000000000..09496e880a2 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/CallApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.CallApiV6 + +internal open class CallApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : CallApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/ClientApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/ClientApiV7.kt new file mode 100644 index 00000000000..2f3946f13ed --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/ClientApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.ClientApiV6 + +internal open class ClientApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : ClientApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/ConnectionApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/ConnectionApiV7.kt new file mode 100644 index 00000000000..b3dbf8c4d26 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/ConnectionApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.ConnectionApiV6 + +internal open class ConnectionApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : ConnectionApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/ConversationApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/ConversationApiV7.kt new file mode 100644 index 00000000000..cd10ebd3b2f --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/ConversationApiV7.kt @@ -0,0 +1,48 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.authenticated.conversation.ConversationResponse +import com.wire.kalium.network.api.authenticated.conversation.ConversationResponseV6 +import com.wire.kalium.network.api.model.ApiModelMapper +import com.wire.kalium.network.api.model.ApiModelMapperImpl +import com.wire.kalium.network.api.model.UserId +import com.wire.kalium.network.api.v6.authenticated.ConversationApiV6 +import com.wire.kalium.network.utils.NetworkResponse +import com.wire.kalium.network.utils.mapSuccess +import com.wire.kalium.network.utils.wrapKaliumResponse +import io.ktor.client.request.get + +internal open class ConversationApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + private val apiModelMapper: ApiModelMapper = ApiModelMapperImpl(), +) : ConversationApiV6(authenticatedNetworkClient) { + + override suspend fun fetchMlsOneToOneConversation(userId: UserId): NetworkResponse = + wrapKaliumResponse { + httpClient.get("$PATH_ONE_2_ONE_CONVERSATIONS/${userId.domain}/${userId.value}") + }.mapSuccess { + apiModelMapper.fromApiV6(it) + } + + protected companion object { + const val PATH_ONE_2_ONE_CONVERSATIONS = "one2one-conversations" + } +} diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/E2EIApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/E2EIApiV7.kt new file mode 100644 index 00000000000..c645339d015 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/E2EIApiV7.kt @@ -0,0 +1,25 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.E2EIApiV6 + +internal open class E2EIApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : E2EIApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/FeatureConfigApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/FeatureConfigApiV7.kt new file mode 100644 index 00000000000..ab9ec0f62b4 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/FeatureConfigApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.FeatureConfigApiV6 + +internal open class FeatureConfigApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : FeatureConfigApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/KeyPackageApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/KeyPackageApiV7.kt new file mode 100644 index 00000000000..ae9ab0f5cc7 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/KeyPackageApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.KeyPackageApiV6 + +internal open class KeyPackageApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : KeyPackageApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/LogoutApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/LogoutApiV7.kt new file mode 100644 index 00000000000..731121e8acd --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/LogoutApiV7.kt @@ -0,0 +1,28 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.LogoutApiV6 +import com.wire.kalium.network.session.SessionManager + +internal open class LogoutApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + sessionManager: SessionManager +) : LogoutApiV6(authenticatedNetworkClient, sessionManager) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/MLSMessageApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/MLSMessageApiV7.kt new file mode 100644 index 00000000000..74757410650 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/MLSMessageApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.MLSMessageApiV6 + +internal open class MLSMessageApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : MLSMessageApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/MLSPublicKeyApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/MLSPublicKeyApiV7.kt new file mode 100644 index 00000000000..371e72a5500 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/MLSPublicKeyApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.MLSPublicKeyApiV6 + +internal open class MLSPublicKeyApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : MLSPublicKeyApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/MessageApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/MessageApiV7.kt new file mode 100644 index 00000000000..c7f967be701 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/MessageApiV7.kt @@ -0,0 +1,28 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.base.authenticated.message.EnvelopeProtoMapper +import com.wire.kalium.network.api.v6.authenticated.MessageApiV6 + +internal open class MessageApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + envelopeProtoMapper: EnvelopeProtoMapper +) : MessageApiV6(authenticatedNetworkClient, envelopeProtoMapper) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/NotificationApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/NotificationApiV7.kt new file mode 100644 index 00000000000..b47dd923243 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/NotificationApiV7.kt @@ -0,0 +1,30 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.AuthenticatedWebSocketClient +import com.wire.kalium.network.api.unbound.configuration.ServerConfigDTO +import com.wire.kalium.network.api.v6.authenticated.NotificationApiV6 + +internal open class NotificationApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + authenticatedWebSocketClient: AuthenticatedWebSocketClient, + serverLinks: ServerConfigDTO.Links +) : NotificationApiV6(authenticatedNetworkClient, authenticatedWebSocketClient, serverLinks) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/PreKeyApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/PreKeyApiV7.kt new file mode 100644 index 00000000000..c50ced3d815 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/PreKeyApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.PreKeyApiV6 + +internal open class PreKeyApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : PreKeyApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/PropertiesApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/PropertiesApiV7.kt new file mode 100644 index 00000000000..7f35c7d8b17 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/PropertiesApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.PropertiesApiV6 + +internal open class PropertiesApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : PropertiesApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/SelfApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/SelfApiV7.kt new file mode 100644 index 00000000000..354a6519c78 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/SelfApiV7.kt @@ -0,0 +1,28 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.SelfApiV6 +import com.wire.kalium.network.session.SessionManager + +internal open class SelfApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + sessionManager: SessionManager +) : SelfApiV6(authenticatedNetworkClient, sessionManager) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/TeamsApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/TeamsApiV7.kt new file mode 100644 index 00000000000..4459a2ce9ef --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/TeamsApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.TeamsApiV6 + +internal open class TeamsApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : TeamsApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/UserDetailsApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/UserDetailsApiV7.kt new file mode 100644 index 00000000000..e335745290e --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/UserDetailsApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.UserDetailsApiV6 + +internal open class UserDetailsApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : UserDetailsApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/UserSearchApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/UserSearchApiV7.kt new file mode 100644 index 00000000000..debd4a9c985 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/UserSearchApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v6.authenticated.UserSearchApiV6 + +internal open class UserSearchApiV7 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : UserSearchApiV6(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/networkContainer/AuthenticatedNetworkContainerV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/networkContainer/AuthenticatedNetworkContainerV7.kt new file mode 100644 index 00000000000..8f348f105eb --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/authenticated/networkContainer/AuthenticatedNetworkContainerV7.kt @@ -0,0 +1,151 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.authenticated.networkContainer + +import com.wire.kalium.logger.KaliumLogger +import com.wire.kalium.network.api.base.authenticated.AccessTokenApi +import com.wire.kalium.network.api.base.authenticated.CallApi +import com.wire.kalium.network.api.base.authenticated.TeamsApi +import com.wire.kalium.network.api.base.authenticated.WildCardApi +import com.wire.kalium.network.api.base.authenticated.asset.AssetApi +import com.wire.kalium.network.api.base.authenticated.client.ClientApi +import com.wire.kalium.network.api.base.authenticated.connection.ConnectionApi +import com.wire.kalium.network.api.base.authenticated.conversation.ConversationApi +import com.wire.kalium.network.api.base.authenticated.e2ei.E2EIApi +import com.wire.kalium.network.api.base.authenticated.featureConfigs.FeatureConfigApi +import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackageApi +import com.wire.kalium.network.api.base.authenticated.logout.LogoutApi +import com.wire.kalium.network.api.base.authenticated.message.EnvelopeProtoMapperImpl +import com.wire.kalium.network.api.base.authenticated.message.MLSMessageApi +import com.wire.kalium.network.api.base.authenticated.message.MessageApi +import com.wire.kalium.network.api.base.authenticated.notification.NotificationApi +import com.wire.kalium.network.api.base.authenticated.prekey.PreKeyApi +import com.wire.kalium.network.api.base.authenticated.properties.PropertiesApi +import com.wire.kalium.network.api.base.authenticated.search.UserSearchApi +import com.wire.kalium.network.api.base.authenticated.self.SelfApi +import com.wire.kalium.network.api.base.authenticated.serverpublickey.MLSPublicKeyApi +import com.wire.kalium.network.api.base.authenticated.userDetails.UserDetailsApi +import com.wire.kalium.network.api.model.UserId +import com.wire.kalium.network.api.v7.authenticated.AccessTokenApiV7 +import com.wire.kalium.network.api.v7.authenticated.AssetApiV7 +import com.wire.kalium.network.api.v7.authenticated.CallApiV7 +import com.wire.kalium.network.api.v7.authenticated.ClientApiV7 +import com.wire.kalium.network.api.v7.authenticated.ConnectionApiV7 +import com.wire.kalium.network.api.v7.authenticated.ConversationApiV7 +import com.wire.kalium.network.api.v7.authenticated.E2EIApiV7 +import com.wire.kalium.network.api.v7.authenticated.FeatureConfigApiV7 +import com.wire.kalium.network.api.v7.authenticated.KeyPackageApiV7 +import com.wire.kalium.network.api.v7.authenticated.LogoutApiV7 +import com.wire.kalium.network.api.v7.authenticated.MLSMessageApiV7 +import com.wire.kalium.network.api.v7.authenticated.MLSPublicKeyApiV7 +import com.wire.kalium.network.api.v7.authenticated.MessageApiV7 +import com.wire.kalium.network.api.v7.authenticated.NotificationApiV7 +import com.wire.kalium.network.api.v7.authenticated.PreKeyApiV7 +import com.wire.kalium.network.api.v7.authenticated.PropertiesApiV7 +import com.wire.kalium.network.api.v7.authenticated.SelfApiV7 +import com.wire.kalium.network.api.v7.authenticated.TeamsApiV7 +import com.wire.kalium.network.api.v7.authenticated.UserDetailsApiV7 +import com.wire.kalium.network.api.v7.authenticated.UserSearchApiV7 +import com.wire.kalium.network.api.vcommon.WildCardApiImpl +import com.wire.kalium.network.defaultHttpEngine +import com.wire.kalium.network.networkContainer.AuthenticatedHttpClientProvider +import com.wire.kalium.network.networkContainer.AuthenticatedHttpClientProviderImpl +import com.wire.kalium.network.networkContainer.AuthenticatedNetworkContainer +import com.wire.kalium.network.session.CertificatePinning +import com.wire.kalium.network.session.SessionManager +import io.ktor.client.engine.HttpClientEngine +import io.ktor.websocket.WebSocketSession + +@Suppress("LongParameterList") +internal class AuthenticatedNetworkContainerV7 internal constructor( + private val sessionManager: SessionManager, + private val selfUserId: UserId, + certificatePinning: CertificatePinning, + mockEngine: HttpClientEngine?, + mockWebSocketSession: WebSocketSession?, + kaliumLogger: KaliumLogger, + engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + serverConfigDTOApiProxy = sessionManager.serverConfig().links.apiProxy, + proxyCredentials = sessionManager.proxyCredentials(), + certificatePinning = certificatePinning + ) +) : AuthenticatedNetworkContainer, + AuthenticatedHttpClientProvider by AuthenticatedHttpClientProviderImpl( + sessionManager = sessionManager, + accessTokenApi = { httpClient -> AccessTokenApiV7(httpClient) }, + engine = engine, + kaliumLogger = kaliumLogger, + webSocketSessionProvider = if (mockWebSocketSession != null) { + { _, _ -> mockWebSocketSession } + } else { + null + } + ) { + + override val accessTokenApi: AccessTokenApi get() = AccessTokenApiV7(networkClient.httpClient) + + override val logoutApi: LogoutApi get() = LogoutApiV7(networkClient, sessionManager) + + override val clientApi: ClientApi get() = ClientApiV7(networkClient) + + override val messageApi: MessageApi + get() = MessageApiV7( + networkClient, + EnvelopeProtoMapperImpl() + ) + + override val mlsMessageApi: MLSMessageApi get() = MLSMessageApiV7(networkClient) + + override val e2eiApi: E2EIApi get() = E2EIApiV7(networkClient) + + override val conversationApi: ConversationApi get() = ConversationApiV7(networkClient) + + override val keyPackageApi: KeyPackageApi get() = KeyPackageApiV7(networkClient) + + override val preKeyApi: PreKeyApi get() = PreKeyApiV7(networkClient) + + override val assetApi: AssetApi get() = AssetApiV7(networkClientWithoutCompression, selfUserId) + + override val notificationApi: NotificationApi + get() = NotificationApiV7( + networkClient, + websocketClient, + backendConfig + ) + + override val teamsApi: TeamsApi get() = TeamsApiV7(networkClient) + + override val selfApi: SelfApi get() = SelfApiV7(networkClient, sessionManager) + + override val userDetailsApi: UserDetailsApi get() = UserDetailsApiV7(networkClient) + + override val userSearchApi: UserSearchApi get() = UserSearchApiV7(networkClient) + + override val callApi: CallApi get() = CallApiV7(networkClient) + + override val connectionApi: ConnectionApi get() = ConnectionApiV7(networkClient) + + override val featureConfigApi: FeatureConfigApi get() = FeatureConfigApiV7(networkClient) + + override val mlsPublicKeyApi: MLSPublicKeyApi get() = MLSPublicKeyApiV7(networkClient) + + override val propertiesApi: PropertiesApi get() = PropertiesApiV7(networkClient) + + override val wildCardApi: WildCardApi get() = WildCardApiImpl(networkClient) +} diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/DomainLookupApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/DomainLookupApiV7.kt new file mode 100644 index 00000000000..7eb49e09941 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/DomainLookupApiV7.kt @@ -0,0 +1,25 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ +package com.wire.kalium.network.api.v7.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v6.unauthenticated.DomainLookupApiV6 + +internal open class DomainLookupApiV7 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : DomainLookupApiV6(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/LoginApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/LoginApiV7.kt new file mode 100644 index 00000000000..47d3953e351 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/LoginApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v6.unauthenticated.LoginApiV6 + +internal open class LoginApiV7 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : LoginApiV6(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/RegisterApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/RegisterApiV7.kt new file mode 100644 index 00000000000..4f6b384955d --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/RegisterApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v6.unauthenticated.RegisterApiV6 + +internal open class RegisterApiV7 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : RegisterApiV6(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/SSOLoginApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/SSOLoginApiV7.kt new file mode 100644 index 00000000000..8ecc50ad97c --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/SSOLoginApiV7.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v6.unauthenticated.SSOLoginApiV6 + +internal open class SSOLoginApiV7 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : SSOLoginApiV6(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/VerificationCodeApiV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/VerificationCodeApiV7.kt new file mode 100644 index 00000000000..fde0fbb268d --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/VerificationCodeApiV7.kt @@ -0,0 +1,25 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ +package com.wire.kalium.network.api.v7.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v6.unauthenticated.VerificationCodeApiV6 + +internal open class VerificationCodeApiV7 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : VerificationCodeApiV6(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV7.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV7.kt new file mode 100644 index 00000000000..3f3dd9a070f --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v7/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV7.kt @@ -0,0 +1,85 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.network.api.v7.unauthenticated.networkContainer + +import com.wire.kalium.network.api.base.unauthenticated.appVersioning.AppVersioningApi +import com.wire.kalium.network.api.base.unauthenticated.appVersioning.AppVersioningApiImpl +import com.wire.kalium.network.api.base.unauthenticated.domainLookup.DomainLookupApi +import com.wire.kalium.network.api.base.unauthenticated.login.LoginApi +import com.wire.kalium.network.api.base.unauthenticated.register.RegisterApi +import com.wire.kalium.network.api.base.unauthenticated.sso.SSOLoginApi +import com.wire.kalium.network.api.base.unauthenticated.verification.VerificationCodeApi +import com.wire.kalium.network.api.base.unbound.configuration.ServerConfigApi +import com.wire.kalium.network.api.base.unbound.configuration.ServerConfigApiImpl +import com.wire.kalium.network.api.base.unbound.versioning.VersionApi +import com.wire.kalium.network.api.base.unbound.versioning.VersionApiImpl +import com.wire.kalium.network.api.model.ProxyCredentialsDTO +import com.wire.kalium.network.api.unbound.configuration.ServerConfigDTO +import com.wire.kalium.network.api.v7.unauthenticated.DomainLookupApiV7 +import com.wire.kalium.network.api.v7.unauthenticated.LoginApiV7 +import com.wire.kalium.network.api.v7.unauthenticated.RegisterApiV7 +import com.wire.kalium.network.api.v7.unauthenticated.SSOLoginApiV7 +import com.wire.kalium.network.api.v7.unauthenticated.VerificationCodeApiV7 +import com.wire.kalium.network.defaultHttpEngine +import com.wire.kalium.network.networkContainer.UnauthenticatedNetworkClientProvider +import com.wire.kalium.network.networkContainer.UnauthenticatedNetworkClientProviderImpl +import com.wire.kalium.network.networkContainer.UnauthenticatedNetworkContainer +import com.wire.kalium.network.session.CertificatePinning +import io.ktor.client.engine.HttpClientEngine + +@Suppress("LongParameterList") +class UnauthenticatedNetworkContainerV7 internal constructor( + backendLinks: ServerConfigDTO, + proxyCredentials: ProxyCredentialsDTO?, + certificatePinning: CertificatePinning, + mockEngine: HttpClientEngine?, + engine: HttpClientEngine = mockEngine ?: defaultHttpEngine( + serverConfigDTOApiProxy = backendLinks.links.apiProxy, + proxyCredentials = proxyCredentials, + certificatePinning = certificatePinning + ), + private val developmentApiEnabled: Boolean +) : UnauthenticatedNetworkContainer, + UnauthenticatedNetworkClientProvider by UnauthenticatedNetworkClientProviderImpl( + backendLinks, + engine + ) { + override val loginApi: LoginApi get() = LoginApiV7(unauthenticatedNetworkClient) + override val verificationCodeApi: VerificationCodeApi + get() = VerificationCodeApiV7( + unauthenticatedNetworkClient + ) + override val domainLookupApi: DomainLookupApi + get() = DomainLookupApiV7( + unauthenticatedNetworkClient + ) + override val remoteVersion: VersionApi + get() = VersionApiImpl( + unauthenticatedNetworkClient, + developmentApiEnabled = developmentApiEnabled + ) + override val serverConfigApi: ServerConfigApi + get() = ServerConfigApiImpl(unauthenticatedNetworkClient) + override val registerApi: RegisterApi get() = RegisterApiV7(unauthenticatedNetworkClient) + override val sso: SSOLoginApi get() = SSOLoginApiV7(unauthenticatedNetworkClient) + override val appVersioningApi: AppVersioningApi + get() = AppVersioningApiImpl( + unauthenticatedNetworkClient + ) +} diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt index d46fe227c44..6eb175d3280 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/AuthenticatedNetworkContainer.kt @@ -49,6 +49,7 @@ import com.wire.kalium.network.api.v2.authenticated.networkContainer.Authenticat import com.wire.kalium.network.api.v4.authenticated.networkContainer.AuthenticatedNetworkContainerV4 import com.wire.kalium.network.api.v5.authenticated.networkContainer.AuthenticatedNetworkContainerV5 import com.wire.kalium.network.api.v6.authenticated.networkContainer.AuthenticatedNetworkContainerV6 +import com.wire.kalium.network.api.v7.authenticated.networkContainer.AuthenticatedNetworkContainerV7 import com.wire.kalium.network.session.CertificatePinning import com.wire.kalium.network.session.SessionManager import io.ktor.client.HttpClient @@ -188,6 +189,15 @@ interface AuthenticatedNetworkContainer { kaliumLogger ) + 7 -> AuthenticatedNetworkContainerV7( + sessionManager, + selfUserId, + certificatePinning, + mockEngine, + mockWebSocketSession, + kaliumLogger + ) + else -> error("Unsupported version: $version") } } diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt index 54a0579d0db..194f9775d34 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/networkContainer/UnauthenticatedNetworkContainer.kt @@ -19,21 +19,22 @@ package com.wire.kalium.network.networkContainer import com.wire.kalium.network.UnauthenticatedNetworkClient -import com.wire.kalium.network.api.model.ProxyCredentialsDTO +import com.wire.kalium.network.api.base.unauthenticated.appVersioning.AppVersioningApi import com.wire.kalium.network.api.base.unauthenticated.domainLookup.DomainLookupApi import com.wire.kalium.network.api.base.unauthenticated.login.LoginApi +import com.wire.kalium.network.api.base.unauthenticated.register.RegisterApi import com.wire.kalium.network.api.base.unauthenticated.sso.SSOLoginApi import com.wire.kalium.network.api.base.unauthenticated.verification.VerificationCodeApi -import com.wire.kalium.network.api.base.unauthenticated.appVersioning.AppVersioningApi -import com.wire.kalium.network.api.base.unauthenticated.register.RegisterApi import com.wire.kalium.network.api.base.unbound.configuration.ServerConfigApi -import com.wire.kalium.network.api.unbound.configuration.ServerConfigDTO import com.wire.kalium.network.api.base.unbound.versioning.VersionApi +import com.wire.kalium.network.api.model.ProxyCredentialsDTO +import com.wire.kalium.network.api.unbound.configuration.ServerConfigDTO import com.wire.kalium.network.api.v0.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV0 import com.wire.kalium.network.api.v2.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV2 import com.wire.kalium.network.api.v4.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV4 import com.wire.kalium.network.api.v5.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV5 import com.wire.kalium.network.api.v6.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV6 +import com.wire.kalium.network.api.v7.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV7 import com.wire.kalium.network.session.CertificatePinning import io.ktor.client.engine.HttpClientEngine @@ -120,6 +121,14 @@ interface UnauthenticatedNetworkContainer { developmentApiEnabled = developmentApiEnabled ) + 7 -> UnauthenticatedNetworkContainerV7( + backendLinks = serverConfigDTO, + proxyCredentials = proxyCredentials, + certificatePinning = certificatePinning, + mockEngine = mockEngine, + developmentApiEnabled = developmentApiEnabled + ) + else -> error("Unsupported version: ${serverConfigDTO.metaData.commonApiVersion.version}") } } diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/utils/ObfuscateUtil.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/utils/ObfuscateUtil.kt index 225d622fcca..881b0ccb6cb 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/utils/ObfuscateUtil.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/utils/ObfuscateUtil.kt @@ -25,7 +25,6 @@ import com.wire.kalium.logger.obfuscateId import com.wire.kalium.logger.obfuscateUrlPath import com.wire.kalium.util.serialization.toJsonElement import io.ktor.http.Url -import kotlinx.serialization.decodeFromString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonArray import kotlinx.serialization.json.JsonElement diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/authenticated/client/ClientDTOSerializationTest.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/authenticated/client/ClientDTOSerializationTest.kt new file mode 100644 index 00000000000..5d8c238d963 --- /dev/null +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/authenticated/client/ClientDTOSerializationTest.kt @@ -0,0 +1,41 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ +package com.wire.kalium.api.authenticated.client + +import com.wire.kalium.mocks.responses.ClientResponseJson +import com.wire.kalium.network.api.authenticated.client.ClientDTO +import kotlinx.serialization.json.Json +import kotlin.test.Test +import kotlin.test.assertTrue + + +class ClientDTOSerializationTest { + @Test + fun givenJsonWithCapabilitiesList_whenDeserialize_thenReturnCapabilities() { + val jsonString = ClientResponseJson.valid.rawJson + val deserializedClient = Json.decodeFromString(jsonString) + assertTrue(deserializedClient.capabilities.isNotEmpty()) + } + + @Test + fun givenJsonWithCapabilitiesObjectWrapperList_whenDeserialize_thenReturnCapabilities() { + val jsonString = ClientResponseJson.validCapabilitiesObject.rawJson + val deserializedClient = Json.decodeFromString(jsonString) + assertTrue(deserializedClient.capabilities.isNotEmpty()) + } +} \ No newline at end of file diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/v7/ConversationApiV7Test.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/v7/ConversationApiV7Test.kt new file mode 100644 index 00000000000..a9b2946f9c1 --- /dev/null +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/v7/ConversationApiV7Test.kt @@ -0,0 +1,64 @@ +/* + * Wire + * Copyright (C) 2024 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +package com.wire.kalium.api.v7 + +import com.wire.kalium.api.ApiTest +import com.wire.kalium.mocks.responses.conversation.ConversationResponseJson +import com.wire.kalium.network.api.model.UserId +import com.wire.kalium.network.api.v7.authenticated.ConversationApiV7 +import com.wire.kalium.network.utils.isSuccessful +import io.ktor.http.HttpStatusCode +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertTrue + +internal class ConversationApiV7Test : ApiTest() { + + @Test + fun whenCallingFetchMlsOneToOneConversation_thenTheRequestShouldBeConfiguredOK() = runTest { + val networkClient = mockAuthenticatedNetworkClient( + FETCH_CONVERSATION_RESPONSE, + statusCode = HttpStatusCode.OK, + assertion = { + assertGet() + assertPathEqual("/one2one-conversations/${USER_ID.domain}/${USER_ID.value}") + } + ) + val conversationApi = ConversationApiV7(networkClient) + conversationApi.fetchMlsOneToOneConversation(USER_ID) + } + + @Test + fun given200Response_whenCallingFetchMlsOneToOneConversation_thenResponseIsParsedCorrectly() = + runTest { + val networkClient = mockAuthenticatedNetworkClient( + FETCH_CONVERSATION_RESPONSE, + statusCode = HttpStatusCode.OK + ) + val conversationApi = ConversationApiV7(networkClient) + + val fetchMlsOneToOneConversation = conversationApi.fetchMlsOneToOneConversation(USER_ID) + assertTrue(fetchMlsOneToOneConversation.isSuccessful()) + } + + companion object { + val USER_ID = UserId("id", "domain") + val FETCH_CONVERSATION_RESPONSE = ConversationResponseJson.v6.rawJson + } +}