diff --git a/app/consumer/auth-queue.consumer.ts b/app/consumer/auth-queue.consumer.ts index 173ff73..9e23a92 100644 --- a/app/consumer/auth-queue.consumer.ts +++ b/app/consumer/auth-queue.consumer.ts @@ -4,9 +4,6 @@ export class AuthQueueConsumer implements QueueConsumer { private channel: any; private ctxArgs: ContextArgs = {} as ContextArgs; - constructor() { - } - init = ( channel: string, ctxArgs: ContextArgs ) => { this.channel = channel; this.ctxArgs = ctxArgs; @@ -24,7 +21,7 @@ export class AuthQueueConsumer implements QueueConsumer { let requeue = false; if ( message.example ) { - var exampleHook = async () => { + const exampleHook = async () => { console.log( 'Auth server example' ); }; diff --git a/app/controller/auth.controller.ts b/app/controller/auth.controller.ts index 62ae566..7f612ee 100644 --- a/app/controller/auth.controller.ts +++ b/app/controller/auth.controller.ts @@ -24,11 +24,13 @@ import { UserRepository } from '../repository/user.repository'; import { TwoFactorCodeController } from './two-factor.controller'; export class AuthController { - constructor( - private environment = new Environment(), - private tokenUtil: TokenUtil = new TokenUtil( environment.args() ) - ) { - /* intentionally blank */ + + environment: Environment; + tokenUtil: TokenUtil; + + constructor() { + this.environment = new Environment(); + this.tokenUtil = new TokenUtil( this.environment.args() ); } /** @@ -131,8 +133,8 @@ export class AuthController { let dbUser = await userRepository.findUserByUsernameOrEmail( username ); // if user is not admin and origin is related with admin clients, do not permit to process - if(dbUser?.role && dbUser.role !== UserRole.ADMIN && process.env.ADMIN_CLIENT_URLS?.includes(origin)) { - let e = new Error("Bad Credentials") as HttpError; + if ( dbUser?.role && dbUser.role !== UserRole.ADMIN && process.env.ADMIN_CLIENT_URLS?.includes( origin ) ) { + let e = new Error( 'Bad Credentials' ) as HttpError; e.responseCode = ResponseCode.FORBIDDEN; throw e; } @@ -223,7 +225,6 @@ export class AuthController { verify = async ( db: PostgreSqlProvider, token: string, - languageCode?: string ) => { const user: any = this.tokenUtil.verifyVerificationToken( token ); @@ -372,48 +373,48 @@ export class AuthController { } getUsers = async ( - db: PostgreSqlProvider, - role?: string, - verified?: any, - oauth?: any, - twoFA?: any, - username?: string, - offset?: number, - limit?: number + db: PostgreSqlProvider, + role?: string, + verified?: any, + oauth?: any, + twoFA?: any, + username?: string, + offset?: number, + limit?: number ) => { - const userRepository = new UserRepository(db); + const userRepository = new UserRepository( db ); - if(role === 'All') { + if ( role === 'All' ) { role = ''; } - if(verified === 'true') { - verified = true - } else if(verified === 'false') { - verified = false + if ( verified === 'true' ) { + verified = true; + } else if ( verified === 'false' ) { + verified = false; } - if(twoFA === 'true') { - twoFA = true - } else if(twoFA === 'false') { - twoFA = false + if ( twoFA === 'true' ) { + twoFA = true; + } else if ( twoFA === 'false' ) { + twoFA = false; } - if(!offset) { + if ( !offset ) { offset = 0; } - if(!limit) { + if ( !limit ) { limit = 20; } - let users: any[] = [] + let users: any[] = []; let count: any; - users = await userRepository.getAllUsers(role ?? '', verified, twoFA, oauth, username ?? '', offset, limit); - count = +(await userRepository.getAllUsersCount(role ?? '', verified, twoFA, oauth, username ?? '')).count ?? 0; + users = await userRepository.getAllUsers( role ?? '', verified, twoFA, oauth, username ?? '', offset, limit ); + count = +( await userRepository.getAllUsersCount( role ?? '', verified, twoFA, oauth, username ?? '' ) ).count ?? 0; return { users, meta: { offset, limit, count } }; - } + }; } diff --git a/app/controller/social-login.controller.ts b/app/controller/social-login.controller.ts index 6521dae..85b94cb 100644 --- a/app/controller/social-login.controller.ts +++ b/app/controller/social-login.controller.ts @@ -29,13 +29,19 @@ import { UserRepository } from '../repository/user.repository'; import { TwoFactorCodeController } from './two-factor.controller'; export class SocialLoginController { - constructor( - private builder = new BuilderUtil(), - private parser = new ParserUtil(), - private environment = new Environment(), - private encryptionUtil = new EncryptionUtil( environment.args() ), - private tokenUtil: TokenUtil = new TokenUtil( environment.args() ) - ) { + + builder: BuilderUtil; + parser: ParserUtil; + environment: Environment; + encryptionUtil: EncryptionUtil; + tokenUtil: TokenUtil; + + constructor() { + this.builder = new BuilderUtil(); + this.parser = new ParserUtil(); + this.environment = new Environment(); + this.encryptionUtil = new EncryptionUtil( this.environment.args() ); + this.tokenUtil = new TokenUtil( this.environment.args() ); } /** diff --git a/app/controller/two-factor.controller.ts b/app/controller/two-factor.controller.ts index e7b3dbe..097948d 100644 --- a/app/controller/two-factor.controller.ts +++ b/app/controller/two-factor.controller.ts @@ -8,7 +8,6 @@ import { SmsActionType, TokenUtil, TwoFactorCodeRequestParams, - User } from '@open-template-hub/common'; import crypto from 'crypto'; import { Environment } from '../../environment'; @@ -18,10 +17,10 @@ import { UserRepository } from '../repository/user.repository'; import { AuthController } from './auth.controller'; export class TwoFactorCodeController { - constructor( - private environment = new Environment() - ) { - // intentionally blank + + environment: Environment; + constructor() { + this.environment = new Environment(); } request = async ( @@ -94,7 +93,6 @@ export class TwoFactorCodeController { loginVerify = async ( db: PostgreSqlProvider, - messageQueueProvider: MessageQueueProvider, code: string, preAuthToken: string ) => { @@ -115,11 +113,6 @@ export class TwoFactorCodeController { const userRepository = new UserRepository( db ); let dbUser = await userRepository.findUserByUsernameOrEmail( decrpytedPreAuthToken.username as string ); - const user = { - username: dbUser.username, - password: dbUser.password, - } as User; - const authController = new AuthController(); return authController.twoFactorVerifiedLogin( db, dbUser ); }; diff --git a/app/route/auth.route.ts b/app/route/auth.route.ts index f9acc03..937c388 100644 --- a/app/route/auth.route.ts +++ b/app/route/auth.route.ts @@ -159,7 +159,7 @@ router.delete( router.get( subRoutes.submittedPhoneNumber, authorizedBy( [ UserRole.ADMIN, UserRole.DEFAULT ] ), - async ( req: Request, res: Response ) => { + async ( _req: Request, res: Response ) => { const authController = new AuthController(); const context = res.locals.ctx; const submittedPhoneNumber = await authController.getSubmittedPhoneNumber( @@ -173,7 +173,7 @@ router.get( router.delete( subRoutes.submittedPhoneNumber, authorizedBy( [ UserRole.ADMIN, UserRole.DEFAULT ] ), - async ( req: Request, res: Response ) => { + async ( _req: Request, res: Response ) => { const authController = new AuthController(); const context = res.locals.ctx; await authController.deleteSubmittedPhoneNumber( @@ -187,10 +187,10 @@ router.delete( router.get( subRoutes.users, authorizedBy([UserRole.ADMIN, UserRole.DEFAULT]), - async(req: Request, res: Response) => { + async(req: Request, res: Response) => { const authController = new AuthController(); const context = res.locals.ctx; - + const users = await authController.getUsers( context.postgresql_provider, req.query.role as string, @@ -204,4 +204,4 @@ router.get( res.status(ResponseCode.OK).json(users); } -) \ No newline at end of file +) diff --git a/app/route/index.route.ts b/app/route/index.route.ts index 5f32d00..26b92af 100644 --- a/app/route/index.route.ts +++ b/app/route/index.route.ts @@ -39,7 +39,7 @@ export namespace Routes { applicationName: 'AuthServer', } as MountAssets; - var routes: Array = []; + const routes: Array = []; routes.push( { name: subRoutes.auth, router: authRouter } ); routes.push( { name: subRoutes.info, router: infoRouter } ); diff --git a/app/route/info.route.ts b/app/route/info.route.ts index 81a40a3..e463e09 100644 --- a/app/route/info.route.ts +++ b/app/route/info.route.ts @@ -19,7 +19,7 @@ const infoController = new InfoController(); router.get( subRoutes.me, authorizedBy( [ UserRole.ADMIN, UserRole.DEFAULT ] ), - async ( req: Request, res: Response ) => { + async ( _req: Request, res: Response ) => { // gets user info const context = res.locals.ctx; const response = await infoController.me( diff --git a/app/route/monitor.route.ts b/app/route/monitor.route.ts index 0913fee..6c124c5 100644 --- a/app/route/monitor.route.ts +++ b/app/route/monitor.route.ts @@ -14,7 +14,7 @@ const subRoutes = { export const router = Router(); -router.get( subRoutes.alive, async ( req: Request, res: Response ) => { +router.get( subRoutes.alive, async ( _req: Request, res: Response ) => { // check system is alive res.status( ResponseCode.OK ).json( { version } ); } ); diff --git a/app/route/two-factor-code.route.ts b/app/route/two-factor-code.route.ts index 5ccdbe0..a184d63 100644 --- a/app/route/two-factor-code.route.ts +++ b/app/route/two-factor-code.route.ts @@ -57,7 +57,6 @@ router.post( subRoutes.loginVerify, async ( req: Request, res: Response ) => { const loginVerifyResponse = await twoFactorCodeController.loginVerify( context.postgresql_provider, - context.message_queue_provider, req.body.code, req.body.preAuthToken ); diff --git a/dependency-checker.ts b/dependency-checker.ts index 19573ee..4f7a337 100644 --- a/dependency-checker.ts +++ b/dependency-checker.ts @@ -5,6 +5,8 @@ const lines = outdatedCmd.stdout.toString().split( '\n' ); const columnIndexes = [ 0, 0, 0, 0 ]; +let indexOfDependedBy = -1; + console.log( '

\n' + ' \n' + @@ -41,7 +43,17 @@ for ( const line of lines ) { modifiedLine += '| '; - for ( let part of stringParts ) { + for ( let i = 0; i < stringParts.length; ++i ) { + const part = stringParts[ i ]; + + if ( lines.indexOf( line ) === 0 && i < stringParts.length - 1 && stringParts[ i + 1 ] === 'Depended' ) { + indexOfDependedBy = i; + } + + if ( indexOfDependedBy !== -1 && i >= indexOfDependedBy ) { + continue; + } + if ( part.match( /\s+/ ) ) { modifiedLine += ' | '; } else {