暂无描述

FIRAuthErrorUtils.h 28KB

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