FIRAppAttestArtifactStorage.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2021 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 FBLPromise<ValueType>;
  18. @class GULKeychainStorage;
  19. NS_ASSUME_NONNULL_BEGIN
  20. /// Defines API of a storage capable to store an encrypted artifact required to refresh Firebase App
  21. /// Check token obtained with App Attest provider.
  22. @protocol FIRAppAttestArtifactStorageProtocol <NSObject>
  23. /// Set the artifact. An artifact previously set for *any* key ID will be replaced by the new one
  24. /// with the new key ID. The storage always stores a single artifact.
  25. /// @param artifact The artifact data to store. Pass `nil` to remove the stored artifact.
  26. /// @param keyID The App Attest key ID used to generate the artifact.
  27. /// @return An artifact that is resolved with the artifact data passed into the method in case of
  28. /// success or is rejected with an error.
  29. - (FBLPromise<NSData *> *)setArtifact:(nullable NSData *)artifact forKey:(NSString *)keyID;
  30. /// Get the artifact.
  31. /// @param keyID The App Attest key ID used to generate the artifact.
  32. /// @return A promise that is resolved with the artifact data if artifact exists, is resolved with
  33. /// `nil` if no artifact found (or the existing artifact was set for a different key ID) or is
  34. /// rejected with an error.
  35. - (FBLPromise<NSData *> *)getArtifactForKey:(NSString *)keyID;
  36. @end
  37. /// An implementation of FIRAppAttestArtifactStorageProtocol.
  38. @interface FIRAppAttestArtifactStorage : NSObject <FIRAppAttestArtifactStorageProtocol>
  39. - (instancetype)init NS_UNAVAILABLE;
  40. /// Default convenience initializer.
  41. /// @param appName A Firebase App name (`FirebaseApp.name`). The app name will be used as a part of
  42. /// the key to store the token for the storage instance.
  43. /// @param appID A Firebase App identifier (`FirebaseOptions.googleAppID`). The app ID will be used
  44. /// as a part of the key to store the token for the storage instance.
  45. /// @param accessGroup The Keychain Access Group.
  46. - (instancetype)initWithAppName:(NSString *)appName
  47. appID:(NSString *)appID
  48. accessGroup:(nullable NSString *)accessGroup;
  49. /// Designated initializer.
  50. /// @param appName A Firebase App name (`FirebaseApp.name`). The app name will be used as a part of
  51. /// the key to store the token for the storage instance.
  52. /// @param appID A Firebase App identifier (`FirebaseOptions.googleAppID`). The app ID will be used
  53. /// as a part of the key to store the token for the storage instance.
  54. /// @param keychainStorage An instance of `GULKeychainStorage` used as an underlying secure storage.
  55. /// @param accessGroup The Keychain Access Group.
  56. - (instancetype)initWithAppName:(NSString *)appName
  57. appID:(NSString *)appID
  58. keychainStorage:(GULKeychainStorage *)keychainStorage
  59. accessGroup:(nullable NSString *)accessGroup NS_DESIGNATED_INITIALIZER;
  60. @end
  61. NS_ASSUME_NONNULL_END