npm.io
1.3.0 • Published 2 months ago

shoppyhook

Licence
GPL-3.0
Version
1.3.0
Deps
0
Size
39 kB
Vulns
0
Weekly
0
Stars
1
DeprecatedThis package is deprecated

shoppyhook

A really simple and lightweight shoppy webhook middleware for express.

It will only let webhook requests pass that have a valid signature, meaning that faking purchase webhooks is not possible (provided that you do not leak your secret). The body will then be available as a JSON object in req.body.

Install

npm i shoppyhook

Usage

const shoppyhook = require("shoppyhook")

app.use("/your/shoppy/endpoint", shoppyhook("secret"))
Parser issues

You need to disable any parser you have enabled for the webhook route, otherwise it will not work as it requires the raw unparsed body.

Example: Using json as a global parser through app.use(express.json()), I can simply replace it with this workaround, which applies it globally except for that specific shoppy webhook route.

app.use(req, res, next => req.path != "/your/shoppy/endpoint" ? express.json(req, res, next) : next())

Disclaimer

This is for educational purposes only. I am not responsible for any damage caused by this tool.

License

GPLv3 dxxxxy

Keywords