feat(kmp): convert :libs:encryption:utils to KMP - #1206
Merged
Merged
Conversation
Split the Android-only module into commonMain + androidMain: - commonMain/Extensions.kt: portable byte helpers — intToByteArray, byteArrayToLong/Int, subByteArray, hexEncodedString, base58 extensions, replaceParam, toUTF8Bytes, Byte.shl, HexEncodingOptions. Depends only on :libs:encryption:base58 (pure KMP). String.toUTF8Bytes now uses encodeToByteArray() instead of toByteArray(Charsets.UTF_8) for KMP compat. - androidMain/Extensions.android.kt: Android-specific helpers — Base64 encode/ decode (android.util.Base64), URL encode/decode (java.net.URLEncoder/Decoder), protobuf ByteString conversions, SHA-512 via MessageDigest, Ed25519 key helpers. - androidMain/Utils.kt: port of Utils.java to Kotlin object with @JvmStatic. Timber replaces raw Timber calls; all public API preserved with same signatures so existing callers need no changes. - commonTest/ExtensionsTest.kt: pure-Kotlin KAT vectors for commonMain helpers; runs on JVM + iosSimulatorArm64. URL tests removed (Android-only). - androidHostTest/: Base64ExtensionsTest (Robolectric; android.util.Base64), UrlExtensionsTest (java.net.URLEncoder), UtilsTest (BigInteger/stream/MPI). - settings.gradle.kts: add :libs:encryption:utils to kmpUnitTestModules so the aggregate test task uses testAndroidHostTest instead of testDebugUnitTest.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
:libs:encryption:utilsfrom Android-only to Kotlin Multiplatform, following the same pattern as:libs:encryption:base58,:sha256,:sha512, and:hmac.commonMainso they compile on iOS targets (and are usable from the SharedCore XCFramework pipeline).androidMain.Utils.javaported to Kotlin (Utils.ktinandroidMain); all public API and@JvmStaticannotations preserved — zero changes required in callers.:libs:encryption:utilsadded tokmpUnitTestModulesinsettings.gradle.ktsso the aggregate test task usestestAndroidHostTest.What moved where
Extensions.kt(portable helpers)commonMain/Extensions.ktExtensions.kt(Base64, URL, ByteString, Ed25519, SHA-512)androidMain/Extensions.android.ktUtils.javaandroidMain/Utils.kt(Kotlin port)ExtensionsTest.kt(portable)commonTest/ExtensionsTest.ktExtensionsTest.kt(URL tests)androidHostTest/UrlExtensionsTest.ktBase64ExtensionsTest.ktandroidHostTest/Base64ExtensionsTest.ktUtilsTest.ktandroidHostTest/UtilsTest.ktNote on settings.gradle.kts
Adding
:libs:encryption:utilstokmpUnitTestModulesmay conflict at merge time if concurrent work is adding other modules to that set. Resolve with a simple union merge.Test results
./gradlew :libs:encryption:utils:compileCommonMainKotlinMetadata— PASS./gradlew :libs:encryption:utils:compileAndroidMain— PASS./gradlew :libs:encryption:utils:testAndroidHostTest— PASS (all tests)./gradlew :libs:encryption:utils:allTests— PASS (JVM + iosSimulatorArm64)./gradlew :apps:flipcash:app:compileDebugSources— PASS (onlyprocessDebugGoogleServicesfails as expected in worktree)