Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
fastify-webhook
Advanced tools
Fastify Plugin to serve webhooks with some useful default settings.
With this plugin, Fastify will have a route configured for /webhook
POST requests.
const fastify = require('fastify')()
// example without specifying options, returning a default webhook mapped to '/webhook' that only acknowledge the POST request
fastify.register(require('fastify-webhook'))
// or
// example with custom webhook url and handler, and secret key
// fastify.register(require('fastify-webhook'), {'url': '/custom-webhook', 'handler': myWebhookHandler, 'secretKey': 'secret key'})
//
// note that to use one of handlers bundled with the plugin, you need to get a reference to the plugin script 'src/handlers', and then as handler pass a reference to desired function, like:
// const webhookHandlers = require('fastify-webhook/src/handlers') // get plugin handlers (optional)
// const webhookPlugin = require('fastify-webhook')
// fastify.register(webhookPlugin, { 'url': '/custom-webhook', 'handler': webhookHandlers.echo, 'secretKey': 'secret key'})
//
fastify.listen(3000)
// To test, for example (in another terminal session) do:
// curl http://127.0.0.1:3000/webhook -X POST -H 'Content-Type: application/json' -d '{"payload":"test"}' => returning a JSON dump of the given data, and no thrown error
// in Windows you need to escape double quote char in the given json body, so do:
// curl http://127.0.0.1:3000/webhook -X POST -H "Content-Type: application/json" -d "{\"payload\":\"test\"}"
// or put data in a json file and pass with something like: '-d @body.json'
In the example folder there are some simple server scripts that uses the plugin (inline but it's the same using it from npm registry).
Fastify ^1.1.0 , Node.js 8.15.x or later. Note that plugin releases 0.x and 1.x are for Fastify 1.x, plugin releases 2.x are for Fastify 2.x, etc.
By default the plugin map a default handler on the URI /webhook
to be called via POST, otherwise it's possible to change via the setting 'url' in plugin options.
The plugin exposes some handlers, for common base operations (and webhook debug help).
To use one of them, before registering the plugin, you need to get a reference from its src/handlers
source file;
then you can configure the desired one in the setting 'handler' in plugin options.
They are:
acknowledge
(default handler) that simply acknowledge the request, and reply with a simple json responseecho
it dumps the given input data in the (json) responselogger
it dumps some info on the request using Fastify logger
but of course for a real world usage you need to specify your own handler function, with arguments '(req, reply)'.
Otherwise you can use yours, with signature function handler (req, reply)
.Other plugin options:
function beforeHandler (req, reply, done)
.Note that there is not a good general way to handle (usually user-specific) token in requests, so this is not managed via the plugin, but in examples and tests you can find some info.
Licensed under Apache-2.0.
0.4.0 (2019-04-01)
Summary Changelog:
FAQs
Fastify Plugin to serve webhooks with some default settings
The npm package fastify-webhook receives a total of 12 weekly downloads. As such, fastify-webhook popularity was classified as not popular.
We found that fastify-webhook demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.