|
15 | 15 | * limitations under the License. |
16 | 16 | */ |
17 | 17 |
|
18 | | -import { AuthErrorMap, User } from '../model/public_types'; |
19 | | -import { ErrorFactory, ErrorMap } from '@firebase/util'; |
20 | | - |
| 18 | +import { AuthErrorMap, User, ConfirmationResult } from '../model/public_types'; |
| 19 | +import { ErrorFactory, ErrorMap, FirebaseError } from '@firebase/util'; |
21 | 20 | import { IdTokenMfaResponse } from '../api/authentication/mfa'; |
22 | 21 | import { AppName } from '../model/auth'; |
23 | 22 | import { AuthCredential } from './credentials'; |
@@ -133,6 +132,7 @@ export const enum AuthErrorCode { |
133 | 132 | MISSING_RECAPTCHA_VERSION = 'missing-recaptcha-version', |
134 | 133 | INVALID_RECAPTCHA_VERSION = 'invalid-recaptcha-version', |
135 | 134 | INVALID_REQ_TYPE = 'invalid-req-type', |
| 135 | + WEB_OTP_NOT_RETRIEVED = 'web-otp-not-retrieved', |
136 | 136 | UNSUPPORTED_PASSWORD_POLICY_SCHEMA_VERSION = 'unsupported-password-policy-schema-version', |
137 | 137 | PASSWORD_DOES_NOT_MEET_REQUIREMENTS = 'password-does-not-meet-requirements' |
138 | 138 | } |
@@ -383,7 +383,18 @@ function _debugErrorMap(): ErrorMap<AuthErrorCode> { |
383 | 383 | 'The reCAPTCHA version is missing when sending request to the backend.', |
384 | 384 | [AuthErrorCode.INVALID_REQ_TYPE]: 'Invalid request parameters.', |
385 | 385 | [AuthErrorCode.INVALID_RECAPTCHA_VERSION]: |
386 | | - 'The reCAPTCHA version is invalid when sending request to the backend.', |
| 386 | + 'The reCAPTCHA version sent to the backend is invalid.', |
| 387 | + [AuthErrorCode.WEB_OTP_NOT_RETRIEVED]: |
| 388 | + 'Web OTP code is not retrieved successfully', |
| 389 | + /** |
| 390 | + * This is the default error message. |
| 391 | + * This message is customized to one of the following depending on the type of error: |
| 392 | + * `Web OTP code is not fetched before timeout` |
| 393 | + * `The auto-retrieved credential or code is not defined` |
| 394 | + * `Web OTP get method failed to retrieve the code` |
| 395 | + * `Web OTP code received is incorrect` |
| 396 | + * `Web OTP is not supported` |
| 397 | + */ |
387 | 398 | [AuthErrorCode.UNSUPPORTED_PASSWORD_POLICY_SCHEMA_VERSION]: |
388 | 399 | 'The password policy received from the backend uses a schema version that is not supported by this version of the Firebase SDK.', |
389 | 400 | [AuthErrorCode.PASSWORD_DOES_NOT_MEET_REQUIREMENTS]: |
@@ -434,6 +445,10 @@ export interface NamedErrorParams { |
434 | 445 | user?: User; |
435 | 446 | _serverResponse?: object; |
436 | 447 | } |
| 448 | +export interface WebOTPError extends FirebaseError { |
| 449 | + code: AuthErrorCode.WEB_OTP_NOT_RETRIEVED; |
| 450 | + confirmationResult: ConfirmationResult; // Standard ConfirmationResult; for fallback |
| 451 | +} |
437 | 452 |
|
438 | 453 | /** |
439 | 454 | * @internal |
@@ -597,5 +612,6 @@ export const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = { |
597 | 612 | MISSING_CLIENT_TYPE: 'auth/missing-client-type', |
598 | 613 | MISSING_RECAPTCHA_VERSION: 'auth/missing-recaptcha-version', |
599 | 614 | INVALID_RECAPTCHA_VERSION: 'auth/invalid-recaptcha-version', |
600 | | - INVALID_REQ_TYPE: 'auth/invalid-req-type' |
| 615 | + INVALID_REQ_TYPE: 'auth/invalid-req-type', |
| 616 | + WEB_OTP_NOT_RETRIEVED: 'auth/web-otp-not-retrieved' |
601 | 617 | } as const; |
0 commit comments