npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

polyonic-secure-pouch

v1.0.7

Published

PouchDB AES encryption using brix/crypto-js for polyonic and browsers

Downloads

46

Readme

JavaScript Style Guide devDependencies Status

MIT Licence Open Source Love

Secure Pouch

PouchDB plugin for AES encryption of data in Polyonic and browsers using danang-id/simple-crypto-js which uses brix/crypto-js

const db = new PouchDB('app.db');

db.encrypt(password);
// all done, docs should be transparently encrypted/decrypted

Details

If you replicate to another database, it will decrypt before sending it to the external one. So make sure that one also has a password set as well if you want it encrypted too.

If you need to decrypt manually see danang-id/simple-crypto-js

This only encrypts the contents of documents, not the _id, _rev, _conflicts or _deleted.

I based this plugin on lil5/simple-cryptor-pouch, but tailored it to work with the Polyonic app seed project.

This project should also work on the following:

  • web (with a babel.js bundler)
  • electron
  • nodejs
  • react native

Save attachments are not ignored by default (_attachments), I would first need to make some test to really see if this is sane. At the moment I do not use attachments. I prefer to store attachments/blobs in blob storage.

Install

This plugin is hosted on npm:

npm i -s polyonic-secure-pouch

API

db.encrypt(password [, options])

Set up encryption on the database.

  • options.ignore
    String or Array of Strings of properties that will not be encrypted.

Examples

Change password

const PouchDB = require('pouchdb')
const SecurePouch = require('polyonic-secure-pouch')
PouchDB.plugin(SecurePouch)

const oldDBpath = './password-old.db'
const newDBpath = './password-new.db'

const oldDB = PouchDB(oldDBpath)
const newDB = PouchDB(newDBpath)

oldDB.encrypt('oldPassword')
newDB.encrypt('newBe//erPassw0rd')

PouchDB.replicate(oldDB, newDB, {live: true, retry: true})
.on('complete', info => console.log({output: info, message: 'complete'}))
.on('error', err => console.error(Error({output: err, message: 'error'})))
.on('denied', err => console.error(Error({output: err, message: 'denied'})))

file: examples/change-password.js

Sync encrypted remote

const PouchDB = require('pouchdb')
const SecurePouch = require('polyonic-secure-pouch')
PouchDB.plugin(SecurePouch)

const localPath = './sync-remote.db'
const remoteURL = 'http://127.0.0.1:5984'

const local = PouchDB(localPath)
const remote = PouchDB(remoteURL)

remote.encrypt('password')

// comment out to encrypt only the remote
// local.encrypt('password')

PouchDB.sync(local, remote, {live: true, retry: true})
.on('complete', info => console.log({output: info, message: 'complete'}))
.on('error', err => console.error(Error({output: err, message: 'error'})))
.on('denied', err => console.error(Error({output: err, message: 'denied'})))

file: examples/sync-encrypted-remote.js