alexa-verifier-middleware is an Express.js middleware designed to verify incoming HTTP requests to an Alexa skill endpoint, ensuring they originate from Amazon. The package is currently stable at version 2.1.0, though the README indicates a 3.x branch exists which is pure ESM. The release cadence appears to follow semantic versioning with major updates indicating breaking changes, such as the transition to ES modules. Its primary differentiator is its focused role in securing Alexa skill endpoints by verifying request authenticity, building upon the `alexa-verifier` module. This middleware is crucial for preventing spoofed requests and maintaining the security posture of an Alexa skill's backend service.
npm install alexa-verifier-middlewareVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up an Express.js server with the alexa-verifier-middleware, ensuring that incoming Alexa requests are validated before being processed by your skill's logic.
Migrate your project to use ES modules by adding `"type": "module"` to your `package.json` and using `import` statements, or stick to version 2.x for CommonJS compatibility.
Ensure `app.use(verifier)` or `router.use(verifier)` is called before any `app.use(express.json())` or `app.use(bodyParser.json())` calls for the affected routes.
Upgrade your Node.js environment to 12.17 or newer, or use `alexa-verifier-middleware@1.x` if you need to support older Node.js versions.
Place `alexaRouter.use(verifier)` *before* any body parsing middlewares like `alexaRouter.use(bodyParser.json())`.
If using v3.x+, ensure your project is configured for ESM (`"type": "module"` in `package.json`) and use `import verifier from 'alexa-verifier-middleware'`. If using an older Node.js or CommonJS, use v2.x or earlier and `const verifier = require('alexa-verifier-middleware')`.