FIRAuthErrorUtils.h 30 KB

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