Hawkify PouchDB
Make PouchDB HTTP requests use hawk authentication.
Sign your PouchDB requests with a hawk Authorization
header. This plugin works in conjunction with MRN-Code/nodeapi and MRN-Code/coinstac-storage-proxy to ensure clients using PouchDB are authenticated.
Installation
Make sure you have Node.js (4.2.x
or greater) and NPM installed. To use hawkify-pouchdb in your project, run:
npm install hawkify-pouchdb --save
Use
This plugin works by altering PouchDB’s internal request system. hawkify-pouchdb exports a single function which expects two arguments:
PouchDB
: The PouchDB constructor.credentials
: A valid hawk credentials object withalgorithm
,id
andkey
properties. Example:
algorithm: 'sha256' id: 'abcdef' key: '1234567890'
See hawk’s source code for further documentation.
Example
const PouchDB = ;const hawkifyPouchDB = ;const myCredentials = algorithm: 'sha256' id: 'abcdef' key: '1234567890'; ; const myDb = 'http://localhost:5984/my-database/'; myDb ;
Development
To work on hawkify-pouchdb, clone this repository and run npm install
in the directory to install its dependencies.
- Style: This plugin adheres to the Airbnb JavaScript style guide via ESLint. Run
npm run lint
to lint the files. - Tests: This plugin uses tape for testing. Run
npm test
to run the tests.
License
MIT. See LICENSE.