From 49eb177e8ca24d8dcaead52052870bb15078ebb4 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Thu, 28 Dec 2023 08:15:46 -0800 Subject: [PATCH] More review --- .../Backend/RPC/EmailLinkSignInResponse.swift | 18 ++++++------------ .../Backend/RPC/VerifyAssertionResponse.swift | 18 ++++++------------ .../Backend/RPC/VerifyPasswordResponse.swift | 18 ++++++------------ 3 files changed, 18 insertions(+), 36 deletions(-) diff --git a/FirebaseAuth/Sources/Swift/Backend/RPC/EmailLinkSignInResponse.swift b/FirebaseAuth/Sources/Swift/Backend/RPC/EmailLinkSignInResponse.swift index 644cca73b14..f41d0bde732 100644 --- a/FirebaseAuth/Sources/Swift/Backend/RPC/EmailLinkSignInResponse.swift +++ b/FirebaseAuth/Sources/Swift/Backend/RPC/EmailLinkSignInResponse.swift @@ -23,7 +23,7 @@ class EmailLinkSignInResponse: NSObject, AuthRPCResponse, AuthMFAResponse { /** @property IDToken @brief The ID token in the email link sign-in response. */ - private var _idToken: String? + private(set) var idToken: String? /** @property email @brief The email returned by the IdP. @@ -47,26 +47,20 @@ class EmailLinkSignInResponse: NSObject, AuthRPCResponse, AuthMFAResponse { // MARK: - AuthMFAResponse - var mfaPendingCredential: String? { return _mfaPendingCredential } - - var mfaInfo: [AuthProtoMFAEnrollment]? { return _mfaInfo } - - var idToken: String? { return _idToken } - /** @property MFAPendingCredential @brief An opaque string that functions as proof that the user has successfully passed the first factor check. */ - private var _mfaPendingCredential: String? + private(set) var mfaPendingCredential: String? /** @property MFAInfo @brief Info on which multi-factor authentication providers are enabled. */ - private var _mfaInfo: [AuthProtoMFAEnrollment]? + private(set) var mfaInfo: [AuthProtoMFAEnrollment]? func setFields(dictionary: [String: AnyHashable]) throws { email = dictionary["email"] as? String - _idToken = dictionary["idToken"] as? String + idToken = dictionary["idToken"] as? String isNewUser = dictionary["isNewUser"] as? Bool ?? false refreshToken = dictionary["refreshToken"] as? String @@ -80,8 +74,8 @@ class EmailLinkSignInResponse: NSObject, AuthRPCResponse, AuthMFAResponse { let enrollment = AuthProtoMFAEnrollment(dictionary: entry) mfaInfo.append(enrollment) } - _mfaInfo = mfaInfo + self.mfaInfo = mfaInfo } - _mfaPendingCredential = dictionary["mfaPendingCredential"] as? String + mfaPendingCredential = dictionary["mfaPendingCredential"] as? String } } diff --git a/FirebaseAuth/Sources/Swift/Backend/RPC/VerifyAssertionResponse.swift b/FirebaseAuth/Sources/Swift/Backend/RPC/VerifyAssertionResponse.swift index 5b308c5610b..b8610028df5 100644 --- a/FirebaseAuth/Sources/Swift/Backend/RPC/VerifyAssertionResponse.swift +++ b/FirebaseAuth/Sources/Swift/Backend/RPC/VerifyAssertionResponse.swift @@ -97,7 +97,7 @@ class VerifyAssertionResponse: AuthRPCResponse, AuthMFAResponse { access token from Secure Token Service, depending on whether @c returnSecureToken is set on the request. */ - private var _idToken: String? + private(set) var idToken: String? /** @property approximateExpirationDate @brief The approximate expiration date of the access token. @@ -203,15 +203,9 @@ class VerifyAssertionResponse: AuthRPCResponse, AuthMFAResponse { // MARK: - AuthMFAResponse - var mfaPendingCredential: String? { return _mfaPendingCredential } + private(set) var mfaPendingCredential: String? - var mfaInfo: [AuthProtoMFAEnrollment]? { return _mfaInfo } - - var idToken: String? { return _idToken } - - private var _mfaPendingCredential: String? - - private var _mfaInfo: [AuthProtoMFAEnrollment]? + private(set) var mfaInfo: [AuthProtoMFAEnrollment]? func setFields(dictionary: [String: AnyHashable]) throws { federatedID = dictionary["federatedId"] as? String @@ -229,7 +223,7 @@ class VerifyAssertionResponse: AuthRPCResponse, AuthMFAResponse { fullName = dictionary["fullName"] as? String nickName = dictionary["nickName"] as? String displayName = dictionary["displayName"] as? String - _idToken = dictionary["idToken"] as? String + idToken = dictionary["idToken"] as? String if let expiresIn = dictionary["expiresIn"] as? String { approximateExpirationDate = Date(timeIntervalSinceNow: (expiresIn as NSString) .doubleValue) @@ -275,10 +269,10 @@ class VerifyAssertionResponse: AuthRPCResponse, AuthMFAResponse { pendingToken = dictionary["pendingToken"] as? String if let mfaInfoDicts = dictionary["mfaInfo"] as? [[String: AnyHashable]] { - _mfaInfo = mfaInfoDicts.map { + mfaInfo = mfaInfoDicts.map { AuthProtoMFAEnrollment(dictionary: $0) } } - _mfaPendingCredential = dictionary["mfaPendingCredential"] as? String + mfaPendingCredential = dictionary["mfaPendingCredential"] as? String } } diff --git a/FirebaseAuth/Sources/Swift/Backend/RPC/VerifyPasswordResponse.swift b/FirebaseAuth/Sources/Swift/Backend/RPC/VerifyPasswordResponse.swift index cdf7de6e6d2..8a5e03262c6 100644 --- a/FirebaseAuth/Sources/Swift/Backend/RPC/VerifyPasswordResponse.swift +++ b/FirebaseAuth/Sources/Swift/Backend/RPC/VerifyPasswordResponse.swift @@ -45,7 +45,7 @@ class VerifyPasswordResponse: AuthRPCResponse, AuthMFAResponse { access token from Secure Token Service, depending on whether @c returnSecureToken is set on the request. */ - private var _idToken: String? + private(set) var idToken: String? /** @property approximateExpirationDate @brief The approximate expiration date of the access token. @@ -64,21 +64,15 @@ class VerifyPasswordResponse: AuthRPCResponse, AuthMFAResponse { // MARK: - AuthMFAResponse - var mfaPendingCredential: String? { return _mfaPendingCredential } + private(set) var mfaPendingCredential: String? - var mfaInfo: [AuthProtoMFAEnrollment]? { return _mfaInfo } - - var idToken: String? { return _idToken } - - private var _mfaPendingCredential: String? - - private var _mfaInfo: [AuthProtoMFAEnrollment]? + private(set) var mfaInfo: [AuthProtoMFAEnrollment]? func setFields(dictionary: [String: AnyHashable]) throws { localID = dictionary["localId"] as? String email = dictionary["email"] as? String displayName = dictionary["displayName"] as? String - _idToken = dictionary["idToken"] as? String + idToken = dictionary["idToken"] as? String if let expiresIn = dictionary["expiresIn"] as? String { approximateExpirationDate = Date(timeIntervalSinceNow: (expiresIn as NSString) .doubleValue) @@ -87,8 +81,8 @@ class VerifyPasswordResponse: AuthRPCResponse, AuthMFAResponse { photoURL = (dictionary["photoUrl"] as? String).flatMap { URL(string: $0) } if let mfaInfo = dictionary["mfaInfo"] as? [[String: AnyHashable]] { - _mfaInfo = mfaInfo.map { AuthProtoMFAEnrollment(dictionary: $0) } + self.mfaInfo = mfaInfo.map { AuthProtoMFAEnrollment(dictionary: $0) } } - _mfaPendingCredential = dictionary["mfaPendingCredential"] as? String + mfaPendingCredential = dictionary["mfaPendingCredential"] as? String } }