Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
auth (calc = 0, dms = 0) {
if (!this._isOpen) return Promise.reject(new Error('not open'))
if (this._isAuthenticated) {
return Promise.reject(new Error('already authenticated'))
}
const authNonce = nonce()
const authPayload = `AUTH${authNonce}${authNonce}`
const { sig } = genAuthSig(this._apiSecret, authPayload)
return new Promise((resolve, reject) => {
this.once('auth', () => {
debug('authenticated')
resolve()
})
this.send({
event: 'auth',
apiKey: this._apiKey,
authSig: sig,
authPayload,
authNonce,
dms,
calc
})
auth (calc = 0, dms = 0) {
if (!this._isOpen) return Promise.reject(new Error('not open'))
if (this._isAuthenticated) {
return Promise.reject(new Error('already authenticated'))
}
const authNonce = nonce()
const authPayload = `AUTH${authNonce}${authNonce}`
const { sig } = genAuthSig(this._apiSecret, authPayload)
return new Promise((resolve, reject) => {
this.once('auth', () => {
debug('authenticated')
resolve()
})
this.send({
event: 'auth',
apiKey: this._apiKey,
authSig: sig,
authPayload,
authNonce,
dms,