1 | import * as auth from "firebase-admin/auth";
|
2 | import { EventContext } from "../../v1/cloud-functions";
|
3 | import { HttpsError } from "./https";
|
4 | export { HttpsError };
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export type AuthBlockingEventType = "beforeCreate" | "beforeSignIn" | "beforeSendEmail" | "beforeSendSms";
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export type UserRecord = auth.UserRecord;
|
17 |
|
18 |
|
19 |
|
20 | export type UserInfo = auth.UserInfo;
|
21 |
|
22 |
|
23 |
|
24 | export declare class UserRecordMetadata implements auth.UserMetadata {
|
25 | creationTime: string;
|
26 | lastSignInTime: string;
|
27 | constructor(creationTime: string, lastSignInTime: string);
|
28 | /** Returns a plain JavaScript object with the properties of UserRecordMetadata. */
|
29 | toJSON(): AuthUserMetadata;
|
30 | }
|
31 | /**
|
32 | * Helper function that creates a `UserRecord` class from data sent over the wire.
|
33 | * @param wireData data sent over the wire
|
34 | * @returns an instance of `UserRecord` with correct toJSON functions
|
35 | */
|
36 | export declare function userRecordConstructor(wireData: Record<string, unknown>): UserRecord;
|
37 | /**
|
38 | * User info that is part of the `AuthUserRecord`.
|
39 | */
|
40 | export interface AuthUserInfo {
|
41 | |
42 |
|
43 |
|
44 | uid: string;
|
45 | |
46 |
|
47 |
|
48 | displayName: string;
|
49 | |
50 |
|
51 |
|
52 | email: string;
|
53 | |
54 |
|
55 |
|
56 | photoURL: string;
|
57 | |
58 |
|
59 |
|
60 | providerId: string;
|
61 | |
62 |
|
63 |
|
64 | phoneNumber: string;
|
65 | }
|
66 |
|
67 |
|
68 |
|
69 | export interface AuthUserMetadata {
|
70 | |
71 |
|
72 |
|
73 | creationTime: string;
|
74 | |
75 |
|
76 |
|
77 | lastSignInTime: string;
|
78 | }
|
79 |
|
80 |
|
81 |
|
82 | export interface AuthMultiFactorInfo {
|
83 | |
84 |
|
85 |
|
86 | uid: string;
|
87 | |
88 |
|
89 |
|
90 | displayName?: string;
|
91 | |
92 |
|
93 |
|
94 | factorId: string;
|
95 | |
96 |
|
97 |
|
98 | enrollmentTime?: string;
|
99 | |
100 |
|
101 |
|
102 | phoneNumber?: string;
|
103 | }
|
104 |
|
105 |
|
106 |
|
107 | export interface AuthMultiFactorSettings {
|
108 | |
109 |
|
110 |
|
111 | enrolledFactors: AuthMultiFactorInfo[];
|
112 | }
|
113 |
|
114 |
|
115 |
|
116 | export interface AuthUserRecord {
|
117 | |
118 |
|
119 |
|
120 | uid: string;
|
121 | |
122 |
|
123 |
|
124 | email?: string;
|
125 | |
126 |
|
127 |
|
128 | emailVerified: boolean;
|
129 | |
130 |
|
131 |
|
132 | displayName?: string;
|
133 | |
134 |
|
135 |
|
136 | photoURL?: string;
|
137 | |
138 |
|
139 |
|
140 | phoneNumber?: string;
|
141 | |
142 |
|
143 |
|
144 |
|
145 | disabled: boolean;
|
146 | |
147 |
|
148 |
|
149 | metadata: AuthUserMetadata;
|
150 | |
151 |
|
152 |
|
153 | providerData: AuthUserInfo[];
|
154 | |
155 |
|
156 |
|
157 | passwordHash?: string;
|
158 | |
159 |
|
160 |
|
161 | passwordSalt?: string;
|
162 | |
163 |
|
164 |
|
165 |
|
166 | customClaims?: Record<string, any>;
|
167 | |
168 |
|
169 |
|
170 | tenantId?: string | null;
|
171 | |
172 |
|
173 |
|
174 | tokensValidAfterTime?: string;
|
175 | |
176 |
|
177 |
|
178 | multiFactor?: AuthMultiFactorSettings;
|
179 | }
|
180 |
|
181 | export interface AdditionalUserInfo {
|
182 | providerId?: string;
|
183 | profile?: any;
|
184 | username?: string;
|
185 | isNewUser: boolean;
|
186 | recaptchaScore?: number;
|
187 | email?: string;
|
188 | phoneNumber?: string;
|
189 | }
|
190 |
|
191 | export interface Credential {
|
192 | claims?: {
|
193 | [key: string]: any;
|
194 | };
|
195 | idToken?: string;
|
196 | accessToken?: string;
|
197 | refreshToken?: string;
|
198 | expirationTime?: string;
|
199 | secret?: string;
|
200 | providerId: string;
|
201 | signInMethod: string;
|
202 | }
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 | export type EmailType = "EMAIL_SIGN_IN" | "PASSWORD_RESET";
|
209 |
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 | export type SmsType = "SIGN_IN_OR_SIGN_UP" | "MULTI_FACTOR_SIGN_IN" | "MULTI_FACTOR_ENROLLMENT";
|
216 |
|
217 | export interface AuthEventContext extends EventContext {
|
218 | locale?: string;
|
219 | ipAddress: string;
|
220 | userAgent: string;
|
221 | additionalUserInfo?: AdditionalUserInfo;
|
222 | credential?: Credential;
|
223 | emailType?: EmailType;
|
224 | smsType?: SmsType;
|
225 | }
|
226 |
|
227 | export interface AuthBlockingEvent extends AuthEventContext {
|
228 | data?: AuthUserRecord;
|
229 | }
|
230 |
|
231 | export type RecaptchaActionOptions = "ALLOW" | "BLOCK";
|
232 |
|
233 | export interface BeforeEmailResponse {
|
234 | recaptchaActionOverride?: RecaptchaActionOptions;
|
235 | }
|
236 |
|
237 | export interface BeforeSmsResponse {
|
238 | recaptchaActionOverride?: RecaptchaActionOptions;
|
239 | }
|
240 |
|
241 | export interface BeforeCreateResponse {
|
242 | displayName?: string;
|
243 | disabled?: boolean;
|
244 | emailVerified?: boolean;
|
245 | photoURL?: string;
|
246 | customClaims?: object;
|
247 | recaptchaActionOverride?: RecaptchaActionOptions;
|
248 | }
|
249 |
|
250 | export interface BeforeSignInResponse extends BeforeCreateResponse {
|
251 | sessionClaims?: object;
|
252 | }
|
253 | export type MaybeAsync<T> = T | Promise<T>;
|
254 | export type HandlerV1 = (userOrContext: AuthUserRecord | AuthEventContext, context?: AuthEventContext) => MaybeAsync<BeforeCreateResponse | BeforeSignInResponse | BeforeEmailResponse | BeforeSmsResponse | void>;
|
255 | export type HandlerV2 = (event: AuthBlockingEvent) => MaybeAsync<BeforeCreateResponse | BeforeSignInResponse | BeforeEmailResponse | BeforeSmsResponse | void>;
|
256 | export type AuthBlockingEventHandler = (HandlerV1 | HandlerV2) & {
|
257 | platform: "gcfv1" | "gcfv2";
|
258 | };
|