From dfb1534d222e55aa6ddfbc112a98e34fa77efe1b Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Wed, 22 Mar 2023 09:44:40 +0000 Subject: [PATCH] fix(): fix unintentional pointer ref, fixes very rare sign issue if request is fired in parallel --- src/util/BaseRestClient.ts | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/util/BaseRestClient.ts b/src/util/BaseRestClient.ts index 923140c..425ce96 100644 --- a/src/util/BaseRestClient.ts +++ b/src/util/BaseRestClient.ts @@ -304,24 +304,31 @@ export default abstract class BaseRestClient { isPublicApi ); - if (!options.headers) { - options.headers = {}; - } - options.headers['ACCESS-KEY'] = this.apiKey; - options.headers['ACCESS-PASSPHRASE'] = this.apiPass; - options.headers['ACCESS-TIMESTAMP'] = signResult.timestamp; - options.headers['ACCESS-SIGN'] = signResult.sign; - options.headers['Content-Type'] = 'application/json'; + const authHeaders = { + 'ACCESS-KEY': this.apiKey, + 'ACCESS-PASSPHRASE': this.apiPass, + 'ACCESS-TIMESTAMP': signResult.timestamp, + 'ACCESS-SIGN': signResult.sign, + 'Content-Type': 'application/json', + }; if (method === 'GET') { return { ...options, + headers: { + ...authHeaders, + ...options.headers, + }, url: options.url + signResult.queryParamsWithSign, }; } return { ...options, + headers: { + ...authHeaders, + ...options.headers, + }, data: params, }; }