AuthRPCRequest.swift 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import Foundation
  15. /// The generic interface for an RPC request needed by AuthBackend.
  16. @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
  17. protocol AuthRPCRequest {
  18. associatedtype Response: AuthRPCResponse
  19. /// Gets the request's full URL.
  20. func requestURL() -> URL
  21. /// Creates unencoded HTTP body representing the request.
  22. /// - Returns: The HTTP body data representing the request before any encoding.
  23. /// - Note: Requests with a post body are POST requests. Requests without a
  24. /// post body are GET requests.
  25. var unencodedHTTPRequestBody: [String: AnyHashable]? { get }
  26. /// The request configuration.
  27. func requestConfiguration() -> AuthRequestConfiguration
  28. func injectRecaptchaFields(recaptchaResponse: String?, recaptchaVersion: String)
  29. }
  30. // Default implementation of AuthRPCRequests. This produces similar behaviour to an optional method
  31. // in Obj-C.
  32. @available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
  33. extension AuthRPCRequest {
  34. func injectRecaptchaFields(recaptchaResponse: String?, recaptchaVersion: String) {
  35. fatalError("Internal FirebaseAuth Error: unimplemented injectRecaptchaFields")
  36. }
  37. }