= com.google.firebase.FirebaseApp.getApps(context as Context)
.map { FirebaseApp(it) }
private fun FirebaseOptions.toAndroid() = com.google.firebase.FirebaseOptions.Builder()
diff --git a/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt
index 9810ef6a8..1ba1b6865 100644
--- a/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt
+++ b/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt
@@ -3,6 +3,7 @@
*/
@file:JvmName("tests")
+
package dev.gitlive.firebase
import org.junit.Ignore
diff --git a/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt
index a02e952c9..fe03f6c3e 100644
--- a/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt
+++ b/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt
@@ -4,6 +4,7 @@
@file:JvmMultifileClass
@file:JvmName("CommonKt")
+
package dev.gitlive.firebase
import kotlin.jvm.JvmMultifileClass
@@ -12,54 +13,115 @@ import kotlin.jvm.JvmName
/**
* Single access point to all firebase sdks from Kotlin.
*
- * Acts as a target for extension methods provided by sdks.
+ * Acts as a target for extension methods provided by sdks.
*/
-object Firebase
+public object Firebase
-expect class FirebaseApp {
- val name: String
- val options: FirebaseOptions
- suspend fun delete()
+/**
+ * The entry point of Firebase SDKs. It holds common configuration and state for Firebase APIs. Most
+ * applications don't need to directly interact with FirebaseApp.
+ *
+ * For a vast majority of apps, FirebaseInitProvider will handle the initialization of
+ * Firebase for the default project that it's configured to work with, via the data contained in the
+ * app's `google-services.json` file. This `ContentProvider`
+ * is merged into the app's manifest by default when building with Gradle,
+ * and it runs automatically at app launch. No additional lines of code are needed in this
+ * case.
+ *
+ * Any `FirebaseApp` initialization must occur only in the main process of the app.
+ * Use of Firebase in processes other than the main process is not supported and will likely cause
+ * problems related to resource contention.
+ */
+public expect class FirebaseApp {
+ /** Returns the unique name of this app. */
+ public val name: String
+
+ /** Returns the specified [FirebaseOptions]. */
+ public val options: FirebaseOptions
+
+ /**
+ * Deletes the [FirebaseApp] and all its data. All calls to this [FirebaseApp]
+ * instance will throw once it has been called.
+ *
+ * A no-op if delete was called before.
+ */
+ public suspend fun delete()
}
/** Returns the default firebase app instance. */
-expect val Firebase.app: FirebaseApp
+public expect val Firebase.app: FirebaseApp
/** Returns a named firebase app instance. */
-expect fun Firebase.app(name: String): FirebaseApp
+public expect fun Firebase.app(name: String): FirebaseApp
/** Returns all firebase app instances. */
-expect fun Firebase.apps(context: Any? = null): List
+public expect fun Firebase.apps(context: Any? = null): List
/** Initializes and returns a FirebaseApp. */
-expect fun Firebase.initialize(context: Any? = null): FirebaseApp?
+public expect fun Firebase.initialize(context: Any? = null): FirebaseApp?
/** Initializes and returns a FirebaseApp. */
-expect fun Firebase.initialize(context: Any? = null, options: FirebaseOptions): FirebaseApp
+public expect fun Firebase.initialize(context: Any? = null, options: FirebaseOptions): FirebaseApp
/** Initializes and returns a FirebaseApp. */
-expect fun Firebase.initialize(context: Any? = null, options: FirebaseOptions, name: String): FirebaseApp
+public expect fun Firebase.initialize(context: Any? = null, options: FirebaseOptions, name: String): FirebaseApp
/** Returns options of default FirebaseApp */
-val Firebase.options: FirebaseOptions
+@Suppress("UnusedReceiverParameter")
+public val Firebase.options: FirebaseOptions
get() = Firebase.app.options
-data class FirebaseOptions(
+/** Configurable Firebase options. */
+public data class FirebaseOptions(
+ /** The Google App ID that is used to uniquely identify an instance of an app. */
val applicationId: String,
+
+ /**
+ * API key used for authenticating requests from your app, e.g.
+ * AIzaSyDdVgKwhZl0sTTTLZ7iTmt1r3N2cJLnaDk, used to identify your app to Google servers.
+ */
val apiKey: String,
+
+ /** The database root URL, e.g. http://abc-xyz-123.firebaseio.com. */
val databaseUrl: String? = null,
+
+ /**
+ * The tracking ID for Google Analytics, e.g. UA-12345678-1, used to configure Google Analytics.
+ */
val gaTrackingId: String? = null,
+
+ /** The Google Cloud Storage bucket name, e.g. abc-xyz-123.storage.firebase.com. */
val storageBucket: String? = null,
+
+ /** The Google Cloud project ID, e.g. my-project-1234 */
val projectId: String? = null,
+
+ /**
+ * The Project Number from the Google Developer's console, for example 012345678901, used to
+ * configure Google Cloud Messaging.
+ */
val gcmSenderId: String? = null,
- val authDomain: String? = null
-)
-expect open class FirebaseException : Exception
+ /** The auth domain. */
+ val authDomain: String? = null,
+)
-expect class FirebaseNetworkException : FirebaseException
+/**
+ * Exception that gets thrown when an operation on Firebase fails.
+ */
+public expect open class FirebaseException : Exception
-expect open class FirebaseTooManyRequestsException : FirebaseException
+/**
+ * Exception that gets thrown when an operation on Firebase fails.
+ */
+public expect class FirebaseNetworkException : FirebaseException
-expect open class FirebaseApiNotAvailableException : FirebaseException
+/**
+ * Exception that gets thrown when an operation on Firebase fails.
+ */
+public expect open class FirebaseTooManyRequestsException : FirebaseException
+/**
+ * Exception that gets thrown when an operation on Firebase fails.
+ */
+public expect open class FirebaseApiNotAvailableException : FirebaseException
diff --git a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt
index 5cf41e354..5b59bbe2e 100644
--- a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt
+++ b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt
@@ -8,8 +8,7 @@ expect annotation class IgnoreForAndroidUnitTest()
@IgnoreForAndroidUnitTest
class FirebaseAppTest {
-
- @IgnoreForAndroidUnitTest
+
@Test
fun testInitialize() = runTest {
Firebase.initialize(
@@ -20,8 +19,8 @@ class FirebaseAppTest {
databaseUrl = "https://fir-kotlin-sdk.firebaseio.com",
storageBucket = "fir-kotlin-sdk.appspot.com",
projectId = "fir-kotlin-sdk",
- gcmSenderId = "846484016111"
- )
+ gcmSenderId = "846484016111",
+ ),
)
assertEquals(1, Firebase.apps(context).size)
@@ -30,5 +29,4 @@ class FirebaseAppTest {
it.delete()
}
}
-
-}
\ No newline at end of file
+}
diff --git a/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt
index a68e315e2..fc20a3b7a 100644
--- a/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt
+++ b/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt
@@ -8,48 +8,50 @@ import cocoapods.FirebaseCore.FIRApp
import cocoapods.FirebaseCore.FIROptions
import kotlinx.coroutines.CompletableDeferred
-actual open class FirebaseException(message: String) : Exception(message)
-actual open class FirebaseNetworkException(message: String) : FirebaseException(message)
-actual open class FirebaseTooManyRequestsException(message: String) : FirebaseException(message)
-actual open class FirebaseApiNotAvailableException(message: String) : FirebaseException(message)
+public actual open class FirebaseException(message: String) : Exception(message)
+public actual open class FirebaseNetworkException(message: String) : FirebaseException(message)
+public actual open class FirebaseTooManyRequestsException(message: String) : FirebaseException(message)
+public actual open class FirebaseApiNotAvailableException(message: String) : FirebaseException(message)
-actual val Firebase.app: FirebaseApp
+public val FirebaseApp.ios: FIRApp get() = ios
+
+public actual val Firebase.app: FirebaseApp
get() = FirebaseApp(FIRApp.defaultApp()!!)
-actual fun Firebase.app(name: String): FirebaseApp =
+public actual fun Firebase.app(name: String): FirebaseApp =
FirebaseApp(FIRApp.appNamed(name)!!)
-actual fun Firebase.initialize(context: Any?): FirebaseApp? =
+public actual fun Firebase.initialize(context: Any?): FirebaseApp? =
FIRApp.configure().let { app }
-actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp =
+public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp =
FIRApp.configureWithName(name, options.toIos()).let { app(name) }
-actual fun Firebase.initialize(context: Any?, options: FirebaseOptions) =
+public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp =
FIRApp.configureWithOptions(options.toIos()).let { app }
-actual data class FirebaseApp internal constructor(val ios: FIRApp) {
+public actual data class FirebaseApp internal constructor(internal val ios: FIRApp) {
actual val name: String
get() = ios.name
actual val options: FirebaseOptions
get() = ios.options.run { FirebaseOptions(bundleID, APIKey!!, databaseURL!!, trackingID, storageBucket, projectID, GCMSenderID) }
- actual suspend fun delete() {
+ public actual suspend fun delete() {
val deleted = CompletableDeferred()
ios.deleteApp { deleted.complete(Unit) }
deleted.await()
}
}
-actual fun Firebase.apps(context: Any?) = FIRApp.allApps()
+public actual fun Firebase.apps(context: Any?): List = FIRApp.allApps()
.orEmpty()
.values
.map { FirebaseApp(it as FIRApp) }
private fun FirebaseOptions.toIos() = FIROptions(this@toIos.applicationId, this@toIos.gcmSenderId ?: "").apply {
- APIKey = this@toIos.apiKey
- databaseURL = this@toIos.databaseUrl
- trackingID = this@toIos.gaTrackingId
- storageBucket = this@toIos.storageBucket
- projectID = this@toIos.projectId
- }
+ APIKey = this@toIos.apiKey
+ databaseURL = this@toIos.databaseUrl
+ trackingID = this@toIos.gaTrackingId
+ storageBucket = this@toIos.storageBucket
+ projectID = this@toIos.projectId
+}
diff --git a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/externals/app.kt b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/externals/app.kt
index ab2066cf9..2563e0311 100644
--- a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/externals/app.kt
+++ b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/externals/app.kt
@@ -5,28 +5,28 @@ package dev.gitlive.firebase.externals
import kotlin.js.Promise
-external fun initializeApp(options: Any, name: String = definedExternally): FirebaseApp
+public external fun initializeApp(options: Any, name: String = definedExternally): FirebaseApp
-external fun getApp(name: String = definedExternally): FirebaseApp
+public external fun getApp(name: String = definedExternally): FirebaseApp
-external fun getApps(): Array
+public external fun getApps(): Array
-external fun deleteApp(app: FirebaseApp): Promise
+public external fun deleteApp(app: FirebaseApp): Promise
-external interface FirebaseApp {
- val automaticDataCollectionEnabled: Boolean
- val name: String
- val options: FirebaseOptions
+public external interface FirebaseApp {
+ public val automaticDataCollectionEnabled: Boolean
+ public val name: String
+ public val options: FirebaseOptions
}
-external interface FirebaseOptions {
- val apiKey: String
- val appId : String
- val authDomain: String?
- val databaseURL: String?
- val measurementId: String?
- val messagingSenderId: String?
- val gaTrackingId: String?
- val projectId: String?
- val storageBucket: String?
+public external interface FirebaseOptions {
+ public val apiKey: String
+ public val appId: String
+ public val authDomain: String?
+ public val databaseURL: String?
+ public val measurementId: String?
+ public val messagingSenderId: String?
+ public val gaTrackingId: String?
+ public val projectId: String?
+ public val storageBucket: String?
}
diff --git a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt
index ed7619ab9..d51f28633 100644
--- a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt
+++ b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt
@@ -11,35 +11,37 @@ import dev.gitlive.firebase.externals.initializeApp
import kotlin.js.json
import dev.gitlive.firebase.externals.FirebaseApp as JsFirebaseApp
-actual val Firebase.app: FirebaseApp
+public actual val Firebase.app: FirebaseApp
get() = FirebaseApp(getApp())
-actual fun Firebase.app(name: String): FirebaseApp =
+public actual fun Firebase.app(name: String): FirebaseApp =
FirebaseApp(getApp(name))
-actual fun Firebase.initialize(context: Any?): FirebaseApp? =
+public actual fun Firebase.initialize(context: Any?): FirebaseApp? =
throw UnsupportedOperationException("Cannot initialize firebase without options in JS")
-actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp =
+public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp =
FirebaseApp(initializeApp(options.toJson(), name))
-actual fun Firebase.initialize(context: Any?, options: FirebaseOptions) =
+public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp =
FirebaseApp(initializeApp(options.toJson()))
-actual class FirebaseApp internal constructor(val js: JsFirebaseApp) {
- actual val name: String
+public val FirebaseApp.js: JsFirebaseApp get() = js
+
+public actual class FirebaseApp internal constructor(internal val js: JsFirebaseApp) {
+ public actual val name: String
get() = js.name
- actual val options: FirebaseOptions
+ public actual val options: FirebaseOptions
get() = js.options.run {
FirebaseOptions(appId, apiKey, databaseURL, gaTrackingId, storageBucket, projectId, messagingSenderId, authDomain)
}
- actual suspend fun delete() {
+ public actual suspend fun delete() {
deleteApp(js)
}
}
-actual fun Firebase.apps(context: Any?) = getApps().map { FirebaseApp(it) }
+public actual fun Firebase.apps(context: Any?): List = getApps().map { FirebaseApp(it) }
private fun FirebaseOptions.toJson() = json(
"apiKey" to apiKey,
@@ -49,10 +51,10 @@ private fun FirebaseOptions.toJson() = json(
"projectId" to (projectId ?: undefined),
"gaTrackingId" to (gaTrackingId ?: undefined),
"messagingSenderId" to (gcmSenderId ?: undefined),
- "authDomain" to (authDomain ?: undefined)
+ "authDomain" to (authDomain ?: undefined),
)
-actual open class FirebaseException(code: String?, cause: Throwable) : Exception("$code: ${cause.message}", cause)
-actual open class FirebaseNetworkException(code: String?, cause: Throwable) : FirebaseException(code, cause)
-actual open class FirebaseTooManyRequestsException(code: String?, cause: Throwable) : FirebaseException(code, cause)
-actual open class FirebaseApiNotAvailableException(code: String?, cause: Throwable) : FirebaseException(code, cause)
+public actual open class FirebaseException(code: String?, cause: Throwable) : Exception("$code: ${cause.message}", cause)
+public actual open class FirebaseNetworkException(code: String?, cause: Throwable) : FirebaseException(code, cause)
+public actual open class FirebaseTooManyRequestsException(code: String?, cause: Throwable) : FirebaseException(code, cause)
+public actual open class FirebaseApiNotAvailableException(code: String?, cause: Throwable) : FirebaseException(code, cause)
diff --git a/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt
index abcab363e..a5dd86da4 100644
--- a/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt
+++ b/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt
@@ -3,12 +3,10 @@
*/
@file:JvmName("tests")
-package dev.gitlive.firebase
-import android.content.Context
-import com.google.firebase.FirebasePlatform
+package dev.gitlive.firebase
-actual val context: Any get() = Context().also { FirebasePlatform.initializeFirebasePlatform(MockFirebasePlatform()) }
+actual val context: Any = testContext
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
actual annotation class IgnoreForAndroidUnitTest
diff --git a/firebase-auth/api/android/firebase-auth.api b/firebase-auth/api/android/firebase-auth.api
new file mode 100644
index 000000000..a5ac17791
--- /dev/null
+++ b/firebase-auth/api/android/firebase-auth.api
@@ -0,0 +1,286 @@
+public abstract class dev/gitlive/firebase/auth/ActionCodeResult {
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$PasswordReset : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$RecoverEmail : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getPreviousEmail ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$RevertSecondFactorAddition : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getMultiFactorInfo ()Ldev/gitlive/firebase/auth/MultiFactorInfo;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$SignInWithEmailLink : dev/gitlive/firebase/auth/ActionCodeResult {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/ActionCodeResult$SignInWithEmailLink;
+ public fun equals (Ljava/lang/Object;)Z
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$VerifyBeforeChangeEmail : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getPreviousEmail ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$VerifyEmail : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeSettings {
+ public fun (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;)V
+ public synthetic fun (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public final fun component1 ()Ljava/lang/String;
+ public final fun component2 ()Ldev/gitlive/firebase/auth/AndroidPackageName;
+ public final fun component3 ()Ljava/lang/String;
+ public final fun component4 ()Z
+ public final fun component5 ()Ljava/lang/String;
+ public final fun copy (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;)Ldev/gitlive/firebase/auth/ActionCodeSettings;
+ public static synthetic fun copy$default (Ldev/gitlive/firebase/auth/ActionCodeSettings;Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/ActionCodeSettings;
+ public fun equals (Ljava/lang/Object;)Z
+ public final fun getAndroidPackageName ()Ldev/gitlive/firebase/auth/AndroidPackageName;
+ public final fun getCanHandleCodeInApp ()Z
+ public final fun getDynamicLinkDomain ()Ljava/lang/String;
+ public final fun getIOSBundleId ()Ljava/lang/String;
+ public final fun getUrl ()Ljava/lang/String;
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+}
+
+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
+ public final fun component1 ()Ljava/lang/String;
+ public final fun component2 ()Z
+ public final fun component3 ()Ljava/lang/String;
+ public final fun copy (Ljava/lang/String;ZLjava/lang/String;)Ldev/gitlive/firebase/auth/AndroidPackageName;
+ public static synthetic fun copy$default (Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/AndroidPackageName;
+ public fun equals (Ljava/lang/Object;)Z
+ public final fun getInstallIfNotAvailable ()Z
+ public final fun getMinimumVersion ()Ljava/lang/String;
+ public final fun getPackageName ()Ljava/lang/String;
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+}
+
+public class dev/gitlive/firebase/auth/AuthCredential {
+ public fun (Lcom/google/firebase/auth/AuthCredential;)V
+ public fun getAndroid ()Lcom/google/firebase/auth/AuthCredential;
+ public final fun getProviderId ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/AuthResult {
+ 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 getClaims ()Ljava/util/Map;
+ public final fun getSignInProvider ()Ljava/lang/String;
+ public final fun getToken ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/CredentialsKt {
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/OAuthProvider;)Lcom/google/firebase/auth/OAuthProvider;
+}
+
+public final class dev/gitlive/firebase/auth/EmailAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/EmailAuthProvider;
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+ public final fun credentialWithLink (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/FacebookAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/FacebookAuthProvider;
+ public final fun credential (Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/FirebaseAuth {
+ public final fun applyActionCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun checkActionCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun confirmPasswordReset (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun createUserWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun fetchSignInMethodsForEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getAuthStateChanged ()Lkotlinx/coroutines/flow/Flow;
+ public final fun getCurrentUser ()Ldev/gitlive/firebase/auth/FirebaseUser;
+ public final fun getIdTokenChanged ()Lkotlinx/coroutines/flow/Flow;
+ public final fun getLanguageCode ()Ljava/lang/String;
+ public final fun isSignInWithEmailLink (Ljava/lang/String;)Z
+ public final fun sendPasswordResetEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public static synthetic fun sendPasswordResetEmail$default (Ldev/gitlive/firebase/auth/FirebaseAuth;Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
+ public final fun sendSignInLinkToEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun setLanguageCode (Ljava/lang/String;)V
+ public final fun signInAnonymously (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signInWithCredential (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signInWithCustomToken (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signInWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signInWithEmailLink (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signOut (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateCurrentUser (Ldev/gitlive/firebase/auth/FirebaseUser;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun useEmulator (Ljava/lang/String;I)V
+ public final fun verifyPasswordResetCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/FirebaseUser {
+ public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getDisplayName ()Ljava/lang/String;
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getIdToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getIdTokenResult (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getMetaData ()Ldev/gitlive/firebase/auth/UserMetaData;
+ public final fun getMultiFactor ()Ldev/gitlive/firebase/auth/MultiFactor;
+ public final fun getPhoneNumber ()Ljava/lang/String;
+ public final fun getPhotoURL ()Ljava/lang/String;
+ public final fun getProviderData ()Ljava/util/List;
+ public final fun getProviderId ()Ljava/lang/String;
+ public final fun getUid ()Ljava/lang/String;
+ public final fun isAnonymous ()Z
+ public final fun isEmailVerified ()Z
+ public final fun linkWithCredential (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun reauthenticate (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun reauthenticateAndRetrieveData (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun reload (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun sendEmailVerification (Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public static synthetic fun sendEmailVerification$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
+ public final fun unlink (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updatePassword (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updatePhoneNumber (Ldev/gitlive/firebase/auth/PhoneAuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateProfile (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public static synthetic fun updateProfile$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
+ public final fun verifyBeforeUpdateEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public static synthetic fun verifyBeforeUpdateEmail$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/GithubAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/GithubAuthProvider;
+ public final fun credential (Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/GoogleAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/GoogleAuthProvider;
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactor {
+ public fun (Lcom/google/firebase/auth/MultiFactor;)V
+ public final fun enroll (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getEnrolledFactors ()Ljava/util/List;
+ public final fun getSession (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun unenroll (Ldev/gitlive/firebase/auth/MultiFactorInfo;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun unenroll (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactorAssertion {
+ public fun (Lcom/google/firebase/auth/MultiFactorAssertion;)V
+ public final fun getFactorId ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactorInfo {
+ public fun (Lcom/google/firebase/auth/MultiFactorInfo;)V
+ public final fun getDisplayName ()Ljava/lang/String;
+ public final fun getEnrollmentTime ()D
+ public final fun getFactorId ()Ljava/lang/String;
+ public final fun getUid ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactorResolver {
+ public fun (Lcom/google/firebase/auth/MultiFactorResolver;)V
+ public final fun getAuth ()Ldev/gitlive/firebase/auth/FirebaseAuth;
+ public final fun getHints ()Ljava/util/List;
+ public final fun getSession ()Ldev/gitlive/firebase/auth/MultiFactorSession;
+ public final fun resolveSignIn (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactorSession {
+ public fun (Lcom/google/firebase/auth/MultiFactorSession;)V
+}
+
+public final class dev/gitlive/firebase/auth/MultifactorKt {
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactor;)Lcom/google/firebase/auth/MultiFactor;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorAssertion;)Lcom/google/firebase/auth/MultiFactorAssertion;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorInfo;)Lcom/google/firebase/auth/MultiFactorInfo;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorResolver;)Lcom/google/firebase/auth/MultiFactorResolver;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorSession;)Lcom/google/firebase/auth/MultiFactorSession;
+}
+
+public final class dev/gitlive/firebase/auth/OAuthCredential : dev/gitlive/firebase/auth/AuthCredential {
+ public fun (Lcom/google/firebase/auth/OAuthCredential;)V
+ public synthetic fun getAndroid ()Lcom/google/firebase/auth/AuthCredential;
+ public fun getAndroid ()Lcom/google/firebase/auth/OAuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/OAuthProvider {
+ public static final field Companion Ldev/gitlive/firebase/auth/OAuthProvider$Companion;
+ public fun (Lcom/google/firebase/auth/OAuthProvider;)V
+ public fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;)V
+ public synthetic fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+}
+
+public final class dev/gitlive/firebase/auth/OAuthProvider$Companion {
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/OAuthCredential;
+ public static synthetic fun credential$default (Ldev/gitlive/firebase/auth/OAuthProvider$Companion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/OAuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/PhoneAuthCredential : dev/gitlive/firebase/auth/AuthCredential {
+ public fun (Lcom/google/firebase/auth/PhoneAuthCredential;)V
+ public synthetic fun getAndroid ()Lcom/google/firebase/auth/AuthCredential;
+ public fun getAndroid ()Lcom/google/firebase/auth/PhoneAuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/PhoneAuthProvider {
+ public fun (Ldev/gitlive/firebase/auth/FirebaseAuth;)V
+ public synthetic fun (Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public fun (Lkotlin/jvm/functions/Function0;)V
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/PhoneAuthCredential;
+ public final fun getCreateOptionsBuilder ()Lkotlin/jvm/functions/Function0;
+ public final fun verifyPhoneNumber (Ljava/lang/String;Ldev/gitlive/firebase/auth/PhoneVerificationProvider;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public abstract interface class dev/gitlive/firebase/auth/PhoneVerificationProvider {
+ public abstract fun codeSent (Lkotlin/jvm/functions/Function1;)V
+ public abstract fun getActivity ()Landroid/app/Activity;
+ public abstract fun getTimeout ()J
+ public abstract fun getUnit ()Ljava/util/concurrent/TimeUnit;
+ public abstract fun getVerificationCode (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/TwitterAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/TwitterAuthProvider;
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/UserInfo {
+ public fun (Lcom/google/firebase/auth/UserInfo;)V
+ public final fun getDisplayName ()Ljava/lang/String;
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getPhoneNumber ()Ljava/lang/String;
+ public final fun getPhotoURL ()Ljava/lang/String;
+ public final fun getProviderId ()Ljava/lang/String;
+ public final fun getUid ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/UserKt {
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/FirebaseUser;)Lcom/google/firebase/auth/FirebaseUser;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/UserInfo;)Lcom/google/firebase/auth/UserInfo;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/UserMetaData;)Lcom/google/firebase/auth/FirebaseUserMetadata;
+}
+
+public final class dev/gitlive/firebase/auth/UserMetaData {
+ public fun (Lcom/google/firebase/auth/FirebaseUserMetadata;)V
+ public final fun getCreationTime ()Ljava/lang/Double;
+ public final fun getLastSignInTime ()Ljava/lang/Double;
+}
+
+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/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;
+ public static final fun getAuth (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/auth/FirebaseAuth;
+}
+
diff --git a/firebase-auth/api/jvm/firebase-auth.api b/firebase-auth/api/jvm/firebase-auth.api
new file mode 100644
index 000000000..170ac9afa
--- /dev/null
+++ b/firebase-auth/api/jvm/firebase-auth.api
@@ -0,0 +1,285 @@
+public abstract class dev/gitlive/firebase/auth/ActionCodeResult {
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$PasswordReset : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$RecoverEmail : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getPreviousEmail ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$RevertSecondFactorAddition : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getMultiFactorInfo ()Ldev/gitlive/firebase/auth/MultiFactorInfo;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$SignInWithEmailLink : dev/gitlive/firebase/auth/ActionCodeResult {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/ActionCodeResult$SignInWithEmailLink;
+ public fun equals (Ljava/lang/Object;)Z
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$VerifyBeforeChangeEmail : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getPreviousEmail ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeResult$VerifyEmail : dev/gitlive/firebase/auth/ActionCodeResult {
+ public final fun getEmail ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/ActionCodeSettings {
+ public fun (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;)V
+ public synthetic fun (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public final fun component1 ()Ljava/lang/String;
+ public final fun component2 ()Ldev/gitlive/firebase/auth/AndroidPackageName;
+ public final fun component3 ()Ljava/lang/String;
+ public final fun component4 ()Z
+ public final fun component5 ()Ljava/lang/String;
+ public final fun copy (Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;)Ldev/gitlive/firebase/auth/ActionCodeSettings;
+ public static synthetic fun copy$default (Ldev/gitlive/firebase/auth/ActionCodeSettings;Ljava/lang/String;Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/ActionCodeSettings;
+ public fun equals (Ljava/lang/Object;)Z
+ public final fun getAndroidPackageName ()Ldev/gitlive/firebase/auth/AndroidPackageName;
+ public final fun getCanHandleCodeInApp ()Z
+ public final fun getDynamicLinkDomain ()Ljava/lang/String;
+ public final fun getIOSBundleId ()Ljava/lang/String;
+ public final fun getUrl ()Ljava/lang/String;
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+}
+
+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
+ public final fun component1 ()Ljava/lang/String;
+ public final fun component2 ()Z
+ public final fun component3 ()Ljava/lang/String;
+ public final fun copy (Ljava/lang/String;ZLjava/lang/String;)Ldev/gitlive/firebase/auth/AndroidPackageName;
+ public static synthetic fun copy$default (Ldev/gitlive/firebase/auth/AndroidPackageName;Ljava/lang/String;ZLjava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/AndroidPackageName;
+ public fun equals (Ljava/lang/Object;)Z
+ public final fun getInstallIfNotAvailable ()Z
+ public final fun getMinimumVersion ()Ljava/lang/String;
+ public final fun getPackageName ()Ljava/lang/String;
+ public fun hashCode ()I
+ public fun toString ()Ljava/lang/String;
+}
+
+public class dev/gitlive/firebase/auth/AuthCredential {
+ public fun (Lcom/google/firebase/auth/AuthCredential;)V
+ public fun getAndroid ()Lcom/google/firebase/auth/AuthCredential;
+ public final fun getProviderId ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/AuthResult {
+ 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 getClaims ()Ljava/util/Map;
+ public final fun getSignInProvider ()Ljava/lang/String;
+ public final fun getToken ()Ljava/lang/String;
+}
+
+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 (Lcom/google/firebase/auth/PhoneAuthProvider;)Lcom/google/firebase/auth/PhoneAuthProvider;
+}
+
+public final class dev/gitlive/firebase/auth/EmailAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/EmailAuthProvider;
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+ public final fun credentialWithLink (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/FacebookAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/FacebookAuthProvider;
+ public final fun credential (Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/FirebaseAuth {
+ public final fun applyActionCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun checkActionCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun confirmPasswordReset (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun createUserWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun fetchSignInMethodsForEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getAuthStateChanged ()Lkotlinx/coroutines/flow/Flow;
+ public final fun getCurrentUser ()Ldev/gitlive/firebase/auth/FirebaseUser;
+ public final fun getIdTokenChanged ()Lkotlinx/coroutines/flow/Flow;
+ public final fun getLanguageCode ()Ljava/lang/String;
+ public final fun isSignInWithEmailLink (Ljava/lang/String;)Z
+ public final fun sendPasswordResetEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public static synthetic fun sendPasswordResetEmail$default (Ldev/gitlive/firebase/auth/FirebaseAuth;Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
+ public final fun sendSignInLinkToEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun setLanguageCode (Ljava/lang/String;)V
+ public final fun signInAnonymously (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signInWithCredential (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signInWithCustomToken (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signInWithEmailAndPassword (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signInWithEmailLink (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun signOut (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateCurrentUser (Ldev/gitlive/firebase/auth/FirebaseUser;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun useEmulator (Ljava/lang/String;I)V
+ public final fun verifyPasswordResetCode (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/FirebaseUser {
+ public final fun delete (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getDisplayName ()Ljava/lang/String;
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getIdToken (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getIdTokenResult (ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getMetaData ()Ldev/gitlive/firebase/auth/UserMetaData;
+ public final fun getMultiFactor ()Ldev/gitlive/firebase/auth/MultiFactor;
+ public final fun getPhoneNumber ()Ljava/lang/String;
+ public final fun getPhotoURL ()Ljava/lang/String;
+ public final fun getProviderData ()Ljava/util/List;
+ public final fun getProviderId ()Ljava/lang/String;
+ public final fun getUid ()Ljava/lang/String;
+ public final fun isAnonymous ()Z
+ public final fun isEmailVerified ()Z
+ public final fun linkWithCredential (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun reauthenticate (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun reauthenticateAndRetrieveData (Ldev/gitlive/firebase/auth/AuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun reload (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun sendEmailVerification (Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public static synthetic fun sendEmailVerification$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
+ public final fun unlink (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateEmail (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updatePassword (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updatePhoneNumber (Ldev/gitlive/firebase/auth/PhoneAuthCredential;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun updateProfile (Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public static synthetic fun updateProfile$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
+ public final fun verifyBeforeUpdateEmail (Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public static synthetic fun verifyBeforeUpdateEmail$default (Ldev/gitlive/firebase/auth/FirebaseUser;Ljava/lang/String;Ldev/gitlive/firebase/auth/ActionCodeSettings;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/GithubAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/GithubAuthProvider;
+ public final fun credential (Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/GoogleAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/GoogleAuthProvider;
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactor {
+ public fun (Lcom/google/firebase/auth/MultiFactor;)V
+ public final fun enroll (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun getEnrolledFactors ()Ljava/util/List;
+ public final fun getSession (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun unenroll (Ldev/gitlive/firebase/auth/MultiFactorInfo;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+ public final fun unenroll (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactorAssertion {
+ public fun (Lcom/google/firebase/auth/MultiFactorAssertion;)V
+ public final fun getFactorId ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactorInfo {
+ public fun (Lcom/google/firebase/auth/MultiFactorInfo;)V
+ public final fun getDisplayName ()Ljava/lang/String;
+ public final fun getEnrollmentTime ()D
+ public final fun getFactorId ()Ljava/lang/String;
+ public final fun getUid ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactorResolver {
+ public fun (Lcom/google/firebase/auth/MultiFactorResolver;)V
+ public final fun getAuth ()Ldev/gitlive/firebase/auth/FirebaseAuth;
+ public final fun getHints ()Ljava/util/List;
+ public final fun getSession ()Ldev/gitlive/firebase/auth/MultiFactorSession;
+ public final fun resolveSignIn (Ldev/gitlive/firebase/auth/MultiFactorAssertion;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/MultiFactorSession {
+ public fun (Lcom/google/firebase/auth/MultiFactorSession;)V
+}
+
+public final class dev/gitlive/firebase/auth/MultifactorKt {
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactor;)Lcom/google/firebase/auth/MultiFactor;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorAssertion;)Lcom/google/firebase/auth/MultiFactorAssertion;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorInfo;)Lcom/google/firebase/auth/MultiFactorInfo;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorResolver;)Lcom/google/firebase/auth/MultiFactorResolver;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/MultiFactorSession;)Lcom/google/firebase/auth/MultiFactorSession;
+}
+
+public final class dev/gitlive/firebase/auth/OAuthCredential : dev/gitlive/firebase/auth/AuthCredential {
+ public fun (Lcom/google/firebase/auth/OAuthCredential;)V
+ public synthetic fun getAndroid ()Lcom/google/firebase/auth/AuthCredential;
+ public fun getAndroid ()Lcom/google/firebase/auth/OAuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/OAuthProvider {
+ public static final field Companion Ldev/gitlive/firebase/auth/OAuthProvider$Companion;
+ public fun (Lcom/google/firebase/auth/OAuthProvider;)V
+ public fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;)V
+ public synthetic fun (Ljava/lang/String;Ljava/util/List;Ljava/util/Map;Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+}
+
+public final class dev/gitlive/firebase/auth/OAuthProvider$Companion {
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/OAuthCredential;
+ public static synthetic fun credential$default (Ldev/gitlive/firebase/auth/OAuthProvider$Companion;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/gitlive/firebase/auth/OAuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/PhoneAuthCredential : dev/gitlive/firebase/auth/AuthCredential {
+ public fun (Lcom/google/firebase/auth/PhoneAuthCredential;)V
+ public synthetic fun getAndroid ()Lcom/google/firebase/auth/AuthCredential;
+ public fun getAndroid ()Lcom/google/firebase/auth/PhoneAuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/PhoneAuthProvider {
+ public fun (Lcom/google/firebase/auth/PhoneAuthProvider;)V
+ public fun (Ldev/gitlive/firebase/auth/FirebaseAuth;)V
+ public synthetic fun (Ldev/gitlive/firebase/auth/FirebaseAuth;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/PhoneAuthCredential;
+ public final fun verifyPhoneNumber (Ljava/lang/String;Ldev/gitlive/firebase/auth/PhoneVerificationProvider;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public abstract interface class dev/gitlive/firebase/auth/PhoneVerificationProvider {
+ public abstract fun codeSent (Lkotlin/jvm/functions/Function1;)V
+ public abstract fun getActivity ()Landroid/app/Activity;
+ public abstract fun getTimeout ()J
+ public abstract fun getUnit ()Ljava/util/concurrent/TimeUnit;
+ public abstract fun getVerificationCode (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
+}
+
+public final class dev/gitlive/firebase/auth/TwitterAuthProvider {
+ public static final field INSTANCE Ldev/gitlive/firebase/auth/TwitterAuthProvider;
+ public final fun credential (Ljava/lang/String;Ljava/lang/String;)Ldev/gitlive/firebase/auth/AuthCredential;
+}
+
+public final class dev/gitlive/firebase/auth/UserInfo {
+ public fun (Lcom/google/firebase/auth/UserInfo;)V
+ public final fun getDisplayName ()Ljava/lang/String;
+ public final fun getEmail ()Ljava/lang/String;
+ public final fun getPhoneNumber ()Ljava/lang/String;
+ public final fun getPhotoURL ()Ljava/lang/String;
+ public final fun getProviderId ()Ljava/lang/String;
+ public final fun getUid ()Ljava/lang/String;
+}
+
+public final class dev/gitlive/firebase/auth/UserKt {
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/FirebaseUser;)Lcom/google/firebase/auth/FirebaseUser;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/UserInfo;)Lcom/google/firebase/auth/UserInfo;
+ public static final fun getAndroid (Ldev/gitlive/firebase/auth/UserMetaData;)Lcom/google/firebase/auth/FirebaseUserMetadata;
+}
+
+public final class dev/gitlive/firebase/auth/UserMetaData {
+ public fun (Lcom/google/firebase/auth/FirebaseUserMetadata;)V
+ public final fun getCreationTime ()Ljava/lang/Double;
+ public final fun getLastSignInTime ()Ljava/lang/Double;
+}
+
+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/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 getAuth (Ldev/gitlive/firebase/Firebase;)Ldev/gitlive/firebase/auth/FirebaseAuth;
+}
+
diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts
index 03cb349a3..e1447399b 100644
--- a/firebase-auth/build.gradle.kts
+++ b/firebase-auth/build.gradle.kts
@@ -1,4 +1,9 @@
+import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
+import org.jetbrains.kotlin.gradle.dsl.JvmTarget
+import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree
+import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTargetWithSimulatorTests
+import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest
/*
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
@@ -10,31 +15,26 @@ plugins {
id("com.android.library")
kotlin("multiplatform")
kotlin("native.cocoapods")
- //id("com.quittle.android-emulator") version "0.2.0"
+ id("testOptionsConvention")
}
android {
- val minSdkVersion: Int by project
val compileSdkVersion: Int by project
compileSdk = compileSdkVersion
namespace = "dev.gitlive.firebase.auth"
defaultConfig {
- minSdk = minSdkVersion
+ minSdk = 23 // Auth has a MinSDK of 23. See https://github.com/firebase/firebase-android-sdk/issues/5927#issuecomment-2093466572
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
- sourceCompatibility = JavaVersion.VERSION_11
- targetCompatibility = JavaVersion.VERSION_11
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
- testOptions {
- unitTests.apply {
- isIncludeAndroidResources = true
- }
- }
+ testOptions.configureTestOptions(project)
packaging {
resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module")
resources.pickFirsts.add("META-INF/AL2.0")
@@ -45,26 +45,25 @@ android {
}
}
-// Optional configuration
-//androidEmulator {
-// emulator {
-// name("givlive_emulator")
-// sdkVersion(28)
-// abi("x86_64")
-// includeGoogleApis(true) // Defaults to false
-//
-// }
-// headless(false)
-// logEmulatorOutput(false)
-//}
-
val supportIosTarget = project.property("skipIosTarget") != "true"
kotlin {
+ explicitApi()
+ @OptIn(ExperimentalKotlinGradlePluginApi::class)
+ compilerOptions {
+ freeCompilerArgs.add("-Xexpect-actual-classes")
+ }
targets.configureEach {
compilations.configureEach {
- kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes"
+ compileTaskProvider.configure {
+ compilerOptions {
+ if (this is KotlinJvmCompilerOptions) {
+ jvmTarget = JvmTarget.JVM_17
+ }
+ freeCompilerArgs.add("-Xexpect-actual-classes")
+ }
+ }
}
}
@@ -73,25 +72,23 @@ kotlin {
instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test)
unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test)
publishAllLibraryVariants()
- compilations.configureEach {
- kotlinOptions {
- jvmTarget = "11"
- }
- }
}
+ jvm()
+
if (supportIosTarget) {
iosArm64()
- iosX64()
- iosSimulatorArm64()
+ iosX64().enableKeychainForTests()
+ iosSimulatorArm64().enableKeychainForTests()
cocoapods {
- ios.deploymentTarget = "12.0"
+ ios.deploymentTarget = libs.versions.ios.deploymentTarget.get()
framework {
baseName = "FirebaseAuth"
}
noPodspec()
pod("FirebaseAuth") {
- version = "10.25.0"
+ version = libs.versions.firebase.cocoapods.get()
+ extraOpts += listOf("-compiler-option", "-fmodules")
}
}
}
@@ -99,29 +96,17 @@ kotlin {
js(IR) {
useCommonJs()
nodejs {
- testTask(
- Action {
- useKarma {
- useChromeHeadless()
- }
+ testTask {
+ useKarma {
+ useChromeHeadless()
}
- )
+ }
}
browser {
- testTask(
- Action {
- useKarma {
- useChromeHeadless()
- }
+ testTask {
+ useKarma {
+ useChromeHeadless()
}
- )
- }
- }
-
- jvm {
- compilations.getByName("main") {
- kotlinOptions {
- jvmTarget = "17"
}
}
}
@@ -129,10 +114,8 @@ kotlin {
sourceSets {
all {
languageSettings.apply {
- val apiVersion: String by project
- val languageVersion: String by project
- this.apiVersion = apiVersion
- this.languageVersion = languageVersion
+ this.apiVersion = libs.versions.settings.api.get()
+ this.languageVersion = libs.versions.settings.language.get()
progressiveMode = true
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
if (name.lowercase().contains("ios")) {
@@ -157,7 +140,7 @@ kotlin {
getByName("androidMain") {
dependencies {
- api("com.google.firebase:firebase-auth-ktx")
+ api(libs.google.firebase.auth.ktx)
}
}
}
@@ -169,12 +152,41 @@ if (project.property("firebase-auth.skipIosTests") == "true") {
}
}
+if (project.property("firebase-auth.skipJvmTests") == "true") {
+ tasks.forEach {
+ if (it.name.contains("jvm", true) && it.name.contains("test", true)) { it.enabled = false }
+ }
+}
+
if (project.property("firebase-auth.skipJsTests") == "true") {
tasks.forEach {
if (it.name.contains("js", true) && it.name.contains("test", true)) { it.enabled = false }
}
}
+if (supportIosTarget) {
+ tasks.create("launchIosSimulator") {
+ commandLine("open", "-a", "Simulator")
+ }
+
+ tasks.withType().configureEach {
+ dependsOn("launchIosSimulator")
+ standalone.set(false)
+ device.set("booted")
+ }
+}
+
+fun KotlinNativeTargetWithSimulatorTests.enableKeychainForTests() {
+ testRuns.configureEach {
+ executionSource.binary.linkerOpts(
+ "-sectcreate",
+ "__TEXT",
+ "__entitlements",
+ file("$projectDir/src/commonTest/resources/entitlements.plist").absolutePath
+ )
+ }
+}
+
signing {
val signingKey: String? by project
val signingPassword: String? by project
diff --git a/firebase-auth/documentation.md b/firebase-auth/documentation.md
new file mode 100644
index 000000000..2ff7437e5
--- /dev/null
+++ b/firebase-auth/documentation.md
@@ -0,0 +1,2 @@
+# Module firebase-auth
+This module is a direct forward of the Firebase Authentication library. It provides the main functionality, like authenticating with Google or Apple.
\ No newline at end of file
diff --git a/firebase-auth/package.json b/firebase-auth/package.json
index 8f9f047e8..23da53f91 100644
--- a/firebase-auth/package.json
+++ b/firebase-auth/package.json
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-auth",
- "version": "1.10.4",
+ "version": "2.0.0",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-auth.js",
"scripts": {
@@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
- "@gitlive/firebase-app": "1.10.4",
+ "@gitlive/firebase-app": "2.0.0",
"firebase": "9.19.1",
"kotlin": "1.8.20",
"kotlinx-coroutines-core": "1.6.4"
diff --git a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt
index 0d4d18e96..0b86ac10a 100644
--- a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt
+++ b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt
@@ -3,6 +3,7 @@
*/
@file:JvmName("tests")
+
package dev.gitlive.firebase.auth
import androidx.test.platform.app.InstrumentationRegistry
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 acdbc36fd..fec2e73a0 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
@@ -3,6 +3,7 @@
*/
@file:JvmName("android")
+
package dev.gitlive.firebase.auth
import com.google.firebase.auth.ActionCodeEmailInfo
@@ -11,85 +12,90 @@ import com.google.firebase.auth.ActionCodeResult.*
import com.google.firebase.auth.FirebaseAuth.AuthStateListener
import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseApp
+import dev.gitlive.firebase.android as publicAndroid
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.tasks.await
-actual val Firebase.auth
+public val FirebaseAuth.android: com.google.firebase.auth.FirebaseAuth get() = com.google.firebase.auth.FirebaseAuth.getInstance()
+
+public actual val Firebase.auth: FirebaseAuth
get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance())
-actual fun Firebase.auth(app: FirebaseApp) =
- FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.android))
+public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth =
+ FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid))
-actual data class FirebaseAuth internal constructor(val android: com.google.firebase.auth.FirebaseAuth) {
- actual val currentUser: FirebaseUser?
+public actual class FirebaseAuth internal constructor(internal val android: com.google.firebase.auth.FirebaseAuth) {
+ public actual val currentUser: FirebaseUser?
get() = android.currentUser?.let { FirebaseUser(it) }
- actual val authStateChanged: Flow get() = callbackFlow {
- val listener = object : AuthStateListener {
- override fun onAuthStateChanged(auth: com.google.firebase.auth.FirebaseAuth) {
- trySend(auth.currentUser?.let { FirebaseUser(it) })
- }
- }
+ public actual val authStateChanged: Flow get() = callbackFlow {
+ val listener = AuthStateListener { auth -> trySend(auth.currentUser?.let { FirebaseUser(it) }) }
android.addAuthStateListener(listener)
awaitClose { android.removeAuthStateListener(listener) }
}
- actual val idTokenChanged get(): Flow = callbackFlow {
- val listener = object : com.google.firebase.auth.FirebaseAuth.IdTokenListener {
- override fun onIdTokenChanged(auth: com.google.firebase.auth.FirebaseAuth) {
- trySend(auth.currentUser?.let { FirebaseUser(it) })
- }
- }
+ public actual val idTokenChanged: Flow get() = callbackFlow {
+ val listener = com.google.firebase.auth.FirebaseAuth.IdTokenListener { auth -> trySend(auth.currentUser?.let { FirebaseUser(it) }) }
android.addIdTokenListener(listener)
awaitClose { android.removeIdTokenListener(listener) }
}
- actual var languageCode: String
+ public actual var languageCode: String
get() = android.languageCode ?: ""
- set(value) { android.setLanguageCode(value) }
-
+ set(value) {
+ android.setLanguageCode(value)
+ }
- actual suspend fun applyActionCode(code: String) = android.applyActionCode(code).await().run { Unit }
- actual suspend fun confirmPasswordReset(code: String, newPassword: String) = android.confirmPasswordReset(code, newPassword).await().run { Unit }
+ public actual suspend fun applyActionCode(code: String) {
+ android.applyActionCode(code).await()
+ }
+ public actual suspend fun confirmPasswordReset(code: String, newPassword: String) {
+ android.confirmPasswordReset(code, newPassword).await()
+ }
- actual suspend fun createUserWithEmailAndPassword(email: String, password: String) =
+ public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult =
AuthResult(android.createUserWithEmailAndPassword(email, password).await())
- actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty()
+ @Suppress("DEPRECATION")
+ public actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty()
- actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) {
+ public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) {
android.sendPasswordResetEmail(email, actionCodeSettings?.toAndroid()).await()
}
- actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) = android.sendSignInLinkToEmail(email, actionCodeSettings.toAndroid()).await().run { Unit }
+ public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) {
+ android.sendSignInLinkToEmail(email, actionCodeSettings.toAndroid()).await()
+ }
- actual fun isSignInWithEmailLink(link: String) = android.isSignInWithEmailLink(link)
+ public actual fun isSignInWithEmailLink(link: String): Boolean = android.isSignInWithEmailLink(link)
- actual suspend fun signInWithEmailAndPassword(email: String, password: String) =
+ public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult =
AuthResult(android.signInWithEmailAndPassword(email, password).await())
- actual suspend fun signInWithCustomToken(token: String) =
+ public actual suspend fun signInWithCustomToken(token: String): AuthResult =
AuthResult(android.signInWithCustomToken(token).await())
- actual suspend fun signInAnonymously() = AuthResult(android.signInAnonymously().await())
+ public actual suspend fun signInAnonymously(): AuthResult = AuthResult(android.signInAnonymously().await())
- actual suspend fun signInWithCredential(authCredential: AuthCredential) =
+ public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult =
AuthResult(android.signInWithCredential(authCredential.android).await())
- actual suspend fun signInWithEmailLink(email: String, link: String) =
+ public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult =
AuthResult(android.signInWithEmailLink(email, link).await())
- actual suspend fun signOut() = android.signOut()
+ public actual suspend fun signOut(): Unit = android.signOut()
- actual suspend fun updateCurrentUser(user: FirebaseUser) = android.updateCurrentUser(user.android).await().run { Unit }
- actual suspend fun verifyPasswordResetCode(code: String): String = android.verifyPasswordResetCode(code).await()
+ public actual suspend fun updateCurrentUser(user: FirebaseUser) {
+ android.updateCurrentUser(user.android).await()
+ }
+ public actual suspend fun verifyPasswordResetCode(code: String): String = android.verifyPasswordResetCode(code).await()
- actual suspend fun checkActionCode(code: String): T {
+ public actual suspend fun checkActionCode(code: String): T {
val result = android.checkActionCode(code).await()
@Suppress("UNCHECKED_CAST")
- return when(result.operation) {
+ return when (result.operation) {
SIGN_IN_WITH_EMAIL_LINK -> ActionCodeResult.SignInWithEmailLink
VERIFY_EMAIL -> ActionCodeResult.VerifyEmail(result.info!!.email)
PASSWORD_RESET -> ActionCodeResult.PasswordReset(result.info!!.email)
@@ -107,26 +113,31 @@ actual data class FirebaseAuth internal constructor(val android: com.google.fire
} as T
}
- actual fun useEmulator(host: String, port: Int) = android.useEmulator(host, port)
+ public actual fun useEmulator(host: String, port: Int): Unit = android.useEmulator(host, port)
}
-actual class AuthResult internal constructor(val android: com.google.firebase.auth.AuthResult) {
- actual val user: FirebaseUser?
+public val AuthResult.android: com.google.firebase.auth.AuthResult get() = android
+
+public actual class AuthResult internal constructor(internal val android: com.google.firebase.auth.AuthResult) {
+ public actual val user: FirebaseUser?
get() = android.user?.let { FirebaseUser(it) }
}
-actual class AuthTokenResult(val android: com.google.firebase.auth.GetTokenResult) {
+public val AuthTokenResult.android: com.google.firebase.auth.GetTokenResult get() = android
+
+public actual class AuthTokenResult(internal val android: com.google.firebase.auth.GetTokenResult) {
// actual val authTimestamp: Long
// get() = android.authTimestamp
- actual val claims: Map
+ public actual val claims: Map
get() = android.claims
+
// actual val expirationTimestamp: Long
// get() = android.expirationTimestamp
// actual val issuedAtTimestamp: Long
// get() = android.issuedAtTimestamp
- actual val signInProvider: String?
+ public actual val signInProvider: String?
get() = android.signInProvider
- actual val token: String?
+ public actual val token: String?
get() = android.token
}
@@ -138,13 +149,13 @@ internal fun ActionCodeSettings.toAndroid() = com.google.firebase.auth.ActionCod
.also { iOSBundleId?.run { it.setIOSBundleId(this) } }
.build()
-actual typealias FirebaseAuthException = com.google.firebase.auth.FirebaseAuthException
-actual typealias FirebaseAuthActionCodeException = com.google.firebase.auth.FirebaseAuthActionCodeException
-actual typealias FirebaseAuthEmailException = com.google.firebase.auth.FirebaseAuthEmailException
-actual typealias FirebaseAuthInvalidCredentialsException = com.google.firebase.auth.FirebaseAuthInvalidCredentialsException
-actual typealias FirebaseAuthWeakPasswordException = com.google.firebase.auth.FirebaseAuthWeakPasswordException
-actual typealias FirebaseAuthInvalidUserException = com.google.firebase.auth.FirebaseAuthInvalidUserException
-actual typealias FirebaseAuthMultiFactorException = com.google.firebase.auth.FirebaseAuthMultiFactorException
-actual typealias FirebaseAuthRecentLoginRequiredException = com.google.firebase.auth.FirebaseAuthRecentLoginRequiredException
-actual typealias FirebaseAuthUserCollisionException = com.google.firebase.auth.FirebaseAuthUserCollisionException
-actual typealias FirebaseAuthWebException = com.google.firebase.auth.FirebaseAuthWebException
+public actual typealias FirebaseAuthException = com.google.firebase.auth.FirebaseAuthException
+public actual typealias FirebaseAuthActionCodeException = com.google.firebase.auth.FirebaseAuthActionCodeException
+public actual typealias FirebaseAuthEmailException = com.google.firebase.auth.FirebaseAuthEmailException
+public actual typealias FirebaseAuthInvalidCredentialsException = com.google.firebase.auth.FirebaseAuthInvalidCredentialsException
+public actual typealias FirebaseAuthWeakPasswordException = com.google.firebase.auth.FirebaseAuthWeakPasswordException
+public actual typealias FirebaseAuthInvalidUserException = com.google.firebase.auth.FirebaseAuthInvalidUserException
+public actual typealias FirebaseAuthMultiFactorException = com.google.firebase.auth.FirebaseAuthMultiFactorException
+public actual typealias FirebaseAuthRecentLoginRequiredException = com.google.firebase.auth.FirebaseAuthRecentLoginRequiredException
+public actual typealias FirebaseAuthUserCollisionException = com.google.firebase.auth.FirebaseAuthUserCollisionException
+public actual typealias FirebaseAuthWebException = com.google.firebase.auth.FirebaseAuthWebException
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 f1681a17e..914e4e4f3 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,46 +6,45 @@ 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.OAuthProvider as AndroidOAuthProvider
import com.google.firebase.auth.PhoneAuthOptions
import com.google.firebase.auth.PhoneAuthProvider
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
-import kotlinx.coroutines.tasks.await
import java.util.concurrent.TimeUnit
-actual open class AuthCredential(open val android: com.google.firebase.auth.AuthCredential) {
- actual val providerId: String
+public actual open class AuthCredential(public open val android: com.google.firebase.auth.AuthCredential) {
+ public actual val providerId: String
get() = android.provider
}
-actual class PhoneAuthCredential(override val android: com.google.firebase.auth.PhoneAuthCredential) : AuthCredential(android)
+public actual class PhoneAuthCredential(override val android: com.google.firebase.auth.PhoneAuthCredential) : AuthCredential(android)
-actual class OAuthCredential(override val android: com.google.firebase.auth.OAuthCredential) : AuthCredential(android)
+public actual class OAuthCredential(override val android: com.google.firebase.auth.OAuthCredential) : AuthCredential(android)
-actual object EmailAuthProvider {
- actual fun credential(
+public actual object EmailAuthProvider {
+ public actual fun credential(
email: String,
- password: String
+ password: String,
): AuthCredential = AuthCredential(com.google.firebase.auth.EmailAuthProvider.getCredential(email, password))
- actual fun credentialWithLink(
+ public actual fun credentialWithLink(
email: String,
- emailLink: String
+ emailLink: String,
): AuthCredential = AuthCredential(com.google.firebase.auth.EmailAuthProvider.getCredentialWithLink(email, emailLink))
}
-actual object FacebookAuthProvider {
- actual fun credential(accessToken: String): AuthCredential = AuthCredential(com.google.firebase.auth.FacebookAuthProvider.getCredential(accessToken))
+public actual object FacebookAuthProvider {
+ public actual fun credential(accessToken: String): AuthCredential = AuthCredential(com.google.firebase.auth.FacebookAuthProvider.getCredential(accessToken))
}
-actual object GithubAuthProvider {
- actual fun credential(token: String): AuthCredential = AuthCredential(com.google.firebase.auth.GithubAuthProvider.getCredential(token))
+public actual object GithubAuthProvider {
+ public actual fun credential(token: String): AuthCredential = AuthCredential(com.google.firebase.auth.GithubAuthProvider.getCredential(token))
}
-actual object GoogleAuthProvider {
- actual fun credential(idToken: String?, accessToken: String?): AuthCredential {
+public actual object GoogleAuthProvider {
+ public actual fun credential(idToken: String?, accessToken: String?): AuthCredential {
require(idToken != null || accessToken != null) {
"Both parameters are optional but at least one must be present."
}
@@ -53,39 +52,41 @@ actual object GoogleAuthProvider {
}
}
-actual class OAuthProvider(val android: com.google.firebase.auth.OAuthProvider) {
+public val OAuthProvider.android: AndroidOAuthProvider get() = android
- actual constructor(
+public actual class OAuthProvider(internal val android: AndroidOAuthProvider) {
+
+ public actual constructor(
provider: String,
scopes: List,
customParameters: Map,
- auth: FirebaseAuth
+ auth: FirebaseAuth,
) : this(
- com.google.firebase.auth.OAuthProvider
+ AndroidOAuthProvider
.newBuilder(provider, auth.android)
.setScopes(scopes)
.addCustomParameters(customParameters)
- .build()
+ .build(),
)
- actual companion object {
- actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential {
- val builder = OAuthProvider.newCredentialBuilder(providerId)
+ public actual companion object {
+ public actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential {
+ val builder = AndroidOAuthProvider.newCredentialBuilder(providerId)
accessToken?.let { builder.setAccessToken(it) }
idToken?.let { builder.setIdToken(it) }
- rawNonce?.let { builder.setIdTokenWithRawNonce(idToken!!, it) }
+ rawNonce?.let { builder.setIdTokenWithRawNonce(idToken!!, it) }
return OAuthCredential(builder.build() as com.google.firebase.auth.OAuthCredential)
}
}
}
-actual class PhoneAuthProvider(val createOptionsBuilder: () -> PhoneAuthOptions.Builder) {
+public actual class PhoneAuthProvider(public val createOptionsBuilder: () -> PhoneAuthOptions.Builder) {
- actual constructor(auth: FirebaseAuth) : this({ PhoneAuthOptions.newBuilder(auth.android) })
+ public actual constructor(auth: FirebaseAuth) : this({ PhoneAuthOptions.newBuilder(auth.android) })
- actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(com.google.firebase.auth.PhoneAuthProvider.getCredential(verificationId, smsCode))
+ public actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(PhoneAuthProvider.getCredential(verificationId, smsCode))
- actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = coroutineScope {
+ public actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = coroutineScope {
val response = CompletableDeferred>()
val callback = object :
PhoneAuthProvider.OnVerificationStateChangedCallbacks() {
@@ -121,7 +122,6 @@ actual class PhoneAuthProvider(val createOptionsBuilder: () -> PhoneAuthOptions.
override fun onVerificationFailed(error: FirebaseException) {
response.complete(Result.failure(error))
}
-
}
val options = createOptionsBuilder()
@@ -136,14 +136,14 @@ actual class PhoneAuthProvider(val createOptionsBuilder: () -> PhoneAuthOptions.
}
}
-actual interface PhoneVerificationProvider {
- val activity: Activity
- val timeout: Long
- val unit: TimeUnit
- fun codeSent(triggerResend: (Unit) -> Unit)
- suspend fun getVerificationCode(): String
+public actual interface PhoneVerificationProvider {
+ public val activity: Activity
+ public val timeout: Long
+ public val unit: TimeUnit
+ public fun codeSent(triggerResend: (Unit) -> Unit)
+ public suspend fun getVerificationCode(): String
}
-actual object TwitterAuthProvider {
- actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(com.google.firebase.auth.TwitterAuthProvider.getCredential(token, secret))
+public actual object TwitterAuthProvider {
+ public actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(com.google.firebase.auth.TwitterAuthProvider.getCredential(token, secret))
}
diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt
index 7b68960c2..8a32d501f 100644
--- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt
+++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt
@@ -6,37 +6,53 @@ package dev.gitlive.firebase.auth
import kotlinx.coroutines.tasks.await
-actual class MultiFactor(val android: com.google.firebase.auth.MultiFactor) {
- actual val enrolledFactors: List
+public val MultiFactor.android: com.google.firebase.auth.MultiFactor get() = android
+
+public actual class MultiFactor(internal val android: com.google.firebase.auth.MultiFactor) {
+ public actual val enrolledFactors: List
get() = android.enrolledFactors.map { MultiFactorInfo(it) }
- actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) = android.enroll(multiFactorAssertion.android, displayName).await().run { Unit }
- actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(android.session.await())
- actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) = android.unenroll(multiFactorInfo.android).await().run { Unit }
- actual suspend fun unenroll(factorUid: String) = android.unenroll(factorUid).await().run { Unit }
+ public actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) {
+ android.enroll(multiFactorAssertion.android, displayName).await()
+ }
+ public actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(android.session.await())
+ public actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) {
+ android.unenroll(multiFactorInfo.android).await()
+ }
+ public actual suspend fun unenroll(factorUid: String) {
+ android.unenroll(factorUid).await()
+ }
}
-actual class MultiFactorInfo(val android: com.google.firebase.auth.MultiFactorInfo) {
- actual val displayName: String?
+public val MultiFactorInfo.android: com.google.firebase.auth.MultiFactorInfo get() = android
+
+public actual class MultiFactorInfo(internal val android: com.google.firebase.auth.MultiFactorInfo) {
+ public actual val displayName: String?
get() = android.displayName
- actual val enrollmentTime: Double
+ public actual val enrollmentTime: Double
get() = android.enrollmentTimestamp.toDouble()
- actual val factorId: String
+ public actual val factorId: String
get() = android.factorId
- actual val uid: String
+ public actual val uid: String
get() = android.uid
}
-actual class MultiFactorAssertion(val android: com.google.firebase.auth.MultiFactorAssertion) {
- actual val factorId: String
+public val MultiFactorAssertion.android: com.google.firebase.auth.MultiFactorAssertion get() = android
+
+public actual class MultiFactorAssertion(internal val android: com.google.firebase.auth.MultiFactorAssertion) {
+ public actual val factorId: String
get() = android.factorId
}
-actual class MultiFactorSession(val android: com.google.firebase.auth.MultiFactorSession)
+public val MultiFactorSession.android: com.google.firebase.auth.MultiFactorSession get() = android
-actual class MultiFactorResolver(val android: com.google.firebase.auth.MultiFactorResolver) {
- actual val auth: FirebaseAuth = FirebaseAuth(android.firebaseAuth)
- actual val hints: List = android.hints.map { MultiFactorInfo(it) }
- actual val session: MultiFactorSession = MultiFactorSession(android.session)
+public actual class MultiFactorSession(internal val android: com.google.firebase.auth.MultiFactorSession)
- actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(android.resolveSignIn(assertion.android).await())
-}
\ No newline at end of file
+public val MultiFactorResolver.android: com.google.firebase.auth.MultiFactorResolver get() = android
+
+public actual class MultiFactorResolver(internal val android: com.google.firebase.auth.MultiFactorResolver) {
+ public actual val auth: FirebaseAuth = FirebaseAuth(android.firebaseAuth)
+ public actual val hints: List = android.hints.map { MultiFactorInfo(it) }
+ public actual val session: MultiFactorSession = MultiFactorSession(android.session)
+
+ public actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(android.resolveSignIn(assertion.android).await())
+}
diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt
index 5ff3a286d..8fa60207a 100644
--- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt
+++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt
@@ -8,73 +8,94 @@ import android.net.Uri
import com.google.firebase.auth.UserProfileChangeRequest
import kotlinx.coroutines.tasks.await
-actual class FirebaseUser internal constructor(val android: com.google.firebase.auth.FirebaseUser) : FirebaseUserProfile {
- actual val uid: String
+public val FirebaseUser.android: com.google.firebase.auth.FirebaseUser get() = android
+
+public actual class FirebaseUser internal constructor(internal val android: com.google.firebase.auth.FirebaseUser) {
+ public actual val uid: String
get() = android.uid
- override val displayName: String?
+ public actual val displayName: String?
get() = android.displayName
- actual val email: String?
+ public actual val email: String?
get() = android.email
- actual val phoneNumber: String?
+ public actual val phoneNumber: String?
get() = android.phoneNumber
- override val photoURL: String?
+ public actual val photoURL: String?
get() = android.photoUrl?.toString()
- actual val isAnonymous: Boolean
+ public actual val isAnonymous: Boolean
get() = android.isAnonymous
- actual val isEmailVerified: Boolean
+ public actual val isEmailVerified: Boolean
get() = android.isEmailVerified
- actual val metaData: UserMetaData?
- get() = android.metadata?.let{ UserMetaData(it) }
- actual val multiFactor: MultiFactor
+ public actual val metaData: UserMetaData?
+ get() = android.metadata?.let { UserMetaData(it) }
+ public actual val multiFactor: MultiFactor
get() = MultiFactor(android.multiFactor)
- actual val providerData: List
+ public actual val providerData: List
get() = android.providerData.map { UserInfo(it) }
- actual val providerId: String
+ public actual val providerId: String
get() = android.providerId
- actual suspend fun delete() = android.delete().await().run { Unit }
- actual suspend fun reload() = android.reload().await().run { Unit }
- actual suspend fun getIdToken(forceRefresh: Boolean): String? = android.getIdToken(forceRefresh).await().token
- actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = android.getIdToken(forceRefresh).await().run { AuthTokenResult(this) }
- actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(android.linkWithCredential(credential.android).await())
- actual suspend fun reauthenticate(credential: AuthCredential) = android.reauthenticate(credential.android).await().run { Unit }
- actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(android.reauthenticateAndRetrieveData(credential.android).await())
- actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) {
+ public actual suspend fun delete() {
+ android.delete().await()
+ }
+ public actual suspend fun reload() {
+ android.reload().await()
+ }
+ public actual suspend fun getIdToken(forceRefresh: Boolean): String? = android.getIdToken(forceRefresh).await().token
+ public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = android.getIdToken(forceRefresh).await().run { AuthTokenResult(this) }
+ public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(android.linkWithCredential(credential.android).await())
+ public actual suspend fun reauthenticate(credential: AuthCredential) {
+ android.reauthenticate(credential.android).await()
+ }
+ public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(android.reauthenticateAndRetrieveData(credential.android).await())
+ public actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) {
val request = actionCodeSettings?.let { android.sendEmailVerification(it.toAndroid()) } ?: android.sendEmailVerification()
request.await()
}
- actual suspend fun unlink(provider: String): FirebaseUser? = android.unlink(provider).await().user?.let { FirebaseUser(it) }
- actual suspend fun updateEmail(email: String) = android.updateEmail(email).await().run { Unit }
- actual suspend fun updatePassword(password: String) = android.updatePassword(password).await().run { Unit }
- actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = android.updatePhoneNumber(credential.android).await().run { Unit }
- override suspend fun updateProfile(displayName: String?, photoUrl: String?) {
- val request = UserProfileChangeRequest.Builder().apply {
- this.displayName = displayName
- photoUri = photoUrl?.let { Uri.parse(it) }
- }.build()
+ public actual suspend fun unlink(provider: String): FirebaseUser? = android.unlink(provider).await().user?.let { FirebaseUser(it) }
+
+ @Suppress("DEPRECATION")
+ public actual suspend fun updateEmail(email: String) {
+ android.updateEmail(email).await()
+ }
+ public actual suspend fun updatePassword(password: String) {
+ android.updatePassword(password).await()
+ }
+ public actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) {
+ android.updatePhoneNumber(credential.android).await()
+ }
+ public actual suspend fun updateProfile(displayName: String?, photoUrl: String?) {
+ val request = UserProfileChangeRequest.Builder()
+ .apply { setDisplayName(displayName) }
+ .apply { photoUri = photoUrl?.let { Uri.parse(it) } }
+ .build()
android.updateProfile(request).await()
}
- actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) =
- android.verifyBeforeUpdateEmail(newEmail, actionCodeSettings?.toAndroid()).await().run { Unit }
+ public actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) {
+ android.verifyBeforeUpdateEmail(newEmail, actionCodeSettings?.toAndroid()).await()
+ }
}
-actual class UserInfo(val android: com.google.firebase.auth.UserInfo) {
- actual val displayName: String?
+public val UserInfo.android: com.google.firebase.auth.UserInfo get() = android
+
+public actual class UserInfo(internal val android: com.google.firebase.auth.UserInfo) {
+ public actual val displayName: String?
get() = android.displayName
- actual val email: String?
+ public actual val email: String?
get() = android.email
- actual val phoneNumber: String?
+ public actual val phoneNumber: String?
get() = android.phoneNumber
- actual val photoURL: String?
+ public actual val photoURL: String?
get() = android.photoUrl?.toString()
- actual val providerId: String
+ public actual val providerId: String
get() = android.providerId
- actual val uid: String
+ public actual val uid: String
get() = android.uid
}
-actual class UserMetaData(val android: com.google.firebase.auth.FirebaseUserMetadata) {
- actual val creationTime: Double?
+public val UserMetaData.android: com.google.firebase.auth.FirebaseUserMetadata get() = android
+
+public actual class UserMetaData(internal val android: com.google.firebase.auth.FirebaseUserMetadata) {
+ public actual val creationTime: Double?
get() = android.creationTimestamp.toDouble()
- actual val lastSignInTime: Double?
+ public actual val lastSignInTime: Double?
get() = android.lastSignInTimestamp.toDouble()
}
diff --git a/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt
index 216b48f4c..3b9348d5a 100644
--- a/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt
+++ b/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt
@@ -3,6 +3,7 @@
*/
@file:JvmName("tests")
+
package dev.gitlive.firebase.auth
import org.junit.Ignore
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..f66ce3c03 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
@@ -2,8 +2,6 @@
* Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license.
*/
-@file:Suppress("EXTENSION_SHADOWED_BY_MEMBER")
-
package dev.gitlive.firebase.auth
import dev.gitlive.firebase.Firebase
@@ -11,77 +9,80 @@ import dev.gitlive.firebase.FirebaseApp
import dev.gitlive.firebase.FirebaseException
import kotlinx.coroutines.flow.Flow
-expect val Firebase.auth: FirebaseAuth
+public expect val Firebase.auth: FirebaseAuth
+
+public expect fun Firebase.auth(app: FirebaseApp): FirebaseAuth
-expect fun Firebase.auth(app: FirebaseApp): FirebaseAuth
+public expect class FirebaseAuth {
+ public val currentUser: FirebaseUser?
+ public val authStateChanged: Flow
+ public val idTokenChanged: Flow
+ public var languageCode: String
+ public suspend fun applyActionCode(code: String)
+ public suspend fun checkActionCode(code: String): T
+ public suspend fun confirmPasswordReset(code: String, newPassword: String)
+ public suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult
-expect class FirebaseAuth {
- val currentUser: FirebaseUser?
- val authStateChanged: Flow
- val idTokenChanged: Flow
- var languageCode: String
- suspend fun applyActionCode(code: String)
- suspend fun checkActionCode(code: String): T
- suspend fun confirmPasswordReset(code: String, newPassword: String)
- suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult
- suspend fun fetchSignInMethodsForEmail(email: String): List
- suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings? = null)
- suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings)
- fun isSignInWithEmailLink(link: String): Boolean
- suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult
- suspend fun signInWithCustomToken(token: String): AuthResult
- suspend fun signInAnonymously(): AuthResult
- suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult
- suspend fun signInWithEmailLink(email: String, link: String): AuthResult
- suspend fun signOut()
- suspend fun updateCurrentUser(user: FirebaseUser)
- suspend fun verifyPasswordResetCode(code: String): String
- fun useEmulator(host: String, port: Int)
+ @Deprecated("Migrating off of this method is recommended as a security best-practice. Learn more in the Identity Platform documentation for [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection).")
+ public suspend fun fetchSignInMethodsForEmail(email: String): List
+ public suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings? = null)
+ public suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings)
+ public fun isSignInWithEmailLink(link: String): Boolean
+ public suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult
+ public suspend fun signInWithCustomToken(token: String): AuthResult
+ public suspend fun signInAnonymously(): AuthResult
+ public suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult
+ public suspend fun signInWithEmailLink(email: String, link: String): AuthResult
+ public suspend fun signOut()
+ public suspend fun updateCurrentUser(user: FirebaseUser)
+ public suspend fun verifyPasswordResetCode(code: String): String
+ public fun useEmulator(host: String, port: Int)
}
-expect class AuthResult {
- val user: FirebaseUser?
+public expect class AuthResult {
+ public val user: FirebaseUser?
}
-expect class AuthTokenResult {
+public expect class AuthTokenResult {
// val authTimestamp: Long
- val claims: Map
+ public val claims: Map
+
// val expirationTimestamp: Long
// val issuedAtTimestamp: Long
- val signInProvider: String?
- val token: String?
+ public val signInProvider: String?
+ public val token: String?
}
-sealed class ActionCodeResult {
- object SignInWithEmailLink : ActionCodeResult()
- class PasswordReset internal constructor(val email: String) : ActionCodeResult()
- class VerifyEmail internal constructor(val email: String) : ActionCodeResult()
- class RecoverEmail internal constructor(val email: String, val previousEmail: String) : ActionCodeResult()
- class VerifyBeforeChangeEmail internal constructor(val email: String, val previousEmail: String) : ActionCodeResult()
- class RevertSecondFactorAddition internal constructor(val email: String, val multiFactorInfo: MultiFactorInfo?) : ActionCodeResult()
+public sealed class ActionCodeResult {
+ public data object SignInWithEmailLink : ActionCodeResult()
+ public class PasswordReset internal constructor(public val email: String) : ActionCodeResult()
+ public class VerifyEmail internal constructor(public val email: String) : ActionCodeResult()
+ public class RecoverEmail internal constructor(public val email: String, public val previousEmail: String) : ActionCodeResult()
+ public class VerifyBeforeChangeEmail internal constructor(public val email: String, public val previousEmail: String) : ActionCodeResult()
+ public class RevertSecondFactorAddition internal constructor(public val email: String, public val multiFactorInfo: MultiFactorInfo?) : ActionCodeResult()
}
-data class ActionCodeSettings(
+public data class ActionCodeSettings(
val url: String,
val androidPackageName: AndroidPackageName? = null,
val dynamicLinkDomain: String? = null,
val canHandleCodeInApp: Boolean = false,
- val iOSBundleId: String? = null
+ val iOSBundleId: String? = null,
)
-data class AndroidPackageName(
+public data class AndroidPackageName(
val packageName: String,
val installIfNotAvailable: Boolean = true,
- val minimumVersion: String? = null
+ val minimumVersion: String? = null,
)
-expect open class FirebaseAuthException : FirebaseException
-expect class FirebaseAuthActionCodeException : FirebaseAuthException
-expect class FirebaseAuthEmailException : FirebaseAuthException
-expect open class FirebaseAuthInvalidCredentialsException : FirebaseAuthException
-expect class FirebaseAuthWeakPasswordException: FirebaseAuthInvalidCredentialsException
-expect class FirebaseAuthInvalidUserException : FirebaseAuthException
-expect class FirebaseAuthMultiFactorException: FirebaseAuthException
-expect class FirebaseAuthRecentLoginRequiredException : FirebaseAuthException
-expect class FirebaseAuthUserCollisionException : FirebaseAuthException
-expect class FirebaseAuthWebException : FirebaseAuthException
+public expect open class FirebaseAuthException : FirebaseException
+public expect class FirebaseAuthActionCodeException : FirebaseAuthException
+public expect class FirebaseAuthEmailException : FirebaseAuthException
+public expect open class FirebaseAuthInvalidCredentialsException : FirebaseAuthException
+public expect class FirebaseAuthWeakPasswordException : FirebaseAuthInvalidCredentialsException
+public expect class FirebaseAuthInvalidUserException : FirebaseAuthException
+public expect class FirebaseAuthMultiFactorException : FirebaseAuthException
+public expect class FirebaseAuthRecentLoginRequiredException : FirebaseAuthException
+public expect class FirebaseAuthUserCollisionException : FirebaseAuthException
+public expect class FirebaseAuthWebException : FirebaseAuthException
diff --git a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/credentials.kt
index 28ed0b801..c7ea6e450 100644
--- a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/credentials.kt
+++ b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/credentials.kt
@@ -6,48 +6,48 @@ package dev.gitlive.firebase.auth
import dev.gitlive.firebase.Firebase
-expect open class AuthCredential {
- val providerId: String
+public expect open class AuthCredential {
+ public val providerId: String
}
-expect class PhoneAuthCredential : AuthCredential
+public expect class PhoneAuthCredential : AuthCredential
-expect class OAuthCredential : AuthCredential
+public expect class OAuthCredential : AuthCredential
-expect object EmailAuthProvider {
- fun credential(email: String, password: String): AuthCredential
- fun credentialWithLink(email: String, emailLink: String): AuthCredential
+public expect object EmailAuthProvider {
+ public fun credential(email: String, password: String): AuthCredential
+ public fun credentialWithLink(email: String, emailLink: String): AuthCredential
}
-expect object FacebookAuthProvider {
- fun credential(accessToken: String): AuthCredential
+public expect object FacebookAuthProvider {
+ public fun credential(accessToken: String): AuthCredential
}
-expect object GithubAuthProvider {
- fun credential(token: String): AuthCredential
+public expect object GithubAuthProvider {
+ public fun credential(token: String): AuthCredential
}
-expect object GoogleAuthProvider {
- fun credential(idToken: String?, accessToken: String?): AuthCredential
+public expect object GoogleAuthProvider {
+ public fun credential(idToken: String?, accessToken: String?): AuthCredential
}
-expect class OAuthProvider constructor(
+public expect class OAuthProvider(
provider: String,
scopes: List = emptyList(),
customParameters: Map = emptyMap(),
- auth: FirebaseAuth = Firebase.auth
+ auth: FirebaseAuth = Firebase.auth,
) {
- companion object {
- fun credential(providerId: String, accessToken: String? = null, idToken: String? = null, rawNonce: String? = null): OAuthCredential
+ public companion object {
+ public fun credential(providerId: String, accessToken: String? = null, idToken: String? = null, rawNonce: String? = null): OAuthCredential
}
}
-expect class PhoneAuthProvider constructor(auth: FirebaseAuth = Firebase.auth) {
- fun credential(verificationId: String, smsCode: String): PhoneAuthCredential
- suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential
+public expect class PhoneAuthProvider(auth: FirebaseAuth = Firebase.auth) {
+ public fun credential(verificationId: String, smsCode: String): PhoneAuthCredential
+ public suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential
}
-expect interface PhoneVerificationProvider
+public expect interface PhoneVerificationProvider
-expect object TwitterAuthProvider {
- fun credential(token: String, secret: String): AuthCredential
+public expect object TwitterAuthProvider {
+ public fun credential(token: String, secret: String): AuthCredential
}
diff --git a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt
index 04d3b11aa..4b52aebe2 100644
--- a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt
+++ b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt
@@ -4,31 +4,31 @@
package dev.gitlive.firebase.auth
-expect class MultiFactor {
- val enrolledFactors: List
- suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?)
- suspend fun getSession(): MultiFactorSession
- suspend fun unenroll(multiFactorInfo: MultiFactorInfo)
- suspend fun unenroll(factorUid: String)
+public expect class MultiFactor {
+ public val enrolledFactors: List
+ public suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?)
+ public suspend fun getSession(): MultiFactorSession
+ public suspend fun unenroll(multiFactorInfo: MultiFactorInfo)
+ public suspend fun unenroll(factorUid: String)
}
-expect class MultiFactorInfo {
- val displayName: String?
- val enrollmentTime: Double
- val factorId: String
- val uid: String
+public expect class MultiFactorInfo {
+ public val displayName: String?
+ public val enrollmentTime: Double
+ public val factorId: String
+ public val uid: String
}
-expect class MultiFactorAssertion {
- val factorId: String
+public expect class MultiFactorAssertion {
+ public val factorId: String
}
-expect class MultiFactorSession
+public expect class MultiFactorSession
-expect class MultiFactorResolver {
- val auth: FirebaseAuth
- val hints: List
- val session: MultiFactorSession
+public expect class MultiFactorResolver {
+ public val auth: FirebaseAuth
+ public val hints: List
+ public val session: MultiFactorSession
- suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult
-}
\ No newline at end of file
+ public suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult
+}
diff --git a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt
index bdbddc6af..61422f4f3 100644
--- a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt
+++ b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt
@@ -4,48 +4,46 @@
package dev.gitlive.firebase.auth
-// Javascript IR compilation has issues with referencing to actual values as default parameters, so we should use an interface instead
-interface FirebaseUserProfile {
- val displayName: String?
- val photoURL: String?
- suspend fun updateProfile(displayName: String? = this.displayName, photoUrl: String? = this.photoURL)
-}
+public expect class FirebaseUser {
+ public val uid: String
+ public val displayName: String?
+ public val email: String?
+ public val phoneNumber: String?
+ public val photoURL: String?
+ public val isAnonymous: Boolean
+ public val isEmailVerified: Boolean
+ public val metaData: UserMetaData?
+ public val multiFactor: MultiFactor
+ public val providerData: List
+ public val providerId: String
+ public suspend fun delete()
+ public suspend fun reload()
+ public suspend fun getIdToken(forceRefresh: Boolean): String?
+ public suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult
+ public suspend fun linkWithCredential(credential: AuthCredential): AuthResult
+ public suspend fun reauthenticate(credential: AuthCredential)
+ public suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult
+ public suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings? = null)
+ public suspend fun unlink(provider: String): FirebaseUser?
-expect class FirebaseUser : FirebaseUserProfile {
- val uid: String
- val email: String?
- val phoneNumber: String?
- val isAnonymous: Boolean
- val isEmailVerified: Boolean
- val metaData: UserMetaData?
- val multiFactor: MultiFactor
- val providerData: List
- val providerId: String
- suspend fun delete()
- suspend fun reload()
- suspend fun getIdToken(forceRefresh: Boolean): String?
- suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult
- suspend fun linkWithCredential(credential: AuthCredential): AuthResult
- suspend fun reauthenticate(credential: AuthCredential)
- suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult
- suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings? = null)
- suspend fun unlink(provider: String): FirebaseUser?
- suspend fun updateEmail(email: String)
- suspend fun updatePassword(password: String)
- suspend fun updatePhoneNumber(credential: PhoneAuthCredential)
- suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings? = null)
+ @Deprecated("Use verifyBeforeUpdateEmail instead", replaceWith = ReplaceWith("verifyBeforeUpdateEmail(email)"))
+ public suspend fun updateEmail(email: String)
+ public suspend fun updatePassword(password: String)
+ public suspend fun updatePhoneNumber(credential: PhoneAuthCredential)
+ public suspend fun updateProfile(displayName: String? = this.displayName, photoUrl: String? = this.photoURL)
+ public suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings? = null)
}
-expect class UserInfo {
- val displayName: String?
- val email: String?
- val phoneNumber: String?
- val photoURL: String?
- val providerId: String
- val uid: String
+public expect class UserInfo {
+ public val displayName: String?
+ public val email: String?
+ public val phoneNumber: String?
+ public val photoURL: String?
+ public val providerId: String
+ public val uid: String
}
-expect class UserMetaData {
- val creationTime: Double?
- val lastSignInTime: Double?
+public expect class UserMetaData {
+ public val creationTime: Double?
+ public val lastSignInTime: Double?
}
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 ceaf34929..47db21755 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
@@ -4,7 +4,12 @@
package dev.gitlive.firebase.auth
-import dev.gitlive.firebase.*
+import dev.gitlive.firebase.Firebase
+import dev.gitlive.firebase.FirebaseOptions
+import dev.gitlive.firebase.apps
+import dev.gitlive.firebase.initialize
+import dev.gitlive.firebase.runBlockingTest
+import dev.gitlive.firebase.runTest
import kotlin.random.Random
import kotlin.test.*
@@ -27,8 +32,8 @@ class FirebaseAuthTest {
databaseUrl = "https://fir-kotlin-sdk.firebaseio.com",
storageBucket = "fir-kotlin-sdk.appspot.com",
projectId = "fir-kotlin-sdk",
- gcmSenderId = "846484016111"
- )
+ gcmSenderId = "846484016111",
+ ),
)
auth = Firebase.auth(app).apply {
@@ -66,6 +71,7 @@ class FirebaseAuthTest {
}
@Test
+ @Ignore
fun testFetchSignInMethods() = runTest {
val email = "test+${Random.nextInt(100000)}@test.com"
var signInMethodResult = auth.fetchSignInMethodsForEmail(email)
diff --git a/firebase-auth/src/commonTest/resources/entitlements.plist b/firebase-auth/src/commonTest/resources/entitlements.plist
new file mode 100644
index 000000000..12a365278
--- /dev/null
+++ b/firebase-auth/src/commonTest/resources/entitlements.plist
@@ -0,0 +1,12 @@
+
+
+
+
+ application-identifier
+ {PERSONAL_ID}.bundle.id
+ keychain-access-groups
+
+ {PERSONAL_ID}.bundle.id
+
+
+
\ No newline at end of file
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 04a743c86..b659b0c68 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
@@ -10,83 +10,87 @@ import dev.gitlive.firebase.FirebaseApp
import dev.gitlive.firebase.FirebaseException
import dev.gitlive.firebase.FirebaseNetworkException
import dev.gitlive.firebase.auth.ActionCodeResult.*
+import dev.gitlive.firebase.ios
import kotlinx.cinterop.*
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.callbackFlow
+import kotlinx.coroutines.flow.Flow
import platform.Foundation.NSError
import platform.Foundation.NSURL
+public val FirebaseAuth.ios: FIRAuth get() = FIRAuth.auth()
-actual val Firebase.auth
+public actual val Firebase.auth: FirebaseAuth
get() = FirebaseAuth(FIRAuth.auth())
-@Suppress("CAST_NEVER_SUCCEEDS")
-actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(
- FIRAuth.authWithApp(app.ios as objcnames.classes.FIRApp)
+public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(
+ FIRAuth.authWithApp(app.ios as objcnames.classes.FIRApp),
)
-actual data class FirebaseAuth internal constructor(val ios: FIRAuth) {
+public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth) {
- actual val currentUser: FirebaseUser?
+ public actual val currentUser: FirebaseUser?
get() = ios.currentUser?.let { FirebaseUser(it) }
- actual val authStateChanged get() = callbackFlow {
+ public actual val authStateChanged: Flow get() = callbackFlow {
val handle = ios.addAuthStateDidChangeListener { _, user -> trySend(user?.let { FirebaseUser(it) }) }
awaitClose { ios.removeAuthStateDidChangeListener(handle) }
}
- actual val idTokenChanged get() = callbackFlow {
+ public actual val idTokenChanged: Flow get() = callbackFlow {
val handle = ios.addIDTokenDidChangeListener { _, user -> trySend(user?.let { FirebaseUser(it) }) }
awaitClose { ios.removeIDTokenDidChangeListener(handle) }
}
- actual var languageCode: String
+ public actual var languageCode: String
get() = ios.languageCode ?: ""
- set(value) { ios.setLanguageCode(value) }
+ set(value) {
+ ios.setLanguageCode(value)
+ }
- actual suspend fun applyActionCode(code: String) = ios.await { applyActionCode(code, it) }.run { Unit }
- actual suspend fun confirmPasswordReset(code: String, newPassword: String) = ios.await { confirmPasswordResetWithCode(code, newPassword, it) }.run { Unit }
+ public actual suspend fun applyActionCode(code: String): Unit = ios.await { applyActionCode(code, it) }
+ public actual suspend fun confirmPasswordReset(code: String, newPassword: String): Unit = ios.await { confirmPasswordResetWithCode(code, newPassword, it) }
- actual suspend fun createUserWithEmailAndPassword(email: String, password: String) =
+ public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult =
AuthResult(ios.awaitResult { createUserWithEmail(email = email, password = password, completion = it) })
@Suppress("UNCHECKED_CAST")
- actual suspend fun fetchSignInMethodsForEmail(email: String) =
+ public actual suspend fun fetchSignInMethodsForEmail(email: String): List =
ios.awaitResult?> { fetchSignInMethodsForEmail(email, it) }.orEmpty() as List
- actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) {
+ public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) {
ios.await { actionCodeSettings?.let { actionSettings -> sendPasswordResetWithEmail(email, actionSettings.toIos(), it) } ?: sendPasswordResetWithEmail(email = email, completion = it) }
}
- actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) = ios.await { sendSignInLinkToEmail(email, actionCodeSettings.toIos(), it) }.run { Unit }
+ public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit = ios.await { sendSignInLinkToEmail(email, actionCodeSettings.toIos(), it) }
- actual fun isSignInWithEmailLink(link: String) = ios.isSignInWithEmailLink(link)
+ public actual fun isSignInWithEmailLink(link: String): Boolean = ios.isSignInWithEmailLink(link)
- actual suspend fun signInWithEmailAndPassword(email: String, password: String) =
+ public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult =
AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) })
- actual suspend fun signInWithCustomToken(token: String) =
+ public actual suspend fun signInWithCustomToken(token: String): AuthResult =
AuthResult(ios.awaitResult { signInWithCustomToken(token, it) })
- actual suspend fun signInAnonymously() =
+ public actual suspend fun signInAnonymously(): AuthResult =
AuthResult(ios.awaitResult { signInAnonymouslyWithCompletion(it) })
- actual suspend fun signInWithCredential(authCredential: AuthCredential) =
+ public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult =
AuthResult(ios.awaitResult { signInWithCredential(authCredential.ios, it) })
- actual suspend fun signInWithEmailLink(email: String, link: String) =
+ public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult =
AuthResult(ios.awaitResult { signInWithEmail(email = email, link = link, completion = it) })
- actual suspend fun signOut() = ios.throwError { signOut(it) }.run { Unit }
+ public actual suspend fun signOut(): Unit = ios.throwError { signOut(it) }
- actual suspend fun updateCurrentUser(user: FirebaseUser) = ios.await { updateCurrentUser(user.ios, it) }.run { Unit }
- actual suspend fun verifyPasswordResetCode(code: String): String = ios.awaitResult { verifyPasswordResetCode(code, it) }
+ public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit = ios.await { updateCurrentUser(user.ios, it) }
+ public actual suspend fun verifyPasswordResetCode(code: String): String = ios.awaitResult { verifyPasswordResetCode(code, it) }
- actual suspend fun checkActionCode(code: String): T {
+ 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!!)
@@ -98,47 +102,50 @@ actual data class FirebaseAuth internal constructor(val ios: FIRAuth) {
} as T
}
- actual fun useEmulator(host: String, port: Int) = ios.useEmulatorWithHost(host, port.toLong())
+ public actual fun useEmulator(host: String, port: Int): Unit = ios.useEmulatorWithHost(host, port.toLong())
}
+public val AuthResult.ios: FIRAuthDataResult get() = ios
-actual class AuthResult internal constructor(val ios: FIRAuthDataResult) {
- actual val user: FirebaseUser?
+public actual class AuthResult internal constructor(internal val ios: FIRAuthDataResult) {
+ public actual val user: FirebaseUser?
get() = FirebaseUser(ios.user)
}
-actual class AuthTokenResult(val ios: FIRAuthTokenResult) {
+public val AuthTokenResult.ios: FIRAuthTokenResult get() = ios
+public actual class AuthTokenResult(internal val ios: FIRAuthTokenResult) {
// actual val authTimestamp: Long
// get() = ios.authDate
- actual val claims: Map
+ public actual val claims: Map
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
- actual val signInProvider: String?
+ public actual val signInProvider: String?
get() = ios.signInProvider
- actual val token: String?
+ public actual val token: String?
get() = ios.token
}
internal fun ActionCodeSettings.toIos() = FIRActionCodeSettings().also {
- it.URL = NSURL.URLWithString(url)
+ it.URL = NSURL.URLWithString(url)
androidPackageName?.run { it.setAndroidPackageName(packageName, installIfNotAvailable, minimumVersion) }
it.dynamicLinkDomain = dynamicLinkDomain
it.handleCodeInApp = canHandleCodeInApp
iOSBundleId?.run { it.setIOSBundleID(this) }
}
-actual open class FirebaseAuthException(message: String): FirebaseException(message)
-actual open class FirebaseAuthActionCodeException(message: String): FirebaseAuthException(message)
-actual open class FirebaseAuthEmailException(message: String): FirebaseAuthException(message)
-actual open class FirebaseAuthInvalidCredentialsException(message: String): FirebaseAuthException(message)
-actual open class FirebaseAuthWeakPasswordException(message: String): FirebaseAuthInvalidCredentialsException(message)
-actual open class FirebaseAuthInvalidUserException(message: String): FirebaseAuthException(message)
-actual open class FirebaseAuthMultiFactorException(message: String): FirebaseAuthException(message)
-actual open class FirebaseAuthRecentLoginRequiredException(message: String): FirebaseAuthException(message)
-actual open class FirebaseAuthUserCollisionException(message: String): FirebaseAuthException(message)
-actual open class FirebaseAuthWebException(message: String): FirebaseAuthException(message)
+public actual open class FirebaseAuthException(message: String) : FirebaseException(message)
+public actual open class FirebaseAuthActionCodeException(message: String) : FirebaseAuthException(message)
+public actual open class FirebaseAuthEmailException(message: String) : FirebaseAuthException(message)
+public actual open class FirebaseAuthInvalidCredentialsException(message: String) : FirebaseAuthException(message)
+public actual open class FirebaseAuthWeakPasswordException(message: String) : FirebaseAuthInvalidCredentialsException(message)
+public actual open class FirebaseAuthInvalidUserException(message: String) : FirebaseAuthException(message)
+public actual open class FirebaseAuthMultiFactorException(message: String) : FirebaseAuthException(message)
+public actual open class FirebaseAuthRecentLoginRequiredException(message: String) : FirebaseAuthException(message)
+public actual open class FirebaseAuthUserCollisionException(message: String) : FirebaseAuthException(message)
+public actual open class FirebaseAuthWebException(message: String) : FirebaseAuthException(message)
internal fun T.throwError(block: T.(errorPointer: CPointer>) -> R): R {
memScoped {
@@ -154,34 +161,33 @@ internal fun T.throwError(block: T.(errorPointer: CPointer T.awaitResult(function: T.(callback: (R?, NSError?) -> Unit) -> Unit): R {
val job = CompletableDeferred()
- val callback = { result: R?, error: NSError? ->
- if(error == null) {
+ function { result, error ->
+ if (error == null) {
job.complete(result)
} else {
job.completeExceptionally(error.toException())
}
}
- function(callback)
return job.await() as R
}
internal suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) {
val job = CompletableDeferred()
- val callback = { error: NSError? ->
- if(error == null) {
+ function { error ->
+ if (error == null) {
job.complete(Unit)
} else {
job.completeExceptionally(error.toException())
}
}
- function(callback)
job.await()
}
-private fun NSError.toException() = when(domain) {
- FIRAuthErrorDomain -> when(code) {
+private fun NSError.toException() = when (domain) {
+ FIRAuthErrorDomain -> when (code) {
FIRAuthErrorCodeInvalidActionCode,
- FIRAuthErrorCodeExpiredActionCode -> FirebaseAuthActionCodeException(toString())
+ FIRAuthErrorCodeExpiredActionCode,
+ -> FirebaseAuthActionCodeException(toString())
FIRAuthErrorCodeInvalidEmail -> FirebaseAuthEmailException(toString())
@@ -193,7 +199,8 @@ private fun NSError.toException() = when(domain) {
FIRAuthErrorCodeMissingVerificationID,
FIRAuthErrorCodeMissingVerificationCode,
FIRAuthErrorCodeUserTokenExpired,
- FIRAuthErrorCodeInvalidCredential -> FirebaseAuthInvalidCredentialsException(toString())
+ FIRAuthErrorCodeInvalidCredential,
+ -> FirebaseAuthInvalidCredentialsException(toString())
FIRAuthErrorCodeWeakPassword -> FirebaseAuthWeakPasswordException(toString())
@@ -204,15 +211,18 @@ private fun NSError.toException() = when(domain) {
FIRAuthErrorCodeSecondFactorAlreadyEnrolled,
FIRAuthErrorCodeSecondFactorRequired,
FIRAuthErrorCodeMaximumSecondFactorCountExceeded,
- FIRAuthErrorCodeMultiFactorInfoNotFound -> FirebaseAuthMultiFactorException(toString())
+ FIRAuthErrorCodeMultiFactorInfoNotFound,
+ -> FirebaseAuthMultiFactorException(toString())
FIRAuthErrorCodeEmailAlreadyInUse,
FIRAuthErrorCodeAccountExistsWithDifferentCredential,
- FIRAuthErrorCodeCredentialAlreadyInUse -> FirebaseAuthUserCollisionException(toString())
+ FIRAuthErrorCodeCredentialAlreadyInUse,
+ -> FirebaseAuthUserCollisionException(toString())
FIRAuthErrorCodeWebContextAlreadyPresented,
FIRAuthErrorCodeWebContextCancelled,
- FIRAuthErrorCodeWebInternalError -> FirebaseAuthWebException(toString())
+ FIRAuthErrorCodeWebInternalError,
+ -> FirebaseAuthWebException(toString())
FIRAuthErrorCodeNetworkError -> FirebaseNetworkException(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 365fee8ce..08387a0e1 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
@@ -6,59 +6,61 @@ package dev.gitlive.firebase.auth
import cocoapods.FirebaseAuth.*
-actual open class AuthCredential(open val ios: FIRAuthCredential) {
- actual val providerId: String
+public actual open class AuthCredential(public open val ios: FIRAuthCredential) {
+ public actual val providerId: String
get() = ios.provider
}
-actual class PhoneAuthCredential(override val ios: FIRPhoneAuthCredential) : AuthCredential(ios)
-actual class OAuthCredential(override val ios: FIROAuthCredential) : AuthCredential(ios)
+public actual class PhoneAuthCredential(override val ios: FIRPhoneAuthCredential) : AuthCredential(ios)
+public actual class OAuthCredential(override val ios: FIROAuthCredential) : AuthCredential(ios)
-actual object EmailAuthProvider {
- actual fun credential(
+public actual object EmailAuthProvider {
+ public actual fun credential(
email: String,
- password: String
+ password: String,
): AuthCredential =
AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, password = password))
- actual fun credentialWithLink(
+ public actual fun credentialWithLink(
email: String,
- emailLink: String
+ emailLink: String,
): AuthCredential =
AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, link = emailLink))
}
-actual object FacebookAuthProvider {
- actual fun credential(accessToken: String): AuthCredential = AuthCredential(FIRFacebookAuthProvider.credentialWithAccessToken(accessToken))
+public actual object FacebookAuthProvider {
+ public actual fun credential(accessToken: String): AuthCredential = AuthCredential(FIRFacebookAuthProvider.credentialWithAccessToken(accessToken))
}
-actual object GithubAuthProvider {
- actual fun credential(token: String): AuthCredential = AuthCredential(FIRGitHubAuthProvider.credentialWithToken(token))
+public actual object GithubAuthProvider {
+ public actual fun credential(token: String): AuthCredential = AuthCredential(FIRGitHubAuthProvider.credentialWithToken(token))
}
-actual object GoogleAuthProvider {
- actual fun credential(idToken: String?, accessToken: String?): AuthCredential {
+public actual object GoogleAuthProvider {
+ public actual fun credential(idToken: String?, accessToken: String?): AuthCredential {
requireNotNull(idToken) { "idToken must not be null" }
requireNotNull(accessToken) { "accessToken must not be null" }
return AuthCredential(FIRGoogleAuthProvider.credentialWithIDToken(idToken, accessToken))
}
}
-actual class OAuthProvider(val ios: FIROAuthProvider) {
+public val OAuthProvider.ios: FIROAuthProvider get() = ios
- actual constructor(
+public actual class OAuthProvider(internal val ios: FIROAuthProvider) {
+
+ public actual constructor(
provider: String,
scopes: List,
customParameters: Map,
- auth: FirebaseAuth
+ auth: FirebaseAuth,
) : this(FIROAuthProvider.providerWithProviderID(provider, auth.ios)) {
ios.setScopes(scopes)
@Suppress("UNCHECKED_CAST")
ios.setCustomParameters(customParameters as Map)
}
- actual companion object {
- actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential {
+ public actual companion object {
+ public actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential {
val credential = when {
idToken == null -> FIROAuthProvider.credentialWithProviderID(providerID = providerId, accessToken = accessToken!!)
accessToken == null -> FIROAuthProvider.credentialWithProviderID(providerID = providerId, IDToken = idToken, rawNonce = rawNonce!!)
@@ -70,24 +72,26 @@ actual class OAuthProvider(val ios: FIROAuthProvider) {
}
}
-actual class PhoneAuthProvider(val ios: FIRPhoneAuthProvider) {
+public val PhoneAuthProvider.ios: FIRPhoneAuthProvider get() = ios
+
+public actual class PhoneAuthProvider(internal val ios: FIRPhoneAuthProvider) {
- actual constructor(auth: FirebaseAuth) : this(FIRPhoneAuthProvider.providerWithAuth(auth.ios))
+ public actual constructor(auth: FirebaseAuth) : this(FIRPhoneAuthProvider.providerWithAuth(auth.ios))
- actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(ios.credentialWithVerificationID(verificationId, smsCode))
+ public actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(ios.credentialWithVerificationID(verificationId, smsCode))
- actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential {
+ public actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential {
val verificationId: String = ios.awaitResult { ios.verifyPhoneNumber(phoneNumber, verificationProvider.delegate, it) }
val verificationCode = verificationProvider.getVerificationCode()
return credential(verificationId, verificationCode)
}
}
-actual interface PhoneVerificationProvider {
- val delegate: FIRAuthUIDelegateProtocol
- suspend fun getVerificationCode(): String
+public actual interface PhoneVerificationProvider {
+ public val delegate: FIRAuthUIDelegateProtocol?
+ public suspend fun getVerificationCode(): String
}
-actual object TwitterAuthProvider {
- actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(FIRTwitterAuthProvider.credentialWithToken(token, secret))
+public actual object TwitterAuthProvider {
+ public actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(FIRTwitterAuthProvider.credentialWithToken(token, secret))
}
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 2822e7406..f389b6abb 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
@@ -6,37 +6,47 @@ package dev.gitlive.firebase.auth
import cocoapods.FirebaseAuth.*
-actual class MultiFactor(val ios: FIRMultiFactor) {
- actual val enrolledFactors: List
- get() = ios.enrolledFactors.mapNotNull { info -> (info as? FIRMultiFactorInfo)?.let{ MultiFactorInfo(it) } }
- actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) = ios.await { enrollWithAssertion(multiFactorAssertion.ios, displayName, it) }.run { Unit }
- actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(ios.awaitResult { getSessionWithCompletion(completion = it) })
- actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) = ios.await { unenrollWithInfo(multiFactorInfo.ios, it) }.run { Unit }
- actual suspend fun unenroll(factorUid: String) = ios.await { unenrollWithFactorUID(factorUid, it) }.run { Unit }
+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) } }
+ 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) }
+ public actual suspend fun unenroll(factorUid: String): Unit = ios.await { unenrollWithFactorUID(factorUid, it) }
}
-actual class MultiFactorInfo(val ios: FIRMultiFactorInfo) {
- actual val displayName: String?
+public val MultiFactorInfo.ios: FIRMultiFactorInfo get() = ios
+
+public actual class MultiFactorInfo(internal val ios: FIRMultiFactorInfo) {
+ public actual val displayName: String?
get() = ios.displayName
- actual val enrollmentTime: Double
- get() = ios.enrollmentDate.timeIntervalSinceReferenceDate.toDouble()
- actual val factorId: String
+ public actual val enrollmentTime: Double
+ get() = ios.enrollmentDate.timeIntervalSinceReferenceDate
+ public actual val factorId: String
get() = ios.factorID
- actual val uid: String
+ public actual val uid: String
get() = ios.UID
}
-actual class MultiFactorAssertion(val ios: FIRMultiFactorAssertion) {
- actual val factorId: String
+public val MultiFactorAssertion.ios: FIRMultiFactorAssertion get() = ios
+
+public actual class MultiFactorAssertion(internal val ios: FIRMultiFactorAssertion) {
+ public actual val factorId: String
get() = ios.factorID
}
-actual class MultiFactorSession(val ios: FIRMultiFactorSession)
+public val MultiFactorSession.ios: FIRMultiFactorSession get() = ios
+
+public actual class MultiFactorSession(internal val ios: FIRMultiFactorSession)
-actual class MultiFactorResolver(val ios: FIRMultiFactorResolver) {
- actual val auth: FirebaseAuth = FirebaseAuth(ios.auth)
- actual val hints: List = ios.hints.mapNotNull { hint -> (hint as? FIRMultiFactorInfo)?.let { MultiFactorInfo(it) } }
- actual val session: MultiFactorSession = MultiFactorSession(ios.session)
+public val MultiFactorResolver.ios: FIRMultiFactorResolver get() = ios
- actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(ios.awaitResult { resolveSignInWithAssertion(assertion.ios, it) })
-}
\ No newline at end of file
+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 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 f4f0b6c70..f2f6c67cc 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
@@ -10,93 +10,99 @@ import cocoapods.FirebaseAuth.FIRUserInfoProtocol
import cocoapods.FirebaseAuth.FIRUserMetadata
import platform.Foundation.NSURL
-actual class FirebaseUser internal constructor(val ios: FIRUser) : FirebaseUserProfile {
- actual val uid: String
+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
- override val displayName: String?
+ public actual val displayName: String?
get() = ios.displayName
- actual val email: String?
+ public actual val email: String?
get() = ios.email
- actual val phoneNumber: String?
+ public actual val phoneNumber: String?
get() = ios.phoneNumber
- override val photoURL: String?
+ public actual val photoURL: String?
get() = ios.photoURL?.absoluteString
- actual val isAnonymous: Boolean
+ public actual val isAnonymous: Boolean
get() = ios.anonymous
- actual val isEmailVerified: Boolean
+ public actual val isEmailVerified: Boolean
get() = ios.emailVerified
- actual val metaData: UserMetaData?
+ public actual val metaData: UserMetaData?
get() = UserMetaData(ios.metadata)
- actual val multiFactor: MultiFactor
+ public actual val multiFactor: MultiFactor
get() = MultiFactor(ios.multiFactor)
- actual val providerData: List
+ public actual val providerData: List
get() = ios.providerData.mapNotNull { provider -> (provider as? FIRUserInfoProtocol)?.let { UserInfo(it) } }
- actual val providerId: String
+ public actual val providerId: String
get() = ios.providerID
- actual suspend fun delete() = ios.await { deleteWithCompletion(it) }.run { Unit }
+ public actual suspend fun delete(): Unit = ios.await { deleteWithCompletion(it) }
- actual suspend fun reload() = ios.await { reloadWithCompletion(it) }.run { Unit }
+ public actual suspend fun reload(): Unit = ios.await { reloadWithCompletion(it) }
- actual suspend fun getIdToken(forceRefresh: Boolean): String? =
+ public actual suspend fun getIdToken(forceRefresh: Boolean): String? =
ios.awaitResult { getIDTokenForcingRefresh(forceRefresh, it) }
- actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult =
+ public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult =
AuthTokenResult(ios.awaitResult { getIDTokenResultForcingRefresh(forceRefresh, it) })
- actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult =
+ public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult =
AuthResult(ios.awaitResult { linkWithCredential(credential.ios, it) })
- actual suspend fun reauthenticate(credential: AuthCredential) =
- ios.awaitResult { reauthenticateWithCredential(credential.ios, it) }.run { Unit }
+ public actual suspend fun reauthenticate(credential: AuthCredential) {
+ ios.awaitResult { reauthenticateWithCredential(credential.ios, it) }
+ }
- actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult =
+ public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult =
AuthResult(ios.awaitResult { reauthenticateWithCredential(credential.ios, it) })
- actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) = ios.await {
+ public actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?): Unit = ios.await {
actionCodeSettings?.let { settings -> sendEmailVerificationWithActionCodeSettings(settings.toIos(), it) }
?: sendEmailVerificationWithCompletion(it)
}
- actual suspend fun unlink(provider: String): FirebaseUser? {
+ public actual suspend fun unlink(provider: String): FirebaseUser? {
val user: FIRUser? = ios.awaitResult { unlinkFromProvider(provider, it) }
return user?.let {
FirebaseUser(it)
}
}
- actual suspend fun updateEmail(email: String) = ios.await { updateEmail(email, it) }.run { Unit }
- actual suspend fun updatePassword(password: String) = ios.await { updatePassword(password, it) }.run { Unit }
- actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = ios.await { updatePhoneNumberCredential(credential.ios, it) }.run { Unit }
- override suspend fun updateProfile(displayName: String?, photoUrl: String?) {
- val request = ios.profileChangeRequest().apply {
- this.displayName = displayName
- this.photoURL = photoUrl?.let { NSURL.URLWithString(it) }
- }
+ public actual suspend fun updateEmail(email: String): Unit = ios.await { updateEmail(email, it) }
+ public actual suspend fun updatePassword(password: String): Unit = ios.await { updatePassword(password, it) }
+ public actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential): Unit = ios.await { updatePhoneNumberCredential(credential.ios, it) }
+ public actual suspend fun updateProfile(displayName: String?, photoUrl: String?) {
+ val request = ios.profileChangeRequest()
+ .apply { setDisplayName(displayName) }
+ .apply { setPhotoURL(photoUrl?.let { NSURL.URLWithString(it) }) }
ios.await { request.commitChangesWithCompletion(it) }
}
- actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) = ios.await {
+ public actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?): Unit = ios.await {
actionCodeSettings?.let { actionSettings -> sendEmailVerificationBeforeUpdatingEmail(newEmail, actionSettings.toIos(), it) } ?: sendEmailVerificationBeforeUpdatingEmail(newEmail, it)
- }.run { Unit }
+ }
}
-actual class UserInfo(val ios: FIRUserInfoProtocol) {
- actual val displayName: String?
+public val UserInfo.ios: FIRUserInfoProtocol get() = ios
+
+public actual class UserInfo(internal val ios: FIRUserInfoProtocol) {
+ public actual val displayName: String?
get() = ios.displayName
- actual val email: String?
+ public actual val email: String?
get() = ios.email
- actual val phoneNumber: String?
+ public actual val phoneNumber: String?
get() = ios.phoneNumber
- actual val photoURL: String?
+ public actual val photoURL: String?
get() = ios.photoURL?.absoluteString
- actual val providerId: String
+ public actual val providerId: String
get() = ios.providerID
- actual val uid: String
+ public actual val uid: String
get() = ios.uid
}
-actual class UserMetaData(val ios: FIRUserMetadata) {
- actual val creationTime: Double?
- get() = ios.creationDate?.timeIntervalSinceReferenceDate?.toDouble()
- actual val lastSignInTime: Double?
- get() = ios.lastSignInDate?.timeIntervalSinceReferenceDate?.toDouble()
+public val UserMetaData.ios: FIRUserMetadata get() = ios
+
+public actual class UserMetaData(internal val ios: FIRUserMetadata) {
+ public actual val creationTime: Double?
+ get() = ios.creationDate?.timeIntervalSinceReferenceDate
+ public actual val lastSignInTime: Double?
+ get() = ios.lastSignInDate?.timeIntervalSinceReferenceDate
}
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 9bfc2e61b..a222d4d6e 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
@@ -4,125 +4,157 @@
package dev.gitlive.firebase.auth
-import dev.gitlive.firebase.*
+import dev.gitlive.firebase.Firebase
import dev.gitlive.firebase.FirebaseApp
-import dev.gitlive.firebase.auth.externals.*
+import dev.gitlive.firebase.FirebaseException
+import dev.gitlive.firebase.FirebaseNetworkException
+import dev.gitlive.firebase.auth.externals.Auth
+import dev.gitlive.firebase.auth.externals.getAuth
+import dev.gitlive.firebase.auth.externals.applyActionCode
+import dev.gitlive.firebase.auth.externals.confirmPasswordReset
+import dev.gitlive.firebase.auth.externals.createUserWithEmailAndPassword
+import dev.gitlive.firebase.auth.externals.sendPasswordResetEmail
+import dev.gitlive.firebase.auth.externals.fetchSignInMethodsForEmail
+import dev.gitlive.firebase.auth.externals.sendSignInLinkToEmail
+import dev.gitlive.firebase.auth.externals.isSignInWithEmailLink
+import dev.gitlive.firebase.auth.externals.signInWithEmailAndPassword
+import dev.gitlive.firebase.auth.externals.signInWithCustomToken
+import dev.gitlive.firebase.auth.externals.signInAnonymously
+import dev.gitlive.firebase.auth.externals.signInWithCredential
+import dev.gitlive.firebase.auth.externals.signInWithEmailLink
+import dev.gitlive.firebase.auth.externals.signOut
+import dev.gitlive.firebase.auth.externals.updateCurrentUser
+import dev.gitlive.firebase.auth.externals.verifyPasswordResetCode
+import dev.gitlive.firebase.auth.externals.checkActionCode
+import dev.gitlive.firebase.auth.externals.connectAuthEmulator
+import dev.gitlive.firebase.auth.externals.IdTokenResult
+import dev.gitlive.firebase.js
import kotlinx.coroutines.await
import kotlinx.coroutines.channels.awaitClose
+import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.callbackFlow
import kotlin.js.json
import dev.gitlive.firebase.auth.externals.AuthResult as JsAuthResult
-actual val Firebase.auth
+public actual val Firebase.auth: FirebaseAuth
get() = rethrow { FirebaseAuth(getAuth()) }
-actual fun Firebase.auth(app: FirebaseApp) =
+public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth =
rethrow { FirebaseAuth(getAuth(app.js)) }
-actual class FirebaseAuth internal constructor(val js: Auth) {
+public val FirebaseAuth.js: Auth get() = js
- actual val currentUser: FirebaseUser?
+public actual class FirebaseAuth internal constructor(internal val js: Auth) {
+
+ public actual val currentUser: FirebaseUser?
get() = rethrow { js.currentUser?.let { FirebaseUser(it) } }
- actual val authStateChanged get() = callbackFlow {
+ public actual val authStateChanged: Flow get() = callbackFlow {
val unsubscribe = js.onAuthStateChanged {
trySend(it?.let { FirebaseUser(it) })
}
awaitClose { unsubscribe() }
}
- actual val idTokenChanged get() = callbackFlow {
+ public actual val idTokenChanged: Flow get() = callbackFlow {
val unsubscribe = js.onIdTokenChanged {
trySend(it?.let { FirebaseUser(it) })
}
awaitClose { unsubscribe() }
}
- actual var languageCode: String
+ public actual var languageCode: String
get() = js.languageCode ?: ""
- set(value) { js.languageCode = value }
+ set(value) {
+ js.languageCode = value
+ }
- actual suspend fun applyActionCode(code: String) = rethrow { applyActionCode(js, code).await() }
- actual suspend fun confirmPasswordReset(code: String, newPassword: String) = rethrow { confirmPasswordReset(js, code, newPassword).await() }
+ public actual suspend fun applyActionCode(code: String): Unit = rethrow { applyActionCode(js, code).await() }
+ public actual suspend fun confirmPasswordReset(code: String, newPassword: String): Unit = rethrow { confirmPasswordReset(js, code, newPassword).await() }
- actual suspend fun createUserWithEmailAndPassword(email: String, password: String) =
+ public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult =
rethrow { AuthResult(createUserWithEmailAndPassword(js, email, password).await()) }
- actual suspend fun fetchSignInMethodsForEmail(email: String): List = rethrow { fetchSignInMethodsForEmail(js, email).await().asList() }
+ public actual suspend fun fetchSignInMethodsForEmail(email: String): List = rethrow { fetchSignInMethodsForEmail(js, email).await().asList() }
- actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) =
+ public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?): Unit =
rethrow { sendPasswordResetEmail(js, email, actionCodeSettings?.toJson()).await() }
- actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) =
+ public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit =
rethrow { sendSignInLinkToEmail(js, email, actionCodeSettings.toJson()).await() }
- actual fun isSignInWithEmailLink(link: String) = rethrow { isSignInWithEmailLink(js, link) }
+ public actual fun isSignInWithEmailLink(link: String): Boolean = rethrow { isSignInWithEmailLink(js, link) }
- actual suspend fun signInWithEmailAndPassword(email: String, password: String) =
+ public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult =
rethrow { AuthResult(signInWithEmailAndPassword(js, email, password).await()) }
- actual suspend fun signInWithCustomToken(token: String) =
+ public actual suspend fun signInWithCustomToken(token: String): AuthResult =
rethrow { AuthResult(signInWithCustomToken(js, token).await()) }
- actual suspend fun signInAnonymously() =
+ public actual suspend fun signInAnonymously(): AuthResult =
rethrow { AuthResult(signInAnonymously(js).await()) }
- actual suspend fun signInWithCredential(authCredential: AuthCredential) =
+ public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult =
rethrow { AuthResult(signInWithCredential(js, authCredential.js).await()) }
- actual suspend fun signInWithEmailLink(email: String, link: String) =
+ public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult =
rethrow { AuthResult(signInWithEmailLink(js, email, link).await()) }
- actual suspend fun signOut() = rethrow { signOut(js).await() }
+ public actual suspend fun signOut(): Unit = rethrow { signOut(js).await() }
- actual suspend fun updateCurrentUser(user: FirebaseUser) =
+ public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit =
rethrow { updateCurrentUser(js, user.js).await() }
- actual suspend fun verifyPasswordResetCode(code: String): String =
+ public actual suspend fun verifyPasswordResetCode(code: String): String =
rethrow { verifyPasswordResetCode(js, code).await() }
- actual suspend fun checkActionCode(code: String): T = rethrow {
+ public actual suspend fun checkActionCode(code: String): T = rethrow {
val result = checkActionCode(js, code).await()
@Suppress("UNCHECKED_CAST")
- return when(result.operation) {
+ return when (result.operation) {
"EMAIL_SIGNIN" -> ActionCodeResult.SignInWithEmailLink
"VERIFY_EMAIL" -> ActionCodeResult.VerifyEmail(result.data.email!!)
"PASSWORD_RESET" -> ActionCodeResult.PasswordReset(result.data.email!!)
"RECOVER_EMAIL" -> ActionCodeResult.RecoverEmail(result.data.email!!, result.data.previousEmail!!)
"VERIFY_AND_CHANGE_EMAIL" -> ActionCodeResult.VerifyBeforeChangeEmail(
result.data.email!!,
- result.data.previousEmail!!
+ result.data.previousEmail!!,
)
"REVERT_SECOND_FACTOR_ADDITION" -> ActionCodeResult.RevertSecondFactorAddition(
result.data.email!!,
- result.data.multiFactorInfo?.let { MultiFactorInfo(it) }
+ result.data.multiFactorInfo?.let { MultiFactorInfo(it) },
)
else -> throw UnsupportedOperationException(result.operation)
} as T
}
- actual fun useEmulator(host: String, port: Int) = rethrow { connectAuthEmulator(js, "http://$host:$port") }
+ public actual fun useEmulator(host: String, port: Int): Unit = rethrow { connectAuthEmulator(js, "http://$host:$port") }
}
-actual class AuthResult internal constructor(val js: JsAuthResult) {
- actual val user: FirebaseUser?
+public val AuthResult.js: JsAuthResult get() = js
+
+public actual class AuthResult internal constructor(internal val js: JsAuthResult) {
+ public actual val user: FirebaseUser?
get() = rethrow { js.user?.let { FirebaseUser(it) } }
}
-actual class AuthTokenResult(val js: IdTokenResult) {
+public val AuthTokenResult.js: IdTokenResult get() = js
+
+public actual class AuthTokenResult(internal val js: IdTokenResult) {
// actual val authTimestamp: Long
// get() = js.authTime
- actual val claims: Map
- get() = (js("Object").keys(js.claims) as Array).mapNotNull {
- key -> js.claims[key]?.let { key to it }
+ public actual val claims: Map
+ get() = (js("Object").keys(js.claims) as Array).mapNotNull { key ->
+ js.claims[key]?.let { key to it }
}.toMap()
+
// actual val expirationTimestamp: Long
// get() = android.expirationTime
// actual val issuedAtTimestamp: Long
// get() = js.issuedAtTime
- actual val signInProvider: String?
+ public actual val signInProvider: String?
get() = js.signInProvider
- actual val token: String?
+ public actual val token: String?
get() = js.token
}
@@ -131,20 +163,19 @@ internal fun ActionCodeSettings.toJson() = json(
"android" to (androidPackageName?.run { json("installApp" to installIfNotAvailable, "minimumVersion" to minimumVersion, "packageName" to packageName) } ?: undefined),
"dynamicLinkDomain" to (dynamicLinkDomain ?: undefined),
"handleCodeInApp" to canHandleCodeInApp,
- "ios" to (iOSBundleId?.run { json("bundleId" to iOSBundleId) } ?: undefined)
+ "ios" to (iOSBundleId?.run { json("bundleId" to iOSBundleId) } ?: undefined),
)
-actual open class FirebaseAuthException(code: String?, cause: Throwable): FirebaseException(code, cause)
-actual open class FirebaseAuthActionCodeException(code: String?, cause: Throwable): FirebaseAuthException(code, cause)
-actual open class FirebaseAuthEmailException(code: String?, cause: Throwable): FirebaseAuthException(code, cause)
-actual open class FirebaseAuthInvalidCredentialsException(code: String?, cause: Throwable): FirebaseAuthException(code, cause)
-actual open class FirebaseAuthWeakPasswordException(code: String?, cause: Throwable): FirebaseAuthInvalidCredentialsException(code, cause)
-actual open class FirebaseAuthInvalidUserException(code: String?, cause: Throwable): FirebaseAuthException(code, cause)
-actual open class FirebaseAuthMultiFactorException(code: String?, cause: Throwable): FirebaseAuthException(code, cause)
-actual open class FirebaseAuthRecentLoginRequiredException(code: String?, cause: Throwable): FirebaseAuthException(code, cause)
-actual open class FirebaseAuthUserCollisionException(code: String?, cause: Throwable): FirebaseAuthException(code, cause)
-actual open class FirebaseAuthWebException(code: String?, cause: Throwable): FirebaseAuthException(code, cause)
-
+public actual open class FirebaseAuthException(code: String?, cause: Throwable) : FirebaseException(code, cause)
+public actual open class FirebaseAuthActionCodeException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause)
+public actual open class FirebaseAuthEmailException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause)
+public actual open class FirebaseAuthInvalidCredentialsException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause)
+public actual open class FirebaseAuthWeakPasswordException(code: String?, cause: Throwable) : FirebaseAuthInvalidCredentialsException(code, cause)
+public actual open class FirebaseAuthInvalidUserException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause)
+public actual open class FirebaseAuthMultiFactorException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause)
+public actual open class FirebaseAuthRecentLoginRequiredException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause)
+public actual open class FirebaseAuthUserCollisionException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause)
+public actual open class FirebaseAuthWebException(code: String?, cause: Throwable) : FirebaseAuthException(code, cause)
internal inline fun T.rethrow(function: T.() -> R): R = dev.gitlive.firebase.auth.rethrow { function() }
@@ -153,30 +184,32 @@ private inline fun rethrow(function: () -> R): R {
return function()
} catch (e: Exception) {
throw e
- } catch(e: dynamic) {
+ } catch (e: dynamic) {
throw errorToException(e)
}
}
-private fun errorToException(cause: dynamic) = when(val code = cause.code?.toString()?.lowercase()) {
- "auth/invalid-user-token" -> FirebaseAuthInvalidUserException(code, cause)
- "auth/requires-recent-login" -> FirebaseAuthRecentLoginRequiredException(code, cause)
- "auth/user-disabled" -> FirebaseAuthInvalidUserException(code, cause)
- "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)
+private fun errorToException(cause: dynamic) = when (val code = cause.code?.toString()?.lowercase()) {
+ "auth/invalid-user-token" -> FirebaseAuthInvalidUserException(code, cause.unsafeCast())
+ "auth/requires-recent-login" -> FirebaseAuthRecentLoginRequiredException(code, cause.unsafeCast())
+ "auth/user-disabled" -> FirebaseAuthInvalidUserException(code, cause.unsafeCast())
+ "auth/user-token-expired" -> FirebaseAuthInvalidUserException(code, cause.unsafeCast())
+ "auth/web-storage-unsupported" -> FirebaseAuthWebException(code, cause.unsafeCast())
+ "auth/network-request-failed" -> FirebaseNetworkException(code, cause.unsafeCast())
+ "auth/timeout" -> FirebaseNetworkException(code, cause.unsafeCast())
+ "auth/weak-password" -> FirebaseAuthWeakPasswordException(code, cause.unsafeCast())
"auth/invalid-credential",
"auth/invalid-verification-code",
"auth/missing-verification-code",
"auth/invalid-verification-id",
- "auth/missing-verification-id" -> FirebaseAuthInvalidCredentialsException(code, cause)
+ "auth/missing-verification-id",
+ -> FirebaseAuthInvalidCredentialsException(code, cause.unsafeCast())
"auth/maximum-second-factor-count-exceeded",
- "auth/second-factor-already-in-use" -> FirebaseAuthMultiFactorException(code, cause)
- "auth/credential-already-in-use" -> FirebaseAuthUserCollisionException(code, cause)
- "auth/email-already-in-use" -> FirebaseAuthUserCollisionException(code, cause)
- "auth/invalid-email" -> FirebaseAuthEmailException(code, cause)
+ "auth/second-factor-already-in-use",
+ -> FirebaseAuthMultiFactorException(code, cause.unsafeCast())
+ "auth/credential-already-in-use" -> FirebaseAuthUserCollisionException(code, cause.unsafeCast())
+ "auth/email-already-in-use" -> FirebaseAuthUserCollisionException(code, cause.unsafeCast())
+ "auth/invalid-email" -> FirebaseAuthEmailException(code, cause.unsafeCast())
// "auth/app-deleted" ->
// "auth/app-not-authorized" ->
// "auth/argument-error" ->
@@ -186,6 +219,6 @@ private fun errorToException(cause: dynamic) = when(val code = cause.code?.toStr
// "auth/unauthorized-domain" ->
else -> {
println("Unknown error code in ${JSON.stringify(cause)}")
- FirebaseAuthException(code, cause)
+ FirebaseAuthException(code, cause.unsafeCast())
}
}
diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt
index eb6fb9efe..112099734 100644
--- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt
+++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/credentials.kt
@@ -5,43 +5,45 @@ import dev.gitlive.firebase.auth.externals.EmailAuthProvider
import dev.gitlive.firebase.auth.externals.FacebookAuthProvider
import dev.gitlive.firebase.auth.externals.GithubAuthProvider
import dev.gitlive.firebase.auth.externals.GoogleAuthProvider
-import dev.gitlive.firebase.auth.externals.PhoneAuthProvider
+import dev.gitlive.firebase.auth.externals.PhoneAuthProvider as JsPhoneAuthProvider
import dev.gitlive.firebase.auth.externals.TwitterAuthProvider
import kotlinx.coroutines.await
import kotlin.js.json
import dev.gitlive.firebase.auth.externals.AuthCredential as JsAuthCredential
import dev.gitlive.firebase.auth.externals.OAuthProvider as JsOAuthProvider
-actual open class AuthCredential(val js: JsAuthCredential) {
- actual val providerId: String
+public val AuthCredential.js: JsAuthCredential get() = js
+
+public actual open class AuthCredential(internal val js: JsAuthCredential) {
+ public actual val providerId: String
get() = js.providerId
}
-actual class PhoneAuthCredential(js: JsAuthCredential) : AuthCredential(js)
-actual class OAuthCredential(js: JsAuthCredential) : AuthCredential(js)
+public actual class PhoneAuthCredential(js: JsAuthCredential) : AuthCredential(js)
+public actual class OAuthCredential(js: JsAuthCredential) : AuthCredential(js)
-actual object EmailAuthProvider {
- actual fun credential(email: String, password: String): AuthCredential =
+public actual object EmailAuthProvider {
+ public actual fun credential(email: String, password: String): AuthCredential =
AuthCredential(EmailAuthProvider.credential(email, password))
- actual fun credentialWithLink(
+ public actual fun credentialWithLink(
email: String,
- emailLink: String
+ emailLink: String,
): AuthCredential = AuthCredential(EmailAuthProvider.credentialWithLink(email, emailLink))
}
-actual object FacebookAuthProvider {
- actual fun credential(accessToken: String): AuthCredential =
+public actual object FacebookAuthProvider {
+ public actual fun credential(accessToken: String): AuthCredential =
AuthCredential(FacebookAuthProvider.credential(accessToken))
}
-actual object GithubAuthProvider {
- actual fun credential(token: String): AuthCredential =
+public actual object GithubAuthProvider {
+ public actual fun credential(token: String): AuthCredential =
AuthCredential(GithubAuthProvider.credential(token))
}
-actual object GoogleAuthProvider {
- actual fun credential(idToken: String?, accessToken: String?): AuthCredential {
+public actual object GoogleAuthProvider {
+ public actual fun credential(idToken: String?, accessToken: String?): AuthCredential {
require(idToken != null || accessToken != null) {
"Both parameters are optional but at least one must be present."
}
@@ -49,52 +51,56 @@ actual object GoogleAuthProvider {
}
}
-actual class OAuthProvider(val js: JsOAuthProvider) {
+public val OAuthProvider.js: JsOAuthProvider get() = js
+
+public actual class OAuthProvider(internal val js: JsOAuthProvider) {
- actual constructor(
+ public actual constructor(
provider: String,
scopes: List,
customParameters: Map,
- auth: FirebaseAuth
+ auth: FirebaseAuth,
) : this(JsOAuthProvider(provider)) {
rethrow {
scopes.forEach { js.addScope(it) }
js.setCustomParameters(customParameters)
}
}
- actual companion object {
- actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential = rethrow {
+ public actual companion object {
+ public actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential = rethrow {
JsOAuthProvider(providerId)
.credential(
json(
"accessToken" to (accessToken ?: undefined),
"idToken" to (idToken ?: undefined),
- "rawNonce" to (rawNonce ?: undefined)
+ "rawNonce" to (rawNonce ?: undefined),
),
- accessToken ?: undefined
+ accessToken ?: undefined,
)
.let { OAuthCredential(it) }
}
}
}
-actual class PhoneAuthProvider(val js: PhoneAuthProvider) {
+public val PhoneAuthProvider.js: JsPhoneAuthProvider get() = js
+
+public actual class PhoneAuthProvider(internal val js: JsPhoneAuthProvider) {
- actual constructor(auth: FirebaseAuth) : this(PhoneAuthProvider(auth.js))
+ public actual constructor(auth: FirebaseAuth) : this(JsPhoneAuthProvider(auth.js))
- actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(PhoneAuthProvider.credential(verificationId, smsCode))
- actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = rethrow {
+ public actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(JsPhoneAuthProvider.credential(verificationId, smsCode))
+ public actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = rethrow {
val verificationId = js.verifyPhoneNumber(phoneNumber, verificationProvider.verifier).await()
val verificationCode = verificationProvider.getVerificationCode(verificationId)
credential(verificationId, verificationCode)
}
}
-actual interface PhoneVerificationProvider {
- val verifier: ApplicationVerifier
- suspend fun getVerificationCode(verificationId: String): String
+public actual interface PhoneVerificationProvider {
+ public val verifier: ApplicationVerifier
+ public suspend fun getVerificationCode(verificationId: String): String
}
-actual object TwitterAuthProvider {
- actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(TwitterAuthProvider.credential(token, secret))
+public actual object TwitterAuthProvider {
+ public actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(TwitterAuthProvider.credential(token, secret))
}
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 ca32fe3c5..e535e6c22 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
@@ -8,292 +8,292 @@ import dev.gitlive.firebase.externals.FirebaseApp
import kotlin.js.Json
import kotlin.js.Promise
-external fun applyActionCode(auth: Auth, code: String): Promise
+public external fun applyActionCode(auth: Auth, code: String): Promise
-external fun checkActionCode(auth: Auth, code: String): Promise
+public external fun checkActionCode(auth: Auth, code: String): Promise
-external fun confirmPasswordReset(auth: Auth, code: String, newPassword: String): Promise
+public external fun confirmPasswordReset(auth: Auth, code: String, newPassword: String): Promise
-external fun connectAuthEmulator(auth: Auth, url: String, options: Any? = definedExternally)
+public external fun connectAuthEmulator(auth: Auth, url: String, options: Any? = definedExternally)
-external fun createUserWithEmailAndPassword(
+public external fun createUserWithEmailAndPassword(
auth: Auth,
email: String,
- password: String
+ password: String,
): Promise
-external fun deleteUser(user: User): Promise
+public external fun deleteUser(user: User): Promise
-external fun fetchSignInMethodsForEmail(auth: Auth, email: String): Promise>
+public external fun fetchSignInMethodsForEmail(auth: Auth, email: String): Promise>
-external fun getAuth(app: FirebaseApp? = definedExternally): Auth
+public external fun getAuth(app: FirebaseApp? = definedExternally): Auth
-external fun initializeAuth(app: FirebaseApp? = definedExternally, deps: dynamic = definedExternally): Auth
+public external fun initializeAuth(app: FirebaseApp? = definedExternally, deps: dynamic = definedExternally): Auth
-external fun getIdToken(user: User, forceRefresh: Boolean?): Promise
+public external fun getIdToken(user: User, forceRefresh: Boolean?): Promise
-external fun getIdTokenResult(user: User, forceRefresh: Boolean?): Promise
+public external fun getIdTokenResult(user: User, forceRefresh: Boolean?): Promise
-external fun isSignInWithEmailLink(auth: Auth, link: String): Boolean
+public external fun isSignInWithEmailLink(auth: Auth, link: String): Boolean
-external fun linkWithCredential(user: User, credential: AuthCredential): Promise
+public external fun linkWithCredential(user: User, credential: AuthCredential): Promise
-external fun multiFactor(user: User): MultiFactorUser
+public external fun multiFactor(user: User): MultiFactorUser
-external fun onAuthStateChanged(auth: Auth, nextOrObserver: (User?) -> Unit): Unsubscribe
+public external fun onAuthStateChanged(auth: Auth, nextOrObserver: (User?) -> Unit): Unsubscribe
-external fun onIdTokenChanged(auth: Auth, nextOrObserver: (User?) -> Unit): Unsubscribe
+public external fun onIdTokenChanged(auth: Auth, nextOrObserver: (User?) -> Unit): Unsubscribe
-external fun sendEmailVerification(user: User, actionCodeSettings: Any?): Promise
+public external fun sendEmailVerification(user: User, actionCodeSettings: Any?): Promise
-external fun reauthenticateWithCredential(
+public external fun reauthenticateWithCredential(
user: User,
- credential: AuthCredential
+ credential: AuthCredential,
): Promise
-external fun reload(user: User): Promise
+public external fun reload(user: User): Promise
-external fun sendPasswordResetEmail(
+public external fun sendPasswordResetEmail(
auth: Auth,
email: String,
- actionCodeSettings: Any?
+ actionCodeSettings: Any?,
): Promise
-external fun sendSignInLinkToEmail(
+public external fun sendSignInLinkToEmail(
auth: Auth,
email: String,
- actionCodeSettings: Any?
+ actionCodeSettings: Any?,
): Promise
-external fun signInAnonymously(auth: Auth): Promise
+public external fun signInAnonymously(auth: Auth): Promise
-external fun signInWithCredential(auth: Auth, authCredential: AuthCredential): Promise
+public external fun signInWithCredential(auth: Auth, authCredential: AuthCredential): Promise
-external fun signInWithCustomToken(auth: Auth, token: String): Promise
+public external fun signInWithCustomToken(auth: Auth, token: String): Promise
-external fun signInWithEmailAndPassword(
+public external fun signInWithEmailAndPassword(
auth: Auth,
email: String,
- password: String
+ password: String,
): Promise
-external fun signInWithEmailLink(auth: Auth, email: String, link: String): Promise
+public external fun signInWithEmailLink(auth: Auth, email: String, link: String): Promise
-external fun signInWithPopup(auth: Auth, provider: AuthProvider): Promise
+public external fun signInWithPopup(auth: Auth, provider: AuthProvider): Promise
-external fun signInWithRedirect(auth: Auth, provider: AuthProvider): Promise
+public external fun signInWithRedirect(auth: Auth, provider: AuthProvider): Promise
-external fun getRedirectResult(auth: Auth): Promise
+public external fun getRedirectResult(auth: Auth): Promise
-external fun signOut(auth: Auth): Promise
+public external fun signOut(auth: Auth): Promise
-external fun unlink(user: User, providerId: String): Promise
+public external fun unlink(user: User, providerId: String): Promise