Skip to content

strttn/alexa-verifier-middleware

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

alexa-verifier-middleware

NPM

dependencies Status NPM Version

Verify HTTP requests sent to an Alexa skill are sent from Amazon.

This is an express middleware that wraps logic in the alexa-verifier module.

Usage

var express = require('express');
var avm = require('alexa-verifier-middleware');
var app = express();

app.use(avm()); // install the verifier middleware

// other body parsers, etc. follow...

Usage with other body parser middlewares

This middleware needs to read the entire request body, and express doesn't expose that on the request object. If you are using any other body parsing middleware, you must load this one first.

Example:

var express = require('express');
var bodyParser = require('body-parser');
var avm = require('alexa-verifier-middleware');
var app = express();

// note that the 'avm' middleware is loaded first
app.use(avm());

// now you can load other body parser related middlewares here
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());

If there is another middleware that says it needs to load first, and you are not sure which placement is better, let me know by opening an issue and I'll do some extensive testing before reporting which middleware to load first.

Extra options

  • strictHeaderCheck - Allows for strict handling of incoming requests to make sure they only come from Amazon's servers. By default this check will not be enforced.

    Example:

    var express = require('express');
    var avm = require('alexa-verifier-middleware');
    var app = express();
    
    var alexaRouter = express.Router();
    alexaRouter.use(avm({ strictHeaderCheck: true }));
    
    // Routes that handle alexa traffic are now attached here.
    // Since this is attached to a router mounted at /alexa,
    // this endpoint will be accessible at /alexa/weather_info
    alexaRouter.get('/weather_info', function(req, res) { ... });
    
    app.use('/alexa', alexaRouter);
    
    app.listen(3000)

Mentions

License

Copyright (c) 2016-2017 Tejas Shah

MIT License, see LICENSE for details.

About

Verify HTTP requests sent to an Alexa skill are sent from Amazon.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%