Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.util.Locale

buildscript {
Expand All @@ -20,7 +21,7 @@ plugins {
alias(libs.plugins.publish)
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlinx.serialization)
alias(libs.plugins.jlleitschuh.ktlint)
alias(libs.plugins.kotlinter)
alias(libs.plugins.ben.manes.versions)
}

Expand Down Expand Up @@ -57,14 +58,10 @@ val extractClasses by tasks.registering(Copy::class) {
tasks {
compileKotlin {
dependsOn(extractClasses)
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
}
compileTestKotlin {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()
}
compilerOptions.jvmTarget.set(JvmTarget.JVM_17)
}
withType<Sign>().configureEach {
onlyIf { !project.gradle.startParameter.taskNames.any { "MavenLocal" in it } }
Expand Down Expand Up @@ -147,8 +144,7 @@ dependencies {
aar(libs.google.firebase.installations)
aar(libs.google.firebase.storage)
// extracted aar dependencies
// exclude lifecycle libs due to https://github.com/GitLiveApp/firebase-java-sdk/pull/15 - remove the exclude once the dependencies in the aars are updated to the required version
api(fileTree(mapOf("dir" to "build/jar", "include" to listOf("*.jar"), "exclude" to listOf("lifecycle-*"))))
api(fileTree(mapOf("dir" to "build/jar", "include" to listOf("*.jar"))))
// polyfill dependencies
implementation(libs.kotlinx.coroutines.core)
implementation(libs.kotlinx.serialization.core)
Expand All @@ -173,10 +169,6 @@ tasks.named("publish").configure {
dependsOn(cleanLibs)
}

ktlint {
version.set(libs.versions.ktlint.get())
}

tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {

fun isNonStable(version: String): Boolean {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=0.6.3
version=0.6.4
31 changes: 17 additions & 14 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
[versions]
androidx-lifecycle = "2.10.0-alpha01"
androidx-lifecycle = "2.10.0"
androidx-collection = "1.5.0"
okhttp="5.3.2"
sqlite="3.51.1.0"
robolectric="16-robolectric-13921718"
ben-manes-versions = "0.51.0"
google-firebase-bom = "32.7.0"
io-grpc = "1.68.0"
jlleitschuh-ktlint = "12.1.1"
kotlin = "2.0.20"
kotlinx-coroutines = "1.9.0"
kotlinx-serialization = "1.7.2"
ktlint = "0.47.1"
publish = "0.34.0"
google-firebase-bom = "34.6.0"
io-grpc = "1.77.0"
kotlinter = "5.3.0"
kotlin = "2.2.21"
kotlinx-coroutines = "1.10.2"
kotlinx-serialization = "1.9.0"
publish = "0.35.0"

[libraries]
androidx-collection = { module = "androidx.collection:collection", version = "1.4.3" }
androidx-collection = { module = "androidx.collection:collection", version.ref = "androidx-collection" }
androidx-lifecycle-common = { module = "androidx.lifecycle:lifecycle-common", version.ref = "androidx-lifecycle" }
androidx-lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel", version.ref = "androidx-lifecycle" }
google-firebase-bom = { module = "com.google.firebase:firebase-bom", version.ref = "google-firebase-bom" }
Expand All @@ -32,13 +35,13 @@ kotlinx-coroutines-swing = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-
kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx-coroutines" }
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "3.12.13" }
robolectric-android-all = { module = "org.robolectric:android-all", version = "14-robolectric-10818077" }
xerial-sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version = "3.46.1.0" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
robolectric-android-all = { module = "org.robolectric:android-all", version.ref = "robolectric" }
xerial-sqlite-jdbc = { module = "org.xerial:sqlite-jdbc", version.ref = "sqlite" }

[plugins]
ben-manes-versions = { id = "com.github.ben-manes.versions", version.ref = "ben-manes-versions" }
jlleitschuh-ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "jlleitschuh-ktlint" }
kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" }
25 changes: 13 additions & 12 deletions src/main/java/com/google/firebase/auth/FirebaseAuth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import kotlinx.serialization.json.longOrNull
import okhttp3.Call
import okhttp3.Callback
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
Expand Down Expand Up @@ -237,7 +238,7 @@ data class FirebaseUserImpl internal constructor(
class FirebaseAuth constructor(
val app: FirebaseApp
) : InternalAuthProvider {
internal val json = MediaType.parse("application/json; charset=utf-8")
internal val json = "application/json; charset=utf-8".toMediaTypeOrNull()
internal val client: OkHttpClient =
OkHttpClient
.Builder()
Expand Down Expand Up @@ -276,7 +277,7 @@ class FirebaseAuth constructor(
createAuthInvalidUserException("accounts", request, response)
)
} else {
if (response.body()?.use { it.string() }?.also { responseBody ->
if (response.body.use { it.string() }?.also { responseBody ->
user = setResult(responseBody)
source.setResult(AuthResult { user })
} == null
Expand Down Expand Up @@ -411,7 +412,7 @@ class FirebaseAuth constructor(
val newBody =
jsonParser
.parseToJsonElement(
response.body()?.use { it.string() } ?: ""
response.body?.use { it.string() } ?: ""
).jsonObject

user = user?.copy(
Expand Down Expand Up @@ -486,7 +487,7 @@ class FirebaseAuth constructor(
request: Request,
response: Response
): FirebaseAuthInvalidUserException {
val body = response.body()!!.use { it.string() }
val body = response.body.use { it.string() }
val jsonObject = jsonParser.parseToJsonElement(body).jsonObject

return FirebaseAuthInvalidUserException(
Expand All @@ -497,20 +498,20 @@ class FirebaseAuth constructor(
?.contentOrNull
?: "UNKNOWN_ERROR",
"$action API returned an error, " +
"with url [${request.method()}] ${request.url()} ${request.body()} -- " +
"response [${response.code()}] ${response.message()} $body"
"with url [${request.method}] ${request.url} ${request.body} -- " +
"response [${response.code}] ${response.message} $body"
)
}

fun signOut() {
// cancel token refresher
client
.dispatcher()
.dispatcher
.queuedCalls()
.find { it.request().tag() == REFRESH_TOKEN_TAG }
?.cancel() ?: {
client
.dispatcher()
.dispatcher
.runningCalls()
.find { it.request().tag() == REFRESH_TOKEN_TAG }
?.cancel()
Expand Down Expand Up @@ -579,9 +580,9 @@ class FirebaseAuth constructor(
call: Call,
response: Response
) {
val responseBody = response.body()?.use { it.string() }
val responseBody = response.body.use { it.string() }

if (!response.isSuccessful || responseBody == null) {
if (!response.isSuccessful) {
signOutAndThrowInvalidUserException(responseBody.orEmpty(), "token API returned an error: $body")
} else {
jsonParser.parseToJsonElement(responseBody).jsonObject.apply {
Expand Down Expand Up @@ -659,7 +660,7 @@ class FirebaseAuth constructor(
val newBody =
jsonParser
.parseToJsonElement(
response.body()?.use { it.string() } ?: ""
response.body.use { it.string() }
).jsonObject

user?.let { prev ->
Expand Down Expand Up @@ -734,7 +735,7 @@ class FirebaseAuth constructor(
val newBody =
jsonParser
.parseToJsonElement(
response.body()?.use { it.string() } ?: ""
response.body.use { it.string() }
).jsonObject

user?.let { prev ->
Expand Down