No Description

FIRAuthErrorUtils.h 27KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. /*
  2. * Copyright 2017 Google
  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 FIRAuthCredential;
  18. NS_ASSUME_NONNULL_BEGIN
  19. /** @class FIRAuthErrorUtils
  20. @brief Utility class used to construct @c NSError instances.
  21. */
  22. @interface FIRAuthErrorUtils : NSObject
  23. /** @fn RPCRequestEncodingErrorWithUnderlyingError
  24. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeRPCRequestEncodingError
  25. code and a populated @c NSUnderlyingErrorKey in the @c NSError.userInfo dictionary.
  26. @param underlyingError The value of the @c NSUnderlyingErrorKey key.
  27. @remarks This error is used when an @c FIRAuthRPCRequest.unencodedHTTPRequestBodyWithError:
  28. invocation returns an error. The error returned is wrapped in this internal error code.
  29. */
  30. + (NSError *)RPCRequestEncodingErrorWithUnderlyingError:(NSError *)underlyingError;
  31. /** @fn JSONSerializationErrorForUnencodableType
  32. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeJSONSerializationError code.
  33. @remarks This error is used when an @c NSJSONSerialization.isValidJSONObject: check fails, not
  34. for when an error is returned from @c NSJSONSerialization.dataWithJSONObject:options:error:.
  35. */
  36. + (NSError *)JSONSerializationErrorForUnencodableType;
  37. /** @fn JSONSerializationErrorWithUnderlyingError:
  38. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeJSONSerializationError code, and the
  39. @c underlyingError as the @c NSUnderlyingErrorKey value in the @c NSError.userInfo
  40. dictionary.
  41. @param underlyingError The value of the @c NSUnderlyingErrorKey key.
  42. @remarks This error is used when an invocation of
  43. @c NSJSONSerialization.dataWithJSONObject:options:error: returns an error.
  44. */
  45. + (NSError *)JSONSerializationErrorWithUnderlyingError:(NSError *)underlyingError;
  46. /** @fn networkErrorWithUnderlyingError:
  47. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeNetworkError code, and the
  48. @c underlyingError as the @c NSUnderlyingErrorKey value in the @c NSError.userInfo
  49. dictionary.
  50. @param underlyingError The value of the @c NSUnderlyingErrorKey key. Should be the error from
  51. GTM.
  52. @remarks This error is used when a network request results in an error, and no body data was
  53. returned.
  54. */
  55. + (NSError *)networkErrorWithUnderlyingError:(NSError *)underlyingError;
  56. /** @fn unexpectedErrorResponseWithUnderlyingError:
  57. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeNetworkError code, and the
  58. @c underlyingError as the @c NSUnderlyingErrorKey value.
  59. @param data The value of the @c FIRAuthErrorUserInfoDataKey key in the @c NSError.userInfo
  60. dictionary.
  61. @param underlyingError The value of the @c NSUnderlyingErrorKey key in the @c NSError.userInfo
  62. dictionary.
  63. @remarks This error is used when a network request results in an error, and unserializable body
  64. data was returned.
  65. */
  66. + (NSError *)unexpectedErrorResponseWithData:(NSData *)data
  67. underlyingError:(NSError *)underlyingError;
  68. /** @fn unexpectedErrorResponseWithDeserializedResponse:
  69. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeUnexpectedErrorResponse
  70. code, and a populated @c FIRAuthErrorUserInfoDeserializedResponseKey key in the
  71. @c NSError.userInfo dictionary.
  72. @param deserializedResponse The value of the @c FIRAuthErrorUserInfoDeserializedResponseKey key.
  73. @remarks This error is used when a network request results in an error, and the body data was
  74. deserializable as JSON, but couldn't be decoded as an error.
  75. */
  76. + (NSError *)unexpectedErrorResponseWithDeserializedResponse:(id)deserializedResponse;
  77. /** @fn malformedJWTErrorWithToken:underlyingError:
  78. @brief Constructs an @c NSError with the code set to @c FIRAuthErrorCodeMalformedJWT and
  79. populates the userInfo dictionary with an error message, the bad token, and an underlying
  80. error that may have occurred when parsing.
  81. @param token The token that failed to parse.
  82. @param underlyingError The error that caused this error. If this parameter is nil, the
  83. NSUnderlyingErrorKey value will not be set.
  84. @remarks This error is returned when JWT parsing fails.
  85. @returns An @c FIRAuthErrorCodeMalformedJWT error wrapping an underlying error, if available.
  86. */
  87. + (NSError *)malformedJWTErrorWithToken:(NSString *)token
  88. underlyingError:(NSError *_Nullable)underlyingError;
  89. /** @fn unexpectedResponseWithData:underlyingError:
  90. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeUnexpectedResponse
  91. code, and a populated @c FIRAuthErrorUserInfoDataKey key in the @c NSError.userInfo
  92. dictionary.
  93. @param data The value of the @c FIRAuthErrorUserInfoDataKey key in the @c NSError.userInfo
  94. dictionary.
  95. @param underlyingError The value of the @c NSUnderlyingErrorKey key in the @c NSError.userInfo
  96. dictionary.
  97. @remarks This error is used when a network request is apparently successful, but the body data
  98. couldn't be deserialized as JSON.
  99. */
  100. + (NSError *)unexpectedResponseWithData:(NSData *)data
  101. underlyingError:(NSError *)underlyingError;;
  102. /** @fn unexpectedResponseWithDeserializedResponse:
  103. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeUnexpectedResponse
  104. code, and a populated @c FIRAuthErrorUserInfoDeserializedResponseKey key in the
  105. @c NSError.userInfo dictionary.
  106. @param deserializedResponse The value of the @c FIRAuthErrorUserInfoDeserializedResponseKey key.
  107. @remarks This error is used when a network request is apparently successful, the body data was
  108. successfully deserialized as JSON, but the JSON wasn't a dictionary.
  109. */
  110. + (NSError *)unexpectedResponseWithDeserializedResponse:(id)deserializedResponse;
  111. /** @fn unexpectedResponseWithDeserializedResponse:underlyingError:
  112. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeUnexpectedResponse
  113. code, and populated @c FIRAuthErrorUserInfoDeserializedResponseKey and
  114. @c NSUnderlyingErrorKey keys in the @c NSError.userInfo dictionary.
  115. @param deserializedResponse The value of the @c FIRAuthErrorUserInfoDeserializedResponseKey key.
  116. @param underlyingError The value of the @c NSUnderlyingErrorKey key.
  117. @remarks This error is used when a network request was apparently successful, the body data was
  118. successfully deserialized as JSON, but the data type of the response was unexpected.
  119. */
  120. + (NSError *)unexpectedResponseWithDeserializedResponse:(nullable id)deserializedResponse
  121. underlyingError:(NSError *)underlyingError;
  122. /** @fn RPCResponseDecodingErrorWithDeserializedResponse:underlyingError:
  123. @brief Constructs an @c NSError with the @c FIRAuthInternalErrorCodeRPCResponseDecodingError
  124. code, and populated @c FIRAuthErrorUserInfoDeserializedResponseKey and
  125. @c NSUnderlyingErrorKey keys in the @c NSError.userInfo dictionary.
  126. @param deserializedResponse The value of the @c FIRAuthErrorUserInfoDeserializedResponseKey key.
  127. @param underlyingError The value of the @c NSUnderlyingErrorKey key.
  128. @remarks This error is used when an invocation of @c FIRAuthRPCResponse.setWithDictionary:error:
  129. resulted in an error.
  130. */
  131. + (NSError *)RPCResponseDecodingErrorWithDeserializedResponse:(id)deserializedResponse
  132. underlyingError:(NSError *)underlyingError;
  133. /** @fn emailAlreadyInUseErrorWithEmail:
  134. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeEmailExists code.
  135. @param email The email address that is already in use.
  136. @return The NSError instance associated with the given FIRAuthError.
  137. */
  138. + (NSError *)emailAlreadyInUseErrorWithEmail:(nullable NSString *)email;
  139. /** @fn userDisabledErrorWithMessageWithMessage:
  140. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUserDisabled code.
  141. @param message Error message from the backend, if any.
  142. @return The NSError instance associated with the given FIRAuthError.
  143. */
  144. + (NSError *)userDisabledErrorWithMessage:(nullable NSString *)message;
  145. /** @fn wrongPasswordErrorWithMessage:
  146. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeWrongPassword code.
  147. @param message Error message from the backend, if any.
  148. @return The NSError instance associated with the given FIRAuthError.
  149. */
  150. + (NSError *)wrongPasswordErrorWithMessage:(nullable NSString *)message;
  151. /** @fn tooManyRequestsErrorWithMessage:
  152. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeTooManyRequests Code.
  153. @param message Error message from the backend, if any.
  154. @return The NSError instance associated with the given FIRAuthError.
  155. */
  156. + (NSError *)tooManyRequestsErrorWithMessage:(nullable NSString *)message;
  157. /** @fn invalidCustomTokenErrorWithMessage:
  158. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidCustomToken code.
  159. @param message Error message from the backend, if any.
  160. @return The NSError instance associated with the given FIRAuthError.
  161. */
  162. + (NSError *)invalidCustomTokenErrorWithMessage:(nullable NSString *)message;
  163. /** @fn customTokenMistmatchErrorWithMessage:
  164. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeCustomTokenMismatch code.
  165. @param message Error message from the backend, if any.
  166. @return The NSError instance associated with the given FIRAuthError.
  167. */
  168. + (NSError *)customTokenMistmatchErrorWithMessage:(nullable NSString *)message;
  169. /** @fn invalidCredentialErrorWithMessage:
  170. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidCredential code.
  171. @param message Error message from the backend, if any.
  172. @return The NSError instance associated with the given FIRAuthError.
  173. */
  174. + (NSError *)invalidCredentialErrorWithMessage:(nullable NSString *)message;
  175. /** @fn requiresRecentLoginError
  176. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeRequiresRecentLogin code.
  177. @param message Error message from the backend, if any.
  178. @return The NSError instance associated with the given FIRAuthError.
  179. */
  180. + (NSError *)requiresRecentLoginErrorWithMessage:(nullable NSString *)message;
  181. /** @fn invalidUserTokenErrorWithMessage:
  182. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidUserToken code.
  183. @param message Error message from the backend, if any.
  184. @return The NSError instance associated with the given FIRAuthError.
  185. */
  186. + (NSError *)invalidUserTokenErrorWithMessage:(nullable NSString *)message;
  187. /** @fn invalidEmailErrorWithMessage:
  188. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidEmail code.
  189. @param message Error message from the backend, if any.
  190. @return The NSError instance associated with the given FIRAuthError.
  191. */
  192. + (NSError *)invalidEmailErrorWithMessage:(nullable NSString *)message;
  193. /** @fn accountExistsWithDifferentCredentialErrorWithEmail:
  194. @brief Constructs an @c NSError with the @c FIRAuthErrorAccountExistsWithDifferentCredential
  195. code.
  196. @param Email The email address that is already associated with an existing account
  197. @return The NSError instance associated with the given FIRAuthError.
  198. */
  199. + (NSError *)accountExistsWithDifferentCredentialErrorWithEmail:(nullable NSString *)Email;
  200. /** @fn providerAlreadyLinkedErrorWithMessage:
  201. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeProviderAlreadyLinked code.
  202. @return The NSError instance associated with the given FIRAuthError.
  203. */
  204. + (NSError *)providerAlreadyLinkedError;
  205. /** @fn noSuchProviderError
  206. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeNoSuchProvider code.
  207. @return The NSError instance associated with the given FIRAuthError.
  208. */
  209. + (NSError *)noSuchProviderError;
  210. /** @fn userTokenExpiredErrorWithMessage:
  211. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUserTokenExpired code.
  212. @param message Error message from the backend, if any.
  213. @return The NSError instance associated with the given FIRAuthError.
  214. */
  215. + (NSError *)userTokenExpiredErrorWithMessage:(nullable NSString *)message;
  216. /** @fn userNotFoundErrorWithMessage:
  217. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUserNotFound code.
  218. @param message Error message from the backend, if any.
  219. @return The NSError instance associated with the given FIRAuthError.
  220. */
  221. + (NSError *)userNotFoundErrorWithMessage:(nullable NSString *)message;
  222. /** @fn invalidLocalAPIKeyErrorWithMessage:
  223. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidAPIKey code.
  224. @return The NSError instance associated with the given FIRAuthError.
  225. */
  226. + (NSError *)invalidAPIKeyError;
  227. /** @fn userMismatchError
  228. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUserMismatch code.
  229. @return The NSError instance associated with the given FIRAuthError.
  230. */
  231. + (NSError *)userMismatchError;
  232. /** @fn credentialAlreadyInUseErrorWithMessage:email:
  233. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeCredentialAlreadyInUse code.
  234. @param message Error message from the backend, if any.
  235. @param credential Auth credential to be added to the Error User Info dictionary.
  236. @param email Email to be added to the Error User Info dictionary.
  237. @return The NSError instance associated with the given FIRAuthError.
  238. */
  239. + (NSError *)credentialAlreadyInUseErrorWithMessage:(nullable NSString *)message
  240. credential:(nullable FIRAuthCredential *)credential
  241. email:(nullable NSString *)email;
  242. /** @fn operationNotAllowedErrorWithMessage:
  243. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeOperationNotAllowed code.
  244. @param message Error message from the backend, if any.
  245. @return The NSError instance associated with the given FIRAuthError.
  246. */
  247. + (NSError *)operationNotAllowedErrorWithMessage:(nullable NSString *)message;
  248. /** @fn weakPasswordErrorWithServerResponseReason:
  249. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeWeakPassword code.
  250. @param serverResponseReason A more detailed explanation string from server response.
  251. @return The NSError instance associated with the given FIRAuthError.
  252. */
  253. + (NSError *)weakPasswordErrorWithServerResponseReason:(nullable NSString *)serverResponseReason;
  254. /** @fn appNotAuthorizedError
  255. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeAppNotAuthorized code.
  256. @return The NSError instance associated with the given FIRAuthError.
  257. */
  258. + (NSError *)appNotAuthorizedError;
  259. /** @fn expiredActionCodeErrorWithMessage:
  260. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeExpiredActionCode code.
  261. @param message Error message from the backend, if any.
  262. @return The NSError instance associated with the given FIRAuthError.
  263. */
  264. + (NSError *)expiredActionCodeErrorWithMessage:(nullable NSString *)message;
  265. /** @fn invalidActionCodeErrorWithMessage:
  266. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidActionCode code.
  267. @param message Error message from the backend, if any.
  268. @return The NSError instance associated with the given FIRAuthError.
  269. */
  270. + (NSError *)invalidActionCodeErrorWithMessage:(nullable NSString *)message;
  271. /** @fn invalidMessagePayloadError:
  272. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidMessagePayload code.
  273. @param message Error message from the backend, if any.
  274. @return The NSError instance associated with the given FIRAuthError.
  275. */
  276. + (NSError *)invalidMessagePayloadErrorWithMessage:(nullable NSString *)message;
  277. /** @fn invalidSenderErrorWithMessage:
  278. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidSender code.
  279. @param message Error message from the backend, if any.
  280. @return The NSError instance associated with the given FIRAuthError.
  281. */
  282. + (NSError *)invalidSenderErrorWithMessage:(nullable NSString *)message;
  283. /** @fn invalidRecipientEmailError:
  284. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidRecipientEmail code.
  285. @param message Error message from the backend, if any.
  286. @return The NSError instance associated with the given FIRAuthError.
  287. */
  288. + (NSError *)invalidRecipientEmailErrorWithMessage:(nullable NSString *)message;
  289. /** @fn missingIosBundleIDErrorWithMessage:
  290. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingIosBundleID code.
  291. @param message Error message from the backend, if any.
  292. @return The NSError instance associated with the given FIRAuthError.
  293. */
  294. + (NSError *)missingIosBundleIDErrorWithMessage:(nullable NSString *)message;
  295. /** @fn missingAndroidPackageNameErrorWithMessage:
  296. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingAndroidPackageName code.
  297. @param message Error message from the backend, if any.
  298. @return The NSError instance associated with the given FIRAuthError.
  299. */
  300. + (NSError *)missingAndroidPackageNameErrorWithMessage:(nullable NSString *)message;
  301. /** @fn unauthorizedDomainErrorWithMessage:
  302. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeUnauthorizedDomain code.
  303. @param message Error message from the backend, if any.
  304. @return The NSError instance associated with the given FIRAuthError.
  305. */
  306. + (NSError *)unauthorizedDomainErrorWithMessage:(nullable NSString *)message;
  307. /** @fn invalidContinueURIErrorWithMessage:
  308. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidContinueURI code.
  309. @param message Error message from the backend, if any.
  310. @return The NSError instance associated with the given FIRAuthError.
  311. */
  312. + (NSError *)invalidContinueURIErrorWithMessage:(nullable NSString *)message;
  313. /** @fn missingContinueURIErrorWithMessage:
  314. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingContinueURI code.
  315. @param message Error message from the backend, if any.
  316. @return The NSError instance associated with the given FIRAuthError.
  317. */
  318. + (NSError *)missingContinueURIErrorWithMessage:(nullable NSString *)message;
  319. /** @fn missingEmailErrorWithMessage
  320. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingEmail code.
  321. @param message Error message from the backend, if any.
  322. @return The NSError instance associated with the given FIRAuthError.
  323. */
  324. + (NSError *)missingEmailErrorWithMessage:(nullable NSString *)message;
  325. /** @fn missingPhoneNumberErrorWithMessage:
  326. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingPhoneNumber code.
  327. @param message Error message from the backend, if any.
  328. @return The NSError instance associated with the given FIRAuthError.
  329. */
  330. + (NSError *)missingPhoneNumberErrorWithMessage:(nullable NSString *)message;
  331. /** @fn invalidPhoneNumberErrorWithMessage:
  332. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidPhoneNumber code.
  333. @param message Error message from the backend, if any.
  334. @return The NSError instance associated with the given FIRAuthError.
  335. */
  336. + (NSError *)invalidPhoneNumberErrorWithMessage:(nullable NSString *)message;
  337. /** @fn missingVerificationCodeErrorWithMessage:
  338. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingVerificationCode code.
  339. @param message Error message from the backend, if any.
  340. @return The NSError instance associated with the given FIRAuthError.
  341. */
  342. + (NSError *)missingVerificationCodeErrorWithMessage:(nullable NSString *)message;
  343. /** @fn invalidVerificationCodeErrorWithMessage:
  344. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidVerificationCode code.
  345. @param message Error message from the backend, if any.
  346. @return The NSError instance associated with the given FIRAuthError.
  347. */
  348. + (NSError *)invalidVerificationCodeErrorWithMessage:(nullable NSString *)message;
  349. /** @fn missingVerificationIDErrorWithMessage:
  350. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingVerificationID code.
  351. @param message Error message from the backend, if any.
  352. @return The NSError instance associated with the given FIRAuthError.
  353. */
  354. + (NSError *)missingVerificationIDErrorWithMessage:(nullable NSString *)message;
  355. /** @fn invalidVerificationIDErrorWithMessage:
  356. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeInvalidVerificationID code.
  357. @param message Error message from the backend, if any.
  358. @return The NSError instance associated with the given FIRAuthError.
  359. */
  360. + (NSError *)invalidVerificationIDErrorWithMessage:(nullable NSString *)message;
  361. /** @fn sessionExpiredErrorWithMessage:
  362. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeSessionExpired code.
  363. @param message Error message from the backend, if any.
  364. @return The NSError instance associated with the given FIRAuthError.
  365. */
  366. + (NSError *)sessionExpiredErrorWithMessage:(nullable NSString *)message;
  367. /** @fn missingAppCredentialWithMessage:
  368. @brief Constructs an @c NSError with the @c FIRAuthErrorMissingCredential code.
  369. @param message Error message from the backend, if any.
  370. @return The NSError instance associated with the given FIRAuthError.
  371. */
  372. + (NSError *)missingAppCredentialWithMessage:(nullable NSString *)message;
  373. /** @fn invalidAppCredentialWithMessage:
  374. @brief Constructs an @c NSError with the @c FIRAuthErrorInvalidCredential code.
  375. @param message Error message from the backend, if any.
  376. @return The NSError instance associated with the given FIRAuthError.
  377. */
  378. + (NSError *)invalidAppCredentialWithMessage:(nullable NSString *)message;
  379. /** @fn quotaExceededErrorWithMessage:
  380. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeQuotaExceeded code.
  381. @param message Error message from the backend, if any.
  382. @return The NSError instance associated with the given FIRAuthError.
  383. */
  384. + (NSError *)quotaExceededErrorWithMessage:(nullable NSString *)message;
  385. /** @fn missingAppTokenErrorWithUnderlyingError
  386. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeMissingAppToken code.
  387. @param underlyingError The underlying error, if any.
  388. @return The NSError instance associated with the given FIRAuthError.
  389. */
  390. + (NSError *)missingAppTokenErrorWithUnderlyingError:(nullable NSError *)underlyingError;
  391. /** @fn localPlayerNotAuthenticatedError
  392. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeLocalPlayerNotAuthenticated code.
  393. @return The NSError instance associated with the given FIRAuthError.
  394. */
  395. + (NSError *)localPlayerNotAuthenticatedError;
  396. /** @fn gameKitNotLinkedError
  397. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeGameKitNotLinked code.
  398. @return The NSError instance associated with the given FIRAuthError.
  399. */
  400. + (NSError *)gameKitNotLinkedError;
  401. /** @fn notificationNotForwardedError
  402. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeNotificationNotForwarded code.
  403. @return The NSError instance associated with the given FIRAuthError.
  404. */
  405. + (NSError *)notificationNotForwardedError;
  406. /** @fn appNotVerifiedErrorWithMessage:
  407. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeAppNotVerified code.
  408. @param message Error message from the backend, if any.
  409. @return The NSError instance associated with the given FIRAuthError.
  410. */
  411. + (NSError *)appNotVerifiedErrorWithMessage:(nullable NSString *)message;
  412. /** @fn captchaCheckFailedErrorWithMessage:
  413. @brief Constructs an @c NSError with the @c FIRAuthErrorCaptchaCheckFailed code.
  414. @param message Error message from the backend, if any.
  415. @return The NSError instance associated with the given FIRAuthError.
  416. */
  417. + (NSError *)captchaCheckFailedErrorWithMessage:(nullable NSString *)message;
  418. /** @fn webContextAlreadyPresentedErrorWithMessage:
  419. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeWebContextAlreadyPresented code.
  420. @param message Error message from the backend, if any.
  421. @return The NSError instance associated with the given FIRAuthError.
  422. */
  423. + (NSError *)webContextAlreadyPresentedErrorWithMessage:(nullable NSString *)message;
  424. /** @fn webContextCancelledErrorWithMessage:
  425. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeWebContextCancelled code.
  426. @param message Error message from the backend, if any.
  427. @return The NSError instance associated with the given FIRAuthError.
  428. */
  429. + (NSError *)webContextCancelledErrorWithMessage:(nullable NSString *)message;
  430. /** @fn appVerificationUserInteractionFailureWithReason:
  431. @brief Constructs an @c NSError with the @c
  432. FIRAuthErrorCodeAppVerificationUserInteractionFailure code.
  433. @param reason Reason for error, returned via URL response.
  434. @return The NSError instance associated with the given FIRAuthError.
  435. */
  436. + (NSError *)appVerificationUserInteractionFailureWithReason:(NSString *)reason;
  437. /** @fn webSignInUserInteractionFailureWithReason:
  438. @brief Constructs an @c NSError with the @c
  439. FIRAuthErrorCodeWebSignInUserInteractionFailure code.
  440. @param reason Reason for error, returned via URL response.
  441. @return The NSError instance associated with the given FIRAuthError.
  442. */
  443. + (NSError *)webSignInUserInteractionFailureWithReason:(nullable NSString *)reason;
  444. /** @fn URLResponseErrorWithCode:message:
  445. @brief Constructs an @c NSError with the code and message provided.
  446. @param message Error message from the backend, if any.
  447. @return The nullable NSError instance associated with the given error message, if one is found.
  448. */
  449. + (nullable NSError *)URLResponseErrorWithCode:(NSString *)code message:(nullable NSString *)message;
  450. /** @fn nullUserErrorWithMessage:
  451. @brief Constructs an @c NSError with the code and message provided.
  452. @param message Error message from the backend, if any.
  453. @return The nullable NSError instance associated with the given error message, if one is found.
  454. */
  455. + (NSError *)nullUserErrorWithMessage:(nullable NSString *)message;
  456. /** @fn invalidDynamicLinkDomainErrorWithMessage:
  457. @brief Constructs an @c NSError with the code and message provided.
  458. @param message Error message from the backend, if any.
  459. @return The nullable NSError instance associated with the given error message, if one is found.
  460. */
  461. + (NSError *)invalidDynamicLinkDomainErrorWithMessage:(nullable NSString *)message;
  462. /** @fn keychainErrorWithFunction:status:
  463. @brief Constructs an @c NSError with the @c FIRAuthErrorCodeKeychainError code.
  464. @param keychainFunction The keychain function which was invoked and yielded an unexpected
  465. response. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo
  466. dictionary will contain a string partially comprised of this value.
  467. @param status The response status from the invoked keychain function. The
  468. @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain
  469. a string partially comprised of this value.
  470. */
  471. + (NSError *)keychainErrorWithFunction:(NSString *)keychainFunction status:(OSStatus)status;
  472. @end
  473. NS_ASSUME_NONNULL_END