1.2.0 • Published 4 years ago

@lifeomic/twilio-webhook-validator-koa v1.2.0

Weekly downloads
152
License
MIT
Repository
github
Last release
4 years ago

twilio-webhook-validator-koa

npm Build Status Greenkeeper badge

Koa middleware that provides Twilio request validation to Twilio webhooks.

Example usage

import * as Koa from 'koa';
import * as Router from 'koa-router';
import * as bodyParser from 'koa-bodyparser';
import { webhookValidator } from '@lifeomic/twilio-webhook-validator-koa';

const app = new Koa();
const router = new Router();

router.post(
  '/twilio',
  bodyParser(),
  webhookValidator({
    authToken: process.env.TWILIO_AUTH_TOKEN
  }),
  (ctx) => {
    ctx.body = `<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Say>Twilio request validation succeeded!</Say>
</Response>`;
  }
);

app.use(router.routes()).listen(3000);

Example usage with custom host and port (e.g. behind proxy)

webhookValidator({
  authToken: process.env.TWILIO_AUTH_TOKEN,
  host: ctx.header['x-forwarded-host'],
  protocol: ctx.header['x-forwarded-proto']
});
1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago