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}));

Readme

Keywords

Package Sidebar

Install

npm i pfsense-fauxer

Weekly Downloads

18

Version

0.2.0

License

MIT

Unpacked Size

740 kB

Total Files

156

Last publish

Collaborators

  • elhigu