From 407beeca0cdc16c99780efb68a8e31d01602f6b2 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Thu, 12 Feb 2026 10:58:15 +0000 Subject: [PATCH 1/4] chore: dependency audit bumps --- package-lock.json | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index e501b18..1d437cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2034,16 +2034,17 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" }, "node_modules/axios": { - "version": "1.12.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.12.2.tgz", - "integrity": "sha512-vMJzPewAlRyOgxV2dU0Cuz2O8zzzx9VYtbJOaBgXFeLc4IV/Eg50n4LowmehOOR61S8ZMpc2K5Sa7g6A4jfkUw==", + "version": "1.13.5", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.5.tgz", + "integrity": "sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q==", "license": "MIT", "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.4", + "follow-redirects": "^1.15.11", + "form-data": "^4.0.5", "proxy-from-env": "^1.1.0" } }, @@ -2445,6 +2446,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" }, @@ -2569,6 +2571,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", "engines": { "node": ">=0.4.0" } @@ -2583,10 +2586,11 @@ } }, "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz", + "integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" } @@ -3263,15 +3267,16 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "version": "1.15.11", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", + "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", "funding": [ { "type": "individual", "url": "https://github.com/sponsors/RubenVerborgh" } ], + "license": "MIT", "engines": { "node": ">=4.0" }, @@ -3282,9 +3287,9 @@ } }, "node_modules/form-data": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", - "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", "license": "MIT", "dependencies": { "asynckit": "^0.4.0", From b15806bb7a6c9f7ca3ad822860113e56a0d87b6d Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Thu, 12 Feb 2026 11:59:41 +0000 Subject: [PATCH 2/4] chore: refactor getNormalised method as exported --- src/lib/BaseWSClient.ts | 34 ++++++----------------------- src/lib/websocket/websocket-util.ts | 27 +++++++++++++++++++++++ 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/lib/BaseWSClient.ts b/src/lib/BaseWSClient.ts index c0efed9..83f03ec 100644 --- a/src/lib/BaseWSClient.ts +++ b/src/lib/BaseWSClient.ts @@ -14,6 +14,7 @@ import { WSTopic } from '../types/websockets/ws-subscriptions.js'; import { checkWebCryptoAPISupported } from './webCryptoAPI.js'; import { DefaultLogger } from './websocket/logger.js'; import { + getNormalisedTopicRequests, safeTerminateWs, WSOperation, WSTopicRequest, @@ -155,33 +156,6 @@ function getFinalEmittable( }; } -/** - * Users can conveniently pass topics as strings or objects (object has topic name + optional params). - * - * This method normalises topics into objects (object has topic name + optional params). - */ -function getNormalisedTopicRequests( - wsTopicRequests: WSTopicRequestOrStringTopic[], -): WSTopicRequest[] { - const normalisedTopicRequests: WSTopicRequest[] = []; - - for (const wsTopicRequest of wsTopicRequests) { - // passed as string, convert to object - if (typeof wsTopicRequest === 'string') { - const topicRequest: WSTopicRequest = { - topic: wsTopicRequest as WSTopic, - payload: undefined, - }; - normalisedTopicRequests.push(topicRequest); - continue; - } - - // already a normalised object, thanks to user - normalisedTopicRequests.push(wsTopicRequest); - } - return normalisedTopicRequests; -} - // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging export abstract class BaseWebsocketClient< TWSKey extends string, @@ -218,15 +192,20 @@ export abstract class BaseWebsocketClient< pingInterval: 10000, reconnectTimeout: 500, recvWindow: 5000, + // Requires a confirmation "response" from the ws connection before assuming it is ready requireConnectionReadyConfirmation: false, + // Automatically auth after opening a connection? authPrivateConnectionsOnConnect: false, + // Automatically include auth/sign/token with every WS request. // Automatically handled during getWsRequestEvents. authPrivateRequests: true, + // Automatically re-auth WS API, if we were auth'd before and get reconnected reauthWSAPIOnReconnect: true, + // Whether to use native heartbeats (depends on the exchange) useNativeHeartbeats: true, @@ -1112,6 +1091,7 @@ export abstract class BaseWebsocketClient< } catch (e) { this.logger.error( 'Exception trying to resolve "connectionInProgress" promise', + e, ); } } diff --git a/src/lib/websocket/websocket-util.ts b/src/lib/websocket/websocket-util.ts index eadc4de..dd60125 100644 --- a/src/lib/websocket/websocket-util.ts +++ b/src/lib/websocket/websocket-util.ts @@ -120,3 +120,30 @@ export function getPromiseRefForWSAPIRequest( ); return promiseRef; } + +/** + * Users can conveniently pass topics as strings or objects (object has topic name + optional params). + * + * This method normalises topics into objects (object has topic name + optional params). + */ +export function getNormalisedTopicRequests( + wsTopicRequests: WSTopicRequestOrStringTopic[], +): WSTopicRequest[] { + const normalisedTopicRequests: WSTopicRequest[] = []; + + for (const wsTopicRequest of wsTopicRequests) { + // passed as string, convert to object + if (typeof wsTopicRequest === 'string') { + const topicRequest: WSTopicRequest = { + topic: wsTopicRequest as WSTopic, + payload: undefined, + }; + normalisedTopicRequests.push(topicRequest); + continue; + } + + // already a normalised object, thanks to user + normalisedTopicRequests.push(wsTopicRequest); + } + return normalisedTopicRequests; +} From e66aca9c0f5ff18c30d6bfab54b5a2803b005491 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Thu, 12 Feb 2026 12:01:20 +0000 Subject: [PATCH 3/4] chore: test logging --- test/REST/private.futures.write.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/REST/private.futures.write.test.ts b/test/REST/private.futures.write.test.ts index 2456269..327fe38 100644 --- a/test/REST/private.futures.write.test.ts +++ b/test/REST/private.futures.write.test.ts @@ -375,7 +375,7 @@ describe('REST PRIVATE FUTURES WRITE', () => { }); } catch (e: any) { // Expected - validates signature is correct - //console.log(`err "${expect.getState().currentTestName}"`, e?.body || e); + console.log(`err "${expect.getState().currentTestName}"`, e?.body || e); const responseBody = e?.body; expect(responseBody).toMatchObject({ result: 'error', From 21ccf8d1786f2f80039d521933c7d993b97214c3 Mon Sep 17 00:00:00 2001 From: Tiago Siebler Date: Thu, 12 Feb 2026 12:05:13 +0000 Subject: [PATCH 4/4] chore: update test --- test/REST/private.futures.write.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/REST/private.futures.write.test.ts b/test/REST/private.futures.write.test.ts index 327fe38..95997d1 100644 --- a/test/REST/private.futures.write.test.ts +++ b/test/REST/private.futures.write.test.ts @@ -375,11 +375,17 @@ describe('REST PRIVATE FUTURES WRITE', () => { }); } catch (e: any) { // Expected - validates signature is correct - console.log(`err "${expect.getState().currentTestName}"`, e?.body || e); + // console.log(`err "${expect.getState().currentTestName}"`, e?.body || e); const responseBody = e?.body; + expect(responseBody).toMatchObject({ result: 'error', - error: expect.stringContaining('invalidArgument'), + }); + + const firstError = responseBody?.errors?.[0]; + expect(firstError).toMatchObject({ + code: expect.any(Number), + message: expect.stringContaining('Invalid UUID'), }); } });