A class implementation to simplify the validation process of JWT generated by AWS Cognito as prescribed in https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-verifying-a-jwt.html
npm install cognitoken-verifier
const { CognitokenVerifier } = require('cognitoken-verifier');
// Parameters for CognitoVerifier class
const appClientId = '<Enter app client Id of User Pool>';
const issuer = 'https://cognito-idp.<REGION>.amazonaws.com/<USERPOOLID>';
const verifier = new CognitokenVerifier(appClientId, issuer);
verifier.verify(['<Tokens>'], '<id/access>')
.then(payload=>{
//Verification Success
})
.catch(err=>{
// Verification Fail
// returns CognitokenError class
})