3.2.1 • Published 9 years ago

oclc-wskey v3.2.1

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

node-oclc-wskey

build status

Module to construct a WebService Key for use with OCLC services.

npm install oclc-wskey

usage

var key = new WSKey(publicKey, secret /*, user */)

Where user is an object with the keys principalID and principalIDNS. Depending on what you're planning, you may not need to provide a one.

You can also pass an object as the sole parameter. Use these keys:

keyvalue
publicthe public key
secretthe secret key
useran object with principalID and principalIDNS keys
redirect_uriredirect uri associated with the key
scopean array of scopes associated with the key

redirect_uri and scope have no bearing on this module's only function (key.HMACSignature), but are necessary for generating Access Tokens.

var sig = key.HMACSignature(method, uri /*, user */)

Returns an HMAC signature for method and uri. Uses the instantiated user by default, but can be overridden with a different user.

example

var WSKey = require('oclc-wskey')
var https = require('https')
var url = require('url')
var me = { principalID: 'principalID', principalIDNS: 'principalIDNS' }
var key = new WSKey('wskey', 'secret', me)
var addr = url.parse('https://circ.sd00.worldcat.org/LHR?q=oclc:656296916')

var opts = {
  hostname: addr.hostname,
  path: addr.path,
  headers: {
    'Authorization': key.HMACSignature('GET', url.format(addr)),
    'Accept': 'application/json'
  }
}

https.get(opts, function (res) {
  res.pipe(process.stdout)
})

license

MIT

3.2.1

9 years ago

3.2.0

9 years ago

3.1.0

9 years ago

3.0.2

9 years ago

3.0.1

10 years ago

3.0.0

10 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago