@absolunet/lastpass-sdk 中文文档教程
@absolunet/lastpass-sdk
映射来自 LastPass CLI 并尝试将结果解析为对象
还包含包装函数以帮助解决 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 adata
property with parsed data) - Failed calls returns an Object with
success:false
,message
properties (Some may also returndata
,raw
if pertinent)
login(username [, parameters])
登录到 LastPass
username
的一些缺点必需
类型:字符串
LastPass 用户名
parameters.password
类型:String
如果您想跳过手动 PIN 输入
,请输入 LastPass 密码
logout([parameters])
从 LastPass 注销
passwd()
更改主密码
show(nameOrUniqueId [, parameters])
显示条目详细信息
将数据作为条目字段的 Object
的 Array
返回
nameOrUniqueId
Required
类型:String
或 Array[String]
条目名称或唯一 ID
ls([group] [, parameters])
列出所有条目 以条目字段的 Object
的 Array
形式返回数据
group
类型:String
组名
mv(uniqueNameOrUniqueId, group [, parameters])
将条目移动到另一个组
uniqueNameOrUniqueId
必需
类型:字符串
唯一条目名称或 ID
group
必需
类型:字符串
群组名称
add(nameOrUniqueId [, parameters])
添加条目
nameOrUniqueId
必需
类型:字符串
条目名称或唯一 ID
edit(nameOrUniqueId [, parameters])
编辑条目
nameOrUniqueId
必需
类型:字符串
条目名称或唯一 ID
generate(nameOrUniqueId [, length] [, parameters])
生成密码 将数据作为 Object
返回,密码
nameOrUniqueId
Required
类型:字符串
条目名称或唯一 ID
length
类型:String
密码长度
默认值:32
duplicate(uniqueNameOrUniqueId [, parameters])
重复条目
uniqueNameOrUniqueId
必需
类型:字符串
唯一条目名称或 ID
rm(uniqueNameOrUniqueId [, parameters])
删除条目
uniqueNameOrUniqueId
必需
类型:字符串
唯一条目名称或 ID
status([parameters])
检查是否已记录 将数据作为 Object
返回,用户名
sync([parameters])
将本地缓存与 LastPass 服务器同步
import(filename [, parameters])
导入条目
filename
必需
类型:字符串
要导入的文件路径
export([parameters])
导出条目
shareUserls(share)
列出共享文件夹的用户
share
必需
类型:字符串
共享文件夹
shareUseradd(share, username [, parameters])
将用户添加到共享文件夹
share
必需
类型:字符串
共享文件夹
username
必需
类型:字符串
LastPass 用户名
shareUsermod(share, username [, parameters])
修改共享文件夹的用户
share
必需
类型:字符串
共享文件夹
username
必需
类型:字符串
LastPass 用户名
shareUserdel(share, username)
从共享文件夹中删除用户
share
必需
类型:字符串
共享文件夹
username
必需
类型:字符串
LastPass 用户名
shareCreate(share)
创建共享文件夹
share
必需
类型:字符串
共享文件夹
shareRm(share)
删除共享文件夹
share
必需
类型:字符串
共享文件夹
shareLimit(share, username [, sites] [, parameters])
为特定用户管理共享文件夹上的帐户访问列表
share
必需
类型:字符串
共享文件夹
username
必需
类型:字符串
LastPass 用户名
sites
必填
类型:String
或 Array[String]
站点
API - Helpers
scan(searchInput [, options])
通过“lpass show”扫描条目(重要信息:必须登录,否则将引发错误)对象
的数组
searchInput
返回条目全名和 ID
必需
类型:String
或 Array[String]
条目名称或搜索模式
options.basicRegexp
类型:Boolean
激活“lpass show --basic-regexp”标志
options.fixedStrings
类型:Boolean
激活“lpass show --fixed-strings”标志
License
MIT © Absolunet
@absolunet/lastpass-sdk
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 adata
property with parsed data) - Failed calls returns an Object with
success:false
,message
properties (Some may also returndata
,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] [, parameters])
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] [, parameters])
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] [, parameters])
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