Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

calamarble-xhub

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

calamarble-xhub

xhub signature verification for POST requests from facebook

  • 0.6.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
increased by228.57%
Maintainers
1
Weekly downloads
 
Created
Source

X-Hub-Signature check

A function to check the integrity of a body payload against it's x-hub-signature header for a given shared secret. Used by Facebook Messenger Webhook POST requests

Usage

With express.js

import express from 'express';
import bodyParser from 'body-parser';
import { apiEndpoint } from 'calamarble-xhub';

const expressConfig = {
    port: 8088,
    postPath: '/fbwebhook',
    messages: {
        serverRunning: port => `Server running on port ${port}`
    }
};
const xHubConfig = {
    algo: 'sha1',
    secret: 'MY_APP_SECRET',
    messages: {
        wrongSignature: 'Content signature don\'t match'
    }
};
const app = express();
const postEndPoint = apiEndpoint(xHubConfig);
app.use(bodyParser.raw({ type: 'application/json' }));
app.post(expressConfig.postPath, postEndPoint);
app.listen(expressConfig.port, () => console.log(`Server running on port ${expressConfig.port}`));

With claudia-api-builder

import ApiBuilder from 'claudia-api-builder';
import { apiEndpoint as webhookPost} from 'calamarble-xhub';

const api = new ApiBuilder();
const xHubConfig = {
    algo: 'sha1',
    secret: 'MY_APP_SECRET',
    messages: {
        wrongSignature: 'Content signature don\'t match'
    }
}

api.post('/fbwebhook', webhookPost(xHubConfig));

export { api as default };

With claudia-api-builder and a callback

import ApiBuilder from 'claudia-api-builder';
import { apiEndpoint as webhookPost} from 'calamarble-xhub';

const api = new ApiBuilder();
const myCallback = (req, res) => {
    return { foo: 'bar' };
}
const xHubConfig = {
    algo: 'sha1',
    secret: 'MY_APP_SECRET',
    messages: {
        wrongSignature: 'Content signature don\'t match'
    },
    next: myCallback
}


api.post('/fbwebhook', webhookPost(xHubConfig));

export { api as default };

Keywords

FAQs

Package last updated on 08 Aug 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc