@@ -32,7 +32,7 @@ public actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth(
32
32
public actual class FirebaseAuth internal constructor(internal val ios : FIRAuth ) {
33
33
34
34
public actual val currentUser: FirebaseUser ?
35
- get() = ios.currentUser?.let { FirebaseUser (it) }
35
+ get() = ios.currentUser() ?.let { FirebaseUser (it) }
36
36
37
37
public actual val authStateChanged: Flow <FirebaseUser ?> get() = callbackFlow {
38
38
val handle = ios.addAuthStateDidChangeListener { _, user -> trySend(user?.let { FirebaseUser (it) }) }
@@ -45,7 +45,7 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth)
45
45
}
46
46
47
47
public actual var languageCode: String
48
- get() = ios.languageCode ? : " "
48
+ get() = ios.languageCode() ? : " "
49
49
set(value) {
50
50
ios.setLanguageCode(value)
51
51
}
@@ -91,15 +91,15 @@ public actual class FirebaseAuth internal constructor(internal val ios: FIRAuth)
91
91
public actual suspend fun <T : ActionCodeResult > checkActionCode (code : String ): T {
92
92
val result: FIRActionCodeInfo = ios.awaitResult { checkActionCode(code, it) }
93
93
@Suppress(" UNCHECKED_CAST" )
94
- return when (result.operation) {
94
+ return when (result.operation() ) {
95
95
FIRActionCodeOperationEmailLink -> SignInWithEmailLink
96
- FIRActionCodeOperationVerifyEmail -> VerifyEmail (result.email!! )
97
- FIRActionCodeOperationPasswordReset -> PasswordReset (result.email!! )
98
- FIRActionCodeOperationRecoverEmail -> RecoverEmail (result.email!! , result.previousEmail!! )
99
- FIRActionCodeOperationVerifyAndChangeEmail -> VerifyBeforeChangeEmail (result.email!! , result.previousEmail!! )
100
- FIRActionCodeOperationRevertSecondFactorAddition -> RevertSecondFactorAddition (result.email!! , null )
101
- FIRActionCodeOperationUnknown -> throw UnsupportedOperationException (result.operation.toString())
102
- else -> throw UnsupportedOperationException (result.operation.toString())
96
+ FIRActionCodeOperationVerifyEmail -> VerifyEmail (result.email() )
97
+ FIRActionCodeOperationPasswordReset -> PasswordReset (result.email() )
98
+ FIRActionCodeOperationRecoverEmail -> RecoverEmail (result.email() , result.previousEmail() !! )
99
+ FIRActionCodeOperationVerifyAndChangeEmail -> VerifyBeforeChangeEmail (result.email() , result.previousEmail() !! )
100
+ FIRActionCodeOperationRevertSecondFactorAddition -> RevertSecondFactorAddition (result.email() , null )
101
+ FIRActionCodeOperationUnknown -> throw UnsupportedOperationException (result.operation() .toString())
102
+ else -> throw UnsupportedOperationException (result.operation() .toString())
103
103
} as T
104
104
}
105
105
@@ -110,7 +110,7 @@ public val AuthResult.ios: FIRAuthDataResult get() = ios
110
110
111
111
public actual class AuthResult (internal val ios : FIRAuthDataResult ) {
112
112
public actual val user: FirebaseUser ?
113
- get() = FirebaseUser (ios.user)
113
+ get() = FirebaseUser (ios.user() )
114
114
public actual val credential: AuthCredential ?
115
115
get() = ios.credential?.let { AuthCredential (it) }
116
116
public actual val additionalUserInfo: AdditionalUserInfo ?
@@ -145,23 +145,23 @@ public actual class AuthTokenResult(internal val ios: FIRAuthTokenResult) {
145
145
// actual val authTimestamp: Long
146
146
// get() = ios.authDate
147
147
public actual val claims: Map <String , Any >
148
- get() = ios.claims.map { it.key.toString() to it.value as Any }.toMap()
148
+ get() = ios.claims() .map { it.key.toString() to it.value as Any }.toMap()
149
149
150
150
// actual val expirationTimestamp: Long
151
151
// get() = ios.expirationDate
152
152
// actual val issuedAtTimestamp: Long
153
153
// get() = ios.issuedAtDate
154
154
public actual val signInProvider: String?
155
- get() = ios.signInProvider
155
+ get() = ios.signInProvider()
156
156
public actual val token: String?
157
- get() = ios.token
157
+ get() = ios.token()
158
158
}
159
159
160
160
internal fun ActionCodeSettings.toIos () = FIRActionCodeSettings ().also {
161
- it.URL = NSURL .URLWithString (url)
161
+ it.setURL( NSURL .URLWithString (url) )
162
162
androidPackageName?.run { it.setAndroidPackageName(packageName, installIfNotAvailable, minimumVersion) }
163
- it.dynamicLinkDomain = dynamicLinkDomain
164
- it.handleCodeInApp = canHandleCodeInApp
163
+ it.setDynamicLinkDomain( dynamicLinkDomain)
164
+ it.setHandleCodeInApp( canHandleCodeInApp)
165
165
iOSBundleId?.run { it.setIOSBundleID(this ) }
166
166
}
167
167
@@ -213,47 +213,55 @@ internal suspend inline fun <T> T.await(function: T.(callback: (NSError?) -> Uni
213
213
}
214
214
215
215
private fun NSError.toException () = when (domain) {
216
+ // codes from AuthErrors.swift: https://github.com/firebase/firebase-ios-sdk/blob/
217
+ // 2f6ac4c2c61cd57c7ea727009e187b7e1163d613/FirebaseAuth/Sources/Swift/Utilities/
218
+ // AuthErrors.swift#L51
216
219
FIRAuthErrorDomain -> when (code) {
217
- FIRAuthErrorCodeInvalidActionCode ,
218
- FIRAuthErrorCodeExpiredActionCode ,
220
+ 17030L , // AuthErrorCode.invalidActionCode
221
+ 17029L , // AuthErrorCode.expiredActionCode
219
222
-> FirebaseAuthActionCodeException (toString())
220
223
221
- FIRAuthErrorCodeInvalidEmail -> FirebaseAuthEmailException (toString())
222
-
223
- FIRAuthErrorCodeCaptchaCheckFailed ,
224
- FIRAuthErrorCodeInvalidPhoneNumber ,
225
- FIRAuthErrorCodeMissingPhoneNumber ,
226
- FIRAuthErrorCodeInvalidVerificationID ,
227
- FIRAuthErrorCodeInvalidVerificationCode ,
228
- FIRAuthErrorCodeMissingVerificationID ,
229
- FIRAuthErrorCodeMissingVerificationCode ,
230
- FIRAuthErrorCodeUserTokenExpired ,
231
- FIRAuthErrorCodeInvalidCredential ,
224
+ 17008L , // AuthErrorCode.invalidEmail
225
+ -> FirebaseAuthEmailException (toString())
226
+
227
+ 17056L , // AuthErrorCode.captchaCheckFailed
228
+ 17042L , // AuthErrorCode.invalidPhoneNumber
229
+ 17041L , // AuthErrorCode.missingPhoneNumber
230
+ 17046L , // AuthErrorCode.invalidVerificationID
231
+ 17044L , // AuthErrorCode.invalidVerificationCode
232
+ 17045L , // AuthErrorCode.missingVerificationID
233
+ 17043L , // AuthErrorCode.missingVerificationCode
234
+ 17021L , // AuthErrorCode.userTokenExpired
235
+ 17004L , // AuthErrorCode.invalidCredential
232
236
-> FirebaseAuthInvalidCredentialsException (toString())
233
237
234
- FIRAuthErrorCodeWeakPassword -> FirebaseAuthWeakPasswordException (toString())
238
+ 17026L , // AuthErrorCode.weakPassword
239
+ -> FirebaseAuthWeakPasswordException (toString())
235
240
236
- FIRAuthErrorCodeInvalidUserToken -> FirebaseAuthInvalidUserException (toString())
241
+ 17017L , // AuthErrorCode.invalidUserToken
242
+ -> FirebaseAuthInvalidUserException (toString())
237
243
238
- FIRAuthErrorCodeRequiresRecentLogin -> FirebaseAuthRecentLoginRequiredException (toString())
244
+ 17014L , // AuthErrorCode.requiresRecentLogin
245
+ -> FirebaseAuthRecentLoginRequiredException (toString())
239
246
240
- FIRAuthErrorCodeSecondFactorAlreadyEnrolled ,
241
- FIRAuthErrorCodeSecondFactorRequired ,
242
- FIRAuthErrorCodeMaximumSecondFactorCountExceeded ,
243
- FIRAuthErrorCodeMultiFactorInfoNotFound ,
247
+ 17087L , // AuthErrorCode.secondFactorAlreadyEnrolled
248
+ 17078L , // AuthErrorCode.secondFactorRequired
249
+ 17088L , // AuthErrorCode.maximumSecondFactorCountExceeded
250
+ 17084L , // AuthErrorCode.multiFactorInfoNotFound
244
251
-> FirebaseAuthMultiFactorException (toString())
245
252
246
- FIRAuthErrorCodeEmailAlreadyInUse ,
247
- FIRAuthErrorCodeAccountExistsWithDifferentCredential ,
248
- FIRAuthErrorCodeCredentialAlreadyInUse ,
253
+ 17007L , // AuthErrorCode.emailAlreadyInUse
254
+ 17012L , // AuthErrorCode.accountExistsWithDifferentCredential
255
+ 17025L , // AuthErrorCode.credentialAlreadyInUse
249
256
-> FirebaseAuthUserCollisionException (toString())
250
257
251
- FIRAuthErrorCodeWebContextAlreadyPresented ,
252
- FIRAuthErrorCodeWebContextCancelled ,
253
- FIRAuthErrorCodeWebInternalError ,
258
+ 17057L , // AuthErrorCode.webContextAlreadyPresented
259
+ 17058L , // AuthErrorCode.webContextCancelled
260
+ 17062L , // AuthErrorCode.webInternalError
254
261
-> FirebaseAuthWebException (toString())
255
262
256
- FIRAuthErrorCodeNetworkError -> FirebaseNetworkException (toString())
263
+ 17020L , // AuthErrorCode.networkError
264
+ -> FirebaseNetworkException (toString())
257
265
258
266
else -> FirebaseAuthException (toString())
259
267
}
0 commit comments