import { createAskSdkError , Skill } from 'ask-sdk-core' ; import { ResponseEnvelope } from 'ask-sdk-model' ; import { IncomingHttpHeaders } from 'http' ; import { Verifier } from '../verifier' ; param { IncomingHttpHeaders } httpRequestHeader param { string } httpRequestBody param { Skill } skill param { Verifier [ ] } verifiers export async function asyncVerifyRequestAndDispatch ( httpRequestHeader , httpRequestBody , skill , verifiers ) { try { await Promise . all ( verifiers . map ( async ( verifier ) => { await verifier . verify ( httpRequestBody , httpRequestHeader ) ; } ) ) ; } catch ( err ) { throw createAskSdkError ( 'Request verification failed' , err . message ) ; } let responseEnvelope ; try { responseEnvelope = await skill . invoke ( JSON . parse ( httpRequestBody ) ) ; } catch ( err ) { throw createAskSdkError ( 'Skill dispatch failed' , err . message ) ; } return responseEnvelope ; }