import ValidationQueueItem from './ValidationQueueItem' ; import { IValidationResponse } from './IValidationResponse' ; import ClaimToken , { TokenType } from '../verifiable_credential/ClaimToken' ; export default class ValidationQueue { /**
     * Keeps track of all tokens to validate and the results of validated tokens
     */ private queue : ValidationQueueItem [ ] = [ ] ; param token public enqueueToken ( id , token ) { this . queue . push ( new ValidationQueueItem ( id , token ) ) ; } param node public enqueueItem ( node ) { this . queue . push ( node ) ; } param token public get items ( ) : ValidationQueueItem [ ] { return this . queue ; } /**
     * Get next token to validate from the queue
     */ public getNextToken ( ) { for ( let inx = 0 ; inx < this . queue . length ; inx ++ ) { if ( ! this . queue [ inx ] . isValidated ) { return this . queue [ inx ] ; } } return undefined ; } /**
     * Get the result of the validation
     */ public getResult ( ) { for ( let inx = this . queue . length - 1 ; inx >= 0 ; inx -- ) { const item = this . queue [ inx ] ; if ( ! item . result ) { return item . validationResponse ; } } return this . queue [ this . queue . length - 1 ] . validationResponse ; } }