A native Node module to get, add, replace, and delete passwords in system's keychain. On OS X the passwords are managed by the Keychain, on Linux they are managed by the Secret Service API/libsecret, and on Windows they are managed by Credential Vault.
npm install keytar
Currently this library uses libsecret
so you may need to install it before npm install
ing.
Depending on your distribution, you will need to run the following command:
- Debian/Ubuntu:
sudo apt-get install libsecret-1-dev
- Red Hat-based:
sudo yum install libsecret-devel
- Arch Linux:
sudo pacman -S libsecret
- Clone the repository
- Run
npm install
- Run
grunt
to compile the native and CoffeeScript code - Run
grunt test
to run the specs
keytar = require 'keytar'
Get the stored password for the service
and account
.
service
- The string service name.
account
- The string account name.
Returns the string password or null
on failures.
Add the password
for the service
and account
to the keychain.
service
- The string service name.
account
- The string account name.
password
- The string password.
Returns true
on success, false
on failure.
Delete the stored password for the service
and account
.
service
- The string service name.
account
- The string account name.
Returns true
if a password has been deleted, or false
on failure.
Replace the password
for the service
and account
in the keychain.
This is a simple convenience function that internally calls
deletePassword(service, account)
followed by
addPassword(service, account, password)
.
service
- The string service name.
account
- The string account name.
password
- The string password.
Returns true
on success, false
on failure.
Find a password for the service
in the keychain.
service
- The string service name.
Returns the string password or null
on failures.