Skip to content

Commit

Permalink
(refactor) rm default auth() dms and calc params, use only if provided
Browse files Browse the repository at this point in the history
  • Loading branch information
f3rno authored and JacobPlaster committed Feb 25, 2020
1 parent 4fc33e3 commit 727c5f8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/ws2_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const { EventEmitter } = require('events')
const debug = require('debug')('bfx:ws2:manager')
const _isEqual = require('lodash/isEqual')
const _isFinite = require('lodash/isFinite')
const _includes = require('lodash/includes')
const _pick = require('lodash/pick')
const PromiseThrottle = require('promise-throttle')
Expand Down Expand Up @@ -116,19 +117,17 @@ class WS2Manager extends EventEmitter {
* @param {Object?} args.calc - default 0
* @param {Object?} args.dms - dead man switch, active 4
*/
auth ({ apiKey, apiSecret, calc = 0, dms = 0 } = {}) {
auth ({ apiKey, apiSecret, calc, dms } = {}) {
if (this._socketArgs.apiKey || this._socketArgs.apiSecret) {
debug('error: auth credentials already provided! refusing auth')
return
}

this._socketArgs.apiKey = apiKey
this._socketArgs.apiSecret = apiSecret
this._authArgs = {
...this._authArgs,
calc,
dms,
}

if (_isFinite(calc)) this._authArgs.calc = calc
if (_isFinite(dms)) this._authArgs.dms = dms

this._sockets.forEach(s => {
if (!s.ws.isAuthenticated()) {
Expand Down

0 comments on commit 727c5f8

Please sign in to comment.