![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | lib/ | 2 years ago | - | |
![]() | CHANGES.md | 2 years ago | 1.3K | 0fb859dc fixed mobile overflwo options [كارل مبارك] |
![]() | LICENSE | 2 years ago | 1.0K | 0fb859dc fixed mobile overflwo options [كارل مبارك] |
![]() | README.md | 2 years ago | 1.6K | 0fb859dc fixed mobile overflwo options [كارل مبارك] |
![]() | http_signing.md | 2 years ago | 14K | 0fb859dc fixed mobile overflwo options [كارل مبارك] |
![]() | package.json | 2 years ago | 1.8K | 0fb859dc fixed mobile overflwo options [كارل مبارك] |
node-http-signature is a node.js library that has client and server components for Joyent's HTTP Signature Scheme.
Note the example below signs a request with the same key/cert used to start an HTTP server. This is almost certainly not what you actually want, but is just used to illustrate the API calls; you will need to provide your own key management in addition to this library.
var fs = require('fs');
var https = require('https');
var httpSignature = require('http-signature');
var key = fs.readFileSync('./key.pem', 'ascii');
var options = {
host: 'localhost',
port: 8443,
path: '/',
method: 'GET',
headers: {}
};
// Adds a 'Date' header in, signs it, and adds the
// 'Authorization' header in.
var req = https.request(options, function(res) {
console.log(res.statusCode);
});
httpSignature.sign(req, {
key: key,
keyId: './cert.pem'
});
req.end();
var fs = require('fs');
var https = require('https');
var httpSignature = require('http-signature');
var options = {
key: fs.readFileSync('./key.pem'),
cert: fs.readFileSync('./cert.pem')
};
https.createServer(options, function (req, res) {
var rc = 200;
var parsed = httpSignature.parseRequest(req);
var pub = fs.readFileSync(parsed.keyId, 'ascii');
if (!httpSignature.verifySignature(parsed, pub))
rc = 401;
res.writeHead(rc);
res.end();
}).listen(8443);
npm install http-signature
MIT.