Skip to content

Commit

Permalink
Merge pull request #796 from supabase-community/kotlin-2-1-0
Browse files Browse the repository at this point in the history
Update Kotlin to 2.1.0
  • Loading branch information
jan-tennert authored Dec 4, 2024
1 parent af6f770 commit 4f822b7
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 27 deletions.
9 changes: 8 additions & 1 deletion Auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ kotlin {
val commonMain by getting {
dependencies {
addModules(SupabaseModule.SUPABASE)
implementation(libs.krypto)
// implementation(libs.krypto)
implementation(libs.secure.random)
api(libs.okio)
}
}
val desktopMain by getting {
Expand All @@ -65,6 +67,11 @@ kotlin {
api(libs.androidx.browser)
}
}
val wasmJsMain by getting {
dependencies {
api(libs.kotlinx.browser)
}
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions Auth/src/commonMain/kotlin/io/github/jan/supabase/auth/PKCE.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@file:Suppress("MatchingDeclarationName")
package io.github.jan.supabase.auth

import korlibs.crypto.SHA256
import korlibs.crypto.SecureRandom
import okio.ByteString.Companion.toByteString
import org.kotlincrypto.SecureRandom
import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi

Expand All @@ -14,13 +14,13 @@ internal object PKCEConstants {
@OptIn(ExperimentalEncodingApi::class)
internal fun generateCodeVerifier(): String {
val bytes = ByteArray(PKCEConstants.VERIFIER_LENGTH)
SecureRandom.nextBytes(bytes)
SecureRandom().nextBytesCopyTo(bytes)
return Base64.UrlSafe.encode(bytes)
}

@OptIn(ExperimentalEncodingApi::class)
internal fun generateCodeChallenge(codeVerifier: String): String {
val bytes = codeVerifier.encodeToByteArray()
val hash = SHA256.digest(bytes)
return Base64.UrlSafe.encode(hash.bytes).replace("=", "")
val byteString = codeVerifier.encodeToByteArray().toByteString()
val hash = byteString.sha256()
return Base64.UrlSafe.encode(hash.toByteArray()).replace("=", "")
}
2 changes: 1 addition & 1 deletion Functions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ kotlin {
}

android {
compileSdk = 34
compileSdk = 35
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
namespace = "io.github.jan.supabase.functions.library"
defaultConfig {
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ For information about supported Kotlin targets, see the corresponding module REA

[![](https://img.shields.io/github/release/supabase-community/supabase-kt?label=stable)](https://github.com/supabase-community/supabase-kt/releases)
[![](https://badgen.net/github/release/supabase-community/supabase-kt?label=prerelease)](https://central.sonatype.com/search?q=io.github.jan.supabase&smo=true)
[![Kotlin](https://img.shields.io/badge/kotlin-2.0.21-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Ktor](https://img.shields.io/badge/ktor-3.0.0-blue)](https://ktor.io/)
[![Kotlin](https://img.shields.io/badge/kotlin-2.1.0-blue.svg?logo=kotlin)](http://kotlinlang.org)
[![Ktor](https://img.shields.io/badge/ktor-3.0.1-blue)](https://ktor.io/)
[![slack](https://img.shields.io/badge/slack-%23supabase--kt-purple.svg?logo=slack)](https://kotlinlang.slack.com/archives/C06QXPC7064)

### Links
Expand Down Expand Up @@ -101,7 +101,7 @@ val iosMain by getting {
**Note:** It is recommended to use the same Ktor version as supabase-kt:

__For 3.0.0 and above:__
[![Ktor](https://img.shields.io/badge/ktor-3.0.0-blue)](https://ktor.io/)
[![Ktor](https://img.shields.io/badge/ktor-3.0.1-blue)](https://ktor.io/)

__For versions below 3.0.0:__
[![Ktor](https://img.shields.io/badge/ktor-2.3.12-blue)](https://ktor.io/)
Expand Down
2 changes: 1 addition & 1 deletion demos/android-login/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
}

android {
compileSdk = 34
compileSdk = 35
defaultConfig {
applicationId = "io.github.jan.supabase.android"
minSdk = 26
Expand Down
2 changes: 1 addition & 1 deletion demos/android-login/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ kotlin {
}

android {
compileSdk = 34
compileSdk = 35
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
namespace = "io.github.jan.supabase.common"
defaultConfig {
Expand Down
2 changes: 1 addition & 1 deletion demos/multiplatform-deeplinks/android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
}

android {
compileSdk = 34
compileSdk = 35
defaultConfig {
applicationId = "io.github.jan.supabase.android"
minSdk = 26
Expand Down
2 changes: 1 addition & 1 deletion demos/multiplatform-deeplinks/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ kotlin {
}

android {
compileSdk = 34
compileSdk = 35
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
namespace = "io.github.jan.supabase.common"
defaultConfig {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ org.jetbrains.compose.experimental.uikit.enabled=true
org.jetbrains.compose.experimental.jscanvas.enabled=true
org.jetbrains.compose.experimental.wasm.enabled=true

supabase-version = 3.0.2
supabase-version = 3.0.3
base-group = io.github.jan-tennert.supabase
16 changes: 10 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[versions]
kotlin = "2.0.21"
kotlin = "2.1.0"
accompanist-permissions = "0.36.0"
ktor = "3.0.1"
ktor = "3.0.2"
dokka = "1.9.20"
kotlinx-datetime = "0.6.1"
kermit = "2.0.5"
atomicfu = "0.26.0"
atomicfu = "0.26.1"
coroutines = "1.9.0"
android-lifecycle = "2.8.7"
androidx-startup = "1.2.0"
androidx-activity-compose = "1.9.3"
multiplatform-settings = "1.2.0"
multiplatform-settings = "1.3.0"
complete-kotlin = "1.1.0"
agp = "8.5.2"
maven-publish = "0.30.0"
apollo-kotlin = "4.1.0"
korlibs = "4.0.10"
korlibs = "6.0.0"
detekt = "1.23.7"
moshi = "1.15.1"
jackson = "2.18.1"
Expand All @@ -33,6 +33,8 @@ androidx-core = "1.15.0"
androidx-compat = "1.7.0"
androidx-lifecycle = "2.8.7"
filekit = "0.8.7"
kotlinx-browser = "0.3"
secure-random = "0.3.2"

[plugins]
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
Expand All @@ -54,6 +56,7 @@ power-assert = { id = "org.jetbrains.kotlin.plugin.power-assert", version.ref =
[libraries]
kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version.ref = "atomicfu" }
kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
kotlinx-browser = { module = "org.jetbrains.kotlinx:kotlinx-browser", version.ref = "kotlinx-browser" }
kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }
kotlinx-coroutines-play-services = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-play-services", version.ref = "coroutines" }
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
Expand Down Expand Up @@ -98,7 +101,8 @@ multiplatform-settings-test = { module = "com.russhwolf:multiplatform-settings-t

apollo-kotlin = { module = "com.apollographql.apollo:apollo-runtime", version.ref = "apollo-kotlin" }

krypto = { module = "com.soywiz.korlibs.krypto:krypto", version.ref = "korlibs" }
krypto = { module = "com.soywiz:korlibs-crypto", version.ref = "korlibs" }
secure-random = { module = "org.kotlincrypto:secure-random", version.ref = "secure-random" }
okio = { module = "com.squareup.okio:okio", version.ref = "okio" }

moshi = { module = "com.squareup.moshi:moshi", version.ref = "moshi" }
Expand Down
2 changes: 1 addition & 1 deletion plugins/ComposeAuth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ kotlin {
dependencies {
addModules(SupabaseModule.AUTH)
implementation(compose.runtime)
implementation(libs.krypto)
// implementation(libs.krypto)
}
}
val androidMain by getting {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package io.github.jan.supabase.compose.auth

import io.ktor.utils.io.core.toByteArray
import korlibs.crypto.SHA256
import okio.ByteString.Companion.toByteString

internal fun String.hash(): String {
val hash = SHA256.digest(this.toByteArray())
return hash.hex
val hash = this.encodeToByteArray().toByteString()
return hash.sha256().hex()
}

0 comments on commit 4f822b7

Please sign in to comment.