Skip to content

Commit 58996a8

Browse files
committed
Fix signature error with email in params
There is an issue with signature creation for requests involving emails (subaccount requests). The query params are encoded and then the signature is created from encoded query, but for the signature to be correct, it has to be created on decoded query, and encoded after signature is created. email=xxx%40xxx.com this is encoded, and therefore creates wrong signature, so we need to decode it, when creating the signature. I encountered this only for emails in params, but could also happen in other cases
1 parent 583a34a commit 58996a8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

node-binance-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ let api = function Binance( options = {} ) {
328328
data.timestamp = new Date().getTime() + Binance.info.timeOffset;
329329
if ( typeof data.recvWindow === 'undefined' ) data.recvWindow = Binance.options.recvWindow;
330330
let query = method === 'POST' && noDataInSignature ? '' : makeQueryString( data );
331-
let signature = crypto.createHmac( 'sha256', Binance.options.APISECRET ).update( query ).digest( 'hex' ); // set the HMAC hash header
331+
let signature = crypto.createHmac( 'sha256', Binance.options.APISECRET ).update( decodeURIComponent(query) ).digest( 'hex' ); // set the HMAC hash header
332332
if ( method === 'POST' ) {
333333
let opt = reqObjPOST(
334334
url,

0 commit comments

Comments
 (0)