@nishantwrp/bwfs
v0.1.0
Published
A high-level, key-value pair based virtual file system library for Bitwarden
Downloads
10
Maintainers
Readme
@nishantwrp/bwfs
A high-level, key-value pair based virtual file system (VFS) library for Bitwarden. @nishantwrp/bwfs allows you to treat Bitwarden Folders as "universes" and Secure Notes as "files" containing arbitrary key-value pairs.
Features
- Virtual File System Abstraction: Maps Bitwarden folders to directories and secure notes to files.
- Key-Value Pair Storage: Efficiently stores and retrieves multiple key-value pairs within a single Bitwarden secure note.
- Base64 Encoding: Automatically handles encoding of keys and values for safe storage in Bitwarden notes.
- Metadata Support: Allows attaching arbitrary JSON metadata to both folders and files.
- Bundled Bitwarden CLI: Uses a bundled and isolated Bitwarden CLI for all operations.
- Sandboxed: Supports custom data directories to avoid interfering with system-wide Bitwarden configurations.
Installation
npm install bwfsUsage
import { BWFS } from 'bwfs';
const bwfs = new BWFS({ dataDir: './custom-data' });
// Login and Unlock
await bwfs.login(clientId, clientSecret);
const session = await bwfs.unlock(masterPassword);
// Create a folder (Universe)
const folder = await bwfs.createFolder('My Universe', { version: '1.0' });
// Create a file (Project)
const file = await bwfs.createFile('My Project', { type: 'env' }, folder.id);
// Set key-value pairs
await bwfs.setKeyValuePairs(file.id, [
{ key: 'DB_URL', value: 'postgresql://localhost:5432' },
{ key: 'API_KEY', value: 'secret-token' }
]);
// Get key-value pairs
const pairs = await bwfs.getKeyValuePairs(file.id);
console.log(pairs);License
ISC
