1.4.1 • Published 5 years ago

hmac-express v1.4.1

Weekly downloads
11
License
MIT
Repository
github
Last release
5 years ago

hmac-express

A simple middleware to be used with express. It checks if the HMAC digest of the body or a header is equal to the value of the one provided through the query string.

npm install hmac-express

Getting Started

This middleware requires three parameters when it is created. The first two are the algorithm and the secret key that will be used by the createHmac function of the crypto library. The third one is the name of the query parameter containing the HMAC digest to check.

var middleware = require("hmac-express")("sha256", "secret", "token")

app.get("/", middleware, function(request, response) {
	response.send("Hello")
})

By default the encoding of the digest is in hex but it can be changed by passing a fourth parameter. This parameter is a JSON object and the key to change the encoding is "encoding" (This value should be one of the value accepted by the method hmac.digest of the crypto library). To use the HMAC digest of a header, specify its name in the options JSON object.

var opts = {
	encoding : "base64",
	header : "timestamp"
}
var middleware = require("hmac-express")("sha256", "secret", "token", opts)

License

Copyright (c) 2016 Gautier TANGUY

MIT License

1.4.1

5 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago