From 9c6392b1b6b92031b42ef2e4d36f4d4cb864c605 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Thu, 28 Dec 2023 16:41:43 -0800 Subject: [PATCH] [auth-swift] Fix a few decode runtime analyze issues --- .../Sources/Swift/AuthProvider/PhoneAuthCredential.swift | 6 +++--- .../Swift/MultiFactor/Phone/PhoneMultiFactorInfo.swift | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/FirebaseAuth/Sources/Swift/AuthProvider/PhoneAuthCredential.swift b/FirebaseAuth/Sources/Swift/AuthProvider/PhoneAuthCredential.swift index 48ff9bf9acb..b5afda96ce7 100644 --- a/FirebaseAuth/Sources/Swift/AuthProvider/PhoneAuthCredential.swift +++ b/FirebaseAuth/Sources/Swift/AuthProvider/PhoneAuthCredential.swift @@ -60,9 +60,9 @@ import Foundation as? String { credentialKind = .verification(verificationID, verificationCode) super.init(provider: PhoneAuthProvider.id) - } else if let temporaryProof = coder.decodeObject(forKey: "temporaryProof") as? String, - let phoneNumber = coder.decodeObject(forKey: "phoneNumber") as? String { - credentialKind = .phoneNumber(phoneNumber, temporaryProof) + } else if let temporaryProof = coder.decodeObject(of: NSString.self, forKey: "temporaryProof"), + let phoneNumber = coder.decodeObject(of: NSString.self, forKey: "phoneNumber") { + credentialKind = .phoneNumber(phoneNumber as String, temporaryProof as String) super.init(provider: PhoneAuthProvider.id) } else { return nil diff --git a/FirebaseAuth/Sources/Swift/MultiFactor/Phone/PhoneMultiFactorInfo.swift b/FirebaseAuth/Sources/Swift/MultiFactor/Phone/PhoneMultiFactorInfo.swift index ef168311feb..7997eade81c 100644 --- a/FirebaseAuth/Sources/Swift/MultiFactor/Phone/PhoneMultiFactorInfo.swift +++ b/FirebaseAuth/Sources/Swift/MultiFactor/Phone/PhoneMultiFactorInfo.swift @@ -55,7 +55,8 @@ import Foundation override public class var supportsSecureCoding: Bool { return secureCodingWorkaround } public required init?(coder: NSCoder) { - guard let phoneNumber = coder.decodeObject(forKey: kPhoneNumberCodingKey) as? NSString else { + guard let phoneNumber = coder.decodeObject(of: NSString.self, + forKey: kPhoneNumberCodingKey) else { return nil } self.phoneNumber = phoneNumber as String