UNPKG

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