AuthErrors.swift 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997
  1. // Copyright 2023 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. import Foundation
  15. /// Error Codes common to all API Methods:
  16. @objc(FIRAuthErrors) open class AuthErrors: NSObject {
  17. /// The Firebase Auth error domain.
  18. @objc public static let domain: String = "FIRAuthErrorDomain"
  19. /// The name of the key for the error short string of an error code.
  20. @objc public static let userInfoNameKey: String = "FIRAuthErrorUserInfoNameKey"
  21. /// Error codes for Email operations
  22. ///
  23. /// Errors with one of the following three codes:
  24. /// * `accountExistsWithDifferentCredential`
  25. /// * `credentialAlreadyInUse`
  26. /// * emailAlreadyInUse`
  27. ///
  28. /// may contain an `NSError.userInfo` dictionary object which contains this key. The value
  29. /// associated with this key is an NSString of the email address of the account that already
  30. /// exists.
  31. @objc public static let userInfoEmailKey: String = "FIRAuthErrorUserInfoEmailKey"
  32. /// The key used to read the updated Auth credential from the userInfo dictionary of the
  33. /// NSError object returned. This is the updated auth credential the developer should use for
  34. /// recovery if applicable.
  35. @objc public static let userInfoUpdatedCredentialKey: String =
  36. "FIRAuthErrorUserInfoUpdatedCredentialKey"
  37. /// The key used to read the MFA resolver from the userInfo dictionary of the NSError object
  38. /// returned when 2FA is required for sign-incompletion.
  39. @objc(FIRAuthErrorUserInfoMultiFactorResolverKey)
  40. public static let userInfoMultiFactorResolverKey: String =
  41. "FIRAuthErrorUserInfoMultiFactorResolverKey"
  42. }
  43. /// Error codes used by Firebase Auth.
  44. @objc(FIRAuthErrorCode) public enum AuthErrorCode: Int {
  45. /// Indicates a validation error with the custom token.
  46. case invalidCustomToken = 17000
  47. /// Indicates the service account and the API key belong to different projects.
  48. case customTokenMismatch = 17002
  49. /// Indicates the IDP token or requestUri is invalid.
  50. case invalidCredential = 17004
  51. /// Indicates the user's account is disabled on the server.
  52. case userDisabled = 17005
  53. /// Indicates the administrator disabled sign in with the specified identity provider.
  54. case operationNotAllowed = 17006
  55. /// Indicates the email used to attempt a sign up is already in use.
  56. case emailAlreadyInUse = 17007
  57. /// Indicates the email is invalid.
  58. case invalidEmail = 17008
  59. /// Indicates the user attempted sign in with a wrong password.
  60. case wrongPassword = 17009
  61. /// Indicates that too many requests were made to a server method.
  62. case tooManyRequests = 17010
  63. /// Indicates the user account was not found.
  64. case userNotFound = 17011
  65. /// Indicates account linking is required.
  66. case accountExistsWithDifferentCredential = 17012
  67. /// Indicates the user has attemped to change email or password more than 5 minutes after
  68. /// signing in.
  69. case requiresRecentLogin = 17014
  70. /// Indicates an attempt to link a provider to which the account is already linked.
  71. case providerAlreadyLinked = 17015
  72. /// Indicates an attempt to unlink a provider that is not linked.
  73. case noSuchProvider = 17016
  74. /// Indicates user's saved auth credential is invalid the user needs to sign in again.
  75. case invalidUserToken = 17017
  76. /// Indicates a network error occurred (such as a timeout interrupted connection or
  77. /// unreachable host). These types of errors are often recoverable with a retry. The
  78. /// `NSUnderlyingError` field in the `NSError.userInfo` dictionary will contain the error
  79. /// encountered.
  80. case networkError = 17020
  81. /// Indicates the saved token has expired for example the user may have changed account
  82. /// password on another device. The user needs to sign in again on the device that made this
  83. /// request.
  84. case userTokenExpired = 17021
  85. /// Indicates an invalid API key was supplied in the request.
  86. case invalidAPIKey = 17023
  87. /// Indicates that an attempt was made to reauthenticate with a user which is not the current
  88. /// user.
  89. case userMismatch = 17024
  90. /// Indicates an attempt to link with a credential that has already been linked with a
  91. /// different Firebase account.
  92. case credentialAlreadyInUse = 17025
  93. /// Indicates an attempt to set a password that is considered too weak.
  94. case weakPassword = 17026
  95. /// Indicates the App is not authorized to use Firebase Authentication with the
  96. /// provided API Key.
  97. case appNotAuthorized = 17028
  98. /// Indicates the OOB code is expired.
  99. case expiredActionCode = 17029
  100. /// Indicates the OOB code is invalid.
  101. case invalidActionCode = 17030
  102. /// Indicates that there are invalid parameters in the payload during a
  103. /// "send password reset email" attempt.
  104. case invalidMessagePayload = 17031
  105. /// Indicates that the sender email is invalid during a "send password reset email" attempt.
  106. case invalidSender = 17032
  107. /// Indicates that the recipient email is invalid.
  108. case invalidRecipientEmail = 17033
  109. /// Indicates that an email address was expected but one was not provided.
  110. case missingEmail = 17034
  111. // The enum values 17035 is reserved and should NOT be used for new error codes.
  112. /// Indicates that the iOS bundle ID is missing when a iOS App Store ID is provided.
  113. case missingIosBundleID = 17036
  114. /// Indicates that the android package name is missing when the `androidInstallApp` flag is set
  115. /// to `true`.
  116. case missingAndroidPackageName = 17037
  117. /// Indicates that the domain specified in the continue URL is not allowlisted in the Firebase
  118. /// console.
  119. case unauthorizedDomain = 17038
  120. /// Indicates that the domain specified in the continue URI is not valid.
  121. case invalidContinueURI = 17039
  122. /// Indicates that a continue URI was not provided in a request to the backend which requires one.
  123. case missingContinueURI = 17040
  124. /// Indicates that a phone number was not provided in a call to
  125. /// `verifyPhoneNumber:completion:`.
  126. case missingPhoneNumber = 17041
  127. /// Indicates that an invalid phone number was provided in a call to
  128. /// `verifyPhoneNumber:completion:`.
  129. case invalidPhoneNumber = 17042
  130. /// Indicates that the phone auth credential was created with an empty verification code.
  131. case missingVerificationCode = 17043
  132. /// Indicates that an invalid verification code was used in the verifyPhoneNumber request.
  133. case invalidVerificationCode = 17044
  134. /// Indicates that the phone auth credential was created with an empty verification ID.
  135. case missingVerificationID = 17045
  136. /// Indicates that an invalid verification ID was used in the verifyPhoneNumber request.
  137. case invalidVerificationID = 17046
  138. /// Indicates that the APNS device token is missing in the verifyClient request.
  139. case missingAppCredential = 17047
  140. /// Indicates that an invalid APNS device token was used in the verifyClient request.
  141. case invalidAppCredential = 17048
  142. // The enum values between 17048 and 17051 are reserved and should NOT be used for new error
  143. // codes.
  144. /// Indicates that the SMS code has expired.
  145. case sessionExpired = 17051
  146. /// Indicates that the quota of SMS messages for a given project has been exceeded.
  147. case quotaExceeded = 17052
  148. /// Indicates that the APNs device token could not be obtained. The app may not have set up
  149. /// remote notification correctly or may fail to forward the APNs device token to Auth
  150. /// if app delegate swizzling is disabled.
  151. case missingAppToken = 17053
  152. /// Indicates that the app fails to forward remote notification to FIRAuth.
  153. case notificationNotForwarded = 17054
  154. /// Indicates that the app could not be verified by Firebase during phone number authentication.
  155. case appNotVerified = 17055
  156. /// Indicates that the reCAPTCHA token is not valid.
  157. case captchaCheckFailed = 17056
  158. /// Indicates that an attempt was made to present a new web context while one was already being
  159. /// presented.
  160. case webContextAlreadyPresented = 17057
  161. /// Indicates that the URL presentation was cancelled prematurely by the user.
  162. case webContextCancelled = 17058
  163. /// Indicates a general failure during the app verification flow.
  164. case appVerificationUserInteractionFailure = 17059
  165. /// Indicates that the clientID used to invoke a web flow is invalid.
  166. case invalidClientID = 17060
  167. /// Indicates that a network request within a SFSafariViewController or WKWebView failed.
  168. case webNetworkRequestFailed = 17061
  169. /// Indicates that an internal error occurred within a SFSafariViewController or WKWebView.
  170. case webInternalError = 17062
  171. /// Indicates a general failure during a web sign-in flow.
  172. case webSignInUserInteractionFailure = 17063
  173. /// Indicates that the local player was not authenticated prior to attempting Game Center signin.
  174. case localPlayerNotAuthenticated = 17066
  175. /// Indicates that a non-null user was expected as an argmument to the operation but a null
  176. /// user was provided.
  177. case nullUser = 17067
  178. /// Indicates that a Firebase Dynamic Link is not activated.
  179. case dynamicLinkNotActivated = 17068
  180. /// Represents the error code for when the given provider id for a web operation is invalid.
  181. case invalidProviderID = 17071
  182. /// Represents the error code for when an attempt is made to update the current user with a
  183. /// tenantId that differs from the current FirebaseAuth instance's tenantId.
  184. case tenantIDMismatch = 17072
  185. /// Represents the error code for when a request is made to the backend with an associated tenant
  186. /// ID for an operation that does not support multi-tenancy.
  187. case unsupportedTenantOperation = 17073
  188. /// Indicates that the Firebase Dynamic Link domain used is either not configured or is
  189. /// unauthorized for the current project.
  190. case invalidDynamicLinkDomain = 17074
  191. /// Indicates that the credential is rejected because it's misformed or mismatching.
  192. case rejectedCredential = 17075
  193. /// Indicates that the GameKit framework is not linked prior to attempting Game Center signin.
  194. case gameKitNotLinked = 17076
  195. /// Indicates that the second factor is required for signin.
  196. case secondFactorRequired = 17078
  197. /// Indicates that the multi factor session is missing.
  198. case missingMultiFactorSession = 17081
  199. /// Indicates that the multi factor info is missing.
  200. case missingMultiFactorInfo = 17082
  201. /// Indicates that the multi factor session is invalid.
  202. case invalidMultiFactorSession = 17083
  203. /// Indicates that the multi factor info is not found.
  204. case multiFactorInfoNotFound = 17084
  205. /// Indicates that the operation is admin restricted.
  206. case adminRestrictedOperation = 17085
  207. /// Indicates that the email is required for verification.
  208. case unverifiedEmail = 17086
  209. /// Indicates that the second factor is already enrolled.
  210. case secondFactorAlreadyEnrolled = 17087
  211. /// Indicates that the maximum second factor count is exceeded.
  212. case maximumSecondFactorCountExceeded = 17088
  213. /// Indicates that the first factor is not supported.
  214. case unsupportedFirstFactor = 17089
  215. /// Indicates that the a verifed email is required to changed to.
  216. case emailChangeNeedsVerification = 17090
  217. /// Indicates that the request does not contain a client identifier.
  218. case missingClientIdentifier = 17093
  219. /// Indicates that the nonce is missing or invalid.
  220. case missingOrInvalidNonce = 17094
  221. /// Raised when n Cloud Function returns a blocking error. Will include a message returned from
  222. /// the function.
  223. case blockingCloudFunctionError = 17105
  224. /// Indicates that reCAPTCHA Enterprise integration is not enabled for this project.
  225. case recaptchaNotEnabled = 17200
  226. /// Indicates that the reCAPTCHA token is missing from the backend request.
  227. case missingRecaptchaToken = 17201
  228. /// Indicates that the reCAPTCHA token sent with the backend request is invalid.
  229. case invalidRecaptchaToken = 17202
  230. /// Indicates that the requested reCAPTCHA action is invalid.
  231. case invalidRecaptchaAction = 17203
  232. /// Indicates that the client type is missing from the request.
  233. case missingClientType = 17204
  234. /// Indicates that the reCAPTCHA version is missing from the request.
  235. case missingRecaptchaVersion = 17205
  236. /// Indicates that the reCAPTCHA version sent to the backend is invalid.
  237. case invalidRecaptchaVersion = 17206
  238. /// Indicates that the request type sent to the backend is invalid.
  239. case invalidReqType = 17207
  240. /// Indicates that the reCAPTCHA SDK is not linked to the app.
  241. case recaptchaSDKNotLinked = 17208
  242. /// Indicates that the reCAPTCHA SDK site key wasn't found.
  243. case recaptchaSiteKeyMissing = 17209
  244. /// Indicates that the reCAPTCHA SDK actions class failed to create.
  245. case recaptchaActionCreationFailed = 17210
  246. /// Indicates an error occurred while attempting to access the keychain.
  247. case keychainError = 17995
  248. /// Indicates an internal error occurred.
  249. case internalError = 17999
  250. /// Raised when a JWT fails to parse correctly. May be accompanied by an underlying error
  251. /// describing which step of the JWT parsing process failed.
  252. case malformedJWT = 18000
  253. var errorDescription: String {
  254. switch self {
  255. case .invalidCustomToken:
  256. return kErrorInvalidCustomToken
  257. case .customTokenMismatch:
  258. return kErrorCustomTokenMismatch
  259. case .invalidEmail:
  260. return kErrorInvalidEmail
  261. case .invalidCredential:
  262. return kErrorInvalidCredential
  263. case .userDisabled:
  264. return kErrorUserDisabled
  265. case .emailAlreadyInUse:
  266. return kErrorEmailAlreadyInUse
  267. case .wrongPassword:
  268. return kErrorWrongPassword
  269. case .tooManyRequests:
  270. return kErrorTooManyRequests
  271. case .accountExistsWithDifferentCredential:
  272. return kErrorAccountExistsWithDifferentCredential
  273. case .requiresRecentLogin:
  274. return kErrorRequiresRecentLogin
  275. case .providerAlreadyLinked:
  276. return kErrorProviderAlreadyLinked
  277. case .noSuchProvider:
  278. return kErrorNoSuchProvider
  279. case .invalidUserToken:
  280. return kErrorInvalidUserToken
  281. case .networkError:
  282. return kErrorNetworkError
  283. case .keychainError:
  284. return kErrorKeychainError
  285. case .missingClientIdentifier:
  286. return kErrorMissingClientIdentifier
  287. case .userTokenExpired:
  288. return kErrorUserTokenExpired
  289. case .userNotFound:
  290. return kErrorUserNotFound
  291. case .invalidAPIKey:
  292. return kErrorInvalidAPIKey
  293. case .credentialAlreadyInUse:
  294. return kErrorCredentialAlreadyInUse
  295. case .internalError:
  296. return kErrorInternalError
  297. case .userMismatch:
  298. return FIRAuthErrorMessageUserMismatch
  299. case .operationNotAllowed:
  300. return kErrorOperationNotAllowed
  301. case .weakPassword:
  302. return kErrorWeakPassword
  303. case .appNotAuthorized:
  304. return kErrorAppNotAuthorized
  305. case .expiredActionCode:
  306. return kErrorExpiredActionCode
  307. case .invalidActionCode:
  308. return kErrorInvalidActionCode
  309. case .invalidSender:
  310. return kErrorInvalidSender
  311. case .invalidMessagePayload:
  312. return kErrorInvalidMessagePayload
  313. case .invalidRecipientEmail:
  314. return kErrorInvalidRecipientEmail
  315. case .missingIosBundleID:
  316. return kErrorMissingIosBundleID
  317. case .missingAndroidPackageName:
  318. return kErrorMissingAndroidPackageName
  319. case .unauthorizedDomain:
  320. return kErrorUnauthorizedDomain
  321. case .invalidContinueURI:
  322. return kErrorInvalidContinueURI
  323. case .missingContinueURI:
  324. return kErrorMissingContinueURI
  325. case .missingEmail:
  326. return kErrorMissingEmail
  327. case .missingPhoneNumber:
  328. return kErrorMissingPhoneNumber
  329. case .invalidPhoneNumber:
  330. return kErrorInvalidPhoneNumber
  331. case .missingVerificationCode:
  332. return kErrorMissingVerificationCode
  333. case .invalidVerificationCode:
  334. return kErrorInvalidVerificationCode
  335. case .missingVerificationID:
  336. return kErrorMissingVerificationID
  337. case .invalidVerificationID:
  338. return kErrorInvalidVerificationID
  339. case .sessionExpired:
  340. return kErrorSessionExpired
  341. case .missingAppCredential:
  342. return kErrorMissingAppCredential
  343. case .invalidAppCredential:
  344. return kErrorInvalidAppCredential
  345. case .quotaExceeded:
  346. return kErrorQuotaExceeded
  347. case .missingAppToken:
  348. return kErrorMissingAppToken
  349. case .notificationNotForwarded:
  350. return kErrorNotificationNotForwarded
  351. case .appNotVerified:
  352. return kErrorAppNotVerified
  353. case .captchaCheckFailed:
  354. return kErrorCaptchaCheckFailed
  355. case .webContextAlreadyPresented:
  356. return kErrorWebContextAlreadyPresented
  357. case .webContextCancelled:
  358. return kErrorWebContextCancelled
  359. case .invalidClientID:
  360. return kErrorInvalidClientID
  361. case .appVerificationUserInteractionFailure:
  362. return kErrorAppVerificationUserInteractionFailure
  363. case .webNetworkRequestFailed:
  364. return kErrorWebRequestFailed
  365. case .nullUser:
  366. return kErrorNullUser
  367. case .invalidProviderID:
  368. return kErrorInvalidProviderID
  369. case .invalidDynamicLinkDomain:
  370. return kErrorInvalidDynamicLinkDomain
  371. case .webInternalError:
  372. return kErrorWebInternalError
  373. case .webSignInUserInteractionFailure:
  374. return kErrorAppVerificationUserInteractionFailure
  375. case .malformedJWT:
  376. return kErrorMalformedJWT
  377. case .localPlayerNotAuthenticated:
  378. return kErrorLocalPlayerNotAuthenticated
  379. case .gameKitNotLinked:
  380. return kErrorGameKitNotLinked
  381. case .secondFactorRequired:
  382. return kErrorSecondFactorRequired
  383. case .missingMultiFactorSession:
  384. return FIRAuthErrorMessageMissingMultiFactorSession
  385. case .missingMultiFactorInfo:
  386. return FIRAuthErrorMessageMissingMultiFactorInfo
  387. case .invalidMultiFactorSession:
  388. return FIRAuthErrorMessageInvalidMultiFactorSession
  389. case .multiFactorInfoNotFound:
  390. return FIRAuthErrorMessageMultiFactorInfoNotFound
  391. case .adminRestrictedOperation:
  392. return FIRAuthErrorMessageAdminRestrictedOperation
  393. case .unverifiedEmail:
  394. return FIRAuthErrorMessageUnverifiedEmail
  395. case .secondFactorAlreadyEnrolled:
  396. return FIRAuthErrorMessageSecondFactorAlreadyEnrolled
  397. case .maximumSecondFactorCountExceeded:
  398. return FIRAuthErrorMessageMaximumSecondFactorCountExceeded
  399. case .unsupportedFirstFactor:
  400. return FIRAuthErrorMessageUnsupportedFirstFactor
  401. case .emailChangeNeedsVerification:
  402. return FIRAuthErrorMessageEmailChangeNeedsVerification
  403. case .dynamicLinkNotActivated:
  404. return kErrorDynamicLinkNotActivated
  405. case .rejectedCredential:
  406. return kErrorRejectedCredential
  407. case .missingOrInvalidNonce:
  408. return kErrorMissingOrInvalidNonce
  409. case .tenantIDMismatch:
  410. return kErrorTenantIDMismatch
  411. case .unsupportedTenantOperation:
  412. return kErrorUnsupportedTenantOperation
  413. case .blockingCloudFunctionError:
  414. return kErrorBlockingCloudFunctionReturnedError
  415. case .recaptchaNotEnabled:
  416. return kErrorRecaptchaNotEnabled
  417. case .missingRecaptchaToken:
  418. return kErrorMissingRecaptchaToken
  419. case .invalidRecaptchaToken:
  420. return kErrorInvalidRecaptchaToken
  421. case .invalidRecaptchaAction:
  422. return kErrorInvalidRecaptchaAction
  423. case .missingClientType:
  424. return kErrorMissingClientType
  425. case .missingRecaptchaVersion:
  426. return kErrorMissingRecaptchaVersion
  427. case .invalidRecaptchaVersion:
  428. return kErrorInvalidRecaptchaVersion
  429. case .invalidReqType:
  430. return kErrorInvalidReqType
  431. case .recaptchaSDKNotLinked:
  432. return kErrorRecaptchaSDKNotLinked
  433. case .recaptchaSiteKeyMissing:
  434. return kErrorSiteKeyMissing
  435. case .recaptchaActionCreationFailed:
  436. return kErrorRecaptchaActionCreationFailed
  437. }
  438. }
  439. var errorCodeString: String {
  440. switch self {
  441. case .invalidCustomToken:
  442. return "ERROR_INVALID_CUSTOM_TOKEN"
  443. case .customTokenMismatch:
  444. return "ERROR_CUSTOM_TOKEN_MISMATCH"
  445. case .invalidEmail:
  446. return "ERROR_INVALID_EMAIL"
  447. case .invalidCredential:
  448. return "ERROR_INVALID_CREDENTIAL"
  449. case .userDisabled:
  450. return "ERROR_USER_DISABLED"
  451. case .emailAlreadyInUse:
  452. return "ERROR_EMAIL_ALREADY_IN_USE"
  453. case .wrongPassword:
  454. return "ERROR_WRONG_PASSWORD"
  455. case .tooManyRequests:
  456. return "ERROR_TOO_MANY_REQUESTS"
  457. case .accountExistsWithDifferentCredential:
  458. return "ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL"
  459. case .requiresRecentLogin:
  460. return "ERROR_REQUIRES_RECENT_LOGIN"
  461. case .providerAlreadyLinked:
  462. return "ERROR_PROVIDER_ALREADY_LINKED"
  463. case .noSuchProvider:
  464. return "ERROR_NO_SUCH_PROVIDER"
  465. case .invalidUserToken:
  466. return "ERROR_INVALID_USER_TOKEN"
  467. case .networkError:
  468. return "ERROR_NETWORK_REQUEST_FAILED"
  469. case .keychainError:
  470. return "ERROR_KEYCHAIN_ERROR"
  471. case .missingClientIdentifier:
  472. return "ERROR_MISSING_CLIENT_IDENTIFIER"
  473. case .userTokenExpired:
  474. return "ERROR_USER_TOKEN_EXPIRED"
  475. case .userNotFound:
  476. return "ERROR_USER_NOT_FOUND"
  477. case .invalidAPIKey:
  478. return "ERROR_INVALID_API_KEY"
  479. case .credentialAlreadyInUse:
  480. return "ERROR_CREDENTIAL_ALREADY_IN_USE"
  481. case .internalError:
  482. return "ERROR_INTERNAL_ERROR"
  483. case .userMismatch:
  484. return "ERROR_USER_MISMATCH"
  485. case .operationNotAllowed:
  486. return "ERROR_OPERATION_NOT_ALLOWED"
  487. case .weakPassword:
  488. return "ERROR_WEAK_PASSWORD"
  489. case .appNotAuthorized:
  490. return "ERROR_APP_NOT_AUTHORIZED"
  491. case .expiredActionCode:
  492. return "ERROR_EXPIRED_ACTION_CODE"
  493. case .invalidActionCode:
  494. return "ERROR_INVALID_ACTION_CODE"
  495. case .invalidMessagePayload:
  496. return "ERROR_INVALID_MESSAGE_PAYLOAD"
  497. case .invalidSender:
  498. return "ERROR_INVALID_SENDER"
  499. case .invalidRecipientEmail:
  500. return "ERROR_INVALID_RECIPIENT_EMAIL"
  501. case .missingIosBundleID:
  502. return "ERROR_MISSING_IOS_BUNDLE_ID"
  503. case .missingAndroidPackageName:
  504. return "ERROR_MISSING_ANDROID_PKG_NAME"
  505. case .unauthorizedDomain:
  506. return "ERROR_UNAUTHORIZED_DOMAIN"
  507. case .invalidContinueURI:
  508. return "ERROR_INVALID_CONTINUE_URI"
  509. case .missingContinueURI:
  510. return "ERROR_MISSING_CONTINUE_URI"
  511. case .missingEmail:
  512. return "ERROR_MISSING_EMAIL"
  513. case .missingPhoneNumber:
  514. return "ERROR_MISSING_PHONE_NUMBER"
  515. case .invalidPhoneNumber:
  516. return "ERROR_INVALID_PHONE_NUMBER"
  517. case .missingVerificationCode:
  518. return "ERROR_MISSING_VERIFICATION_CODE"
  519. case .invalidVerificationCode:
  520. return "ERROR_INVALID_VERIFICATION_CODE"
  521. case .missingVerificationID:
  522. return "ERROR_MISSING_VERIFICATION_ID"
  523. case .invalidVerificationID:
  524. return "ERROR_INVALID_VERIFICATION_ID"
  525. case .sessionExpired:
  526. return "ERROR_SESSION_EXPIRED"
  527. case .missingAppCredential:
  528. return "MISSING_APP_CREDENTIAL"
  529. case .invalidAppCredential:
  530. return "INVALID_APP_CREDENTIAL"
  531. case .quotaExceeded:
  532. return "ERROR_QUOTA_EXCEEDED"
  533. case .missingAppToken:
  534. return "ERROR_MISSING_APP_TOKEN"
  535. case .notificationNotForwarded:
  536. return "ERROR_NOTIFICATION_NOT_FORWARDED"
  537. case .appNotVerified:
  538. return "ERROR_APP_NOT_VERIFIED"
  539. case .captchaCheckFailed:
  540. return "ERROR_CAPTCHA_CHECK_FAILED"
  541. case .webContextAlreadyPresented:
  542. return "ERROR_WEB_CONTEXT_ALREADY_PRESENTED"
  543. case .webContextCancelled:
  544. return "ERROR_WEB_CONTEXT_CANCELLED"
  545. case .invalidClientID:
  546. return "ERROR_INVALID_CLIENT_ID"
  547. case .appVerificationUserInteractionFailure:
  548. return "ERROR_APP_VERIFICATION_FAILED"
  549. case .webNetworkRequestFailed:
  550. return "ERROR_WEB_NETWORK_REQUEST_FAILED"
  551. case .nullUser:
  552. return "ERROR_NULL_USER"
  553. case .invalidProviderID:
  554. return "ERROR_INVALID_PROVIDER_ID"
  555. case .invalidDynamicLinkDomain:
  556. return "ERROR_INVALID_DYNAMIC_LINK_DOMAIN"
  557. case .webInternalError:
  558. return "ERROR_WEB_INTERNAL_ERROR"
  559. case .webSignInUserInteractionFailure:
  560. return "ERROR_WEB_USER_INTERACTION_FAILURE"
  561. case .malformedJWT:
  562. return "ERROR_MALFORMED_JWT"
  563. case .localPlayerNotAuthenticated:
  564. return "ERROR_LOCAL_PLAYER_NOT_AUTHENTICATED"
  565. case .gameKitNotLinked:
  566. return "ERROR_GAME_KIT_NOT_LINKED"
  567. case .secondFactorRequired:
  568. return "ERROR_SECOND_FACTOR_REQUIRED"
  569. case .missingMultiFactorSession:
  570. return "ERROR_MISSING_MULTI_FACTOR_SESSION"
  571. case .missingMultiFactorInfo:
  572. return "ERROR_MISSING_MULTI_FACTOR_INFO"
  573. case .invalidMultiFactorSession:
  574. return "ERROR_INVALID_MULTI_FACTOR_SESSION"
  575. case .multiFactorInfoNotFound:
  576. return "ERROR_MULTI_FACTOR_INFO_NOT_FOUND"
  577. case .adminRestrictedOperation:
  578. return "ERROR_ADMIN_RESTRICTED_OPERATION"
  579. case .unverifiedEmail:
  580. return "ERROR_UNVERIFIED_EMAIL"
  581. case .secondFactorAlreadyEnrolled:
  582. return "ERROR_SECOND_FACTOR_ALREADY_ENROLLED"
  583. case .maximumSecondFactorCountExceeded:
  584. return "ERROR_MAXIMUM_SECOND_FACTOR_COUNT_EXCEEDED"
  585. case .unsupportedFirstFactor:
  586. return "ERROR_UNSUPPORTED_FIRST_FACTOR"
  587. case .emailChangeNeedsVerification:
  588. return "ERROR_EMAIL_CHANGE_NEEDS_VERIFICATION"
  589. case .dynamicLinkNotActivated:
  590. return "ERROR_DYNAMIC_LINK_NOT_ACTIVATED"
  591. case .rejectedCredential:
  592. return "ERROR_REJECTED_CREDENTIAL"
  593. case .missingOrInvalidNonce:
  594. return "ERROR_MISSING_OR_INVALID_NONCE"
  595. case .tenantIDMismatch:
  596. return "ERROR_TENANT_ID_MISMATCH"
  597. case .unsupportedTenantOperation:
  598. return "ERROR_UNSUPPORTED_TENANT_OPERATION"
  599. case .blockingCloudFunctionError:
  600. return "ERROR_BLOCKING_CLOUD_FUNCTION_RETURNED_ERROR"
  601. case .recaptchaNotEnabled:
  602. return "ERROR_RECAPTCHA_NOT_ENABLED"
  603. case .missingRecaptchaToken:
  604. return "ERROR_MISSING_RECAPTCHA_TOKEN"
  605. case .invalidRecaptchaToken:
  606. return "ERROR_INVALID_RECAPTCHA_TOKEN"
  607. case .invalidRecaptchaAction:
  608. return "ERROR_INVALID_RECAPTCHA_ACTION"
  609. case .missingClientType:
  610. return "ERROR_MISSING_CLIENT_TYPE"
  611. case .missingRecaptchaVersion:
  612. return "ERROR_MISSING_RECAPTCHA_VERSION"
  613. case .invalidRecaptchaVersion:
  614. return "ERROR_INVALID_RECAPTCHA_VERSION"
  615. case .invalidReqType:
  616. return "ERROR_INVALID_REQ_TYPE"
  617. case .recaptchaSDKNotLinked:
  618. return "ERROR_RECAPTCHA_SDK_NOT_LINKED"
  619. case .recaptchaSiteKeyMissing:
  620. return "ERROR_RECAPTCHA_SITE_KEY_MISSING"
  621. case .recaptchaActionCreationFailed:
  622. return "ERROR_RECAPTCHA_ACTION_CREATION_FAILED"
  623. }
  624. }
  625. }
  626. // MARK: - Standard Error Messages
  627. private let kErrorInvalidCustomToken =
  628. "The custom token format is incorrect. Please check the documentation."
  629. private let kErrorCustomTokenMismatch =
  630. "The custom token corresponds to a different audience."
  631. private let kErrorInvalidEmail = "The email address is badly formatted."
  632. private let kErrorInvalidCredential =
  633. "The supplied auth credential is malformed or has expired."
  634. private let kErrorUserDisabled =
  635. "The user account has been disabled by an administrator."
  636. private let kErrorEmailAlreadyInUse =
  637. "The email address is already in use by another account."
  638. private let kErrorWrongPassword =
  639. "The password is invalid or the user does not have a password."
  640. private let kErrorTooManyRequests =
  641. "We have blocked all requests from this device due to unusual activity. Try again later."
  642. private let kErrorAccountExistsWithDifferentCredential =
  643. "An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address."
  644. private let kErrorRequiresRecentLogin =
  645. "This operation is sensitive and requires recent authentication. Log in again before retrying this request."
  646. private let kErrorProviderAlreadyLinked =
  647. "[ERROR_PROVIDER_ALREADY_LINKED] - User can only be linked to one identity for the given provider."
  648. private let kErrorNoSuchProvider =
  649. "User was not linked to an account with the given provider."
  650. private let kErrorInvalidUserToken =
  651. "This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user doesn’t belong to the project associated with the API key used in your request."
  652. private let kErrorNetworkError =
  653. "Network error (such as timeout, interrupted connection or unreachable host) has occurred."
  654. private let kErrorKeychainError =
  655. "An error occurred when accessing the keychain. The NSLocalizedFailureReasonErrorKey field in the NSError.userInfo dictionary will contain more information about the error encountered"
  656. private let kErrorUserTokenExpired =
  657. "The user's credential is no longer valid. The user must sign in again."
  658. private let kErrorUserNotFound =
  659. "There is no user record corresponding to this identifier. The user may have been deleted."
  660. private let kErrorInvalidAPIKey = "An invalid API Key was supplied in the request."
  661. private let FIRAuthErrorMessageUserMismatch =
  662. "The supplied credentials do not correspond to the previously signed in user."
  663. private let kErrorCredentialAlreadyInUse =
  664. "This credential is already associated with a different user account."
  665. private let kErrorOperationNotAllowed =
  666. "The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section."
  667. private let kErrorWeakPassword = "The password must be 6 characters long or more."
  668. private let kErrorAppNotAuthorized =
  669. "This app is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console and ensure that it accepts requests from your app's bundle ID."
  670. private let kErrorExpiredActionCode = "The action code has expired."
  671. private let kErrorInvalidActionCode =
  672. "The action code is invalid. This can happen if the code is malformed, expired, or has already been used."
  673. private let kErrorInvalidMessagePayload =
  674. "The action code is invalid. This can happen if the code is malformed, expired, or has already been used."
  675. private let kErrorInvalidSender =
  676. "The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console."
  677. private let kErrorInvalidRecipientEmail =
  678. "The action code is invalid. This can happen if the code is malformed, expired, or has already been used."
  679. private let kErrorMissingIosBundleID =
  680. "An iOS Bundle ID must be provided if an App Store ID is provided."
  681. private let kErrorMissingAndroidPackageName =
  682. "An Android Package Name must be provided if the Android App is required to be installed."
  683. private let kErrorUnauthorizedDomain =
  684. "The domain of the continue URL is not allowlisted. Please allowlist the domain in the Firebase console."
  685. private let kErrorInvalidContinueURI =
  686. "The continue URL provided in the request is invalid."
  687. private let kErrorMissingEmail = "An email address must be provided."
  688. private let kErrorMissingContinueURI =
  689. "A continue URL must be provided in the request."
  690. private let kErrorMissingPhoneNumber =
  691. "To send verification codes, provide a phone number for the recipient."
  692. private let kErrorInvalidPhoneNumber =
  693. "The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code]."
  694. private let kErrorMissingVerificationCode =
  695. "The phone auth credential was created with an empty SMS verification Code."
  696. private let kErrorInvalidVerificationCode =
  697. "The multifactor verification code used to create the auth credential is invalid. " +
  698. "Re-collect the verification code and be sure to use the verification code provided by the user."
  699. private let kErrorMissingVerificationID =
  700. "The phone auth credential was created with an empty verification ID."
  701. private let kErrorInvalidVerificationID =
  702. "The verification ID used to create the phone auth credential is invalid."
  703. private let kErrorLocalPlayerNotAuthenticated =
  704. "The local player is not authenticated. Please log the local player in to Game Center."
  705. private let kErrorGameKitNotLinked =
  706. "The GameKit framework is not linked. Please turn on the Game Center capability."
  707. private let kErrorSessionExpired =
  708. "The SMS code has expired. Please re-send the verification code to try again."
  709. private let kErrorMissingAppCredential =
  710. "The phone verification request is missing an APNs Device token. Firebase Auth automatically detects APNs Device Tokens, however, if method swizzling is disabled, the APNs token must be set via the APNSToken property on FIRAuth or by calling setAPNSToken:type on FIRAuth."
  711. private let kErrorInvalidAppCredential =
  712. "The APNs device token provided is either incorrect or does not match the private certificate uploaded to the Firebase Console."
  713. private let kErrorQuotaExceeded = "The quota for this operation has been exceeded."
  714. private let kErrorMissingAppToken =
  715. "There seems to be a problem with your project's Firebase phone number authentication set-up, please make sure to follow the instructions found at https://firebase.google.com/docs/auth/ios/phone-auth"
  716. private let kErrorNotificationNotForwarded =
  717. "If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to" +
  718. "be forwarded to FirebaseAuth's canHandleNotification method."
  719. private let kErrorAppNotVerified =
  720. "Firebase could not retrieve the silent push notification and therefore could not verify your app. Ensure that you configured your app correctly to receive push notifications."
  721. private let kErrorCaptchaCheckFailed =
  722. "The reCAPTCHA response token provided is either invalid, expired or already"
  723. private let kErrorWebContextAlreadyPresented =
  724. "User interaction is still ongoing, another view cannot be presented."
  725. private let kErrorWebContextCancelled = "The interaction was cancelled by the user."
  726. private let kErrorInvalidClientID =
  727. "The OAuth client ID provided is either invalid or does not match the specified API key."
  728. private let kErrorWebRequestFailed =
  729. "A network error (such as timeout, interrupted connection, or unreachable host) has occurred within the web context."
  730. private let kErrorWebInternalError =
  731. "An internal error has occurred within the SFSafariViewController or WKWebView."
  732. private let kErrorAppVerificationUserInteractionFailure =
  733. "The app verification process has failed, print and inspect the error details for more information"
  734. private let kErrorNullUser =
  735. "A null user object was provided as the argument for an operation which requires a non-null user object."
  736. private let kErrorInvalidProviderID =
  737. "The provider ID provided for the attempted web operation is invalid."
  738. private let kErrorInvalidDynamicLinkDomain =
  739. "The Firebase Dynamic Link domain used is either not configured or is unauthorized for the current project."
  740. private let kErrorInternalError =
  741. "An internal error has occurred, print and inspect the error details for more information."
  742. private let kErrorMalformedJWT =
  743. "Failed to parse JWT. Check the userInfo dictionary for the full token."
  744. private let kErrorSecondFactorRequired =
  745. "Please complete a second factor challenge to finish signing into this account."
  746. private let FIRAuthErrorMessageMissingMultiFactorSession =
  747. "The request is missing proof of first factor successful sign-in."
  748. private let FIRAuthErrorMessageMissingMultiFactorInfo =
  749. "No second factor identifier is provided."
  750. private let FIRAuthErrorMessageInvalidMultiFactorSession =
  751. "The request does not contain a valid proof of first factor successful sign-in."
  752. private let FIRAuthErrorMessageMultiFactorInfoNotFound =
  753. "The user does not have a second factor matching the identifier provided."
  754. private let FIRAuthErrorMessageAdminRestrictedOperation =
  755. "This operation is restricted to administrators only."
  756. private let FIRAuthErrorMessageUnverifiedEmail =
  757. "The operation requires a verified email."
  758. private let FIRAuthErrorMessageSecondFactorAlreadyEnrolled =
  759. "The second factor is already enrolled on this account."
  760. private let FIRAuthErrorMessageMaximumSecondFactorCountExceeded =
  761. "The maximum allowed number of second factors on a user has been exceeded."
  762. private let FIRAuthErrorMessageUnsupportedFirstFactor =
  763. "Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor."
  764. private let FIRAuthErrorMessageEmailChangeNeedsVerification =
  765. "Multi-factor users must always have a verified email."
  766. private let kErrorDynamicLinkNotActivated =
  767. "Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions."
  768. private let kErrorRejectedCredential =
  769. "The request contains malformed or mismatching credentials."
  770. private let kErrorMissingClientIdentifier =
  771. "The request does not contain a client identifier."
  772. private let kErrorMissingOrInvalidNonce =
  773. "The request contains malformed or mismatched credentials."
  774. private let kErrorTenantIDMismatch =
  775. "The provided user's tenant ID does not match the Auth instance's tenant ID."
  776. private let kErrorUnsupportedTenantOperation =
  777. "This operation is not supported in a multi-tenant context."
  778. private let kErrorBlockingCloudFunctionReturnedError =
  779. "Blocking cloud function returned an error."
  780. private let kErrorRecaptchaNotEnabled =
  781. "reCAPTCHA Enterprise is not enabled for this project."
  782. private let kErrorMissingRecaptchaToken =
  783. "The backend request is missing the reCAPTCHA verification token."
  784. private let kErrorInvalidRecaptchaToken =
  785. "The reCAPTCHA verification token is invalid or has expired."
  786. private let kErrorInvalidRecaptchaAction =
  787. "The reCAPTCHA verification failed due to an invalid action."
  788. private let kErrorMissingClientType =
  789. "The request is missing a client type or the client type is invalid."
  790. private let kErrorMissingRecaptchaVersion =
  791. "The request is missing the reCAPTCHA version parameter."
  792. private let kErrorInvalidRecaptchaVersion =
  793. "The request specifies an invalid version of reCAPTCHA."
  794. private let kErrorInvalidReqType =
  795. "The request is not supported or is invalid."
  796. // TODO(chuanr, ObjC): point the link to GCIP doc once available.
  797. private let kErrorRecaptchaSDKNotLinked =
  798. "The reCAPTCHA SDK is not linked to your app. See " +
  799. "https://cloud.google.com/recaptcha-enterprise/docs/instrument-ios-apps"
  800. private let kErrorSiteKeyMissing =
  801. "The reCAPTCHA SDK site key wasn't found. See " +
  802. "https://cloud.google.com/recaptcha-enterprise/docs/instrument-ios-apps"
  803. private let kErrorRecaptchaActionCreationFailed =
  804. "The reCAPTCHA SDK action class failed to initialize. See " +
  805. "https://cloud.google.com/recaptcha-enterprise/docs/instrument-ios-apps"