Registry / database / pouchdb-users

pouchdb-users

JSON →
library1.0.6jsnpmunverified

pouchdb-users is a PouchDB plugin designed to simulate the behavior of CouchDB's `_users` database. It handles password hashing (using PBKDF2) and ensures user document formats adhere to CouchDB's specifications. This allows developers to use any PouchDB adapter, including in-memory or LevelDB-based local storage, for persisting user accounts, thereby decoupling user management from a live CouchDB instance for basic operations. The current stable version is 1.0.6, released in June 2017. The package has seen no updates since then, indicating it is no longer actively maintained. Its key differentiator is enabling offline-first user account management within PouchDB environments without requiring a constant connection to a CouchDB `_users` database for operations like user creation and retrieval. It explicitly does *not* implement access control, focusing solely on document format and password security for user records.

npm install pouchdb-users
INSTALL
IMPORT
SIG · POUCHDB-USERS
P
pouchdb-users
databasejavascriptv1.0.6
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PouchDB
const PouchDB = require('pouchdb')
import PouchDB from 'pouchdb'
This package primarily supports CommonJS `require()` patterns. Modern PouchDB versions might have ESM support, but this plugin is designed for older CommonJS PouchDB environments.
pouchdb-users
const PouchDBUsers = require('pouchdb-users')
import PouchDBUsers from 'pouchdb-users'
Import the plugin module using CommonJS `require()` for compatibility.
plugin installation
PouchDB.plugin(require('pouchdb-users'))
db.plugin(require('pouchdb-users'))
PouchDB plugins are installed on the `PouchDB` constructor itself, not on an individual database instance.

Demonstrates how to install the pouchdb-users plugin and create a new user document, showing how the password gets hashed and stored in a CouchDB-compatible format within a local PouchDB instance.

const PouchDB = require('pouchdb') PouchDB.plugin(require('pouchdb-users')) const memdown = require('memdown') // For an in-memory database example async function setupUsersDatabase() { const db = new PouchDB('my-users', { db: memdown }) console.log('Installing users behavior...') await db.installUsersBehavior() console.log('Users behavior installed.') console.log('Creating a new user...') const newUserDoc = { _id: 'org.couchdb.user:testuser', type: 'user', name: 'testuser', password: 'supersecretpassword123' } const response = await db.put(newUserDoc) console.log('User created/updated:', response) console.log('Fetching the user document to see hashed password...') const userDoc = await db.get('org.couchdb.user:testuser') console.log('Retrieved user document:', userDoc) // Example against a remote CouchDB _users database (requires admin credentials) // const remoteDb = new PouchDB('http://localhost:5984/_users', { // auth: { // username: process.env.COUCHDB_ADMIN_USERNAME ?? 'admin', // password: process.env.COUCHDB_ADMIN_PASSWORD ?? 'adminpassword' // } // }) // await remoteDb.installUsersBehavior() // console.log('Remote users behavior installed.') // const remoteResponse = await remoteDb.put({ // _id: 'org.couchdb.user:remoteuser', // type: 'user', // name: 'remoteuser', // password: 'anothersecretpassword' // }) // console.log('Remote user created:', remoteResponse) } setupUsersDatabase().catch(console.error)
Debug
Known issues
gotchapouchdb-users explicitly does NOT implement any access restrictions or user context. It solely handles password hashing and document formatting for CouchDB's `_users` database. You will need to implement your own authorization logic on top of this plugin.
fix
Always build your own access control layer or use a separate authentication/authorization system alongside `pouchdb-users`.
affects: >=1.0.0
deprecatedThis package is no longer actively maintained; the last release was in June 2017. This may lead to compatibility issues with newer Node.js versions, updated PouchDB APIs, or potential security vulnerabilities due to unaddressed bugs or outdated dependencies (e.g., in `pbkdf2`).
fix
Consider migrating to more actively maintained PouchDB authentication solutions or developing custom logic for user management if long-term support is critical. Evaluate the risks of using unmaintained software carefully.
affects: >=1.0.6
gotchaThe plugin is designed for PouchDB environments that primarily use CommonJS `require()`. While PouchDB itself has evolved, this plugin might not be directly compatible with pure ESM environments without transpilation or specific build configurations.
fix
Ensure your project's module resolution for PouchDB and its plugins is configured for CommonJS, or use older Node.js versions if encountering module loading issues. Consider using a bundler like Webpack or Rollup to handle compatibility.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: PouchDB.plugin is not a function
PouchDB was not loaded or aliased correctly, or the plugin was attempted to be installed on a database instance instead of the PouchDB constructor.
fix
Ensure `const PouchDB = require('pouchdb')` is called before attempting to install the plugin, and that `PouchDB.plugin()` is used, not `db.plugin()`.
TypeError: db.installUsersBehavior is not a function
The `pouchdb-users` plugin was not successfully installed on the PouchDB constructor before initializing the database instance.
fix
Verify that `PouchDB.plugin(require('pouchdb-users'))` is called prior to `new PouchDB()` or `db = new PouchDB()`.
Error: Document update conflict
Attempted to `put` a user document with an `_id` that already exists without specifying the `_rev` property of the existing document, or without handling the conflict programmatically.
fix
When updating an existing user, retrieve the document first to get its `_rev`, then include `_rev` in the updated document. Alternatively, handle the conflict in your `catch` block.
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies
pouchdbrequiredThis package is a plugin for PouchDB and requires a PouchDB instance to operate.
pbkdf2requiredUsed for password hashing, mirroring CouchDB's password security mechanisms.
pouchdb-mapreduce-utilsrequiredSupports internal PouchDB plugin mechanisms, likely for view-related operations on user documents.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
pouchdb-users — npm install pouchdb-users · libregistry