Keep your password safe. It's pastore API. you can write your own app by using this module.
npm install --save pastore
import pastore from 'pastore';
Return: Boolean
Check whether pastore need configuration or not.
Example:
if (pastore.needInit) {
console.log('You should initialize pastore');
} else {
console.log('everthing is ready');
}
Usage: pastore.init(password, algorithm)
Return: Promise
Arguments:
password
: typeString
, required. It's master password.algorithm
: typeString
, required. Encryption algorithm. Available algorithms:AES
,DES
,TripleDES
,RC4
,RC4Drop
,Rabbit
,RabbitLegacy
.
Initialize pastore with your master password.
You only need initializing if needInit is true. In other words, you only need initializing if it's first time and pastore need config, and you must initialize. you can know about first time or not, with pastore.needInit
property. if you have not initialized your pastore, module does not work functionally.
Example:
if (pastore.needInit) {
pastore.init('yourmasterpassword', 'Rabbit').then(() => {
// Do what you want to do
}).catch(error => { console.log(error); })
} else {
console.log('pooof, nothing to do');
}
Usage: pastore.load(password)
Return: Promise
Promise
will reject if you enter incorrect password.
Arguments:
password
: typeString
, required. It's master password.
Load database.
Example:
if (pastore.needInit) {
pastore.init('yourmasterpassword', 'Rabbit').then(() => {
// Do what you want to do
}).catch(error => { console.log(error); })
} else {
pastore.load('icantremember').then(() => {
console.log('password was correct');
}).catch(err => {
console.log(err);
});
}
Usage: pastore.clear()
Return: Promise
Reset pastore to default. everything include database, will be removed and reset.
These below methods must run after initializing or loading database.
Usage: pastore.add(title, password, [info], [tag]).then(pass).catch(err)
Return: Promise
Arguments:
title
: typeString
, required. title of password. title must be unique.password
: typeString
, required. password.info
: typeString
, optional, defaultnull
. more information for password like email, site address or etc.tag
: typeArray
, optional, defaultnull
. password tag.
Arguments to Promise:
pass
: typeObject
. Password object which is saved.err
: typeTypeError
. It will occur if there is a another password with same title.
Add a password.
Usage: pastore.remove(title)
Return: Promise
Arguments:
title
: typeString
, required. password title.
Remove a password.
Usage: pastore.removeByTag(tag)
Return: Promise
Arguments:
tag
: typeString
, required. password tag.
Remove passwords which they have specified tag.
Usage: pastore.update(title, update)
Return: Promise
Arguments:
title
: typeString
, required. password title.update
: typeObject
, required. object will be replaced with old stuff.
Update a password.
Example:
import pastore from 'pastore';
pastore.load('something').then(async () => {
await pastore.add('twitter', '123123');
pastore.update('twitter', {title: 'tweet', password: '173532'});
});
Usage: pastore.find(title)
Return: Object
or undefined
.
Return undefined when there is no password with the title
.
Arguments:
title
: typeString
, required. key for searching, like title.
Search and find password by specified title, like searching for a password that it has twitter as title.
Example:
import pastore from 'pastore';
pastore.init('something', 'AES').then(aync () => {
await pastore.add('twitter', '123123');
pastore.find('twitter');
/*
* return
*
* { title: 'twitter', password: '123123', info: ''},
*
*/
pastore.find('facebook');
/**
* return undefined
*/
});
Usage: pastore.findByTag(tag)
Return: Array
Arguments:
tag
: typeString
, required. password tag.
Return passwords which they have specified tag.
Usage: pastore.findPasswords()
Return: Array
Return all passwords.
Usage: pastore.findTitles()
Return: Array
Return only titles.
Usage: pastore.changePassword(password)
Return: Promise
Arguments:
password
: typeString
, required. new password.
Change password, master one.
Usage: pastore.changeAlgorithm(algorithm)
Return: Promise
Arguments:
algorithm
: typeString
, required. new algorithm. Available algorithms:AES
,DES
,TripleDES
,RC4
,RC4Drop
,Rabbit
,RabbitLegacy
.
Change encryption algorithm.
Usage: pastore.exportDB()
Return: String
Export encrypted database.
Usage: pastore.importDB(db, password, algorithm)
Return: Promise
Arguments:
db
: typeString
, required. encrypted database.password
: typeString
, required.db
master password.algorithm
: typeString
, required.db
algorithm encryption.
Import database.
Any ideas and pull requests is appreciated. read CONTRIBUTING.md
MIT