FIRAppAttestProviderState.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. NS_ASSUME_NONNULL_BEGIN
  18. /// Represents different stages of App Attest attestation.
  19. typedef NS_ENUM(NSInteger, FIRAppAttestAttestationState) {
  20. /// App Attest is not supported on the current device.
  21. FIRAppAttestAttestationStateUnsupported,
  22. /// App Attest is supported, the App Attest key pair has been generated.
  23. FIRAppAttestAttestationStateSupportedInitial,
  24. /// App Attest key pair has been generated but has not been attested and registered with Firebase
  25. /// backend.
  26. FIRAppAttestAttestationStateKeyGenerated,
  27. /// App Attest key has been generated, attested with Apple backend and registered with Firebase
  28. /// backend. An encrypted artifact required to refresh FAC token is stored on the device.
  29. FIRAppAttestAttestationStateKeyRegistered,
  30. };
  31. /// Represents attestation stages of App Attest. The class is designed to be used exclusively by
  32. /// `FIRAppAttestProvider`.
  33. @interface FIRAppAttestProviderState : NSObject
  34. /// App Attest attestation state.
  35. @property(nonatomic, readonly) FIRAppAttestAttestationState state;
  36. /// An error object when state is FIRAppAttestAttestationStateUnsupported.
  37. @property(nonatomic, nullable, readonly) NSError *appAttestUnsupportedError;
  38. /// An App Attest key ID when state is FIRAppAttestAttestationStateKeyGenerated or
  39. /// FIRAppAttestAttestationStateKeyRegistered.
  40. @property(nonatomic, nullable, readonly) NSString *appAttestKeyID;
  41. /// An attestation artifact received from Firebase backend when state is
  42. /// FIRAppAttestAttestationStateKeyRegistered.
  43. @property(nonatomic, nullable, readonly) NSData *attestationArtifact;
  44. - (instancetype)init NS_UNAVAILABLE;
  45. /// Init with FIRAppAttestAttestationStateUnsupported and an error describing issue.
  46. - (instancetype)initUnsupportedWithError:(NSError *)error;
  47. /// Init with FIRAppAttestAttestationStateSupportedInitial.
  48. - (instancetype)initWithSupportedInitialState;
  49. /// Init with FIRAppAttestAttestationStateKeyGenerated and the key ID.
  50. - (instancetype)initWithGeneratedKeyID:(NSString *)keyID;
  51. /// Init with FIRAppAttestAttestationStateKeyRegistered, the key ID and the attestation artifact
  52. /// received from Firebase backend.
  53. - (instancetype)initWithRegisteredKeyID:(NSString *)keyID artifact:(NSData *)artifact;
  54. @end
  55. NS_ASSUME_NONNULL_END