FIRAuthErrorUtils.h 31 KB

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