Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including pfsense-fauxer with all npm packages installed. Try it out:

var pfsenseFauxer = require("pfsense-fauxer")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

pfsense-fauxer v0.2.0

Node library for running pfsense faux API queries

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}));
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free