http-signature
Reference implementation of Joyent's HTTP Signature scheme.
Last updated 3 years ago by bahamat .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install http-signature 
SYNC missed versions from official npm registry.

node-http-signature

node-http-signature is a node.js library that has client and server components for Joyent's HTTP Signature Scheme.

Usage

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.

Client

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',
  keyPassphrase: 'secret' // (optional)
});

req.end();

Server

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);

Installation

npm install http-signature

License

MIT.

Bugs

See https://github.com/joyent/node-http-signature/issues.

Current Tags

  • 1.3.6                                ...           latest (3 years ago)

27 Versions

  • 1.3.6                                ...           3 years ago
  • 1.3.5                                ...           4 years ago
  • 1.3.4                                ...           5 years ago
  • 1.3.3                                ...           5 years ago
  • 1.3.2                                ...           5 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.0                                ...           7 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           9 years ago
  • 1.0.2                                ...           9 years ago
  • 1.0.1                                ...           9 years ago
  • 1.0.0                                ...           9 years ago
  • 0.11.0                                ...           10 years ago
  • 0.10.1                                ...           10 years ago
  • 0.10.0                                ...           12 years ago
  • 0.9.11                                ...           12 years ago
  • 0.9.10                                ...           12 years ago
  • 0.9.9                                ...           13 years ago
  • 0.9.8                                ...           13 years ago
  • 0.9.7                                ...           13 years ago
  • 0.9.6                                ...           13 years ago
  • 0.9.5                                ...           13 years ago
  • 0.9.4                                ...           13 years ago
  • 0.9.3                                ...           13 years ago
  • 0.9.2                                ...           13 years ago
  • 0.9.0                                ...           13 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |