diff --git a/composeApp/src/commonMain/kotlin/com/clipevery/dto/sync/DataContent.kt b/composeApp/src/commonMain/kotlin/com/clipevery/dto/sync/DataContent.kt index a808cbe72..2726a68ee 100644 --- a/composeApp/src/commonMain/kotlin/com/clipevery/dto/sync/DataContent.kt +++ b/composeApp/src/commonMain/kotlin/com/clipevery/dto/sync/DataContent.kt @@ -1,11 +1,11 @@ package com.clipevery.dto.sync -import com.clipevery.serializer.Base64MimeByteArraySerializer +import com.clipevery.serializer.Base64ByteArraySerializer import kotlinx.serialization.Serializable @Serializable data class DataContent( - @Serializable(with = Base64MimeByteArraySerializer::class) val data: ByteArray + @Serializable(with = Base64ByteArraySerializer::class) val data: ByteArray ) { override fun equals(other: Any?): Boolean { if (this === other) return true diff --git a/composeApp/src/commonMain/kotlin/com/clipevery/serializer/Base64MimeByteArraySerializer.kt b/composeApp/src/commonMain/kotlin/com/clipevery/serializer/Base64ByteArraySerializer.kt similarity index 91% rename from composeApp/src/commonMain/kotlin/com/clipevery/serializer/Base64MimeByteArraySerializer.kt rename to composeApp/src/commonMain/kotlin/com/clipevery/serializer/Base64ByteArraySerializer.kt index 041d0b181..84d9a6643 100644 --- a/composeApp/src/commonMain/kotlin/com/clipevery/serializer/Base64MimeByteArraySerializer.kt +++ b/composeApp/src/commonMain/kotlin/com/clipevery/serializer/Base64ByteArraySerializer.kt @@ -8,7 +8,7 @@ import kotlinx.serialization.descriptors.buildClassSerialDescriptor import kotlinx.serialization.encoding.Decoder import kotlinx.serialization.encoding.Encoder -object Base64MimeByteArraySerializer: KSerializer { +object Base64ByteArraySerializer: KSerializer { override val descriptor: SerialDescriptor = buildClassSerialDescriptor("ByteArray") {} diff --git a/composeApp/src/commonMain/kotlin/com/clipevery/utils/JsonUtils.kt b/composeApp/src/commonMain/kotlin/com/clipevery/utils/JsonUtils.kt index d9f0e8179..0c11a134e 100644 --- a/composeApp/src/commonMain/kotlin/com/clipevery/utils/JsonUtils.kt +++ b/composeApp/src/commonMain/kotlin/com/clipevery/utils/JsonUtils.kt @@ -1,6 +1,6 @@ package com.clipevery.utils -import com.clipevery.serializer.Base64MimeByteArraySerializer +import com.clipevery.serializer.Base64ByteArraySerializer import com.clipevery.serializer.IdentityKeySerializer import com.clipevery.serializer.PreKeyBundleSerializer import kotlinx.serialization.json.Json @@ -13,7 +13,7 @@ object JsonUtils { val JSON: Json = Json { serializersModule = SerializersModule { - serializersModuleOf(ByteArray::class, Base64MimeByteArraySerializer) + serializersModuleOf(ByteArray::class, Base64ByteArraySerializer) serializersModuleOf(PreKeyBundle::class, PreKeyBundleSerializer) serializersModuleOf(IdentityKey::class, IdentityKeySerializer) } diff --git a/composeApp/src/desktopMain/kotlin/com/clipevery/net/plugin/SignalDecryption.kt b/composeApp/src/desktopMain/kotlin/com/clipevery/net/plugin/SignalDecryption.kt index 7d41340cb..c45b6ac30 100644 --- a/composeApp/src/desktopMain/kotlin/com/clipevery/net/plugin/SignalDecryption.kt +++ b/composeApp/src/desktopMain/kotlin/com/clipevery/net/plugin/SignalDecryption.kt @@ -1,8 +1,6 @@ package com.clipevery.net.plugin import com.clipevery.Dependencies -import com.clipevery.serializer.Base64MimeByteArraySerializer -import com.clipevery.utils.JsonUtils import io.ktor.server.application.ApplicationPlugin import io.ktor.server.application.createApplicationPlugin import io.ktor.server.application.hooks.ReceiveRequestBytes @@ -30,9 +28,7 @@ val SignalDecryption: ApplicationPlugin = createApplicat if (signal == "1") { call.request.path() return@on application.writer { - val base64Content = body.readRemaining().readBytes() - val originalString = String(base64Content, Charsets.UTF_8) - val encryptedContent = JsonUtils.JSON.decodeFromString(Base64MimeByteArraySerializer, originalString) + val encryptedContent = body.readRemaining().readBytes() val signalProtocolAddress = SignalProtocolAddress(appInstanceId, 1) val signalMessage = SignalMessage(encryptedContent) val sessionCipher = SessionCipher(signalProtocolStore, signalProtocolAddress)