Skip to content

Commit abdfb00

Browse files
Revert "feat(auth): Support sms region config change on Tenant and Project level." (#1676)
* Revert "feat(auth): Support sms region config change on Tenant and Project level. (#1673)" This reverts commit 35df364. * Trigger CI
1 parent 35df364 commit abdfb00

File tree

12 files changed

+12
-1115
lines changed

12 files changed

+12
-1115
lines changed

etc/firebase-admin.auth.api.md

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,10 @@ export interface ActionCodeSettings {
2323
url: string;
2424
}
2525

26-
// @public
27-
export interface AllowByDefault {
28-
disallowedRegions: string[];
29-
}
30-
31-
// @public
32-
export interface AllowByDefaultWrap {
33-
allowByDefault: AllowByDefault;
34-
// @alpha (undocumented)
35-
allowlistOnly?: never;
36-
}
37-
38-
// @public
39-
export interface AllowlistOnly {
40-
allowedRegions: string[];
41-
}
42-
43-
// @public
44-
export interface AllowlistOnlyWrap {
45-
// @alpha (undocumented)
46-
allowByDefault?: never;
47-
allowlistOnly: AllowlistOnly;
48-
}
49-
5026
// @public
5127
export class Auth extends BaseAuth {
5228
// Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts
5329
get app(): App;
54-
projectConfigManager(): ProjectConfigManager;
5530
tenantManager(): TenantManager;
5631
}
5732

@@ -334,18 +309,6 @@ export class PhoneMultiFactorInfo extends MultiFactorInfo {
334309
toJSON(): object;
335310
}
336311

337-
// @public
338-
export class ProjectConfig {
339-
readonly smsRegionConfig?: SmsRegionConfig;
340-
toJSON(): object;
341-
}
342-
343-
// @public
344-
export class ProjectConfigManager {
345-
getProjectConfig(): Promise<ProjectConfig>;
346-
updateProjectConfig(projectConfigOptions: UpdateProjectConfigRequest): Promise<ProjectConfig>;
347-
}
348-
349312
// @public
350313
export interface ProviderIdentifier {
351314
// (undocumented)
@@ -379,17 +342,13 @@ export interface SessionCookieOptions {
379342
expiresIn: number;
380343
}
381344

382-
// @public
383-
export type SmsRegionConfig = AllowByDefaultWrap | AllowlistOnlyWrap;
384-
385345
// @public
386346
export class Tenant {
387347
// (undocumented)
388348
readonly anonymousSignInEnabled: boolean;
389349
readonly displayName?: string;
390350
get emailSignInConfig(): EmailSignInProviderConfig | undefined;
391351
get multiFactorConfig(): MultiFactorConfig | undefined;
392-
readonly smsRegionConfig?: SmsRegionConfig;
393352
readonly tenantId: string;
394353
readonly testPhoneNumbers?: {
395354
[phoneNumber: string]: string;
@@ -432,11 +391,6 @@ export interface UpdatePhoneMultiFactorInfoRequest extends BaseUpdateMultiFactor
432391
phoneNumber: string;
433392
}
434393

435-
// @public
436-
export interface UpdateProjectConfigRequest {
437-
smsRegionConfig?: SmsRegionConfig;
438-
}
439-
440394
// @public
441395
export interface UpdateRequest {
442396
disabled?: boolean;
@@ -457,7 +411,6 @@ export interface UpdateTenantRequest {
457411
displayName?: string;
458412
emailSignInConfig?: EmailSignInProviderConfig;
459413
multiFactorConfig?: MultiFactorConfig;
460-
smsRegionConfig?: SmsRegionConfig;
461414
testPhoneNumbers?: {
462415
[phoneNumber: string]: string;
463416
} | null;

src/auth/auth-api-request.ts

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -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. */
4847
const FIREBASE_AUTH_HEADER = {
@@ -103,6 +102,7 @@ const FIREBASE_AUTH_TENANT_URL_FORMAT = FIREBASE_AUTH_BASE_URL_FORMAT.replace(
103102
const 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. */
107107
const 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. */
20091986
const 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
*/
20792056
export 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;

src/auth/auth-config.ts

Lines changed: 0 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,146 +1451,3 @@ export class OIDCConfig implements OIDCAuthProviderConfig {
14511451
};
14521452
}
14531453
}
1454-
1455-
/**
1456-
* The request interface for updating a SMS Region Config.
1457-
* Configures the regions where users are allowed to send verification SMS.
1458-
* This is based on the calling code of the destination phone number.
1459-
*/
1460-
export type SmsRegionConfig = AllowByDefaultWrap | AllowlistOnlyWrap;
1461-
1462-
/**
1463-
* Mutual exclusive SMS Region Config of AllowByDefault interface
1464-
*/
1465-
export interface AllowByDefaultWrap {
1466-
/**
1467-
* Allow every region by default.
1468-
*/
1469-
allowByDefault: AllowByDefault;
1470-
/** @alpha */
1471-
allowlistOnly?: never;
1472-
}
1473-
1474-
/**
1475-
* Mutually exclusive SMS Region Config of AllowlistOnly interface
1476-
*/
1477-
export interface AllowlistOnlyWrap {
1478-
/**
1479-
* Only allowing regions by explicitly adding them to an
1480-
* allowlist.
1481-
*/
1482-
allowlistOnly: AllowlistOnly;
1483-
/** @alpha */
1484-
allowByDefault?: never;
1485-
}
1486-
1487-
/**
1488-
* Defines a policy of allowing every region by default and adding disallowed
1489-
* regions to a disallow list.
1490-
*/
1491-
export interface AllowByDefault {
1492-
/**
1493-
* Two letter unicode region codes to disallow as defined by
1494-
* https://cldr.unicode.org/
1495-
* The full list of these region codes is here:
1496-
* https://github.com/unicode-cldr/cldr-localenames-full/blob/master/main/en/territories.json
1497-
*/
1498-
disallowedRegions: string[];
1499-
}
1500-
1501-
/**
1502-
* Defines a policy of only allowing regions by explicitly adding them to an
1503-
* allowlist.
1504-
*/
1505-
export interface AllowlistOnly {
1506-
/**
1507-
* Two letter unicode region codes to allow as defined by
1508-
* https://cldr.unicode.org/
1509-
* The full list of these region codes is here:
1510-
* https://github.com/unicode-cldr/cldr-localenames-full/blob/master/main/en/territories.json
1511-
*/
1512-
allowedRegions: string[];
1513-
}
1514-
1515-
/**
1516-
* Defines the SMSRegionConfig class used for validation.
1517-
*
1518-
* @internal
1519-
*/
1520-
export class SmsRegionsAuthConfig {
1521-
public static validate(options: SmsRegionConfig): void {
1522-
if (!validator.isNonNullObject(options)) {
1523-
throw new FirebaseAuthError(
1524-
AuthClientErrorCode.INVALID_CONFIG,
1525-
'"SmsRegionConfig" must be a non-null object.',
1526-
);
1527-
}
1528-
1529-
const validKeys = {
1530-
allowlistOnly: true,
1531-
allowByDefault: true,
1532-
};
1533-
1534-
for (const key in options) {
1535-
if (!(key in validKeys)) {
1536-
throw new FirebaseAuthError(
1537-
AuthClientErrorCode.INVALID_CONFIG,
1538-
`"${key}" is not a valid SmsRegionConfig parameter.`,
1539-
);
1540-
}
1541-
}
1542-
1543-
// validate mutual exclusiveness of allowByDefault and allowlistOnly
1544-
if (typeof options.allowByDefault !== 'undefined' && typeof options.allowlistOnly !== 'undefined') {
1545-
throw new FirebaseAuthError(
1546-
AuthClientErrorCode.INVALID_CONFIG,
1547-
'SmsRegionConfig cannot have both "allowByDefault" and "allowlistOnly" parameters.',
1548-
);
1549-
}
1550-
// validation for allowByDefault type
1551-
if (typeof options.allowByDefault !== 'undefined') {
1552-
const allowByDefaultValidKeys = {
1553-
disallowedRegions: true,
1554-
}
1555-
for (const key in options.allowByDefault) {
1556-
if (!(key in allowByDefaultValidKeys)) {
1557-
throw new FirebaseAuthError(
1558-
AuthClientErrorCode.INVALID_CONFIG,
1559-
`"${key}" is not a valid SmsRegionConfig.allowByDefault parameter.`,
1560-
);
1561-
}
1562-
}
1563-
// disallowedRegion can be empty.
1564-
if (typeof options.allowByDefault.disallowedRegions !== 'undefined'
1565-
&& !validator.isArray(options.allowByDefault.disallowedRegions)) {
1566-
throw new FirebaseAuthError(
1567-
AuthClientErrorCode.INVALID_CONFIG,
1568-
'"SmsRegionConfig.allowByDefault.disallowedRegions" must be a valid string array.',
1569-
);
1570-
}
1571-
}
1572-
1573-
if (typeof options.allowlistOnly !== 'undefined') {
1574-
const allowListOnlyValidKeys = {
1575-
allowedRegions: true,
1576-
}
1577-
for (const key in options.allowlistOnly) {
1578-
if (!(key in allowListOnlyValidKeys)) {
1579-
throw new FirebaseAuthError(
1580-
AuthClientErrorCode.INVALID_CONFIG,
1581-
`"${key}" is not a valid SmsRegionConfig.allowlistOnly parameter.`,
1582-
);
1583-
}
1584-
}
1585-
1586-
// allowedRegions can be empty
1587-
if (typeof options.allowlistOnly.allowedRegions !== 'undefined'
1588-
&& !validator.isArray(options.allowlistOnly.allowedRegions)) {
1589-
throw new FirebaseAuthError(
1590-
AuthClientErrorCode.INVALID_CONFIG,
1591-
'"SmsRegionConfig.allowlistOnly.allowedRegions" must be a valid string array.',
1592-
);
1593-
}
1594-
}
1595-
}
1596-
}

0 commit comments

Comments
 (0)