binance / binance-futures-connector-node

Simple NodeJS connector to Binance Futures API
MIT License
16 stars 6 forks source link

Add Type Validation for `listenKey` Parameter in User Data Stream Methods #17

Open Mohamednowfil opened 6 days ago

Mohamednowfil commented 6 days ago

Issue Description:

The listenKey parameter, used in the renewListenKey and closeListenKey methods, is not validated for its type before being used in API requests. This can lead to potential runtime errors if listenKey is not a valid string, causing failures or unexpected behavior when interacting with the API.

Problem:

The listenKey is being passed directly into API requests without validating if it's a string. This may cause issues if the listenKey is not properly validated, especially if a non-string value is provided.

Suggested Fix:

Add a type validation for listenKey to ensure that it is always a string before being used in API requests.

Example Fix:


// Before:
validateRequiredParameters({ listenKey });

// ToFix:
if (typeof listenKey !== 'string') {
  throw new Error('ListenKey must be a string');
}
validateRequiredParameters({ listenKey });
Mohamednowfil commented 6 days ago

I not created in ai and other suggestion see in Object.assign I already created issue for that

I reviewed the changes in commit jjyutm4532@e9c291c and it look good.

Thanks your quick response

alplabin commented 7 hours ago

It has been updated in v0.1.6