FIRAuthErrorUtils.m 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885
  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 "FIRAuthErrorUtils.h"
  17. #import "FIRAuthCredential.h"
  18. #import "FIRAuthInternalErrors.h"
  19. NS_ASSUME_NONNULL_BEGIN
  20. NSString *const FIRAuthErrorDomain = @"FIRAuthErrorDomain";
  21. NSString *const FIRAuthInternalErrorDomain = @"FIRAuthInternalErrorDomain";
  22. NSString *const FIRAuthErrorUserInfoDeserializedResponseKey =
  23. @"FIRAuthErrorUserInfoDeserializedResponseKey";
  24. NSString *const FIRAuthErrorUserInfoDataKey = @"FIRAuthErrorUserInfoDataKey";
  25. NSString *const FIRAuthErrorUserInfoEmailKey = @"FIRAuthErrorUserInfoEmailKey";
  26. NSString *const FIRAuthErrorNameKey = @"error_name";
  27. NSString *const FIRAuthUpdatedCredentialKey = @"FIRAuthUpdatedCredentialKey";
  28. /** @var kServerErrorDetailMarker
  29. @brief This marker indicates that the server error message contains a detail error message which
  30. should be used instead of the hardcoded client error message.
  31. */
  32. static NSString *const kServerErrorDetailMarker = @" : ";
  33. #pragma mark - Standard Error Messages
  34. /** @var kFIRAuthErrorMessageInvalidCustomToken
  35. @brief Message for @c FIRAuthErrorCodeInvalidCustomToken error code.
  36. */
  37. static NSString *const kFIRAuthErrorMessageInvalidCustomToken = @"The custom token format is "
  38. "incorrect. Please check the documentation.";
  39. /** @var kFIRAuthErrorMessageCustomTokenMismatch
  40. @brief Message for @c FIRAuthErrorCodeCustomTokenMismatch error code.
  41. */
  42. static NSString *const kFIRAuthErrorMessageCustomTokenMismatch = @"The custom token corresponds to "
  43. "a different audience.";
  44. /** @var kFIRAuthErrorMessageInvalidEmail
  45. @brief Message for @c FIRAuthErrorCodeInvalidEmail error code.
  46. */
  47. static NSString *const kFIRAuthErrorMessageInvalidEmail = @"The email address is badly formatted.";
  48. /** @var kFIRAuthErrorMessageInvalidCredential
  49. @brief Message for @c FIRAuthErrorCodeInvalidCredential error code.
  50. */
  51. static NSString *const kFIRAuthErrorMessageInvalidCredential = @"The supplied auth credential is "
  52. "malformed or has expired.";
  53. /** @var kFIRAuthErrorMessageUserDisabled
  54. @brief Message for @c FIRAuthErrorCodeUserDisabled error code.
  55. */
  56. static NSString *const kFIRAuthErrorMessageUserDisabled = @"The user account has been disabled by "
  57. "an administrator.";
  58. /** @var kFIRAuthErrorMessageEmailAlreadyInUse
  59. @brief Message for @c FIRAuthErrorCodeEmailAlreadyInUse error code.
  60. */
  61. static NSString *const kFIRAuthErrorMessageEmailAlreadyInUse = @"The email address is already in "
  62. "use by another account.";
  63. /** @var kFIRAuthErrorMessageWrongPassword
  64. @brief Message for @c FIRAuthErrorCodeWrongPassword error code.
  65. */
  66. static NSString *const kFIRAuthErrorMessageWrongPassword = @"The password is invalid or the user "
  67. "does not have a password.";
  68. /** @var kFIRAuthErrorMessageTooManyRequests
  69. @brief Message for @c FIRAuthErrorCodeTooManyRequests error code.
  70. */
  71. static NSString *const kFIRAuthErrorMessageTooManyRequests = @"We have blocked all requests from "
  72. "this device due to unusual activity. Try again later.";
  73. /** @var kFIRAuthErrorMessageAccountExistsWithDifferentCredential
  74. @brief Message for @c FIRAuthErrorCodeAccountLinkNeeded error code.
  75. */
  76. static NSString *const kFIRAuthErrorMessageAccountExistsWithDifferentCredential = @"An account "
  77. "already exists with the same email address but different sign-in credentials. Sign in using a "
  78. "provider associated with this email address.";
  79. /** @var kFIRAuthErrorMessageRequiresRecentLogin
  80. @brief Message for @c FIRAuthErrorCodeRequiresRecentLogin error code.
  81. */
  82. static NSString *const kFIRAuthErrorMessageRequiresRecentLogin= @"This operation is sensitive and "
  83. "requires recent authentication. Log in again before retrying this request.";
  84. /** @var kFIRAuthErrorMessageProviderAlreadyLinked
  85. @brief Message for @c FIRAuthErrorCodeProviderAlreadyExists error code.
  86. */
  87. static NSString *const kFIRAuthErrorMessageProviderAlreadyLinked =
  88. @"[ERROR_PROVIDER_ALREADY_LINKED] - User can only be linked to one identity for the given "
  89. "provider.";
  90. /** @var kFIRAuthErrorMessageNoSuchProvider
  91. @brief Message for @c FIRAuthErrorCodeNoSuchProvider error code.
  92. */
  93. static NSString *const kFIRAuthErrorMessageNoSuchProvider = @"User was not linked to an account "
  94. "with the given provider.";
  95. /** @var kFIRAuthErrorMessageInvalidUserToken
  96. @brief Message for @c FIRAuthErrorCodeInvalidUserToken error code.
  97. */
  98. static NSString *const kFIRAuthErrorMessageInvalidUserToken = @"The user's credential is no longer "
  99. "valid. The user must sign in again.";
  100. /** @var kFIRAuthErrorMessageNetworkError
  101. @brief Message for @c FIRAuthErrorCodeNetworkError error code.
  102. */
  103. static NSString *const kFIRAuthErrorMessageNetworkError = @"Network error (such as timeout, "
  104. "interrupted connection or unreachable host) has occurred.";
  105. /** @var kFIRAuthErrorMessageKeychainError
  106. @brief Message for @c FIRAuthErrorCodeKeychainError error code.
  107. */
  108. static NSString *const kFIRAuthErrorMessageKeychainError = @"An error occurred when accessing the "
  109. "keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary "
  110. "will contain more information about the error encountered";
  111. /** @var kFIRAuthErrorMessageUserTokenExpired
  112. @brief Message for @c FIRAuthErrorCodeTokenExpired error code.
  113. */
  114. static NSString *const kFIRAuthErrorMessageUserTokenExpired = @"The user's credential is no longer "
  115. "valid. The user must sign in again.";
  116. /** @var kFIRAuthErrorMessageUserNotFound
  117. @brief Message for @c FIRAuthErrorCodeUserNotFound error code.
  118. */
  119. static NSString *const kFIRAuthErrorMessageUserNotFound = @"There is no user record corresponding "
  120. "to this identifier. The user may have been deleted.";
  121. /** @var kFIRAuthErrorMessageInvalidAPIKey
  122. @brief Message for @c FIRAuthErrorCodeInvalidAPIKey error code.
  123. @remarks This error is not thrown by the server.
  124. */
  125. static NSString *const kFIRAuthErrorMessageInvalidAPIKey = @"An invalid API Key was supplied in "
  126. "the request.";
  127. /** @var kFIRAuthErrorMessageUserMismatch.
  128. @brief Message for @c FIRAuthErrorCodeInvalidAPIKey error code.
  129. */
  130. static NSString *const FIRAuthErrorMessageUserMismatch = @"The supplied credentials do not "
  131. "correspond to the previously signed in user.";
  132. /** @var kFIRAuthErrorMessageCredentialAlreadyInUse
  133. @brief Message for @c FIRAuthErrorCodeCredentialAlreadyInUse error code.
  134. */
  135. static NSString *const kFIRAuthErrorMessageCredentialAlreadyInUse = @"This credential is already "
  136. "associated with a different user account.";
  137. /** @var kFIRAuthErrorMessageOperationNotAllowed
  138. @brief Message for @c FIRAuthErrorCodeOperationNotAllowed error code.
  139. */
  140. static NSString *const kFIRAuthErrorMessageOperationNotAllowed = @"The given sign-in provider is "
  141. "disabled for this Firebase project. Enable it in the Firebase console, under the sign-in "
  142. "method tab of the Auth section.";
  143. /** @var kFIRAuthErrorMessageWeakPassword
  144. @brief Message for @c FIRAuthErrorCodeWeakPassword error code.
  145. */
  146. static NSString *const kFIRAuthErrorMessageWeakPassword = @"The password must be 6 characters long "
  147. "or more.";
  148. /** @var kFIRAuthErrorMessageAppNotAuthorized
  149. @brief Message for @c FIRAuthErrorCodeAppNotAuthorized error code.
  150. */
  151. static NSString *const kFIRAuthErrorMessageAppNotAuthorized = @"This app is not authorized to use "
  152. "Firebase Authentication with the provided API key. Review your key configuration in the "
  153. "Google API console and ensure that it accepts requests from your app's bundle ID.";
  154. /** @var kFIRAuthErrorMessageExpiredActionCode
  155. @brief Message for @c FIRAuthErrorCodeExpiredActionCode error code.
  156. */
  157. static NSString *const kFIRAuthErrorMessageExpiredActionCode = @"The action code has expired.";
  158. /** @var kFIRAuthErrorMessageInvalidActionCode
  159. @brief Message for @c FIRAuthErrorCodeInvalidActionCode error code.
  160. */
  161. static NSString *const kFIRAuthErrorMessageInvalidActionCode = @"The action code is invalid. This "
  162. "can happen if the code is malformed, expired, or has already been used.";
  163. /** @var kFIRAuthErrorMessageInvalidMessagePayload
  164. @brief Message for @c FIRAuthErrorCodeInvalidMessagePayload error code.
  165. */
  166. static NSString *const kFIRAuthErrorMessageInvalidMessagePayload = @"The action code is invalid. "
  167. "This can happen if the code is malformed, expired, or has already been used.";
  168. /** @var kFIRAuthErrorMessageInvalidSender
  169. @brief Message for @c FIRAuthErrorCodeInvalidSender error code.
  170. */
  171. static NSString *const kFIRAuthErrorMessageInvalidSender = @"The email template corresponding to "
  172. "this action contains invalid characters in its message. Please fix by going to the Auth email "
  173. "templates section in the Firebase Console.";
  174. /** @var kFIRAuthErrorMessageInvalidRecipientEmail
  175. @brief Message for @c FIRAuthErrorCodeInvalidRecipient error code.
  176. */
  177. static NSString *const kFIRAuthErrorMessageInvalidRecipientEmail = @"The action code is invalid. "
  178. "This can happen if the code is malformed, expired, or has already been used.";
  179. /** @var kFIRAuthErrorMessageMissingIosBundleID
  180. @brief Message for @c FIRAuthErrorCodeMissingIosbundleID error code.
  181. */
  182. static NSString *const kFIRAuthErrorMessageMissingIosBundleID =
  183. @"An iOS Bundle ID must be provided if an App Store ID is provided.";
  184. /** @var kFIRAuthErrorMessageMissingAndroidPackageName
  185. @brief Message for @c FIRAuthErrorCodeMissingAndroidPackageName error code.
  186. */
  187. static NSString *const kFIRAuthErrorMessageMissingAndroidPackageName =
  188. @"An Android Package Name must be provided if the Android App is required to be installed.";
  189. /** @var kFIRAuthErrorMessageUnauthorizedDomain
  190. @brief Message for @c FIRAuthErrorCodeUnauthorizedDomain error code.
  191. */
  192. static NSString *const kFIRAuthErrorMessageUnauthorizedDomain = @"The domain of the continue URL "
  193. "is not whitelisted. Please whitelist the domain in the Firebase console.";
  194. /** @var kFIRAuthErrorMessageInvalidContinueURI
  195. @brief Message for @c FIRAuthErrorCodeInvalidContinueURI error code.
  196. */
  197. static NSString *const kFIRAuthErrorMessageInvalidContinueURI =
  198. @"The continue URL provided in the request is invalid.";
  199. /** @var kFIRAuthErrorMessageMissingEmail
  200. @brief Message for @c FIRAuthErrorCodeMissingEmail error code.
  201. */
  202. static NSString *const kFIRAuthErrorMessageMissingEmail = @"An email address must be provided.";
  203. /** @var kFIRAuthErrorMessageMissingContinueURI
  204. @brief Message for @c FIRAuthErrorCodeMissingContinueURI error code.
  205. */
  206. static NSString *const kFIRAuthErrorMessageMissingContinueURI =
  207. @"A continue URL must be provided in the request.";
  208. /** @var kFIRAuthErrorMessageMissingPhoneNumber
  209. @brief Message for @c FIRAuthErrorCodeMissingPhoneNumber error code.
  210. */
  211. static NSString *const kFIRAuthErrorMessageMissingPhoneNumber =
  212. @"To send verification codes, provide a phone number for the recipient.";
  213. /** @var kFIRAuthErrorMessageInvalidPhoneNumber
  214. @brief Message for @c FIRAuthErrorCodeInvalidPhoneNumber error code.
  215. */
  216. static NSString *const kFIRAuthErrorMessageInvalidPhoneNumber =
  217. @"The format of the phone number provided is incorrect. Please enter the phone number in a "
  218. "format that can be parsed into E.164 format. E.164 phone numbers are written in the format "
  219. "[+][country code][subscriber number including area code].";
  220. /** @var kFIRAuthErrorMessageMissingVerificationCode
  221. @brief Message for @c FIRAuthErrorCodeMissingVerificationCode error code.
  222. */
  223. static NSString *const kFIRAuthErrorMessageMissingVerificationCode =
  224. @"The phone auth credential was created with an empty SMS verification Code.";
  225. /** @var kFIRAuthErrorMessageInvalidVerificationCode
  226. @brief Message for @c FIRAuthErrorCodeInvalidVerificationCode error code.
  227. */
  228. static NSString *const kFIRAuthErrorMessageInvalidVerificationCode =
  229. @"The SMS verification code used to create the phone auth credential is invalid. Please resend "
  230. "the verification code SMS and be sure to use the verification code provided by the user.";
  231. /** @var kFIRAuthErrorMessageMissingVerificationID
  232. @brief Message for @c FIRAuthErrorCodeInvalidVerificationID error code.
  233. */
  234. static NSString *const kFIRAuthErrorMessageMissingVerificationID =
  235. @"The phone auth credential was created with an empty verification ID.";
  236. /** @var kFIRAuthErrorMessageInvalidVerificationID
  237. @brief Message for @c FIRAuthErrorCodeInvalidVerificationID error code.
  238. */
  239. static NSString *const kFIRAuthErrorMessageInvalidVerificationID =
  240. @"The verification ID used to create the phone auth credential is invalid.";
  241. /** @var kFIRAuthErrorMessageSessionExpired
  242. @brief Message for @c FIRAuthErrorCodeSessionExpired error code.
  243. */
  244. static NSString *const kFIRAuthErrorMessageSessionExpired = @"The SMS code has expired. Please "
  245. @"re-send the verification code to try again.";
  246. /** @var kFIRAuthErrorMessageMissingAppCredential
  247. @brief Message for @c FIRAuthErrorCodeMissingAppCredential error code.
  248. */
  249. static NSString *const kFIRAuthErrorMessageMissingAppCredential = @"The phone verification request "
  250. "is missing an APNs Device token. Firebase Auth automatically detects APNs Device Tokens, "
  251. "however, if method swizzling is disabled, the APNs token must be set via the APNSToken "
  252. "property on FIRAuth or by calling setAPNSToken:type on FIRAuth.";
  253. /** @var kFIRAuthErrorMessageInvalidAppCredential
  254. @brief Message for @c FIRAuthErrorCodeInvalidAppCredential error code.
  255. */
  256. static NSString *const kFIRAuthErrorMessageInvalidAppCredential = @"The APNs device token provided "
  257. "is either incorrect or does not match the private certificate uploaded to the Firebase "
  258. "Console.";
  259. /** @var kFIRAuthErrorMessageQuotaExceeded
  260. @brief Message for @c FIRAuthErrorCodeQuotaExceeded error code.
  261. */
  262. static NSString *const kFIRAuthErrorMessageQuotaExceeded = @"The phone verification quota for this "
  263. "project has been exceeded.";
  264. /** @var kFIRAuthErrorMessageMissingAppToken
  265. @brief Message for @c FIRAuthErrorCodeMissingAppToken error code.
  266. */
  267. static NSString *const kFIRAuthErrorMessageMissingAppToken = @"There seems to be a problem with "
  268. "your project's Firebase phone number authentication set-up, please make sure to follow the "
  269. "instructions found at https://firebase.google.com/docs/auth/ios/phone-auth";
  270. /** @var kFIRAuthErrorMessageMissingAppToken
  271. @brief Message for @c FIRAuthErrorCodeMissingAppToken error code.
  272. */
  273. static NSString *const kFIRAuthErrorMessageNotificationNotForwarded = @"If app delegate swizzling "
  274. "is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to "
  275. "FIRAuth's canHandleNotificaton: method.";
  276. /** @var kFIRAuthErrorMessageAppNotVerified
  277. @brief Message for @c FIRAuthErrorCodeMissingAppToken error code.
  278. */
  279. static NSString *const kFIRAuthErrorMessageAppNotVerified = @"Firebase could not retrieve the "
  280. "silent push notification and therefore could not verify your app. Ensure that you configured "
  281. "your app correctly to recieve push notifications.";
  282. /** @var kFIRAuthErrorMessageCaptchaCheckFailed
  283. @brief Message for @c FIRAuthErrorCodeCaptchaCheckFailed error code.
  284. */
  285. static NSString *const kFIRAuthErrorMessageCaptchaCheckFailed = @"The reCAPTCHA response token "
  286. "provided is either invalid, expired or already";
  287. /** @var kFIRAuthErrorMessageInternalError
  288. @brief Message for @c FIRAuthErrorCodeInternalError error code.
  289. */
  290. static NSString *const kFIRAuthErrorMessageInternalError = @"An internal error has occurred, "
  291. "print and inspect the error details for more information.";
  292. /** @var FIRAuthErrorDescription
  293. @brief The error descrioption, based on the error code.
  294. @remarks No default case so that we get a compiler warning if a new value was added to the enum.
  295. */
  296. static NSString *FIRAuthErrorDescription(FIRAuthErrorCode code) {
  297. switch (code) {
  298. case FIRAuthErrorCodeInvalidCustomToken:
  299. return kFIRAuthErrorMessageInvalidCustomToken;
  300. case FIRAuthErrorCodeCustomTokenMismatch:
  301. return kFIRAuthErrorMessageCustomTokenMismatch;
  302. case FIRAuthErrorCodeInvalidEmail:
  303. return kFIRAuthErrorMessageInvalidEmail;
  304. case FIRAuthErrorCodeInvalidCredential:
  305. return kFIRAuthErrorMessageInvalidCredential;
  306. case FIRAuthErrorCodeUserDisabled:
  307. return kFIRAuthErrorMessageUserDisabled;
  308. case FIRAuthErrorCodeEmailAlreadyInUse:
  309. return kFIRAuthErrorMessageEmailAlreadyInUse;
  310. case FIRAuthErrorCodeWrongPassword:
  311. return kFIRAuthErrorMessageWrongPassword;
  312. case FIRAuthErrorCodeTooManyRequests:
  313. return kFIRAuthErrorMessageTooManyRequests;
  314. case FIRAuthErrorCodeAccountExistsWithDifferentCredential:
  315. return kFIRAuthErrorMessageAccountExistsWithDifferentCredential;
  316. case FIRAuthErrorCodeRequiresRecentLogin:
  317. return kFIRAuthErrorMessageRequiresRecentLogin;
  318. case FIRAuthErrorCodeProviderAlreadyLinked:
  319. return kFIRAuthErrorMessageProviderAlreadyLinked;
  320. case FIRAuthErrorCodeNoSuchProvider:
  321. return kFIRAuthErrorMessageNoSuchProvider;
  322. case FIRAuthErrorCodeInvalidUserToken:
  323. return kFIRAuthErrorMessageInvalidUserToken;
  324. case FIRAuthErrorCodeNetworkError:
  325. return kFIRAuthErrorMessageNetworkError;
  326. case FIRAuthErrorCodeKeychainError:
  327. return kFIRAuthErrorMessageKeychainError;
  328. case FIRAuthErrorCodeUserTokenExpired:
  329. return kFIRAuthErrorMessageUserTokenExpired;
  330. case FIRAuthErrorCodeUserNotFound:
  331. return kFIRAuthErrorMessageUserNotFound;
  332. case FIRAuthErrorCodeInvalidAPIKey:
  333. return kFIRAuthErrorMessageInvalidAPIKey;
  334. case FIRAuthErrorCodeCredentialAlreadyInUse:
  335. return kFIRAuthErrorMessageCredentialAlreadyInUse;
  336. case FIRAuthErrorCodeInternalError:
  337. return kFIRAuthErrorMessageInternalError;
  338. case FIRAuthErrorCodeUserMismatch:
  339. return FIRAuthErrorMessageUserMismatch;
  340. case FIRAuthErrorCodeOperationNotAllowed:
  341. return kFIRAuthErrorMessageOperationNotAllowed;
  342. case FIRAuthErrorCodeWeakPassword:
  343. return kFIRAuthErrorMessageWeakPassword;
  344. case FIRAuthErrorCodeAppNotAuthorized:
  345. return kFIRAuthErrorMessageAppNotAuthorized;
  346. case FIRAuthErrorCodeExpiredActionCode:
  347. return kFIRAuthErrorMessageExpiredActionCode;
  348. case FIRAuthErrorCodeInvalidActionCode:
  349. return kFIRAuthErrorMessageInvalidActionCode;
  350. case FIRAuthErrorCodeInvalidSender:
  351. return kFIRAuthErrorMessageInvalidSender;
  352. case FIRAuthErrorCodeInvalidMessagePayload:
  353. return kFIRAuthErrorMessageInvalidMessagePayload;
  354. case FIRAuthErrorCodeInvalidRecipientEmail:
  355. return kFIRAuthErrorMessageInvalidRecipientEmail;
  356. case FIRAuthErrorCodeMissingIosBundleID:
  357. return kFIRAuthErrorMessageMissingIosBundleID;
  358. case FIRAuthErrorCodeMissingAndroidPackageName:
  359. return kFIRAuthErrorMessageMissingAndroidPackageName;
  360. case FIRAuthErrorCodeUnauthorizedDomain:
  361. return kFIRAuthErrorMessageUnauthorizedDomain;
  362. case FIRAuthErrorCodeInvalidContinueURI:
  363. return kFIRAuthErrorMessageInvalidContinueURI;
  364. case FIRAuthErrorCodeMissingContinueURI:
  365. return kFIRAuthErrorMessageMissingContinueURI;
  366. case FIRAuthErrorCodeMissingEmail:
  367. return kFIRAuthErrorMessageMissingEmail;
  368. case FIRAuthErrorCodeMissingPhoneNumber:
  369. return kFIRAuthErrorMessageMissingPhoneNumber;
  370. case FIRAuthErrorCodeInvalidPhoneNumber:
  371. return kFIRAuthErrorMessageInvalidPhoneNumber;
  372. case FIRAuthErrorCodeMissingVerificationCode:
  373. return kFIRAuthErrorMessageMissingVerificationCode;
  374. case FIRAuthErrorCodeInvalidVerificationCode:
  375. return kFIRAuthErrorMessageInvalidVerificationCode;
  376. case FIRAuthErrorCodeMissingVerificationID:
  377. return kFIRAuthErrorMessageMissingVerificationID;
  378. case FIRAuthErrorCodeInvalidVerificationID:
  379. return kFIRAuthErrorMessageInvalidVerificationID;
  380. case FIRAuthErrorCodeSessionExpired:
  381. return kFIRAuthErrorMessageSessionExpired;
  382. case FIRAuthErrorCodeMissingAppCredential:
  383. return kFIRAuthErrorMessageMissingAppCredential;
  384. case FIRAuthErrorCodeInvalidAppCredential:
  385. return kFIRAuthErrorMessageInvalidAppCredential;
  386. case FIRAuthErrorCodeQuotaExceeded:
  387. return kFIRAuthErrorMessageQuotaExceeded;
  388. case FIRAuthErrorCodeMissingAppToken:
  389. return kFIRAuthErrorMessageMissingAppToken;
  390. case FIRAuthErrorCodeNotificationNotForwarded:
  391. return kFIRAuthErrorMessageNotificationNotForwarded;
  392. case FIRAuthErrorCodeAppNotVerified:
  393. return kFIRAuthErrorMessageAppNotVerified;
  394. case FIRAuthErrorCodeCaptchaCheckFailed:
  395. return kFIRAuthErrorMessageCaptchaCheckFailed;
  396. }
  397. }
  398. /** @var FIRAuthErrorCodeString
  399. @brief The the error short string, based on the error code.
  400. @remarks No default case so that we get a compiler warning if a new value was added to the enum.
  401. */
  402. static NSString *const FIRAuthErrorCodeString(FIRAuthErrorCode code) {
  403. switch (code) {
  404. case FIRAuthErrorCodeInvalidCustomToken:
  405. return @"ERROR_INVALID_CUSTOM_TOKEN";
  406. case FIRAuthErrorCodeCustomTokenMismatch:
  407. return @"ERROR_CUSTOM_TOKEN_MISMATCH";
  408. case FIRAuthErrorCodeInvalidEmail:
  409. return @"ERROR_INVALID_EMAIL";
  410. case FIRAuthErrorCodeInvalidCredential:
  411. return @"ERROR_INVALID_CREDENTIAL";
  412. case FIRAuthErrorCodeUserDisabled:
  413. return @"ERROR_USER_DISABLED";
  414. case FIRAuthErrorCodeEmailAlreadyInUse:
  415. return @"ERROR_EMAIL_ALREADY_IN_USE";
  416. case FIRAuthErrorCodeWrongPassword:
  417. return @"ERROR_WRONG_PASSWORD";
  418. case FIRAuthErrorCodeTooManyRequests:
  419. return @"ERROR_TOO_MANY_REQUESTS";
  420. case FIRAuthErrorCodeAccountExistsWithDifferentCredential:
  421. return @"ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL";
  422. case FIRAuthErrorCodeRequiresRecentLogin:
  423. return @"ERROR_REQUIRES_RECENT_LOGIN";
  424. case FIRAuthErrorCodeProviderAlreadyLinked:
  425. return @"ERROR_PROVIDER_ALREADY_LINKED";
  426. case FIRAuthErrorCodeNoSuchProvider:
  427. return @"ERROR_NO_SUCH_PROVIDER";
  428. case FIRAuthErrorCodeInvalidUserToken:
  429. return @"ERROR_INVALID_USER_TOKEN";
  430. case FIRAuthErrorCodeNetworkError:
  431. return @"ERROR_NETWORK_REQUEST_FAILED";
  432. case FIRAuthErrorCodeKeychainError:
  433. return @"ERROR_KEYCHAIN_ERROR";
  434. case FIRAuthErrorCodeUserTokenExpired:
  435. return @"ERROR_USER_TOKEN_EXPIRED";
  436. case FIRAuthErrorCodeUserNotFound:
  437. return @"ERROR_USER_NOT_FOUND";
  438. case FIRAuthErrorCodeInvalidAPIKey:
  439. return @"ERROR_INVALID_API_KEY";
  440. case FIRAuthErrorCodeCredentialAlreadyInUse:
  441. return @"ERROR_CREDENTIAL_ALREADY_IN_USE";
  442. case FIRAuthErrorCodeInternalError:
  443. return @"ERROR_INTERNAL_ERROR";
  444. case FIRAuthErrorCodeUserMismatch:
  445. return @"ERROR_USER_MISMATCH";
  446. case FIRAuthErrorCodeOperationNotAllowed:
  447. return @"ERROR_OPERATION_NOT_ALLOWED";
  448. case FIRAuthErrorCodeWeakPassword:
  449. return @"ERROR_WEAK_PASSWORD";
  450. case FIRAuthErrorCodeAppNotAuthorized:
  451. return @"ERROR_APP_NOT_AUTHORIZED";
  452. case FIRAuthErrorCodeExpiredActionCode:
  453. return @"ERROR_EXPIRED_ACTION_CODE";
  454. case FIRAuthErrorCodeInvalidActionCode:
  455. return @"ERROR_INVALID_ACTION_CODE";
  456. case FIRAuthErrorCodeInvalidMessagePayload:
  457. return @"ERROR_INVALID_MESSAGE_PAYLOAD";
  458. case FIRAuthErrorCodeInvalidSender:
  459. return @"ERROR_INVALID_SENDER";
  460. case FIRAuthErrorCodeInvalidRecipientEmail:
  461. return @"ERROR_INVALID_RECIPIENT_EMAIL";
  462. case FIRAuthErrorCodeMissingIosBundleID:
  463. return @"ERROR_MISSING_IOS_BUNDLE_ID";
  464. case FIRAuthErrorCodeMissingAndroidPackageName:
  465. return @"ERROR_MISSING_ANDROID_PKG_NAME";
  466. case FIRAuthErrorCodeUnauthorizedDomain:
  467. return @"ERROR_UNAUTHORIZED_DOMAIN";
  468. case FIRAuthErrorCodeInvalidContinueURI:
  469. return @"ERROR_INVALID_CONTINUE_URI";
  470. case FIRAuthErrorCodeMissingContinueURI:
  471. return @"ERROR_MISSING_CONTINUE_URI";
  472. case FIRAuthErrorCodeMissingEmail:
  473. return @"ERROR_MISSING_EMAIL";
  474. case FIRAuthErrorCodeMissingPhoneNumber:
  475. return @"ERROR_MISSING_PHONE_NUMBER";
  476. case FIRAuthErrorCodeInvalidPhoneNumber:
  477. return @"ERROR_INVALID_PHONE_NUMBER";
  478. case FIRAuthErrorCodeMissingVerificationCode:
  479. return @"ERROR_MISSING_VERIFICATION_CODE";
  480. case FIRAuthErrorCodeInvalidVerificationCode:
  481. return @"ERROR_INVALID_VERIFICATION_CODE";
  482. case FIRAuthErrorCodeMissingVerificationID:
  483. return @"ERROR_MISSING_VERIFICATION_ID";
  484. case FIRAuthErrorCodeInvalidVerificationID:
  485. return @"ERROR_INVALID_VERIFICATION_ID";
  486. case FIRAuthErrorCodeSessionExpired:
  487. return @"ERROR_SESSION_EXPIRED";
  488. case FIRAuthErrorCodeMissingAppCredential:
  489. return @"MISSING_APP_CREDENTIAL";
  490. case FIRAuthErrorCodeInvalidAppCredential:
  491. return @"INVALID_APP_CREDENTIAL";
  492. case FIRAuthErrorCodeQuotaExceeded:
  493. return @"ERROR_QUOTA_EXCEEDED";
  494. case FIRAuthErrorCodeMissingAppToken:
  495. return @"ERROR_MISSING_APP_TOKEN";
  496. case FIRAuthErrorCodeNotificationNotForwarded:
  497. return @"ERROR_NOTIFICATION_NOT_FORWARDED";
  498. case FIRAuthErrorCodeAppNotVerified:
  499. return @"ERROR_APP_NOT_VERIFIED";
  500. case FIRAuthErrorCodeCaptchaCheckFailed:
  501. return @"ERROR_CAPTCHA_CHECK_FAILED";
  502. }
  503. }
  504. @implementation FIRAuthErrorUtils
  505. + (NSError *)errorWithCode:(FIRAuthInternalErrorCode)code {
  506. return [self errorWithCode:code message:nil];
  507. }
  508. + (NSError *)errorWithCode:(FIRAuthInternalErrorCode)code
  509. message:(nullable NSString *)message {
  510. NSDictionary *userInfo = nil;
  511. if (message.length) {
  512. userInfo = @{
  513. NSLocalizedDescriptionKey : message
  514. };
  515. }
  516. return [self errorWithCode:code userInfo:userInfo];
  517. }
  518. + (NSError *)errorWithCode:(FIRAuthInternalErrorCode)code
  519. underlyingError:(nullable NSError *)underlyingError {
  520. NSDictionary *errorUserInfo = nil;
  521. if (underlyingError) {
  522. errorUserInfo = @{
  523. NSUnderlyingErrorKey : underlyingError
  524. };
  525. }
  526. return [self errorWithCode:code userInfo:errorUserInfo];
  527. }
  528. + (NSError *)errorWithCode:(FIRAuthInternalErrorCode)code userInfo:(NSDictionary *)userInfo {
  529. BOOL isPublic = (code & FIRAuthPublicErrorCodeFlag) == FIRAuthPublicErrorCodeFlag;
  530. if (isPublic) {
  531. // This is a public error. Return it as a public error and add a description.
  532. NSInteger errorCode = code & ~FIRAuthPublicErrorCodeFlag;
  533. NSMutableDictionary *errorUserInfo = [NSMutableDictionary dictionaryWithDictionary:userInfo];
  534. if (!errorUserInfo[NSLocalizedDescriptionKey]) {
  535. errorUserInfo[NSLocalizedDescriptionKey] = FIRAuthErrorDescription(errorCode);
  536. }
  537. errorUserInfo[FIRAuthErrorNameKey] = FIRAuthErrorCodeString(errorCode);
  538. return [NSError errorWithDomain:FIRAuthErrorDomain code:errorCode userInfo:errorUserInfo];
  539. } else {
  540. // This is an internal error. Wrap it in an internal error.
  541. NSError *error =
  542. [NSError errorWithDomain:FIRAuthInternalErrorDomain code:code userInfo:userInfo];
  543. return [self errorWithCode:FIRAuthInternalErrorCodeInternalError underlyingError:error];
  544. }
  545. }
  546. + (NSError *)RPCRequestEncodingErrorWithUnderlyingError:(NSError *)underlyingError {
  547. return [self errorWithCode:FIRAuthInternalErrorCodeRPCRequestEncodingError
  548. underlyingError:underlyingError];
  549. }
  550. + (NSError *)JSONSerializationErrorForUnencodableType {
  551. return [self errorWithCode:FIRAuthInternalErrorCodeJSONSerializationError];
  552. }
  553. + (NSError *)JSONSerializationErrorWithUnderlyingError:(NSError *)underlyingError {
  554. return [self errorWithCode:FIRAuthInternalErrorCodeJSONSerializationError
  555. underlyingError:underlyingError];
  556. }
  557. + (NSError *)networkErrorWithUnderlyingError:(NSError *)underlyingError {
  558. return [self errorWithCode:FIRAuthInternalErrorCodeNetworkError
  559. underlyingError:underlyingError];
  560. }
  561. + (NSError *)unexpectedErrorResponseWithData:(NSData *)data
  562. underlyingError:(NSError *)underlyingError {
  563. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedErrorResponse userInfo:@{
  564. FIRAuthErrorUserInfoDataKey : data,
  565. NSUnderlyingErrorKey : underlyingError
  566. }];
  567. }
  568. + (NSError *)unexpectedErrorResponseWithDeserializedResponse:(id)deserializedResponse {
  569. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedErrorResponse userInfo:@{
  570. FIRAuthErrorUserInfoDeserializedResponseKey : deserializedResponse
  571. }];
  572. }
  573. + (NSError *)unexpectedResponseWithData:(NSData *)data
  574. underlyingError:(NSError *)underlyingError {
  575. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedResponse userInfo:@{
  576. FIRAuthErrorUserInfoDataKey : data,
  577. NSUnderlyingErrorKey : underlyingError
  578. }];
  579. }
  580. + (NSError *)unexpectedResponseWithDeserializedResponse:(id)deserializedResponse {
  581. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedResponse userInfo:@{
  582. FIRAuthErrorUserInfoDeserializedResponseKey : deserializedResponse
  583. }];
  584. }
  585. + (NSError *)unexpectedResponseWithDeserializedResponse:(nullable id)deserializedResponse
  586. underlyingError:(NSError *)underlyingError {
  587. NSMutableDictionary *userInfo =
  588. [NSMutableDictionary dictionaryWithDictionary:@{ NSUnderlyingErrorKey : underlyingError }];
  589. if (deserializedResponse) {
  590. userInfo[FIRAuthErrorUserInfoDeserializedResponseKey] = deserializedResponse;
  591. }
  592. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedResponse userInfo:userInfo];
  593. }
  594. + (NSError *)RPCResponseDecodingErrorWithDeserializedResponse:(id)deserializedResponse
  595. underlyingError:(NSError *)underlyingError {
  596. return [self errorWithCode:FIRAuthInternalErrorCodeRPCResponseDecodingError userInfo:@{
  597. FIRAuthErrorUserInfoDeserializedResponseKey : deserializedResponse,
  598. NSUnderlyingErrorKey : underlyingError
  599. }];
  600. }
  601. + (NSError *)emailAlreadyInUseErrorWithEmail:(nullable NSString *)email {
  602. NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
  603. if (email.length) {
  604. userInfo[FIRAuthErrorUserInfoEmailKey] = email;
  605. }
  606. return [self errorWithCode:FIRAuthInternalErrorCodeEmailAlreadyInUse userInfo:userInfo];
  607. }
  608. + (NSError *)userDisabledErrorWithMessage:(nullable NSString *)message {
  609. return [self errorWithCode:FIRAuthInternalErrorCodeUserDisabled message:message];
  610. }
  611. + (NSError *)wrongPasswordErrorWithMessage:(nullable NSString *)message {
  612. return [self errorWithCode:FIRAuthInternalErrorCodeWrongPassword message:message];
  613. }
  614. + (NSError *)tooManyRequestsErrorWithMessage:(nullable NSString *)message {
  615. return [self errorWithCode:FIRAuthInternalErrorCodeTooManyRequests message:message];
  616. }
  617. + (NSError *)invalidCustomTokenErrorWithMessage:(nullable NSString *)message {
  618. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidCustomToken message:message];
  619. }
  620. + (NSError *)customTokenMistmatchErrorWithMessage:(nullable NSString *)message {
  621. return [self errorWithCode:FIRAuthInternalErrorCodeCustomTokenMismatch message:message];
  622. }
  623. + (NSError *)invalidCredentialErrorWithMessage:(nullable NSString *)message {
  624. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidCredential message:message];
  625. }
  626. + (NSError *)requiresRecentLoginErrorWithMessage:(nullable NSString *)message {
  627. return [self errorWithCode:FIRAuthInternalErrorCodeRequiresRecentLogin message:message];
  628. }
  629. + (NSError *)invalidUserTokenErrorWithMessage:(nullable NSString *)message {
  630. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidUserToken message:message];
  631. }
  632. + (NSError *)invalidEmailErrorWithMessage:(nullable NSString *)message {
  633. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidEmail message:message];
  634. }
  635. + (NSError *)accountExistsWithDifferentCredentialErrorWithEmail:(nullable NSString *)email {
  636. return [self errorWithCode:FIRAuthInternalErrorCodeAccountExistsWithDifferentCredential
  637. userInfo:@{ FIRAuthErrorUserInfoEmailKey : email }];
  638. }
  639. + (NSError *)providerAlreadyLinkedError {
  640. return [self errorWithCode:FIRAuthInternalErrorCodeProviderAlreadyLinked];
  641. }
  642. + (NSError *)noSuchProviderError {
  643. return [self errorWithCode:FIRAuthInternalErrorCodeNoSuchProvider];
  644. }
  645. + (NSError *)userTokenExpiredErrorWithMessage:(nullable NSString *)message {
  646. return [self errorWithCode:FIRAuthInternalErrorCodeUserTokenExpired message:message];
  647. }
  648. + (NSError *)userNotFoundErrorWithMessage:(nullable NSString *)message {
  649. return [self errorWithCode:FIRAuthInternalErrorCodeUserNotFound message:message];
  650. }
  651. + (NSError *)invalidAPIKeyError {
  652. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidAPIKey];
  653. }
  654. + (NSError *)userMismatchError {
  655. return [self errorWithCode:FIRAuthInternalErrorCodeUserMismatch];
  656. }
  657. + (NSError *)credentialAlreadyInUseErrorWithMessage:(nullable NSString *)message
  658. credential:(nullable FIRPhoneAuthCredential *)credential {
  659. if (credential) {
  660. return [self errorWithCode:FIRAuthInternalErrorCodeCredentialAlreadyInUse
  661. userInfo:@{ FIRAuthUpdatedCredentialKey : credential }];
  662. }
  663. return [self errorWithCode:FIRAuthInternalErrorCodeCredentialAlreadyInUse message:message];
  664. }
  665. + (NSError *)operationNotAllowedErrorWithMessage:(nullable NSString *)message {
  666. return [self errorWithCode:FIRAuthInternalErrorCodeOperationNotAllowed message:message];
  667. }
  668. + (NSError *)weakPasswordErrorWithServerResponseReason:(NSString *)reason {
  669. return [self errorWithCode:FIRAuthInternalErrorCodeWeakPassword userInfo:@{
  670. NSLocalizedFailureReasonErrorKey : reason
  671. }];
  672. }
  673. + (NSError *)appNotAuthorizedError {
  674. return [self errorWithCode:FIRAuthInternalErrorCodeAppNotAuthorized];
  675. }
  676. + (NSError *)expiredActionCodeErrorWithMessage:(nullable NSString *)message {
  677. return [self errorWithCode:FIRAuthInternalErrorCodeExpiredActionCode message:message];
  678. }
  679. + (NSError *)invalidActionCodeErrorWithMessage:(nullable NSString *)message {
  680. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidActionCode message:message];
  681. }
  682. + (NSError *)invalidMessagePayloadErrorWithMessage:(nullable NSString *)message {
  683. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidMessagePayload message:message];
  684. }
  685. + (NSError *)invalidSenderErrorWithMessage:(nullable NSString *)message {
  686. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidSender message:message];
  687. }
  688. + (NSError *)invalidRecipientEmailErrorWithMessage:(nullable NSString *)message {
  689. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidRecipientEmail message:message];
  690. }
  691. + (NSError *)missingIosBundleIDErrorWithMessage:(nullable NSString *)message {
  692. return [self errorWithCode:FIRAuthinternalErrorCodeMissingIosBundleID message:message];
  693. }
  694. + (NSError *)missingAndroidPackageNameErrorWithMessage:(nullable NSString *)message {
  695. return [self errorWithCode:FIRAuthInternalErrorCodeMissingAndroidPackageName message:message];
  696. }
  697. + (NSError *)unauthorizedDomainErrorWithMessage:(nullable NSString *)message {
  698. return [self errorWithCode:FIRAuthInternalErrorCodeUnauthorizedDomain message:message];
  699. }
  700. + (NSError *)invalidContinueURIErrorWithMessage:(nullable NSString *)message {
  701. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidContinueURI message:message];
  702. }
  703. + (NSError *)missingContinueURIErrorWithMessage:(nullable NSString *)message {
  704. return[self errorWithCode:FIRAuthInternalErrorCodeMissingContinueURI message:message];
  705. }
  706. + (NSError *)missingEmailErrorWithMessage:(nullable NSString *)message {
  707. return [self errorWithCode:FIRAuthInternalErrorCodeMissingEmail message:message];
  708. }
  709. + (NSError *)missingPhoneNumberErrorWithMessage:(nullable NSString *)message {
  710. return [self errorWithCode:FIRAuthInternalErrorCodeMissingPhoneNumber message:message];
  711. }
  712. + (NSError *)invalidPhoneNumberErrorWithMessage:(nullable NSString *)message {
  713. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidPhoneNumber message:message];
  714. }
  715. + (NSError *)missingVerificationCodeErrorWithMessage:(nullable NSString *)message {
  716. return [self errorWithCode:FIRAuthInternalErrorCodeMissingVerificationCode message:message];
  717. }
  718. + (NSError *)invalidVerificationCodeErrorWithMessage:(nullable NSString *)message {
  719. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidVerificationCode message:message];
  720. }
  721. + (NSError *)missingVerificationIDErrorWithMessage:(nullable NSString *)message {
  722. return [self errorWithCode:FIRAuthInternalErrorCodeMissingVerificationID message:message];
  723. }
  724. + (NSError *)invalidVerificationIDErrorWithMessage:(nullable NSString *)message {
  725. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidVerificationID message:message];
  726. }
  727. + (NSError *)sessionExpiredErrorWithMessage:(nullable NSString *)message {
  728. return [self errorWithCode:FIRAuthInternalErrorCodeSessionExpired message:message];
  729. }
  730. + (NSError *)missingAppCredentialWithMessage:(nullable NSString *)message {
  731. return [self errorWithCode:FIRAuthInternalErrorCodeMissingAppCredential message:message];
  732. }
  733. + (NSError *)invalidAppCredentialWithMessage:(nullable NSString *)message {
  734. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidAppCredential message:message];
  735. }
  736. + (NSError *)quotaExceededErrorWithMessage:(nullable NSString *)message {
  737. return [self errorWithCode:FIRAuthInternalErrorCodeQuotaExceeded message:message];
  738. }
  739. + (NSError *)missingAppTokenError {
  740. return [self errorWithCode:FIRAuthInternalErrorCodeMissingAppToken];
  741. }
  742. + (NSError *)notificationNotForwardedError {
  743. return [self errorWithCode:FIRAuthInternalErrorCodeNotificationNotForwarded];
  744. }
  745. + (NSError *)appNotVerifiedErrorWithMessage:(nullable NSString *)message {
  746. return [self errorWithCode:FIRAuthInternalErrorCodeAppNotVerified message:message];
  747. }
  748. + (NSError *)captchaCheckFailedErrorWithMessage:(nullable NSString *)message {
  749. return [self errorWithCode:FIRAuthInternalErrorCodeCaptchaCheckFailed message:message];
  750. }
  751. + (NSError *)keychainErrorWithFunction:(NSString *)keychainFunction status:(OSStatus)status {
  752. NSString *failureReason = [NSString stringWithFormat:@"%@ (%li)", keychainFunction, (long)status];
  753. return [self errorWithCode:FIRAuthInternalErrorCodeKeychainError userInfo:@{
  754. NSLocalizedFailureReasonErrorKey : failureReason,
  755. }];
  756. }
  757. @end
  758. NS_ASSUME_NONNULL_END