FIRAppCheckTokenRefreshResult.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 possible results of a Firebase App Check token refresh attempt that matter for
  19. /// `FIRAppCheckTokenRefresher`.
  20. typedef NS_ENUM(NSInteger, FIRAppCheckTokenRefreshStatus) {
  21. // The token has not been refreshed.
  22. FIRAppCheckTokenRefreshStatusNever,
  23. // The token was successfully refreshed.
  24. FIRAppCheckTokenRefreshStatusSuccess,
  25. // The token refresh failed.
  26. FIRAppCheckTokenRefreshStatusFailure
  27. };
  28. /// An object to pass the possible results of a Firebase App Check token refresh attempt and
  29. /// supplementary data.
  30. @interface FIRAppCheckTokenRefreshResult : NSObject
  31. /// Status of the refresh.
  32. @property(nonatomic, readonly) FIRAppCheckTokenRefreshStatus status;
  33. /// A date when the new Firebase App Check token is expiring.
  34. @property(nonatomic, readonly, nullable) NSDate *tokenExpirationDate;
  35. /// A date when the new Firebase App Check token was received from the server.
  36. @property(nonatomic, readonly, nullable) NSDate *tokenReceivedAtDate;
  37. - (instancetype)init NS_UNAVAILABLE;
  38. /// Initializes the instance with `FIRAppCheckTokenRefreshStatusNever`.
  39. - (instancetype)initWithStatusNever;
  40. /// Initializes the instance with `FIRAppCheckTokenRefreshStatusFailure`.
  41. - (instancetype)initWithStatusFailure;
  42. /// Initializes the instance with `FIRAppCheckTokenRefreshStatusSuccess`.
  43. /// @param tokenExpirationDate See `tokenExpirationDate` property.
  44. /// @param tokenReceivedAtDate See `tokenReceivedAtDate` property.
  45. - (instancetype)initWithStatusSuccessAndExpirationDate:(NSDate *)tokenExpirationDate
  46. receivedAtDate:(NSDate *)tokenReceivedAtDate;
  47. @end
  48. NS_ASSUME_NONNULL_END