UNPKG

3.17 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 { IdTokenResult, User, UserCredential, UserInfo } from './public_types';
18import { NextFn } from '@firebase/util';
19import { APIUserInfo } from '../api/account_management/account';
20import { FinalizeMfaResponse } from '../api/authentication/mfa';
21import { PersistedBlob } from '../core/persistence';
22import { StsTokenManager } from '../core/user/token_manager';
23import { UserMetadata } from '../core/user/user_metadata';
24import { AuthInternal } from './auth';
25import { IdTokenResponse, TaggedWithTokenResponse } from './id_token';
26import { ProviderId } from './enums';
27export declare type MutableUserInfo = {
28 -readonly [K in keyof UserInfo]: UserInfo[K];
29};
30export interface UserParameters {
31 uid: string;
32 auth: AuthInternal;
33 stsTokenManager: StsTokenManager;
34 displayName?: string | null;
35 email?: string | null;
36 phoneNumber?: string | null;
37 photoURL?: string | null;
38 isAnonymous?: boolean | null;
39 emailVerified?: boolean | null;
40 tenantId?: string | null;
41 providerData?: MutableUserInfo[] | null;
42 createdAt?: string | null;
43 lastLoginAt?: string | null;
44}
45/**
46 * UserInternal and AuthInternal reference each other, so both of them are included in the public typings.
47 * In order to exclude them, we mark them as internal explicitly.
48 *
49 * @internal
50 */
51export interface UserInternal extends User {
52 displayName: string | null;
53 email: string | null;
54 phoneNumber: string | null;
55 photoURL: string | null;
56 auth: AuthInternal;
57 providerId: ProviderId.FIREBASE;
58 refreshToken: string;
59 emailVerified: boolean;
60 tenantId: string | null;
61 providerData: MutableUserInfo[];
62 metadata: UserMetadata;
63 stsTokenManager: StsTokenManager;
64 _redirectEventId?: string;
65 _updateTokensIfNecessary(response: IdTokenResponse | FinalizeMfaResponse, reload?: boolean): Promise<void>;
66 _assign(user: UserInternal): void;
67 _clone(auth: AuthInternal): UserInternal;
68 _onReload: (cb: NextFn<APIUserInfo>) => void;
69 _notifyReloadListener: NextFn<APIUserInfo>;
70 _startProactiveRefresh: () => void;
71 _stopProactiveRefresh: () => void;
72 getIdToken(forceRefresh?: boolean): Promise<string>;
73 getIdTokenResult(forceRefresh?: boolean): Promise<IdTokenResult>;
74 reload(): Promise<void>;
75 delete(): Promise<void>;
76 toJSON(): PersistedBlob;
77}
78/**
79 * @internal
80 */
81export interface UserCredentialInternal extends UserCredential, TaggedWithTokenResponse {
82 user: UserInternal;
83}