Skip to content
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

FR: Access to fireauth.authenum.Error #2599

Open
Alynva opened this issue Feb 6, 2020 · 0 comments
Open

FR: Access to fireauth.authenum.Error #2599

Alynva opened this issue Feb 6, 2020 · 0 comments

Comments

@Alynva
Copy link

Alynva commented Feb 6, 2020

[REQUIRED] Describe your environment

  • Operating System version: Windows 8.1
  • Browser version: Chrome v79
  • Firebase SDK version: v7.7.0
  • Firebase Product: auth, but it's probably similar to others

[REQUIRED] Describe the problem

The docs here describes the Error and the AuthError objects from firebase.auth, but they are not actually exported from the library.

Steps to reproduce:

  • Import the firebase
  • Try to find the auth enum error, created here:

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

Relevant Code:

I'm handling the errors from Firebase Auth with something like this:

.catch(err => {
	switch (err.code) {
		case 'auth/too-many-requests':
			...
			break;
		default:
			...
	}
})

... but it would be better if I got something like this:

.catch(err => {
	switch (err.code) {
		case firebase.auth.AuthError.TOO_MANY_ATTEMPTS_TRY_LATER:
			...
			break;
		default:
			...
	}
})

I know that's much more code, but I don't need care about how the codes are and don't need to keep rereading the docs to see other error codes that can happen, I would just let the autocomplete do it's work. It's more about allow us to use this code design too...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants