import { ChallengeService } from './ChallengeService' ; export class TimingAttackService extends ChallengeService { public static USER = { username : "abel" , password : "___" } ; public static async checkLogin ( username , password ) { await this . sleep ( 100 ) ; if ( username . toLowerCase ( ) === TimingAttackService . USER . username ) { await this . sleep ( 500 ) ; return false ; } return false ; } public static async checkUsername ( username ) { await this . sleep ( 5000 ) ; return username === TimingAttackService . USER . username ; } public static async sleep ( miliseconds ) { return new Promise ( ( resolve , reject ) => { setTimeout ( ( ) => resolve ( ) , miliseconds ) ; } ) ; } }