FIRAppCheckProtocol.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright 2023 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @class FIRAppCheckToken;
  18. NS_ASSUME_NONNULL_BEGIN
  19. NS_SWIFT_NAME(AppCheckProtocol)
  20. @protocol FIRAppCheckProtocol <NSObject>
  21. /// Requests Firebase app check token. This method should *only* be used if you need to authorize
  22. /// requests to a non-Firebase backend. Requests to Firebase backend are authorized automatically if
  23. /// configured.
  24. ///
  25. /// If your non-Firebase backend exposes sensitive or expensive endpoints that have low traffic
  26. /// volume, consider protecting it with [Replay
  27. /// Protection](https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection).
  28. /// In this case, use the ``limitedUseToken(completion:)`` instead to obtain a limited-use token.
  29. /// @param forcingRefresh If `YES`, a new Firebase app check token is requested and the token
  30. /// cache is ignored. If `NO`, the cached token is used if it exists and has not expired yet. In
  31. /// most cases, `NO` should be used. `YES` should only be used if the server explicitly returns an
  32. /// error, indicating a revoked token.
  33. /// @param handler The completion handler. Includes the app check token if the request succeeds,
  34. /// or an error if the request fails.
  35. - (void)tokenForcingRefresh:(BOOL)forcingRefresh
  36. completion:
  37. (void (^)(FIRAppCheckToken *_Nullable token, NSError *_Nullable error))handler
  38. NS_SWIFT_NAME(token(forcingRefresh:completion:));
  39. /// Requests a limited-use Firebase App Check token. This method should be used only if you need to
  40. /// authorize requests to a non-Firebase backend.
  41. ///
  42. /// Returns limited-use tokens that are intended for use with your non-Firebase backend endpoints
  43. /// that are protected with [Replay
  44. /// Protection](https://firebase.google.com/docs/app-check/custom-resource-backend#replay-protection).
  45. /// This method does not affect the token generation behavior of the
  46. /// ``tokenForcingRefresh()`` method.
  47. - (void)limitedUseTokenWithCompletion:(void (^)(FIRAppCheckToken *_Nullable token,
  48. NSError *_Nullable error))handler;
  49. @end
  50. NS_ASSUME_NONNULL_END