From 36735fb1e35e6d1afe70e9c4e1962f96cd323494 Mon Sep 17 00:00:00 2001 From: nbransby Date: Sun, 24 Sep 2023 10:55:49 +0400 Subject: [PATCH] throw FirebaseNetworkException on ios FIRAuthErrorCodeNetworkError and js auth/timeout --- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 6 ++++- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 +- gradle.properties | 22 +++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 26ddb3e85..38f996687 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -8,12 +8,14 @@ import cocoapods.FirebaseAuth.* import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.FirebaseException +import dev.gitlive.firebase.FirebaseNetworkException import dev.gitlive.firebase.auth.ActionCodeResult.* import kotlinx.cinterop.* import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.callbackFlow -import platform.Foundation.* +import platform.Foundation.NSError +import platform.Foundation.NSURL actual val Firebase.auth @@ -208,6 +210,8 @@ private fun NSError.toException() = when(domain) { FIRAuthErrorCodeWebContextCancelled, FIRAuthErrorCodeWebInternalError -> FirebaseAuthWebException(toString()) + FIRAuthErrorCodeNetworkError -> FirebaseNetworkException(toString()) + else -> FirebaseAuthException(toString()) } else -> FirebaseAuthException(toString()) diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt index a6499a5e7..9bfc2e61b 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -165,6 +165,7 @@ private fun errorToException(cause: dynamic) = when(val code = cause.code?.toStr "auth/user-token-expired" -> FirebaseAuthInvalidUserException(code, cause) "auth/web-storage-unsupported" -> FirebaseAuthWebException(code, cause) "auth/network-request-failed" -> FirebaseNetworkException(code, cause) + "auth/timeout" -> FirebaseNetworkException(code, cause) "auth/weak-password" -> FirebaseAuthWeakPasswordException(code, cause) "auth/invalid-credential", "auth/invalid-verification-code", @@ -176,7 +177,6 @@ private fun errorToException(cause: dynamic) = when(val code = cause.code?.toStr "auth/credential-already-in-use" -> FirebaseAuthUserCollisionException(code, cause) "auth/email-already-in-use" -> FirebaseAuthUserCollisionException(code, cause) "auth/invalid-email" -> FirebaseAuthEmailException(code, cause) - // "auth/app-deleted" -> // "auth/app-not-authorized" -> // "auth/argument-error" -> diff --git a/gradle.properties b/gradle.properties index 6384d22a4..e0d8e7f6d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -49,14 +49,14 @@ firebase-perf.skipJsTests=false firebase-storage.skipJsTests=false # Versions: -firebase-app.version=1.10.0 -firebase-auth.version=1.10.0 -firebase-common.version=1.10.0 -firebase-config.version=1.10.0 -firebase-database.version=1.10.0 -firebase-firestore.version=1.10.0 -firebase-functions.version=1.10.0 -firebase-installations.version=1.10.0 -firebase-perf.version=1.10.0 -firebase-crashlytics.version=1.10.0 -firebase-storage.version=1.10.0 +firebase-app.version=1.10.1 +firebase-auth.version=1.10.1 +firebase-common.version=1.10.1 +firebase-config.version=1.10.1 +firebase-database.version=1.10.1 +firebase-firestore.version=1.10.1 +firebase-functions.version=1.10.1 +firebase-installations.version=1.10.1 +firebase-perf.version=1.10.1 +firebase-crashlytics.version=1.10.1 +firebase-storage.version=1.10.1