pastore v0.4.7
pastore
Keep your password safe. It's pastore API. you can write your own app by using this module.
App using pastore
Installation
npm install --save pastore
Usage
import pastore from 'pastore';
Property
needInit
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');
}
Methods
init
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');
}
load
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);
});
}
clear
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.
add
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.
remove
Usage: pastore.remove(title)
Return: Promise
Arguments:
title
: typeString
, required. password title.
Remove a password.
removeByTag
Usage: pastore.removeByTag(tag)
Return: Promise
Arguments:
tag
: typeString
, required. password tag.
Remove passwords which they have specified tag.
update
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'});
});
find
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
*/
});
findByTag
Usage: pastore.findByTag(tag)
Return: Array
Arguments:
tag
: typeString
, required. password tag.
Return passwords which they have specified tag.
findPasswords
Usage: pastore.findPasswords()
Return: Array
Return all passwords.
findTitles
Usage: pastore.findTitles()
Return: Array
Return only titles.
changePassword
Usage: pastore.changePassword(password)
Return: Promise
Arguments:
password
: typeString
, required. new password.
Change password, master one.
changeAlgorithm
Usage: pastore.changeAlgorithm(algorithm)
Return: Promise
Arguments:
algorithm
: typeString
, required. new algorithm. Available algorithms:AES
,DES
,TripleDES
,RC4
,RC4Drop
,Rabbit
,RabbitLegacy
.
Change encryption algorithm.
exportDB
Usage: pastore.exportDB()
Return: String
Export encrypted database.
importDB
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.
Contributing
Any ideas and pull requests is appreciated. read CONTRIBUTING.md
LICENSE
MIT
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago