UNPKG

6.18 kBTypeScriptView Raw
1/*! firebase-admin v10.0.0 */
2/*!
3 * Copyright 2019 Google Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17import { BaseAuth, SessionCookieOptions } from './base-auth';
18import { Tenant, CreateTenantRequest, UpdateTenantRequest } from './tenant';
19import { DecodedIdToken } from './token-verifier';
20/**
21 * Interface representing the object returned from a
22 * {@link TenantManager.listTenants}
23 * operation.
24 * Contains the list of tenants for the current batch and the next page token if available.
25 */
26export interface ListTenantsResult {
27 /**
28 * The list of {@link Tenant} objects for the downloaded batch.
29 */
30 tenants: Tenant[];
31 /**
32 * The next page token if available. This is needed for the next batch download.
33 */
34 pageToken?: string;
35}
36/**
37 * Tenant-aware `Auth` interface used for managing users, configuring SAML/OIDC providers,
38 * generating email links for password reset, email verification, etc for specific tenants.
39 *
40 * Multi-tenancy support requires Google Cloud's Identity Platform
41 * (GCIP). To learn more about GCIP, including pricing and features,
42 * see the {@link https://cloud.google.com/identity-platform | GCIP documentation}.
43 *
44 * Each tenant contains its own identity providers, settings and sets of users.
45 * Using `TenantAwareAuth`, users for a specific tenant and corresponding OIDC/SAML
46 * configurations can also be managed, ID tokens for users signed in to a specific tenant
47 * can be verified, and email action links can also be generated for users belonging to the
48 * tenant.
49 *
50 * `TenantAwareAuth` instances for a specific `tenantId` can be instantiated by calling
51 * {@link TenantManager.authForTenant}.
52 */
53export declare class TenantAwareAuth extends BaseAuth {
54 /**
55 * The tenant identifier corresponding to this `TenantAwareAuth` instance.
56 * All calls to the user management APIs, OIDC/SAML provider management APIs, email link
57 * generation APIs, etc will only be applied within the scope of this tenant.
58 */
59 readonly tenantId: string;
60 /**
61 * {@inheritdoc BaseAuth.verifyIdToken}
62 */
63 verifyIdToken(idToken: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
64 /**
65 * {@inheritdoc BaseAuth.createSessionCookie}
66 */
67 createSessionCookie(idToken: string, sessionCookieOptions: SessionCookieOptions): Promise<string>;
68 /**
69 * {@inheritdoc BaseAuth.verifySessionCookie}
70 */
71 verifySessionCookie(sessionCookie: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
72}
73/**
74 * Defines the tenant manager used to help manage tenant related operations.
75 * This includes:
76 * <ul>
77 * <li>The ability to create, update, list, get and delete tenants for the underlying
78 * project.</li>
79 * <li>Getting a `TenantAwareAuth` instance for running Auth related operations
80 * (user management, provider configuration management, token verification,
81 * email link generation, etc) in the context of a specified tenant.</li>
82 * </ul>
83 */
84export declare class TenantManager {
85 private readonly app;
86 private readonly authRequestHandler;
87 private readonly tenantsMap;
88 /**
89 * Returns a `TenantAwareAuth` instance bound to the given tenant ID.
90 *
91 * @param tenantId - The tenant ID whose `TenantAwareAuth` instance is to be returned.
92 *
93 * @returns The `TenantAwareAuth` instance corresponding to this tenant identifier.
94 */
95 authForTenant(tenantId: string): TenantAwareAuth;
96 /**
97 * Gets the tenant configuration for the tenant corresponding to a given `tenantId`.
98 *
99 * @param tenantId - The tenant identifier corresponding to the tenant whose data to fetch.
100 *
101 * @returns A promise fulfilled with the tenant configuration to the provided `tenantId`.
102 */
103 getTenant(tenantId: string): Promise<Tenant>;
104 /**
105 * Retrieves a list of tenants (single batch only) with a size of `maxResults`
106 * starting from the offset as specified by `pageToken`. This is used to
107 * retrieve all the tenants of a specified project in batches.
108 *
109 * @param maxResults - The page size, 1000 if undefined. This is also
110 * the maximum allowed limit.
111 * @param pageToken - The next page token. If not specified, returns
112 * tenants starting without any offset.
113 *
114 * @returns A promise that resolves with
115 * a batch of downloaded tenants and the next page token.
116 */
117 listTenants(maxResults?: number, pageToken?: string): Promise<ListTenantsResult>;
118 /**
119 * Deletes an existing tenant.
120 *
121 * @param tenantId - The `tenantId` corresponding to the tenant to delete.
122 *
123 * @returns An empty promise fulfilled once the tenant has been deleted.
124 */
125 deleteTenant(tenantId: string): Promise<void>;
126 /**
127 * Creates a new tenant.
128 * When creating new tenants, tenants that use separate billing and quota will require their
129 * own project and must be defined as `full_service`.
130 *
131 * @param tenantOptions - The properties to set on the new tenant configuration to be created.
132 *
133 * @returns A promise fulfilled with the tenant configuration corresponding to the newly
134 * created tenant.
135 */
136 createTenant(tenantOptions: CreateTenantRequest): Promise<Tenant>;
137 /**
138 * Updates an existing tenant configuration.
139 *
140 * @param tenantId - The `tenantId` corresponding to the tenant to delete.
141 * @param tenantOptions - The properties to update on the provided tenant.
142 *
143 * @returns A promise fulfilled with the update tenant data.
144 */
145 updateTenant(tenantId: string, tenantOptions: UpdateTenantRequest): Promise<Tenant>;
146}