0.1.3 • Published 7 years ago

oauther v0.1.3

Weekly downloads
92
License
Apache-2.0
Repository
github
Last release
7 years ago

oauther

Build Status npm version

Simple OAuth 1.0 signature generation/validation.

Supports HMAC-SHA1 and PLAINTEXT signatures.

Requirements

  • Express
  • Node

Installation

npm install oauther

Usage

Initialise oauther with your secrets and use it to sign or validate requests.

var oauther = require('oauther');

var config = {
    consumer : { key : 'consumerkey', secret : 'consumersecret' },
    token : { key : 'tokenkey', secret : 'tokenkey' }, // optional
    signature_method : 'HMAC-SHA1', // 'HMAC-SHA1' (default), or 'PLAINTEXT'
    nonce_length : 32, // optional defaults to 32
    version : '1.0'  // currently only supports 1.0
};

var oauth = oauther(config);

var request = {
    hostname : 'example.com',
    path : '/oauther',
    method : 'GET'
};

var signature = oauth.sign(request);

// header formatted signature
req.header('Authorization', signature.toHeader());

// query formatted signature
var query = signature.toQuery();

// oauth parameters as json object
var params = signature.toObject();
...

// validate an incoming request
if (oauth.validate(req)) {
  console.log('Valid!');
}

Signing Requests

Request data needs to be passed to the sign method:

var request = {
    hostname : 'example.com',
    method : 'GET',
    path : '/path/to/url',
    port : 80, // optional
    protocol : 'http', // optional, default 'http'
    query, : { 'gaius' : 'baltar' },// optional, query string as json
    body : { 'kara' : 'thrace' } // optional, form encoded body as json
};
0.1.3

7 years ago

0.1.2

8 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago