@@ -31,7 +31,7 @@ public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(
31
31
public actual class FirebaseAuth internal constructor(internal val ios : FIRAuth ) {
32
32
33
33
public actual val currentUser: FirebaseUser ?
34
- get() = ios.currentUser?.let { FirebaseUser (it) }
34
+ get() = ios.currentUser() ?.let { FirebaseUser (it) }
35
35
36
36
public actual val authStateChanged: Flow <FirebaseUser ?> get() = callbackFlow {
37
37
val handle = ios.addAuthStateDidChangeListener { _, user -> trySend(user?.let { FirebaseUser (it) }) }
@@ -44,7 +44,7 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth)
44
44
}
45
45
46
46
public actual var languageCode: String
47
- get() = ios.languageCode ? : " "
47
+ get() = ios.languageCode() ? : " "
48
48
set(value) {
49
49
ios.setLanguageCode(value)
50
50
}
@@ -90,15 +90,15 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth)
90
90
public actual suspend fun <T : ActionCodeResult > checkActionCode (code : String ): T {
91
91
val result: FIRActionCodeInfo = ios.awaitResult { checkActionCode(code, it) }
92
92
@Suppress(" UNCHECKED_CAST" )
93
- return when (result.operation) {
93
+ return when (result.operation() ) {
94
94
FIRActionCodeOperationEmailLink -> SignInWithEmailLink
95
- FIRActionCodeOperationVerifyEmail -> VerifyEmail (result.email!! )
96
- FIRActionCodeOperationPasswordReset -> PasswordReset (result.email!! )
97
- FIRActionCodeOperationRecoverEmail -> RecoverEmail (result.email!! , result.previousEmail!! )
98
- FIRActionCodeOperationVerifyAndChangeEmail -> VerifyBeforeChangeEmail (result.email!! , result.previousEmail!! )
99
- FIRActionCodeOperationRevertSecondFactorAddition -> RevertSecondFactorAddition (result.email!! , null )
100
- FIRActionCodeOperationUnknown -> throw UnsupportedOperationException (result.operation.toString())
101
- else -> throw UnsupportedOperationException (result.operation.toString())
95
+ FIRActionCodeOperationVerifyEmail -> VerifyEmail (result.email() )
96
+ FIRActionCodeOperationPasswordReset -> PasswordReset (result.email() )
97
+ FIRActionCodeOperationRecoverEmail -> RecoverEmail (result.email() , result.previousEmail() !! )
98
+ FIRActionCodeOperationVerifyAndChangeEmail -> VerifyBeforeChangeEmail (result.email() , result.previousEmail() !! )
99
+ FIRActionCodeOperationRevertSecondFactorAddition -> RevertSecondFactorAddition (result.email() , null )
100
+ FIRActionCodeOperationUnknown -> throw UnsupportedOperationException (result.operation() .toString())
101
+ else -> throw UnsupportedOperationException (result.operation() .toString())
102
102
} as T
103
103
}
104
104
@@ -108,31 +108,31 @@ public val AuthResult.ios: FIRAuthDataResult get() = ios
108
108
109
109
public actual class AuthResult internal constructor(internal val ios : FIRAuthDataResult ) {
110
110
public actual val user: FirebaseUser ?
111
- get() = FirebaseUser (ios.user)
111
+ get() = FirebaseUser (ios.user() )
112
112
}
113
113
114
114
public val AuthTokenResult .ios: FIRAuthTokenResult get() = ios
115
115
public actual class AuthTokenResult (internal val ios : FIRAuthTokenResult ) {
116
116
// actual val authTimestamp: Long
117
117
// get() = ios.authDate
118
118
public actual val claims: Map <String , Any >
119
- get() = ios.claims.map { it.key.toString() to it.value as Any }.toMap()
119
+ get() = ios.claims() .map { it.key.toString() to it.value as Any }.toMap()
120
120
121
121
// actual val expirationTimestamp: Long
122
122
// get() = ios.expirationDate
123
123
// actual val issuedAtTimestamp: Long
124
124
// get() = ios.issuedAtDate
125
125
public actual val signInProvider: String?
126
- get() = ios.signInProvider
126
+ get() = ios.signInProvider()
127
127
public actual val token: String?
128
- get() = ios.token
128
+ get() = ios.token()
129
129
}
130
130
131
131
internal fun ActionCodeSettings.toIos () = FIRActionCodeSettings ().also {
132
- it.URL = NSURL .URLWithString (url)
132
+ it.setURL( NSURL .URLWithString (url) )
133
133
androidPackageName?.run { it.setAndroidPackageName(packageName, installIfNotAvailable, minimumVersion) }
134
- it.dynamicLinkDomain = dynamicLinkDomain
135
- it.handleCodeInApp = canHandleCodeInApp
134
+ it.setDynamicLinkDomain( dynamicLinkDomain)
135
+ it.setHandleCodeInApp( canHandleCodeInApp)
136
136
iOSBundleId?.run { it.setIOSBundleID(this ) }
137
137
}
138
138
@@ -184,47 +184,55 @@ internal suspend inline fun <T> T.await(function: T.(callback: (NSError?) -> Uni
184
184
}
185
185
186
186
private fun NSError.toException () = when (domain) {
187
+ // codes from AuthErrors.swift: https://github.com/firebase/firebase-ios-sdk/blob/
188
+ // 2f6ac4c2c61cd57c7ea727009e187b7e1163d613/FirebaseAuth/Sources/Swift/Utilities/
189
+ // AuthErrors.swift#L51
187
190
FIRAuthErrorDomain -> when (code) {
188
- FIRAuthErrorCodeInvalidActionCode ,
189
- FIRAuthErrorCodeExpiredActionCode ,
191
+ 17030L , // AuthErrorCode.invalidActionCode
192
+ 17029L , // AuthErrorCode.expiredActionCode
190
193
-> FirebaseAuthActionCodeException (toString())
191
194
192
- FIRAuthErrorCodeInvalidEmail -> FirebaseAuthEmailException (toString())
193
-
194
- FIRAuthErrorCodeCaptchaCheckFailed ,
195
- FIRAuthErrorCodeInvalidPhoneNumber ,
196
- FIRAuthErrorCodeMissingPhoneNumber ,
197
- FIRAuthErrorCodeInvalidVerificationID ,
198
- FIRAuthErrorCodeInvalidVerificationCode ,
199
- FIRAuthErrorCodeMissingVerificationID ,
200
- FIRAuthErrorCodeMissingVerificationCode ,
201
- FIRAuthErrorCodeUserTokenExpired ,
202
- FIRAuthErrorCodeInvalidCredential ,
195
+ 17008L , // AuthErrorCode.invalidEmail
196
+ -> FirebaseAuthEmailException (toString())
197
+
198
+ 17056L , // AuthErrorCode.captchaCheckFailed
199
+ 17042L , // AuthErrorCode.invalidPhoneNumber
200
+ 17041L , // AuthErrorCode.missingPhoneNumber
201
+ 17046L , // AuthErrorCode.invalidVerificationID
202
+ 17044L , // AuthErrorCode.invalidVerificationCode
203
+ 17045L , // AuthErrorCode.missingVerificationID
204
+ 17043L , // AuthErrorCode.missingVerificationCode
205
+ 17021L , // AuthErrorCode.userTokenExpired
206
+ 17004L , // AuthErrorCode.invalidCredential
203
207
-> FirebaseAuthInvalidCredentialsException (toString())
204
208
205
- FIRAuthErrorCodeWeakPassword -> FirebaseAuthWeakPasswordException (toString())
209
+ 17026L , // AuthErrorCode.weakPassword
210
+ -> FirebaseAuthWeakPasswordException (toString())
206
211
207
- FIRAuthErrorCodeInvalidUserToken -> FirebaseAuthInvalidUserException (toString())
212
+ 17017L , // AuthErrorCode.invalidUserToken
213
+ -> FirebaseAuthInvalidUserException (toString())
208
214
209
- FIRAuthErrorCodeRequiresRecentLogin -> FirebaseAuthRecentLoginRequiredException (toString())
215
+ 17014L , // AuthErrorCode.requiresRecentLogin
216
+ -> FirebaseAuthRecentLoginRequiredException (toString())
210
217
211
- FIRAuthErrorCodeSecondFactorAlreadyEnrolled ,
212
- FIRAuthErrorCodeSecondFactorRequired ,
213
- FIRAuthErrorCodeMaximumSecondFactorCountExceeded ,
214
- FIRAuthErrorCodeMultiFactorInfoNotFound ,
218
+ 17087L , // AuthErrorCode.secondFactorAlreadyEnrolled
219
+ 17078L , // AuthErrorCode.secondFactorRequired
220
+ 17088L , // AuthErrorCode.maximumSecondFactorCountExceeded
221
+ 17084L , // AuthErrorCode.multiFactorInfoNotFound
215
222
-> FirebaseAuthMultiFactorException (toString())
216
223
217
- FIRAuthErrorCodeEmailAlreadyInUse ,
218
- FIRAuthErrorCodeAccountExistsWithDifferentCredential ,
219
- FIRAuthErrorCodeCredentialAlreadyInUse ,
224
+ 17007L , // AuthErrorCode.emailAlreadyInUse
225
+ 17012L , // AuthErrorCode.accountExistsWithDifferentCredential
226
+ 17025L , // AuthErrorCode.credentialAlreadyInUse
220
227
-> FirebaseAuthUserCollisionException (toString())
221
228
222
- FIRAuthErrorCodeWebContextAlreadyPresented ,
223
- FIRAuthErrorCodeWebContextCancelled ,
224
- FIRAuthErrorCodeWebInternalError ,
229
+ 17057L , // AuthErrorCode.webContextAlreadyPresented
230
+ 17058L , // AuthErrorCode.webContextCancelled
231
+ 17062L , // AuthErrorCode.webInternalError
225
232
-> FirebaseAuthWebException (toString())
226
233
227
- FIRAuthErrorCodeNetworkError -> FirebaseNetworkException (toString())
234
+ 17020L , // AuthErrorCode.networkError
235
+ -> FirebaseNetworkException (toString())
228
236
229
237
else -> FirebaseAuthException (toString())
230
238
}
0 commit comments