From 377b887d29f0a0e9372645283d6ffe0d49a016da Mon Sep 17 00:00:00 2001 From: David Holas Date: Thu, 27 Jun 2024 06:45:59 +0200 Subject: [PATCH 01/20] Missing fields added to AuthResult Adds missing fields to AuthResult and makes its constructor public --- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 21 ++++++++++++- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 9 ++++++ .../kotlin/dev/gitlive/firebase/auth/auth.kt | 31 ++++++++++++++++++- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 22 ++++++++++++- .../gitlive/firebase/auth/externals/auth.kt | 8 +++++ .../kotlin/dev/gitlive/firebase/auth/auth.kt | 19 +++++++++++- 6 files changed, 106 insertions(+), 4 deletions(-) diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 1ea49e666..f4ecc0d8a 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -110,9 +110,28 @@ actual class FirebaseAuth internal constructor(val android: com.google.firebase. actual fun useEmulator(host: String, port: Int) = android.useEmulator(host, port) } -actual class AuthResult internal constructor(val android: com.google.firebase.auth.AuthResult) { +actual class AuthResult( + val android: com.google.firebase.auth.AuthResult, +) { actual val user: FirebaseUser? get() = android.user?.let { FirebaseUser(it) } + actual val credential: AuthCredential? + get() = android.credential?.let { AuthCredential(it) } + actual val additionalUserInfo: AdditionalUserInfo? + get() = android.additionalUserInfo?.let { AdditionalUserInfo(it) } +} + +actual class AdditionalUserInfo( + val android: com.google.firebase.auth.AdditionalUserInfo, +) { + actual val providerId: String? + get() = android.providerId + actual val username: String? + get() = android.username + actual val profile: Map? + get() = android.profile + actual val isNewUser: Boolean + get() = android.isNewUser } actual class AuthTokenResult(val android: com.google.firebase.auth.GetTokenResult) { diff --git a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 8f6eb0c01..b0c045a2c 100644 --- a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -41,6 +41,15 @@ expect class FirebaseAuth { expect class AuthResult { val user: FirebaseUser? + val credential: AuthCredential? + val additionalUserInfo: AdditionalUserInfo? +} + +expect class AdditionalUserInfo { + val providerId: String? + val username: String? + val profile: Map? + val isNewUser: Boolean } expect class AuthTokenResult { 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 486deaefa..def7f1a5b 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 @@ -15,7 +15,9 @@ import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.callbackFlow import platform.Foundation.NSError +import platform.Foundation.NSString import platform.Foundation.NSURL +import kotlin.coroutines.suspendCoroutine actual val Firebase.auth @@ -101,9 +103,36 @@ actual class FirebaseAuth internal constructor(val ios: FIRAuth) { actual fun useEmulator(host: String, port: Int) = ios.useEmulatorWithHost(host, port.toLong()) } -actual class AuthResult internal constructor(val ios: FIRAuthDataResult) { +actual class AuthResult( + val ios: FIRAuthDataResult, +) { actual val user: FirebaseUser? get() = FirebaseUser(ios.user) + actual val credential: AuthCredential? + get() = ios.credential?.let { AuthCredential(it) } + actual val additionalUserInfo: AdditionalUserInfo? + get() = ios.additionalUserInfo?.let { AdditionalUserInfo(it) } +} + +actual class AdditionalUserInfo( + val ios: FIRAdditionalUserInfo, +) { + actual val providerId: String? + get() = ios.providerID + actual val username: String? + get() = ios.username + actual val profile: Map? + get() = ios.profile + ?.mapNotNull { (key, value) -> + if (key is NSString && value != null) { + key.toString() to value + } else { + null + } + } + ?.toMap() + actual val isNewUser: Boolean + get() = ios.newUser } actual class AuthTokenResult(val ios: FIRAuthTokenResult) { 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 f2db371b4..b50486df0 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 @@ -14,6 +14,7 @@ import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.callbackFlow import kotlin.js.json import dev.gitlive.firebase.auth.externals.AuthResult as JsAuthResult +import dev.gitlive.firebase.auth.externals.AdditionalUserInfo as JsAdditionalUserInfo actual val Firebase.auth get() = rethrow { FirebaseAuth(getAuth()) } @@ -106,9 +107,28 @@ actual class FirebaseAuth internal constructor(val js: Auth) { actual fun useEmulator(host: String, port: Int) = rethrow { connectAuthEmulator(js, "http://$host:$port") } } -actual class AuthResult internal constructor(val js: JsAuthResult) { +actual class AuthResult( + val js: JsAuthResult, +) { actual val user: FirebaseUser? get() = rethrow { js.user?.let { FirebaseUser(it) } } + actual val credential: AuthCredential? + get() = rethrow { js.credential?.let { AuthCredential(it) } } + actual val additionalUserInfo: AdditionalUserInfo? + get() = js.additionalUserInfo?.let { AdditionalUserInfo(it) } +} + +actual class AdditionalUserInfo( + val js: JsAdditionalUserInfo, +) { + actual val providerId: String? + get() = js.providerId + actual val username: String? + get() = js.username + actual val profile: Map? + get() = js.profile + actual val isNewUser: Boolean + get() = js.newUser } actual class AuthTokenResult(val js: IdTokenResult) { diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt index e3bf651d9..3658511f7 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt @@ -170,6 +170,14 @@ external interface AuthResult { val credential: AuthCredential? val operationType: String? val user: User? + val additionalUserInfo: AdditionalUserInfo? +} + +external interface AdditionalUserInfo { + val providerId: String? + val username: String? + val profile: Map? + val newUser: Boolean } external interface AuthCredential { diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 839a4b2a4..50fdb9c08 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -110,9 +110,26 @@ actual class FirebaseAuth internal constructor(val android: com.google.firebase. actual fun useEmulator(host: String, port: Int) = android.useEmulator(host, port) } -actual class AuthResult internal constructor(val android: com.google.firebase.auth.AuthResult) { +actual class AuthResult( + val android: com.google.firebase.auth.AuthResult, +) { actual val user: FirebaseUser? get() = android.user?.let { FirebaseUser(it) } + actual val credential: AuthCredential? + get() { throw NotImplementedError() } + actual val additionalUserInfo: AdditionalUserInfo? + get() { throw NotImplementedError() } +} + +actual class AdditionalUserInfo { + actual val providerId: String? + get() { throw NotImplementedError() } + actual val username: String? + get() { throw NotImplementedError() } + actual val profile: Map? + get() { throw NotImplementedError() } + actual val isNewUser: Boolean + get() { throw NotImplementedError() } } actual class AuthTokenResult(val android: com.google.firebase.auth.GetTokenResult) { From 31d8466dc8276f21a97634beb620771799484bfe Mon Sep 17 00:00:00 2001 From: David Holas Date: Sun, 30 Jun 2024 19:09:56 +0200 Subject: [PATCH 02/20] Removed unused import --- .../src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 1 - 1 file changed, 1 deletion(-) 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 46540e4e4..45bc6f07f 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 @@ -18,7 +18,6 @@ import kotlinx.coroutines.flow.Flow import platform.Foundation.NSError import platform.Foundation.NSString import platform.Foundation.NSURL -import kotlin.coroutines.suspendCoroutine public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(FIRAuth.auth()) From 37867cff96c7cbb9e3bede4074b173c49587d0ff Mon Sep 17 00:00:00 2001 From: David Holas Date: Sun, 30 Jun 2024 19:23:21 +0200 Subject: [PATCH 03/20] AuthResult test --- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 9dcf36903..25ffb21b4 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -127,6 +127,21 @@ class FirebaseAuthTest { assertEquals("password", credential.providerId) } + @Test + fun testAuthResultStructure() = runTest { + val uid = getTestUid("test@test.com", "test123") + val result = auth.signInWithEmailAndPassword("test@test.com", "test123") + assertNotNull(result.user) + assertEquals(uid, result.user!!.uid) + assertNotNull(result.credential) + assertNotNull(result.credential!!.providerId) + assertNotNull(result.additionalUserInfo) + assertNotNull(result.additionalUserInfo!!.providerId) + assertNotNull(result.additionalUserInfo!!.username) + assertNotNull(result.additionalUserInfo!!.profile) + assertNotNull(result.additionalUserInfo!!.isNewUser) + } + private suspend fun getTestUid(email: String, password: String): String { val uid = auth.let { val user = try { From 93b9ddae20f8b27db260cf2bc48ff3c6ade8648b Mon Sep 17 00:00:00 2001 From: David Holas Date: Mon, 15 Jul 2024 10:01:23 +0200 Subject: [PATCH 04/20] Added messages to asserts in AuthResult test --- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 25ffb21b4..3af7e01d4 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -131,15 +131,15 @@ class FirebaseAuthTest { fun testAuthResultStructure() = runTest { val uid = getTestUid("test@test.com", "test123") val result = auth.signInWithEmailAndPassword("test@test.com", "test123") - assertNotNull(result.user) - assertEquals(uid, result.user!!.uid) - assertNotNull(result.credential) - assertNotNull(result.credential!!.providerId) - assertNotNull(result.additionalUserInfo) - assertNotNull(result.additionalUserInfo!!.providerId) - assertNotNull(result.additionalUserInfo!!.username) - assertNotNull(result.additionalUserInfo!!.profile) - assertNotNull(result.additionalUserInfo!!.isNewUser) + assertNotNull(result.user, "User does not exist.") + assertEquals(uid, result.user!!.uid, "uid does not match.") + assertNotNull(result.credential, "Credential does not exist.") + assertNotNull(result.credential!!.providerId, "Credential providerId does not exist.") + assertNotNull(result.additionalUserInfo, "AdditionalUserInfo does not exist.") + assertNotNull(result.additionalUserInfo!!.providerId, "AdditionalUserInfo providerId does not exist.") + assertNotNull(result.additionalUserInfo!!.username, "AdditionalUserInfo username does not exist.") + assertNotNull(result.additionalUserInfo!!.profile, "AdditionalUserInfo profile does not exist.") + assertNotNull(result.additionalUserInfo!!.isNewUser, "AdditionalUserInfo isNewUser does not exist.") } private suspend fun getTestUid(email: String, password: String): String { From ef5e5d95d1c6c143a88c379edaf9505d5e358b93 Mon Sep 17 00:00:00 2001 From: David Holas Date: Mon, 15 Jul 2024 10:03:48 +0200 Subject: [PATCH 05/20] JVM lint issues fixed --- .../src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt index e0e0dde41..200f7eee0 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -17,10 +17,10 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.tasks.await -public actual val Firebase.auth +public actual val Firebase.auth: FirebaseAuth get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) -public actual fun Firebase.auth(app: FirebaseApp) = +public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.android)) public actual class FirebaseAuth internal constructor(public val android: com.google.firebase.auth.FirebaseAuth) { From be998c3fc33f6589233a2608c5d45a93b4cdaca7 Mon Sep 17 00:00:00 2001 From: David Holas Date: Mon, 15 Jul 2024 11:53:48 +0200 Subject: [PATCH 06/20] JVM lint issues properly fixed --- .../jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 200f7eee0..99c6c73a9 100644 --- a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -129,20 +129,20 @@ public actual class AuthResult( public actual val user: FirebaseUser? get() = android.user?.let { FirebaseUser(it) } public actual val credential: AuthCredential? - get() { throw NotImplementedError() } + get() = throw NotImplementedError() public actual val additionalUserInfo: AdditionalUserInfo? - get() { throw NotImplementedError() } + get() = throw NotImplementedError() } public actual class AdditionalUserInfo { public actual val providerId: String? - get() { throw NotImplementedError() } + get() = throw NotImplementedError() public actual val username: String? - get() { throw NotImplementedError() } + get() = throw NotImplementedError() public actual val profile: Map? - get() { throw NotImplementedError() } + get() = throw NotImplementedError() public actual val isNewUser: Boolean - get() { throw NotImplementedError() } + get() = throw NotImplementedError() } public actual class AuthTokenResult(public val android: com.google.firebase.auth.GetTokenResult) { From f2c2c510861dd63022ed48fca3cc0686b8a202a2 Mon Sep 17 00:00:00 2001 From: David Holas Date: Mon, 15 Jul 2024 12:11:13 +0200 Subject: [PATCH 07/20] Public api updated --- firebase-auth/api/android/firebase-auth.api | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/firebase-auth/api/android/firebase-auth.api b/firebase-auth/api/android/firebase-auth.api index cc211e626..a756fc5bb 100644 --- a/firebase-auth/api/android/firebase-auth.api +++ b/firebase-auth/api/android/firebase-auth.api @@ -73,11 +73,23 @@ public class dev/gitlive/firebase/auth/AuthCredential { public final fun getProviderId ()Ljava/lang/String; } -public final class dev/gitlive/firebase/auth/AuthResult { - public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; - public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; +public final class dev/gitlive/firebase/auth/AdditionalUserInfo { + public fun (Lcom/google/firebase/auth/AdditionalUserInfo;)V + public final fun getAndroid ()Lcom/google/firebase/auth/AdditionalUserInfo; + public final fun getProfile ()Ljava/util/Map; + public final fun getProviderId ()Ljava/lang/String; + public final fun getUsername ()Ljava/lang/String; + public final fun isNewUser ()Z } +public final class dev/gitlive/firebase/auth/AuthResult { + public fun (Lcom/google/firebase/auth/AuthResult;)V + public final fun getAdditionalUserInfo ()Ldev/gitlive/firebase/auth/AdditionalUserInfo; + public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; + public final fun getCredential ()Ldev/gitlive/firebase/auth/AuthCredential; + public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; + } + public final class dev/gitlive/firebase/auth/AuthTokenResult { public fun (Lcom/google/firebase/auth/GetTokenResult;)V public final fun getAndroid ()Lcom/google/firebase/auth/GetTokenResult; From ed24041331992f9a9f03aaf6f870cca5ee5ce793 Mon Sep 17 00:00:00 2001 From: David Holas Date: Mon, 15 Jul 2024 12:31:49 +0200 Subject: [PATCH 08/20] Public api fix --- firebase-auth/api/android/firebase-auth.api | 30 ++++++++++----------- firebase-auth/api/jvm/firebase-auth.api | 11 ++++++++ 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/firebase-auth/api/android/firebase-auth.api b/firebase-auth/api/android/firebase-auth.api index a756fc5bb..1e1e49450 100644 --- a/firebase-auth/api/android/firebase-auth.api +++ b/firebase-auth/api/android/firebase-auth.api @@ -51,6 +51,15 @@ public final class dev/gitlive/firebase/auth/ActionCodeSettings { public fun toString ()Ljava/lang/String; } +public final class dev/gitlive/firebase/auth/AdditionalUserInfo { + public fun (Lcom/google/firebase/auth/AdditionalUserInfo;)V + public final fun getAndroid ()Lcom/google/firebase/auth/AdditionalUserInfo; + public final fun getProfile ()Ljava/util/Map; + public final fun getProviderId ()Ljava/lang/String; + public final fun getUsername ()Ljava/lang/String; + public final fun isNewUser ()Z +} + public final class dev/gitlive/firebase/auth/AndroidPackageName { public fun (Ljava/lang/String;ZLjava/lang/String;)V public synthetic fun (Ljava/lang/String;ZLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -73,22 +82,13 @@ public class dev/gitlive/firebase/auth/AuthCredential { public final fun getProviderId ()Ljava/lang/String; } -public final class dev/gitlive/firebase/auth/AdditionalUserInfo { - public fun (Lcom/google/firebase/auth/AdditionalUserInfo;)V - public final fun getAndroid ()Lcom/google/firebase/auth/AdditionalUserInfo; - public final fun getProfile ()Ljava/util/Map; - public final fun getProviderId ()Ljava/lang/String; - public final fun getUsername ()Ljava/lang/String; - public final fun isNewUser ()Z -} - public final class dev/gitlive/firebase/auth/AuthResult { - public fun (Lcom/google/firebase/auth/AuthResult;)V - public final fun getAdditionalUserInfo ()Ldev/gitlive/firebase/auth/AdditionalUserInfo; - public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; - public final fun getCredential ()Ldev/gitlive/firebase/auth/AuthCredential; - public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; - } + public fun (Lcom/google/firebase/auth/AuthResult;)V + public final fun getAdditionalUserInfo ()Ldev/gitlive/firebase/auth/AdditionalUserInfo; + public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; + public final fun getCredential ()Ldev/gitlive/firebase/auth/AuthCredential; + public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; +} public final class dev/gitlive/firebase/auth/AuthTokenResult { public fun (Lcom/google/firebase/auth/GetTokenResult;)V diff --git a/firebase-auth/api/jvm/firebase-auth.api b/firebase-auth/api/jvm/firebase-auth.api index 3afffeac4..b6a0eda07 100644 --- a/firebase-auth/api/jvm/firebase-auth.api +++ b/firebase-auth/api/jvm/firebase-auth.api @@ -51,6 +51,14 @@ public final class dev/gitlive/firebase/auth/ActionCodeSettings { public fun toString ()Ljava/lang/String; } +public final class dev/gitlive/firebase/auth/AdditionalUserInfo { + public fun ()V + public final fun getProfile ()Ljava/util/Map; + public final fun getProviderId ()Ljava/lang/String; + public final fun getUsername ()Ljava/lang/String; + public final fun isNewUser ()Z +} + public final class dev/gitlive/firebase/auth/AndroidPackageName { public fun (Ljava/lang/String;ZLjava/lang/String;)V public synthetic fun (Ljava/lang/String;ZLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V @@ -74,7 +82,10 @@ public class dev/gitlive/firebase/auth/AuthCredential { } public final class dev/gitlive/firebase/auth/AuthResult { + public fun (Lcom/google/firebase/auth/AuthResult;)V + public final fun getAdditionalUserInfo ()Ldev/gitlive/firebase/auth/AdditionalUserInfo; public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; + public final fun getCredential ()Ldev/gitlive/firebase/auth/AuthCredential; public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; } From 434abaac21d3243052050a04a9b8499e0e76a1b7 Mon Sep 17 00:00:00 2001 From: David Holas Date: Mon, 15 Jul 2024 12:38:20 +0200 Subject: [PATCH 09/20] AuthResult structure test allows null values --- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 3af7e01d4..8b87c13e9 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -133,13 +133,13 @@ class FirebaseAuthTest { val result = auth.signInWithEmailAndPassword("test@test.com", "test123") assertNotNull(result.user, "User does not exist.") assertEquals(uid, result.user!!.uid, "uid does not match.") - assertNotNull(result.credential, "Credential does not exist.") - assertNotNull(result.credential!!.providerId, "Credential providerId does not exist.") - assertNotNull(result.additionalUserInfo, "AdditionalUserInfo does not exist.") - assertNotNull(result.additionalUserInfo!!.providerId, "AdditionalUserInfo providerId does not exist.") - assertNotNull(result.additionalUserInfo!!.username, "AdditionalUserInfo username does not exist.") - assertNotNull(result.additionalUserInfo!!.profile, "AdditionalUserInfo profile does not exist.") - assertNotNull(result.additionalUserInfo!!.isNewUser, "AdditionalUserInfo isNewUser does not exist.") + assertNull(result.credential, "Credential throws.") + assertNull(result.credential!!.providerId, "Credential providerId throws.") + assertNull(result.additionalUserInfo, "AdditionalUserInfo throws.") + assertNull(result.additionalUserInfo!!.providerId, "AdditionalUserInfo providerId throws.") + assertNull(result.additionalUserInfo!!.username, "AdditionalUserInfo username throws.") + assertNull(result.additionalUserInfo!!.profile, "AdditionalUserInfo profile throws.") + assertNull(result.additionalUserInfo!!.isNewUser, "AdditionalUserInfo isNewUser throws.") } private suspend fun getTestUid(email: String, password: String): String { From 84cdf2c7f240ce5b99b9f4438bf3796a0a309b7c Mon Sep 17 00:00:00 2001 From: David Holas Date: Mon, 15 Jul 2024 14:54:49 +0200 Subject: [PATCH 10/20] AuthResult structure test unwrap fixed Tests for null using optional unwrap don't make much sense --- .../src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 8b87c13e9..a2202909f 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -134,12 +134,7 @@ class FirebaseAuthTest { assertNotNull(result.user, "User does not exist.") assertEquals(uid, result.user!!.uid, "uid does not match.") assertNull(result.credential, "Credential throws.") - assertNull(result.credential!!.providerId, "Credential providerId throws.") assertNull(result.additionalUserInfo, "AdditionalUserInfo throws.") - assertNull(result.additionalUserInfo!!.providerId, "AdditionalUserInfo providerId throws.") - assertNull(result.additionalUserInfo!!.username, "AdditionalUserInfo username throws.") - assertNull(result.additionalUserInfo!!.profile, "AdditionalUserInfo profile throws.") - assertNull(result.additionalUserInfo!!.isNewUser, "AdditionalUserInfo isNewUser throws.") } private suspend fun getTestUid(email: String, password: String): String { From a18e3f2b5515070a5914eb4b275b0fa45d755906 Mon Sep 17 00:00:00 2001 From: David Holas Date: Mon, 15 Jul 2024 15:41:08 +0200 Subject: [PATCH 11/20] AuthResult structure additionalUserInfo exists --- .../src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index a2202909f..d197c9bba 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -134,7 +134,11 @@ class FirebaseAuthTest { assertNotNull(result.user, "User does not exist.") assertEquals(uid, result.user!!.uid, "uid does not match.") assertNull(result.credential, "Credential throws.") - assertNull(result.additionalUserInfo, "AdditionalUserInfo throws.") + assertNotNull(result.additionalUserInfo, "AdditionalUserInfo does not exist.") + assertNull(result.additionalUserInfo!!.providerId, "AdditionalUserInfo providerId throws.") + assertNull(result.additionalUserInfo!!.username, "AdditionalUserInfo username throws.") + assertNull(result.additionalUserInfo!!.profile, "AdditionalUserInfo profile throws.") + assertNull(result.additionalUserInfo!!.isNewUser, "AdditionalUserInfo isNewUser throws.") } private suspend fun getTestUid(email: String, password: String): String { From 79a75167bc4b8e2115998edfd75f16c0941e3c56 Mon Sep 17 00:00:00 2001 From: David Holas Date: Mon, 15 Jul 2024 15:53:00 +0200 Subject: [PATCH 12/20] AuthResult structure isNewUser default respected --- .../src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index d197c9bba..56be08491 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -138,7 +138,7 @@ class FirebaseAuthTest { assertNull(result.additionalUserInfo!!.providerId, "AdditionalUserInfo providerId throws.") assertNull(result.additionalUserInfo!!.username, "AdditionalUserInfo username throws.") assertNull(result.additionalUserInfo!!.profile, "AdditionalUserInfo profile throws.") - assertNull(result.additionalUserInfo!!.isNewUser, "AdditionalUserInfo isNewUser throws.") + assertFalse(result.additionalUserInfo!!.isNewUser, "AdditionalUserInfo isNewUser does not exist.") } private suspend fun getTestUid(email: String, password: String): String { From ac4cffaa88f5bae23da4447116dca82017db28aa Mon Sep 17 00:00:00 2001 From: David Holas Date: Wed, 17 Jul 2024 08:11:28 +0200 Subject: [PATCH 13/20] AuthResult structure test made more forgiving Exact values differ on different platforms --- .../commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 56be08491..33e2a9c21 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -135,10 +135,11 @@ class FirebaseAuthTest { assertEquals(uid, result.user!!.uid, "uid does not match.") assertNull(result.credential, "Credential throws.") assertNotNull(result.additionalUserInfo, "AdditionalUserInfo does not exist.") - assertNull(result.additionalUserInfo!!.providerId, "AdditionalUserInfo providerId throws.") - assertNull(result.additionalUserInfo!!.username, "AdditionalUserInfo username throws.") - assertNull(result.additionalUserInfo!!.profile, "AdditionalUserInfo profile throws.") - assertFalse(result.additionalUserInfo!!.isNewUser, "AdditionalUserInfo isNewUser does not exist.") + // Just test if it does not throw + result.additionalUserInfo!!.providerId + result.additionalUserInfo!!.username + result.additionalUserInfo!!.profile + result.additionalUserInfo!!.isNewUser } private suspend fun getTestUid(email: String, password: String): String { From e5af67d296f55f0e11d40a3ac1c90ae60ab31d0c Mon Sep 17 00:00:00 2001 From: David Holas Date: Wed, 28 Aug 2024 14:16:07 +0200 Subject: [PATCH 14/20] AuthResult map parsing fixed in JS --- .../jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 10 ++++++++-- .../kotlin/dev/gitlive/firebase/auth/externals/auth.kt | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) 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 34f5eb20a..61b461adc 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 @@ -118,7 +118,7 @@ public actual class AuthResult( public actual val credential: AuthCredential? get() = rethrow { js.credential?.let { AuthCredential(it) } } public actual val additionalUserInfo: AdditionalUserInfo? - get() = js.additionalUserInfo?.let { AdditionalUserInfo(it) } + get() = rethrow { js.additionalUserInfo?.let { AdditionalUserInfo(it) } } } public actual class AdditionalUserInfo( @@ -129,7 +129,13 @@ public actual class AdditionalUserInfo( public actual val username: String? get() = js.username public actual val profile: Map? - get() = js.profile + get() = rethrow { + val profile = js.profile ?: return@rethrow null + val entries = js("Object.entries") as (dynamic) -> Array> + return@rethrow entries + .invoke(profile) + .associate { entry -> entry[0] as String to entry[1] } + } public actual val isNewUser: Boolean get() = js.newUser } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt index e0136a81e..9b60a95b9 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt @@ -176,7 +176,7 @@ public external interface AuthResult { public external interface AdditionalUserInfo { public val providerId: String? public val username: String? - public val profile: Map? + public val profile: dynamic public val newUser: Boolean } From 9681cf433aff387c35782769ec87aeb5b6653626 Mon Sep 17 00:00:00 2001 From: David Holas Date: Wed, 28 Aug 2024 14:30:08 +0200 Subject: [PATCH 15/20] Used Json? instead od dynamic for better clarity --- .../src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 3 ++- .../jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 61b461adc..07c833c77 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 @@ -13,6 +13,7 @@ import kotlinx.coroutines.await import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow +import kotlin.js.Json import kotlin.js.json import dev.gitlive.firebase.auth.externals.AuthResult as JsAuthResult import dev.gitlive.firebase.auth.externals.AdditionalUserInfo as JsAdditionalUserInfo @@ -131,7 +132,7 @@ public actual class AdditionalUserInfo( public actual val profile: Map? get() = rethrow { val profile = js.profile ?: return@rethrow null - val entries = js("Object.entries") as (dynamic) -> Array> + val entries = js("Object.entries") as (Json) -> Array> return@rethrow entries .invoke(profile) .associate { entry -> entry[0] as String to entry[1] } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt index 9b60a95b9..20c3f14c3 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/externals/auth.kt @@ -176,7 +176,7 @@ public external interface AuthResult { public external interface AdditionalUserInfo { public val providerId: String? public val username: String? - public val profile: dynamic + public val profile: Json? public val newUser: Boolean } From fad36646f05a010d78c3af9370c724d6b94df4f6 Mon Sep 17 00:00:00 2001 From: David Holas Date: Wed, 28 Aug 2024 16:36:02 +0200 Subject: [PATCH 16/20] AuthResult structure JS test fixed --- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 33e2a9c21..67a6cffe5 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -111,6 +111,22 @@ class FirebaseAuthTest { assertEquals(uid, result.user!!.uid) } + @Test + fun testAuthResultStructure() = runTest { + val uid = getTestUid("test@test.com", "test123") + val result = auth.signInWithEmailAndPassword("test@test.com", "test123") + assertNotNull(result.user, "User does not exist.") + assertEquals(uid, result.user!!.uid, "uid does not match.") + assertNull(result.credential, "Credential throws.") + // Just test if it does not throw + result.additionalUserInfo?.let { additionalUserInfo -> + additionalUserInfo.providerId + additionalUserInfo.username + additionalUserInfo.profile + additionalUserInfo.isNewUser + } + } + @Test fun testIsSignInWithEmailLink() { val validLink = "http://localhost:9099/emulator/action?mode=signIn&lang=en&oobCode=_vr0QcFcxcVeLZbrcU-GpTaZiuxlHquqdC8MSy0YM_vzWCTAQgV9Jq&apiKey=fake-api-key&continueUrl=https%3A%2F%2Fexample.com%2Fsignin" @@ -127,21 +143,6 @@ class FirebaseAuthTest { assertEquals("password", credential.providerId) } - @Test - fun testAuthResultStructure() = runTest { - val uid = getTestUid("test@test.com", "test123") - val result = auth.signInWithEmailAndPassword("test@test.com", "test123") - assertNotNull(result.user, "User does not exist.") - assertEquals(uid, result.user!!.uid, "uid does not match.") - assertNull(result.credential, "Credential throws.") - assertNotNull(result.additionalUserInfo, "AdditionalUserInfo does not exist.") - // Just test if it does not throw - result.additionalUserInfo!!.providerId - result.additionalUserInfo!!.username - result.additionalUserInfo!!.profile - result.additionalUserInfo!!.isNewUser - } - private suspend fun getTestUid(email: String, password: String): String { val uid = auth.let { val user = try { From b566e31a6e5a536dbe0e03ae6497b24990ecec0a Mon Sep 17 00:00:00 2001 From: David Holas Date: Thu, 29 Aug 2024 08:10:55 +0200 Subject: [PATCH 17/20] Merge cleanup --- .../src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 1 + 1 file changed, 1 insertion(+) 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 887847807..71cca6ed8 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 @@ -105,6 +105,7 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) public actual fun useEmulator(host: String, port: Int): Unit = ios.useEmulatorWithHost(host, port.toLong()) } + public val AuthResult.ios: FIRAuthDataResult get() = ios public actual class AuthResult(internal val ios: FIRAuthDataResult) { From 1a9a14afced3dd4631e5c166a81652fa8882f934 Mon Sep 17 00:00:00 2001 From: mr-kew Date: Thu, 29 Aug 2024 08:53:43 +0200 Subject: [PATCH 18/20] API dump --- firebase-auth/api/android/firebase-auth.api | 1 - firebase-auth/api/jvm/firebase-auth.api | 1 - 2 files changed, 2 deletions(-) diff --git a/firebase-auth/api/android/firebase-auth.api b/firebase-auth/api/android/firebase-auth.api index ce28ec999..793afeb1f 100644 --- a/firebase-auth/api/android/firebase-auth.api +++ b/firebase-auth/api/android/firebase-auth.api @@ -85,7 +85,6 @@ public class dev/gitlive/firebase/auth/AuthCredential { public final class dev/gitlive/firebase/auth/AuthResult { public fun (Lcom/google/firebase/auth/AuthResult;)V public final fun getAdditionalUserInfo ()Ldev/gitlive/firebase/auth/AdditionalUserInfo; - public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; public final fun getCredential ()Ldev/gitlive/firebase/auth/AuthCredential; public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; } diff --git a/firebase-auth/api/jvm/firebase-auth.api b/firebase-auth/api/jvm/firebase-auth.api index 6b6a51786..f629f1f01 100644 --- a/firebase-auth/api/jvm/firebase-auth.api +++ b/firebase-auth/api/jvm/firebase-auth.api @@ -84,7 +84,6 @@ public class dev/gitlive/firebase/auth/AuthCredential { public final class dev/gitlive/firebase/auth/AuthResult { public fun (Lcom/google/firebase/auth/AuthResult;)V public final fun getAdditionalUserInfo ()Ldev/gitlive/firebase/auth/AdditionalUserInfo; - public final fun getAndroid ()Lcom/google/firebase/auth/AuthResult; public final fun getCredential ()Ldev/gitlive/firebase/auth/AuthCredential; public final fun getUser ()Ldev/gitlive/firebase/auth/FirebaseUser; } From 3eb1a0ce3412685e9bf876fc4db24ccf5199f112 Mon Sep 17 00:00:00 2001 From: mr-kew Date: Thu, 29 Aug 2024 23:40:33 +0200 Subject: [PATCH 19/20] Native properties moved into extensions --- firebase-auth/api/android/firebase-auth.api | 2 +- .../src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 5 ++++- .../src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 4 +++- .../src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/firebase-auth/api/android/firebase-auth.api b/firebase-auth/api/android/firebase-auth.api index 793afeb1f..e6ab3cfef 100644 --- a/firebase-auth/api/android/firebase-auth.api +++ b/firebase-auth/api/android/firebase-auth.api @@ -53,7 +53,6 @@ public final class dev/gitlive/firebase/auth/ActionCodeSettings { public final class dev/gitlive/firebase/auth/AdditionalUserInfo { public fun (Lcom/google/firebase/auth/AdditionalUserInfo;)V - public final fun getAndroid ()Lcom/google/firebase/auth/AdditionalUserInfo; public final fun getProfile ()Ljava/util/Map; public final fun getProviderId ()Ljava/lang/String; public final fun getUsername ()Ljava/lang/String; @@ -290,6 +289,7 @@ public final class dev/gitlive/firebase/auth/UserMetaData { public final class dev/gitlive/firebase/auth/android { public static final fun auth (Ldev/gitlive/firebase/Firebase;Ldev/gitlive/firebase/FirebaseApp;)Ldev/gitlive/firebase/auth/FirebaseAuth; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/AdditionalUserInfo;)Lcom/google/firebase/auth/AdditionalUserInfo; public static final fun getAndroid (Ldev/gitlive/firebase/auth/AuthResult;)Lcom/google/firebase/auth/AuthResult; public static final fun getAndroid (Ldev/gitlive/firebase/auth/AuthTokenResult;)Lcom/google/firebase/auth/GetTokenResult; public static final fun getAndroid (Ldev/gitlive/firebase/auth/FirebaseAuth;)Lcom/google/firebase/auth/FirebaseAuth; diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 045e683c6..cc4f2957d 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -127,8 +127,11 @@ public actual class AuthResult(internal val android: com.google.firebase.auth.Au get() = android.additionalUserInfo?.let { AdditionalUserInfo(it) } } +public val AdditionalUserInfo.android: com.google.firebase.auth.AdditionalUserInfo + get() = android + public actual class AdditionalUserInfo( - public val android: com.google.firebase.auth.AdditionalUserInfo, + internal val android: com.google.firebase.auth.AdditionalUserInfo, ) { public actual val providerId: String? get() = android.providerId 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 71cca6ed8..b7588fe80 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 @@ -117,8 +117,10 @@ public actual class AuthResult(internal val ios: FIRAuthDataResult) { get() = ios.additionalUserInfo?.let { AdditionalUserInfo(it) } } +public val AdditionalUserInfo.ios: FIRAdditionalUserInfo get() = ios + public actual class AdditionalUserInfo( - public val ios: FIRAdditionalUserInfo, + internal val ios: FIRAdditionalUserInfo, ) { public actual val providerId: String? get() = ios.providerID 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 4442d2661..4d0223d28 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 @@ -144,8 +144,10 @@ public actual class AuthResult(internal val js: JsAuthResult) { get() = rethrow { js.additionalUserInfo?.let { AdditionalUserInfo(it) } } } +public val AdditionalUserInfo.js: JsAdditionalUserInfo get() = js + public actual class AdditionalUserInfo( - public val js: JsAdditionalUserInfo, + internal val js: JsAdditionalUserInfo, ) { public actual val providerId: String? get() = js.providerId From 9e8ef049386baf9a73f979de6a6ac43f68930d2b Mon Sep 17 00:00:00 2001 From: Nicholas Bransby-Williams Date: Fri, 30 Aug 2024 08:11:59 +0100 Subject: [PATCH 20/20] Update auth.kt --- .../iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 7d6798822..30ff27bc1 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 @@ -112,9 +112,9 @@ public actual class AuthResult(internal val ios: FIRAuthDataResult) { public actual val user: FirebaseUser? get() = FirebaseUser(ios.user()) public actual val credential: AuthCredential? - get() = ios.credential?.let { AuthCredential(it) } + get() = ios.credential()?.let { AuthCredential(it) } public actual val additionalUserInfo: AdditionalUserInfo? - get() = ios.additionalUserInfo?.let { AdditionalUserInfo(it) } + get() = ios.additionalUserInfo()?.let { AdditionalUserInfo(it) } } public val AdditionalUserInfo.ios: FIRAdditionalUserInfo get() = ios @@ -123,11 +123,11 @@ public actual class AdditionalUserInfo( internal val ios: FIRAdditionalUserInfo, ) { public actual val providerId: String? - get() = ios.providerID + get() = ios.providerID() public actual val username: String? - get() = ios.username + get() = ios.username() public actual val profile: Map? - get() = ios.profile + get() = ios.profile() ?.mapNotNull { (key, value) -> if (key is NSString && value != null) { key.toString() to value @@ -137,7 +137,7 @@ public actual class AdditionalUserInfo( } ?.toMap() public actual val isNewUser: Boolean - get() = ios.newUser + get() = ios.newUser() } public val AuthTokenResult.ios: FIRAuthTokenResult get() = ios