digitalbazaar/node-http-signature

Name: node-http-signature

Owner: Digital Bazaar, Inc.

Description: Reference implementation of Joyent's HTTP Signature Scheme

Created: 2013-04-18 17:40:07.0

Updated: 2014-02-01 16:17:48.0

Pushed: 2016-05-04 15:52:36.0

Homepage: http://www.joyent.com

Size: 140

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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
fs = require('fs');
https = require('https');
httpSignature = require('http-signature');

key = fs.readFileSync('./key.pem', 'ascii');

options = {
st: 'localhost',
rt: 8443,
th: '/',
thod: 'GET',
aders: {}


dds a 'Date' header in, signs it, and adds the
Authorization' header in.
req = https.request(options, function(res) {
nsole.log(res.statusCode);



Signature.sign(req, {
y: key,
yId: './cert.pem'


end();
Server
fs = require('fs');
https = require('https');
httpSignature = require('http-signature');

options = {
y: fs.readFileSync('./key.pem'),
rt: fs.readFileSync('./cert.pem')


s.createServer(options, function (req, res) {
r rc = 200;
r parsed = httpSignature.parseRequest(req);
r pub = fs.readFileSync(parsed.keyId, 'ascii');
 (!httpSignature.verifySignature(parsed, pub))
rc = 401;

s.writeHead(rc);
s.end();
isten(8443);
Installation
npm install http-signature
License

MIT.

Bugs

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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.