Very simple password manager for my js projects.
I often forgot the passwords in my scripts and committed them to the repository. So I created a simple password manager so that it doesn't happen to me anymore.
Create file mypwd.json
with passwords in your $HOME
directory. For example C:\Users\jarberan\mypwd.json
{
"mongo-uat": {
"login": "appl",
"password": "hS78#pbTgc#J.CQL",
"server": "myserver-uat.com"
},
"mongo-dev": {
"login": "appl",
"password": "VacK>p3k3~t*c~RX",
"server": "myserver-dev.com",
"note": "Valid until end of month"
}
}
Now you can access your secrets from js code and you will never commit secret anymore.
const mypwd = require('@berk76/mypwd');
let login, password, server;
[login, password, server] = mypwd.getValues('mongo-uat', ['login', 'password', 'server']);
You should store your passwords in encrypted file mypwd.json.gpg
instead of in plain text file mypwd.json
.
- install GPG (if you are using GitBash you probably have gpg already installed)
- create key-pair
gpg --gen-key
- encrypt your passwords
gpg --output mypwd.json.gpg --encrypt --recipient your@email.com mypwd.json
- try to decrypt it
gpg --decrypt mypwd.json.gpg
- finally you can remove plain text file
rm mypwd.json
and mypwd will usemypwd.json.gpg
Installation is simple:
npm install @berk76/mypwd
Feel free create issue or pull request.