import { BodyParams , Controller , Get , Header , HeaderParams , Post } from "@tsed/common" ; import { HashLengthExtensionService } from '../../services/HashLengthExtensionService' ; interface IData { data : string ; signature : string ; } interface IResponse { flag : string ; tampered : boolean ; } @ Controller ( "/hash-length-extension" ) export class HashLengthExtensionController { @ Post ( "/" ) public index ( @ BodyParams ( ) data ) { let tampered = false ; console . log ( HashLengthExtensionService . sign ( data . data ) ) ; if ( HashLengthExtensionService . sign ( data . data ) === data . signature ) { if ( HashLengthExtensionService . EXPECTED_SIGNATURE !== data . signature ) return { flag : HashLengthExtensionService . getFlag ( ) , tampered : false } ; } else tampered = true ; return { flag : "" , tampered } ; } @ Post ( "/data" ) public data ( ) { const data = HashLengthExtensionService . DATA ; const signature = HashLengthExtensionService . sign ( data ) ; return { data , signature } ; } }