FIRAppCheckStorage.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright 2020 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. @class FBLPromise<ValueType>;
  19. @class GULKeychainStorage;
  20. NS_ASSUME_NONNULL_BEGIN
  21. @protocol FIRAppCheckStorageProtocol <NSObject>
  22. /** Manages storage of the FAA token.
  23. * @param token A token object to store or `nil` to remove existing token.
  24. * @return A promise that is resolved with the stored object in the case of success or is rejected
  25. * with a specific error otherwise.
  26. */
  27. - (FBLPromise<FIRAppCheckToken *> *)setToken:(nullable FIRAppCheckToken *)token;
  28. /** Reads a stored FAA token.
  29. * @return A promise that is resolved with a stored token or `nil` if there is not a stored token.
  30. * The promise is rejected with an error in the case of a failure.
  31. */
  32. - (FBLPromise<FIRAppCheckToken *> *)getToken;
  33. @end
  34. /// The class provides an implementation of persistent storage to store data like FAA token, etc.
  35. @interface FIRAppCheckStorage : NSObject <FIRAppCheckStorageProtocol>
  36. - (instancetype)init NS_UNAVAILABLE;
  37. /** Default convenience initializer.
  38. * @param appName A Firebase App name (`FirebaseApp.name`). The app name will be used as a part of
  39. * the key to store the token for the storage instance.
  40. * @param appID A Firebase App identifier (`FirebaseOptions.googleAppID`). The app ID will be used
  41. * as a part of the key to store the token for the storage instance.
  42. * @param accessGroup The Keychain Access Group.
  43. */
  44. - (instancetype)initWithAppName:(NSString *)appName
  45. appID:(NSString *)appID
  46. accessGroup:(nullable NSString *)accessGroup;
  47. /** Designated initializer.
  48. * @param appName A Firebase App name (`FirebaseApp.name`). The app name will be used as a part of
  49. * the key to store the token for the storage instance.
  50. * @param appID A Firebase App identifier (`FirebaseOptions.googleAppID`). The app ID will be used
  51. * as a part of the key to store the token for the storage instance.
  52. * @param keychainStorage An instance of `GULKeychainStorage` used as an underlying secure storage.
  53. * @param accessGroup The Keychain Access Group.
  54. */
  55. - (instancetype)initWithAppName:(NSString *)appName
  56. appID:(NSString *)appID
  57. keychainStorage:(GULKeychainStorage *)keychainStorage
  58. accessGroup:(nullable NSString *)accessGroup NS_DESIGNATED_INITIALIZER;
  59. @end
  60. NS_ASSUME_NONNULL_END