JSPM

authorization-hmac256

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 342
  • Score
    100M100P100Q89432F
  • License MIT

Amazon style authorization using signing.

Package Exports

  • authorization-hmac256

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (authorization-hmac256) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

authorization-hmac256

Amazon style authorization using HMAC-SHA256 signing.

installation

$ npm install --save authorization-hmac256

options

  • service: (STRING) the name of the service, typically acronym like AWS or CWS (Classy Web Services)
  • token: (STRING) unique identifier for client making call, like OAuth2 client ID
  • secret: (STRING) secret value used for signing

usage

HmacAuthorize.sign(method, path, contentType, body)

const request = require('request');
const HmacAuthorize = require('authorization-hmac256')({
  service: 'service',
  token: 'token',
  secret: 'secret'
});

function postSomething(next) {
  let method = 'POST';
  let resource = '/sample/resource';
  let contentType = 'application/json';
  let body = {
    key: 'value'
  };
  let authorization = HmacAuthorize.sign(method, resource, contentType, JSON.stringify(body));
  request({
    url: 'http://api.acme.org',
    method,
    headers: {
      'Content-Type': contentType,
      'Authorization': authorization
    },
    body: JSON.stringify(body)
  }, next);
}