UNPKG

8.68 kBTypeScriptView Raw
1/*! firebase-admin v12.0.0 */
2/*!
3 * @license
4 * Copyright 2017 Google Inc.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18export interface MultiFactorInfoResponse {
19 mfaEnrollmentId: string;
20 displayName?: string;
21 phoneInfo?: string;
22 totpInfo?: TotpInfoResponse;
23 enrolledAt?: string;
24 [key: string]: unknown;
25}
26export interface TotpInfoResponse {
27 [key: string]: unknown;
28}
29export interface ProviderUserInfoResponse {
30 rawId: string;
31 displayName?: string;
32 email?: string;
33 photoUrl?: string;
34 phoneNumber?: string;
35 providerId: string;
36 federatedId?: string;
37}
38export interface GetAccountInfoUserResponse {
39 localId: string;
40 email?: string;
41 emailVerified?: boolean;
42 phoneNumber?: string;
43 displayName?: string;
44 photoUrl?: string;
45 disabled?: boolean;
46 passwordHash?: string;
47 salt?: string;
48 customAttributes?: string;
49 validSince?: string;
50 tenantId?: string;
51 providerUserInfo?: ProviderUserInfoResponse[];
52 mfaInfo?: MultiFactorInfoResponse[];
53 createdAt?: string;
54 lastLoginAt?: string;
55 lastRefreshAt?: string;
56 [key: string]: any;
57}
58/**
59 * Interface representing the common properties of a user-enrolled second factor.
60 */
61export declare abstract class MultiFactorInfo {
62 /**
63 * The ID of the enrolled second factor. This ID is unique to the user.
64 */
65 readonly uid: string;
66 /**
67 * The optional display name of the enrolled second factor.
68 */
69 readonly displayName?: string;
70 /**
71 * The type identifier of the second factor.
72 * For SMS second factors, this is `phone`.
73 * For TOTP second factors, this is `totp`.
74 */
75 readonly factorId: string;
76 /**
77 * The optional date the second factor was enrolled, formatted as a UTC string.
78 */
79 readonly enrollmentTime?: string;
80 /**
81 * Returns a JSON-serializable representation of this object.
82 *
83 * @returns A JSON-serializable representation of this object.
84 */
85 toJSON(): object;
86 /**
87 * Initializes the MultiFactorInfo object using the provided server response.
88 *
89 * @param response - The server side response.
90 */
91 private initFromServerResponse;
92}
93/**
94 * Interface representing a phone specific user-enrolled second factor.
95 */
96export declare class PhoneMultiFactorInfo extends MultiFactorInfo {
97 /**
98 * The phone number associated with a phone second factor.
99 */
100 readonly phoneNumber: string;
101 /**
102 * {@inheritdoc MultiFactorInfo.toJSON}
103 */
104 toJSON(): object;
105}
106/**
107 * `TotpInfo` struct associated with a second factor
108 */
109export declare class TotpInfo {
110}
111/**
112 * Interface representing a TOTP specific user-enrolled second factor.
113 */
114export declare class TotpMultiFactorInfo extends MultiFactorInfo {
115 /**
116 * `TotpInfo` struct associated with a second factor
117 */
118 readonly totpInfo: TotpInfo;
119 /**
120 * {@inheritdoc MultiFactorInfo.toJSON}
121 */
122 toJSON(): object;
123}
124/**
125 * The multi-factor related user settings.
126 */
127export declare class MultiFactorSettings {
128 /**
129 * List of second factors enrolled with the current user.
130 * Currently only phone and TOTP second factors are supported.
131 */
132 enrolledFactors: MultiFactorInfo[];
133 /**
134 * Returns a JSON-serializable representation of this multi-factor object.
135 *
136 * @returns A JSON-serializable representation of this multi-factor object.
137 */
138 toJSON(): object;
139}
140/**
141 * Represents a user's metadata.
142 */
143export declare class UserMetadata {
144 /**
145 * The date the user was created, formatted as a UTC string.
146 */
147 readonly creationTime: string;
148 /**
149 * The date the user last signed in, formatted as a UTC string.
150 */
151 readonly lastSignInTime: string;
152 /**
153 * The time at which the user was last active (ID token refreshed),
154 * formatted as a UTC Date string (eg 'Sat, 03 Feb 2001 04:05:06 GMT').
155 * Returns null if the user was never active.
156 */
157 readonly lastRefreshTime?: string | null;
158 /**
159 * Returns a JSON-serializable representation of this object.
160 *
161 * @returns A JSON-serializable representation of this object.
162 */
163 toJSON(): object;
164}
165/**
166 * Represents a user's info from a third-party identity provider
167 * such as Google or Facebook.
168 */
169export declare class UserInfo {
170 /**
171 * The user identifier for the linked provider.
172 */
173 readonly uid: string;
174 /**
175 * The display name for the linked provider.
176 */
177 readonly displayName: string;
178 /**
179 * The email for the linked provider.
180 */
181 readonly email: string;
182 /**
183 * The photo URL for the linked provider.
184 */
185 readonly photoURL: string;
186 /**
187 * The linked provider ID (for example, "google.com" for the Google provider).
188 */
189 readonly providerId: string;
190 /**
191 * The phone number for the linked provider.
192 */
193 readonly phoneNumber: string;
194 /**
195 * Returns a JSON-serializable representation of this object.
196 *
197 * @returns A JSON-serializable representation of this object.
198 */
199 toJSON(): object;
200}
201/**
202 * Represents a user.
203 */
204export declare class UserRecord {
205 /**
206 * The user's `uid`.
207 */
208 readonly uid: string;
209 /**
210 * The user's primary email, if set.
211 */
212 readonly email?: string;
213 /**
214 * Whether or not the user's primary email is verified.
215 */
216 readonly emailVerified: boolean;
217 /**
218 * The user's display name.
219 */
220 readonly displayName?: string;
221 /**
222 * The user's photo URL.
223 */
224 readonly photoURL?: string;
225 /**
226 * The user's primary phone number, if set.
227 */
228 readonly phoneNumber?: string;
229 /**
230 * Whether or not the user is disabled: `true` for disabled; `false` for
231 * enabled.
232 */
233 readonly disabled: boolean;
234 /**
235 * Additional metadata about the user.
236 */
237 readonly metadata: UserMetadata;
238 /**
239 * An array of providers (for example, Google, Facebook) linked to the user.
240 */
241 readonly providerData: UserInfo[];
242 /**
243 * The user's hashed password (base64-encoded), only if Firebase Auth hashing
244 * algorithm (SCRYPT) is used. If a different hashing algorithm had been used
245 * when uploading this user, as is typical when migrating from another Auth
246 * system, this will be an empty string. If no password is set, this is
247 * null. This is only available when the user is obtained from
248 * {@link BaseAuth.listUsers}.
249 */
250 readonly passwordHash?: string;
251 /**
252 * The user's password salt (base64-encoded), only if Firebase Auth hashing
253 * algorithm (SCRYPT) is used. If a different hashing algorithm had been used to
254 * upload this user, typical when migrating from another Auth system, this will
255 * be an empty string. If no password is set, this is null. This is only
256 * available when the user is obtained from {@link BaseAuth.listUsers}.
257 */
258 readonly passwordSalt?: string;
259 /**
260 * The user's custom claims object if available, typically used to define
261 * user roles and propagated to an authenticated user's ID token.
262 * This is set via {@link BaseAuth.setCustomUserClaims}
263 */
264 readonly customClaims?: {
265 [key: string]: any;
266 };
267 /**
268 * The ID of the tenant the user belongs to, if available.
269 */
270 readonly tenantId?: string | null;
271 /**
272 * The date the user's tokens are valid after, formatted as a UTC string.
273 * This is updated every time the user's refresh token are revoked either
274 * from the {@link BaseAuth.revokeRefreshTokens}
275 * API or from the Firebase Auth backend on big account changes (password
276 * resets, password or email updates, etc).
277 */
278 readonly tokensValidAfterTime?: string;
279 /**
280 * The multi-factor related properties for the current user, if available.
281 */
282 readonly multiFactor?: MultiFactorSettings;
283 /**
284 * Returns a JSON-serializable representation of this object.
285 *
286 * @returns A JSON-serializable representation of this object.
287 */
288 toJSON(): object;
289}