UNPKG

14.6 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2020 Google LLC
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17import { AuthErrorMap, User } from '../model/public_types';
18import { ErrorFactory, ErrorMap } from '@firebase/util';
19import { IdTokenMfaResponse } from '../api/authentication/mfa';
20import { AppName } from '../model/auth';
21import { AuthCredential } from './credentials';
22/**
23 * Enumeration of Firebase Auth error codes.
24 *
25 * @internal
26 */
27export declare const enum AuthErrorCode {
28 ADMIN_ONLY_OPERATION = "admin-restricted-operation",
29 ARGUMENT_ERROR = "argument-error",
30 APP_NOT_AUTHORIZED = "app-not-authorized",
31 APP_NOT_INSTALLED = "app-not-installed",
32 CAPTCHA_CHECK_FAILED = "captcha-check-failed",
33 CODE_EXPIRED = "code-expired",
34 CORDOVA_NOT_READY = "cordova-not-ready",
35 CORS_UNSUPPORTED = "cors-unsupported",
36 CREDENTIAL_ALREADY_IN_USE = "credential-already-in-use",
37 CREDENTIAL_MISMATCH = "custom-token-mismatch",
38 CREDENTIAL_TOO_OLD_LOGIN_AGAIN = "requires-recent-login",
39 DEPENDENT_SDK_INIT_BEFORE_AUTH = "dependent-sdk-initialized-before-auth",
40 DYNAMIC_LINK_NOT_ACTIVATED = "dynamic-link-not-activated",
41 EMAIL_CHANGE_NEEDS_VERIFICATION = "email-change-needs-verification",
42 EMAIL_EXISTS = "email-already-in-use",
43 EMULATOR_CONFIG_FAILED = "emulator-config-failed",
44 EXPIRED_OOB_CODE = "expired-action-code",
45 EXPIRED_POPUP_REQUEST = "cancelled-popup-request",
46 INTERNAL_ERROR = "internal-error",
47 INVALID_API_KEY = "invalid-api-key",
48 INVALID_APP_CREDENTIAL = "invalid-app-credential",
49 INVALID_APP_ID = "invalid-app-id",
50 INVALID_AUTH = "invalid-user-token",
51 INVALID_AUTH_EVENT = "invalid-auth-event",
52 INVALID_CERT_HASH = "invalid-cert-hash",
53 INVALID_CODE = "invalid-verification-code",
54 INVALID_CONTINUE_URI = "invalid-continue-uri",
55 INVALID_CORDOVA_CONFIGURATION = "invalid-cordova-configuration",
56 INVALID_CUSTOM_TOKEN = "invalid-custom-token",
57 INVALID_DYNAMIC_LINK_DOMAIN = "invalid-dynamic-link-domain",
58 INVALID_EMAIL = "invalid-email",
59 INVALID_EMULATOR_SCHEME = "invalid-emulator-scheme",
60 INVALID_IDP_RESPONSE = "invalid-credential",
61 INVALID_MESSAGE_PAYLOAD = "invalid-message-payload",
62 INVALID_MFA_SESSION = "invalid-multi-factor-session",
63 INVALID_OAUTH_CLIENT_ID = "invalid-oauth-client-id",
64 INVALID_OAUTH_PROVIDER = "invalid-oauth-provider",
65 INVALID_OOB_CODE = "invalid-action-code",
66 INVALID_ORIGIN = "unauthorized-domain",
67 INVALID_PASSWORD = "wrong-password",
68 INVALID_PERSISTENCE = "invalid-persistence-type",
69 INVALID_PHONE_NUMBER = "invalid-phone-number",
70 INVALID_PROVIDER_ID = "invalid-provider-id",
71 INVALID_RECIPIENT_EMAIL = "invalid-recipient-email",
72 INVALID_SENDER = "invalid-sender",
73 INVALID_SESSION_INFO = "invalid-verification-id",
74 INVALID_TENANT_ID = "invalid-tenant-id",
75 LOGIN_BLOCKED = "login-blocked",
76 MFA_INFO_NOT_FOUND = "multi-factor-info-not-found",
77 MFA_REQUIRED = "multi-factor-auth-required",
78 MISSING_ANDROID_PACKAGE_NAME = "missing-android-pkg-name",
79 MISSING_APP_CREDENTIAL = "missing-app-credential",
80 MISSING_AUTH_DOMAIN = "auth-domain-config-required",
81 MISSING_CODE = "missing-verification-code",
82 MISSING_CONTINUE_URI = "missing-continue-uri",
83 MISSING_IFRAME_START = "missing-iframe-start",
84 MISSING_IOS_BUNDLE_ID = "missing-ios-bundle-id",
85 MISSING_OR_INVALID_NONCE = "missing-or-invalid-nonce",
86 MISSING_MFA_INFO = "missing-multi-factor-info",
87 MISSING_MFA_SESSION = "missing-multi-factor-session",
88 MISSING_PHONE_NUMBER = "missing-phone-number",
89 MISSING_SESSION_INFO = "missing-verification-id",
90 MODULE_DESTROYED = "app-deleted",
91 NEED_CONFIRMATION = "account-exists-with-different-credential",
92 NETWORK_REQUEST_FAILED = "network-request-failed",
93 NULL_USER = "null-user",
94 NO_AUTH_EVENT = "no-auth-event",
95 NO_SUCH_PROVIDER = "no-such-provider",
96 OPERATION_NOT_ALLOWED = "operation-not-allowed",
97 OPERATION_NOT_SUPPORTED = "operation-not-supported-in-this-environment",
98 POPUP_BLOCKED = "popup-blocked",
99 POPUP_CLOSED_BY_USER = "popup-closed-by-user",
100 PROVIDER_ALREADY_LINKED = "provider-already-linked",
101 QUOTA_EXCEEDED = "quota-exceeded",
102 REDIRECT_CANCELLED_BY_USER = "redirect-cancelled-by-user",
103 REDIRECT_OPERATION_PENDING = "redirect-operation-pending",
104 REJECTED_CREDENTIAL = "rejected-credential",
105 SECOND_FACTOR_ALREADY_ENROLLED = "second-factor-already-in-use",
106 SECOND_FACTOR_LIMIT_EXCEEDED = "maximum-second-factor-count-exceeded",
107 TENANT_ID_MISMATCH = "tenant-id-mismatch",
108 TIMEOUT = "timeout",
109 TOKEN_EXPIRED = "user-token-expired",
110 TOO_MANY_ATTEMPTS_TRY_LATER = "too-many-requests",
111 UNAUTHORIZED_DOMAIN = "unauthorized-continue-uri",
112 UNSUPPORTED_FIRST_FACTOR = "unsupported-first-factor",
113 UNSUPPORTED_PERSISTENCE = "unsupported-persistence-type",
114 UNSUPPORTED_TENANT_OPERATION = "unsupported-tenant-operation",
115 UNVERIFIED_EMAIL = "unverified-email",
116 USER_CANCELLED = "user-cancelled",
117 USER_DELETED = "user-not-found",
118 USER_DISABLED = "user-disabled",
119 USER_MISMATCH = "user-mismatch",
120 USER_SIGNED_OUT = "user-signed-out",
121 WEAK_PASSWORD = "weak-password",
122 WEB_STORAGE_UNSUPPORTED = "web-storage-unsupported",
123 ALREADY_INITIALIZED = "already-initialized"
124}
125export interface ErrorMapRetriever extends AuthErrorMap {
126 (): ErrorMap<AuthErrorCode>;
127}
128/**
129 * A verbose error map with detailed descriptions for most error codes.
130 *
131 * See discussion at {@link AuthErrorMap}
132 *
133 * @public
134 */
135export declare const debugErrorMap: AuthErrorMap;
136/**
137 * A minimal error map with all verbose error messages stripped.
138 *
139 * See discussion at {@link AuthErrorMap}
140 *
141 * @public
142 */
143export declare const prodErrorMap: AuthErrorMap;
144export interface NamedErrorParams {
145 appName: AppName;
146 credential?: AuthCredential;
147 email?: string;
148 phoneNumber?: string;
149 tenantId?: string;
150 user?: User;
151 _serverResponse?: object;
152}
153/**
154 * @internal
155 */
156declare type GenericAuthErrorParams = {
157 [key in Exclude<AuthErrorCode, AuthErrorCode.ARGUMENT_ERROR | AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH | AuthErrorCode.INTERNAL_ERROR | AuthErrorCode.MFA_REQUIRED | AuthErrorCode.NO_AUTH_EVENT | AuthErrorCode.OPERATION_NOT_SUPPORTED>]: {
158 appName?: AppName;
159 email?: string;
160 phoneNumber?: string;
161 message?: string;
162 };
163};
164/**
165 * @internal
166 */
167export interface AuthErrorParams extends GenericAuthErrorParams {
168 [AuthErrorCode.ARGUMENT_ERROR]: {
169 appName?: AppName;
170 };
171 [AuthErrorCode.DEPENDENT_SDK_INIT_BEFORE_AUTH]: {
172 appName?: AppName;
173 };
174 [AuthErrorCode.INTERNAL_ERROR]: {
175 appName?: AppName;
176 };
177 [AuthErrorCode.LOGIN_BLOCKED]: {
178 appName?: AppName;
179 originalMessage?: string;
180 };
181 [AuthErrorCode.OPERATION_NOT_SUPPORTED]: {
182 appName?: AppName;
183 };
184 [AuthErrorCode.NO_AUTH_EVENT]: {
185 appName?: AppName;
186 };
187 [AuthErrorCode.MFA_REQUIRED]: {
188 appName: AppName;
189 _serverResponse: IdTokenMfaResponse;
190 };
191 [AuthErrorCode.INVALID_CORDOVA_CONFIGURATION]: {
192 appName: AppName;
193 missingPlugin?: string;
194 };
195}
196export declare const _DEFAULT_AUTH_ERROR_FACTORY: ErrorFactory<AuthErrorCode, AuthErrorParams>;
197/**
198 * A map of potential `Auth` error codes, for easier comparison with errors
199 * thrown by the SDK.
200 *
201 * @remarks
202 * Note that you can't tree-shake individual keys
203 * in the map, so by using the map you might substantially increase your
204 * bundle size.
205 *
206 * @public
207 */
208export declare const AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY: {
209 readonly ADMIN_ONLY_OPERATION: "auth/admin-restricted-operation";
210 readonly ARGUMENT_ERROR: "auth/argument-error";
211 readonly APP_NOT_AUTHORIZED: "auth/app-not-authorized";
212 readonly APP_NOT_INSTALLED: "auth/app-not-installed";
213 readonly CAPTCHA_CHECK_FAILED: "auth/captcha-check-failed";
214 readonly CODE_EXPIRED: "auth/code-expired";
215 readonly CORDOVA_NOT_READY: "auth/cordova-not-ready";
216 readonly CORS_UNSUPPORTED: "auth/cors-unsupported";
217 readonly CREDENTIAL_ALREADY_IN_USE: "auth/credential-already-in-use";
218 readonly CREDENTIAL_MISMATCH: "auth/custom-token-mismatch";
219 readonly CREDENTIAL_TOO_OLD_LOGIN_AGAIN: "auth/requires-recent-login";
220 readonly DEPENDENT_SDK_INIT_BEFORE_AUTH: "auth/dependent-sdk-initialized-before-auth";
221 readonly DYNAMIC_LINK_NOT_ACTIVATED: "auth/dynamic-link-not-activated";
222 readonly EMAIL_CHANGE_NEEDS_VERIFICATION: "auth/email-change-needs-verification";
223 readonly EMAIL_EXISTS: "auth/email-already-in-use";
224 readonly EMULATOR_CONFIG_FAILED: "auth/emulator-config-failed";
225 readonly EXPIRED_OOB_CODE: "auth/expired-action-code";
226 readonly EXPIRED_POPUP_REQUEST: "auth/cancelled-popup-request";
227 readonly INTERNAL_ERROR: "auth/internal-error";
228 readonly INVALID_API_KEY: "auth/invalid-api-key";
229 readonly INVALID_APP_CREDENTIAL: "auth/invalid-app-credential";
230 readonly INVALID_APP_ID: "auth/invalid-app-id";
231 readonly INVALID_AUTH: "auth/invalid-user-token";
232 readonly INVALID_AUTH_EVENT: "auth/invalid-auth-event";
233 readonly INVALID_CERT_HASH: "auth/invalid-cert-hash";
234 readonly INVALID_CODE: "auth/invalid-verification-code";
235 readonly INVALID_CONTINUE_URI: "auth/invalid-continue-uri";
236 readonly INVALID_CORDOVA_CONFIGURATION: "auth/invalid-cordova-configuration";
237 readonly INVALID_CUSTOM_TOKEN: "auth/invalid-custom-token";
238 readonly INVALID_DYNAMIC_LINK_DOMAIN: "auth/invalid-dynamic-link-domain";
239 readonly INVALID_EMAIL: "auth/invalid-email";
240 readonly INVALID_EMULATOR_SCHEME: "auth/invalid-emulator-scheme";
241 readonly INVALID_IDP_RESPONSE: "auth/invalid-credential";
242 readonly INVALID_MESSAGE_PAYLOAD: "auth/invalid-message-payload";
243 readonly INVALID_MFA_SESSION: "auth/invalid-multi-factor-session";
244 readonly INVALID_OAUTH_CLIENT_ID: "auth/invalid-oauth-client-id";
245 readonly INVALID_OAUTH_PROVIDER: "auth/invalid-oauth-provider";
246 readonly INVALID_OOB_CODE: "auth/invalid-action-code";
247 readonly INVALID_ORIGIN: "auth/unauthorized-domain";
248 readonly INVALID_PASSWORD: "auth/wrong-password";
249 readonly INVALID_PERSISTENCE: "auth/invalid-persistence-type";
250 readonly INVALID_PHONE_NUMBER: "auth/invalid-phone-number";
251 readonly INVALID_PROVIDER_ID: "auth/invalid-provider-id";
252 readonly INVALID_RECIPIENT_EMAIL: "auth/invalid-recipient-email";
253 readonly INVALID_SENDER: "auth/invalid-sender";
254 readonly INVALID_SESSION_INFO: "auth/invalid-verification-id";
255 readonly INVALID_TENANT_ID: "auth/invalid-tenant-id";
256 readonly MFA_INFO_NOT_FOUND: "auth/multi-factor-info-not-found";
257 readonly MFA_REQUIRED: "auth/multi-factor-auth-required";
258 readonly MISSING_ANDROID_PACKAGE_NAME: "auth/missing-android-pkg-name";
259 readonly MISSING_APP_CREDENTIAL: "auth/missing-app-credential";
260 readonly MISSING_AUTH_DOMAIN: "auth/auth-domain-config-required";
261 readonly MISSING_CODE: "auth/missing-verification-code";
262 readonly MISSING_CONTINUE_URI: "auth/missing-continue-uri";
263 readonly MISSING_IFRAME_START: "auth/missing-iframe-start";
264 readonly MISSING_IOS_BUNDLE_ID: "auth/missing-ios-bundle-id";
265 readonly MISSING_OR_INVALID_NONCE: "auth/missing-or-invalid-nonce";
266 readonly MISSING_MFA_INFO: "auth/missing-multi-factor-info";
267 readonly MISSING_MFA_SESSION: "auth/missing-multi-factor-session";
268 readonly MISSING_PHONE_NUMBER: "auth/missing-phone-number";
269 readonly MISSING_SESSION_INFO: "auth/missing-verification-id";
270 readonly MODULE_DESTROYED: "auth/app-deleted";
271 readonly NEED_CONFIRMATION: "auth/account-exists-with-different-credential";
272 readonly NETWORK_REQUEST_FAILED: "auth/network-request-failed";
273 readonly NULL_USER: "auth/null-user";
274 readonly NO_AUTH_EVENT: "auth/no-auth-event";
275 readonly NO_SUCH_PROVIDER: "auth/no-such-provider";
276 readonly OPERATION_NOT_ALLOWED: "auth/operation-not-allowed";
277 readonly OPERATION_NOT_SUPPORTED: "auth/operation-not-supported-in-this-environment";
278 readonly POPUP_BLOCKED: "auth/popup-blocked";
279 readonly POPUP_CLOSED_BY_USER: "auth/popup-closed-by-user";
280 readonly PROVIDER_ALREADY_LINKED: "auth/provider-already-linked";
281 readonly QUOTA_EXCEEDED: "auth/quota-exceeded";
282 readonly REDIRECT_CANCELLED_BY_USER: "auth/redirect-cancelled-by-user";
283 readonly REDIRECT_OPERATION_PENDING: "auth/redirect-operation-pending";
284 readonly REJECTED_CREDENTIAL: "auth/rejected-credential";
285 readonly SECOND_FACTOR_ALREADY_ENROLLED: "auth/second-factor-already-in-use";
286 readonly SECOND_FACTOR_LIMIT_EXCEEDED: "auth/maximum-second-factor-count-exceeded";
287 readonly TENANT_ID_MISMATCH: "auth/tenant-id-mismatch";
288 readonly TIMEOUT: "auth/timeout";
289 readonly TOKEN_EXPIRED: "auth/user-token-expired";
290 readonly TOO_MANY_ATTEMPTS_TRY_LATER: "auth/too-many-requests";
291 readonly UNAUTHORIZED_DOMAIN: "auth/unauthorized-continue-uri";
292 readonly UNSUPPORTED_FIRST_FACTOR: "auth/unsupported-first-factor";
293 readonly UNSUPPORTED_PERSISTENCE: "auth/unsupported-persistence-type";
294 readonly UNSUPPORTED_TENANT_OPERATION: "auth/unsupported-tenant-operation";
295 readonly UNVERIFIED_EMAIL: "auth/unverified-email";
296 readonly USER_CANCELLED: "auth/user-cancelled";
297 readonly USER_DELETED: "auth/user-not-found";
298 readonly USER_DISABLED: "auth/user-disabled";
299 readonly USER_MISMATCH: "auth/user-mismatch";
300 readonly USER_SIGNED_OUT: "auth/user-signed-out";
301 readonly WEAK_PASSWORD: "auth/weak-password";
302 readonly WEB_STORAGE_UNSUPPORTED: "auth/web-storage-unsupported";
303 readonly ALREADY_INITIALIZED: "auth/already-initialized";
304};
305export {};