oclc-wskey

3.2.1 • Public • Published

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:

key value
public the public key
secret the secret key
user an object with principalID and principalIDNS keys
redirect_uri redirect uri associated with the key
scope an 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

Package Sidebar

Install

npm i oclc-wskey

Weekly Downloads

3

Version

3.2.1

License

MIT

Last publish

Collaborators

  • malantonio