Skip to content

Commit

Permalink
[auth-swift] Remove extra publics (#12097)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored Nov 13, 2023
1 parent 051cc6e commit 9a3ea6f
Show file tree
Hide file tree
Showing 29 changed files with 82 additions and 89 deletions.
2 changes: 1 addition & 1 deletion FirebaseAuth/Sources/Swift/Auth/AuthComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import FirebaseCore
import FirebaseCoreExtension

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
@objc(FIRAuthProvider) public protocol AuthProvider {
@objc(FIRAuthProvider) protocol AuthProvider {
@objc func auth() -> Auth
}

Expand Down
2 changes: 1 addition & 1 deletion FirebaseAuth/Sources/Swift/Auth/AuthOperationType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Foundation
@brief Indicates the type of operation performed for RPCs that support the operation
parameter.
*/
@objc(FIRAuthOperationType) public enum AuthOperationType: Int {
enum AuthOperationType: Int {
/** Indicates that the operation type is uspecified.
*/
case unspecified = 0
Expand Down
9 changes: 4 additions & 5 deletions FirebaseAuth/Sources/Swift/Auth/AuthSerialTaskQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@

import Foundation

typealias FIRAuthSerialTaskCompletionBlock = () -> Void
typealias FIRAuthSerialTask = (_ complete: @escaping FIRAuthSerialTaskCompletionBlock)
-> Void
typealias AuthSerialTaskCompletionBlock = () -> Void

class AuthSerialTaskQueue: NSObject {
private let dispatchQueue: DispatchQueue

@objc override public init() {
override init() {
dispatchQueue = DispatchQueue(
label: "com.google.firebase.auth.serialTaskQueue",
target: kAuthGlobalWorkQueue
)
super.init()
}

func enqueueTask(_ task: @escaping FIRAuthSerialTask) {
func enqueueTask(_ task: @escaping ((_ complete: @escaping AuthSerialTaskCompletionBlock)
-> Void)) {
dispatchQueue.async {
self.dispatchQueue.suspend()
task {
Expand Down
4 changes: 2 additions & 2 deletions FirebaseAuth/Sources/Swift/Backend/AuthRPCResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Foundation

public protocol AuthRPCResponse {
protocol AuthRPCResponse {
/// Bare initializer for a response.
init()

Expand All @@ -36,7 +36,7 @@ public protocol AuthRPCResponse {
func clientError(shortErrorMessage: String, detailedErrorMessage: String?) -> Error?
}

public extension AuthRPCResponse {
extension AuthRPCResponse {
// Default implementation.
func clientError(shortErrorMessage: String, detailedErrorMessage: String? = nil) -> Error? {
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,41 @@ import Foundation
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/createAuthUri
*/

public class CreateAuthURIResponse: AuthRPCResponse {
class CreateAuthURIResponse: AuthRPCResponse {
/** @property authUri
@brief The URI used by the IDP to authenticate the user.
*/
public var authURI: String?
var authURI: String?

/** @property registered
@brief Whether the user is registered if the identifier is an email.
*/
public var registered: Bool = false
var registered: Bool = false

/** @property providerId
@brief The provider ID of the auth URI.
*/
public var providerID: String?
var providerID: String?

/** @property forExistingProvider
@brief True if the authUri is for user's existing provider.
*/
public var forExistingProvider: Bool = false
var forExistingProvider: Bool = false

/** @property allProviders
@brief A list of provider IDs the passed @c identifier could use to sign in with.
*/
public var allProviders: [String]?
var allProviders: [String]?

/** @property signinMethods
@brief A list of sign-in methods available for the passed @c identifier.
*/
public var signinMethods: [String]?
var signinMethods: [String]?

/// Bare initializer.
public required init() {}
required init() {}

public func setFields(dictionary: [String: AnyHashable]) throws {
func setFields(dictionary: [String: AnyHashable]) throws {
providerID = dictionary["providerId"] as? String
authURI = dictionary["authUri"] as? String
registered = dictionary["registered"] as? Bool ?? false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import Foundation
@brief Represents the response from the deleteAccount endpoint.
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/deleteAccount
*/
public class DeleteAccountResponse: NSObject, AuthRPCResponse {
override public required init() {}
class DeleteAccountResponse: NSObject, AuthRPCResponse {
override required init() {}

public func setFields(dictionary: [String: AnyHashable]) throws {}
func setFields(dictionary: [String: AnyHashable]) throws {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Foundation
@brief Represents the response from the emailLinkSignin endpoint.
*/
class EmailLinkSignInResponse: NSObject, AuthRPCResponse {
override public required init() {}
override required init() {}

/** @property IDToken
@brief The ID token in the email link sign-in response.
Expand Down Expand Up @@ -56,7 +56,7 @@ class EmailLinkSignInResponse: NSObject, AuthRPCResponse {
*/
var mfaInfo: [AuthProtoMFAEnrollment]?

public func setFields(dictionary: [String: AnyHashable]) throws {
func setFields(dictionary: [String: AnyHashable]) throws {
email = dictionary["email"] as? String
idToken = dictionary["idToken"] as? String
isNewUser = dictionary["isNewUser"] as? Bool ?? false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class GetAccountInfoResponseUser: NSObject {
*/
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class GetAccountInfoResponse: AuthRPCResponse {
public required init() {}
required init() {}

/** @property providerUserInfo
@brief The requested users' profiles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class FinalizeMFAEnrollmentRequest: IdentityToolkitRequest, AuthRPCRequest {
)
}

public func unencodedHTTPRequestBody() throws -> [String: AnyHashable] {
func unencodedHTTPRequestBody() throws -> [String: AnyHashable] {
var body: [String: AnyHashable] = [:]
if let idToken = idToken {
body["idToken"] = idToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Foundation

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
class FinalizeMFAEnrollmentResponse: AuthRPCResponse {
public required init() {}
required init() {}

private(set) var idToken: String?
private(set) var refreshToken: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class WithdrawMFAResponse: AuthRPCResponse {
var idToken: String?
var refreshToken: String?

public func setFields(dictionary: [String: AnyHashable]) throws {
func setFields(dictionary: [String: AnyHashable]) throws {
idToken = dictionary["idToken"] as? String
refreshToken = dictionary["refreshToken"] as? String
}
Expand Down
4 changes: 2 additions & 2 deletions FirebaseAuth/Sources/Swift/Backend/RPC/Proto/AuthProto.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Foundation

@objc(FIRAuthProto) public protocol AuthProto: NSObjectProtocol {
@objc init(dictionary: [String: AnyHashable])
@objc protocol AuthProto: NSObjectProtocol {
init(dictionary: [String: AnyHashable])
@objc optional var dictionary: [String: AnyHashable] { get }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AuthProtoMFAEnrollment: NSObject, AuthProto {
let displayName: String?
let enrolledAt: Date?

public required init(dictionary: [String: AnyHashable]) {
required init(dictionary: [String: AnyHashable]) {
phoneInfo = dictionary["phoneInfo"] as? String
totpInfo = dictionary["totpInfo"] as? NSObject
mfaEnrollmentID = dictionary["mfaEnrollmentId"] as? String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AuthProtoFinalizeMFAPhoneRequestInfo: NSObject, AuthProto {

var sessionInfo: String?
var code: String?
@objc public init(sessionInfo: String?, verificationCode: String?) {
init(sessionInfo: String?, verificationCode: String?) {
self.sessionInfo = sessionInfo
code = verificationCode
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import Foundation

class AuthProtoStartMFATOTPEnrollmentRequestInfo: NSObject, AuthProto {
public required init(dictionary: [String: AnyHashable]) {
required init(dictionary: [String: AnyHashable]) {
fatalError()
}

Expand Down
22 changes: 11 additions & 11 deletions FirebaseAuth/Sources/Swift/Backend/RPC/SecureTokenRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import Foundation

@objc(FIRSecureTokenRequestGrantType) enum SecureTokenRequestGrantType: Int {
enum SecureTokenRequestGrantType: Int {
case authorizationCode
case refreshToken

Expand Down Expand Up @@ -96,7 +96,7 @@ class SecureTokenRequest: AuthRPCRequest {
/** @property refreshToken
@brief The client's refresh token.
*/
public var refreshToken: String?
var refreshToken: String?

/** @property code
@brief The client's authorization code (legacy Gitkit "ID Token").
Expand All @@ -106,15 +106,15 @@ class SecureTokenRequest: AuthRPCRequest {
/** @property APIKey
@brief The client's API Key.
*/
public let apiKey: String
let apiKey: String

let _requestConfiguration: AuthRequestConfiguration
public func requestConfiguration() -> AuthRequestConfiguration {
func requestConfiguration() -> AuthRequestConfiguration {
_requestConfiguration
}

public static func authCodeRequest(code: String,
requestConfiguration: AuthRequestConfiguration)
static func authCodeRequest(code: String,
requestConfiguration: AuthRequestConfiguration)
-> SecureTokenRequest {
SecureTokenRequest(
grantType: .authorizationCode,
Expand All @@ -125,8 +125,8 @@ class SecureTokenRequest: AuthRPCRequest {
)
}

public static func refreshRequest(refreshToken: String,
requestConfiguration: AuthRequestConfiguration)
static func refreshRequest(refreshToken: String,
requestConfiguration: AuthRequestConfiguration)
-> SecureTokenRequest {
SecureTokenRequest(
grantType: .refreshToken,
Expand All @@ -147,7 +147,7 @@ class SecureTokenRequest: AuthRPCRequest {
_requestConfiguration = requestConfiguration
}

public func requestURL() -> URL {
func requestURL() -> URL {
let urlString: String
if let emulatorHostAndPort = _requestConfiguration.emulatorHostAndPort {
urlString = "http://\(emulatorHostAndPort)/\(gAPIHost)/v1/token?key=\(apiKey)"
Expand All @@ -157,9 +157,9 @@ class SecureTokenRequest: AuthRPCRequest {
return URL(string: urlString)!
}

public func containsPostBody() -> Bool { true }
func containsPostBody() -> Bool { true }

public func unencodedHTTPRequestBody() throws -> [String: AnyHashable] {
func unencodedHTTPRequestBody() throws -> [String: AnyHashable] {
var postBody: [String: AnyHashable] = [
kGrantTypeKey: grantType.value,
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,27 @@ import Foundation
@brief Represents the provider user info part of the response from the setAccountInfo endpoint.
@see https://developers.google.com/identity/toolkit/web/reference/relyingparty/setAccountInfo
*/
@objc(FIRSetAccountInfoResponseProviderUserInfo)
public class SetAccountInfoResponseProviderUserInfo: NSObject {
class SetAccountInfoResponseProviderUserInfo: NSObject {
/** @property providerID
@brief The ID of the identity provider.
*/
@objc public var providerID: String?
var providerID: String?

/** @property displayName
@brief The user's display name at the identity provider.
*/
@objc public var displayName: String?
var displayName: String?

/** @property photoURL
@brief The user's photo URL at the identity provider.
*/
@objc public var photoURL: URL?
var photoURL: URL?

/** @fn initWithAPIKey:
@brief Designated initializer.
@param dictionary The provider user info data from endpoint.
*/
@objc public init(dictionary: [String: Any]) {
init(dictionary: [String: Any]) {
providerID = dictionary["providerId"] as? String
displayName = dictionary["displayName"] as? String
if let photoURL = dictionary["photoUrl"] as? String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class VerifyAssertionResponse: AuthRPCResponse {
access token from Secure Token Service, depending on whether @c returnSecureToken is set
on the request.
*/
@objc(IDToken) var idToken: String?
var idToken: String?

/** @property approximateExpirationDate
@brief The approximate expiration date of the access token.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Foundation
}

@available(*, unavailable)
public required init?(coder: NSCoder) {
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Expand Down
10 changes: 4 additions & 6 deletions FirebaseAuth/Sources/Swift/SystemService/AuthAPNSToken.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
#if !os(macOS)
import Foundation

// TODO: Eliminate objc public after Sample app port.

/** @class AuthAPNSToken
@brief A data structure for an APNs token.
*/
@objc(FIRAuthAPNSToken) public class AuthAPNSToken: NSObject {
@objc public let data: Data
@objc public let type: AuthAPNSTokenType
class AuthAPNSToken: NSObject {
let data: Data
let type: AuthAPNSTokenType

/** @fn initWithData:type:
@brief Initializes the instance.
Expand All @@ -38,7 +36,7 @@
/** @property string
@brief The uppercase hexadecimal string form of the APNs token data.
*/
@objc public lazy var string: String = {
lazy var string: String = {
let byteArray = [UInt8](data)
var s = ""
for byte in byteArray {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#endif // SWIFT_PACKAGE

// Protocol to help with unit tests.
public protocol AuthAPNSTokenApplication {
protocol AuthAPNSTokenApplication {
func registerForRemoteNotifications()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
@param notification The notification in question.
@return Whether or the notification has been handled.
*/
@objc(canHandleNotification:) public func canHandle(notification: [AnyHashable: Any]) -> Bool {
func canHandle(notification: [AnyHashable: Any]) -> Bool {
var stringDictionary: [String: Any]?
let data = notification[kNotificationDataKey]
if let jsonString = data as? String {
Expand Down
Loading

0 comments on commit 9a3ea6f

Please sign in to comment.