webpasswordsafe
v1.0.0
Published
A Javascript binding for https://github.com/joshdrummond/webpasswordsafe 's API
Downloads
4
Readme
webpasswordsafe
Simple API Wrapper for WebPasswordSafe, an online Java-based password store.
Requirements
- Node >= 8.0 (It doesn't use any too modern JavaScript features, but I haven't tried it. Good luck!)
- Depends on axios for all the heavy networking stuff.
Installation
$ npm install webpasswordsafe
Classes
Password
This is a description of the password objects returned and consumed by the WebPasswordSafe-API.
Kind: global interface
Properties
| Name | Type | Description |
| --- | --- | --- |
| id | number | Internal ID of the password, primarly used to retrieve it's value after finding it. |
| title | string | The password's name. |
| username | string | Username this password belongs to. |
| notes | string | Additional information users might need to know about, for example how and where to use these credentials. |
| tags | Array.<string> | Array of space-seperated tags set for this password. |
| active | boolean | Wether or not this password is active and visible. |
| value | string | The actual 'value' of the password, the password itself. This is only included by getPassword when the includePassword
option is set, otherwise WPS#getPasswordValue should be used. |
WPS
Kind: global class
- WPS
- new WPS(options)
- .getPasswordList(query) ⇒ Promise.<Array.<Password>>
- .getPassword(passwordId, [includeValue]) ⇒ Promise.<Password>
- .getCurrentPassword(passwordId) ⇒ Promise.<string>
- .addPassword(password) ⇒ Promise.<Password>
- .updatePassword(password) ⇒ Promise.<Password>
new WPS(options)
Create an instance of the WebPasswordStore client.
| Param | Type | Description |
| --- | --- | --- |
| options | | |
| options.url | string | URL to a WebPasswordStore. This should not include the final '/rest/' bit of the URL. |
| options.username | string | Username to login with. |
| options.password | string | Password of the user. Note that this will be sent - as any other passwords - in plain text, so using an https url is strongly recommended. |
| options.* | any | Any other arguments are passed into axios.create()
. |
Example
const https = require('https');
const wps = require('webpasswordsafe')({
url: 'https://pwstore.local:8443/',
username: 'jack',
password: '*********',
// pass this to allow self-signed certificates.
// httpsAgent: new https.Agent({ rejectUnauthorized: false })
});
// search all passwords matching 'npm'
wps.getPasswordList('npm')
.then(passwords => Promise.all(passwords.map(password =>
// get the actual password for each of them
wps.getCurrentPassword(password.id, true)
.then(value => {
// convert this value to an object containing the interesting bits
return {
title: password.title,
username: password.username,
value: value
};
})
)))
// here we get a promise that is resolved once all password values are converted
.then(passwordsData => {
passwordsData.forEach(password => {
// print all the passwords!
console.log(password.title, '::', password.username, '::', password.value);
})
})
WPS.getPasswordList(query) ⇒ Promise.<Array.<Password>>
Search for passwords on the server. This is equivalent of using the search function in the client app. The passwords returned by this function do not include their value. To get the actual password, use the getPassword or getCurrentPassword functions.
Kind: instance method of WPS
Returns: Promise.<Array.<Password>> - A list of passwords matching query
| Param | Type | Description | | --- | --- | --- | | query | string | Search Query. |
WPS.getPassword(passwordId, [includeValue]) ⇒ Promise.<Password>
Get a single password.
Kind: instance method of WPS
Returns: Promise.<Password> - The password
| Param | Type | Description | | --- | --- | --- | | passwordId | number | The internal ID of the password, for example returned as the password.id field from getPasswordList | | [includeValue] | boolean | If this is a truthy value, an additional request will be made and the resulting Password will have it's value property set. |
WPS.getCurrentPassword(passwordId) ⇒ Promise.<string>
Get only the value of a password.
Kind: instance method of WPS
Returns: Promise.<string> - The password's value.
| Param | Type | Description | | --- | --- | --- | | passwordId | number | The internal ID of the password, for example returned as the password.id field from getPasswordList |
WPS.addPassword(password) ⇒ Promise.<Password>
Add a password to the WebPasswordSafe and grant the logged in user permissions to it. Unfortunately, there is no way to set additional permission using the API.
Kind: instance method of WPS
Returns: Promise.<Password> - The newly safed password, including their id.
| Param | Type | Description | | --- | --- | --- | | password | Password | The password to add. Note that the id field will be ignored. |
WPS.updatePassword(password) ⇒ Promise.<Password>
Update password data. Passwords are matched by their id. Note that this might be broken: https://github.com/joshdrummond/webpasswordsafe/issues/120
Kind: instance method of WPS
Returns: Promise.<Password> - The newly updated password, without the actual value.
| Param | Type | Description | | --- | --- | --- | | password | Password | The password to update. |