UNPKG

2.8 kBTypeScriptView Raw
1import { AuthEventContext, AuthUserRecord, BeforeCreateResponse, BeforeSignInResponse, HttpsError, UserInfo, UserRecord, userRecordConstructor, UserRecordMetadata } from "../../common/providers/identity";
2import { BlockingFunction, CloudFunction, EventContext } from "../cloud-functions";
3export { UserRecord, UserInfo, UserRecordMetadata, userRecordConstructor };
4export { HttpsError };
5/**
6 * Options for Auth blocking function.
7 */
8export interface UserOptions {
9 /** Options to set configuration at the resource level for blocking functions. */
10 blockingOptions?: {
11 /** Pass the ID Token credential to the function. */
12 idToken?: boolean;
13 /** Pass the Access Token credential to the function. */
14 accessToken?: boolean;
15 /** Pass the Refresh Token credential to the function. */
16 refreshToken?: boolean;
17 };
18}
19/**
20 * Handles events related to Firebase Auth users events.
21 *
22 * @param userOptions - Resource level options
23 * @returns UserBuilder - Builder used to create functions for Firebase Auth user lifecycle events
24 *
25 * @public
26 */
27export declare function user(userOptions?: UserOptions): UserBuilder;
28/**
29 * Builder used to create functions for Firebase Auth user lifecycle events.
30 * @public
31 */
32export declare class UserBuilder {
33 private triggerResource;
34 private options;
35 private userOptions?;
36 private static dataConstructor;
37 /**
38 * Responds to the creation of a Firebase Auth user.
39 *
40 * @param handler Event handler that responds to the creation of a Firebase Auth user.
41 *
42 * @public
43 */
44 onCreate(handler: (user: UserRecord, context: EventContext) => PromiseLike<any> | any): CloudFunction<UserRecord>;
45 /**
46 * Responds to the deletion of a Firebase Auth user.
47 *
48 * @param handler Event handler that responds to the deletion of a Firebase Auth user.
49 *
50 * @public
51 */
52 onDelete(handler: (user: UserRecord, context: EventContext) => PromiseLike<any> | any): CloudFunction<UserRecord>;
53 /**
54 * Blocks request to create a Firebase Auth user.
55 *
56 * @param handler Event handler that blocks creation of a Firebase Auth user.
57 *
58 * @public
59 */
60 beforeCreate(handler: (user: AuthUserRecord, context: AuthEventContext) => BeforeCreateResponse | void | Promise<BeforeCreateResponse> | Promise<void>): BlockingFunction;
61 /**
62 * Blocks request to sign-in a Firebase Auth user.
63 *
64 * @param handler Event handler that blocks sign-in of a Firebase Auth user.
65 *
66 * @public
67 */
68 beforeSignIn(handler: (user: AuthUserRecord, context: AuthEventContext) => BeforeSignInResponse | void | Promise<BeforeSignInResponse> | Promise<void>): BlockingFunction;
69 private onOperation;
70 private beforeOperation;
71}