UNPKG

7.45 kBTypeScriptView Raw
1/*! firebase-admin v10.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 */
18import { App } from '../app/index';
19import { UserImportOptions, UserImportRecord, UserImportResult } from './user-import-builder';
20import { TenantServerResponse, CreateTenantRequest, UpdateTenantRequest } from './tenant';
21/** List of reserved claims which cannot be provided when creating a custom token. */
22export declare const RESERVED_CLAIMS: string[];
23/** List of supported email action request types. */
24export declare const EMAIL_ACTION_REQUEST_TYPES: string[];
25/** Defines a base utility to help with resource URL construction. */
26declare class AuthResourceUrlBuilder {
27 protected app: App;
28 protected version: string;
29 protected urlFormat: string;
30 private projectId;
31 /**
32 * The resource URL builder constructor.
33 *
34 * @param projectId - The resource project ID.
35 * @param version - The endpoint API version.
36 * @constructor
37 */
38 constructor(app: App, version?: string);
39 /**
40 * Returns the resource URL corresponding to the provided parameters.
41 *
42 * @param api - The backend API name.
43 * @param params - The optional additional parameters to substitute in the
44 * URL path.
45 * @returns The corresponding resource URL.
46 */
47 getUrl(api?: string, params?: object): Promise<string>;
48 private getProjectId;
49}
50interface BatchDeleteErrorInfo {
51 index?: number;
52 localId?: string;
53 message?: string;
54}
55export interface BatchDeleteAccountsResponse {
56 errors?: BatchDeleteErrorInfo[];
57}
58/**
59 * Utility for sending requests to Auth server that are Auth instance related. This includes user and
60 * tenant management related APIs. This extends the BaseFirebaseAuthRequestHandler class and defines
61 * additional tenant management related APIs.
62 */
63export declare class AuthRequestHandler extends AbstractAuthRequestHandler {
64 protected readonly tenantMgmtResourceBuilder: AuthResourceUrlBuilder;
65 /**
66 * The FirebaseAuthRequestHandler constructor used to initialize an instance using a FirebaseApp.
67 *
68 * @param app - The app used to fetch access tokens to sign API requests.
69 * @constructor.
70 */
71 constructor(app: App);
72 /**
73 * @returns A new Auth user management resource URL builder instance.
74 */
75 protected newAuthUrlBuilder(): AuthResourceUrlBuilder;
76 /**
77 * @returns A new project config resource URL builder instance.
78 */
79 protected newProjectConfigUrlBuilder(): AuthResourceUrlBuilder;
80 /**
81 * Looks up a tenant by tenant ID.
82 *
83 * @param tenantId - The tenant identifier of the tenant to lookup.
84 * @returns A promise that resolves with the tenant information.
85 */
86 getTenant(tenantId: string): Promise<TenantServerResponse>;
87 /**
88 * Exports the tenants (single batch only) with a size of maxResults and starting from
89 * the offset as specified by pageToken.
90 *
91 * @param maxResults - The page size, 1000 if undefined. This is also the maximum
92 * allowed limit.
93 * @param pageToken - The next page token. If not specified, returns tenants starting
94 * without any offset. Tenants are returned in the order they were created from oldest to
95 * newest, relative to the page token offset.
96 * @returns A promise that resolves with the current batch of downloaded
97 * tenants and the next page token if available. For the last page, an empty list of tenants
98 * and no page token are returned.
99 */
100 listTenants(maxResults?: number, pageToken?: string): Promise<{
101 tenants: TenantServerResponse[];
102 nextPageToken?: string;
103 }>;
104 /**
105 * Deletes a tenant identified by a tenantId.
106 *
107 * @param tenantId - The identifier of the tenant to delete.
108 * @returns A promise that resolves when the tenant is deleted.
109 */
110 deleteTenant(tenantId: string): Promise<void>;
111 /**
112 * Creates a new tenant with the properties provided.
113 *
114 * @param tenantOptions - The properties to set on the new tenant to be created.
115 * @returns A promise that resolves with the newly created tenant object.
116 */
117 createTenant(tenantOptions: CreateTenantRequest): Promise<TenantServerResponse>;
118 /**
119 * Updates an existing tenant with the properties provided.
120 *
121 * @param tenantId - The tenant identifier of the tenant to update.
122 * @param tenantOptions - The properties to update on the existing tenant.
123 * @returns A promise that resolves with the modified tenant object.
124 */
125 updateTenant(tenantId: string, tenantOptions: UpdateTenantRequest): Promise<TenantServerResponse>;
126}
127/**
128 * Utility for sending requests to Auth server that are tenant Auth instance related. This includes user
129 * management related APIs for specified tenants.
130 * This extends the BaseFirebaseAuthRequestHandler class.
131 */
132export declare class TenantAwareAuthRequestHandler extends AbstractAuthRequestHandler {
133 private readonly tenantId;
134 /**
135 * The FirebaseTenantRequestHandler constructor used to initialize an instance using a
136 * FirebaseApp and a tenant ID.
137 *
138 * @param app - The app used to fetch access tokens to sign API requests.
139 * @param tenantId - The request handler's tenant ID.
140 * @constructor
141 */
142 constructor(app: App, tenantId: string);
143 /**
144 * @returns A new Auth user management resource URL builder instance.
145 */
146 protected newAuthUrlBuilder(): AuthResourceUrlBuilder;
147 /**
148 * @returns A new project config resource URL builder instance.
149 */
150 protected newProjectConfigUrlBuilder(): AuthResourceUrlBuilder;
151 /**
152 * Imports the list of users provided to Firebase Auth. This is useful when
153 * migrating from an external authentication system without having to use the Firebase CLI SDK.
154 * At most, 1000 users are allowed to be imported one at a time.
155 * When importing a list of password users, UserImportOptions are required to be specified.
156 *
157 * Overrides the superclass methods by adding an additional check to match tenant IDs of
158 * imported user records if present.
159 *
160 * @param users - The list of user records to import to Firebase Auth.
161 * @param options - The user import options, required when the users provided
162 * include password credentials.
163 * @returns A promise that resolves when the operation completes
164 * with the result of the import. This includes the number of successful imports, the number
165 * of failed uploads and their corresponding errors.
166 */
167 uploadAccount(users: UserImportRecord[], options?: UserImportOptions): Promise<UserImportResult>;
168}
169/**
170 * When true the SDK should communicate with the Auth Emulator for all API
171 * calls and also produce unsigned tokens.
172 */
173export declare function useEmulator(): boolean;
174export {};