Numerous Problems Multiplied
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

pfsense-fauxer

0.2.0 • Public • Published

pfSense faux-api client for Node

Simple client lib for communicating with pfSense faux-api qith node.

const { FauxApi } = require('pfsense-fauxer');
 
/**
 * Example how to implement your custom faux api functions
 */
class Api extends FauxApi {
  async getCerts() {
    const config = await this.functionCall('parse_config');
    return config.data.return.cert;
  }
}
 
/**
 * Options
 *
 * host: https://mypfsense.sensetive.org
 * key: '<faux api key>'
 * secret: '<faux api secret>'
 * path?: defaults to /fauxapi/v1
 * timeout?: defaults to 15000
 * fakeTimestamp?:
 *   Date object to use in header generation.
 *   Defaults to false. Used for testing and debugging.
 * fakeNonce?:
 *   Nonce seed to use in header generation.
 *   Defaults to false. Used for testing and debugging.
 */
const api = new Api({
  host: 'https://mypsfsensehostname.example.org',
  allowSelfSignedSsl: true,
  key: '<fauxapikey>',
  secret: '<fauxapisecret>'
});
 
// api.functionCall('<function name>', '<arg1>', '<arg2>', '<arg3>', '<arg4>', ...) 
api.functionCall('openvpn_get_active_servers')
  .then(r => console.dir(r.data, {colors: true, depth: null}))
  .catch(err => console.dir(err.response.data, {colors: true, depth: null}));

install

npm i pfsense-fauxer

Downloadsweekly downloads

4

version

0.2.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability