Registry / database / pouchdb-security

pouchdb-security

JSON →
library4.2.0jsnpmunverified

pouchdb-security (v4.2.0) is a plugin for PouchDB that enforces database access restrictions via a CouchDB-compatible security document. It validates user permissions for read, write, admin roles against the `_security` doc. Part of the PouchDB ecosystem with irregular releases; key differentiator is its server-side enforcement when used with pouchdb-server/express-pouchdb, supporting both Node.js and browser environments.

npm install pouchdb-security
INSTALL
IMPORT
SIG · POUCHDB-SECURITY
P
pouchdb-security
databasejavascriptv4.2.0
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.

default
import Security from 'pouchdb-security'
const Security = require('pouchdb-security')
ESM-only since v4.0.0; CJS require() will fail.
Security
import { Security } from 'pouchdb-security'
import security from 'pouchdb-security'
Package exports a class named 'Security' as default; named import works too.
PouchDB
import PouchDB from 'pouchdb'
const PouchDB = window.PouchDB
In Node.js/bundler, always import PouchDB from 'pouchdb'. For browser, use script tag.

Registers the pouchdb-security plugin, creates a database, sets a security document, and attempts to fetch a document with authentication.

import PouchDB from 'pouchdb'; import Security from 'pouchdb-security'; // Register plugin PouchDB.plugin(Security); const db = new PouchDB('mydb'); // Set security document await db.putSecurity({ admins: { names: ['admin'], roles: [] }, members: { names: ['alice'], roles: ['reader'] } }); // Verify access (server-side only) try { const doc = await db.get('some-doc', { auth: { username: 'alice', password: 'pass' } }); console.log('Access granted'); } catch (err) { console.error('Access denied:', err); }
Debug
Known issues
breakingPackage switched to ESM-only in v4.0.0; CommonJS require() no longer works.
fix
Use import syntax or upgrade to an ESM-compatible environment.
affects: >=4.0.0
gotchaSecurity enforcement only works in a server context (pouchdb-server/express-pouchdb). In browser or Node without server, it does nothing.
fix
Use with pouchdb-server or express-pouchdb to enforce restrictions.
affects: *
deprecatedThe 'auth' option in db.get() and similar methods may be deprecated in future PouchDB versions.
fix
Use a proper authentication proxy or server-side auth middleware.
affects: >=7.0.0
Errors
Common errors & fixes
Error: Cannot find module 'pouchdb-security'
Package not installed or not present in node_modules.
fix
Run 'npm install pouchdb-security' and ensure it is in package.json.
TypeError: PouchDB.plugin is not a function
PouchDB not imported properly or Security plugin registered before PouchDB is available.
fix
Ensure import PouchDB from 'pouchdb' is called before PouchDB.plugin(Security).
SecurityError: No security document found
The '_security' document does not exist in the database.
fix
Call db.putSecurity() with an appropriate security object before enforcing access.
Upgrade
Version history
4.2.0latest on npm
Audit
Dependencies
pouchdbrequiredPeer dependency; required as the database engine.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
pouchdb-security — npm install pouchdb-security · libregistry