1.1.0 • Published 5 years ago

@absolunet/lastpass-sdk v1.1.0

Weekly downloads
29
License
MIT
Repository
github
Last release
5 years ago

@absolunet/lastpass-sdk

npm npm dependencies npms Travis CI Code style ESLint

LastPass SDK via lpass(1)

Maps every subcommands from the LastPass CLI and tries to parse the results into Objects

Also contains wrapper functions to help with some shortcomings of the CLI

Install

$ npm install @absolunet/lastpass-sdk

Usage

const lastpass = require('@absolunet/lastpass-sdk');

const { success:logged } = lastpass.login('user@example.com');
if (logged) {

	const results = lastpass.show('site-prod-ubuntu', { password:true });
	if (results.success) {
		console.log(results.data[0].password);
	} else {
		console.error(`Something went wrong: ${results.message}`);
	}
}

API - CLI

  • Uses dargs for arguments mapping
  • Successful calls returns an Object with success:true, raw properties (Some return a data property with parsed data)
  • Failed calls returns an Object with success:false, message properties (Some may also return data, raw if pertinent)

login(username , parameters)

Login to LastPass

username

Required Type: String LastPass username

parameters.password

Type: String LastPass password if you want to skip the manual PIN entry

logout(parameters)

Logout from LastPass

passwd()

Change master password

show(nameOrUniqueId , parameters)

Show entries details Returns data as an Array of Object of entry's fields

nameOrUniqueId

Required Type: String or Array[String] Entry name or unique id

ls(group)

List all entries Returns data as an Array of Object of entry's fields

group

Type: String Group name

mv(uniqueNameOrUniqueId, group , parameters)

Move entry to another group

uniqueNameOrUniqueId

Required Type: String Unique entry name or id

group

Required Type: String Group name

add(nameOrUniqueId , parameters)

Add entry

nameOrUniqueId

Required Type: String Entry name or unique id

edit(nameOrUniqueId , parameters)

Edit entry

nameOrUniqueId

Required Type: String Entry name or unique id

generate(nameOrUniqueId , length)

Generate password Returns data as an Object with password

nameOrUniqueId

Required Type: String Entry name or unique id

length

Type: String Password length Default: 32

duplicate(uniqueNameOrUniqueId , parameters)

Duplicate entry

uniqueNameOrUniqueId

Required Type: String Unique entry name or id

rm(uniqueNameOrUniqueId , parameters)

Remove entry

uniqueNameOrUniqueId

Required Type: String Unique entry name or id

status(parameters)

Check if logged Returns data as an Object with username

sync(parameters)

Synchronize the local cache with the LastPass servers

import(filename , parameters)

Import entries

filename

Required Type: String Path to file to import

export(parameters)

Export entries

shareUserls(share)

List users of a shared folder

share

Required Type: String Shared folder

shareUseradd(share, username , parameters)

Add user to a shared folder

share

Required Type: String Shared folder

username

Required Type: String LastPass username

shareUsermod(share, username , parameters)

Modify user of a shared folder

share

Required Type: String Shared folder

username

Required Type: String LastPass username

shareUserdel(share, username)

Delete user from a shared folder

share

Required Type: String Shared folder

username

Required Type: String LastPass username

shareCreate(share)

Create a shared folder

share

Required Type: String Shared folder

shareRm(share)

Remove a shared folder

share

Required Type: String Shared folder

shareLimit(share, username , sites)

Manipulate account access lists on a shared folder for a specific user

share

Required Type: String Shared folder

username

Required Type: String LastPass username

sites

Required Type: String or Array[String] Sites

API - Helpers

scan(searchInput , options)

Scans for entries via 'lpass show' (IMPORTANT: Must be logged in or will throw an error) Returns an Array of Object of entries fullname and id

searchInput

Required Type: String or Array[String] Entry name or search patterns

options.basicRegexp

Type: Boolean Activate 'lpass show --basic-regexp' flag

options.fixedStrings

Type: Boolean Activate 'lpass show --fixed-strings' flag

License

MIT © Absolunet

1.1.0

5 years ago

1.0.0

5 years ago

0.1.0

5 years ago