lastpass
v1.0.2lastpass-node
Lastpass client for Node.js
About
I always see people using other password integrations with Node.js, like 1Password, and that made me sad. I really like Lastpass, but it seems they aren't too dev friendly. This changes that! Now it's extremely easy to access your Lastpass Vault, securely, and with a promised based API.
Getting started
Install and save the package
npm i -S lastpass
Import the package
import Lastpass from 'lastpass'; // ES6 // OR var Lastpass = require('lastpass').default; // ES5
Instantiate the class
Lastpass
const lpass = new Lastpass();
Methods
new Lastpass([username])
Parameters:
username
: Lastpass account username (probably an email) used to set the account from which to load a vault blob file (if it exists);- Type: string
- Required: false
loadVault(username, password, [twoFactor])
Parameters:
username
: Lastpass account username (probably an email)- Type: string
- Required: true
password
: Lastpass account password- Type: string
- Required: true
twoFactor
: Two factor authentication pin (if it's needed and none is provided an error will be thrown)- Type: string
- Required: false
Returns:
Promise
: resolves toundefined
loadVaultFile([vaultFile])
Parameters:
vaultFile
: Absolute path to location of a stored vault blob. Defaults to~/.lastpass-vault-${USERNAME}
if a username is set, otherwise to~/.lastpass-vault
.- Type: string
- Required: false
Returns:
Promise
: resolves toundefined
saveVaultFile([vaultFile, options])
Parameters:
vaultFile
: Absolute path to store a vault blob file. Defaults to~/.lastpass-vault-${USERNAME}
if a username is set, otherwise to~/.lastpass-vault
.- Type: string
- Required: false
options
: File options for saving the file. Defaults to{ encoding: 'binary', mode: 0o400 }
for safe keeping.- Type: object
- Required: false
Returns:
Promise
: resolves toundefined
getVault()
Parameters:
- none
Returns:
Buffer
: encrypted contents of the vault blob from Lastpass
getAccounts(username, password, [search])
Parameters:
username
: Lastpass account username (probably an email)- Type: string
- Required: true
password
: Lastpass account password- Type: string
- Required: true
search
: Object containing akeyword
to search for andoptions
forfuzzaldrin
. If a this object isn't provided, or akeyword
isn't set all accounts will be returned. Theoptions
object defaults to{ key: 'name' }
.- Type: object
- Required: false
Returns:
Promise
: resolves to anArray
of matched accounts
Credit
This wouldn't be possible without the amazing lastpass-ruby
and
lastpass-cli
.
Metadata
- MIT
- Whatever
- Dylan Frankland
- released 8/5/2016