bfx-api-node-core
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -75,5 +75,2 @@ 'use strict' | ||
this._agent = agent | ||
this.apiKey = apiKey | ||
this.apiSecret = apiSecret | ||
this.authToken = authToken | ||
this._wsURL = wsURL | ||
@@ -85,3 +82,3 @@ this._transform = transform | ||
this.wsPool = [] | ||
this.authArgs = { dms, calc } | ||
this.authArgs = { apiKey, apiSecret, authToken, dms, calc } | ||
} | ||
@@ -94,2 +91,6 @@ | ||
} | ||
this.wsPool.forEach(s => { | ||
s.authArgs = this.authArgs | ||
}) | ||
} | ||
@@ -131,5 +132,5 @@ | ||
auth ({ apiKey, apiSecret, authToken, dms, calc, forceAuth } = {}) { | ||
if (_isString(apiKey)) this.apiKey = apiKey | ||
if (_isString(apiSecret)) this.apiSecret = apiSecret | ||
if (_isString(authToken)) this.authToken = authToken | ||
if (_isString(apiKey)) this.authArgs.apiKey = apiKey | ||
if (_isString(apiSecret)) this.authArgs.apiSecret = apiSecret | ||
if (_isString(authToken)) this.authArgs.authToken = authToken | ||
if (_isFinite(calc)) this.authArgs.calc = calc | ||
@@ -145,8 +146,6 @@ if (_isFinite(dms)) this.authArgs.dms = dms | ||
...ws, | ||
apiKey: this.apiKey, | ||
apiSecret: this.apiSecret, | ||
authToken: this.authToken | ||
authArgs: this.authArgs | ||
} | ||
authWS(nextWS, this.authArgs) | ||
authWS(nextWS) | ||
this.wsPool[i] = nextWS | ||
@@ -255,7 +254,5 @@ } | ||
agent: this._agent, | ||
apiKey: this.apiKey, | ||
apiSecret: this.apiSecret, | ||
authToken: this.authToken, | ||
transform: this._transform, | ||
plugins: this.plugins | ||
plugins: this.plugins, | ||
authArgs: this.authArgs | ||
}) | ||
@@ -262,0 +259,0 @@ |
@@ -20,3 +20,4 @@ 'use strict' | ||
...prevWSState, | ||
isOpen: true | ||
isOpen: true, | ||
authenticated: false | ||
}) | ||
@@ -28,4 +29,6 @@ | ||
if (m.authToken || (m.apiKey && m.apiSecret)) { | ||
authWS(ws, m.authArgs).then(() => { | ||
const { authToken, apiKey, apiSecret } = ws.authArgs || {} | ||
if (authToken || (apiKey && apiSecret)) { | ||
authWS(ws).then(() => { | ||
debug('authenticated socket %d', id) | ||
@@ -32,0 +35,0 @@ }).catch((err) => { |
@@ -5,4 +5,4 @@ 'use strict' | ||
const getAuthParams = (state, dms, calc) => { | ||
const { apiKey, apiSecret, authToken } = state | ||
const getAuthParams = (authArgs = {}) => { | ||
const { apiKey, apiSecret, authToken, dms = 0, calc = 0 } = authArgs | ||
@@ -9,0 +9,0 @@ const authParams = { |
@@ -20,5 +20,5 @@ 'use strict' | ||
*/ | ||
const auth = (state = {}, { dms = 0, calc = 0 } = {}) => { | ||
const { ev } = state | ||
const authParams = getAuthParams.get(state, dms, calc) | ||
const auth = (state = {}) => { | ||
const { ev, authArgs } = state | ||
const authParams = getAuthParams.get(authArgs) | ||
@@ -25,0 +25,0 @@ send(state, authParams) |
@@ -17,5 +17,6 @@ 'use strict' | ||
* @param {boolean?} opts.transform - if true, raw API data arrays will be automatically converted to bfx-api-node-models instances | ||
* @param {string?} opts.apiKey - for later authentication | ||
* @param {string?} opts.apiSecret - for later authentication | ||
* @param {string?} opts.authToken - for later authentication; takes priority over apiKey and apiSecret | ||
* @param {Object?} opts.authArgs - auth details | ||
* @param {string?} opts.authArgs.apiKey - for later authentication | ||
* @param {string?} opts.authArgs.apiSecret - for later authentication | ||
* @param {string?} opts.authArgs.authToken - for later authentication; takes priority over apiKey and apiSecret | ||
* @param {Object?} opts.plugins - optional set of plugins to use with the connection | ||
@@ -27,5 +28,3 @@ * @return {Object} state | ||
agent, | ||
authToken, | ||
apiKey, | ||
apiSecret, | ||
authArgs = {}, | ||
plugins = {}, | ||
@@ -52,5 +51,3 @@ transform, | ||
authToken, | ||
apiKey, | ||
apiSecret, | ||
authArgs, | ||
transform, | ||
@@ -57,0 +54,0 @@ agent, |
{ | ||
"name": "bfx-api-node-core", | ||
"version": "1.5.1", | ||
"version": "1.5.2", | ||
"description": "Core Bitfinex Node API", | ||
@@ -38,2 +38,3 @@ "engines": { | ||
"devDependencies": { | ||
"bfx-api-mock-srv": "^1.1.4", | ||
"chai": "^4.3.4", | ||
@@ -40,0 +41,0 @@ "jsdoc-to-markdown": "^5.0.1", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
92684
7
2863
1