FIRAuthErrorUtils.h 30 KB

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