Skip to content

Commit

Permalink
Merge pull request #5 from ezewer/fix-nonce
Browse files Browse the repository at this point in the history
Fix nonce
  • Loading branch information
prdn committed Jul 18, 2019
2 parents 212ad47 + c7fab82 commit 9e0d87f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
5 changes: 3 additions & 2 deletions lib/gen_auth_sig.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict'

const crypto = require('crypto')
let nonce = Date.now() * 1000
const getNonce = require('./nonce')

module.exports = (secret, payload = '') => {
const nonce = getNonce()
if (payload.length === 0) {
payload = `AUTH${nonce}${nonce}`
}
Expand All @@ -16,6 +17,6 @@ module.exports = (secret, payload = '') => {
return {
payload,
sig,
nonce: nonce++
nonce: getNonce()
}
}
2 changes: 1 addition & 1 deletion lib/nonce.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let nonce = null

module.exports = () => {
let now = new Date().getTime()
let now = Date.now() * 1000
nonce = (nonce < now) ? now : nonce + 1
return nonce
}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-api-node-util",
"version": "1.0.1",
"version": "1.0.2",
"description": "Utilities for the Bitfinex node API",
"engines": {
"node": ">=7"
Expand All @@ -22,6 +22,7 @@
"BTC"
],
"contributors": [
"Ezequiel Wernicke <ezequiel.wernicke@bitfinex.com> (https://www.bitfinex.com)",
"Josh Rossi <josh@bitfinex.com> (https://www.bitfinex.com)",
"Cris Mihalache <cris.m@bitfinex.com> (https://www.bitfinex.com)",
"Robert Kowalski <robert@bitfinex.com> (https://www.bitfinex.com)",
Expand All @@ -36,7 +37,7 @@
"devDependencies": {
"bfx-api-node-models": "bitfinexcom/bfx-api-node-models",
"chai": "^3.4.1",
"mocha": "^3.4.2",
"mocha": "^6.1.4",
"standard": "^10.0.2"
},
"dependencies": {
Expand Down

0 comments on commit 9e0d87f

Please sign in to comment.