Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,11 @@ module.exports = {
"@typescript-eslint/no-use-before-define": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/member-delimiter-style": 0,
"@typescript-eslint/no-empty-interface": 0,
"@typescript-eslint/no-array-constructor": 0,
"@typescript-eslint/ban-types": 0,
"no-case-declarations": 0,
"no-useless-escape": 0,
"no-prototype-builtins": 0,
"no-var": 0,

// Required checks
"indent": ["error", 2]
Expand Down
26 changes: 13 additions & 13 deletions src/auth/auth-api-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function validateProviderUserInfo(request: any) {
* @param {any} request The create/edit request object.
* @param {boolean=} uploadAccountRequest Whether to validate as an uploadAccount request.
*/
function validateCreateEditRequest(request: any, uploadAccountRequest: boolean = false) {
function validateCreateEditRequest(request: any, uploadAccountRequest = false) {
// Hash set of whitelisted parameters.
const validKeys = {
displayName: true,
Expand Down Expand Up @@ -826,7 +826,7 @@ export abstract class AbstractAuthRequestHandler {
*/
public downloadAccount(
maxResults: number = MAX_DOWNLOAD_ACCOUNT_PAGE_SIZE,
pageToken?: string): Promise<{users: object[], nextPageToken?: string}> {
pageToken?: string): Promise<{users: object[]; nextPageToken?: string}> {
// Construct request.
const request = {
maxResults,
Expand All @@ -842,7 +842,7 @@ export abstract class AbstractAuthRequestHandler {
if (!response.users) {
response.users = [];
}
return response as {users: object[], nextPageToken?: string};
return response as {users: object[]; nextPageToken?: string};
});
}

Expand Down Expand Up @@ -885,7 +885,7 @@ export abstract class AbstractAuthRequestHandler {
return this.invokeRequestHandler(this.getAuthUrlBuilder(), FIREBASE_AUTH_UPLOAD_ACCOUNT, request)
.then((response: any) => {
// No error object is returned if no error encountered.
const failedUploads = (response.error || []) as Array<{index: number, message: string}>;
const failedUploads = (response.error || []) as Array<{index: number; message: string}>;
// Rewrite response as UserImportResult and re-insert client previously detected errors.
return userImportBuilder.buildResponse(failedUploads);
});
Expand Down Expand Up @@ -1155,7 +1155,7 @@ export abstract class AbstractAuthRequestHandler {
public listOAuthIdpConfigs(
maxResults: number = MAX_LIST_PROVIDER_CONFIGURATION_PAGE_SIZE,
pageToken?: string): Promise<object> {
const request: {pageSize: number, pageToken?: string} = {
const request: {pageSize: number; pageToken?: string} = {
pageSize: maxResults,
};
// Add next page token if provided.
Expand All @@ -1168,7 +1168,7 @@ export abstract class AbstractAuthRequestHandler {
response.oauthIdpConfigs = [];
delete response.nextPageToken;
}
return response as {oauthIdpConfigs: object[], nextPageToken?: string};
return response as {oauthIdpConfigs: object[]; nextPageToken?: string};
});
}

Expand All @@ -1183,7 +1183,7 @@ export abstract class AbstractAuthRequestHandler {
return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID));
}
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_OAUTH_IDP_CONFIG, {}, {providerId})
.then((response: any) => {
.then(() => {
// Return nothing.
});
}
Expand Down Expand Up @@ -1277,7 +1277,7 @@ export abstract class AbstractAuthRequestHandler {
public listInboundSamlConfigs(
maxResults: number = MAX_LIST_PROVIDER_CONFIGURATION_PAGE_SIZE,
pageToken?: string): Promise<object> {
const request: {pageSize: number, pageToken?: string} = {
const request: {pageSize: number; pageToken?: string} = {
pageSize: maxResults,
};
// Add next page token if provided.
Expand All @@ -1290,7 +1290,7 @@ export abstract class AbstractAuthRequestHandler {
response.inboundSamlConfigs = [];
delete response.nextPageToken;
}
return response as {inboundSamlConfigs: object[], nextPageToken?: string};
return response as {inboundSamlConfigs: object[]; nextPageToken?: string};
});
}

Expand All @@ -1305,7 +1305,7 @@ export abstract class AbstractAuthRequestHandler {
return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_PROVIDER_ID));
}
return this.invokeRequestHandler(this.getProjectConfigUrlBuilder(), DELETE_INBOUND_SAML_CONFIG, {}, {providerId})
.then((response: any) => {
.then(() => {
// Return nothing.
});
}
Expand Down Expand Up @@ -1586,7 +1586,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
*/
public listTenants(
maxResults: number = MAX_LIST_TENANT_PAGE_SIZE,
pageToken?: string): Promise<{tenants: TenantServerResponse[], nextPageToken?: string}> {
pageToken?: string): Promise<{tenants: TenantServerResponse[]; nextPageToken?: string}> {
const request = {
pageSize: maxResults,
pageToken,
Expand All @@ -1601,7 +1601,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
response.tenants = [];
delete response.nextPageToken;
}
return response as {tenants: TenantServerResponse[], nextPageToken?: string};
return response as {tenants: TenantServerResponse[]; nextPageToken?: string};
});
}

Expand All @@ -1616,7 +1616,7 @@ export class AuthRequestHandler extends AbstractAuthRequestHandler {
return Promise.reject(new FirebaseAuthError(AuthClientErrorCode.INVALID_TENANT_ID));
}
return this.invokeRequestHandler(this.tenantMgmtResourceBuilder, DELETE_TENANT, {}, {tenantId})
.then((response: any) => {
.then(() => {
// Return nothing.
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/auth/auth-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class SAMLConfig implements SAMLAuthProviderConfig {
*/
public static buildServerRequest(
options: SAMLAuthProviderRequest,
ignoreMissingFields: boolean = false): SAMLConfigServerRequest | null {
ignoreMissingFields = false): SAMLConfigServerRequest | null {
const makeRequest = validator.isNonNullObject(options) &&
(options.providerId || ignoreMissingFields);
if (!makeRequest) {
Expand Down Expand Up @@ -349,7 +349,7 @@ export class SAMLConfig implements SAMLAuthProviderConfig {
* @param {SAMLAuthProviderRequest} options The options object to validate.
* @param {boolean=} ignoreMissingFields Whether to ignore missing fields.
*/
public static validate(options: SAMLAuthProviderRequest, ignoreMissingFields: boolean = false) {
public static validate(options: SAMLAuthProviderRequest, ignoreMissingFields = false) {
const validKeys = {
enabled: true,
displayName: true,
Expand Down Expand Up @@ -545,7 +545,7 @@ export class OIDCConfig implements OIDCAuthProviderConfig {
*/
public static buildServerRequest(
options: OIDCAuthProviderRequest,
ignoreMissingFields: boolean = false): OIDCConfigServerRequest | null {
ignoreMissingFields = false): OIDCConfigServerRequest | null {
const makeRequest = validator.isNonNullObject(options) &&
(options.providerId || ignoreMissingFields);
if (!makeRequest) {
Expand Down Expand Up @@ -590,7 +590,7 @@ export class OIDCConfig implements OIDCAuthProviderConfig {
* @param {OIDCAuthProviderRequest} options The options object to validate.
* @param {boolean=} ignoreMissingFields Whether to ignore missing fields.
*/
public static validate(options: OIDCAuthProviderRequest, ignoreMissingFields: boolean = false) {
public static validate(options: OIDCAuthProviderRequest, ignoreMissingFields = false) {
const validKeys = {
enabled: true,
displayName: true,
Expand Down
16 changes: 8 additions & 8 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class BaseAuth<T extends AbstractAuthRequestHandler> {
* @return {Promise<DecodedIdToken>} A Promise that will be fulfilled after a successful
* verification.
*/
public verifyIdToken(idToken: string, checkRevoked: boolean = false): Promise<DecodedIdToken> {
public verifyIdToken(idToken: string, checkRevoked = false): Promise<DecodedIdToken> {
return this.idTokenVerifier.verifyJWT(idToken)
.then((decodedIdToken: DecodedIdToken) => {
// Whether to check if the token was revoked.
Expand Down Expand Up @@ -266,7 +266,7 @@ export class BaseAuth<T extends AbstractAuthRequestHandler> {
*/
public deleteUser(uid: string): Promise<void> {
return this.authRequestHandler.deleteAccount(uid)
.then((response) => {
.then(() => {
// Return nothing on success.
});
}
Expand Down Expand Up @@ -296,7 +296,7 @@ export class BaseAuth<T extends AbstractAuthRequestHandler> {
*/
public setCustomUserClaims(uid: string, customUserClaims: object): Promise<void> {
return this.authRequestHandler.setCustomUserClaims(uid, customUserClaims)
.then((existingUid) => {
.then(() => {
// Return nothing on success.
});
}
Expand All @@ -313,7 +313,7 @@ export class BaseAuth<T extends AbstractAuthRequestHandler> {
*/
public revokeRefreshTokens(uid: string): Promise<void> {
return this.authRequestHandler.revokeRefreshTokens(uid)
.then((existingUid) => {
.then(() => {
// Return nothing on success.
});
}
Expand Down Expand Up @@ -371,7 +371,7 @@ export class BaseAuth<T extends AbstractAuthRequestHandler> {
* verification.
*/
public verifySessionCookie(
sessionCookie: string, checkRevoked: boolean = false): Promise<DecodedIdToken> {
sessionCookie: string, checkRevoked = false): Promise<DecodedIdToken> {
return this.sessionCookieVerifier.verifyJWT(sessionCookie)
.then((decodedIdToken: DecodedIdToken) => {
// Whether to check if the token was revoked.
Expand Down Expand Up @@ -639,7 +639,7 @@ export class TenantAwareAuth extends BaseAuth<TenantAwareAuthRequestHandler> {
* @return {Promise<DecodedIdToken>} A Promise that will be fulfilled after a successful
* verification.
*/
public verifyIdToken(idToken: string, checkRevoked: boolean = false): Promise<DecodedIdToken> {
public verifyIdToken(idToken: string, checkRevoked = false): Promise<DecodedIdToken> {
return super.verifyIdToken(idToken, checkRevoked)
.then((decodedClaims) => {
// Validate tenant ID.
Expand Down Expand Up @@ -673,7 +673,7 @@ export class TenantAwareAuth extends BaseAuth<TenantAwareAuthRequestHandler> {
}
// This will verify the ID token and then match the tenant ID before creating the session cookie.
return this.verifyIdToken(idToken)
.then((decodedIdTokenClaims) => {
.then(() => {
return super.createSessionCookie(idToken, sessionCookieOptions);
});
}
Expand All @@ -691,7 +691,7 @@ export class TenantAwareAuth extends BaseAuth<TenantAwareAuthRequestHandler> {
* verification.
*/
public verifySessionCookie(
sessionCookie: string, checkRevoked: boolean = false): Promise<DecodedIdToken> {
sessionCookie: string, checkRevoked = false): Promise<DecodedIdToken> {
return super.verifySessionCookie(sessionCookie, checkRevoked)
.then((decodedClaims) => {
if (decodedClaims.firebase.tenant !== this.tenantId) {
Expand Down
2 changes: 1 addition & 1 deletion src/auth/tenant-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class TenantManager {
maxResults?: number,
pageToken?: string): Promise<ListTenantsResult> {
return this.authRequestHandler.listTenants(maxResults, pageToken)
.then((response: {tenants: TenantServerResponse[], nextPageToken?: string}) => {
.then((response: {tenants: TenantServerResponse[]; nextPageToken?: string}) => {
// List of tenants to return.
const tenants: Tenant[] = [];
// Convert each user response to a Tenant.
Expand Down
24 changes: 12 additions & 12 deletions src/auth/user-import-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export interface UserImportRecord {
creationTime?: string;
};
providerData?: Array<{
uid: string,
displayName?: string,
email?: string,
photoURL?: string,
providerId: string,
uid: string;
displayName?: string;
email?: string;
photoURL?: string;
providerId: string;
}>;
customClaims?: object;
passwordHash?: Buffer;
Expand Down Expand Up @@ -261,7 +261,7 @@ export class UserImportBuilder {
* uploadAccount response.
*/
public buildResponse(
failedUploads: Array<{index: number, message: string}>): UserImportResult {
failedUploads: Array<{index: number; message: string}>): UserImportResult {
// Initialize user import result.
const importResult: UserImportResult = {
successCount: this.validatedUsers.length,
Expand Down Expand Up @@ -343,7 +343,7 @@ export class UserImportBuilder {
case 'MD5':
case 'SHA1':
case 'SHA256':
case 'SHA512':
case 'SHA512': {
// MD5 is [0,8192] but SHA1, SHA256, and SHA512 are [1,8192]
rounds = getNumberField(options.hash, 'rounds');
const minRounds = options.hash.algorithm === 'MD5' ? 0 : 1;
Expand All @@ -359,7 +359,7 @@ export class UserImportBuilder {
rounds,
};
break;

}
case 'PBKDF_SHA1':
case 'PBKDF2_SHA256':
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are the braces { } used only for some case: clauses and not others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only used for case blocks that declare variables with const or let.

See https://eslint.org/docs/rules/no-case-declarations

rounds = getNumberField(options.hash, 'rounds');
Expand All @@ -376,7 +376,7 @@ export class UserImportBuilder {
};
break;

case 'SCRYPT':
case 'SCRYPT': {
if (!validator.isBuffer(options.hash.key)) {
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_KEY,
Expand Down Expand Up @@ -415,14 +415,14 @@ export class UserImportBuilder {
saltSeparator: utils.toWebSafeBase64(options.hash.saltSeparator || Buffer.from('')),
};
break;

}
case 'BCRYPT':
populatedOptions = {
hashAlgorithm: options.hash.algorithm,
};
break;

case 'STANDARD_SCRYPT':
case 'STANDARD_SCRYPT': {
const cpuMemCost = getNumberField(options.hash, 'memoryCost');
if (isNaN(cpuMemCost)) {
throw new FirebaseAuthError(
Expand Down Expand Up @@ -463,7 +463,7 @@ export class UserImportBuilder {
dkLen,
};
break;

}
default:
throw new FirebaseAuthError(
AuthClientErrorCode.INVALID_HASH_ALGORITHM,
Expand Down
2 changes: 1 addition & 1 deletion src/database/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { AuthorizedHttpClient, HttpRequestConfig, HttpError } from '../utils/api
class DatabaseInternals implements FirebaseServiceInternalsInterface {

public databases: {
[dbUrl: string]: Database,
[dbUrl: string]: Database;
} = {};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/firebase-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ export class FirebaseAppInternals {
private setTokenRefreshTimeout(delayInMilliseconds: number, numRetries: number): void {
this.tokenRefreshTimeout_ = setTimeout(() => {
this.getToken(/* forceRefresh */ true)
.catch((error) => {
.catch(() => {
// Ignore the error since this might just be an intermittent failure. If we really cannot
// refresh the token, an error will be logged once the existing token expires and we try
// to fetch a fresh one.
Expand Down
2 changes: 1 addition & 1 deletion src/firebase-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const DEFAULT_APP_NAME = '[DEFAULT]';
* If the environment variable contains a string that starts with '{' it will be parsed as JSON,
* otherwise it will be assumed to be pointing to a file.
*/
export const FIREBASE_CONFIG_VAR: string = 'FIREBASE_CONFIG';
export const FIREBASE_CONFIG_VAR = 'FIREBASE_CONFIG';


let globalAppDefaultCred: Credential;
Expand Down
Loading