Sign and encodes or decodes HTTP requests for Node.js
Its a general purpose sign request manager. Encodes and decodes communications using a private key (a secret) between peers.
Instalation
npm intall signed-req
Usage:
Encoding
Encodes outgoing data with SignedRequest.encodeAndSign()
:
var SignedRequest = ;var request = ; var dataToSend = user: name: "foo" email: "foo@example.com" ; var encoded = SignedRequest; request;
Decoding
And in the other side we can decode that incomming data with SignedRequest.decodeAndParse()
:
var SignedRequest = ; app;
An alternative decoding request can be made through SignedRequest.signedDecodeAndParse()
middleware.
var SignedRequest = ; app;
Where "request" is the name of param we expect contains signed request.
If middleware cant decode info inside the param, will have no access to app.post('/user')