Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions FirebaseAuth/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Unreleased
- [fixed] Updated most decoders to be consistent with Firebase 10's behavior
for decoding `nil` values. (#14212)

# 11.6.0
- [added] Added reCAPTCHA Enterprise support for app verification during phone
authentication for Firebase Authentication (#14114)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRFacebookAuthCredential) class FacebookAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
let accessToken: String
let accessToken: String?

init(withAccessToken accessToken: String) {
self.accessToken = accessToken
Expand All @@ -56,11 +56,7 @@ import Foundation
}

required init?(coder: NSCoder) {
guard let accessToken = coder.decodeObject(of: NSString.self, forKey: "accessToken") as? String
else {
return nil
}
self.accessToken = accessToken
accessToken = coder.decodeObject(of: NSString.self, forKey: "accessToken") as String?
super.init(provider: FacebookAuthProvider.id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGameCenterAuthCredential)
class GameCenterAuthCredential: AuthCredential, NSSecureCoding, @unchecked Sendable {
let playerID: String
let playerID: String?
let teamPlayerID: String?
let gamePlayerID: String?
let publicKeyURL: URL?
let signature: Data?
let salt: Data?
let timestamp: UInt64
let displayName: String
let timestamp: UInt64?
let displayName: String?

/// - Parameter playerID: The ID of the Game Center local player.
/// - Parameter teamPlayerID: The teamPlayerID of the Game Center local player.
Expand Down Expand Up @@ -177,27 +177,20 @@
}

required init?(coder: NSCoder) {
guard let playerID = coder.decodeObject(of: NSString.self, forKey: "playerID") as? String,
let teamPlayerID = coder.decodeObject(
of: NSString.self,
forKey: "teamPlayerID"
) as? String,
let gamePlayerID = coder.decodeObject(
of: NSString.self,
forKey: "gamePlayerID"
) as? String,
let timestamp = coder.decodeObject(of: NSNumber.self, forKey: "timestamp") as? UInt64,
let displayName = coder.decodeObject(
of: NSString.self,
forKey: "displayName"
) as? String else {
return nil
}
self.playerID = playerID
self.teamPlayerID = teamPlayerID
self.gamePlayerID = gamePlayerID
self.timestamp = timestamp
self.displayName = displayName
playerID = coder.decodeObject(of: NSString.self, forKey: "playerID") as String?
teamPlayerID = coder.decodeObject(
of: NSString.self,
forKey: "teamPlayerID"
) as String?
gamePlayerID = coder.decodeObject(
of: NSString.self,
forKey: "gamePlayerID"
) as String?
timestamp = coder.decodeObject(of: NSNumber.self, forKey: "timestamp") as? UInt64
displayName = coder.decodeObject(
of: NSString.self,
forKey: "displayName"
) as String?
publicKeyURL = coder.decodeObject(forKey: "publicKeyURL") as? URL
signature = coder.decodeObject(of: NSData.self, forKey: "signature") as? Data
salt = coder.decodeObject(of: NSData.self, forKey: "salt") as? Data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGitHubAuthCredential) class GitHubAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
let token: String
let token: String?

init(withToken token: String) {
self.token = token
Expand All @@ -56,10 +56,7 @@ import Foundation
}

required init?(coder: NSCoder) {
guard let token = coder.decodeObject(of: NSString.self, forKey: "token") as? String else {
return nil
}
self.token = token
token = coder.decodeObject(of: NSString.self, forKey: "token") as String?
super.init(provider: GitHubAuthProvider.id)
}
}
13 changes: 4 additions & 9 deletions FirebaseAuth/Sources/Swift/AuthProvider/GoogleAuthProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRGoogleAuthCredential) class GoogleAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
let idToken: String
let accessToken: String
let idToken: String?
let accessToken: String?

init(withIDToken idToken: String, accessToken: String) {
self.idToken = idToken
Expand All @@ -62,13 +62,8 @@ import Foundation
}

required init?(coder: NSCoder) {
guard let idToken = coder.decodeObject(of: NSString.self, forKey: "idToken") as? String,
let accessToken = coder.decodeObject(of: NSString.self, forKey: "accessToken") as? String
else {
return nil
}
self.idToken = idToken
self.accessToken = accessToken
idToken = coder.decodeObject(of: NSString.self, forKey: "idToken") as String?
accessToken = coder.decodeObject(of: NSString.self, forKey: "accessToken") as String?
super.init(provider: GoogleAuthProvider.id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import Foundation
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRTwitterAuthCredential) class TwitterAuthCredential: AuthCredential, NSSecureCoding,
@unchecked Sendable {
let token: String
let secret: String
let token: String?
let secret: String?

init(withToken token: String, secret: String) {
self.token = token
Expand All @@ -61,12 +61,8 @@ import Foundation
}

required init?(coder: NSCoder) {
guard let token = coder.decodeObject(of: NSString.self, forKey: "token") as? String,
let secret = coder.decodeObject(of: NSString.self, forKey: "secret") as? String else {
return nil
}
self.token = token
self.secret = secret
token = coder.decodeObject(of: NSString.self, forKey: "token") as String?
secret = coder.decodeObject(of: NSString.self, forKey: "secret") as String?
super.init(provider: TwitterAuthProvider.id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SignInWithGameCenterRequest: IdentityToolkitRequest, AuthRPCRequest {
typealias Response = SignInWithGameCenterResponse

/// The playerID to verify.
var playerID: String
var playerID: String?

/// The team player ID of the Game Center local player.
var teamPlayerID: String?
Expand All @@ -40,7 +40,7 @@ class SignInWithGameCenterRequest: IdentityToolkitRequest, AuthRPCRequest {
var salt: Data

/// The date and time that the signature was created.
var timestamp: UInt64
var timestamp: UInt64?

/// The STS Access Token for the authenticated user, only needed for linking the user.
var accessToken: String?
Expand All @@ -57,10 +57,10 @@ class SignInWithGameCenterRequest: IdentityToolkitRequest, AuthRPCRequest {
/// - Parameter salt: A random string used to compute the hash and keep it randomized.
/// - Parameter timestamp: The date and time that the signature was created.
/// - Parameter displayName: The display name of the Game Center player.
init(playerID: String, teamPlayerID: String?, gamePlayerID: String?,
init(playerID: String?, teamPlayerID: String?, gamePlayerID: String?,
publicKeyURL: URL,
signature: Data, salt: Data,
timestamp: UInt64, displayName: String?,
timestamp: UInt64?, displayName: String?,
requestConfiguration: AuthRequestConfiguration) {
self.playerID = playerID
self.teamPlayerID = teamPlayerID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import Foundation
return .init(idToken: currentUser.tokenService.accessToken, currentUser: currentUser)
}

init(idToken: String, currentUser: User) {
init(idToken: String?, currentUser: User) {
self.idToken = idToken
self.currentUser = currentUser
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class SecureTokenService: NSObject, NSSecureCoding {

/// The cached access token.
///
/// This method is specifically for providing the access token to internal clients during
/// This method is specifically for providing the access token to internal clients during
/// deserialization and sign-in events, and should not be used to retrieve the access token by
/// anyone else.
var accessToken: String
Expand Down
Loading