Skip to content

[Auth] Add exported const map for error codes #5182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions common/api-review/auth-exp.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,105 @@ export interface AuthError extends FirebaseError {
readonly tenantid?: string;
}

// @public
export const AuthErrorCodes: {
readonly ADMIN_ONLY_OPERATION: "auth/admin-restricted-operation";
readonly ARGUMENT_ERROR: "auth/argument-error";
readonly APP_NOT_AUTHORIZED: "auth/app-not-authorized";
readonly APP_NOT_INSTALLED: "auth/app-not-installed";
readonly CAPTCHA_CHECK_FAILED: "auth/captcha-check-failed";
readonly CODE_EXPIRED: "auth/code-expired";
readonly CORDOVA_NOT_READY: "auth/cordova-not-ready";
readonly CORS_UNSUPPORTED: "auth/cors-unsupported";
readonly CREDENTIAL_ALREADY_IN_USE: "auth/credential-already-in-use";
readonly CREDENTIAL_MISMATCH: "auth/custom-token-mismatch";
readonly CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "auth/requires-recent-login";
readonly DEPENDENT_SDK_INIT_BEFORE_AUTH: "auth/dependent-sdk-initialized-before-auth";
readonly DYNAMIC_LINK_NOT_ACTIVATED: "auth/dynamic-link-not-activated";
readonly EMAIL_CHANGE_NEEDS_VERIFICATION: "auth/email-change-needs-verification";
readonly EMAIL_EXISTS: "auth/email-already-in-use";
readonly EMULATOR_CONFIG_FAILED: "auth/emulator-config-failed";
readonly EXPIRED_OOB_CODE: "auth/expired-action-code";
readonly EXPIRED_POPUP_REQUEST: "auth/cancelled-popup-request";
readonly INTERNAL_ERROR: "auth/internal-error";
readonly INVALID_API_KEY: "auth/invalid-api-key";
readonly INVALID_APP_CREDENTIAL: "auth/invalid-app-credential";
readonly INVALID_APP_ID: "auth/invalid-app-id";
readonly INVALID_AUTH: "auth/invalid-user-token";
readonly INVALID_AUTH_EVENT: "auth/invalid-auth-event";
readonly INVALID_CERT_HASH: "auth/invalid-cert-hash";
readonly INVALID_CODE: "auth/invalid-verification-code";
readonly INVALID_CONTINUE_URI: "auth/invalid-continue-uri";
readonly INVALID_CORDOVA_CONFIGURATION: "auth/invalid-cordova-configuration";
readonly INVALID_CUSTOM_TOKEN: "auth/invalid-custom-token";
readonly INVALID_DYNAMIC_LINK_DOMAIN: "auth/invalid-dynamic-link-domain";
readonly INVALID_EMAIL: "auth/invalid-email";
readonly INVALID_EMULATOR_SCHEME: "auth/invalid-emulator-scheme";
readonly INVALID_IDP_RESPONSE: "auth/invalid-credential";
readonly INVALID_MESSAGE_PAYLOAD: "auth/invalid-message-payload";
readonly INVALID_MFA_SESSION: "auth/invalid-multi-factor-session";
readonly INVALID_OAUTH_CLIENT_ID: "auth/invalid-oauth-client-id";
readonly INVALID_OAUTH_PROVIDER: "auth/invalid-oauth-provider";
readonly INVALID_OOB_CODE: "auth/invalid-action-code";
readonly INVALID_ORIGIN: "auth/unauthorized-domain";
readonly INVALID_PASSWORD: "auth/wrong-password";
readonly INVALID_PERSISTENCE: "auth/invalid-persistence-type";
readonly INVALID_PHONE_NUMBER: "auth/invalid-phone-number";
readonly INVALID_PROVIDER_ID: "auth/invalid-provider-id";
readonly INVALID_RECIPIENT_EMAIL: "auth/invalid-recipient-email";
readonly INVALID_SENDER: "auth/invalid-sender";
readonly INVALID_SESSION_INFO: "auth/invalid-verification-id";
readonly INVALID_TENANT_ID: "auth/invalid-tenant-id";
readonly MFA_INFO_NOT_FOUND: "auth/multi-factor-info-not-found";
readonly MFA_REQUIRED: "auth/multi-factor-auth-required";
readonly MISSING_ANDROID_PACKAGE_NAME: "auth/missing-android-pkg-name";
readonly MISSING_APP_CREDENTIAL: "auth/missing-app-credential";
readonly MISSING_AUTH_DOMAIN: "auth/auth-domain-config-required";
readonly MISSING_CODE: "auth/missing-verification-code";
readonly MISSING_CONTINUE_URI: "auth/missing-continue-uri";
readonly MISSING_IFRAME_START: "auth/missing-iframe-start";
readonly MISSING_IOS_BUNDLE_ID: "auth/missing-ios-bundle-id";
readonly MISSING_OR_INVALID_NONCE: "auth/missing-or-invalid-nonce";
readonly MISSING_MFA_INFO: "auth/missing-multi-factor-info";
readonly MISSING_MFA_SESSION: "auth/missing-multi-factor-session";
readonly MISSING_PHONE_NUMBER: "auth/missing-phone-number";
readonly MISSING_SESSION_INFO: "auth/missing-verification-id";
readonly MODULE_DESTROYED: "auth/app-deleted";
readonly NEED_CONFIRMATION: "auth/account-exists-with-different-credential";
readonly NETWORK_REQUEST_FAILED: "auth/network-request-failed";
readonly NULL_USER: "auth/null-user";
readonly NO_AUTH_EVENT: "auth/no-auth-event";
readonly NO_SUCH_PROVIDER: "auth/no-such-provider";
readonly OPERATION_NOT_ALLOWED: "auth/operation-not-allowed";
readonly OPERATION_NOT_SUPPORTED: "auth/operation-not-supported-in-this-environment";
readonly POPUP_BLOCKED: "auth/popup-blocked";
readonly POPUP_CLOSED_BY_USER: "auth/popup-closed-by-user";
readonly PROVIDER_ALREADY_LINKED: "auth/provider-already-linked";
readonly QUOTA_EXCEEDED: "auth/quota-exceeded";
readonly REDIRECT_CANCELLED_BY_USER: "auth/redirect-cancelled-by-user";
readonly REDIRECT_OPERATION_PENDING: "auth/redirect-operation-pending";
readonly REJECTED_CREDENTIAL: "auth/rejected-credential";
readonly SECOND_FACTOR_ALREADY_ENROLLED: "auth/second-factor-already-in-use";
readonly SECOND_FACTOR_LIMIT_EXCEEDED: "auth/maximum-second-factor-count-exceeded";
readonly TENANT_ID_MISMATCH: "auth/tenant-id-mismatch";
readonly TIMEOUT: "auth/timeout";
readonly TOKEN_EXPIRED: "auth/user-token-expired";
readonly TOO_MANY_ATTEMPTS_TRY_LATER: "auth/too-many-requests";
readonly UNAUTHORIZED_DOMAIN: "auth/unauthorized-continue-uri";
readonly UNSUPPORTED_FIRST_FACTOR: "auth/unsupported-first-factor";
readonly UNSUPPORTED_PERSISTENCE: "auth/unsupported-persistence-type";
readonly UNSUPPORTED_TENANT_OPERATION: "auth/unsupported-tenant-operation";
readonly UNVERIFIED_EMAIL: "auth/unverified-email";
readonly USER_CANCELLED: "auth/user-cancelled";
readonly USER_DELETED: "auth/user-not-found";
readonly USER_DISABLED: "auth/user-disabled";
readonly USER_MISMATCH: "auth/user-mismatch";
readonly USER_SIGNED_OUT: "auth/user-signed-out";
readonly WEAK_PASSWORD: "auth/weak-password";
readonly WEB_STORAGE_UNSUPPORTED: "auth/web-storage-unsupported";
readonly ALREADY_INITIALIZED: "auth/already-initialized";
};

// @public
export interface AuthErrorMap {
}
Expand Down
111 changes: 109 additions & 2 deletions packages-exp/auth-exp/src/core/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import { AuthCredential } from './credentials';

/**
* Enumeration of Firebase Auth error codes.
*
* @public
*/
export const enum AuthErrorCode {
ADMIN_ONLY_OPERATION = 'admin-restricted-operation',
Expand Down Expand Up @@ -433,3 +431,112 @@ export const _DEFAULT_AUTH_ERROR_FACTORY = new ErrorFactory<
AuthErrorCode,
AuthErrorParams
>('auth', 'Firebase', _prodErrorMap());

/**
* A map of potential Auth error codes, for easier comparison with errors
* thrown by the SDK.
*
* @remarks
* Please note that you can't tree-shake individual keys
* in the map, so by using the map you might substantially increase your
* bundle size.
*
* @public
*/
export const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY = {
ADMIN_ONLY_OPERATION: 'auth/admin-restricted-operation',
ARGUMENT_ERROR: 'auth/argument-error',
APP_NOT_AUTHORIZED: 'auth/app-not-authorized',
APP_NOT_INSTALLED: 'auth/app-not-installed',
CAPTCHA_CHECK_FAILED: 'auth/captcha-check-failed',
CODE_EXPIRED: 'auth/code-expired',
CORDOVA_NOT_READY: 'auth/cordova-not-ready',
CORS_UNSUPPORTED: 'auth/cors-unsupported',
CREDENTIAL_ALREADY_IN_USE: 'auth/credential-already-in-use',
CREDENTIAL_MISMATCH: 'auth/custom-token-mismatch',
CREDENTIAL_TOO_OLD_LOGIN_AGAIN: 'auth/requires-recent-login',
DEPENDENT_SDK_INIT_BEFORE_AUTH: 'auth/dependent-sdk-initialized-before-auth',
DYNAMIC_LINK_NOT_ACTIVATED: 'auth/dynamic-link-not-activated',
EMAIL_CHANGE_NEEDS_VERIFICATION: 'auth/email-change-needs-verification',
EMAIL_EXISTS: 'auth/email-already-in-use',
EMULATOR_CONFIG_FAILED: 'auth/emulator-config-failed',
EXPIRED_OOB_CODE: 'auth/expired-action-code',
EXPIRED_POPUP_REQUEST: 'auth/cancelled-popup-request',
INTERNAL_ERROR: 'auth/internal-error',
INVALID_API_KEY: 'auth/invalid-api-key',
INVALID_APP_CREDENTIAL: 'auth/invalid-app-credential',
INVALID_APP_ID: 'auth/invalid-app-id',
INVALID_AUTH: 'auth/invalid-user-token',
INVALID_AUTH_EVENT: 'auth/invalid-auth-event',
INVALID_CERT_HASH: 'auth/invalid-cert-hash',
INVALID_CODE: 'auth/invalid-verification-code',
INVALID_CONTINUE_URI: 'auth/invalid-continue-uri',
INVALID_CORDOVA_CONFIGURATION: 'auth/invalid-cordova-configuration',
INVALID_CUSTOM_TOKEN: 'auth/invalid-custom-token',
INVALID_DYNAMIC_LINK_DOMAIN: 'auth/invalid-dynamic-link-domain',
INVALID_EMAIL: 'auth/invalid-email',
INVALID_EMULATOR_SCHEME: 'auth/invalid-emulator-scheme',
INVALID_IDP_RESPONSE: 'auth/invalid-credential',
INVALID_MESSAGE_PAYLOAD: 'auth/invalid-message-payload',
INVALID_MFA_SESSION: 'auth/invalid-multi-factor-session',
INVALID_OAUTH_CLIENT_ID: 'auth/invalid-oauth-client-id',
INVALID_OAUTH_PROVIDER: 'auth/invalid-oauth-provider',
INVALID_OOB_CODE: 'auth/invalid-action-code',
INVALID_ORIGIN: 'auth/unauthorized-domain',
INVALID_PASSWORD: 'auth/wrong-password',
INVALID_PERSISTENCE: 'auth/invalid-persistence-type',
INVALID_PHONE_NUMBER: 'auth/invalid-phone-number',
INVALID_PROVIDER_ID: 'auth/invalid-provider-id',
INVALID_RECIPIENT_EMAIL: 'auth/invalid-recipient-email',
INVALID_SENDER: 'auth/invalid-sender',
INVALID_SESSION_INFO: 'auth/invalid-verification-id',
INVALID_TENANT_ID: 'auth/invalid-tenant-id',
MFA_INFO_NOT_FOUND: 'auth/multi-factor-info-not-found',
MFA_REQUIRED: 'auth/multi-factor-auth-required',
MISSING_ANDROID_PACKAGE_NAME: 'auth/missing-android-pkg-name',
MISSING_APP_CREDENTIAL: 'auth/missing-app-credential',
MISSING_AUTH_DOMAIN: 'auth/auth-domain-config-required',
MISSING_CODE: 'auth/missing-verification-code',
MISSING_CONTINUE_URI: 'auth/missing-continue-uri',
MISSING_IFRAME_START: 'auth/missing-iframe-start',
MISSING_IOS_BUNDLE_ID: 'auth/missing-ios-bundle-id',
MISSING_OR_INVALID_NONCE: 'auth/missing-or-invalid-nonce',
MISSING_MFA_INFO: 'auth/missing-multi-factor-info',
MISSING_MFA_SESSION: 'auth/missing-multi-factor-session',
MISSING_PHONE_NUMBER: 'auth/missing-phone-number',
MISSING_SESSION_INFO: 'auth/missing-verification-id',
MODULE_DESTROYED: 'auth/app-deleted',
NEED_CONFIRMATION: 'auth/account-exists-with-different-credential',
NETWORK_REQUEST_FAILED: 'auth/network-request-failed',
NULL_USER: 'auth/null-user',
NO_AUTH_EVENT: 'auth/no-auth-event',
NO_SUCH_PROVIDER: 'auth/no-such-provider',
OPERATION_NOT_ALLOWED: 'auth/operation-not-allowed',
OPERATION_NOT_SUPPORTED: 'auth/operation-not-supported-in-this-environment',
POPUP_BLOCKED: 'auth/popup-blocked',
POPUP_CLOSED_BY_USER: 'auth/popup-closed-by-user',
PROVIDER_ALREADY_LINKED: 'auth/provider-already-linked',
QUOTA_EXCEEDED: 'auth/quota-exceeded',
REDIRECT_CANCELLED_BY_USER: 'auth/redirect-cancelled-by-user',
REDIRECT_OPERATION_PENDING: 'auth/redirect-operation-pending',
REJECTED_CREDENTIAL: 'auth/rejected-credential',
SECOND_FACTOR_ALREADY_ENROLLED: 'auth/second-factor-already-in-use',
SECOND_FACTOR_LIMIT_EXCEEDED: 'auth/maximum-second-factor-count-exceeded',
TENANT_ID_MISMATCH: 'auth/tenant-id-mismatch',
TIMEOUT: 'auth/timeout',
TOKEN_EXPIRED: 'auth/user-token-expired',
TOO_MANY_ATTEMPTS_TRY_LATER: 'auth/too-many-requests',
UNAUTHORIZED_DOMAIN: 'auth/unauthorized-continue-uri',
UNSUPPORTED_FIRST_FACTOR: 'auth/unsupported-first-factor',
UNSUPPORTED_PERSISTENCE: 'auth/unsupported-persistence-type',
UNSUPPORTED_TENANT_OPERATION: 'auth/unsupported-tenant-operation',
UNVERIFIED_EMAIL: 'auth/unverified-email',
USER_CANCELLED: 'auth/user-cancelled',
USER_DELETED: 'auth/user-not-found',
USER_DISABLED: 'auth/user-disabled',
USER_MISMATCH: 'auth/user-mismatch',
USER_SIGNED_OUT: 'auth/user-signed-out',
WEAK_PASSWORD: 'auth/weak-password',
WEB_STORAGE_UNSUPPORTED: 'auth/web-storage-unsupported',
ALREADY_INITIALIZED: 'auth/already-initialized'
} as const;
6 changes: 5 additions & 1 deletion packages-exp/auth-exp/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import {
Unsubscribe
} from '../model/public_types';

export { debugErrorMap, prodErrorMap } from './errors';
export {
debugErrorMap,
prodErrorMap,
AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as AuthErrorCodes
} from './errors';

// Non-optional auth methods.
/**
Expand Down