UNPKG

3.52 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 { FirebaseError } from '@firebase/util';
18import { AuthErrorCode } from '../core/errors';
19import { Delay } from '../core/util/delay';
20import { Auth } from '../model/public_types';
21import { IdTokenResponse } from '../model/id_token';
22import { ServerError, ServerErrorMap } from './errors';
23export declare const enum HttpMethod {
24 POST = "POST",
25 GET = "GET"
26}
27export declare const enum HttpHeader {
28 CONTENT_TYPE = "Content-Type",
29 X_FIREBASE_LOCALE = "X-Firebase-Locale",
30 X_CLIENT_VERSION = "X-Client-Version",
31 X_FIREBASE_GMPID = "X-Firebase-gmpid",
32 X_FIREBASE_CLIENT = "X-Firebase-Client"
33}
34export declare const enum Endpoint {
35 CREATE_AUTH_URI = "/v1/accounts:createAuthUri",
36 DELETE_ACCOUNT = "/v1/accounts:delete",
37 RESET_PASSWORD = "/v1/accounts:resetPassword",
38 SIGN_UP = "/v1/accounts:signUp",
39 SIGN_IN_WITH_CUSTOM_TOKEN = "/v1/accounts:signInWithCustomToken",
40 SIGN_IN_WITH_EMAIL_LINK = "/v1/accounts:signInWithEmailLink",
41 SIGN_IN_WITH_IDP = "/v1/accounts:signInWithIdp",
42 SIGN_IN_WITH_PASSWORD = "/v1/accounts:signInWithPassword",
43 SIGN_IN_WITH_PHONE_NUMBER = "/v1/accounts:signInWithPhoneNumber",
44 SEND_VERIFICATION_CODE = "/v1/accounts:sendVerificationCode",
45 SEND_OOB_CODE = "/v1/accounts:sendOobCode",
46 SET_ACCOUNT_INFO = "/v1/accounts:update",
47 GET_ACCOUNT_INFO = "/v1/accounts:lookup",
48 GET_RECAPTCHA_PARAM = "/v1/recaptchaParams",
49 START_PHONE_MFA_ENROLLMENT = "/v2/accounts/mfaEnrollment:start",
50 FINALIZE_PHONE_MFA_ENROLLMENT = "/v2/accounts/mfaEnrollment:finalize",
51 START_PHONE_MFA_SIGN_IN = "/v2/accounts/mfaSignIn:start",
52 FINALIZE_PHONE_MFA_SIGN_IN = "/v2/accounts/mfaSignIn:finalize",
53 WITHDRAW_MFA = "/v2/accounts/mfaEnrollment:withdraw",
54 GET_PROJECT_CONFIG = "/v1/projects"
55}
56export declare const DEFAULT_API_TIMEOUT_MS: Delay;
57export declare function _addTidIfNecessary<T extends {
58 tenantId?: string;
59}>(auth: Auth, request: T): T;
60export declare function _performApiRequest<T, V>(auth: Auth, method: HttpMethod, path: Endpoint, request?: T, customErrorMap?: Partial<ServerErrorMap<ServerError>>): Promise<V>;
61export declare function _performFetchWithErrorHandling<V>(auth: Auth, customErrorMap: Partial<ServerErrorMap<ServerError>>, fetchFn: () => Promise<Response>): Promise<V>;
62export declare function _performSignInRequest<T, V extends IdTokenResponse>(auth: Auth, method: HttpMethod, path: Endpoint, request?: T, customErrorMap?: Partial<ServerErrorMap<ServerError>>): Promise<V>;
63export declare function _getFinalTarget(auth: Auth, host: string, path: string, query: string): string;
64interface PotentialResponse extends IdTokenResponse {
65 email?: string;
66 phoneNumber?: string;
67}
68export declare function _makeTaggedError(auth: Auth, code: AuthErrorCode, response: PotentialResponse): FirebaseError;
69export {};