1.0.0 • Published 8 years ago

webpasswordsafe v1.0.0

Weekly downloads
1
License
MIT
Repository
gitlab
Last release
8 years ago

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

NameTypeDescription
idnumberInternal ID of the password, primarly used to retrieve it's value after finding it.
titlestringThe password's name.
usernamestringUsername this password belongs to.
notesstringAdditional information users might need to know about, for example how and where to use these credentials.
tagsArray.<string>Array of space-seperated tags set for this password.
activebooleanWether or not this password is active and visible.
valuestringThe 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

new WPS(options)

Create an instance of the WebPasswordStore client.

ParamTypeDescription
options
options.urlstringURL to a WebPasswordStore. This should not include the final '/rest/' bit of the URL.
options.usernamestringUsername to login with.
options.passwordstringPassword 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.*anyAny 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

ParamTypeDescription
querystringSearch Query.

WPS.getPassword(passwordId, includeValue) ⇒ Promise.<Password>

Get a single password.

Kind: instance method of WPS
Returns: Promise.<Password> - The password

ParamTypeDescription
passwordIdnumberThe internal ID of the password, for example returned as the password.id field from getPasswordList
includeValuebooleanIf 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.

ParamTypeDescription
passwordIdnumberThe 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.

ParamTypeDescription
passwordPasswordThe 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.

ParamTypeDescription
passwordPasswordThe password to update.
1.0.0

8 years ago