import ErrorHelpers from '../error_handling/ErrorHelpers' ; import { IExpectedVerifiableCredential , ITokenValidator , TokenType , ValidationError } from '../index' ; import { IValidationResponse } from '../input_validation/IValidationResponse' ; import ValidationQueue from '../input_validation/ValidationQueue' ; import ValidationQueueItem from '../input_validation/ValidationQueueItem' ; import { VerifiableCredentialValidation } from '../input_validation/VerifiableCredentialValidation' ; import IValidatorOptions from '../options/IValidatorOptions' ; import ValidationOptions from '../options/ValidationOptions' ; const errorCode = ( error ) => ErrorHelpers . errorCode ( 'VCSDKVCTV' , error ) ; /**
 * Class to validate a token
 */ export default class VerifiableCredentialTokenValidator implements ITokenValidator { param validatorOption param expected constructor ( private validatorOption , private expected ) { } param queue param queueItem param siopDid public async validate ( _queue , queueItem , siopDid ) { const options = new ValidationOptions ( this . validatorOption , TokenType . verifiableCredential ) ; if ( typeof queueItem . tokenToValidate . rawToken === 'string' ) { const validator = new VerifiableCredentialValidation ( options , this . expected ) ; const validationResult = await validator . validate ( < string > queueItem . tokenToValidate . rawToken , siopDid ) ; return validationResult as IValidationResponse ; } const validator = new VerifiableCredentialValidation ( options , this . expected ) ; const validationResult = await validator . validate ( < object > queueItem . tokenToValidate . rawToken , siopDid ) ; return validationResult as IValidationResponse ; } param validationResponse param queue public getTokens ( _validationResponse , _queue ) { throw new ValidationError ( `Not implemented` , errorCode ( 1 ) ) ; } /**
     * Gets the type of token to validate
     */ public get isType ( ) : TokenType { return TokenType . verifiableCredential ; } }