if you were previously using common JS : const checkHmacValidity = require('shopify-hmac-validation')
this will now need to either be imported as default or implicitly.
const checkHmacValidity = require('shopify-hmac-validation').checkHmacValidity
or
const {checkHmacValidity} = require('shopify-hmac-validation')
Only named exports are now provided. Implicitly load them.
- checkHmacValidity : Installation hmac validation
- checkWebhookHmacValidity : Webhook validation
- createRawBody : NextJS helper to save from turning off parser
- Install
npm install shopify-hmac-validation --save
- Import
const checkHmacValidity = require('shopify-hmac-validation').checkHmacValidity
- Pass it your APP Secret ( partners.shopify.com)
- PAss it either a querystring object or simply the string it will figure it out (location.search)
- Response will simply be a bool, true if they match, false if not
Example:
checkHmacValidity("SOMEKEY","SOMESTRING or {SOMEOBJECT}")
In the github is a test that has a valid test object and string if you would like to reference that other wise I will place a more indepth docs out in time.
- Install
npm install shopify-hmac-validation --save
- Import
const checkHmacValidity = require('shopify-hmac-validation').checkWebhookHmacValidity
- Pass it your APP Secret ( partners.shopify.com)
3.1 Pass it the raw body of the webook request
3.2 Pass in the hmac from the headers
x-shopify-hmac-sha256
- Response will simply be a bool, true if they match, false if not
- Install
npm install shopify-hmac-validation --save
- Import
const createRawBody = require('shopify-hmac-validation').createRawBody
- A request.body object ( useful with next js body parsed rer)
- Response will simply be a string that can be used as the raw body in webhook validation