From 7289fc33ba836b1ca6002d2874452c6df9b8044f Mon Sep 17 00:00:00 2001 From: TS Date: Tue, 4 May 2021 23:14:11 +0100 Subject: [PATCH 1/2] fix(#10): signature error for param-less non-GET requests --- package.json | 2 +- src/util/requestWrapper.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 48f1ec3..462f8e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ftx-api", - "version": "1.0.6", + "version": "1.0.7-beta.1", "description": "Node.js connector for FTX's REST APIs and WebSockets", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/util/requestWrapper.ts b/src/util/requestWrapper.ts index 96e57ec..a615e2d 100644 --- a/src/util/requestWrapper.ts +++ b/src/util/requestWrapper.ts @@ -174,11 +174,11 @@ export default class RequestUtil { }; } - getRequestSignature( + private getRequestSignature( method: Method, endpoint: string, - secret: string | undefined, - params: string | object = '' + secret?: string | undefined, + params?: string | object ): { timestamp: number; sign: string; } { const timestamp = Date.now() + (this.timeOffset || 0); if (!secret) { @@ -188,7 +188,10 @@ export default class RequestUtil { }; } - const paramsPayload = method == 'GET' ? params : JSON.stringify(params); + const paramsPayload = method === 'GET' + ? params + : params ? JSON.stringify(params) : ''; + const signature_payload = `${timestamp}${method}/api/${endpoint}${paramsPayload}`; return { timestamp, From 09dcacc244a56971c489550d1830a4e60fc95c8d Mon Sep 17 00:00:00 2001 From: TS Date: Wed, 5 May 2021 20:49:10 +0100 Subject: [PATCH 2/2] v1.0.7: fix sign error for some request scenarios --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 462f8e3..c7861dd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ftx-api", - "version": "1.0.7-beta.1", + "version": "1.0.7", "description": "Node.js connector for FTX's REST APIs and WebSockets", "main": "lib/index.js", "types": "lib/index.d.ts",