From 6220163eb1397beeeac62dab630ae16fc5abc4b1 Mon Sep 17 00:00:00 2001 From: Andrew Reed Date: Wed, 28 Aug 2024 21:28:30 +0100 Subject: [PATCH 1/7] Added fixes for imports. --- .../kotlin/dev/gitlive/firebase/auth/credentials.kt | 5 ++--- .../firebase/firestore/internal/callbackExecutorMap.kt | 3 +-- .../kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt | 5 +++-- .../kotlin/dev/gitlive/firebase/perf/performance.kt | 3 +-- .../kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt | 6 ++---- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index 8c5b95978..c87f4af3e 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -6,7 +6,6 @@ package dev.gitlive.firebase.auth import android.app.Activity import com.google.firebase.FirebaseException -import com.google.firebase.auth.OAuthProvider import com.google.firebase.auth.PhoneAuthOptions import com.google.firebase.auth.PhoneAuthProvider import kotlinx.coroutines.CompletableDeferred @@ -52,9 +51,9 @@ public actual object GoogleAuthProvider { } } -public val OAuthProvider.android: OAuthProvider get() = android +public val OAuthProvider.android: com.google.firebase.auth.OAuthProvider get() = android -public actual class OAuthProvider(internal val android: OAuthProvider) { +public actual class OAuthProvider(internal val android: com.google.firebase.auth.OAuthProvider) { public actual constructor( provider: String, diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/callbackExecutorMap.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/callbackExecutorMap.kt index a728f542c..386ef0505 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/callbackExecutorMap.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/internal/callbackExecutorMap.kt @@ -1,8 +1,7 @@ package dev.gitlive.firebase.firestore.internal -import com.google.firebase.firestore.FirebaseFirestore import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.Executor // Since on iOS Callback threads are set as settings, we store the settings explicitly here as well -internal val callbackExecutorMap = ConcurrentHashMap() +internal val callbackExecutorMap = ConcurrentHashMap() diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index a4f373fc9..e79ce1fb0 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -1,9 +1,10 @@ package dev.gitlive.firebase.perf.metrics -import com.google.firebase.perf.metrics.Trace import dev.gitlive.firebase.perf.session.PerfSession -public actual class Trace internal constructor(private val android: Trace) { +public val Trace.android: com.google.firebase.perf.metrics.Trace get() = android + +public actual class Trace internal constructor(internal val android: com.google.firebase.perf.metrics.Trace) { public actual fun start() { android.start() diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt index ca6e00675..a4e4d3d47 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -1,6 +1,5 @@ package dev.gitlive.firebase.perf -import com.google.firebase.FirebaseException import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseApp import dev.gitlive.firebase.android as publicAndroid @@ -25,4 +24,4 @@ public actual class FirebasePerformance(internal val android: com.google.firebas } } -public actual open class FirebasePerformanceException(message: String) : FirebaseException(message) +public actual open class FirebasePerformanceException(message: String) : com.google.firebase.FirebaseException(message) diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt index cc3ad8d02..9e3925596 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt @@ -1,7 +1,5 @@ package dev.gitlive.firebase.perf.session -import com.google.firebase.perf.session.PerfSession +public val PerfSession.android: com.google.firebase.perf.session.PerfSession get() = android -public val PerfSession.android: PerfSession get() = android - -public class PerfSession internal constructor(internal val android: PerfSession) +public class PerfSession internal constructor(internal val android: com.google.firebase.perf.session.PerfSession) From 2f56a62966fb35348bc78cbd7186640b5d63c723 Mon Sep 17 00:00:00 2001 From: Andrew Reed Date: Wed, 28 Aug 2024 21:33:09 +0100 Subject: [PATCH 2/7] Adjusted api dump. --- firebase-auth/api/android/firebase-auth.api | 2 +- .../kotlin/dev/gitlive/firebase/auth/credentials.kt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/firebase-auth/api/android/firebase-auth.api b/firebase-auth/api/android/firebase-auth.api index 2b74dac8b..a5ac17791 100644 --- a/firebase-auth/api/android/firebase-auth.api +++ b/firebase-auth/api/android/firebase-auth.api @@ -85,7 +85,7 @@ public final class dev/gitlive/firebase/auth/AuthTokenResult { } public final class dev/gitlive/firebase/auth/CredentialsKt { - public static final fun getAndroid (Lcom/google/firebase/auth/OAuthProvider;)Lcom/google/firebase/auth/OAuthProvider; + public static final fun getAndroid (Ldev/gitlive/firebase/auth/OAuthProvider;)Lcom/google/firebase/auth/OAuthProvider; } public final class dev/gitlive/firebase/auth/EmailAuthProvider { diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index c87f4af3e..d8bf01360 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -61,7 +61,7 @@ public actual class OAuthProvider(internal val android: com.google.firebase.auth customParameters: Map, auth: FirebaseAuth, ) : this( - OAuthProvider + com.google.firebase.auth.OAuthProvider .newBuilder(provider, auth.android) .setScopes(scopes) .addCustomParameters(customParameters) @@ -70,7 +70,7 @@ public actual class OAuthProvider(internal val android: com.google.firebase.auth public actual companion object { public actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential { - val builder = OAuthProvider.newCredentialBuilder(providerId) + val builder = com.google.firebase.auth.OAuthProvider.newCredentialBuilder(providerId) accessToken?.let { builder.setAccessToken(it) } idToken?.let { builder.setIdToken(it) } rawNonce?.let { builder.setIdTokenWithRawNonce(idToken!!, it) } From a033138cf2552ed9f8435a53863e0d10dbf1318c Mon Sep 17 00:00:00 2001 From: Andrew Reed Date: Thu, 29 Aug 2024 08:12:46 +0100 Subject: [PATCH 3/7] Adjusted import to import as --- .../kotlin/dev/gitlive/firebase/auth/credentials.kt | 9 +++++---- firebase-perf/api/android/firebase-perf.api | 6 +++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index d8bf01360..eec1b6d10 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -6,6 +6,7 @@ package dev.gitlive.firebase.auth import android.app.Activity import com.google.firebase.FirebaseException +import com.google.firebase.auth.OAuthProvider as AndroidOAuthProvider import com.google.firebase.auth.PhoneAuthOptions import com.google.firebase.auth.PhoneAuthProvider import kotlinx.coroutines.CompletableDeferred @@ -51,9 +52,9 @@ public actual object GoogleAuthProvider { } } -public val OAuthProvider.android: com.google.firebase.auth.OAuthProvider get() = android +public val OAuthProvider.android: AndroidOAuthProvider get() = android -public actual class OAuthProvider(internal val android: com.google.firebase.auth.OAuthProvider) { +public actual class OAuthProvider(internal val android: AndroidOAuthProvider) { public actual constructor( provider: String, @@ -61,7 +62,7 @@ public actual class OAuthProvider(internal val android: com.google.firebase.auth customParameters: Map, auth: FirebaseAuth, ) : this( - com.google.firebase.auth.OAuthProvider + AndroidOAuthProvider .newBuilder(provider, auth.android) .setScopes(scopes) .addCustomParameters(customParameters) @@ -70,7 +71,7 @@ public actual class OAuthProvider(internal val android: com.google.firebase.auth public actual companion object { public actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential { - val builder = com.google.firebase.auth.OAuthProvider.newCredentialBuilder(providerId) + val builder = AndroidOAuthProvider.newCredentialBuilder(providerId) accessToken?.let { builder.setAccessToken(it) } idToken?.let { builder.setIdToken(it) } rawNonce?.let { builder.setIdTokenWithRawNonce(idToken!!, it) } diff --git a/firebase-perf/api/android/firebase-perf.api b/firebase-perf/api/android/firebase-perf.api index 135ca3ad0..9fe0d96ca 100644 --- a/firebase-perf/api/android/firebase-perf.api +++ b/firebase-perf/api/android/firebase-perf.api @@ -28,10 +28,14 @@ public final class dev/gitlive/firebase/perf/metrics/Trace { public final fun updateSession (Ldev/gitlive/firebase/perf/session/PerfSession;)V } +public final class dev/gitlive/firebase/perf/metrics/TraceKt { + public static final fun getAndroid (Ldev/gitlive/firebase/perf/metrics/Trace;)Lcom/google/firebase/perf/metrics/Trace; +} + public final class dev/gitlive/firebase/perf/session/PerfSession { } public final class dev/gitlive/firebase/perf/session/PerfSessionKt { - public static final fun getAndroid (Lcom/google/firebase/perf/session/PerfSession;)Lcom/google/firebase/perf/session/PerfSession; + public static final fun getAndroid (Ldev/gitlive/firebase/perf/session/PerfSession;)Lcom/google/firebase/perf/session/PerfSession; } From 1ad7fef1a07b3c84e4d813c6cf3fd6c0edb7a466 Mon Sep 17 00:00:00 2001 From: Andrew Reed Date: Thu, 29 Aug 2024 08:18:30 +0100 Subject: [PATCH 4/7] Added import as Platform --- .../kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt | 6 ++++-- .../kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index e79ce1fb0..c905d4975 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -1,10 +1,12 @@ package dev.gitlive.firebase.perf.metrics +import com.google.firebase.perf.metrics.Trace as AndroidTrace import dev.gitlive.firebase.perf.session.PerfSession -public val Trace.android: com.google.firebase.perf.metrics.Trace get() = android -public actual class Trace internal constructor(internal val android: com.google.firebase.perf.metrics.Trace) { +public val Trace.android: AndroidTrace get() = android + +public actual class Trace internal constructor(internal val android: AndroidTrace) { public actual fun start() { android.start() diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt index 9e3925596..a861992a6 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/session/PerfSession.kt @@ -1,5 +1,7 @@ package dev.gitlive.firebase.perf.session -public val PerfSession.android: com.google.firebase.perf.session.PerfSession get() = android +import com.google.firebase.perf.session.PerfSession as AndroidPerfSession -public class PerfSession internal constructor(internal val android: com.google.firebase.perf.session.PerfSession) +public val PerfSession.android: AndroidPerfSession get() = android + +public class PerfSession internal constructor(internal val android: AndroidPerfSession) From 8310e6cbfb878809bd4d542756f7c5d8fc68c79f Mon Sep 17 00:00:00 2001 From: Reedyuk Date: Thu, 29 Aug 2024 07:20:50 +0000 Subject: [PATCH 5/7] Apply automatic changes --- .../kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index c905d4975..dca1211cc 100644 --- a/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/androidMain/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -3,7 +3,6 @@ package dev.gitlive.firebase.perf.metrics import com.google.firebase.perf.metrics.Trace as AndroidTrace import dev.gitlive.firebase.perf.session.PerfSession - public val Trace.android: AndroidTrace get() = android public actual class Trace internal constructor(internal val android: AndroidTrace) { From 8e2d6a0aa62d15b604dfc621a19ed1ef93a84aa7 Mon Sep 17 00:00:00 2001 From: Andrew Reed Date: Thu, 29 Aug 2024 08:43:53 +0000 Subject: [PATCH 6/7] Adjusted readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 71bb394dd..842a36cb7 100644 --- a/README.md +++ b/README.md @@ -329,4 +329,3 @@ More recently, with the official SDK for Android providing better support for Ko For contributors this means following these points when adding new code to the public API of this project: - **Match the [Android SDKs API](https://firebase.google.com/docs/reference/kotlin/packages).** When adding new API coverage use the Android SDK as the guide on what the public API should be in regard to naming, parameters etc. The goal here is *near binary compatibility*, meaning code consuming the Android SDK compiles *as is* with the Kotlin SDK after just changing the package imports from `com.google` to `dev.gitlive`. - **Follow our [Kotlin-first design](https://github.com/GitLiveApp/firebase-kotlin-sdk/?tab=readme-ov-file#kotlin-first-design) principles when needed.** If the API you are adding coverage for is new, and it's Kotlin-first in the Android SDK, then you can simply just match the Android SDKs API as described in the first point, but if it's an older Java-first API then ideally we would include an identical API for API compatibility *plus* a Kotlin-first overload. A good example for this is where the Builder pattern is employed in the Android SDK, here we can follow [this Kotlin-first design principle](https://github.com/GitLiveApp/firebase-kotlin-sdk/?tab=readme-ov-file#default-arguments) and provide both methods, one taking the options created with the builder and an overload with default arguments to avoid the builder boilerplate for developers not porting an existing android code base. - From 0428e263f2a3f571d7d6058845c7de7379fd5a4a Mon Sep 17 00:00:00 2001 From: Siarhei Luskanau Date: Fri, 23 Aug 2024 17:48:03 +0200 Subject: [PATCH 7/7] Updated firebase-cocoapods to "11.1.0" --- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 96 ++++++++++--------- .../dev/gitlive/firebase/auth/credentials.kt | 2 +- .../dev/gitlive/firebase/auth/multifactor.kt | 18 ++-- .../kotlin/dev/gitlive/firebase/auth/user.kt | 38 ++++---- .../gitlive/firebase/firestore/Timestamp.kt | 2 +- gradle/libs.versions.toml | 2 +- 6 files changed, 83 insertions(+), 75 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 b659b0c68..30cbc9cf0 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 @@ -31,7 +31,7 @@ public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth( public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) { public actual val currentUser: FirebaseUser? - get() = ios.currentUser?.let { FirebaseUser(it) } + get() = ios.currentUser()?.let { FirebaseUser(it) } public actual val authStateChanged: Flow get() = callbackFlow { val handle = ios.addAuthStateDidChangeListener { _, user -> trySend(user?.let { FirebaseUser(it) }) } @@ -44,7 +44,7 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) } public actual var languageCode: String - get() = ios.languageCode ?: "" + get() = ios.languageCode() ?: "" set(value) { ios.setLanguageCode(value) } @@ -90,15 +90,15 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) public actual suspend fun checkActionCode(code: String): T { val result: FIRActionCodeInfo = ios.awaitResult { checkActionCode(code, it) } @Suppress("UNCHECKED_CAST") - return when (result.operation) { + return when (result.operation()) { FIRActionCodeOperationEmailLink -> SignInWithEmailLink - FIRActionCodeOperationVerifyEmail -> VerifyEmail(result.email!!) - FIRActionCodeOperationPasswordReset -> PasswordReset(result.email!!) - FIRActionCodeOperationRecoverEmail -> RecoverEmail(result.email!!, result.previousEmail!!) - FIRActionCodeOperationVerifyAndChangeEmail -> VerifyBeforeChangeEmail(result.email!!, result.previousEmail!!) - FIRActionCodeOperationRevertSecondFactorAddition -> RevertSecondFactorAddition(result.email!!, null) - FIRActionCodeOperationUnknown -> throw UnsupportedOperationException(result.operation.toString()) - else -> throw UnsupportedOperationException(result.operation.toString()) + FIRActionCodeOperationVerifyEmail -> VerifyEmail(result.email()) + FIRActionCodeOperationPasswordReset -> PasswordReset(result.email()) + FIRActionCodeOperationRecoverEmail -> RecoverEmail(result.email(), result.previousEmail()!!) + FIRActionCodeOperationVerifyAndChangeEmail -> VerifyBeforeChangeEmail(result.email(), result.previousEmail()!!) + FIRActionCodeOperationRevertSecondFactorAddition -> RevertSecondFactorAddition(result.email(), null) + FIRActionCodeOperationUnknown -> throw UnsupportedOperationException(result.operation().toString()) + else -> throw UnsupportedOperationException(result.operation().toString()) } as T } @@ -108,7 +108,7 @@ public val AuthResult.ios: FIRAuthDataResult get() = ios public actual class AuthResult internal constructor(internal val ios: FIRAuthDataResult) { public actual val user: FirebaseUser? - get() = FirebaseUser(ios.user) + get() = FirebaseUser(ios.user()) } public val AuthTokenResult.ios: FIRAuthTokenResult get() = ios @@ -116,23 +116,23 @@ public actual class AuthTokenResult(internal val ios: FIRAuthTokenResult) { // actual val authTimestamp: Long // get() = ios.authDate public actual val claims: Map - get() = ios.claims.map { it.key.toString() to it.value as Any }.toMap() + get() = ios.claims().map { it.key.toString() to it.value as Any }.toMap() // actual val expirationTimestamp: Long // get() = ios.expirationDate // actual val issuedAtTimestamp: Long // get() = ios.issuedAtDate public actual val signInProvider: String? - get() = ios.signInProvider + get() = ios.signInProvider() public actual val token: String? - get() = ios.token + get() = ios.token() } internal fun ActionCodeSettings.toIos() = FIRActionCodeSettings().also { - it.URL = NSURL.URLWithString(url) + it.setURL(NSURL.URLWithString(url)) androidPackageName?.run { it.setAndroidPackageName(packageName, installIfNotAvailable, minimumVersion) } - it.dynamicLinkDomain = dynamicLinkDomain - it.handleCodeInApp = canHandleCodeInApp + it.setDynamicLinkDomain(dynamicLinkDomain) + it.setHandleCodeInApp(canHandleCodeInApp) iOSBundleId?.run { it.setIOSBundleID(this) } } @@ -184,47 +184,55 @@ internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Uni } private fun NSError.toException() = when (domain) { + // codes from AuthErrors.swift: https://github.com/firebase/firebase-ios-sdk/blob/ + // 2f6ac4c2c61cd57c7ea727009e187b7e1163d613/FirebaseAuth/Sources/Swift/Utilities/ + // AuthErrors.swift#L51 FIRAuthErrorDomain -> when (code) { - FIRAuthErrorCodeInvalidActionCode, - FIRAuthErrorCodeExpiredActionCode, + 17030L, // AuthErrorCode.invalidActionCode + 17029L, // AuthErrorCode.expiredActionCode -> FirebaseAuthActionCodeException(toString()) - FIRAuthErrorCodeInvalidEmail -> FirebaseAuthEmailException(toString()) - - FIRAuthErrorCodeCaptchaCheckFailed, - FIRAuthErrorCodeInvalidPhoneNumber, - FIRAuthErrorCodeMissingPhoneNumber, - FIRAuthErrorCodeInvalidVerificationID, - FIRAuthErrorCodeInvalidVerificationCode, - FIRAuthErrorCodeMissingVerificationID, - FIRAuthErrorCodeMissingVerificationCode, - FIRAuthErrorCodeUserTokenExpired, - FIRAuthErrorCodeInvalidCredential, + 17008L, // AuthErrorCode.invalidEmail + -> FirebaseAuthEmailException(toString()) + + 17056L, // AuthErrorCode.captchaCheckFailed + 17042L, // AuthErrorCode.invalidPhoneNumber + 17041L, // AuthErrorCode.missingPhoneNumber + 17046L, // AuthErrorCode.invalidVerificationID + 17044L, // AuthErrorCode.invalidVerificationCode + 17045L, // AuthErrorCode.missingVerificationID + 17043L, // AuthErrorCode.missingVerificationCode + 17021L, // AuthErrorCode.userTokenExpired + 17004L, // AuthErrorCode.invalidCredential -> FirebaseAuthInvalidCredentialsException(toString()) - FIRAuthErrorCodeWeakPassword -> FirebaseAuthWeakPasswordException(toString()) + 17026L, // AuthErrorCode.weakPassword + -> FirebaseAuthWeakPasswordException(toString()) - FIRAuthErrorCodeInvalidUserToken -> FirebaseAuthInvalidUserException(toString()) + 17017L, // AuthErrorCode.invalidUserToken + -> FirebaseAuthInvalidUserException(toString()) - FIRAuthErrorCodeRequiresRecentLogin -> FirebaseAuthRecentLoginRequiredException(toString()) + 17014L, // AuthErrorCode.requiresRecentLogin + -> FirebaseAuthRecentLoginRequiredException(toString()) - FIRAuthErrorCodeSecondFactorAlreadyEnrolled, - FIRAuthErrorCodeSecondFactorRequired, - FIRAuthErrorCodeMaximumSecondFactorCountExceeded, - FIRAuthErrorCodeMultiFactorInfoNotFound, + 17087L, // AuthErrorCode.secondFactorAlreadyEnrolled + 17078L, // AuthErrorCode.secondFactorRequired + 17088L, // AuthErrorCode.maximumSecondFactorCountExceeded + 17084L, // AuthErrorCode.multiFactorInfoNotFound -> FirebaseAuthMultiFactorException(toString()) - FIRAuthErrorCodeEmailAlreadyInUse, - FIRAuthErrorCodeAccountExistsWithDifferentCredential, - FIRAuthErrorCodeCredentialAlreadyInUse, + 17007L, // AuthErrorCode.emailAlreadyInUse + 17012L, // AuthErrorCode.accountExistsWithDifferentCredential + 17025L, // AuthErrorCode.credentialAlreadyInUse -> FirebaseAuthUserCollisionException(toString()) - FIRAuthErrorCodeWebContextAlreadyPresented, - FIRAuthErrorCodeWebContextCancelled, - FIRAuthErrorCodeWebInternalError, + 17057L, // AuthErrorCode.webContextAlreadyPresented + 17058L, // AuthErrorCode.webContextCancelled + 17062L, // AuthErrorCode.webInternalError -> FirebaseAuthWebException(toString()) - FIRAuthErrorCodeNetworkError -> FirebaseNetworkException(toString()) + 17020L, // AuthErrorCode.networkError + -> FirebaseNetworkException(toString()) else -> FirebaseAuthException(toString()) } diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index 08387a0e1..5a2084bb9 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -8,7 +8,7 @@ import cocoapods.FirebaseAuth.* public actual open class AuthCredential(public open val ios: FIRAuthCredential) { public actual val providerId: String - get() = ios.provider + get() = ios.provider() } public actual class PhoneAuthCredential(override val ios: FIRPhoneAuthCredential) : AuthCredential(ios) diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt index f389b6abb..3d2c814e5 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -10,7 +10,7 @@ public val MultiFactor.ios: FIRMultiFactor get() = ios public actual class MultiFactor(internal val ios: FIRMultiFactor) { public actual val enrolledFactors: List - get() = ios.enrolledFactors.mapNotNull { info -> (info as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } } + get() = ios.enrolledFactors().mapNotNull { info -> (info as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } } public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?): Unit = ios.await { enrollWithAssertion(multiFactorAssertion.ios, displayName, it) } public actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(ios.awaitResult { getSessionWithCompletion(completion = it) }) public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo): Unit = ios.await { unenrollWithInfo(multiFactorInfo.ios, it) } @@ -21,20 +21,20 @@ public val MultiFactorInfo.ios: FIRMultiFactorInfo get() = ios public actual class MultiFactorInfo(internal val ios: FIRMultiFactorInfo) { public actual val displayName: String? - get() = ios.displayName + get() = ios.displayName() public actual val enrollmentTime: Double - get() = ios.enrollmentDate.timeIntervalSinceReferenceDate + get() = ios.enrollmentDate().timeIntervalSinceReferenceDate public actual val factorId: String - get() = ios.factorID + get() = ios.factorID() public actual val uid: String - get() = ios.UID + get() = ios.UID() } public val MultiFactorAssertion.ios: FIRMultiFactorAssertion get() = ios public actual class MultiFactorAssertion(internal val ios: FIRMultiFactorAssertion) { public actual val factorId: String - get() = ios.factorID + get() = ios.factorID() } public val MultiFactorSession.ios: FIRMultiFactorSession get() = ios @@ -44,9 +44,9 @@ public actual class MultiFactorSession(internal val ios: FIRMultiFactorSession) public val MultiFactorResolver.ios: FIRMultiFactorResolver get() = ios public actual class MultiFactorResolver(internal val ios: FIRMultiFactorResolver) { - public actual val auth: FirebaseAuth = FirebaseAuth(ios.auth) - public actual val hints: List = ios.hints.mapNotNull { hint -> (hint as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } } - public actual val session: MultiFactorSession = MultiFactorSession(ios.session) + public actual val auth: FirebaseAuth = FirebaseAuth(ios.auth()) + public actual val hints: List = ios.hints().mapNotNull { hint -> (hint as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } } + public actual val session: MultiFactorSession = MultiFactorSession(ios.session()) public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(ios.awaitResult { resolveSignInWithAssertion(assertion.ios, it) }) } diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt index f2f6c67cc..d37fc20c0 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -14,27 +14,27 @@ public val FirebaseUser.ios: FIRUser get() = ios public actual class FirebaseUser internal constructor(internal val ios: FIRUser) { public actual val uid: String - get() = ios.uid + get() = ios.uid() public actual val displayName: String? - get() = ios.displayName + get() = ios.displayName() public actual val email: String? - get() = ios.email + get() = ios.email() public actual val phoneNumber: String? - get() = ios.phoneNumber + get() = ios.phoneNumber() public actual val photoURL: String? - get() = ios.photoURL?.absoluteString + get() = ios.photoURL()?.absoluteString public actual val isAnonymous: Boolean - get() = ios.anonymous + get() = ios.anonymous() public actual val isEmailVerified: Boolean - get() = ios.emailVerified + get() = ios.emailVerified() public actual val metaData: UserMetaData? - get() = UserMetaData(ios.metadata) + get() = UserMetaData(ios.metadata()) public actual val multiFactor: MultiFactor - get() = MultiFactor(ios.multiFactor) + get() = MultiFactor(ios.multiFactor()) public actual val providerData: List - get() = ios.providerData.mapNotNull { provider -> (provider as? FIRUserInfoProtocol)?.let { UserInfo(it) } } + get() = ios.providerData().mapNotNull { provider -> (provider as? FIRUserInfoProtocol)?.let { UserInfo(it) } } public actual val providerId: String - get() = ios.providerID + get() = ios.providerID() public actual suspend fun delete(): Unit = ios.await { deleteWithCompletion(it) } @@ -85,24 +85,24 @@ public val UserInfo.ios: FIRUserInfoProtocol get() = ios public actual class UserInfo(internal val ios: FIRUserInfoProtocol) { public actual val displayName: String? - get() = ios.displayName + get() = ios.displayName() public actual val email: String? - get() = ios.email + get() = ios.email() public actual val phoneNumber: String? - get() = ios.phoneNumber + get() = ios.phoneNumber() public actual val photoURL: String? - get() = ios.photoURL?.absoluteString + get() = ios.photoURL()?.absoluteString public actual val providerId: String - get() = ios.providerID + get() = ios.providerID() public actual val uid: String - get() = ios.uid + get() = ios.uid() } public val UserMetaData.ios: FIRUserMetadata get() = ios public actual class UserMetaData(internal val ios: FIRUserMetadata) { public actual val creationTime: Double? - get() = ios.creationDate?.timeIntervalSinceReferenceDate + get() = ios.creationDate()?.timeIntervalSinceReferenceDate public actual val lastSignInTime: Double? - get() = ios.lastSignInDate?.timeIntervalSinceReferenceDate + get() = ios.lastSignInDate()?.timeIntervalSinceReferenceDate } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index d0eb95602..8497833e8 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -1,6 +1,6 @@ package dev.gitlive.firebase.firestore -import cocoapods.FirebaseFirestoreInternal.FIRTimestamp +import cocoapods.FirebaseCore.FIRTimestamp import kotlinx.serialization.Serializable /** A class representing a platform specific Firebase Timestamp. */ diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9561276bc..c2a38ad9b 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,7 +16,7 @@ kotlinx-datetime = "0.6.1" kotlinter = "4.4.1" settings-api = "2.0" settings-language = "2.0" -firebase-cocoapods = "10.28.0" +firebase-cocoapods = "11.1.0" ios-deploymentTarget = "13.0" test-logger-plugin = "4.0.0" dokka = "1.9.20"