GIDAppCheckProvider.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. NS_ASSUME_NONNULL_BEGIN
  18. #if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
  19. @protocol GIDAppCheckTokenFetcher;
  20. @class FIRAppCheckToken;
  21. /// Interface providing the API for both pre-warming `GIDSignIn` to use Firebase App Check and
  22. /// fetching the App Check token.
  23. NS_AVAILABLE_IOS(14)
  24. @protocol GIDAppCheckProvider <NSObject>
  25. /// Creates the instance of this App Check wrapper class.
  26. ///
  27. /// @param tokenFetcher The instance performing the Firebase App Check token requests. If `provider`
  28. /// is nil, then we default to `FIRAppCheck`.
  29. /// @param userDefaults The instance of `NSUserDefaults` that `GIDAppCheck` will use to store its
  30. /// preparation status. If nil, `GIDAppCheck` will use `-[NSUserDefaults standardUserDefaults]`.
  31. - (instancetype)initWithAppCheckTokenFetcher:(nullable id<GIDAppCheckTokenFetcher>)tokenFetcher
  32. userDefaults:(nullable NSUserDefaults *)userDefaults;
  33. /// Prewarms the library for App Check by asking Firebase App Check to generate the App Attest key
  34. /// id and perform the initial attestation process (if needed).
  35. ///
  36. /// @param completion A `nullable` callback with a `nullable` `NSError` if preparation fails.
  37. - (void)prepareForAppCheckWithCompletion:(nullable void (^)(NSError * _Nullable error))completion;
  38. /// Fetches the limited use Firebase token.
  39. ///
  40. /// @param completion A `nullable` callback with the `FIRAppCheckToken` if present, or an `NSError`
  41. /// otherwise.
  42. - (void)getLimitedUseTokenWithCompletion:(nullable void (^)(FIRAppCheckToken * _Nullable token,
  43. NSError * _Nullable error))completion;
  44. /// Whether or not the App Attest key ID created and the attestation object has been fetched.
  45. - (BOOL)isPrepared;
  46. @end
  47. #endif // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
  48. NS_ASSUME_NONNULL_END