1.0.1 • Published 8 years ago

trackmaster-api-signature v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

README

What is this?

This lib is using to make signature of API request for the TrackMaster.

How to use?

Assumed we have an app with credentials like this:

appKey = 'APPKEY'
appSecret = 'APPSECRET'

Signature v1 usage:

var signature = require('trackmaster-api-signature');

var requestCredentials = {
  method: 'GET', // HTTP method
  api: '/api_v2/session', // API interface URI
  params: { // params for the interface calling
    timestamp: '2016-04-07T09:50:55.567Z' // optional, UTC format
  }
};
var sign = signature(requestCredentials, appKey, appSecret);

// return request signature only
console.log(sign.signature); // Pt8j8sXala9ekY8vzZvL%2BoV4xNfheg7Lzs7FRj%2Bqi2Y%3D

console.log(JSON.stringify(sign.params)); // {"app_key":"APPKEY","signature_method":"HmacSHA256","signature_version":"1","timestamp":"2016-04-07T09:50:55.567Z"}

// return full API path join url-encoded query string.
console.log(sign.concat()); // /api_v2/session?app_key=APPKEY&signature_method=HmacSHA256&signature_version=1&timestamp=2016-04-07T09%3A50%3A55.567Z&signature=Pt8j8sXala9ekY8vzZvL%20oV4xNfheg7Lzs7FRj%20qi2Y%3D