FIRAuthErrorUtils.m 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522
  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 "FirebaseAuth/Sources/Utilities/FIRAuthErrorUtils.h"
  17. #import "FirebaseAuth/Sources/Public/FirebaseAuth/FIRAuthCredential.h"
  18. #import "FirebaseAuth/Sources/MultiFactor/FIRMultiFactorResolver+Internal.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 FIRAuthErrorUserInfoUpdatedCredentialKey =
  27. @"FIRAuthErrorUserInfoUpdatedCredentialKey";
  28. NSString *const FIRAuthErrorUserInfoNameKey = @"FIRAuthErrorUserInfoNameKey";
  29. NSString *const FIRAuthErrorUserInfoMultiFactorResolverKey =
  30. @"FIRAuthErrorUserInfoMultiFactorResolverKey";
  31. /** @var kServerErrorDetailMarker
  32. @brief This marker indicates that the server error message contains a detail error message which
  33. should be used instead of the hardcoded client error message.
  34. */
  35. static NSString *const kServerErrorDetailMarker = @" : ";
  36. #pragma mark - URL response error codes
  37. /** @var kURLResponseErrorCodeInvalidClientID
  38. @brief Error code that indicates that the client ID provided was invalid.
  39. */
  40. static NSString *const kURLResponseErrorCodeInvalidClientID = @"auth/invalid-oauth-client-id";
  41. /** @var kURLResponseErrorCodeNetworkRequestFailed
  42. @brief Error code that indicates that a network request within the SFSafariViewController or
  43. WKWebView failed.
  44. */
  45. static NSString *const kURLResponseErrorCodeNetworkRequestFailed = @"auth/network-request-failed";
  46. /** @var kURLResponseErrorCodeInternalError
  47. @brief Error code that indicates that an internal error occurred within the
  48. SFSafariViewController or WKWebView failed.
  49. */
  50. static NSString *const kURLResponseErrorCodeInternalError = @"auth/internal-error";
  51. #pragma mark - Standard Error Messages
  52. /** @var kFIRAuthErrorMessageInvalidCustomToken
  53. @brief Message for @c FIRAuthErrorCodeInvalidCustomToken error code.
  54. */
  55. static NSString *const kFIRAuthErrorMessageInvalidCustomToken =
  56. @"The custom token format is "
  57. "incorrect. Please check the documentation.";
  58. /** @var kFIRAuthErrorMessageCustomTokenMismatch
  59. @brief Message for @c FIRAuthErrorCodeCustomTokenMismatch error code.
  60. */
  61. static NSString *const kFIRAuthErrorMessageCustomTokenMismatch = @"The custom token corresponds to "
  62. "a different audience or issuer.";
  63. /** @var kFIRAuthErrorMessageInvalidEmail
  64. @brief Message for @c FIRAuthErrorCodeInvalidEmail error code.
  65. */
  66. static NSString *const kFIRAuthErrorMessageInvalidEmail = @"The email address is badly formatted.";
  67. /** @var kFIRAuthErrorMessageInvalidCredential
  68. @brief Message for @c FIRAuthErrorCodeInvalidCredential error code.
  69. */
  70. static NSString *const kFIRAuthErrorMessageInvalidCredential = @"The supplied auth credential is "
  71. "malformed or has expired.";
  72. /** @var kFIRAuthErrorMessageUserDisabled
  73. @brief Message for @c FIRAuthErrorCodeUserDisabled error code.
  74. */
  75. static NSString *const kFIRAuthErrorMessageUserDisabled = @"The user account has been disabled by "
  76. "an administrator.";
  77. /** @var kFIRAuthErrorMessageEmailAlreadyInUse
  78. @brief Message for @c FIRAuthErrorCodeEmailAlreadyInUse error code.
  79. */
  80. static NSString *const kFIRAuthErrorMessageEmailAlreadyInUse = @"The email address is already in "
  81. "use by another account.";
  82. /** @var kFIRAuthErrorMessageWrongPassword
  83. @brief Message for @c FIRAuthErrorCodeWrongPassword error code.
  84. */
  85. static NSString *const kFIRAuthErrorMessageWrongPassword = @"The password is invalid or the user "
  86. "does not have a password.";
  87. /** @var kFIRAuthErrorMessageTooManyRequests
  88. @brief Message for @c FIRAuthErrorCodeTooManyRequests error code.
  89. */
  90. static NSString *const kFIRAuthErrorMessageTooManyRequests =
  91. @"We have blocked all requests from "
  92. "this device due to unusual activity. Try again later.";
  93. /** @var kFIRAuthErrorMessageAccountExistsWithDifferentCredential
  94. @brief Message for @c FIRAuthErrorCodeAccountExistsWithDifferentCredential error code.
  95. */
  96. static NSString *const kFIRAuthErrorMessageAccountExistsWithDifferentCredential =
  97. @"An account "
  98. "already exists with the same email address but different sign-in credentials. Sign in using "
  99. "a "
  100. "provider associated with this email address.";
  101. /** @var kFIRAuthErrorMessageRequiresRecentLogin
  102. @brief Message for @c FIRAuthErrorCodeRequiresRecentLogin error code.
  103. */
  104. static NSString *const kFIRAuthErrorMessageRequiresRecentLogin =
  105. @"This operation is sensitive and "
  106. "requires recent authentication. Log in again before retrying this request.";
  107. /** @var kFIRAuthErrorMessageProviderAlreadyLinked
  108. @brief Message for @c FIRAuthErrorCodeProviderAlreadyExists error code.
  109. */
  110. static NSString *const kFIRAuthErrorMessageProviderAlreadyLinked =
  111. @"[ERROR_PROVIDER_ALREADY_LINKED] - User can only be linked to one identity for the given "
  112. "provider.";
  113. /** @var kFIRAuthErrorMessageNoSuchProvider
  114. @brief Message for @c FIRAuthErrorCodeNoSuchProvider error code.
  115. */
  116. static NSString *const kFIRAuthErrorMessageNoSuchProvider = @"User was not linked to an account "
  117. "with the given provider.";
  118. /** @var kFIRAuthErrorMessageInvalidUserToken
  119. @brief Message for @c FIRAuthErrorCodeInvalidUserToken error code.
  120. */
  121. static NSString *const kFIRAuthErrorMessageInvalidUserToken =
  122. @"This user's credential isn't valid "
  123. "for this project. This can happen if the user's token has been tampered with, or if the user "
  124. "doesn’t belong to the project associated with the API key used in your request.";
  125. /** @var kFIRAuthErrorMessageNetworkError
  126. @brief Message for @c FIRAuthErrorCodeNetworkError error code.
  127. */
  128. static NSString *const kFIRAuthErrorMessageNetworkError =
  129. @"Network error (such as timeout, "
  130. "interrupted connection or unreachable host) has occurred.";
  131. /** @var kFIRAuthErrorMessageKeychainError
  132. @brief Message for @c FIRAuthErrorCodeKeychainError error code.
  133. */
  134. static NSString *const kFIRAuthErrorMessageKeychainError =
  135. @"An error occurred when accessing the "
  136. "keychain. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary "
  137. "will contain more information about the error encountered";
  138. /** @var kFIRAuthErrorMessageUserTokenExpired
  139. @brief Message for @c FIRAuthErrorCodeTokenExpired error code.
  140. */
  141. static NSString *const kFIRAuthErrorMessageUserTokenExpired =
  142. @"The user's credential is no longer "
  143. "valid. The user must sign in again.";
  144. /** @var kFIRAuthErrorMessageUserNotFound
  145. @brief Message for @c FIRAuthErrorCodeUserNotFound error code.
  146. */
  147. static NSString *const kFIRAuthErrorMessageUserNotFound =
  148. @"There is no user record corresponding "
  149. "to this identifier. The user may have been deleted.";
  150. /** @var kFIRAuthErrorMessageInvalidAPIKey
  151. @brief Message for @c FIRAuthErrorCodeInvalidAPIKey error code.
  152. @remarks This error is not thrown by the server.
  153. */
  154. static NSString *const kFIRAuthErrorMessageInvalidAPIKey = @"An invalid API Key was supplied in "
  155. "the request.";
  156. /** @var kFIRAuthErrorMessageUserMismatch.
  157. @brief Message for @c FIRAuthErrorCodeInvalidAPIKey error code.
  158. */
  159. static NSString *const FIRAuthErrorMessageUserMismatch =
  160. @"The supplied credentials do not "
  161. "correspond to the previously signed in user.";
  162. /** @var kFIRAuthErrorMessageCredentialAlreadyInUse
  163. @brief Message for @c FIRAuthErrorCodeCredentialAlreadyInUse error code.
  164. */
  165. static NSString *const kFIRAuthErrorMessageCredentialAlreadyInUse =
  166. @"This credential is already "
  167. "associated with a different user account.";
  168. /** @var kFIRAuthErrorMessageOperationNotAllowed
  169. @brief Message for @c FIRAuthErrorCodeOperationNotAllowed error code.
  170. */
  171. static NSString *const kFIRAuthErrorMessageOperationNotAllowed =
  172. @"The given sign-in provider is "
  173. "disabled for this Firebase project. Enable it in the Firebase console, under the sign-in "
  174. "method tab of the Auth section.";
  175. /** @var kFIRAuthErrorMessageWeakPassword
  176. @brief Message for @c FIRAuthErrorCodeWeakPassword error code.
  177. */
  178. static NSString *const kFIRAuthErrorMessageWeakPassword = @"The password must be 6 characters long "
  179. "or more.";
  180. /** @var kFIRAuthErrorMessageAppNotAuthorized
  181. @brief Message for @c FIRAuthErrorCodeAppNotAuthorized error code.
  182. */
  183. static NSString *const kFIRAuthErrorMessageAppNotAuthorized =
  184. @"This app is not authorized to use "
  185. "Firebase Authentication with the provided API key. Review your key configuration in the "
  186. "Google API console and ensure that it accepts requests from your app's bundle ID.";
  187. /** @var kFIRAuthErrorMessageExpiredActionCode
  188. @brief Message for @c FIRAuthErrorCodeExpiredActionCode error code.
  189. */
  190. static NSString *const kFIRAuthErrorMessageExpiredActionCode = @"The action code has expired.";
  191. /** @var kFIRAuthErrorMessageInvalidActionCode
  192. @brief Message for @c FIRAuthErrorCodeInvalidActionCode error code.
  193. */
  194. static NSString *const kFIRAuthErrorMessageInvalidActionCode =
  195. @"The action code is invalid. This "
  196. "can happen if the code is malformed, expired, or has already been used.";
  197. /** @var kFIRAuthErrorMessageInvalidMessagePayload
  198. @brief Message for @c FIRAuthErrorCodeInvalidMessagePayload error code.
  199. */
  200. static NSString *const kFIRAuthErrorMessageInvalidMessagePayload =
  201. @"The action code is invalid. "
  202. "This can happen if the code is malformed, expired, or has already been used.";
  203. /** @var kFIRAuthErrorMessageInvalidSender
  204. @brief Message for @c FIRAuthErrorCodeInvalidSender error code.
  205. */
  206. static NSString *const kFIRAuthErrorMessageInvalidSender =
  207. @"The email template corresponding to "
  208. "this action contains invalid characters in its message. Please fix by going to the Auth "
  209. "email "
  210. "templates section in the Firebase Console.";
  211. /** @var kFIRAuthErrorMessageInvalidRecipientEmail
  212. @brief Message for @c FIRAuthErrorCodeInvalidRecipient error code.
  213. */
  214. static NSString *const kFIRAuthErrorMessageInvalidRecipientEmail =
  215. @"The action code is invalid. "
  216. "This can happen if the code is malformed, expired, or has already been used.";
  217. /** @var kFIRAuthErrorMessageMissingIosBundleID
  218. @brief Message for @c FIRAuthErrorCodeMissingIosbundleID error code.
  219. */
  220. static NSString *const kFIRAuthErrorMessageMissingIosBundleID =
  221. @"An iOS Bundle ID must be provided if an App Store ID is provided.";
  222. /** @var kFIRAuthErrorMessageMissingAndroidPackageName
  223. @brief Message for @c FIRAuthErrorCodeMissingAndroidPackageName error code.
  224. */
  225. static NSString *const kFIRAuthErrorMessageMissingAndroidPackageName =
  226. @"An Android Package Name must be provided if the Android App is required to be installed.";
  227. /** @var kFIRAuthErrorMessageUnauthorizedDomain
  228. @brief Message for @c FIRAuthErrorCodeUnauthorizedDomain error code.
  229. */
  230. static NSString *const kFIRAuthErrorMessageUnauthorizedDomain =
  231. @"The domain of the continue URL "
  232. "is not allowlisted. Please allowlist the domain in the Firebase console.";
  233. /** @var kFIRAuthErrorMessageInvalidContinueURI
  234. @brief Message for @c FIRAuthErrorCodeInvalidContinueURI error code.
  235. */
  236. static NSString *const kFIRAuthErrorMessageInvalidContinueURI =
  237. @"The continue URL provided in the request is invalid.";
  238. /** @var kFIRAuthErrorMessageMissingEmail
  239. @brief Message for @c FIRAuthErrorCodeMissingEmail error code.
  240. */
  241. static NSString *const kFIRAuthErrorMessageMissingEmail = @"An email address must be provided.";
  242. /** @var kFIRAuthErrorMessageMissingContinueURI
  243. @brief Message for @c FIRAuthErrorCodeMissingContinueURI error code.
  244. */
  245. static NSString *const kFIRAuthErrorMessageMissingContinueURI =
  246. @"A continue URL must be provided in the request.";
  247. /** @var kFIRAuthErrorMessageMissingPhoneNumber
  248. @brief Message for @c FIRAuthErrorCodeMissingPhoneNumber error code.
  249. */
  250. static NSString *const kFIRAuthErrorMessageMissingPhoneNumber =
  251. @"To send verification codes, provide a phone number for the recipient.";
  252. /** @var kFIRAuthErrorMessageInvalidPhoneNumber
  253. @brief Message for @c FIRAuthErrorCodeInvalidPhoneNumber error code.
  254. */
  255. static NSString *const kFIRAuthErrorMessageInvalidPhoneNumber =
  256. @"The format of the phone number provided is incorrect. Please enter the phone number in a "
  257. "format that can be parsed into E.164 format. E.164 phone numbers are written in the format "
  258. "[+][country code][subscriber number including area code].";
  259. /** @var kFIRAuthErrorMessageMissingVerificationCode
  260. @brief Message for @c FIRAuthErrorCodeMissingVerificationCode error code.
  261. */
  262. static NSString *const kFIRAuthErrorMessageMissingVerificationCode =
  263. @"The phone auth credential was created with an empty SMS verification Code.";
  264. /** @var kFIRAuthErrorMessageInvalidVerificationCode
  265. @brief Message for @c FIRAuthErrorCodeInvalidVerificationCode error code.
  266. */
  267. static NSString *const kFIRAuthErrorMessageInvalidVerificationCode =
  268. @"The multifactor verification code used to create the auth credential is invalid."
  269. @"Re-collect the verification code and be sure to use the verification code provided by the "
  270. @"user.";
  271. /** @var kFIRAuthErrorMessageMissingVerificationID
  272. @brief Message for @c FIRAuthErrorCodeInvalidVerificationID error code.
  273. */
  274. static NSString *const kFIRAuthErrorMessageMissingVerificationID =
  275. @"The phone auth credential was created with an empty verification ID.";
  276. /** @var kFIRAuthErrorMessageInvalidVerificationID
  277. @brief Message for @c FIRAuthErrorCodeInvalidVerificationID error code.
  278. */
  279. static NSString *const kFIRAuthErrorMessageInvalidVerificationID =
  280. @"The verification ID used to create the phone auth credential is invalid.";
  281. /** @var kFIRAuthErrorMessageLocalPlayerNotAuthenticated
  282. @brief Message for @c FIRAuthErrorCodeLocalPlayerNotAuthenticated error code.
  283. */
  284. static NSString *const kFIRAuthErrorMessageLocalPlayerNotAuthenticated =
  285. @"The local player is not authenticated. Please log the local player in to Game Center.";
  286. /** @var kFIRAuthErrorMessageGameKitNotLinked
  287. @brief Message for @c kFIRAuthErrorMessageGameKitNotLinked error code.
  288. */
  289. static NSString *const kFIRAuthErrorMessageGameKitNotLinked =
  290. @"The GameKit framework is not linked. Please turn on the Game Center capability.";
  291. /** @var kFIRAuthErrorMessageSessionExpired
  292. @brief Message for @c FIRAuthErrorCodeSessionExpired error code.
  293. */
  294. static NSString *const kFIRAuthErrorMessageSessionExpired =
  295. @"The SMS code has expired. Please "
  296. @"re-send the verification code to try again.";
  297. /** @var kFIRAuthErrorMessageMissingAppCredential
  298. @brief Message for @c FIRAuthErrorCodeMissingAppCredential error code.
  299. */
  300. static NSString *const kFIRAuthErrorMessageMissingAppCredential =
  301. @"The phone verification request "
  302. "is missing an APNs Device token. Firebase Auth automatically detects APNs Device Tokens, "
  303. "however, if method swizzling is disabled, the APNs token must be set via the APNSToken "
  304. "property on FIRAuth or by calling setAPNSToken:type on FIRAuth.";
  305. /** @var kFIRAuthErrorMessageInvalidAppCredential
  306. @brief Message for @c FIRAuthErrorCodeInvalidAppCredential error code.
  307. */
  308. static NSString *const kFIRAuthErrorMessageInvalidAppCredential =
  309. @"The APNs device token provided "
  310. "is either incorrect or does not match the private certificate uploaded to the Firebase "
  311. "Console.";
  312. /** @var kFIRAuthErrorMessageQuotaExceeded
  313. @brief Message for @c FIRAuthErrorCodeQuotaExceeded error code.
  314. */
  315. static NSString *const kFIRAuthErrorMessageQuotaExceeded = @"The quota for this operation "
  316. "has been exceeded.";
  317. /** @var kFIRAuthErrorMessageMissingAppToken
  318. @brief Message for @c FIRAuthErrorCodeMissingAppToken error code.
  319. */
  320. static NSString *const kFIRAuthErrorMessageMissingAppToken =
  321. @"There seems to be a problem with "
  322. "your project's Firebase phone number authentication set-up, please make sure to follow the "
  323. "instructions found at https://firebase.google.com/docs/auth/ios/phone-auth";
  324. /** @var kFIRAuthErrorMessageMissingAppToken
  325. @brief Message for @c FIRAuthErrorCodeMissingAppToken error code.
  326. */
  327. static NSString *const kFIRAuthErrorMessageNotificationNotForwarded =
  328. @"If app delegate swizzling "
  329. "is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to "
  330. "FIRAuth's canHandleNotificaton: method.";
  331. /** @var kFIRAuthErrorMessageAppNotVerified
  332. @brief Message for @c FIRAuthErrorCodeMissingAppToken error code.
  333. */
  334. static NSString *const kFIRAuthErrorMessageAppNotVerified =
  335. @"Firebase could not retrieve the "
  336. "silent push notification and therefore could not verify your app. Ensure that you configured "
  337. "your app correctly to receive push notifications.";
  338. /** @var kFIRAuthErrorMessageCaptchaCheckFailed
  339. @brief Message for @c FIRAuthErrorCodeCaptchaCheckFailed error code.
  340. */
  341. static NSString *const kFIRAuthErrorMessageCaptchaCheckFailed =
  342. @"The reCAPTCHA response token "
  343. "provided is either invalid, expired or already";
  344. /** @var kFIRAuthErrorMessageWebContextAlreadyPresented
  345. @brief Message for @c FIRAuthErrorCodeWebContextAlreadyPresented error code.
  346. */
  347. static NSString *const kFIRAuthErrorMessageWebContextAlreadyPresented =
  348. @"User interaction is "
  349. "still ongoing, another view cannot be presented.";
  350. /** @var kFIRAuthErrorMessageWebContextCancelled
  351. @brief Message for @c FIRAuthErrorCodeWebContextCancelled error code.
  352. */
  353. static NSString *const kFIRAuthErrorMessageWebContextCancelled = @"The interaction was cancelled "
  354. "by the user.";
  355. /** @var kFIRAuthErrorMessageInvalidClientID
  356. @brief Message for @c FIRAuthErrorCodeInvalidClientID error code.
  357. */
  358. static NSString *const kFIRAuthErrorMessageInvalidClientID =
  359. @"The OAuth client ID provided is "
  360. "either invalid or does not match the specified API key.";
  361. /** @var kFIRAuthErrorMessageWebRequestFailed
  362. @brief Message for @c FIRAuthErrorCodeWebRequestFailed error code.
  363. */
  364. static NSString *const kFIRAuthErrorMessageWebRequestFailed =
  365. @"A network error (such as timeout, "
  366. "interrupted connection, or unreachable host) has occurred within the web context.";
  367. /** @var kFIRAuthErrorMessageWebInternalError
  368. @brief Message for @c FIRAuthErrorCodeWebInternalError error code.
  369. */
  370. static NSString *const kFIRAuthErrorMessageWebInternalError =
  371. @"An internal error has occurred "
  372. "within the SFSafariViewController or WKWebView.";
  373. /** @var kFIRAuthErrorMessageAppVerificationUserInteractionFailure
  374. @brief Message for @c FIRAuthErrorCodeInvalidClientID error code.
  375. */
  376. static NSString *const kFIRAuthErrorMessageAppVerificationUserInteractionFailure =
  377. @"The app "
  378. "verification process has failed, print and inspect the error details for more information";
  379. /** @var kFIRAuthErrorMessageNullUser
  380. @brief Message for @c FIRAuthErrorCodeNullUser error code.
  381. */
  382. static NSString *const kFIRAuthErrorMessageNullUser =
  383. @"A null user object was provided as the "
  384. "argument for an operation which requires a non-null user object.";
  385. /** @var kFIRAuthErrorMessageInvalidProviderID
  386. @brief Message for @c FIRAuthErrorCodeInvalidProviderID error code.
  387. */
  388. static NSString *const kFIRAuthErrorMessageInvalidProviderID =
  389. @"The provider ID provided for the "
  390. "attempted web operation is invalid.";
  391. /** @var kFIRAuthErrorMessageInvalidDynamicLinkDomain
  392. @brief Message for @c kFIRAuthErrorMessageInvalidDynamicLinkDomain error code.
  393. */
  394. static NSString *const kFIRAuthErrorMessageInvalidDynamicLinkDomain =
  395. @"The "
  396. "Firebase Dynamic Link domain used is either not configured or is unauthorized "
  397. "for the current project.";
  398. /** @var kFIRAuthErrorMessageInternalError
  399. @brief Message for @c FIRAuthErrorCodeInternalError error code.
  400. */
  401. static NSString *const kFIRAuthErrorMessageInternalError =
  402. @"An internal error has occurred, "
  403. "print and inspect the error details for more information.";
  404. /** @var kFIRAuthErrorMessageMalformedJWT
  405. @brief Error message constant describing @c FIRAuthErrorCodeMalformedJWT errors.
  406. */
  407. static NSString *const kFIRAuthErrorMessageMalformedJWT =
  408. @"Failed to parse JWT. Check the userInfo dictionary for the full token.";
  409. /** @var kFIRAuthErrorMessageSecondFactorRequired
  410. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  411. */
  412. static NSString *const kFIRAuthErrorMessageSecondFactorRequired =
  413. @"Please complete a second factor challenge to finish signing into this account.";
  414. /** @var kFIRAuthErrorMessageSecondFactorRequired
  415. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  416. */
  417. static NSString *const FIRAuthErrorMessageMissingMultiFactorSession =
  418. @"The request is missing proof of first factor successful sign-in.";
  419. /** @var kFIRAuthErrorMessageSecondFactorRequired
  420. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  421. */
  422. static NSString *const FIRAuthErrorMessageMissingMultiFactorInfo =
  423. @"No second factor identifier is provided.";
  424. /** @var kFIRAuthErrorMessageSecondFactorRequired
  425. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  426. */
  427. static NSString *const FIRAuthErrorMessageInvalidMultiFactorSession =
  428. @"The request does not contain a valid proof of first factor successful sign-in.";
  429. /** @var kFIRAuthErrorMessageSecondFactorRequired
  430. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  431. */
  432. static NSString *const FIRAuthErrorMessageMultiFactorInfoNotFound =
  433. @"The user does not have a second factor matching the identifier provided.";
  434. /** @var kFIRAuthErrorMessageSecondFactorRequired
  435. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  436. */
  437. static NSString *const FIRAuthErrorMessageAdminRestrictedOperation =
  438. @"This operation is restricted to administrators only.";
  439. /** @var kFIRAuthErrorMessageSecondFactorRequired
  440. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  441. */
  442. static NSString *const FIRAuthErrorMessageUnverifiedEmail =
  443. @"The operation requires a verified email.";
  444. /** @var kFIRAuthErrorMessageSecondFactorRequired
  445. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  446. */
  447. static NSString *const FIRAuthErrorMessageSecondFactorAlreadyEnrolled =
  448. @"The second factor is already enrolled on this account.";
  449. /** @var kFIRAuthErrorMessageSecondFactorRequired
  450. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  451. */
  452. static NSString *const FIRAuthErrorMessageMaximumSecondFactorCountExceeded =
  453. @"The maximum allowed number of second factors on a user has been exceeded.";
  454. /** @var kFIRAuthErrorMessageSecondFactorRequired
  455. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  456. */
  457. static NSString *const FIRAuthErrorMessageUnsupportedFirstFactor =
  458. @"Enrolling a second factor or signing in with a multi-factor account requires sign-in with a "
  459. @"supported first factor.";
  460. /** @var kFIRAuthErrorMessageSecondFactorRequired
  461. @brief Message for @c kFIRAuthErrorMessageSecondFactorRequired error code.
  462. */
  463. static NSString *const FIRAuthErrorMessageEmailChangeNeedsVerification =
  464. @"Multi-factor users must always have a verified email.";
  465. /** @var kFIRAuthErrorMessageDynamicLinkNotActivated
  466. @brief Error message constant describing @c FIRAuthErrorCodeDynamicLinkNotActivated errors.
  467. */
  468. static NSString *const kFIRAuthErrorMessageDynamicLinkNotActivated =
  469. @"Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.";
  470. /** @var kFIRAuthErrorMessageRejectedCredential
  471. @brief Error message constant describing @c FIRAuthErrorCodeRejectedCredential errors.
  472. */
  473. static NSString *const kFIRAuthErrorMessageRejectedCredential =
  474. @"The request contains malformed or mismatching credentials.";
  475. /** @var kFIRAuthErrorMessageMissingClientIdentifier
  476. @brief Error message constant describing @c FIRAuthErrorCodeMissingClientIdentifier errors.
  477. */
  478. static NSString *const kFIRAuthErrorMessageMissingClientIdentifier =
  479. @"The request does not contain a client identifier.";
  480. /** @var kFIRAuthErrorMessageMissingOrInvalidNonce
  481. @brief Error message constant describing @c FIRAuthErrorCodeMissingOrInvalidNonce errors.
  482. */
  483. static NSString *const kFIRAuthErrorMessageMissingOrInvalidNonce =
  484. @"The request contains malformed or mismatched credentials.";
  485. /** @var kFIRAuthErrorMessageTenantIDMismatch.
  486. @brief Message for @c FIRAuthErrorCodeTenantIDMismatch error code.
  487. */
  488. static NSString *const kFIRAuthErrorMessageTenantIDMismatch =
  489. @"The provided user's tenant ID does"
  490. "not match the Auth instance's tenant ID.";
  491. /** @var kFIRAuthErrorMessageUnsupportedTenantOperation
  492. @brief Message for @c FIRAuthErrorCodeUnsupportedTenantOperation error code.
  493. */
  494. static NSString *const kFIRAuthErrorMessageUnsupportedTenantOperation =
  495. @"This operation is not"
  496. "supported in a multi-tenant context.";
  497. /** @var kFIRAuthErrorMessageBlockingCloudFunctionReturnedError
  498. @brief Message for @c FIRAuthErrorCodeBlockingCloudFunctionError error code.
  499. */
  500. static NSString *const kFIRAuthErrorMessageBlockingCloudFunctionReturnedError =
  501. @"Blocking cloud function returned an error.";
  502. static NSString *const kFIRAuthErrorMessageRecaptchaNotEnabled =
  503. @"reCAPTCHA Enterprise is not enabled for this project.";
  504. static NSString *const kFIRAuthErrorMessageMissingRecaptchaToken =
  505. @"The backend request is missing the reCAPTCHA verification token.";
  506. static NSString *const kFIRAuthErrorMessageInvalidRecaptchaToken =
  507. @"The reCAPTCHA verification token is invalid or has expired.";
  508. static NSString *const kFIRAuthErrorMessageInvalidRecaptchaAction =
  509. @"The reCAPTCHA verification failed due to an invalid action.";
  510. static NSString *const kFIRAuthErrorMessageMissingClientType =
  511. @"The request is missing a client type or the client type is invalid.";
  512. static NSString *const kFIRAuthErrorMessageMissingRecaptchaVersion =
  513. @"The request is missing the reCAPTCHA version parameter.";
  514. static NSString *const kFIRAuthErrorMessageInvalidRecaptchaVersion =
  515. @"The request specifies an invalid version of reCAPTCHA.";
  516. static NSString *const kFIRAuthErrorMessageInvalidReqType =
  517. @"The request is not supported or is invalid.";
  518. // TODO(chuanr): point the link to GCIP doc once available.
  519. static NSString *const kFIRAuthErrorMessageRecaptchaSDKNotLinked =
  520. @"The reCAPTCHA SDK is not linked to your app. See "
  521. @"https://cloud.google.com/recaptcha-enterprise/docs/instrument-ios-apps";
  522. /** @var FIRAuthErrorDescription
  523. @brief The error descrioption, based on the error code.
  524. @remarks No default case so that we get a compiler warning if a new value was added to the enum.
  525. */
  526. static NSString *FIRAuthErrorDescription(FIRAuthErrorCode code) {
  527. switch (code) {
  528. case FIRAuthErrorCodeInvalidCustomToken:
  529. return kFIRAuthErrorMessageInvalidCustomToken;
  530. case FIRAuthErrorCodeCustomTokenMismatch:
  531. return kFIRAuthErrorMessageCustomTokenMismatch;
  532. case FIRAuthErrorCodeInvalidEmail:
  533. return kFIRAuthErrorMessageInvalidEmail;
  534. case FIRAuthErrorCodeInvalidCredential:
  535. return kFIRAuthErrorMessageInvalidCredential;
  536. case FIRAuthErrorCodeUserDisabled:
  537. return kFIRAuthErrorMessageUserDisabled;
  538. case FIRAuthErrorCodeEmailAlreadyInUse:
  539. return kFIRAuthErrorMessageEmailAlreadyInUse;
  540. case FIRAuthErrorCodeWrongPassword:
  541. return kFIRAuthErrorMessageWrongPassword;
  542. case FIRAuthErrorCodeTooManyRequests:
  543. return kFIRAuthErrorMessageTooManyRequests;
  544. case FIRAuthErrorCodeAccountExistsWithDifferentCredential:
  545. return kFIRAuthErrorMessageAccountExistsWithDifferentCredential;
  546. case FIRAuthErrorCodeRequiresRecentLogin:
  547. return kFIRAuthErrorMessageRequiresRecentLogin;
  548. case FIRAuthErrorCodeProviderAlreadyLinked:
  549. return kFIRAuthErrorMessageProviderAlreadyLinked;
  550. case FIRAuthErrorCodeNoSuchProvider:
  551. return kFIRAuthErrorMessageNoSuchProvider;
  552. case FIRAuthErrorCodeInvalidUserToken:
  553. return kFIRAuthErrorMessageInvalidUserToken;
  554. case FIRAuthErrorCodeNetworkError:
  555. return kFIRAuthErrorMessageNetworkError;
  556. case FIRAuthErrorCodeKeychainError:
  557. return kFIRAuthErrorMessageKeychainError;
  558. case FIRAuthErrorCodeUserTokenExpired:
  559. return kFIRAuthErrorMessageUserTokenExpired;
  560. case FIRAuthErrorCodeUserNotFound:
  561. return kFIRAuthErrorMessageUserNotFound;
  562. case FIRAuthErrorCodeInvalidAPIKey:
  563. return kFIRAuthErrorMessageInvalidAPIKey;
  564. case FIRAuthErrorCodeCredentialAlreadyInUse:
  565. return kFIRAuthErrorMessageCredentialAlreadyInUse;
  566. case FIRAuthErrorCodeInternalError:
  567. return kFIRAuthErrorMessageInternalError;
  568. case FIRAuthErrorCodeUserMismatch:
  569. return FIRAuthErrorMessageUserMismatch;
  570. case FIRAuthErrorCodeOperationNotAllowed:
  571. return kFIRAuthErrorMessageOperationNotAllowed;
  572. case FIRAuthErrorCodeWeakPassword:
  573. return kFIRAuthErrorMessageWeakPassword;
  574. case FIRAuthErrorCodeAppNotAuthorized:
  575. return kFIRAuthErrorMessageAppNotAuthorized;
  576. case FIRAuthErrorCodeExpiredActionCode:
  577. return kFIRAuthErrorMessageExpiredActionCode;
  578. case FIRAuthErrorCodeInvalidActionCode:
  579. return kFIRAuthErrorMessageInvalidActionCode;
  580. case FIRAuthErrorCodeInvalidSender:
  581. return kFIRAuthErrorMessageInvalidSender;
  582. case FIRAuthErrorCodeInvalidMessagePayload:
  583. return kFIRAuthErrorMessageInvalidMessagePayload;
  584. case FIRAuthErrorCodeInvalidRecipientEmail:
  585. return kFIRAuthErrorMessageInvalidRecipientEmail;
  586. case FIRAuthErrorCodeMissingIosBundleID:
  587. return kFIRAuthErrorMessageMissingIosBundleID;
  588. case FIRAuthErrorCodeMissingAndroidPackageName:
  589. return kFIRAuthErrorMessageMissingAndroidPackageName;
  590. case FIRAuthErrorCodeUnauthorizedDomain:
  591. return kFIRAuthErrorMessageUnauthorizedDomain;
  592. case FIRAuthErrorCodeInvalidContinueURI:
  593. return kFIRAuthErrorMessageInvalidContinueURI;
  594. case FIRAuthErrorCodeMissingContinueURI:
  595. return kFIRAuthErrorMessageMissingContinueURI;
  596. case FIRAuthErrorCodeMissingEmail:
  597. return kFIRAuthErrorMessageMissingEmail;
  598. case FIRAuthErrorCodeMissingPhoneNumber:
  599. return kFIRAuthErrorMessageMissingPhoneNumber;
  600. case FIRAuthErrorCodeInvalidPhoneNumber:
  601. return kFIRAuthErrorMessageInvalidPhoneNumber;
  602. case FIRAuthErrorCodeMissingVerificationCode:
  603. return kFIRAuthErrorMessageMissingVerificationCode;
  604. case FIRAuthErrorCodeInvalidVerificationCode:
  605. return kFIRAuthErrorMessageInvalidVerificationCode;
  606. case FIRAuthErrorCodeMissingVerificationID:
  607. return kFIRAuthErrorMessageMissingVerificationID;
  608. case FIRAuthErrorCodeInvalidVerificationID:
  609. return kFIRAuthErrorMessageInvalidVerificationID;
  610. case FIRAuthErrorCodeSessionExpired:
  611. return kFIRAuthErrorMessageSessionExpired;
  612. case FIRAuthErrorCodeMissingAppCredential:
  613. return kFIRAuthErrorMessageMissingAppCredential;
  614. case FIRAuthErrorCodeInvalidAppCredential:
  615. return kFIRAuthErrorMessageInvalidAppCredential;
  616. case FIRAuthErrorCodeQuotaExceeded:
  617. return kFIRAuthErrorMessageQuotaExceeded;
  618. case FIRAuthErrorCodeMissingAppToken:
  619. return kFIRAuthErrorMessageMissingAppToken;
  620. case FIRAuthErrorCodeNotificationNotForwarded:
  621. return kFIRAuthErrorMessageNotificationNotForwarded;
  622. case FIRAuthErrorCodeAppNotVerified:
  623. return kFIRAuthErrorMessageAppNotVerified;
  624. case FIRAuthErrorCodeCaptchaCheckFailed:
  625. return kFIRAuthErrorMessageCaptchaCheckFailed;
  626. case FIRAuthErrorCodeWebContextAlreadyPresented:
  627. return kFIRAuthErrorMessageWebContextAlreadyPresented;
  628. case FIRAuthErrorCodeWebContextCancelled:
  629. return kFIRAuthErrorMessageWebContextCancelled;
  630. case FIRAuthErrorCodeInvalidClientID:
  631. return kFIRAuthErrorMessageInvalidClientID;
  632. case FIRAuthErrorCodeAppVerificationUserInteractionFailure:
  633. return kFIRAuthErrorMessageAppVerificationUserInteractionFailure;
  634. case FIRAuthErrorCodeWebNetworkRequestFailed:
  635. return kFIRAuthErrorMessageWebRequestFailed;
  636. case FIRAuthErrorCodeNullUser:
  637. return kFIRAuthErrorMessageNullUser;
  638. case FIRAuthErrorCodeInvalidProviderID:
  639. return kFIRAuthErrorMessageInvalidProviderID;
  640. case FIRAuthErrorCodeInvalidDynamicLinkDomain:
  641. return kFIRAuthErrorMessageInvalidDynamicLinkDomain;
  642. case FIRAuthErrorCodeWebInternalError:
  643. return kFIRAuthErrorMessageWebInternalError;
  644. case FIRAuthErrorCodeWebSignInUserInteractionFailure:
  645. return kFIRAuthErrorMessageAppVerificationUserInteractionFailure;
  646. case FIRAuthErrorCodeMalformedJWT:
  647. return kFIRAuthErrorMessageMalformedJWT;
  648. case FIRAuthErrorCodeLocalPlayerNotAuthenticated:
  649. return kFIRAuthErrorMessageLocalPlayerNotAuthenticated;
  650. case FIRAuthErrorCodeGameKitNotLinked:
  651. return kFIRAuthErrorMessageGameKitNotLinked;
  652. case FIRAuthErrorCodeSecondFactorRequired:
  653. return kFIRAuthErrorMessageSecondFactorRequired;
  654. case FIRAuthErrorCodeMissingMultiFactorSession:
  655. return FIRAuthErrorMessageMissingMultiFactorSession;
  656. case FIRAuthErrorCodeMissingMultiFactorInfo:
  657. return FIRAuthErrorMessageMissingMultiFactorInfo;
  658. case FIRAuthErrorCodeInvalidMultiFactorSession:
  659. return FIRAuthErrorMessageInvalidMultiFactorSession;
  660. case FIRAuthErrorCodeMultiFactorInfoNotFound:
  661. return FIRAuthErrorMessageMultiFactorInfoNotFound;
  662. case FIRAuthErrorCodeAdminRestrictedOperation:
  663. return FIRAuthErrorMessageAdminRestrictedOperation;
  664. case FIRAuthErrorCodeUnverifiedEmail:
  665. return FIRAuthErrorMessageUnverifiedEmail;
  666. case FIRAuthErrorCodeSecondFactorAlreadyEnrolled:
  667. return FIRAuthErrorMessageSecondFactorAlreadyEnrolled;
  668. case FIRAuthErrorCodeMaximumSecondFactorCountExceeded:
  669. return FIRAuthErrorMessageMaximumSecondFactorCountExceeded;
  670. case FIRAuthErrorCodeUnsupportedFirstFactor:
  671. return FIRAuthErrorMessageUnsupportedFirstFactor;
  672. case FIRAuthErrorCodeEmailChangeNeedsVerification:
  673. return FIRAuthErrorMessageEmailChangeNeedsVerification;
  674. case FIRAuthErrorCodeDynamicLinkNotActivated:
  675. return kFIRAuthErrorMessageDynamicLinkNotActivated;
  676. case FIRAuthErrorCodeRejectedCredential:
  677. return kFIRAuthErrorMessageRejectedCredential;
  678. case FIRAuthErrorCodeMissingClientIdentifier:
  679. return kFIRAuthErrorMessageMissingClientIdentifier;
  680. case FIRAuthErrorCodeMissingOrInvalidNonce:
  681. return kFIRAuthErrorMessageMissingOrInvalidNonce;
  682. case FIRAuthErrorCodeTenantIDMismatch:
  683. return kFIRAuthErrorMessageTenantIDMismatch;
  684. case FIRAuthErrorCodeUnsupportedTenantOperation:
  685. return kFIRAuthErrorMessageUnsupportedTenantOperation;
  686. case FIRAuthErrorCodeBlockingCloudFunctionError:
  687. return kFIRAuthErrorMessageBlockingCloudFunctionReturnedError;
  688. case FIRAuthErrorCodeRecaptchaNotEnabled:
  689. return kFIRAuthErrorMessageRecaptchaNotEnabled;
  690. case FIRAuthErrorCodeMissingRecaptchaToken:
  691. return kFIRAuthErrorMessageMissingRecaptchaToken;
  692. case FIRAuthErrorCodeInvalidRecaptchaToken:
  693. return kFIRAuthErrorMessageInvalidRecaptchaToken;
  694. case FIRAuthErrorCodeInvalidRecaptchaAction:
  695. return kFIRAuthErrorMessageInvalidRecaptchaAction;
  696. case FIRAuthErrorCodeMissingClientType:
  697. return kFIRAuthErrorMessageMissingClientType;
  698. case FIRAuthErrorCodeMissingRecaptchaVersion:
  699. return kFIRAuthErrorMessageMissingRecaptchaVersion;
  700. case FIRAuthErrorCodeInvalidRecaptchaVersion:
  701. return kFIRAuthErrorMessageInvalidRecaptchaVersion;
  702. case FIRAuthErrorCodeInvalidReqType:
  703. return kFIRAuthErrorMessageInvalidReqType;
  704. case FIRAuthErrorCodeRecaptchaSDKNotLinked:
  705. return kFIRAuthErrorMessageRecaptchaSDKNotLinked;
  706. }
  707. }
  708. /** @var FIRAuthErrorCodeString
  709. @brief The error short string, based on the error code.
  710. @remarks No default case so that we get a compiler warning if a new value was added to the enum.
  711. */
  712. static NSString *const FIRAuthErrorCodeString(FIRAuthErrorCode code) {
  713. switch (code) {
  714. case FIRAuthErrorCodeInvalidCustomToken:
  715. return @"ERROR_INVALID_CUSTOM_TOKEN";
  716. case FIRAuthErrorCodeCustomTokenMismatch:
  717. return @"ERROR_CUSTOM_TOKEN_MISMATCH";
  718. case FIRAuthErrorCodeInvalidEmail:
  719. return @"ERROR_INVALID_EMAIL";
  720. case FIRAuthErrorCodeInvalidCredential:
  721. return @"ERROR_INVALID_CREDENTIAL";
  722. case FIRAuthErrorCodeUserDisabled:
  723. return @"ERROR_USER_DISABLED";
  724. case FIRAuthErrorCodeEmailAlreadyInUse:
  725. return @"ERROR_EMAIL_ALREADY_IN_USE";
  726. case FIRAuthErrorCodeWrongPassword:
  727. return @"ERROR_WRONG_PASSWORD";
  728. case FIRAuthErrorCodeTooManyRequests:
  729. return @"ERROR_TOO_MANY_REQUESTS";
  730. case FIRAuthErrorCodeAccountExistsWithDifferentCredential:
  731. return @"ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL";
  732. case FIRAuthErrorCodeRequiresRecentLogin:
  733. return @"ERROR_REQUIRES_RECENT_LOGIN";
  734. case FIRAuthErrorCodeProviderAlreadyLinked:
  735. return @"ERROR_PROVIDER_ALREADY_LINKED";
  736. case FIRAuthErrorCodeNoSuchProvider:
  737. return @"ERROR_NO_SUCH_PROVIDER";
  738. case FIRAuthErrorCodeInvalidUserToken:
  739. return @"ERROR_INVALID_USER_TOKEN";
  740. case FIRAuthErrorCodeNetworkError:
  741. return @"ERROR_NETWORK_REQUEST_FAILED";
  742. case FIRAuthErrorCodeKeychainError:
  743. return @"ERROR_KEYCHAIN_ERROR";
  744. case FIRAuthErrorCodeMissingClientType:
  745. return @"ERROR_MISSING_CLIENT_TYPE";
  746. case FIRAuthErrorCodeUserTokenExpired:
  747. return @"ERROR_USER_TOKEN_EXPIRED";
  748. case FIRAuthErrorCodeUserNotFound:
  749. return @"ERROR_USER_NOT_FOUND";
  750. case FIRAuthErrorCodeInvalidAPIKey:
  751. return @"ERROR_INVALID_API_KEY";
  752. case FIRAuthErrorCodeCredentialAlreadyInUse:
  753. return @"ERROR_CREDENTIAL_ALREADY_IN_USE";
  754. case FIRAuthErrorCodeInternalError:
  755. return @"ERROR_INTERNAL_ERROR";
  756. case FIRAuthErrorCodeUserMismatch:
  757. return @"ERROR_USER_MISMATCH";
  758. case FIRAuthErrorCodeOperationNotAllowed:
  759. return @"ERROR_OPERATION_NOT_ALLOWED";
  760. case FIRAuthErrorCodeWeakPassword:
  761. return @"ERROR_WEAK_PASSWORD";
  762. case FIRAuthErrorCodeAppNotAuthorized:
  763. return @"ERROR_APP_NOT_AUTHORIZED";
  764. case FIRAuthErrorCodeExpiredActionCode:
  765. return @"ERROR_EXPIRED_ACTION_CODE";
  766. case FIRAuthErrorCodeInvalidActionCode:
  767. return @"ERROR_INVALID_ACTION_CODE";
  768. case FIRAuthErrorCodeInvalidMessagePayload:
  769. return @"ERROR_INVALID_MESSAGE_PAYLOAD";
  770. case FIRAuthErrorCodeInvalidSender:
  771. return @"ERROR_INVALID_SENDER";
  772. case FIRAuthErrorCodeInvalidRecipientEmail:
  773. return @"ERROR_INVALID_RECIPIENT_EMAIL";
  774. case FIRAuthErrorCodeMissingIosBundleID:
  775. return @"ERROR_MISSING_IOS_BUNDLE_ID";
  776. case FIRAuthErrorCodeMissingAndroidPackageName:
  777. return @"ERROR_MISSING_ANDROID_PKG_NAME";
  778. case FIRAuthErrorCodeUnauthorizedDomain:
  779. return @"ERROR_UNAUTHORIZED_DOMAIN";
  780. case FIRAuthErrorCodeInvalidContinueURI:
  781. return @"ERROR_INVALID_CONTINUE_URI";
  782. case FIRAuthErrorCodeMissingContinueURI:
  783. return @"ERROR_MISSING_CONTINUE_URI";
  784. case FIRAuthErrorCodeMissingEmail:
  785. return @"ERROR_MISSING_EMAIL";
  786. case FIRAuthErrorCodeMissingPhoneNumber:
  787. return @"ERROR_MISSING_PHONE_NUMBER";
  788. case FIRAuthErrorCodeInvalidPhoneNumber:
  789. return @"ERROR_INVALID_PHONE_NUMBER";
  790. case FIRAuthErrorCodeMissingVerificationCode:
  791. return @"ERROR_MISSING_VERIFICATION_CODE";
  792. case FIRAuthErrorCodeInvalidVerificationCode:
  793. return @"ERROR_INVALID_VERIFICATION_CODE";
  794. case FIRAuthErrorCodeMissingVerificationID:
  795. return @"ERROR_MISSING_VERIFICATION_ID";
  796. case FIRAuthErrorCodeInvalidVerificationID:
  797. return @"ERROR_INVALID_VERIFICATION_ID";
  798. case FIRAuthErrorCodeSessionExpired:
  799. return @"ERROR_SESSION_EXPIRED";
  800. case FIRAuthErrorCodeMissingAppCredential:
  801. return @"MISSING_APP_CREDENTIAL";
  802. case FIRAuthErrorCodeInvalidAppCredential:
  803. return @"INVALID_APP_CREDENTIAL";
  804. case FIRAuthErrorCodeQuotaExceeded:
  805. return @"ERROR_QUOTA_EXCEEDED";
  806. case FIRAuthErrorCodeMissingAppToken:
  807. return @"ERROR_MISSING_APP_TOKEN";
  808. case FIRAuthErrorCodeNotificationNotForwarded:
  809. return @"ERROR_NOTIFICATION_NOT_FORWARDED";
  810. case FIRAuthErrorCodeAppNotVerified:
  811. return @"ERROR_APP_NOT_VERIFIED";
  812. case FIRAuthErrorCodeCaptchaCheckFailed:
  813. return @"ERROR_CAPTCHA_CHECK_FAILED";
  814. case FIRAuthErrorCodeWebContextAlreadyPresented:
  815. return @"ERROR_WEB_CONTEXT_ALREADY_PRESENTED";
  816. case FIRAuthErrorCodeWebContextCancelled:
  817. return @"ERROR_WEB_CONTEXT_CANCELLED";
  818. case FIRAuthErrorCodeInvalidClientID:
  819. return @"ERROR_INVALID_CLIENT_ID";
  820. case FIRAuthErrorCodeAppVerificationUserInteractionFailure:
  821. return @"ERROR_APP_VERIFICATION_FAILED";
  822. case FIRAuthErrorCodeWebNetworkRequestFailed:
  823. return @"ERROR_WEB_NETWORK_REQUEST_FAILED";
  824. case FIRAuthErrorCodeNullUser:
  825. return @"ERROR_NULL_USER";
  826. case FIRAuthErrorCodeInvalidProviderID:
  827. return @"ERROR_INVALID_PROVIDER_ID";
  828. case FIRAuthErrorCodeInvalidDynamicLinkDomain:
  829. return @"ERROR_INVALID_DYNAMIC_LINK_DOMAIN";
  830. case FIRAuthErrorCodeWebInternalError:
  831. return @"ERROR_WEB_INTERNAL_ERROR";
  832. case FIRAuthErrorCodeWebSignInUserInteractionFailure:
  833. return @"ERROR_WEB_USER_INTERACTION_FAILURE";
  834. case FIRAuthErrorCodeMalformedJWT:
  835. return @"ERROR_MALFORMED_JWT";
  836. case FIRAuthErrorCodeLocalPlayerNotAuthenticated:
  837. return @"ERROR_LOCAL_PLAYER_NOT_AUTHENTICATED";
  838. case FIRAuthErrorCodeGameKitNotLinked:
  839. return @"ERROR_GAME_KIT_NOT_LINKED";
  840. case FIRAuthErrorCodeSecondFactorRequired:
  841. return @"ERROR_SECOND_FACTOR_REQUIRED";
  842. case FIRAuthErrorCodeMissingMultiFactorSession:
  843. return @"ERROR_MISSING_MULTI_FACTOR_SESSION";
  844. case FIRAuthErrorCodeMissingMultiFactorInfo:
  845. return @"ERROR_MISSING_MULTI_FACTOR_INFO";
  846. case FIRAuthErrorCodeInvalidMultiFactorSession:
  847. return @"ERROR_INVALID_MULTI_FACTOR_SESSION";
  848. case FIRAuthErrorCodeMultiFactorInfoNotFound:
  849. return @"ERROR_MULTI_FACTOR_INFO_NOT_FOUND";
  850. case FIRAuthErrorCodeAdminRestrictedOperation:
  851. return @"ERROR_ADMIN_RESTRICTED_OPERATION";
  852. case FIRAuthErrorCodeUnverifiedEmail:
  853. return @"ERROR_UNVERIFIED_EMAIL";
  854. case FIRAuthErrorCodeSecondFactorAlreadyEnrolled:
  855. return @"ERROR_SECOND_FACTOR_ALREADY_ENROLLED";
  856. case FIRAuthErrorCodeMaximumSecondFactorCountExceeded:
  857. return @"ERROR_MAXIMUM_SECOND_FACTOR_COUNT_EXCEEDED";
  858. case FIRAuthErrorCodeUnsupportedFirstFactor:
  859. return @"ERROR_UNSUPPORTED_FIRST_FACTOR";
  860. case FIRAuthErrorCodeEmailChangeNeedsVerification:
  861. return @"ERROR_EMAIL_CHANGE_NEEDS_VERIFICATION";
  862. case FIRAuthErrorCodeDynamicLinkNotActivated:
  863. return @"ERROR_DYNAMIC_LINK_NOT_ACTIVATED";
  864. case FIRAuthErrorCodeRejectedCredential:
  865. return @"ERROR_REJECTED_CREDENTIAL";
  866. case FIRAuthErrorCodeMissingClientIdentifier:
  867. return @"ERROR_MISSING_CLIENT_IDENTIFIER";
  868. case FIRAuthErrorCodeMissingOrInvalidNonce:
  869. return @"ERROR_MISSING_OR_INVALID_NONCE";
  870. case FIRAuthErrorCodeTenantIDMismatch:
  871. return @"ERROR_TENANT_ID_MISMATCH";
  872. case FIRAuthErrorCodeUnsupportedTenantOperation:
  873. return @"ERROR_UNSUPPORTED_TENANT_OPERATION";
  874. case FIRAuthErrorCodeBlockingCloudFunctionError:
  875. return @"ERROR_BLOCKING_CLOUD_FUNCTION_RETURNED_ERROR";
  876. case FIRAuthErrorCodeRecaptchaNotEnabled:
  877. return @"ERROR_RECAPTCHA_NOT_ENABLED";
  878. case FIRAuthErrorCodeMissingRecaptchaToken:
  879. return @"ERROR_MISSING_RECAPTCHA_TOKEN";
  880. case FIRAuthErrorCodeInvalidRecaptchaToken:
  881. return @"ERROR_INVALID_RECAPTCHA_TOKEN";
  882. case FIRAuthErrorCodeInvalidRecaptchaAction:
  883. return @"ERROR_INVALID_RECAPTCHA_ACTION";
  884. case FIRAuthErrorCodeMissingRecaptchaVersion:
  885. return @"ERROR_MISSING_RECAPTCHA_VERSION";
  886. case FIRAuthErrorCodeInvalidRecaptchaVersion:
  887. return @"ERROR_INVALID_RECAPTCHA_VERSION";
  888. case FIRAuthErrorCodeInvalidReqType:
  889. return @"ERROR_INVALID_REQ_TYPE";
  890. case FIRAuthErrorCodeRecaptchaSDKNotLinked:
  891. return @"ERROR_RECAPTCHA_SDK_NOT_LINKED";
  892. }
  893. }
  894. @implementation FIRAuthErrorUtils
  895. + (NSError *)errorWithCode:(FIRAuthInternalErrorCode)code {
  896. return [self errorWithCode:code message:nil];
  897. }
  898. + (NSError *)errorWithCode:(FIRAuthInternalErrorCode)code message:(nullable NSString *)message {
  899. NSDictionary *userInfo = nil;
  900. if (message.length) {
  901. userInfo = @{NSLocalizedDescriptionKey : message};
  902. }
  903. return [self errorWithCode:code userInfo:userInfo];
  904. }
  905. + (NSError *)errorWithCode:(FIRAuthInternalErrorCode)code
  906. underlyingError:(nullable NSError *)underlyingError {
  907. NSDictionary *errorUserInfo;
  908. if (underlyingError) {
  909. errorUserInfo = @{NSUnderlyingErrorKey : underlyingError};
  910. }
  911. return [self errorWithCode:code userInfo:errorUserInfo];
  912. }
  913. + (NSError *)errorWithCode:(FIRAuthInternalErrorCode)code
  914. userInfo:(nullable NSDictionary *)userInfo {
  915. BOOL isPublic = (code & FIRAuthPublicErrorCodeFlag) == FIRAuthPublicErrorCodeFlag;
  916. if (isPublic) {
  917. // This is a public error. Return it as a public error and add a description.
  918. NSInteger errorCode = code & ~FIRAuthPublicErrorCodeFlag;
  919. NSMutableDictionary *errorUserInfo = [NSMutableDictionary dictionary];
  920. if (userInfo) {
  921. [errorUserInfo addEntriesFromDictionary:userInfo];
  922. }
  923. if (!errorUserInfo[NSLocalizedDescriptionKey]) {
  924. errorUserInfo[NSLocalizedDescriptionKey] = FIRAuthErrorDescription(errorCode);
  925. }
  926. errorUserInfo[FIRAuthErrorUserInfoNameKey] = FIRAuthErrorCodeString(errorCode);
  927. return [NSError errorWithDomain:FIRAuthErrorDomain code:errorCode userInfo:errorUserInfo];
  928. } else {
  929. // This is an internal error. Wrap it in an internal error.
  930. NSError *error = [NSError errorWithDomain:FIRAuthInternalErrorDomain
  931. code:code
  932. userInfo:userInfo];
  933. return [self errorWithCode:FIRAuthInternalErrorCodeInternalError underlyingError:error];
  934. }
  935. }
  936. + (NSError *)RPCRequestEncodingErrorWithUnderlyingError:(NSError *)underlyingError {
  937. return [self errorWithCode:FIRAuthInternalErrorCodeRPCRequestEncodingError
  938. underlyingError:underlyingError];
  939. }
  940. + (NSError *)JSONSerializationErrorForUnencodableType {
  941. return [self errorWithCode:FIRAuthInternalErrorCodeJSONSerializationError];
  942. }
  943. + (NSError *)JSONSerializationErrorWithUnderlyingError:(NSError *)underlyingError {
  944. return [self errorWithCode:FIRAuthInternalErrorCodeJSONSerializationError
  945. underlyingError:underlyingError];
  946. }
  947. + (NSError *)networkErrorWithUnderlyingError:(NSError *)underlyingError {
  948. return [self errorWithCode:FIRAuthInternalErrorCodeNetworkError underlyingError:underlyingError];
  949. }
  950. + (NSError *)unexpectedErrorResponseWithData:(NSData *)data
  951. underlyingError:(NSError *)underlyingError {
  952. NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
  953. if (data) {
  954. userInfo[FIRAuthErrorUserInfoDataKey] = data;
  955. }
  956. if (underlyingError) {
  957. userInfo[NSUnderlyingErrorKey] = underlyingError;
  958. }
  959. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedErrorResponse
  960. userInfo:[userInfo copy]];
  961. }
  962. + (NSError *)unexpectedErrorResponseWithDeserializedResponse:(id)deserializedResponse {
  963. NSDictionary *userInfo;
  964. if (deserializedResponse) {
  965. userInfo = @{
  966. FIRAuthErrorUserInfoDeserializedResponseKey : deserializedResponse,
  967. };
  968. }
  969. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedErrorResponse userInfo:userInfo];
  970. }
  971. + (NSError *)unexpectedErrorResponseWithDeserializedResponse:(id)deserializedResponse
  972. underlyingError:(NSError *)underlyingError {
  973. NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
  974. if (deserializedResponse) {
  975. userInfo[FIRAuthErrorUserInfoDeserializedResponseKey] = deserializedResponse;
  976. }
  977. if (underlyingError) {
  978. userInfo[NSUnderlyingErrorKey] = underlyingError;
  979. }
  980. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedErrorResponse
  981. userInfo:[userInfo copy]];
  982. }
  983. + (NSError *)malformedJWTErrorWithToken:(NSString *)token
  984. underlyingError:(NSError *_Nullable)underlyingError {
  985. NSMutableDictionary *userInfo =
  986. [NSMutableDictionary dictionaryWithObject:kFIRAuthErrorMessageMalformedJWT
  987. forKey:NSLocalizedDescriptionKey];
  988. [userInfo setObject:token forKey:FIRAuthErrorUserInfoDataKey];
  989. if (underlyingError != nil) {
  990. [userInfo setObject:underlyingError forKey:NSUnderlyingErrorKey];
  991. }
  992. return [self errorWithCode:FIRAuthInternalErrorCodeMalformedJWT userInfo:[userInfo copy]];
  993. }
  994. + (NSError *)unexpectedResponseWithData:(NSData *)data underlyingError:(NSError *)underlyingError {
  995. NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
  996. if (data) {
  997. userInfo[FIRAuthErrorUserInfoDataKey] = data;
  998. }
  999. if (underlyingError) {
  1000. userInfo[NSUnderlyingErrorKey] = underlyingError;
  1001. }
  1002. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedResponse userInfo:[userInfo copy]];
  1003. }
  1004. + (NSError *)unexpectedResponseWithDeserializedResponse:(id)deserializedResponse {
  1005. NSDictionary *userInfo;
  1006. if (deserializedResponse) {
  1007. userInfo = @{
  1008. FIRAuthErrorUserInfoDeserializedResponseKey : deserializedResponse,
  1009. };
  1010. }
  1011. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedResponse userInfo:userInfo];
  1012. }
  1013. + (NSError *)unexpectedResponseWithDeserializedResponse:(nullable id)deserializedResponse
  1014. underlyingError:(NSError *)underlyingError {
  1015. NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
  1016. if (deserializedResponse) {
  1017. userInfo[FIRAuthErrorUserInfoDeserializedResponseKey] = deserializedResponse;
  1018. }
  1019. if (underlyingError) {
  1020. userInfo[NSUnderlyingErrorKey] = underlyingError;
  1021. }
  1022. return [self errorWithCode:FIRAuthInternalErrorCodeUnexpectedResponse userInfo:[userInfo copy]];
  1023. }
  1024. + (NSError *)RPCResponseDecodingErrorWithDeserializedResponse:(id)deserializedResponse
  1025. underlyingError:(NSError *)underlyingError {
  1026. NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
  1027. if (deserializedResponse) {
  1028. userInfo[FIRAuthErrorUserInfoDeserializedResponseKey] = deserializedResponse;
  1029. }
  1030. if (underlyingError) {
  1031. userInfo[NSUnderlyingErrorKey] = underlyingError;
  1032. }
  1033. return [self errorWithCode:FIRAuthInternalErrorCodeRPCResponseDecodingError
  1034. userInfo:[userInfo copy]];
  1035. }
  1036. + (NSError *)emailAlreadyInUseErrorWithEmail:(nullable NSString *)email {
  1037. NSDictionary *userInfo;
  1038. if (email.length) {
  1039. userInfo = @{
  1040. FIRAuthErrorUserInfoEmailKey : email,
  1041. };
  1042. }
  1043. return [self errorWithCode:FIRAuthInternalErrorCodeEmailAlreadyInUse userInfo:userInfo];
  1044. }
  1045. + (NSError *)userDisabledErrorWithMessage:(nullable NSString *)message {
  1046. return [self errorWithCode:FIRAuthInternalErrorCodeUserDisabled message:message];
  1047. }
  1048. + (NSError *)wrongPasswordErrorWithMessage:(nullable NSString *)message {
  1049. return [self errorWithCode:FIRAuthInternalErrorCodeWrongPassword message:message];
  1050. }
  1051. + (NSError *)tooManyRequestsErrorWithMessage:(nullable NSString *)message {
  1052. return [self errorWithCode:FIRAuthInternalErrorCodeTooManyRequests message:message];
  1053. }
  1054. + (NSError *)invalidCustomTokenErrorWithMessage:(nullable NSString *)message {
  1055. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidCustomToken message:message];
  1056. }
  1057. + (NSError *)customTokenMistmatchErrorWithMessage:(nullable NSString *)message {
  1058. return [self errorWithCode:FIRAuthInternalErrorCodeCustomTokenMismatch message:message];
  1059. }
  1060. + (NSError *)invalidCredentialErrorWithMessage:(nullable NSString *)message {
  1061. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidCredential message:message];
  1062. }
  1063. + (NSError *)requiresRecentLoginErrorWithMessage:(nullable NSString *)message {
  1064. return [self errorWithCode:FIRAuthInternalErrorCodeRequiresRecentLogin message:message];
  1065. }
  1066. + (NSError *)invalidUserTokenErrorWithMessage:(nullable NSString *)message {
  1067. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidUserToken message:message];
  1068. }
  1069. + (NSError *)invalidEmailErrorWithMessage:(nullable NSString *)message {
  1070. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidEmail message:message];
  1071. }
  1072. + (NSError *)accountExistsWithDifferentCredentialErrorWithEmail:(nullable NSString *)email
  1073. updatedCredential:
  1074. (nullable FIRAuthCredential *)updatedCredential {
  1075. NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
  1076. if (email) {
  1077. userInfo[FIRAuthErrorUserInfoEmailKey] = email;
  1078. }
  1079. if (updatedCredential) {
  1080. userInfo[FIRAuthErrorUserInfoUpdatedCredentialKey] = updatedCredential;
  1081. }
  1082. return [self errorWithCode:FIRAuthInternalErrorCodeAccountExistsWithDifferentCredential
  1083. userInfo:userInfo];
  1084. }
  1085. + (NSError *)providerAlreadyLinkedError {
  1086. return [self errorWithCode:FIRAuthInternalErrorCodeProviderAlreadyLinked];
  1087. }
  1088. + (NSError *)noSuchProviderError {
  1089. return [self errorWithCode:FIRAuthInternalErrorCodeNoSuchProvider];
  1090. }
  1091. + (NSError *)userTokenExpiredErrorWithMessage:(nullable NSString *)message {
  1092. return [self errorWithCode:FIRAuthInternalErrorCodeUserTokenExpired message:message];
  1093. }
  1094. + (NSError *)userNotFoundErrorWithMessage:(nullable NSString *)message {
  1095. return [self errorWithCode:FIRAuthInternalErrorCodeUserNotFound message:message];
  1096. }
  1097. + (NSError *)invalidAPIKeyError {
  1098. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidAPIKey];
  1099. }
  1100. + (NSError *)userMismatchError {
  1101. return [self errorWithCode:FIRAuthInternalErrorCodeUserMismatch];
  1102. }
  1103. + (NSError *)credentialAlreadyInUseErrorWithMessage:(nullable NSString *)message
  1104. credential:(nullable FIRAuthCredential *)credential
  1105. email:(nullable NSString *)email {
  1106. NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
  1107. if (credential) {
  1108. userInfo[FIRAuthErrorUserInfoUpdatedCredentialKey] = credential;
  1109. }
  1110. if (email.length) {
  1111. userInfo[FIRAuthErrorUserInfoEmailKey] = email;
  1112. }
  1113. if (userInfo.count) {
  1114. return [self errorWithCode:FIRAuthInternalErrorCodeCredentialAlreadyInUse userInfo:userInfo];
  1115. }
  1116. return [self errorWithCode:FIRAuthInternalErrorCodeCredentialAlreadyInUse message:message];
  1117. }
  1118. + (NSError *)operationNotAllowedErrorWithMessage:(nullable NSString *)message {
  1119. return [self errorWithCode:FIRAuthInternalErrorCodeOperationNotAllowed message:message];
  1120. }
  1121. + (NSError *)weakPasswordErrorWithServerResponseReason:(nullable NSString *)reason {
  1122. NSDictionary *userInfo;
  1123. if (reason.length) {
  1124. userInfo = @{
  1125. NSLocalizedFailureReasonErrorKey : reason,
  1126. };
  1127. }
  1128. return [self errorWithCode:FIRAuthInternalErrorCodeWeakPassword userInfo:userInfo];
  1129. }
  1130. + (NSError *)appNotAuthorizedError {
  1131. return [self errorWithCode:FIRAuthInternalErrorCodeAppNotAuthorized];
  1132. }
  1133. + (NSError *)expiredActionCodeErrorWithMessage:(nullable NSString *)message {
  1134. return [self errorWithCode:FIRAuthInternalErrorCodeExpiredActionCode message:message];
  1135. }
  1136. + (NSError *)invalidActionCodeErrorWithMessage:(nullable NSString *)message {
  1137. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidActionCode message:message];
  1138. }
  1139. + (NSError *)invalidMessagePayloadErrorWithMessage:(nullable NSString *)message {
  1140. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidMessagePayload message:message];
  1141. }
  1142. + (NSError *)invalidSenderErrorWithMessage:(nullable NSString *)message {
  1143. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidSender message:message];
  1144. }
  1145. + (NSError *)invalidRecipientEmailErrorWithMessage:(nullable NSString *)message {
  1146. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidRecipientEmail message:message];
  1147. }
  1148. + (NSError *)missingIosBundleIDErrorWithMessage:(nullable NSString *)message {
  1149. return [self errorWithCode:FIRAuthinternalErrorCodeMissingIosBundleID message:message];
  1150. }
  1151. + (NSError *)missingAndroidPackageNameErrorWithMessage:(nullable NSString *)message {
  1152. return [self errorWithCode:FIRAuthInternalErrorCodeMissingAndroidPackageName message:message];
  1153. }
  1154. + (NSError *)unauthorizedDomainErrorWithMessage:(nullable NSString *)message {
  1155. return [self errorWithCode:FIRAuthInternalErrorCodeUnauthorizedDomain message:message];
  1156. }
  1157. + (NSError *)invalidContinueURIErrorWithMessage:(nullable NSString *)message {
  1158. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidContinueURI message:message];
  1159. }
  1160. + (NSError *)missingContinueURIErrorWithMessage:(nullable NSString *)message {
  1161. return [self errorWithCode:FIRAuthInternalErrorCodeMissingContinueURI message:message];
  1162. }
  1163. + (NSError *)missingEmailErrorWithMessage:(nullable NSString *)message {
  1164. return [self errorWithCode:FIRAuthInternalErrorCodeMissingEmail message:message];
  1165. }
  1166. + (NSError *)missingPhoneNumberErrorWithMessage:(nullable NSString *)message {
  1167. return [self errorWithCode:FIRAuthInternalErrorCodeMissingPhoneNumber message:message];
  1168. }
  1169. + (NSError *)invalidPhoneNumberErrorWithMessage:(nullable NSString *)message {
  1170. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidPhoneNumber message:message];
  1171. }
  1172. + (NSError *)missingVerificationCodeErrorWithMessage:(nullable NSString *)message {
  1173. return [self errorWithCode:FIRAuthInternalErrorCodeMissingVerificationCode message:message];
  1174. }
  1175. + (NSError *)invalidVerificationCodeErrorWithMessage:(nullable NSString *)message {
  1176. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidVerificationCode message:message];
  1177. }
  1178. + (NSError *)missingVerificationIDErrorWithMessage:(nullable NSString *)message {
  1179. return [self errorWithCode:FIRAuthInternalErrorCodeMissingVerificationID message:message];
  1180. }
  1181. + (NSError *)invalidVerificationIDErrorWithMessage:(nullable NSString *)message {
  1182. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidVerificationID message:message];
  1183. }
  1184. + (NSError *)sessionExpiredErrorWithMessage:(nullable NSString *)message {
  1185. return [self errorWithCode:FIRAuthInternalErrorCodeSessionExpired message:message];
  1186. }
  1187. + (NSError *)missingAppCredentialWithMessage:(nullable NSString *)message {
  1188. return [self errorWithCode:FIRAuthInternalErrorCodeMissingAppCredential message:message];
  1189. }
  1190. + (NSError *)invalidAppCredentialWithMessage:(nullable NSString *)message {
  1191. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidAppCredential message:message];
  1192. }
  1193. + (NSError *)quotaExceededErrorWithMessage:(nullable NSString *)message {
  1194. return [self errorWithCode:FIRAuthInternalErrorCodeQuotaExceeded message:message];
  1195. }
  1196. + (NSError *)missingAppTokenErrorWithUnderlyingError:(nullable NSError *)underlyingError {
  1197. return [self errorWithCode:FIRAuthInternalErrorCodeMissingAppToken
  1198. underlyingError:underlyingError];
  1199. }
  1200. + (NSError *)localPlayerNotAuthenticatedError {
  1201. return [self errorWithCode:FIRAuthInternalErrorCodeLocalPlayerNotAuthenticated];
  1202. }
  1203. + (NSError *)gameKitNotLinkedError {
  1204. return [self errorWithCode:FIRAuthInternalErrorCodeGameKitNotLinked];
  1205. }
  1206. #if TARGET_OS_IOS
  1207. + (NSError *)secondFactorRequiredErrorWithPendingCredential:(NSString *)MFAPendingCredential
  1208. hints:(NSArray<FIRMultiFactorInfo *> *)hints
  1209. auth:(FIRAuth *)auth {
  1210. NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
  1211. if (MFAPendingCredential && hints) {
  1212. FIRMultiFactorResolver *resolver =
  1213. [[FIRMultiFactorResolver alloc] initWithMFAPendingCredential:MFAPendingCredential
  1214. hints:hints
  1215. auth:auth];
  1216. userInfo[FIRAuthErrorUserInfoMultiFactorResolverKey] = resolver;
  1217. }
  1218. return [self errorWithCode:FIRAuthInternalErrorCodeSecondFactorRequired userInfo:userInfo];
  1219. }
  1220. #endif
  1221. + (NSError *)notificationNotForwardedError {
  1222. return [self errorWithCode:FIRAuthInternalErrorCodeNotificationNotForwarded];
  1223. }
  1224. + (NSError *)appNotVerifiedErrorWithMessage:(nullable NSString *)message {
  1225. return [self errorWithCode:FIRAuthInternalErrorCodeAppNotVerified message:message];
  1226. }
  1227. + (NSError *)missingClientIdentifierErrorWithMessage:(nullable NSString *)message {
  1228. return [self errorWithCode:FIRAuthInternalErrorCodeMissingClientIdentifier message:message];
  1229. }
  1230. + (NSError *)missingClientTypeErrorWithMessage:(nullable NSString *)message {
  1231. return [self errorWithCode:FIRAuthInternalErrorCodeMissingClientType message:message];
  1232. }
  1233. + (NSError *)captchaCheckFailedErrorWithMessage:(nullable NSString *)message {
  1234. return [self errorWithCode:FIRAuthInternalErrorCodeCaptchaCheckFailed message:message];
  1235. }
  1236. + (NSError *)webContextAlreadyPresentedErrorWithMessage:(nullable NSString *)message {
  1237. return [self errorWithCode:FIRAuthInternalErrorCodeWebContextAlreadyPresented message:message];
  1238. }
  1239. + (NSError *)webContextCancelledErrorWithMessage:(nullable NSString *)message {
  1240. return [self errorWithCode:FIRAuthInternalErrorCodeWebContextCancelled message:message];
  1241. }
  1242. + (NSError *)appVerificationUserInteractionFailureWithReason:(NSString *)reason {
  1243. NSDictionary *userInfo;
  1244. if (reason.length) {
  1245. userInfo = @{
  1246. NSLocalizedFailureReasonErrorKey : reason,
  1247. };
  1248. }
  1249. return [self errorWithCode:FIRAuthInternalErrorCodeAppVerificationUserInteractionFailure
  1250. userInfo:userInfo];
  1251. }
  1252. + (NSError *)webSignInUserInteractionFailureWithReason:(nullable NSString *)reason {
  1253. NSDictionary *userInfo;
  1254. if (reason.length) {
  1255. userInfo = @{
  1256. NSLocalizedFailureReasonErrorKey : reason,
  1257. };
  1258. }
  1259. return [self errorWithCode:FIRAuthInternalErrorCodeWebSignInUserInteractionFailure
  1260. userInfo:userInfo];
  1261. }
  1262. + (nullable NSError *)URLResponseErrorWithCode:(NSString *)code
  1263. message:(nullable NSString *)message {
  1264. if ([code isEqualToString:kURLResponseErrorCodeInvalidClientID]) {
  1265. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidClientID message:message];
  1266. }
  1267. if ([code isEqualToString:kURLResponseErrorCodeNetworkRequestFailed]) {
  1268. return [self errorWithCode:FIRAuthInternalErrorCodeWebNetworkRequestFailed message:message];
  1269. }
  1270. if ([code isEqualToString:kURLResponseErrorCodeInternalError]) {
  1271. return [self errorWithCode:FIRAuthInternalErrorCodeWebInternalError message:message];
  1272. }
  1273. return nil;
  1274. }
  1275. + (NSError *)nullUserErrorWithMessage:(nullable NSString *)message {
  1276. return [self errorWithCode:FIRAuthInternalErrorCodeNullUser message:message];
  1277. }
  1278. + (NSError *)invalidProviderIDErrorWithMessage:(nullable NSString *)message {
  1279. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidProviderID message:message];
  1280. }
  1281. + (NSError *)invalidDynamicLinkDomainErrorWithMessage:(nullable NSString *)message {
  1282. return [self errorWithCode:FIRAuthInternalErrorCodeInvalidDynamicLinkDomain message:message];
  1283. }
  1284. + (NSError *)missingOrInvalidNonceErrorWithMessage:(nullable NSString *)message {
  1285. return [self errorWithCode:FIRAuthInternalErrorCodeMissingOrInvalidNonce message:message];
  1286. }
  1287. + (NSError *)keychainErrorWithFunction:(NSString *)keychainFunction status:(OSStatus)status {
  1288. NSString *failureReason = [NSString stringWithFormat:@"%@ (%li)", keychainFunction, (long)status];
  1289. return [self errorWithCode:FIRAuthInternalErrorCodeKeychainError
  1290. userInfo:@{
  1291. NSLocalizedFailureReasonErrorKey : failureReason,
  1292. }];
  1293. }
  1294. + (NSError *)tenantIDMismatchError {
  1295. return [self errorWithCode:FIRAuthInternalErrorCodeTenantIDMismatch];
  1296. }
  1297. + (NSError *)unsupportedTenantOperationError {
  1298. return [self errorWithCode:FIRAuthInternalErrorCodeUnsupportedTenantOperation];
  1299. }
  1300. + (NSError *)blockingCloudFunctionServerResponseWithMessage:(nullable NSString *)message {
  1301. if (message == nil) {
  1302. return [self errorWithCode:FIRAuthInternalErrorBlockingCloudFunctionError message:message];
  1303. }
  1304. NSString *jsonString =
  1305. [message stringByReplacingOccurrencesOfString:@"HTTP Cloud Function returned an error:"
  1306. withString:@""];
  1307. jsonString = [jsonString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
  1308. NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
  1309. NSError *jsonError;
  1310. NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData
  1311. options:0
  1312. error:&jsonError];
  1313. if (jsonError) {
  1314. return [self JSONSerializationErrorWithUnderlyingError:jsonError];
  1315. }
  1316. NSDictionary *errorDict = jsonDict[@"error"];
  1317. NSString *errorMessage = errorDict[@"message"];
  1318. return [self errorWithCode:FIRAuthInternalErrorBlockingCloudFunctionError message:errorMessage];
  1319. }
  1320. + (NSError *)recaptchaSDKNotLinkedError {
  1321. return [self errorWithCode:FIRAuthInternalErrorCodeRecaptchaSDKNotLinked
  1322. message:kFIRAuthErrorMessageRecaptchaSDKNotLinked];
  1323. }
  1324. @end
  1325. NS_ASSUME_NONNULL_END