forked from GitLiveApp/firebase-kotlin-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.kt
59 lines (47 loc) · 1.97 KB
/
auth.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* 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
import dev.gitlive.firebase.FirebaseApp
import dev.gitlive.firebase.FirebaseException
import kotlinx.coroutines.flow.Flow
expect val Firebase.auth: FirebaseAuth
expect fun Firebase.auth(app: FirebaseApp): FirebaseAuth
expect class FirebaseAuth {
val currentUser: FirebaseUser?
val authStateChanged: Flow<FirebaseUser?>
suspend fun sendPasswordResetEmail(email: String)
suspend fun signInWithEmailAndPassword(email: String, password: String): AuthResult
suspend fun createUserWithEmailAndPassword(email: String, password: String): AuthResult
suspend fun signInWithCustomToken(token: String): AuthResult
suspend fun signInAnonymously(): AuthResult
suspend fun signInWithCredential(authCredential: AuthCredential): AuthResult
suspend fun signOut()
}
expect class AuthResult {
val user: FirebaseUser?
}
expect class FirebaseUser {
val uid: String
val displayName: String?
val email: String?
val phoneNumber: String?
val isAnonymous: Boolean
suspend fun delete()
suspend fun reload()
suspend fun sendEmailVerification()
}
expect open class FirebaseAuthException : FirebaseException
expect class FirebaseAuthActionCodeException : FirebaseAuthException
expect class FirebaseAuthEmailException : FirebaseAuthException
expect class FirebaseAuthInvalidCredentialsException : FirebaseAuthException
expect class FirebaseAuthInvalidUserException : FirebaseAuthException
expect class FirebaseAuthRecentLoginRequiredException : FirebaseAuthException
expect class FirebaseAuthUserCollisionException : FirebaseAuthException
expect class FirebaseAuthWebException : FirebaseAuthException
expect class AuthCredential
expect object EmailAuthProvider{
fun credentialWithEmail(email: String, password: String): AuthCredential
}