Skip to content

Commit

Permalink
[auth-swift] post to call rename (#11918)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulb777 authored Oct 10, 2023
1 parent f964d34 commit 6b997d7
Show file tree
Hide file tree
Showing 30 changed files with 97 additions and 97 deletions.
24 changes: 12 additions & 12 deletions FirebaseAuth/Sources/Swift/Auth/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ extension Auth: AuthInterop {
requestConfiguration: self.requestConfiguration)
Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
Auth.wrapMainAsync(callback: completion, withParam: response.signinMethods, error: nil)
} catch {
Auth.wrapMainAsync(callback: completion, withParam: nil, error: error)
Expand Down Expand Up @@ -386,7 +386,7 @@ extension Auth: AuthInterop {
if request.password.count == 0 {
throw AuthErrorUtils.wrongPasswordError(message: nil)
}
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
return try await completeSignIn(withAccessToken: response.idToken,
accessTokenExpirationDate: response
.approximateExpirationDate,
Expand Down Expand Up @@ -766,7 +766,7 @@ extension Auth: AuthInterop {
let request = SignUpNewUserRequest(requestConfiguration: self.requestConfiguration)
Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
let user = try await self.completeSignIn(
withAccessToken: response.idToken,
accessTokenExpirationDate: response.approximateExpirationDate,
Expand Down Expand Up @@ -838,7 +838,7 @@ extension Auth: AuthInterop {
requestConfiguration: self.requestConfiguration)
Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
let user = try await self.completeSignIn(
withAccessToken: response.idToken,
accessTokenExpirationDate: response.approximateExpirationDate,
Expand Down Expand Up @@ -934,7 +934,7 @@ extension Auth: AuthInterop {
requestConfiguration: self.requestConfiguration)
Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
let user = try await self.completeSignIn(
withAccessToken: response.idToken,
accessTokenExpirationDate: response.approximateExpirationDate,
Expand Down Expand Up @@ -1066,7 +1066,7 @@ extension Auth: AuthInterop {
requestConfiguration: self.requestConfiguration)
Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)

let operation = ActionCodeInfo.actionCodeOperation(forRequestType: response.requestType)
guard let email = response.email else {
Expand Down Expand Up @@ -2113,7 +2113,7 @@ extension Auth: AuthInterop {
requestConfiguration: requestConfiguration)
request.autoCreate = !isReauthentication
credential.prepare(request)
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
if response.needConfirmation {
let email = response.email
let credential = OAuthCredential(withVerifyAssertionResponse: response)
Expand Down Expand Up @@ -2156,7 +2156,7 @@ extension Auth: AuthInterop {
phoneNumber: phoneNumber,
operation: operation,
requestConfiguration: requestConfiguration)
return try await AuthBackend.post(with: request)
return try await AuthBackend.call(with: request)
case let .verification(verificationID, code):
guard verificationID.count > 0 else {
throw AuthErrorUtils.missingVerificationIDError(message: nil)
Expand All @@ -2168,7 +2168,7 @@ extension Auth: AuthInterop {
verificationCode: code,
operation: operation,
requestConfiguration: requestConfiguration)
return try await AuthBackend.post(with: request)
return try await AuthBackend.call(with: request)
}
}
#endif
Expand Down Expand Up @@ -2198,7 +2198,7 @@ extension Auth: AuthInterop {
timestamp: credential.timestamp,
displayName: credential.displayName,
requestConfiguration: requestConfiguration)
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
let user = try await completeSignIn(withAccessToken: response.idToken,
accessTokenExpirationDate: response
.approximateExpirationDate,
Expand Down Expand Up @@ -2234,7 +2234,7 @@ extension Auth: AuthInterop {
let request = EmailLinkSignInRequest(email: email,
oobCode: actionCode,
requestConfiguration: requestConfiguration)
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
let user = try await completeSignIn(withAccessToken: response.idToken,
accessTokenExpirationDate: response
.approximateExpirationDate,
Expand Down Expand Up @@ -2293,7 +2293,7 @@ extension Auth: AuthInterop {
private func wrapAsyncRPCTask(_ request: any AuthRPCRequest, _ callback: ((Error?) -> Void)?) {
Task {
do {
let _ = try await AuthBackend.post(with: request)
let _ = try await AuthBackend.call(with: request)
Auth.wrapMainAsync(callback, nil)
} catch {
Auth.wrapMainAsync(callback, error)
Expand Down
10 changes: 5 additions & 5 deletions FirebaseAuth/Sources/Swift/AuthProvider/PhoneAuthProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ import FirebaseCore
.requestConfiguration)

do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
return response.verificationID
} catch {
return try await handleVerifyErrorWithRetry(error: error,
Expand Down Expand Up @@ -249,7 +249,7 @@ import FirebaseCore
requestConfiguration: auth.requestConfiguration
)

let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
return response.verificationID
}
guard let session else {
Expand All @@ -268,15 +268,15 @@ import FirebaseCore
let request = StartMFAEnrollmentRequest(idToken: session.idToken,
enrollmentInfo: startMFARequestInfo,
requestConfiguration: auth.requestConfiguration)
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
return response.phoneSessionInfo?.sessionInfo
case .recaptcha:
let request = StartMFASignInRequest(MFAPendingCredential: session.mfaPendingCredential,
MFAEnrollmentID: session.multiFactorInfo?.uid,
signInInfo: startMFARequestInfo,
requestConfiguration: auth.requestConfiguration)

let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
return response.responseInfo?.sessionInfo
case .empty:
return nil
Expand Down Expand Up @@ -338,7 +338,7 @@ import FirebaseCore
isSandbox: token.type == AuthAPNSTokenType.sandbox,
requestConfiguration: auth.requestConfiguration)
do {
let verifyResponse = try await AuthBackend.post(with: request)
let verifyResponse = try await AuthBackend.call(with: request)
guard let receipt = verifyResponse.receipt,
let timeout = verifyResponse.suggestedTimeOutDate?.timeIntervalSinceNow else {
fatalError("Internal Auth Error: invalid VerifyClientResponse")
Expand Down
30 changes: 15 additions & 15 deletions FirebaseAuth/Sources/Swift/Backend/AuthBackend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import FirebaseCoreInternal
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
protocol AuthBackendRPCIssuer: NSObjectProtocol {
/** @fn
@brief Asynchronously sends a POST request.
@brief Asynchronously sends a HTTP request.
@param requestConfiguration The request to be made.
@param URL The request URL.
@param body Request body.
@param contentType Content type of the body.
@param handler provided that handles POST response. Invoked asynchronously on the auth global
@param handler provided that handles HTTP response. Invoked asynchronously on the auth global
work queue in the future.
*/
func asyncPostToURL<T: AuthRPCRequest>(with request: T,
func asyncCallToURL<T: AuthRPCRequest>(with request: T,
body: Data?,
contentType: String,
completionHandler: @escaping ((Data?, Error?) -> Void))
Expand All @@ -53,7 +53,7 @@ class AuthBackendRPCIssuerImplementation: NSObject, AuthBackendRPCIssuer {
fetcherService.reuseSession = false
}

func asyncPostToURL<T: AuthRPCRequest>(with request: T,
func asyncCallToURL<T: AuthRPCRequest>(with request: T,
body: Data?,
contentType: String,
completionHandler: @escaping ((Data?, Error?)
Expand Down Expand Up @@ -96,8 +96,8 @@ class AuthBackend: NSObject {
return gBackendImplementation!
}

class func post<T: AuthRPCRequest>(with request: T) async throws -> T.Response {
return try await implementation().post(with: request)
class func call<T: AuthRPCRequest>(with request: T) async throws -> T.Response {
return try await implementation().call(with: request)
}

class func request(withURL url: URL,
Expand Down Expand Up @@ -147,7 +147,7 @@ class AuthBackend: NSObject {

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
protocol AuthBackendImplementation {
func post<T: AuthRPCRequest>(with request: T) async throws -> T.Response
func call<T: AuthRPCRequest>(with request: T) async throws -> T.Response
}

@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
Expand All @@ -157,8 +157,8 @@ private class AuthBackendRPCImplementation: NSObject, AuthBackendImplementation
rpcIssuer = AuthBackendRPCIssuerImplementation()
}

/** @fn postWithRequest:
@brief Calls the RPC using HTTP POST.
/** @fn call
@brief Calls the RPC using HTTP request.
@remarks Possible error responses:
@see FIRAuthInternalErrorCodeRPCRequestEncodingError
@see FIRAuthInternalErrorCodeJSONSerializationError
Expand All @@ -170,8 +170,8 @@ private class AuthBackendRPCImplementation: NSObject, AuthBackendImplementation
@param response The empty response to be filled.
@param callback The callback for both success and failure.
*/
fileprivate func post<T: AuthRPCRequest>(with request: T) async throws -> T.Response {
let response = try await postInternal(with: request)
fileprivate func call<T: AuthRPCRequest>(with request: T) async throws -> T.Response {
let response = try await callInternal(with: request)
if let auth = request.requestConfiguration().auth,
let mfaError = Self.generateMFAError(response: response, auth: auth) {
throw mfaError
Expand Down Expand Up @@ -240,8 +240,8 @@ private class AuthBackendRPCImplementation: NSObject, AuthBackendImplementation
}
#endif

/** @fn postWithRequest:response:
@brief Calls the RPC using HTTP POST.
/** @fn call
@brief Calls the RPC using HTTP request.
@remarks Possible error responses:
@see FIRAuthInternalErrorCodeRPCRequestEncodingError
@see FIRAuthInternalErrorCodeJSONSerializationError
Expand All @@ -253,7 +253,7 @@ private class AuthBackendRPCImplementation: NSObject, AuthBackendImplementation
@param response The empty response to be filled.
@param callback The callback for both success and failure.
*/
fileprivate func postInternal<T: AuthRPCRequest>(with request: T) async throws -> T.Response {
fileprivate func callInternal<T: AuthRPCRequest>(with request: T) async throws -> T.Response {
var bodyData: Data?
if request.containsPostBody {
var postBody: [String: AnyHashable]
Expand Down Expand Up @@ -288,7 +288,7 @@ private class AuthBackendRPCImplementation: NSObject, AuthBackendImplementation
}
return try await withCheckedThrowingContinuation { continuation in
rpcIssuer
.asyncPostToURL(with: request, body: bodyData, contentType: "application/json") {
.asyncCallToURL(with: request, body: bodyData, contentType: "application/json") {
data, error in
// If there is an error with no body data at all, then this must be a
// network error.
Expand Down
6 changes: 3 additions & 3 deletions FirebaseAuth/Sources/Swift/MultiFactor/MultiFactor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ import Foundation
.requestConfiguration)
Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
do {
let user = try await auth.completeSignIn(withAccessToken: response.idToken,
accessTokenExpirationDate: nil,
Expand Down Expand Up @@ -138,7 +138,7 @@ import Foundation

Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
do {
let user = try await auth.completeSignIn(withAccessToken: response.idToken,
accessTokenExpirationDate: nil,
Expand Down Expand Up @@ -222,7 +222,7 @@ import Foundation
requestConfiguration: user.requestConfiguration)
Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
do {
let user = try await auth.completeSignIn(withAccessToken: response.idToken,
accessTokenExpirationDate: nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import Foundation
)
Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
let user = try await self.auth.completeSignIn(withAccessToken: response.idToken,
accessTokenExpirationDate: nil,
refreshToken: response.refreshToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import Foundation
requestConfiguration: requestConfiguration)
Task {
do {
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
if let totpSessionInfo = response.totpSessionInfo {
let secret = TOTPSecret(secretKey: totpSessionInfo.sharedSecretKey,
hashingAlgorithm: totpSessionInfo.hashingAlgorithm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private let kFiveMinutes = 5 * 60.0

let request = SecureTokenRequest.refreshRequest(refreshToken: refreshToken,
requestConfiguration: requestConfiguration)
let response = try await AuthBackend.post(with: request)
let response = try await AuthBackend.call(with: request)
var tokenUpdated = false
if let newAccessToken = response.accessToken,
newAccessToken.count > 0,
Expand Down
2 changes: 1 addition & 1 deletion FirebaseAuth/Sources/Swift/User/AdditionalUserInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ import Foundation
}
self.providerID = providerID
profile = aDecoder.decodeObject(
of: NSDictionary.self,
of: [NSDictionary.self, NSString.self],
forKey: AdditionalUserInfo.profileCodingKey
) as? [String: Any]
username = aDecoder.decodeObject(
Expand Down
Loading

0 comments on commit 6b997d7

Please sign in to comment.