myuserstorage
v1.0.1
Published
A simple user storage library with encryption support
Downloads
4
Readme
myuserstorage
A simple user storage library with encryption support for Node.js using SQLite.
Features
- Supports bcrypt, argon2, pbkdf2, and scrypt for password encryption.
- Provides a simple CRUD interface for user data.
- Uses SQLite for lightweight storage.
Installation
npm install myuserstorage
Usage
const { UserManager } = require('myuserstorage');
const userManager = new UserManager('path/to/your/database.db');
// Create a new user
userManager.createUser('newuser', 'newpassword')
.then(user => console.log('Created user:', user))
.catch(err => console.error(err));
// Get a user by username
userManager.getUserByUsername('newuser')
.then(user => console.log('User:', user))
.catch(err => console.error(err));
// Update a user password
userManager.updateUser('newuser', 'updatedpassword')
.then(result => console.log('Updated user:', result))
.catch(err => console.error(err));
// Delete a user by username
userManager.deleteUser('newuser')
.then(result => console.log('Deleted user:', result))
.catch(err => console.error(err));
Configuration
Set the encryption type and options using environment variables. Create a .env file in your project root:
.env
ENCRYPTION_TYPE=bcrypt
SALT_ROUNDS=10
PBKDF2_ITERATIONS=100000
Supported encryption types are bcrypt, argon2, pbkdf2, and scrypt.