Skip to content

Commit

Permalink
Apply automatic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored and github-actions[bot] committed Dec 9, 2024
1 parent e70763b commit 9b16b8e
Show file tree
Hide file tree
Showing 73 changed files with 261 additions and 459 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import kotlin.time.Duration
public actual val Firebase.analytics: FirebaseAnalytics
get() = FirebaseAnalytics(com.google.firebase.Firebase.analytics)

public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics =
FirebaseAnalytics(com.google.firebase.Firebase.analytics)
public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(com.google.firebase.Firebase.analytics)

public val FirebaseAnalytics.android: com.google.firebase.analytics.FirebaseAnalytics get() = android

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import kotlin.time.Duration
public actual val Firebase.analytics: FirebaseAnalytics
get() = FirebaseAnalytics(getAnalytics())

public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics =
FirebaseAnalytics(getAnalytics(app.js))
public actual fun Firebase.analytics(app: FirebaseApp): FirebaseAnalytics = FirebaseAnalytics(getAnalytics(app.js))

public val FirebaseAnalytics.js: dev.gitlive.firebase.analytics.externals.FirebaseAnalytics get() = js

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,13 @@ public val FirebaseApp.android: com.google.firebase.FirebaseApp get() = android
public actual val Firebase.app: FirebaseApp
get() = FirebaseApp(com.google.firebase.FirebaseApp.getInstance())

public actual fun Firebase.app(name: String): FirebaseApp =
FirebaseApp(com.google.firebase.FirebaseApp.getInstance(name))
public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.getInstance(name))

public actual fun Firebase.initialize(context: Any?): FirebaseApp? =
com.google.firebase.FirebaseApp.initializeApp(context as Context)?.let { FirebaseApp(it) }
public actual fun Firebase.initialize(context: Any?): FirebaseApp? = com.google.firebase.FirebaseApp.initializeApp(context as Context)?.let { FirebaseApp(it) }

public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp =
FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid(), name))
public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid(), name))

public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp =
FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid()))
public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FirebaseApp(com.google.firebase.FirebaseApp.initializeApp(context as Context, options.toAndroid()))

public actual data class FirebaseApp internal constructor(internal val android: com.google.firebase.FirebaseApp) {
actual val name: String
Expand Down
12 changes: 4 additions & 8 deletions firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ public val FirebaseApp.ios: FIRApp get() = ios
public actual val Firebase.app: FirebaseApp
get() = FirebaseApp(FIRApp.defaultApp()!!)

public actual fun Firebase.app(name: String): FirebaseApp =
FirebaseApp(FIRApp.appNamed(name)!!)
public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(FIRApp.appNamed(name)!!)

public actual fun Firebase.initialize(context: Any?): FirebaseApp? =
FIRApp.configure().let { app }
public actual fun Firebase.initialize(context: Any?): FirebaseApp? = FIRApp.configure().let { app }

public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp =
FIRApp.configureWithName(name, options.toIos()).let { app(name) }
public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FIRApp.configureWithName(name, options.toIos()).let { app(name) }

public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp =
FIRApp.configureWithOptions(options.toIos()).let { app }
public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FIRApp.configureWithOptions(options.toIos()).let { app }

public actual data class FirebaseApp internal constructor(internal val ios: FIRApp) {
actual val name: String
Expand Down
12 changes: 4 additions & 8 deletions firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ import dev.gitlive.firebase.externals.FirebaseApp as JsFirebaseApp
public actual val Firebase.app: FirebaseApp
get() = FirebaseApp(getApp())

public actual fun Firebase.app(name: String): FirebaseApp =
FirebaseApp(getApp(name))
public actual fun Firebase.app(name: String): FirebaseApp = FirebaseApp(getApp(name))

public actual fun Firebase.initialize(context: Any?): FirebaseApp? =
throw UnsupportedOperationException("Cannot initialize firebase without options in JS")
public actual fun Firebase.initialize(context: Any?): FirebaseApp? = throw UnsupportedOperationException("Cannot initialize firebase without options in JS")

public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp =
FirebaseApp(initializeApp(options.toJson(), name))
public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions, name: String): FirebaseApp = FirebaseApp(initializeApp(options.toJson(), name))

public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp =
FirebaseApp(initializeApp(options.toJson()))
public actual fun Firebase.initialize(context: Any?, options: FirebaseOptions): FirebaseApp = FirebaseApp(initializeApp(options.toJson()))

public val FirebaseApp.js: JsFirebaseApp get() = js

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public val FirebaseAuth.android: com.google.firebase.auth.FirebaseAuth get() = c
public actual val Firebase.auth: FirebaseAuth
get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance())

public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth =
FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid))
public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.publicAndroid))

public actual class FirebaseAuth internal constructor(internal val android: com.google.firebase.auth.FirebaseAuth) {
public actual val currentUser: FirebaseUser?
Expand Down Expand Up @@ -55,8 +54,7 @@ public actual class FirebaseAuth internal constructor(internal val android: com.
android.confirmPasswordReset(code, newPassword).await()
}

public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult =
AuthResult(android.createUserWithEmailAndPassword(email, password).await())
public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.createUserWithEmailAndPassword(email, password).await())

@Suppress("DEPRECATION")
public actual suspend fun fetchSignInMethodsForEmail(email: String): List<String> = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty()
Expand All @@ -71,19 +69,15 @@ public actual class FirebaseAuth internal constructor(internal val android: com.

public actual fun isSignInWithEmailLink(link: String): Boolean = android.isSignInWithEmailLink(link)

public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult =
AuthResult(android.signInWithEmailAndPassword(email, password).await())
public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(android.signInWithEmailAndPassword(email, password).await())

public actual suspend fun signInWithCustomToken(token: String): AuthResult =
AuthResult(android.signInWithCustomToken(token).await())
public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(android.signInWithCustomToken(token).await())

public actual suspend fun signInAnonymously(): AuthResult = AuthResult(android.signInAnonymously().await())

public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult =
AuthResult(android.signInWithCredential(authCredential.android).await())
public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(android.signInWithCredential(authCredential.android).await())

public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult =
AuthResult(android.signInWithEmailLink(email, link).await())
public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(android.signInWithEmailLink(email, link).await())

public actual suspend fun signOut(): Unit = android.signOut()

Expand Down
21 changes: 7 additions & 14 deletions firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth)
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) }

public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult =
AuthResult(ios.awaitResult { createUserWithEmail(email = email, password = password, completion = it) })
public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(ios.awaitResult { createUserWithEmail(email = email, password = password, completion = it) })

@Suppress("UNCHECKED_CAST")
public actual suspend fun fetchSignInMethodsForEmail(email: String): List<String> =
ios.awaitResult<FIRAuth, List<*>?> { fetchSignInMethodsForEmail(email, it) }.orEmpty() as List<String>
public actual suspend fun fetchSignInMethodsForEmail(email: String): List<String> = ios.awaitResult<FIRAuth, List<*>?> { fetchSignInMethodsForEmail(email, it) }.orEmpty() as List<String>

public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) {
ios.await { actionCodeSettings?.let { actionSettings -> sendPasswordResetWithEmail(email, actionSettings.toIos(), it) } ?: sendPasswordResetWithEmail(email = email, completion = it) }
Expand All @@ -68,20 +66,15 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth)

public actual fun isSignInWithEmailLink(link: String): Boolean = ios.isSignInWithEmailLink(link)

public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult =
AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) })
public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = AuthResult(ios.awaitResult { signInWithEmail(email = email, password = password, completion = it) })

public actual suspend fun signInWithCustomToken(token: String): AuthResult =
AuthResult(ios.awaitResult { signInWithCustomToken(token, it) })
public actual suspend fun signInWithCustomToken(token: String): AuthResult = AuthResult(ios.awaitResult { signInWithCustomToken(token, it) })

public actual suspend fun signInAnonymously(): AuthResult =
AuthResult(ios.awaitResult { signInAnonymouslyWithCompletion(it) })
public actual suspend fun signInAnonymously(): AuthResult = AuthResult(ios.awaitResult { signInAnonymouslyWithCompletion(it) })

public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult =
AuthResult(ios.awaitResult { signInWithCredential(authCredential.ios, it) })
public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { signInWithCredential(authCredential.ios, it) })

public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult =
AuthResult(ios.awaitResult { signInWithEmail(email = email, link = link, completion = it) })
public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = AuthResult(ios.awaitResult { signInWithEmail(email = email, link = link, completion = it) })

public actual suspend fun signOut(): Unit = ios.throwError { signOut(it) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ public actual object EmailAuthProvider {
public actual fun credential(
email: String,
password: String,
): AuthCredential =
AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, password = password))
): AuthCredential = AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, password = password))

public actual fun credentialWithLink(
email: String,
emailLink: String,
): AuthCredential =
AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, link = emailLink))
): AuthCredential = AuthCredential(FIREmailAuthProvider.credentialWithEmail(email = email, link = emailLink))
}

public actual object FacebookAuthProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,17 @@ public actual class FirebaseUser internal constructor(internal val ios: FIRUser)

public actual suspend fun reload(): Unit = ios.await { reloadWithCompletion(it) }

public actual suspend fun getIdToken(forceRefresh: Boolean): String? =
ios.awaitResult { getIDTokenForcingRefresh(forceRefresh, it) }
public actual suspend fun getIdToken(forceRefresh: Boolean): String? = ios.awaitResult { getIDTokenForcingRefresh(forceRefresh, it) }

public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult =
AuthTokenResult(ios.awaitResult { getIDTokenResultForcingRefresh(forceRefresh, it) })
public actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = AuthTokenResult(ios.awaitResult { getIDTokenResultForcingRefresh(forceRefresh, it) })

public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult =
AuthResult(ios.awaitResult { linkWithCredential(credential.ios, it) })
public actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { linkWithCredential(credential.ios, it) })

public actual suspend fun reauthenticate(credential: AuthCredential) {
ios.awaitResult<FIRUser, FIRAuthDataResult?> { reauthenticateWithCredential(credential.ios, it) }
}

public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult =
AuthResult(ios.awaitResult { reauthenticateWithCredential(credential.ios, it) })
public actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(ios.awaitResult { reauthenticateWithCredential(credential.ios, it) })

public actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?): Unit = ios.await {
actionCodeSettings?.let { settings -> sendEmailVerificationWithActionCodeSettings(settings.toIos(), it) }
Expand Down
33 changes: 11 additions & 22 deletions firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/auth.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ import dev.gitlive.firebase.auth.externals.AdditionalUserInfo as JsAdditionalUse
public actual val Firebase.auth: FirebaseAuth
get() = rethrow { FirebaseAuth(getAuth()) }

public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth =
rethrow { FirebaseAuth(getAuth(app.js)) }
public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = rethrow { FirebaseAuth(getAuth(app.js)) }

public val FirebaseAuth.js: Auth get() = js

Expand Down Expand Up @@ -74,41 +73,31 @@ public actual class FirebaseAuth internal constructor(internal val js: Auth) {
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() }

public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult =
rethrow { AuthResult(createUserWithEmailAndPassword(js, email, password).await()) }
public actual suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult = rethrow { AuthResult(createUserWithEmailAndPassword(js, email, password).await()) }

public actual suspend fun fetchSignInMethodsForEmail(email: String): List<String> = rethrow { fetchSignInMethodsForEmail(js, email).await().asList() }

public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?): Unit =
rethrow { sendPasswordResetEmail(js, email, actionCodeSettings?.toJson()).await() }
public actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?): Unit = rethrow { sendPasswordResetEmail(js, email, actionCodeSettings?.toJson()).await() }

public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit =
rethrow { sendSignInLinkToEmail(js, email, actionCodeSettings.toJson()).await() }
public actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings): Unit = rethrow { sendSignInLinkToEmail(js, email, actionCodeSettings.toJson()).await() }

public actual fun isSignInWithEmailLink(link: String): Boolean = rethrow { isSignInWithEmailLink(js, link) }

public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult =
rethrow { AuthResult(signInWithEmailAndPassword(js, email, password).await()) }
public actual suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult = rethrow { AuthResult(signInWithEmailAndPassword(js, email, password).await()) }

public actual suspend fun signInWithCustomToken(token: String): AuthResult =
rethrow { AuthResult(signInWithCustomToken(js, token).await()) }
public actual suspend fun signInWithCustomToken(token: String): AuthResult = rethrow { AuthResult(signInWithCustomToken(js, token).await()) }

public actual suspend fun signInAnonymously(): AuthResult =
rethrow { AuthResult(signInAnonymously(js).await()) }
public actual suspend fun signInAnonymously(): AuthResult = rethrow { AuthResult(signInAnonymously(js).await()) }

public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult =
rethrow { AuthResult(signInWithCredential(js, authCredential.js).await()) }
public actual suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult = rethrow { AuthResult(signInWithCredential(js, authCredential.js).await()) }

public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult =
rethrow { AuthResult(signInWithEmailLink(js, email, link).await()) }
public actual suspend fun signInWithEmailLink(email: String, link: String): AuthResult = rethrow { AuthResult(signInWithEmailLink(js, email, link).await()) }

public actual suspend fun signOut(): Unit = rethrow { signOut(js).await() }

public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit =
rethrow { updateCurrentUser(js, user.js).await() }
public actual suspend fun updateCurrentUser(user: FirebaseUser): Unit = rethrow { updateCurrentUser(js, user.js).await() }

public actual suspend fun verifyPasswordResetCode(code: String): String =
rethrow { verifyPasswordResetCode(js, code).await() }
public actual suspend fun verifyPasswordResetCode(code: String): String = rethrow { verifyPasswordResetCode(js, code).await() }

public actual suspend fun <T : ActionCodeResult> checkActionCode(code: String): T = rethrow {
val result = checkActionCode(js, code).await()
Expand Down
Loading

0 comments on commit 9b16b8e

Please sign in to comment.