UNPKG

iota.lib.js

Version:
56 lines (47 loc) 1.62 kB
var utils = require("./utils/utils"); var makeRequest = require('./utils/makeRequest'); var api = require("./api/api"); var Multisig = require('./multisig/multisig'); function IOTA(settings) { this.setSettings(settings); } /** * Reset the libraries settings and internal objects * * @method setSettings * @param {Object} settings **/ IOTA.prototype.setSettings = function(settings) { // IF NO SETTINGS, SET DEFAULT TO localhost:14265 settings = settings || {}; this.version = require('../package.json').version; this.host = settings.host || "http://localhost"; this.port = settings.port || 14265; this.provider = settings.provider || this.host.replace(/\/$/, '') + ":" + this.port; this.sandbox = settings.sandbox || false; this.token = settings.token || false; this.username = settings.username || false; this.password = settings.password || false; if (this.sandbox) { // remove backslash character this.sandbox = this.provider.replace(/\/$/, ''); this.provider = this.sandbox + '/commands'; } this._makeRequest = new makeRequest(this.provider, this.token || this.username, this.password); this.api = new api(this._makeRequest, this.sandbox); // this.mam // this.flash this.utils = utils; this.valid = require("./utils/inputValidator"); this.multisig = new Multisig(this._makeRequest); }; /** * Change the Node the user connects to * * @method changeNode * @param {Object} settings **/ IOTA.prototype.changeNode = function(settings) { this.setSettings(settings); }; module.exports = IOTA;