@@ -42,7 +42,6 @@ import {
4242 OIDCAuthProviderConfig , SAMLAuthProviderConfig , OIDCUpdateAuthProviderRequest ,
4343 SAMLUpdateAuthProviderRequest
4444} from './auth-config' ;
45- import { ProjectConfig , ProjectConfigServerResponse , UpdateProjectConfigRequest } from './project-config' ;
4645
4746/** Firebase Auth request header. */
4847const FIREBASE_AUTH_HEADER = {
@@ -103,6 +102,7 @@ const FIREBASE_AUTH_TENANT_URL_FORMAT = FIREBASE_AUTH_BASE_URL_FORMAT.replace(
103102const FIREBASE_AUTH_EMULATOR_TENANT_URL_FORMAT = FIREBASE_AUTH_EMULATOR_BASE_URL_FORMAT . replace (
104103 'projects/{projectId}' , 'projects/{projectId}/tenants/{tenantId}' ) ;
105104
105+
106106/** Maximum allowed number of tenants to download at one time. */
107107const MAX_LIST_TENANT_PAGE_SIZE = 1000 ;
108108
@@ -1981,29 +1981,6 @@ export abstract class AbstractAuthRequestHandler {
19811981 }
19821982}
19831983
1984- /** Instantiates the getConfig endpoint settings. */
1985- const GET_PROJECT_CONFIG = new ApiSettings ( '/config' , 'GET' )
1986- . setResponseValidator ( ( response : any ) => {
1987- // Response should always contain at least the config name.
1988- if ( ! validator . isNonEmptyString ( response . name ) ) {
1989- throw new FirebaseAuthError (
1990- AuthClientErrorCode . INTERNAL_ERROR ,
1991- 'INTERNAL ASSERT FAILED: Unable to get project config' ,
1992- ) ;
1993- }
1994- } ) ;
1995-
1996- /** Instantiates the updateConfig endpoint settings. */
1997- const UPDATE_PROJECT_CONFIG = new ApiSettings ( '/config?updateMask={updateMask}' , 'PATCH' )
1998- . setResponseValidator ( ( response : any ) => {
1999- // Response should always contain at least the config name.
2000- if ( ! validator . isNonEmptyString ( response . name ) ) {
2001- throw new FirebaseAuthError (
2002- AuthClientErrorCode . INTERNAL_ERROR ,
2003- 'INTERNAL ASSERT FAILED: Unable to update project config' ,
2004- ) ;
2005- }
2006- } ) ;
20071984
20081985/** Instantiates the getTenant endpoint settings. */
20091986const GET_TENANT = new ApiSettings ( '/tenants/{tenantId}' , 'GET' )
@@ -2072,13 +2049,13 @@ const CREATE_TENANT = new ApiSettings('/tenants', 'POST')
20722049
20732050
20742051/**
2075- * Utility for sending requests to Auth server that are Auth instance related. This includes user, tenant,
2076- * and project config management related APIs. This extends the BaseFirebaseAuthRequestHandler class and defines
2052+ * Utility for sending requests to Auth server that are Auth instance related. This includes user and
2053+ * tenant management related APIs. This extends the BaseFirebaseAuthRequestHandler class and defines
20772054 * additional tenant management related APIs.
20782055 */
20792056export class AuthRequestHandler extends AbstractAuthRequestHandler {
20802057
2081- protected readonly authResourceUrlBuilder : AuthResourceUrlBuilder ;
2058+ protected readonly tenantMgmtResourceBuilder : AuthResourceUrlBuilder ;
20822059
20832060 /**
20842061 * The FirebaseAuthRequestHandler constructor used to initialize an instance using a FirebaseApp.
@@ -2088,7 +2065,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
20882065 */
20892066 constructor ( app : App ) {
20902067 super ( app ) ;
2091- this . authResourceUrlBuilder = new AuthResourceUrlBuilder ( app , 'v2' ) ;
2068+ this . tenantMgmtResourceBuilder = new AuthResourceUrlBuilder ( app , 'v2' ) ;
20922069 }
20932070
20942071 /**
@@ -2105,35 +2082,6 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
21052082 return new AuthResourceUrlBuilder ( this . app , 'v2' ) ;
21062083 }
21072084
2108- /**
2109- * Get the current project's config
2110- * @returns A promise that resolves with the project config information.
2111- */
2112- public getProjectConfig ( ) : Promise < ProjectConfigServerResponse > {
2113- return this . invokeRequestHandler ( this . authResourceUrlBuilder , GET_PROJECT_CONFIG , { } , { } )
2114- . then ( ( response : any ) => {
2115- return response as ProjectConfigServerResponse ;
2116- } ) ;
2117- }
2118-
2119- /**
2120- * Update the current project's config.
2121- * @returns A promise that resolves with the project config information.
2122- */
2123- public updateProjectConfig ( options : UpdateProjectConfigRequest ) : Promise < ProjectConfigServerResponse > {
2124- try {
2125- const request = ProjectConfig . buildServerRequest ( options ) ;
2126- const updateMask = utils . generateUpdateMask ( request ) ;
2127- return this . invokeRequestHandler (
2128- this . authResourceUrlBuilder , UPDATE_PROJECT_CONFIG , request , { updateMask : updateMask . join ( ',' ) } )
2129- . then ( ( response : any ) => {
2130- return response as ProjectConfigServerResponse ;
2131- } ) ;
2132- } catch ( e ) {
2133- return Promise . reject ( e ) ;
2134- }
2135- }
2136-
21372085 /**
21382086 * Looks up a tenant by tenant ID.
21392087 *
@@ -2144,7 +2092,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
21442092 if ( ! validator . isNonEmptyString ( tenantId ) ) {
21452093 return Promise . reject ( new FirebaseAuthError ( AuthClientErrorCode . INVALID_TENANT_ID ) ) ;
21462094 }
2147- return this . invokeRequestHandler ( this . authResourceUrlBuilder , GET_TENANT , { } , { tenantId } )
2095+ return this . invokeRequestHandler ( this . tenantMgmtResourceBuilder , GET_TENANT , { } , { tenantId } )
21482096 . then ( ( response : any ) => {
21492097 return response as TenantServerResponse ;
21502098 } ) ;
@@ -2174,7 +2122,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
21742122 if ( typeof request . pageToken === 'undefined' ) {
21752123 delete request . pageToken ;
21762124 }
2177- return this . invokeRequestHandler ( this . authResourceUrlBuilder , LIST_TENANTS , request )
2125+ return this . invokeRequestHandler ( this . tenantMgmtResourceBuilder , LIST_TENANTS , request )
21782126 . then ( ( response : any ) => {
21792127 if ( ! response . tenants ) {
21802128 response . tenants = [ ] ;
@@ -2194,7 +2142,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
21942142 if ( ! validator . isNonEmptyString ( tenantId ) ) {
21952143 return Promise . reject ( new FirebaseAuthError ( AuthClientErrorCode . INVALID_TENANT_ID ) ) ;
21962144 }
2197- return this . invokeRequestHandler ( this . authResourceUrlBuilder , DELETE_TENANT , undefined , { tenantId } )
2145+ return this . invokeRequestHandler ( this . tenantMgmtResourceBuilder , DELETE_TENANT , undefined , { tenantId } )
21982146 . then ( ( ) => {
21992147 // Return nothing.
22002148 } ) ;
@@ -2210,7 +2158,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
22102158 try {
22112159 // Construct backend request.
22122160 const request = Tenant . buildServerRequest ( tenantOptions , true ) ;
2213- return this . invokeRequestHandler ( this . authResourceUrlBuilder , CREATE_TENANT , request )
2161+ return this . invokeRequestHandler ( this . tenantMgmtResourceBuilder , CREATE_TENANT , request )
22142162 . then ( ( response : any ) => {
22152163 return response as TenantServerResponse ;
22162164 } ) ;
@@ -2236,7 +2184,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
22362184 // Do not traverse deep into testPhoneNumbers. The entire content should be replaced
22372185 // and not just specific phone numbers.
22382186 const updateMask = utils . generateUpdateMask ( request , [ 'testPhoneNumbers' ] ) ;
2239- return this . invokeRequestHandler ( this . authResourceUrlBuilder , UPDATE_TENANT , request ,
2187+ return this . invokeRequestHandler ( this . tenantMgmtResourceBuilder , UPDATE_TENANT , request ,
22402188 { tenantId, updateMask : updateMask . join ( ',' ) } )
22412189 . then ( ( response : any ) => {
22422190 return response as TenantServerResponse ;
0 commit comments