FIRAppCheckErrorUtil.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 FIRAppCheckHTTPError;
  18. NS_ASSUME_NONNULL_BEGIN
  19. FOUNDATION_EXTERN NSErrorDomain const kFIRAppCheckErrorDomain NS_SWIFT_NAME(AppCheckErrorDomain);
  20. void FIRAppCheckSetErrorToPointer(NSError *error, NSError **pointer);
  21. @interface FIRAppCheckErrorUtil : NSObject
  22. // Internal errors.
  23. + (NSError *)cachedTokenNotFound;
  24. + (NSError *)cachedTokenExpired;
  25. + (FIRAppCheckHTTPError *)APIErrorWithHTTPResponse:(NSHTTPURLResponse *)HTTPResponse
  26. data:(nullable NSData *)data;
  27. + (NSError *)APIErrorWithNetworkError:(NSError *)networkError;
  28. + (NSError *)appCheckTokenResponseErrorWithMissingField:(NSString *)fieldName;
  29. + (NSError *)appAttestAttestationResponseErrorWithMissingField:(NSString *)fieldName;
  30. + (NSError *)JSONSerializationError:(NSError *)error;
  31. + (NSError *)errorWithFailureReason:(NSString *)failureReason;
  32. + (NSError *)unsupportedAttestationProvider:(NSString *)providerName;
  33. + (NSError *)appAttestKeyIDNotFound;
  34. @end
  35. typedef NS_ERROR_ENUM(kFIRAppCheckErrorDomain, FIRAppCheckErrorCode){
  36. /// An unknown or non-actionable error.
  37. FIRAppCheckErrorCodeUnknown = 0,
  38. /// A network connection error.
  39. FIRAppCheckErrorCodeServerUnreachable = 1,
  40. /// Invalid configuration error.
  41. FIRAppCheckErrorCodeInvalidConfiguration = 2,
  42. /// System keychain access error.
  43. FIRAppCheckErrorCodeKeychain = 3,
  44. /// Selected app attestation provider is not supported on the current platform or OS version.
  45. FIRAppCheckErrorCodeUnsupported = 4} NS_SWIFT_NAME(AppCheckErrorCode);
  46. NS_ASSUME_NONNULL_END