1.0.0 • Published 3 years ago

x-node-signature v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

X-Node-Signature

Payload signature validation and generation for node.js

npm package

Super simple to use

X-Node-Signature is designed to be very simple to use.

To generate a signature:

import Signature from 'X-Node-Signature'

const secret = "8e1138dbb41c5726420bd0c909ecb9a70ea01eff"
const payload = {hello: "world"}

const generatedSignature = Signature.generateHeader(payload, secret)

To validate a signature

import Signature from 'X-Node-Signature'

const secret = "8e1138dbb41c5726420bd0c909ecb9a70ea01eff"
const signature = "t=1632994609,v1=51835061c251fe1d328ac0fffccebe05e38e198d82ee3c3fdd66973cb9160845"
const payload = '{\n  "hello": "world"\n}'

try {
	const isValid = Signature.verifyHeader(payload, signature, secret)
	// Signature is valid
} catch(e) {
	// Signature is invalid
}