From c047067e64ead51cf47286c07998ed98a0a627a8 Mon Sep 17 00:00:00 2001 From: Csaba Kozak Date: Fri, 30 May 2025 16:03:23 +0200 Subject: [PATCH] [kotlin-client][multiplatform] update Kotlin and libraries versions --- .../multiplatform/build.gradle.kts.mustache | 20 +++++++------------ .../infrastructure/Bytes.kt.mustache | 7 +++++-- .../build.gradle.kts | 20 +++++++------------ .../client/infrastructure/Bytes.kt | 7 +++++-- .../build.gradle.kts | 20 +++++++------------ .../client/infrastructure/Bytes.kt | 7 +++++-- .../build.gradle.kts | 20 +++++++------------ .../client/infrastructure/Bytes.kt | 7 +++++-- .../build.gradle.kts | 20 +++++++------------ .../client/infrastructure/Bytes.kt | 7 +++++-- .../kotlin-multiplatform/build.gradle.kts | 20 +++++++------------ .../client/infrastructure/Bytes.kt | 7 +++++-- 12 files changed, 72 insertions(+), 90 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.kts.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.kts.mustache index 6bf2ef3e8e91..de188e8dace9 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.kts.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/build.gradle.kts.mustache @@ -1,17 +1,17 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget plugins { - kotlin("multiplatform"){{^omitGradlePluginVersions}} version "2.0.21" // kotlin_version{{/omitGradlePluginVersions}} - kotlin("plugin.serialization"){{^omitGradlePluginVersions}} version "2.0.21" // kotlin_version{{/omitGradlePluginVersions}} + kotlin("multiplatform"){{^omitGradlePluginVersions}} version "2.1.21" // kotlin_version{{/omitGradlePluginVersions}} + kotlin("plugin.serialization"){{^omitGradlePluginVersions}} version "2.1.21" // kotlin_version{{/omitGradlePluginVersions}} } group = "{{groupId}}" version = "{{artifactVersion}}" -val kotlin_version = "2.0.21" -val coroutines_version = "1.9.0" -val serialization_version = "1.7.3" -val ktor_version = "3.0.3" +val kotlin_version = "2.1.21" +val coroutines_version = "1.10.2" +val serialization_version = "1.8.1" +val ktor_version = "3.1.3" repositories { mavenCentral() @@ -43,7 +43,7 @@ kotlin { api("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") {{#kotlinx-datetime}} - api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") + api("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") {{/kotlinx-datetime}} } } @@ -79,12 +79,6 @@ kotlin { api("io.ktor:ktor-client-js:$ktor_version") } } - - all { - languageSettings.apply { - optIn("kotlin.Experimental") - } - } } } diff --git a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/Bytes.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/Bytes.kt.mustache index a11e0525d910..c5ee141023b2 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/Bytes.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-client/libraries/multiplatform/infrastructure/Bytes.kt.mustache @@ -1,6 +1,8 @@ package {{packageName}}.infrastructure import io.ktor.utils.io.core.* +import kotlinx.io.Source +import kotlinx.io.readByteArray import kotlin.experimental.and private val digits = "0123456789abcdef".toCharArray() @@ -14,7 +16,8 @@ private fun ByteArray.clearFrom(from: Int) = (from until size).forEach { this[it private fun Int.toBase64(): Char = BASE64_ALPHABET[this] private fun Byte.fromBase64(): Byte = BASE64_INVERSE_ALPHABET[toInt() and 0xff].toByte() and BASE64_MASK internal fun ByteArray.encodeBase64(): String = buildPacket { writeFully(this@encodeBase64) }.encodeBase64() -internal fun String.decodeBase64Bytes(): ByteArray = buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readBytes() +internal fun String.decodeBase64Bytes(): ByteArray = + buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readByteArray() /** * Encode [bytes] as a HEX string with no spaces, newlines and `0x` prefixes. @@ -57,7 +60,7 @@ internal fun hex(s: String): ByteArray { * * Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt */ -private fun ByteReadPacket.encodeBase64(): String = buildString { +private fun Source.encodeBase64(): String = buildString { val data = ByteArray(3) while (remaining > 0) { val read = readAvailable(data) diff --git a/samples/client/petstore/kotlin-array-simple-string-multiplatform/build.gradle.kts b/samples/client/petstore/kotlin-array-simple-string-multiplatform/build.gradle.kts index 148b2e2e72ad..c18e8595dfca 100644 --- a/samples/client/petstore/kotlin-array-simple-string-multiplatform/build.gradle.kts +++ b/samples/client/petstore/kotlin-array-simple-string-multiplatform/build.gradle.kts @@ -1,17 +1,17 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget plugins { - kotlin("multiplatform") version "2.0.21" // kotlin_version - kotlin("plugin.serialization") version "2.0.21" // kotlin_version + kotlin("multiplatform") version "2.1.21" // kotlin_version + kotlin("plugin.serialization") version "2.1.21" // kotlin_version } group = "org.openapitools" version = "1.0.0" -val kotlin_version = "2.0.21" -val coroutines_version = "1.9.0" -val serialization_version = "1.7.3" -val ktor_version = "3.0.3" +val kotlin_version = "2.1.21" +val coroutines_version = "1.10.2" +val serialization_version = "1.8.1" +val ktor_version = "3.1.3" repositories { mavenCentral() @@ -38,7 +38,7 @@ kotlin { api("io.ktor:ktor-client-content-negotiation:$ktor_version") api("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") - api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") + api("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") } } @@ -73,12 +73,6 @@ kotlin { api("io.ktor:ktor-client-js:$ktor_version") } } - - all { - languageSettings.apply { - optIn("kotlin.Experimental") - } - } } } diff --git a/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt b/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt index df72899875bd..fe511d948125 100644 --- a/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt +++ b/samples/client/petstore/kotlin-array-simple-string-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt @@ -1,6 +1,8 @@ package org.openapitools.client.infrastructure import io.ktor.utils.io.core.* +import kotlinx.io.Source +import kotlinx.io.readByteArray import kotlin.experimental.and private val digits = "0123456789abcdef".toCharArray() @@ -14,7 +16,8 @@ private fun ByteArray.clearFrom(from: Int) = (from until size).forEach { this[it private fun Int.toBase64(): Char = BASE64_ALPHABET[this] private fun Byte.fromBase64(): Byte = BASE64_INVERSE_ALPHABET[toInt() and 0xff].toByte() and BASE64_MASK internal fun ByteArray.encodeBase64(): String = buildPacket { writeFully(this@encodeBase64) }.encodeBase64() -internal fun String.decodeBase64Bytes(): ByteArray = buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readBytes() +internal fun String.decodeBase64Bytes(): ByteArray = + buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readByteArray() /** * Encode [bytes] as a HEX string with no spaces, newlines and `0x` prefixes. @@ -57,7 +60,7 @@ internal fun hex(s: String): ByteArray { * * Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt */ -private fun ByteReadPacket.encodeBase64(): String = buildString { +private fun Source.encodeBase64(): String = buildString { val data = ByteArray(3) while (remaining > 0) { val read = readAvailable(data) diff --git a/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/build.gradle.kts b/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/build.gradle.kts index 148b2e2e72ad..c18e8595dfca 100644 --- a/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/build.gradle.kts +++ b/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/build.gradle.kts @@ -1,17 +1,17 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget plugins { - kotlin("multiplatform") version "2.0.21" // kotlin_version - kotlin("plugin.serialization") version "2.0.21" // kotlin_version + kotlin("multiplatform") version "2.1.21" // kotlin_version + kotlin("plugin.serialization") version "2.1.21" // kotlin_version } group = "org.openapitools" version = "1.0.0" -val kotlin_version = "2.0.21" -val coroutines_version = "1.9.0" -val serialization_version = "1.7.3" -val ktor_version = "3.0.3" +val kotlin_version = "2.1.21" +val coroutines_version = "1.10.2" +val serialization_version = "1.8.1" +val ktor_version = "3.1.3" repositories { mavenCentral() @@ -38,7 +38,7 @@ kotlin { api("io.ktor:ktor-client-content-negotiation:$ktor_version") api("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") - api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") + api("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") } } @@ -73,12 +73,6 @@ kotlin { api("io.ktor:ktor-client-js:$ktor_version") } } - - all { - languageSettings.apply { - optIn("kotlin.Experimental") - } - } } } diff --git a/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt b/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt index df72899875bd..fe511d948125 100644 --- a/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt +++ b/samples/client/petstore/kotlin-bigdecimal-default-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt @@ -1,6 +1,8 @@ package org.openapitools.client.infrastructure import io.ktor.utils.io.core.* +import kotlinx.io.Source +import kotlinx.io.readByteArray import kotlin.experimental.and private val digits = "0123456789abcdef".toCharArray() @@ -14,7 +16,8 @@ private fun ByteArray.clearFrom(from: Int) = (from until size).forEach { this[it private fun Int.toBase64(): Char = BASE64_ALPHABET[this] private fun Byte.fromBase64(): Byte = BASE64_INVERSE_ALPHABET[toInt() and 0xff].toByte() and BASE64_MASK internal fun ByteArray.encodeBase64(): String = buildPacket { writeFully(this@encodeBase64) }.encodeBase64() -internal fun String.decodeBase64Bytes(): ByteArray = buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readBytes() +internal fun String.decodeBase64Bytes(): ByteArray = + buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readByteArray() /** * Encode [bytes] as a HEX string with no spaces, newlines and `0x` prefixes. @@ -57,7 +60,7 @@ internal fun hex(s: String): ByteArray { * * Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt */ -private fun ByteReadPacket.encodeBase64(): String = buildString { +private fun Source.encodeBase64(): String = buildString { val data = ByteArray(3) while (remaining > 0) { val read = readAvailable(data) diff --git a/samples/client/petstore/kotlin-default-values-multiplatform/build.gradle.kts b/samples/client/petstore/kotlin-default-values-multiplatform/build.gradle.kts index 148b2e2e72ad..c18e8595dfca 100644 --- a/samples/client/petstore/kotlin-default-values-multiplatform/build.gradle.kts +++ b/samples/client/petstore/kotlin-default-values-multiplatform/build.gradle.kts @@ -1,17 +1,17 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget plugins { - kotlin("multiplatform") version "2.0.21" // kotlin_version - kotlin("plugin.serialization") version "2.0.21" // kotlin_version + kotlin("multiplatform") version "2.1.21" // kotlin_version + kotlin("plugin.serialization") version "2.1.21" // kotlin_version } group = "org.openapitools" version = "1.0.0" -val kotlin_version = "2.0.21" -val coroutines_version = "1.9.0" -val serialization_version = "1.7.3" -val ktor_version = "3.0.3" +val kotlin_version = "2.1.21" +val coroutines_version = "1.10.2" +val serialization_version = "1.8.1" +val ktor_version = "3.1.3" repositories { mavenCentral() @@ -38,7 +38,7 @@ kotlin { api("io.ktor:ktor-client-content-negotiation:$ktor_version") api("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") - api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") + api("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") } } @@ -73,12 +73,6 @@ kotlin { api("io.ktor:ktor-client-js:$ktor_version") } } - - all { - languageSettings.apply { - optIn("kotlin.Experimental") - } - } } } diff --git a/samples/client/petstore/kotlin-default-values-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt b/samples/client/petstore/kotlin-default-values-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt index df72899875bd..fe511d948125 100644 --- a/samples/client/petstore/kotlin-default-values-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt +++ b/samples/client/petstore/kotlin-default-values-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt @@ -1,6 +1,8 @@ package org.openapitools.client.infrastructure import io.ktor.utils.io.core.* +import kotlinx.io.Source +import kotlinx.io.readByteArray import kotlin.experimental.and private val digits = "0123456789abcdef".toCharArray() @@ -14,7 +16,8 @@ private fun ByteArray.clearFrom(from: Int) = (from until size).forEach { this[it private fun Int.toBase64(): Char = BASE64_ALPHABET[this] private fun Byte.fromBase64(): Byte = BASE64_INVERSE_ALPHABET[toInt() and 0xff].toByte() and BASE64_MASK internal fun ByteArray.encodeBase64(): String = buildPacket { writeFully(this@encodeBase64) }.encodeBase64() -internal fun String.decodeBase64Bytes(): ByteArray = buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readBytes() +internal fun String.decodeBase64Bytes(): ByteArray = + buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readByteArray() /** * Encode [bytes] as a HEX string with no spaces, newlines and `0x` prefixes. @@ -57,7 +60,7 @@ internal fun hex(s: String): ByteArray { * * Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt */ -private fun ByteReadPacket.encodeBase64(): String = buildString { +private fun Source.encodeBase64(): String = buildString { val data = ByteArray(3) while (remaining > 0) { val read = readAvailable(data) diff --git a/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/build.gradle.kts b/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/build.gradle.kts index 148b2e2e72ad..c18e8595dfca 100644 --- a/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/build.gradle.kts +++ b/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/build.gradle.kts @@ -1,17 +1,17 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget plugins { - kotlin("multiplatform") version "2.0.21" // kotlin_version - kotlin("plugin.serialization") version "2.0.21" // kotlin_version + kotlin("multiplatform") version "2.1.21" // kotlin_version + kotlin("plugin.serialization") version "2.1.21" // kotlin_version } group = "org.openapitools" version = "1.0.0" -val kotlin_version = "2.0.21" -val coroutines_version = "1.9.0" -val serialization_version = "1.7.3" -val ktor_version = "3.0.3" +val kotlin_version = "2.1.21" +val coroutines_version = "1.10.2" +val serialization_version = "1.8.1" +val ktor_version = "3.1.3" repositories { mavenCentral() @@ -38,7 +38,7 @@ kotlin { api("io.ktor:ktor-client-content-negotiation:$ktor_version") api("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") - api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") + api("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") } } @@ -73,12 +73,6 @@ kotlin { api("io.ktor:ktor-client-js:$ktor_version") } } - - all { - languageSettings.apply { - optIn("kotlin.Experimental") - } - } } } diff --git a/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt b/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt index df72899875bd..fe511d948125 100644 --- a/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt +++ b/samples/client/petstore/kotlin-multiplatform-kotlinx-datetime/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt @@ -1,6 +1,8 @@ package org.openapitools.client.infrastructure import io.ktor.utils.io.core.* +import kotlinx.io.Source +import kotlinx.io.readByteArray import kotlin.experimental.and private val digits = "0123456789abcdef".toCharArray() @@ -14,7 +16,8 @@ private fun ByteArray.clearFrom(from: Int) = (from until size).forEach { this[it private fun Int.toBase64(): Char = BASE64_ALPHABET[this] private fun Byte.fromBase64(): Byte = BASE64_INVERSE_ALPHABET[toInt() and 0xff].toByte() and BASE64_MASK internal fun ByteArray.encodeBase64(): String = buildPacket { writeFully(this@encodeBase64) }.encodeBase64() -internal fun String.decodeBase64Bytes(): ByteArray = buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readBytes() +internal fun String.decodeBase64Bytes(): ByteArray = + buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readByteArray() /** * Encode [bytes] as a HEX string with no spaces, newlines and `0x` prefixes. @@ -57,7 +60,7 @@ internal fun hex(s: String): ByteArray { * * Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt */ -private fun ByteReadPacket.encodeBase64(): String = buildString { +private fun Source.encodeBase64(): String = buildString { val data = ByteArray(3) while (remaining > 0) { val read = readAvailable(data) diff --git a/samples/client/petstore/kotlin-multiplatform/build.gradle.kts b/samples/client/petstore/kotlin-multiplatform/build.gradle.kts index 148b2e2e72ad..c18e8595dfca 100644 --- a/samples/client/petstore/kotlin-multiplatform/build.gradle.kts +++ b/samples/client/petstore/kotlin-multiplatform/build.gradle.kts @@ -1,17 +1,17 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget plugins { - kotlin("multiplatform") version "2.0.21" // kotlin_version - kotlin("plugin.serialization") version "2.0.21" // kotlin_version + kotlin("multiplatform") version "2.1.21" // kotlin_version + kotlin("plugin.serialization") version "2.1.21" // kotlin_version } group = "org.openapitools" version = "1.0.0" -val kotlin_version = "2.0.21" -val coroutines_version = "1.9.0" -val serialization_version = "1.7.3" -val ktor_version = "3.0.3" +val kotlin_version = "2.1.21" +val coroutines_version = "1.10.2" +val serialization_version = "1.8.1" +val ktor_version = "3.1.3" repositories { mavenCentral() @@ -38,7 +38,7 @@ kotlin { api("io.ktor:ktor-client-content-negotiation:$ktor_version") api("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") - api("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") + api("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") } } @@ -73,12 +73,6 @@ kotlin { api("io.ktor:ktor-client-js:$ktor_version") } } - - all { - languageSettings.apply { - optIn("kotlin.Experimental") - } - } } } diff --git a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt index df72899875bd..fe511d948125 100644 --- a/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt +++ b/samples/client/petstore/kotlin-multiplatform/src/commonMain/kotlin/org/openapitools/client/infrastructure/Bytes.kt @@ -1,6 +1,8 @@ package org.openapitools.client.infrastructure import io.ktor.utils.io.core.* +import kotlinx.io.Source +import kotlinx.io.readByteArray import kotlin.experimental.and private val digits = "0123456789abcdef".toCharArray() @@ -14,7 +16,8 @@ private fun ByteArray.clearFrom(from: Int) = (from until size).forEach { this[it private fun Int.toBase64(): Char = BASE64_ALPHABET[this] private fun Byte.fromBase64(): Byte = BASE64_INVERSE_ALPHABET[toInt() and 0xff].toByte() and BASE64_MASK internal fun ByteArray.encodeBase64(): String = buildPacket { writeFully(this@encodeBase64) }.encodeBase64() -internal fun String.decodeBase64Bytes(): ByteArray = buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readBytes() +internal fun String.decodeBase64Bytes(): ByteArray = + buildPacket { writeText(dropLastWhile { it == BASE64_PAD }) }.decodeBase64Bytes().readByteArray() /** * Encode [bytes] as a HEX string with no spaces, newlines and `0x` prefixes. @@ -57,7 +60,7 @@ internal fun hex(s: String): ByteArray { * * Taken from https://github.com/ktorio/ktor/blob/424d1d2cfaa3281302c60af9500f738c8c2fc846/ktor-utils/common/src/io/ktor/util/Base64.kt */ -private fun ByteReadPacket.encodeBase64(): String = buildString { +private fun Source.encodeBase64(): String = buildString { val data = ByteArray(3) while (remaining > 0) { val read = readAvailable(data)