diff --git a/logic/src/commonMain/kotlin/com/wire/kalium/logic/featureFlags/FeatureSupportImpl.kt b/logic/src/commonMain/kotlin/com/wire/kalium/logic/featureFlags/FeatureSupportImpl.kt index e6ecf60fc9c..05091168dca 100644 --- a/logic/src/commonMain/kotlin/com/wire/kalium/logic/featureFlags/FeatureSupportImpl.kt +++ b/logic/src/commonMain/kotlin/com/wire/kalium/logic/featureFlags/FeatureSupportImpl.kt @@ -28,5 +28,5 @@ class FeatureSupportImpl( apiVersion: Int ) : FeatureSupport { - override val isMLSSupported: Boolean = kaliumConfigs.isMLSSupportEnabled && apiVersion >= 4 + override val isMLSSupported: Boolean = kaliumConfigs.isMLSSupportEnabled && apiVersion >= 5 } 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 6156f1a2184..497e4a964be 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.tools.ApiVersionDTO import com.wire.kalium.network.tools.ServerConfigDTO val SupportedApiVersions = setOf(0, 1, 2, 3) -val DevelopmentApiVersions = setOf(4) +val DevelopmentApiVersions = setOf(4, 5) interface BackendMetaDataUtil { fun calculateApiVersion( diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/e2ei/E2EIApi.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/e2ei/E2EIApi.kt index 71aeb294988..27160ca6784 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/e2ei/E2EIApi.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/base/authenticated/e2ei/E2EIApi.kt @@ -26,7 +26,7 @@ interface E2EIApi { suspend fun getWireNonce(clientId: String): NetworkResponse companion object { - fun getApiNotSupportError(apiName: String, apiVersion: String = "4") = NetworkResponse.Error( + fun getApiNotSupportError(apiName: String, apiVersion: String = "5") = NetworkResponse.Error( APINotSupported("${this::class.simpleName}: $apiName api is only available on API V$apiVersion") ) } 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 5c0d9d5dc3d..bdf36b87299 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 @@ -235,7 +235,7 @@ internal open class ConversationApiV0 internal constructor( override suspend fun fetchGroupInfo(conversationId: QualifiedID): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: fetchGroupInfo api is only available on API V3") + APINotSupported("MLS: fetchGroupInfo api is only available on API V5") ) override suspend fun joinConversation( @@ -269,7 +269,7 @@ internal open class ConversationApiV0 internal constructor( subconversationId: SubconversationId ): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: fetchSubconversationDetails api is only available on API V3") + APINotSupported("MLS: fetchSubconversationDetails api is only available on API V5") ) override suspend fun fetchSubconversationGroupInfo( @@ -277,7 +277,7 @@ internal open class ConversationApiV0 internal constructor( subconversationId: SubconversationId ): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: fetchSubconversationGroupInfo api is only available on API V3") + APINotSupported("MLS: fetchSubconversationGroupInfo api is only available on API V5") ) override suspend fun deleteSubconversation( @@ -286,7 +286,7 @@ internal open class ConversationApiV0 internal constructor( deleteRequest: SubconversationDeleteRequest ): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: deleteSubconversation api is only available on API V3") + APINotSupported("MLS: deleteSubconversation api is only available on API V5") ) override suspend fun leaveSubconversation( @@ -294,7 +294,7 @@ internal open class ConversationApiV0 internal constructor( subconversationId: SubconversationId ): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: leaveSubconversation api is only available on API V3") + APINotSupported("MLS: leaveSubconversation api is only available on API V5") ) protected suspend fun handleConversationMemberAddedResponse( diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/KeyPackageApiV0.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/KeyPackageApiV0.kt index b9b1875c8c5..a6efa417a4c 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/KeyPackageApiV0.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/KeyPackageApiV0.kt @@ -29,18 +29,18 @@ internal open class KeyPackageApiV0 internal constructor() : KeyPackageApi { override suspend fun claimKeyPackages( param: KeyPackageApi.Param ): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: claimKeyPackages api is only available on API V4") + APINotSupported("MLS: claimKeyPackages api is only available on API V5") ) override suspend fun uploadKeyPackages( clientId: String, keyPackages: List ): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: uploadKeyPackages api is only available on API V4") + APINotSupported("MLS: uploadKeyPackages api is only available on API V5") ) override suspend fun getAvailableKeyPackageCount(clientId: String): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: getAvailableKeyPackageCount api is only available on API V4") + APINotSupported("MLS: getAvailableKeyPackageCount api is only available on API V5") ) } diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/MLSMessageApiV0.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/MLSMessageApiV0.kt index 37a7ba781a5..3cf340c7e6e 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/MLSMessageApiV0.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/MLSMessageApiV0.kt @@ -26,11 +26,11 @@ import com.wire.kalium.network.utils.NetworkResponse internal open class MLSMessageApiV0 internal constructor() : MLSMessageApi { override suspend fun sendMessage(message: MLSMessageApi.Message): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: sendMessage api is only available on API V4") + APINotSupported("MLS: sendMessage api is only available on API V5") ) override suspend fun sendCommitBundle(bundle: MLSMessageApi.CommitBundle): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: sendCommitBundle api is only available on API V4") + APINotSupported("MLS: sendCommitBundle api is only available on API V5") ) } diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/MLSPublicKeyApiV0.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/MLSPublicKeyApiV0.kt index 1e49aa4562d..7f1f51530da 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/MLSPublicKeyApiV0.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v0/authenticated/MLSPublicKeyApiV0.kt @@ -25,6 +25,6 @@ import com.wire.kalium.network.utils.NetworkResponse open class MLSPublicKeyApiV0 internal constructor() : MLSPublicKeyApi { override suspend fun getMLSPublicKeys(): NetworkResponse = NetworkResponse.Error( - APINotSupported("MLS: getMLSPublicKeys api is only available on API V4") + APINotSupported("MLS: getMLSPublicKeys api is only available on API V5") ) } 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 5db00476804..9cb65102a33 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 @@ -21,6 +21,6 @@ package com.wire.kalium.network.api.v4.authenticated import com.wire.kalium.network.api.v3.authenticated.AccessTokenApiV3 import io.ktor.client.HttpClient -internal class AccessTokenApiV4 internal constructor( +internal open class AccessTokenApiV4 internal constructor( private val httpClient: HttpClient ) : AccessTokenApiV3(httpClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/ConversationApiV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/ConversationApiV4.kt index cdd854efb43..a1f7ec00002 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/ConversationApiV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/ConversationApiV4.kt @@ -23,8 +23,6 @@ import com.wire.kalium.network.api.base.authenticated.conversation.AddConversati import com.wire.kalium.network.api.base.authenticated.conversation.ConversationMemberAddedResponse import com.wire.kalium.network.api.base.authenticated.conversation.ConversationResponseV3 import com.wire.kalium.network.api.base.authenticated.conversation.CreateConversationRequest -import com.wire.kalium.network.api.base.authenticated.conversation.SubconversationDeleteRequest -import com.wire.kalium.network.api.base.authenticated.conversation.SubconversationResponse import com.wire.kalium.network.api.base.authenticated.conversation.model.ConversationCodeInfo import com.wire.kalium.network.api.base.authenticated.notification.EventContentDTO import com.wire.kalium.network.api.base.model.ApiModelMapper @@ -32,8 +30,6 @@ import com.wire.kalium.network.api.base.model.ApiModelMapperImpl import com.wire.kalium.network.api.base.model.ConversationId import com.wire.kalium.network.api.base.model.GenerateGuestLinkRequest import com.wire.kalium.network.api.base.model.JoinConversationRequestV4 -import com.wire.kalium.network.api.base.model.QualifiedID -import com.wire.kalium.network.api.base.model.SubconversationId import com.wire.kalium.network.api.v3.authenticated.ConversationApiV3 import com.wire.kalium.network.exceptions.KaliumException import com.wire.kalium.network.utils.NetworkResponse @@ -41,7 +37,6 @@ import com.wire.kalium.network.utils.handleUnsuccessfulResponse import com.wire.kalium.network.utils.mapSuccess import com.wire.kalium.network.utils.wrapFederationResponse import com.wire.kalium.network.utils.wrapKaliumResponse -import io.ktor.client.request.delete import io.ktor.client.request.get import io.ktor.client.request.parameter import io.ktor.client.request.post @@ -65,58 +60,6 @@ internal open class ConversationApiV4 internal constructor( apiModelMapper.fromApiV3(conversationResponseV4) } - override suspend fun fetchGroupInfo(conversationId: QualifiedID): NetworkResponse = - wrapKaliumResponse { - httpClient.get( - "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}/$PATH_GROUP_INFO" - ) - } - - override suspend fun fetchSubconversationDetails( - conversationId: ConversationId, - subconversationId: SubconversationId - ): NetworkResponse = - wrapKaliumResponse { - httpClient.get( - "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}" + - "/$PATH_SUBCONVERSATIONS/$subconversationId" - ) - } - - override suspend fun fetchSubconversationGroupInfo( - conversationId: ConversationId, - subconversationId: SubconversationId - ): NetworkResponse = - wrapKaliumResponse { - httpClient.get( - "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}/" + - "$PATH_SUBCONVERSATIONS/$subconversationId/$PATH_GROUP_INFO" - ) - } - - override suspend fun deleteSubconversation( - conversationId: ConversationId, - subconversationId: SubconversationId, - deleteRequest: SubconversationDeleteRequest - ): NetworkResponse = - wrapKaliumResponse { - httpClient.delete( - "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}/$PATH_SUBCONVERSATIONS/$subconversationId" - ) { - setBody(deleteRequest) - } - } - - override suspend fun leaveSubconversation( - conversationId: ConversationId, - subconversationId: SubconversationId - ): NetworkResponse = - wrapKaliumResponse { - httpClient.delete( - "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}/$PATH_SUBCONVERSATIONS/$subconversationId/self" - ) - } - override suspend fun joinConversation( code: String, key: String, diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/E2EIApiV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/E2EIApiV4.kt index ab41c73ccf3..9c9744e3e82 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/E2EIApiV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/E2EIApiV4.kt @@ -17,56 +17,6 @@ */ package com.wire.kalium.network.api.v4.authenticated -import com.wire.kalium.network.AuthenticatedNetworkClient -import com.wire.kalium.network.api.base.authenticated.e2ei.AccessTokenResponse -import com.wire.kalium.network.api.base.authenticated.e2ei.E2EIApi -import com.wire.kalium.network.serialization.JoseJson -import com.wire.kalium.network.utils.CustomErrors -import com.wire.kalium.network.utils.NetworkResponse -import com.wire.kalium.network.utils.handleUnsuccessfulResponse -import com.wire.kalium.network.utils.wrapKaliumResponse -import io.ktor.client.request.post -import io.ktor.client.request.prepareHead -import io.ktor.client.statement.HttpResponse -import io.ktor.http.ContentType -import io.ktor.http.contentType -import io.ktor.http.isSuccess +import com.wire.kalium.network.api.v3.authenticated.E2EIApiV3 -internal open class E2EIApiV4 internal constructor(private val authenticatedNetworkClient: AuthenticatedNetworkClient) : E2EIApi { - - private val httpClient get() = authenticatedNetworkClient.httpClient - - override suspend fun getWireNonce(clientId: String): NetworkResponse = - httpClient.prepareHead("$PATH_CLIENTS/$clientId/$PATH_NONCE") { - contentType(ContentType.Application.JoseJson) - }.execute { httpResponse -> - handleNonceResponse(httpResponse) - } - - private suspend fun handleNonceResponse( - httpResponse: HttpResponse - ): NetworkResponse = if (httpResponse.status.isSuccess()) - httpResponse.headers[NONCE_HEADER_KEY]?.let { nonce -> - NetworkResponse.Success(nonce, httpResponse) - } ?: run { - CustomErrors.MISSING_NONCE - } - else { - handleUnsuccessfulResponse(httpResponse) - } - - override suspend fun getAccessToken(clientId: String, dpopToken: String): NetworkResponse = wrapKaliumResponse { - httpClient.post("$PATH_CLIENTS/$clientId/$PATH_ACCESS_TOKEN") { - headers.append(DPOP_HEADER_KEY, dpopToken) - } - } - - private companion object { - const val PATH_CLIENTS = "clients" - const val PATH_NONCE = "nonce" - const val PATH_ACCESS_TOKEN = "access-token" - - const val DPOP_HEADER_KEY = "dpop" - const val NONCE_HEADER_KEY = "Replay-Nonce" - } -} +internal open class E2EIApiV4 internal constructor() : E2EIApiV3() diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/KeyPackageApiV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/KeyPackageApiV4.kt index fe72a2aba82..cd74e01dc2d 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/KeyPackageApiV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/KeyPackageApiV4.kt @@ -18,56 +18,6 @@ package com.wire.kalium.network.api.v4.authenticated -import com.wire.kalium.network.AuthenticatedNetworkClient -import com.wire.kalium.network.api.base.authenticated.keypackage.ClaimedKeyPackageList -import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackage -import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackageApi -import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackageCountDTO -import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackageList import com.wire.kalium.network.api.v3.authenticated.KeyPackageApiV3 -import com.wire.kalium.network.kaliumLogger -import com.wire.kalium.network.utils.NetworkResponse -import com.wire.kalium.network.utils.wrapKaliumResponse -import io.ktor.client.request.get -import io.ktor.client.request.parameter -import io.ktor.client.request.post -import io.ktor.client.request.setBody -internal open class KeyPackageApiV4 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient -) : KeyPackageApiV3() { - - private val httpClient get() = authenticatedNetworkClient.httpClient - - override suspend fun claimKeyPackages( - param: KeyPackageApi.Param - ): NetworkResponse = wrapKaliumResponse { - httpClient.post("$PATH_KEY_PACKAGES/$PATH_CLAIM/${param.user.domain}/${param.user.value}") { - if (param is KeyPackageApi.Param.SkipOwnClient) { - parameter(QUERY_SKIP_OWN, param.selfClientId) - } - } - } - - override suspend fun uploadKeyPackages( - clientId: String, - keyPackages: List - ): NetworkResponse = - wrapKaliumResponse { - kaliumLogger.v("Keypackages Count: ${keyPackages.size}") - httpClient.post("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId") { - setBody(KeyPackageList(keyPackages)) - } - } - - override suspend fun getAvailableKeyPackageCount(clientId: String): NetworkResponse = - wrapKaliumResponse { httpClient.get("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId/$PATH_COUNT") } - - private companion object { - const val PATH_KEY_PACKAGES = "mls/key-packages" - const val PATH_CLAIM = "claim" - const val PATH_SELF = "self" - const val PATH_COUNT = "count" - const val QUERY_SKIP_OWN = "skip_own" - } -} +internal open class KeyPackageApiV4 internal constructor() : KeyPackageApiV3() diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/MLSMessageApiV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/MLSMessageApiV4.kt index 979a2bffcf2..a22e1b6b8b1 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/MLSMessageApiV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/MLSMessageApiV4.kt @@ -18,42 +18,6 @@ package com.wire.kalium.network.api.v4.authenticated -import com.wire.kalium.network.AuthenticatedNetworkClient -import com.wire.kalium.network.api.base.authenticated.message.MLSMessageApi -import com.wire.kalium.network.api.base.authenticated.message.SendMLSMessageResponse import com.wire.kalium.network.api.v3.authenticated.MLSMessageApiV3 -import com.wire.kalium.network.serialization.Mls -import com.wire.kalium.network.utils.NetworkResponse -import com.wire.kalium.network.utils.wrapKaliumResponse -import io.ktor.client.request.post -import io.ktor.client.request.setBody -import io.ktor.http.ContentType -import io.ktor.http.contentType -internal open class MLSMessageApiV4 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient -) : MLSMessageApiV3() { - - private val httpClient get() = authenticatedNetworkClient.httpClient - - override suspend fun sendMessage(message: MLSMessageApi.Message): NetworkResponse = - wrapKaliumResponse { - httpClient.post(PATH_MESSAGE) { - setBody(message.value) - contentType(ContentType.Message.Mls) - } - } - - override suspend fun sendCommitBundle(bundle: MLSMessageApi.CommitBundle): NetworkResponse = - wrapKaliumResponse { - httpClient.post(PATH_COMMIT_BUNDLES) { - setBody(bundle.value) - contentType(ContentType.Message.Mls) - } - } - - private companion object { - const val PATH_COMMIT_BUNDLES = "mls/commit-bundles" - const val PATH_MESSAGE = "mls/messages" - } -} +internal open class MLSMessageApiV4 internal constructor() : MLSMessageApiV3() diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/MLSPublicKeyApiV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/MLSPublicKeyApiV4.kt index 1c6cb6697ae..fa3a4733440 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/MLSPublicKeyApiV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/MLSPublicKeyApiV4.kt @@ -18,24 +18,6 @@ package com.wire.kalium.network.api.v4.authenticated -import com.wire.kalium.network.AuthenticatedNetworkClient -import com.wire.kalium.network.api.base.authenticated.serverpublickey.MLSPublicKeysDTO import com.wire.kalium.network.api.v3.authenticated.MLSPublicKeyApiV3 -import com.wire.kalium.network.utils.NetworkResponse -import com.wire.kalium.network.utils.wrapKaliumResponse -import io.ktor.client.request.get -internal open class MLSPublicKeyApiV4 internal constructor( - private val authenticatedNetworkClient: AuthenticatedNetworkClient -) : MLSPublicKeyApiV3() { - - private val httpClient get() = authenticatedNetworkClient.httpClient - - override suspend fun getMLSPublicKeys(): NetworkResponse = - wrapKaliumResponse { httpClient.get("$PATH_MLS/$PATH_PUBLIC_KEYS") } - - private companion object { - const val PATH_PUBLIC_KEYS = "public-keys" - const val PATH_MLS = "mls" - } -} +internal open class MLSPublicKeyApiV4 internal constructor() : MLSPublicKeyApiV3() diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/networkContainer/AuthenticatedNetworkContainerV4.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/networkContainer/AuthenticatedNetworkContainerV4.kt index c62e1fd3a42..bfa063d2f2b 100644 --- a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/networkContainer/AuthenticatedNetworkContainerV4.kt +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v4/authenticated/networkContainer/AuthenticatedNetworkContainerV4.kt @@ -95,13 +95,13 @@ internal class AuthenticatedNetworkContainerV4 internal constructor( override val messageApi: MessageApi get() = MessageApiV4(networkClient, EnvelopeProtoMapperImpl()) - override val mlsMessageApi: MLSMessageApi get() = MLSMessageApiV4(networkClient) + override val mlsMessageApi: MLSMessageApi get() = MLSMessageApiV4() - override val e2eiApi: E2EIApi get() = E2EIApiV4(networkClient) + override val e2eiApi: E2EIApi get() = E2EIApiV4() override val conversationApi: ConversationApi get() = ConversationApiV4(networkClient) - override val keyPackageApi: KeyPackageApi get() = KeyPackageApiV4(networkClient) + override val keyPackageApi: KeyPackageApi get() = KeyPackageApiV4() override val preKeyApi: PreKeyApi get() = PreKeyApiV4(networkClient) @@ -123,7 +123,7 @@ internal class AuthenticatedNetworkContainerV4 internal constructor( override val featureConfigApi: FeatureConfigApi get() = FeatureConfigApiV4(networkClient) - override val mlsPublicKeyApi: MLSPublicKeyApi get() = MLSPublicKeyApiV4(networkClient) + override val mlsPublicKeyApi: MLSPublicKeyApi get() = MLSPublicKeyApiV4() override val propertiesApi: PropertiesApi get() = PropertiesApiV4(networkClient) } 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 new file mode 100644 index 00000000000..698b0d3ff2a --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AccessTokenApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.api.v4.authenticated.AccessTokenApiV4 +import io.ktor.client.HttpClient + +internal class AccessTokenApiV5 internal constructor( + private val httpClient: HttpClient +) : AccessTokenApiV4(httpClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AssetApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AssetApiV5.kt new file mode 100644 index 00000000000..f919ab6911d --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/AssetApiV5.kt @@ -0,0 +1,28 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.base.model.UserId +import com.wire.kalium.network.api.v4.authenticated.AssetApiV4 + +internal open class AssetApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + selfUserId: UserId +) : AssetApiV4(authenticatedNetworkClient, selfUserId) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/CallApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/CallApiV5.kt new file mode 100644 index 00000000000..abb010d01d8 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/CallApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.CallApiV4 + +internal open class CallApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : CallApiV4(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/ClientApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/ClientApiV5.kt new file mode 100644 index 00000000000..a60ec1b4264 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/ClientApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.ClientApiV4 + +internal open class ClientApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : ClientApiV4(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/ConnectionApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/ConnectionApiV5.kt new file mode 100644 index 00000000000..deeb252651f --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/ConnectionApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.ConnectionApiV4 + +internal open class ConnectionApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : ConnectionApiV4(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/ConversationApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/ConversationApiV5.kt new file mode 100644 index 00000000000..deca8f058e0 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/ConversationApiV5.kt @@ -0,0 +1,90 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.base.authenticated.conversation.SubconversationDeleteRequest +import com.wire.kalium.network.api.base.authenticated.conversation.SubconversationResponse +import com.wire.kalium.network.api.base.model.ConversationId +import com.wire.kalium.network.api.base.model.QualifiedID +import com.wire.kalium.network.api.base.model.SubconversationId +import com.wire.kalium.network.api.v4.authenticated.ConversationApiV4 +import com.wire.kalium.network.utils.NetworkResponse +import com.wire.kalium.network.utils.wrapKaliumResponse +import io.ktor.client.request.delete +import io.ktor.client.request.get +import io.ktor.client.request.setBody + +internal open class ConversationApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, +) : ConversationApiV4(authenticatedNetworkClient) { + + override suspend fun fetchGroupInfo(conversationId: QualifiedID): NetworkResponse = + wrapKaliumResponse { + httpClient.get( + "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}/$PATH_GROUP_INFO" + ) + } + + override suspend fun fetchSubconversationGroupInfo( + conversationId: ConversationId, + subconversationId: SubconversationId + ): NetworkResponse = + wrapKaliumResponse { + httpClient.get( + "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}/" + + "$PATH_SUBCONVERSATIONS/$subconversationId/$PATH_GROUP_INFO" + ) + } + + override suspend fun fetchSubconversationDetails( + conversationId: ConversationId, + subconversationId: SubconversationId + ): NetworkResponse = + wrapKaliumResponse { + httpClient.get( + "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}" + + "/$PATH_SUBCONVERSATIONS/$subconversationId" + ) + } + + override suspend fun deleteSubconversation( + conversationId: ConversationId, + subconversationId: SubconversationId, + deleteRequest: SubconversationDeleteRequest + ): NetworkResponse = + wrapKaliumResponse { + httpClient.delete( + "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}/$PATH_SUBCONVERSATIONS/$subconversationId" + ) { + setBody(deleteRequest) + } + } + + override suspend fun leaveSubconversation( + conversationId: ConversationId, + subconversationId: SubconversationId + ): NetworkResponse = + wrapKaliumResponse { + httpClient.delete( + "$PATH_CONVERSATIONS/${conversationId.domain}/${conversationId.value}/$PATH_SUBCONVERSATIONS/$subconversationId/self" + ) + } + +} diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/E2EIApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/E2EIApiV5.kt new file mode 100644 index 00000000000..d954a09fcb5 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/E2EIApiV5.kt @@ -0,0 +1,73 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.base.authenticated.e2ei.AccessTokenResponse +import com.wire.kalium.network.api.v4.authenticated.E2EIApiV4 +import com.wire.kalium.network.serialization.JoseJson +import com.wire.kalium.network.utils.CustomErrors +import com.wire.kalium.network.utils.NetworkResponse +import com.wire.kalium.network.utils.handleUnsuccessfulResponse +import com.wire.kalium.network.utils.wrapKaliumResponse +import io.ktor.client.request.post +import io.ktor.client.request.prepareHead +import io.ktor.client.statement.HttpResponse +import io.ktor.http.ContentType +import io.ktor.http.contentType +import io.ktor.http.isSuccess + +internal open class E2EIApiV5 internal constructor( + private val authenticatedNetworkClient: AuthenticatedNetworkClient +) : E2EIApiV4() { + private val httpClient get() = authenticatedNetworkClient.httpClient + + override suspend fun getWireNonce(clientId: String): NetworkResponse = + httpClient.prepareHead("$PATH_CLIENTS/$clientId/$PATH_NONCE") { + contentType(ContentType.Application.JoseJson) + }.execute { httpResponse -> + handleNonceResponse(httpResponse) + } + + private suspend fun handleNonceResponse( + httpResponse: HttpResponse + ): NetworkResponse = if (httpResponse.status.isSuccess()) + httpResponse.headers[NONCE_HEADER_KEY]?.let { nonce -> + NetworkResponse.Success(nonce, httpResponse) + } ?: run { + CustomErrors.MISSING_NONCE + } + else { + handleUnsuccessfulResponse(httpResponse) + } + + override suspend fun getAccessToken(clientId: String, dpopToken: String): NetworkResponse = wrapKaliumResponse { + httpClient.post("$PATH_CLIENTS/$clientId/$PATH_ACCESS_TOKEN") { + headers.append(DPOP_HEADER_KEY, dpopToken) + } + } + + private companion object { + const val PATH_CLIENTS = "clients" + const val PATH_NONCE = "nonce" + const val PATH_ACCESS_TOKEN = "access-token" + + const val DPOP_HEADER_KEY = "dpop" + const val NONCE_HEADER_KEY = "Replay-Nonce" + } +} diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/FeatureConfigApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/FeatureConfigApiV5.kt new file mode 100644 index 00000000000..7ce2e8f8b06 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/FeatureConfigApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.FeatureConfigApiV4 + +internal open class FeatureConfigApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : FeatureConfigApiV4(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/KeyPackageApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/KeyPackageApiV5.kt new file mode 100644 index 00000000000..06fa01ddb9e --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/KeyPackageApiV5.kt @@ -0,0 +1,72 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.base.authenticated.keypackage.ClaimedKeyPackageList +import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackage +import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackageApi +import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackageCountDTO +import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackageList +import com.wire.kalium.network.api.v4.authenticated.KeyPackageApiV4 +import com.wire.kalium.network.kaliumLogger +import com.wire.kalium.network.utils.NetworkResponse +import com.wire.kalium.network.utils.wrapKaliumResponse +import io.ktor.client.request.get +import io.ktor.client.request.parameter +import io.ktor.client.request.post +import io.ktor.client.request.setBody + +internal open class KeyPackageApiV5 internal constructor( + private val authenticatedNetworkClient: AuthenticatedNetworkClient +) : KeyPackageApiV4() { + private val httpClient get() = authenticatedNetworkClient.httpClient + + override suspend fun claimKeyPackages( + param: KeyPackageApi.Param + ): NetworkResponse = wrapKaliumResponse { + httpClient.post("$PATH_KEY_PACKAGES/$PATH_CLAIM/${param.user.domain}/${param.user.value}") { + if (param is KeyPackageApi.Param.SkipOwnClient) { + parameter(QUERY_SKIP_OWN, param.selfClientId) + } + } + } + + override suspend fun uploadKeyPackages( + clientId: String, + keyPackages: List + ): NetworkResponse = + wrapKaliumResponse { + kaliumLogger.v("Keypackages Count: ${keyPackages.size}") + httpClient.post("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId") { + setBody(KeyPackageList(keyPackages)) + } + } + + override suspend fun getAvailableKeyPackageCount(clientId: String): NetworkResponse = + wrapKaliumResponse { httpClient.get("$PATH_KEY_PACKAGES/$PATH_SELF/$clientId/$PATH_COUNT") } + + private companion object { + const val PATH_KEY_PACKAGES = "mls/key-packages" + const val PATH_CLAIM = "claim" + const val PATH_SELF = "self" + const val PATH_COUNT = "count" + const val QUERY_SKIP_OWN = "skip_own" + } +} diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/LogoutApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/LogoutApiV5.kt new file mode 100644 index 00000000000..efd6f900355 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/LogoutApiV5.kt @@ -0,0 +1,28 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.LogoutApiV4 +import com.wire.kalium.network.session.SessionManager + +internal open class LogoutApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + sessionManager: SessionManager +) : LogoutApiV4(authenticatedNetworkClient, sessionManager) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MLSMessageApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MLSMessageApiV5.kt new file mode 100644 index 00000000000..9ca9a119a3e --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MLSMessageApiV5.kt @@ -0,0 +1,58 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.base.authenticated.message.MLSMessageApi +import com.wire.kalium.network.api.base.authenticated.message.SendMLSMessageResponse +import com.wire.kalium.network.api.v4.authenticated.MLSMessageApiV4 +import com.wire.kalium.network.serialization.Mls +import com.wire.kalium.network.utils.NetworkResponse +import com.wire.kalium.network.utils.wrapKaliumResponse +import io.ktor.client.request.post +import io.ktor.client.request.setBody +import io.ktor.http.ContentType +import io.ktor.http.contentType + +internal open class MLSMessageApiV5 internal constructor( + private val authenticatedNetworkClient: AuthenticatedNetworkClient +) : MLSMessageApiV4() { + private val httpClient get() = authenticatedNetworkClient.httpClient + + override suspend fun sendMessage(message: MLSMessageApi.Message): NetworkResponse = + wrapKaliumResponse { + httpClient.post(PATH_MESSAGE) { + setBody(message.value) + contentType(ContentType.Message.Mls) + } + } + + override suspend fun sendCommitBundle(bundle: MLSMessageApi.CommitBundle): NetworkResponse = + wrapKaliumResponse { + httpClient.post(PATH_COMMIT_BUNDLES) { + setBody(bundle.value) + contentType(ContentType.Message.Mls) + } + } + + private companion object { + const val PATH_COMMIT_BUNDLES = "mls/commit-bundles" + const val PATH_MESSAGE = "mls/messages" + } +} diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MLSPublicKeyApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MLSPublicKeyApiV5.kt new file mode 100644 index 00000000000..63403f66a7b --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MLSPublicKeyApiV5.kt @@ -0,0 +1,41 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.base.authenticated.serverpublickey.MLSPublicKeysDTO +import com.wire.kalium.network.api.v4.authenticated.MLSPublicKeyApiV4 +import com.wire.kalium.network.utils.NetworkResponse +import com.wire.kalium.network.utils.wrapKaliumResponse +import io.ktor.client.request.get + +internal open class MLSPublicKeyApiV5 internal constructor( + private val authenticatedNetworkClient: AuthenticatedNetworkClient +) : MLSPublicKeyApiV4() { + + private val httpClient get() = authenticatedNetworkClient.httpClient + + override suspend fun getMLSPublicKeys(): NetworkResponse = + wrapKaliumResponse { httpClient.get("$PATH_MLS/$PATH_PUBLIC_KEYS") } + + private companion object { + const val PATH_PUBLIC_KEYS = "public-keys" + const val PATH_MLS = "mls" + } +} diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MessageApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MessageApiV5.kt new file mode 100644 index 00000000000..e9cc8aa9151 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/MessageApiV5.kt @@ -0,0 +1,28 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.base.authenticated.message.EnvelopeProtoMapper +import com.wire.kalium.network.api.v4.authenticated.MessageApiV4 + +internal open class MessageApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + envelopeProtoMapper: EnvelopeProtoMapper +) : MessageApiV4(authenticatedNetworkClient, envelopeProtoMapper) 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 new file mode 100644 index 00000000000..bef40728294 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/NotificationApiV5.kt @@ -0,0 +1,30 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.AuthenticatedWebSocketClient +import com.wire.kalium.network.api.v4.authenticated.NotificationApiV4 +import com.wire.kalium.network.tools.ServerConfigDTO + +internal open class NotificationApiV5 internal constructor( + private val authenticatedNetworkClient: AuthenticatedNetworkClient, + authenticatedWebSocketClient: AuthenticatedWebSocketClient, + serverLinks: ServerConfigDTO.Links +) : NotificationApiV4(authenticatedNetworkClient, authenticatedWebSocketClient, serverLinks) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/PreKeyApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/PreKeyApiV5.kt new file mode 100644 index 00000000000..54a691f833c --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/PreKeyApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.PreKeyApiV4 + +internal open class PreKeyApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : PreKeyApiV4(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/PropertiesApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/PropertiesApiV5.kt new file mode 100644 index 00000000000..e84a835c746 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/PropertiesApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.PropertiesApiV4 + +internal open class PropertiesApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : PropertiesApiV4(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/SelfApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/SelfApiV5.kt new file mode 100644 index 00000000000..a37cf428262 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/SelfApiV5.kt @@ -0,0 +1,28 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.SelfApiV4 +import com.wire.kalium.network.session.SessionManager + +internal open class SelfApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient, + sessionManager: SessionManager +) : SelfApiV4(authenticatedNetworkClient, sessionManager) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/TeamsApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/TeamsApiV5.kt new file mode 100644 index 00000000000..e8c27128a47 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/TeamsApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.TeamsApiV4 + +internal open class TeamsApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : TeamsApiV4(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/UserDetailsApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/UserDetailsApiV5.kt new file mode 100644 index 00000000000..eacc73d2036 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/UserDetailsApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.UserDetailsApiV4 + +internal open class UserDetailsApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : UserDetailsApiV4(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/UserSearchApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/UserSearchApiV5.kt new file mode 100644 index 00000000000..cc80f2a8a9c --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/UserSearchApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated + +import com.wire.kalium.network.AuthenticatedNetworkClient +import com.wire.kalium.network.api.v4.authenticated.UserSearchApiV4 + +internal open class UserSearchApiV5 internal constructor( + authenticatedNetworkClient: AuthenticatedNetworkClient +) : UserSearchApiV4(authenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/networkContainer/AuthenticatedNetworkContainerV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/networkContainer/AuthenticatedNetworkContainerV5.kt new file mode 100644 index 00000000000..616038cb15a --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/authenticated/networkContainer/AuthenticatedNetworkContainerV5.kt @@ -0,0 +1,126 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.authenticated.networkContainer + +import com.wire.kalium.network.NetworkStateObserver +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.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.base.model.UserId +import com.wire.kalium.network.api.v5.authenticated.AccessTokenApiV5 +import com.wire.kalium.network.api.v5.authenticated.AssetApiV5 +import com.wire.kalium.network.api.v5.authenticated.CallApiV5 +import com.wire.kalium.network.api.v5.authenticated.ClientApiV5 +import com.wire.kalium.network.api.v5.authenticated.ConnectionApiV5 +import com.wire.kalium.network.api.v5.authenticated.ConversationApiV5 +import com.wire.kalium.network.api.v5.authenticated.E2EIApiV5 +import com.wire.kalium.network.api.v5.authenticated.FeatureConfigApiV5 +import com.wire.kalium.network.api.v5.authenticated.KeyPackageApiV5 +import com.wire.kalium.network.api.v5.authenticated.LogoutApiV5 +import com.wire.kalium.network.api.v5.authenticated.MLSMessageApiV5 +import com.wire.kalium.network.api.v5.authenticated.MLSPublicKeyApiV5 +import com.wire.kalium.network.api.v5.authenticated.MessageApiV5 +import com.wire.kalium.network.api.v5.authenticated.NotificationApiV5 +import com.wire.kalium.network.api.v5.authenticated.PreKeyApiV5 +import com.wire.kalium.network.api.v5.authenticated.PropertiesApiV5 +import com.wire.kalium.network.api.v5.authenticated.SelfApiV5 +import com.wire.kalium.network.api.v5.authenticated.TeamsApiV5 +import com.wire.kalium.network.api.v5.authenticated.UserDetailsApiV5 +import com.wire.kalium.network.api.v5.authenticated.UserSearchApiV5 +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.SessionManager +import io.ktor.client.engine.HttpClientEngine + +internal class AuthenticatedNetworkContainerV5 internal constructor( + private val networkStateObserver: NetworkStateObserver, + private val sessionManager: SessionManager, + private val selfUserId: UserId, + engine: HttpClientEngine = defaultHttpEngine( + sessionManager.serverConfig().links.apiProxy, + sessionManager.proxyCredentials() + ) +) : AuthenticatedNetworkContainer, + AuthenticatedHttpClientProvider by AuthenticatedHttpClientProviderImpl( + sessionManager, + networkStateObserver, + { httpClient -> AccessTokenApiV5(httpClient) }, + engine + ) { + + override val accessTokenApi: AccessTokenApi get() = AccessTokenApiV5(networkClient.httpClient) + + override val logoutApi: LogoutApi get() = LogoutApiV5(networkClient, sessionManager) + + override val clientApi: ClientApi get() = ClientApiV5(networkClient) + + override val messageApi: MessageApi get() = MessageApiV5(networkClient, EnvelopeProtoMapperImpl()) + + override val mlsMessageApi: MLSMessageApi get() = MLSMessageApiV5(networkClient) + + override val e2eiApi: E2EIApi get() = E2EIApiV5(networkClient) + + override val conversationApi: ConversationApi get() = ConversationApiV5(networkClient) + + override val keyPackageApi: KeyPackageApi get() = KeyPackageApiV5(networkClient) + + override val preKeyApi: PreKeyApi get() = PreKeyApiV5(networkClient) + + override val assetApi: AssetApi get() = AssetApiV5(networkClientWithoutCompression, selfUserId) + + override val notificationApi: NotificationApi get() = NotificationApiV5(networkClient, websocketClient, backendConfig) + + override val teamsApi: TeamsApi get() = TeamsApiV5(networkClient) + + override val selfApi: SelfApi get() = SelfApiV5(networkClient, sessionManager) + + override val userDetailsApi: UserDetailsApi get() = UserDetailsApiV5(networkClient) + + override val userSearchApi: UserSearchApi get() = UserSearchApiV5(networkClient) + + override val callApi: CallApi get() = CallApiV5(networkClient) + + override val connectionApi: ConnectionApi get() = ConnectionApiV5(networkClient) + + override val featureConfigApi: FeatureConfigApi get() = FeatureConfigApiV5(networkClient) + + override val mlsPublicKeyApi: MLSPublicKeyApi get() = MLSPublicKeyApiV5(networkClient) + + override val propertiesApi: PropertiesApi get() = PropertiesApiV5(networkClient) +} diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/DomainLookupApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/DomainLookupApiV5.kt new file mode 100644 index 00000000000..30bc2e4066a --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/DomainLookupApiV5.kt @@ -0,0 +1,25 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v4.unauthenticated.DomainLookupApiV4 + +internal open class DomainLookupApiV5 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : DomainLookupApiV4(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/LoginApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/LoginApiV5.kt new file mode 100644 index 00000000000..41a486b0915 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/LoginApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v4.unauthenticated.LoginApiV4 + +internal open class LoginApiV5 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : LoginApiV4(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/RegisterApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/RegisterApiV5.kt new file mode 100644 index 00000000000..58602bc082d --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/RegisterApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v4.unauthenticated.RegisterApiV4 + +internal open class RegisterApiV5 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : RegisterApiV4(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/SSOLoginApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/SSOLoginApiV5.kt new file mode 100644 index 00000000000..4b9bd525dea --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/SSOLoginApiV5.kt @@ -0,0 +1,26 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v4.unauthenticated.SSOLoginApiV4 + +internal open class SSOLoginApiV5 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : SSOLoginApiV4(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/VerificationCodeApiV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/VerificationCodeApiV5.kt new file mode 100644 index 00000000000..40a1ba84a23 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/VerificationCodeApiV5.kt @@ -0,0 +1,25 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.unauthenticated + +import com.wire.kalium.network.UnauthenticatedNetworkClient +import com.wire.kalium.network.api.v4.unauthenticated.VerificationCodeApiV4 + +internal open class VerificationCodeApiV5 internal constructor( + unauthenticatedNetworkClient: UnauthenticatedNetworkClient +) : VerificationCodeApiV4(unauthenticatedNetworkClient) diff --git a/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV5.kt b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV5.kt new file mode 100644 index 00000000000..aff48a0b1f8 --- /dev/null +++ b/network/src/commonMain/kotlin/com/wire/kalium/network/api/v5/unauthenticated/networkContainer/UnauthenticatedNetworkContainerV5.kt @@ -0,0 +1,60 @@ +/* + * Wire + * Copyright (C) 2023 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.v5.unauthenticated.networkContainer + +import com.wire.kalium.network.NetworkStateObserver +import com.wire.kalium.network.api.base.model.ProxyCredentialsDTO +import com.wire.kalium.network.api.base.unauthenticated.DomainLookupApi +import com.wire.kalium.network.api.base.unauthenticated.LoginApi +import com.wire.kalium.network.api.base.unauthenticated.SSOLoginApi +import com.wire.kalium.network.api.base.unauthenticated.VerificationCodeApi +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.register.RegisterApi +import com.wire.kalium.network.api.v5.unauthenticated.DomainLookupApiV5 +import com.wire.kalium.network.api.v5.unauthenticated.LoginApiV5 +import com.wire.kalium.network.api.v5.unauthenticated.RegisterApiV5 +import com.wire.kalium.network.api.v5.unauthenticated.SSOLoginApiV5 +import com.wire.kalium.network.api.v5.unauthenticated.VerificationCodeApiV5 +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.tools.ServerConfigDTO +import io.ktor.client.engine.HttpClientEngine + +class UnauthenticatedNetworkContainerV5 internal constructor( + networkStateObserver: NetworkStateObserver, + backendLinks: ServerConfigDTO, + proxyCredentials: ProxyCredentialsDTO?, + engine: HttpClientEngine = defaultHttpEngine(backendLinks.links.apiProxy, proxyCredentials) +) : UnauthenticatedNetworkContainer, + UnauthenticatedNetworkClientProvider by UnauthenticatedNetworkClientProviderImpl( + networkStateObserver, + backendLinks, + proxyCredentials, + engine + ) { + override val loginApi: LoginApi get() = LoginApiV5(unauthenticatedNetworkClient) + override val verificationCodeApi: VerificationCodeApi get() = VerificationCodeApiV5(unauthenticatedNetworkClient) + override val domainLookupApi: DomainLookupApi get() = DomainLookupApiV5(unauthenticatedNetworkClient) + override val registerApi: RegisterApi get() = RegisterApiV5(unauthenticatedNetworkClient) + override val sso: SSOLoginApi get() = SSOLoginApiV5(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 7f6b5c3b017..630101db41b 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 @@ -46,7 +46,8 @@ import com.wire.kalium.network.api.v0.authenticated.networkContainer.Authenticat import com.wire.kalium.network.api.v2.authenticated.networkContainer.AuthenticatedNetworkContainerV2 import com.wire.kalium.network.api.v3.authenticated.networkContainer.AuthenticatedNetworkContainerV3 import com.wire.kalium.network.api.v4.authenticated.networkContainer.AuthenticatedNetworkContainerV4 -import com.wire.kalium.network.session.CertificatePinning +import com.wire.kalium.network.api.v5.authenticated.networkContainer.AuthenticatedNetworkContainerV5 +import com.wire.kalium.network.defaultHttpEngine import com.wire.kalium.network.session.SessionManager import com.wire.kalium.network.tools.ServerConfigDTO import io.ktor.client.HttpClient @@ -149,6 +150,12 @@ interface AuthenticatedNetworkContainer { certificatePinning ) + 5 -> AuthenticatedNetworkContainerV5( + networkStateObserver, + sessionManager, + selfUserId + ) + 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 133af4ba0b8..853d016322a 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 @@ -31,7 +31,8 @@ import com.wire.kalium.network.api.v0.unauthenticated.networkContainer.Unauthent import com.wire.kalium.network.api.v2.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV2 import com.wire.kalium.network.api.v3.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV3 import com.wire.kalium.network.api.v4.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV4 -import com.wire.kalium.network.session.CertificatePinning +import com.wire.kalium.network.api.v5.unauthenticated.networkContainer.UnauthenticatedNetworkContainerV5 +import com.wire.kalium.network.defaultHttpEngine import com.wire.kalium.network.tools.ServerConfigDTO import io.ktor.client.engine.HttpClientEngine @@ -91,6 +92,12 @@ interface UnauthenticatedNetworkContainer { certificatePinning = certificatePinning, ) + 5 -> UnauthenticatedNetworkContainerV5( + networkStateObserver, + serverConfigDTO, + proxyCredentials = proxyCredentials + ) + else -> error("Unsupported version: ${serverConfigDTO.metaData.commonApiVersion.version}") } } diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/ConversationApiV4Test.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/v4/ConversationApiV4Test.kt index 355dcb1802a..a843d43fdb5 100644 --- a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/ConversationApiV4Test.kt +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/v4/ConversationApiV4Test.kt @@ -22,17 +22,12 @@ import com.wire.kalium.api.ApiTest import com.wire.kalium.api.json.model.ErrorResponseJson import com.wire.kalium.model.EventContentDTOJson import com.wire.kalium.model.conversation.CreateConversationRequestJson -import com.wire.kalium.model.conversation.SubconversationDeleteRequestJson -import com.wire.kalium.model.conversation.SubconversationDetailsResponseJson import com.wire.kalium.network.api.base.authenticated.conversation.AddConversationMembersRequest -import com.wire.kalium.network.api.base.authenticated.conversation.SubconversationDeleteRequest -import com.wire.kalium.network.api.base.authenticated.conversation.SubconversationResponse import com.wire.kalium.network.api.base.model.ConversationId import com.wire.kalium.network.api.base.model.FederationConflictResponse import com.wire.kalium.network.api.base.model.UserId import com.wire.kalium.network.api.v4.authenticated.ConversationApiV4 import com.wire.kalium.network.exceptions.KaliumException -import com.wire.kalium.network.utils.NetworkResponse import com.wire.kalium.network.utils.UnreachableRemoteBackends import com.wire.kalium.network.utils.isSuccessful import io.ktor.http.HttpStatusCode @@ -40,7 +35,6 @@ import kotlinx.coroutines.test.runTest import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse -import kotlin.test.assertIs import kotlin.test.assertTrue internal class ConversationApiV4Test : ApiTest() { @@ -73,108 +67,6 @@ internal class ConversationApiV4Test : ApiTest() { ) } - @Test - fun givenRequest_whenFetchingSubconversationDetails_thenRequestIsConfiguredCorrectly() = runTest { - val networkClient = mockAuthenticatedNetworkClient( - SubconversationDetailsResponseJson.v4.rawJson, - statusCode = HttpStatusCode.OK, - assertion = { - assertGet() - assertPathEqual( - "/conversations/anta.wire.link/ebafd3d4-1548-49f2-ac4e-b2757e6ca44b/subconversations/sub" - ) - } - ) - - val conversationApi = ConversationApiV4(networkClient) - conversationApi.fetchSubconversationDetails( - ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), - "sub" - ) - } - - @Test - fun givenSuccessSubconversationDetails_whenFetchingSubconversationDetails_thenResponseIsParsedCorrectly() = - runTest { - val networkClient = mockAuthenticatedNetworkClient( - SubconversationDetailsResponseJson.v4.rawJson, - statusCode = HttpStatusCode.OK - ) - - val conversationApi = ConversationApiV4(networkClient) - conversationApi.fetchSubconversationDetails( - ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), - "sub" - ).also { - assertIs>(it) - } - } - - @Test - fun givenRequest_whenFetchingSubconversationGroupInfo_thenRequestIsConfiguredCorrectly() = runTest { - val networkClient = mockAuthenticatedNetworkClient( - "groupinfo".encodeToByteArray(), - statusCode = HttpStatusCode.OK, - assertion = { - assertGet() - assertPathEqual( - "/conversations/anta.wire.link/ebafd3d4-1548-49f2-ac4e-b2757e6ca44b/subconversations/sub/groupinfo" - ) - } - ) - - val conversationApi = ConversationApiV4(networkClient) - conversationApi.fetchSubconversationGroupInfo( - ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), - "sub" - ).also { - assertIs>(it) - } - } - - @Test - fun givenRequest_whenDeletingSubconversation_thenRequestIsConfiguredCorrectly() = runTest { - val networkClient = mockAuthenticatedNetworkClient( - ByteArray(0), - statusCode = HttpStatusCode.OK, - assertion = { - assertDelete() - assertPathEqual( - "/conversations/anta.wire.link/ebafd3d4-1548-49f2-ac4e-b2757e6ca44b/subconversations/sub" - ) - assertJsonBodyContent(SubconversationDeleteRequestJson.v4.rawJson) - } - ) - - val deleteRequest = SubconversationDeleteRequest(43UL, "groupid") - val conversationApi = ConversationApiV4(networkClient) - conversationApi.deleteSubconversation( - ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), - "sub", - deleteRequest - ) - } - - @Test - fun givenRequest_whenLeavingSubconversation_thenRequestIsConfiguredCorrectly() = runTest { - val networkClient = mockAuthenticatedNetworkClient( - ByteArray(0), - statusCode = HttpStatusCode.OK, - assertion = { - assertDelete() - assertPathEqual( - "/conversations/anta.wire.link/ebafd3d4-1548-49f2-ac4e-b2757e6ca44b/subconversations/sub/self" - ) - } - ) - - val conversationApi = ConversationApiV4(networkClient) - conversationApi.leaveSubconversation( - ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), - "sub", - ) - } - @Test fun whenAddingMemberToGroup_AndRemoteFailureUnreachable_thenTheMemberShouldBeAddedCorrectly() = runTest { val conversationId = ConversationId("conversationId", "conversationDomain") diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/v5/ConversationApiV5Test.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/ConversationApiV5Test.kt new file mode 100644 index 00000000000..8df6da3b328 --- /dev/null +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/ConversationApiV5Test.kt @@ -0,0 +1,139 @@ +/* + * Wire + * Copyright (C) 2023 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.v5 + +import com.wire.kalium.api.ApiTest +import com.wire.kalium.model.conversation.CreateConversationRequestJson +import com.wire.kalium.model.conversation.SubconversationDeleteRequestJson +import com.wire.kalium.model.conversation.SubconversationDetailsResponseJson +import com.wire.kalium.network.api.base.authenticated.conversation.SubconversationDeleteRequest +import com.wire.kalium.network.api.base.authenticated.conversation.SubconversationResponse +import com.wire.kalium.network.api.base.model.ConversationId +import com.wire.kalium.network.api.v5.authenticated.ConversationApiV5 +import com.wire.kalium.network.utils.NetworkResponse +import io.ktor.http.HttpStatusCode +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertIs + +internal class ConversationApiV5Test : ApiTest() { + + + @Test + fun givenRequest_whenFetchingSubconversationDetails_thenRequestIsConfiguredCorrectly() = runTest { + val networkClient = mockAuthenticatedNetworkClient( + SubconversationDetailsResponseJson.v5.rawJson, + statusCode = HttpStatusCode.OK, + assertion = { + assertGet() + assertPathEqual( + "/conversations/anta.wire.link/ebafd3d4-1548-49f2-ac4e-b2757e6ca44b/subconversations/sub" + ) + } + ) + + val conversationApi = ConversationApiV5(networkClient) + conversationApi.fetchSubconversationDetails( + ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), + "sub" + ) + } + + @Test + fun givenSuccessSubconversationDetails_whenFetchingSubconversationDetails_thenResponseIsParsedCorrectly() = + runTest { + val networkClient = mockAuthenticatedNetworkClient( + SubconversationDetailsResponseJson.v5.rawJson, + statusCode = HttpStatusCode.OK + ) + + val conversationApi = ConversationApiV5(networkClient) + conversationApi.fetchSubconversationDetails( + ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), + "sub" + ).also { + assertIs>(it) + } + } + + @Test + fun givenRequest_whenFetchingSubconversationGroupInfo_thenRequestIsConfiguredCorrectly() = runTest { + val networkClient = mockAuthenticatedNetworkClient( + "groupinfo".encodeToByteArray(), + statusCode = HttpStatusCode.OK, + assertion = { + assertGet() + assertPathEqual( + "/conversations/anta.wire.link/ebafd3d4-1548-49f2-ac4e-b2757e6ca44b/subconversations/sub/groupinfo" + ) + } + ) + + val conversationApi = ConversationApiV5(networkClient) + conversationApi.fetchSubconversationGroupInfo( + ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), + "sub" + ).also { + assertIs>(it) + } + } + + @Test + fun givenRequest_whenDeletingSubconversation_thenRequestIsConfiguredCorrectly() = runTest { + val networkClient = mockAuthenticatedNetworkClient( + ByteArray(0), + statusCode = HttpStatusCode.OK, + assertion = { + assertDelete() + assertPathEqual( + "/conversations/anta.wire.link/ebafd3d4-1548-49f2-ac4e-b2757e6ca44b/subconversations/sub" + ) + assertJsonBodyContent(SubconversationDeleteRequestJson.v4.rawJson) + } + ) + + val deleteRequest = SubconversationDeleteRequest(43UL, "groupid") + val conversationApi = ConversationApiV5(networkClient) + conversationApi.deleteSubconversation( + ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), + "sub", + deleteRequest + ) + } + + @Test + fun givenRequest_whenLeavingSubconversation_thenRequestIsConfiguredCorrectly() = runTest { + val networkClient = mockAuthenticatedNetworkClient( + ByteArray(0), + statusCode = HttpStatusCode.OK, + assertion = { + assertDelete() + assertPathEqual( + "/conversations/anta.wire.link/ebafd3d4-1548-49f2-ac4e-b2757e6ca44b/subconversations/sub/self" + ) + } + ) + + val conversationApi = ConversationApiV5(networkClient) + conversationApi.leaveSubconversation( + ConversationId("ebafd3d4-1548-49f2-ac4e-b2757e6ca44b", "anta.wire.link"), + "sub", + ) + } +} diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/E2EIApiV4Test.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/E2EIApiV5Test.kt similarity index 91% rename from network/src/commonTest/kotlin/com/wire/kalium/api/v4/E2EIApiV4Test.kt rename to network/src/commonTest/kotlin/com/wire/kalium/api/v5/E2EIApiV5Test.kt index 468cf475a1d..2e322306e91 100644 --- a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/E2EIApiV4Test.kt +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/E2EIApiV5Test.kt @@ -15,11 +15,11 @@ * 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.v4 +package com.wire.kalium.api.v5 import com.wire.kalium.api.ApiTest import com.wire.kalium.network.api.base.authenticated.e2ei.E2EIApi -import com.wire.kalium.network.api.v4.authenticated.E2EIApiV4 +import com.wire.kalium.network.api.v5.authenticated.E2EIApiV5 import com.wire.kalium.network.utils.isSuccessful import io.ktor.http.HttpStatusCode import kotlinx.coroutines.test.runTest @@ -28,7 +28,7 @@ import kotlin.test.assertEquals import kotlin.test.assertFalse import kotlin.test.assertTrue -internal class E2EIApiV4Test : ApiTest() { +internal class E2EIApiV5Test : ApiTest() { @Test fun giveAValidResponseWithNonceInHeader_whenCallingNonceApi_theResponseShouldBeConfigureCorrectly() = runTest { @@ -42,7 +42,7 @@ internal class E2EIApiV4Test : ApiTest() { assertPathEqual(NONCE_PATH) } ) - val e2EIApi: E2EIApi = E2EIApiV4(networkClient) + val e2EIApi: E2EIApi = E2EIApiV5(networkClient) val response = e2EIApi.getWireNonce(VALID_CLIENT_ID) assertTrue(response.isSuccessful()) @@ -60,7 +60,7 @@ internal class E2EIApiV4Test : ApiTest() { assertPathEqual(NONCE_PATH) } ) - val e2EIApi: E2EIApi = E2EIApiV4(networkClient) + val e2EIApi: E2EIApi = E2EIApiV5(networkClient) val response = e2EIApi.getWireNonce(VALID_CLIENT_ID) assertFalse(response.isSuccessful()) diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/KeyPackageApiV4Test.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/KeyPackageApiV5Test.kt similarity index 91% rename from network/src/commonTest/kotlin/com/wire/kalium/api/v4/KeyPackageApiV4Test.kt rename to network/src/commonTest/kotlin/com/wire/kalium/api/v5/KeyPackageApiV5Test.kt index 9f16c4e99c8..e7bdac00877 100644 --- a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/KeyPackageApiV4Test.kt +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/KeyPackageApiV5Test.kt @@ -16,13 +16,13 @@ * along with this program. If not, see http://www.gnu.org/licenses/. */ -package com.wire.kalium.api.v4 +package com.wire.kalium.api.v5 import com.wire.kalium.api.ApiTest import com.wire.kalium.api.json.model.KeyPackageJson import com.wire.kalium.network.api.base.authenticated.keypackage.KeyPackageApi import com.wire.kalium.network.api.base.model.UserId -import com.wire.kalium.network.api.v4.authenticated.KeyPackageApiV4 +import com.wire.kalium.network.api.v5.authenticated.KeyPackageApiV5 import com.wire.kalium.network.utils.isSuccessful import io.ktor.http.HttpStatusCode import kotlinx.coroutines.test.runTest @@ -30,7 +30,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue -internal class KeyPackageApiV4Test : ApiTest() { +internal class KeyPackageApiV5Test : ApiTest() { @Test fun givenAValidClientId_whenCallingGetAvailableKeyPackageCountEndpoint_theRequestShouldBeConfiguredCorrectly() = runTest { @@ -42,7 +42,7 @@ internal class KeyPackageApiV4Test : ApiTest() { assertPathEqual(KEY_PACKAGE_COUNT_PATH) } ) - val keyPackageApi: KeyPackageApi = KeyPackageApiV4(networkClient) + val keyPackageApi: KeyPackageApi = KeyPackageApiV5(networkClient) val response = keyPackageApi.getAvailableKeyPackageCount(VALID_CLIENT_ID) assertTrue(response.isSuccessful()) @@ -60,7 +60,7 @@ internal class KeyPackageApiV4Test : ApiTest() { assertPathEqual(KEY_PACKAGE_UPLOAD_PATH) } ) - val keyPackageApi: KeyPackageApi = KeyPackageApiV4(networkClient) + val keyPackageApi: KeyPackageApi = KeyPackageApiV5(networkClient) val response = keyPackageApi.uploadKeyPackages(VALID_CLIENT_ID, listOf(VALID_KEY_PACKAGE)) assertTrue(response.isSuccessful()) @@ -76,7 +76,7 @@ internal class KeyPackageApiV4Test : ApiTest() { assertPathEqual(KEY_PACKAGE_CLAIM_PATH) } ) - val keyPackageApi: KeyPackageApi = KeyPackageApiV4(networkClient) + val keyPackageApi: KeyPackageApi = KeyPackageApiV5(networkClient) val response = keyPackageApi.claimKeyPackages(KeyPackageApi.Param.IncludeOwnClient(VALID_USER_ID)) assertTrue(response.isSuccessful()) diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/MLSMessageApiV4Test.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/MLSMessageApiV5Test.kt similarity index 90% rename from network/src/commonTest/kotlin/com/wire/kalium/api/v4/MLSMessageApiV4Test.kt rename to network/src/commonTest/kotlin/com/wire/kalium/api/v5/MLSMessageApiV5Test.kt index 0c00b00a4ac..d08d1a3cb2f 100644 --- a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/MLSMessageApiV4Test.kt +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/MLSMessageApiV5Test.kt @@ -16,15 +16,14 @@ * along with this program. If not, see http://www.gnu.org/licenses/. */ -package com.wire.kalium.api.v4 +package com.wire.kalium.api.v5 import com.wire.kalium.api.ApiTest import com.wire.kalium.model.SendMLSMessageResponseJson import com.wire.kalium.network.api.base.authenticated.message.MLSMessageApi import com.wire.kalium.network.api.v0.authenticated.MLSMessageApiV0 -import com.wire.kalium.network.api.v4.authenticated.MLSMessageApiV4 +import com.wire.kalium.network.api.v5.authenticated.MLSMessageApiV5 import com.wire.kalium.network.serialization.Mls -import com.wire.kalium.network.serialization.XProtoBuf import com.wire.kalium.network.utils.isSuccessful import io.ktor.http.ContentType import io.ktor.http.HttpStatusCode @@ -35,7 +34,7 @@ import kotlin.test.assertFalse import kotlin.test.assertTrue @ExperimentalCoroutinesApi -internal class MLSMessageApiV4Test : ApiTest() { +internal class MLSMessageApiV5Test : ApiTest() { @Test fun givenMessage_whenSendingCommitBundle_theRequestShouldBeConfiguredCorrectly() = @@ -50,7 +49,7 @@ internal class MLSMessageApiV4Test : ApiTest() { assertPathEqual(PATH_COMMIT_BUNDLES) } ) - val mlsMessageApi: MLSMessageApi = MLSMessageApiV4(networkClient) + val mlsMessageApi: MLSMessageApi = MLSMessageApiV5(networkClient) val response = mlsMessageApi.sendCommitBundle(COMMIT_BUNDLE) assertTrue(response.isSuccessful()) } @@ -68,7 +67,7 @@ internal class MLSMessageApiV4Test : ApiTest() { assertPathEqual(PATH_MESSAGE) } ) - val mlsMessageApi: MLSMessageApi = MLSMessageApiV4(networkClient) + val mlsMessageApi: MLSMessageApi = MLSMessageApiV5(networkClient) val response = mlsMessageApi.sendMessage(MESSAGE) assertTrue(response.isSuccessful()) } diff --git a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/MLSPublicKeysApiV4Test.kt b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/MLSPublicKeysApiV5Test.kt similarity index 89% rename from network/src/commonTest/kotlin/com/wire/kalium/api/v4/MLSPublicKeysApiV4Test.kt rename to network/src/commonTest/kotlin/com/wire/kalium/api/v5/MLSPublicKeysApiV5Test.kt index 60e9117ecd0..f8ef9b5e4b7 100644 --- a/network/src/commonTest/kotlin/com/wire/kalium/api/v4/MLSPublicKeysApiV4Test.kt +++ b/network/src/commonTest/kotlin/com/wire/kalium/api/v5/MLSPublicKeysApiV5Test.kt @@ -16,12 +16,12 @@ * along with this program. If not, see http://www.gnu.org/licenses/. */ -package com.wire.kalium.api.v4 +package com.wire.kalium.api.v5 import com.wire.kalium.api.ApiTest import com.wire.kalium.model.MLSPublicKeysResponseJson import com.wire.kalium.network.api.base.authenticated.serverpublickey.MLSPublicKeyApi -import com.wire.kalium.network.api.v4.authenticated.MLSPublicKeyApiV4 +import com.wire.kalium.network.api.v5.authenticated.MLSPublicKeyApiV5 import com.wire.kalium.network.utils.isSuccessful import io.ktor.http.ContentType import io.ktor.http.HttpStatusCode @@ -31,7 +31,7 @@ import kotlin.test.Test import kotlin.test.assertTrue @OptIn(ExperimentalCoroutinesApi::class) -internal class MLSPublicKeysApiV4Test : ApiTest() { +internal class MLSPublicKeysApiV5Test : ApiTest() { @Test fun givenWhenGetMLSPublicKeys_theRequestShouldBeConfiguredCorrectly() = runTest { @@ -45,7 +45,7 @@ internal class MLSPublicKeysApiV4Test : ApiTest() { assertPathEqual("$PATH_MLS/$PATH_PUBLIC_KEYS") } ) - val mlsPublicKeyApi: MLSPublicKeyApi = MLSPublicKeyApiV4(networkClient) + val mlsPublicKeyApi: MLSPublicKeyApi = MLSPublicKeyApiV5(networkClient) val response = mlsPublicKeyApi.getMLSPublicKeys() assertTrue(response.isSuccessful()) } diff --git a/network/src/commonTest/kotlin/com/wire/kalium/model/conversation/SubconversationDetailsResponseJson.kt b/network/src/commonTest/kotlin/com/wire/kalium/model/conversation/SubconversationDetailsResponseJson.kt index 45ca7aa76c7..cc61079fe9e 100644 --- a/network/src/commonTest/kotlin/com/wire/kalium/model/conversation/SubconversationDetailsResponseJson.kt +++ b/network/src/commonTest/kotlin/com/wire/kalium/model/conversation/SubconversationDetailsResponseJson.kt @@ -27,5 +27,5 @@ object SubconversationDetailsResponseJson { """.trimIndent() } - val v4 = ValidJsonProvider("", jsonProvider) + val v5 = ValidJsonProvider("", jsonProvider) }