hawkify-pouchdb

    1.0.3 • Public • Published

    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:

    1. PouchDB: The PouchDB constructor.
    2. credentials: A valid hawk credentials object with algorithm, id and key properties. Example:
    {
      algorithm: 'sha256',
      id: 'abcdef',
      key: '1234567890',
    }

    See hawk’s source code for further documentation.

    Example

    const PouchDB = require('pouchdb');
    const hawkifyPouchDB = require('hawkify-pouchdb');
    const myCredentials = {
      algorithm: 'sha256',
      id: 'abcdef',
      key: '1234567890',
    };
     
    hawkifyPouchDB(PouchDB, myCredentials);
     
    const myDb = new PouchDB('http://localhost:5984/my-database/');
     
    myDb.get('my-doc-id')
      .then(response => {
        // Request was valid
      })
      .catch(error => {
        // Error, potentially due to invalid credentials
      });

    Development

    To work on hawkify-pouchdb, clone this repository and run npm install in the directory to install its dependencies.

    License

    MIT. See LICENSE.

    Keywords

    none

    Install

    npm i hawkify-pouchdb

    DownloadsWeekly Downloads

    13

    Version

    1.0.3

    License

    MIT

    Last publish

    Collaborators

    • cdaringe
    • dlandis
    • jwtlake
    • mstone121
    • nidev
    • rsskmr
    • ruwang
    • swashcap