New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

binance

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

binance - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

5

lib/coinm-client.d.ts

@@ -7,3 +7,3 @@ import { AxiosRequestConfig } from 'axios';

private clientId;
constructor(restClientOptions?: RestClientOptions, requestOptions?: AxiosRequestConfig);
constructor(restClientOptions?: RestClientOptions, requestOptions?: AxiosRequestConfig, useTestnet?: boolean);
/**

@@ -13,2 +13,5 @@ * Abstraction required by each client to aid with time sync / drift handling

getServerTime(): Promise<number>;
getFuturesUserDataListenKey(): Promise<{
listenKey: string;
}>;
getSymbolOrderBookTicker(params?: SymbolOrPair): Promise<CoinMSymbolOrderBookTicker[]>;

@@ -15,0 +18,0 @@ getOpenInterest(params: {

7

lib/coinm-client.js

@@ -19,4 +19,4 @@ "use strict";

class CoinMClient extends BaseRestClient_1.default {
constructor(restClientOptions = {}, requestOptions = {}) {
const clientId = 'coinm';
constructor(restClientOptions = {}, requestOptions = {}, useTestnet) {
const clientId = useTestnet ? 'coinmtest' : 'coinm';
super(clientId, restClientOptions, requestOptions);

@@ -34,2 +34,5 @@ this.clientId = clientId;

}
getFuturesUserDataListenKey() {
return this.post('dapi/v1/listenKey');
}
//TODO - https://binance-docs.github.io/apidocs/delivery/en/#change-log

@@ -36,0 +39,0 @@ //TODO - https://binance-docs.github.io/apidocs/delivery/en/#general-info

@@ -5,3 +5,3 @@ export declare type numberInString = string | number;

export declare type BooleanStringCapitalised = 'TRUE' | 'FALSE';
export declare type BinanceBaseUrlKey = 'spot' | 'spot1' | 'spot2' | 'spot3' | 'spot4' | 'usdmtest' | 'usdm' | 'coinm' | 'voptions' | 'voptionstest';
export declare type BinanceBaseUrlKey = 'spot' | 'spot1' | 'spot2' | 'spot3' | 'spot4' | 'usdmtest' | 'usdm' | 'coinm' | 'coinmtest' | 'voptions' | 'voptionstest';
/**

@@ -8,0 +8,0 @@ * Time in force. Note: `GTE_GTC` is not officially documented, use at your own risk.

@@ -27,2 +27,3 @@ "use strict";

case 'coinm':
case 'coinmtest':
return '15PC4ZJy';

@@ -89,3 +90,3 @@ case 'voptions':

coinm: 'https://dapi.binance.com',
// testnet is same as `usdmtest`
coinmtest: 'https://testnet.binancefuture.com',
// Vanilla Options

@@ -108,2 +109,3 @@ voptions: 'https://vapi.binance.com',

case 'coinm':
case 'coinmtest':
return 'dapi/v1/time';

@@ -110,0 +112,0 @@ case 'voptions':

@@ -92,2 +92,3 @@ /// <reference types="node" />

private getUSDMRestClient;
private getCOINMRestClient;
/**

@@ -276,2 +277,6 @@ * Send WS message to subscribe to topics. Use subscribe() to call this.

subscribeUsdFuturesUserDataStream(isTestnet?: boolean, forceNewConnection?: boolean, isReconnecting?: boolean): Promise<WebSocket>;
/**
* Subscribe to COIN-M Futures user data stream - listen key is automatically generated.
*/
subscribeCoinFuturesUserDataStream(isTestnet?: boolean, forceNewConnection?: boolean, isReconnecting?: boolean): Promise<WebSocket>;
}

@@ -25,2 +25,3 @@ "use strict";

const WsStore_1 = __importDefault(require("./util/WsStore"));
const coinm_client_1 = require("./coinm-client");
const wsBaseEndpoints = {

@@ -35,3 +36,3 @@ spot: 'wss://stream.binance.com:9443',

options: 'wss://vstream.binance.com',
optionsTestnet: 'wss://testnetws.binanceops.com',
optionsTestnet: 'wss://testnetws.binanceops.com'
};

@@ -244,3 +245,3 @@ const loggerCategory = { category: 'binance-ws' };

'ORDER_TRADE_UPDATE',
'ACCOUNT_CONFIG_UPDATE',
'ACCOUNT_CONFIG_UPDATE'
].includes(eventType)) {

@@ -257,3 +258,3 @@ this.emit('formattedUserDataMessage', beautifiedMessage);

data: msg,
wsKey,
wsKey
});

@@ -495,4 +496,14 @@ return;

}
// private getCOINMRestClient(isTestnet?: boolean): COINMClient {
// }
getCOINMRestClient(isTestnet) {
if (isTestnet) {
if (!this.restClients.coinmFuturesTestnet) {
this.restClients.coinmFuturesTestnet = new coinm_client_1.CoinMClient(this.getRestClientOptions(), this.options.requestOptions, isTestnet);
}
return this.restClients.coinmFuturesTestnet;
}
if (!this.restClients.coinmFutures) {
this.restClients.coinmFutures = new coinm_client_1.CoinMClient(this.getRestClientOptions(), this.options.requestOptions);
}
return this.restClients.coinmFutures;
}
/**

@@ -505,3 +516,3 @@ * Send WS message to subscribe to topics. Use subscribe() to call this.

params: topics,
id: new Date().getTime(),
id: new Date().getTime()
});

@@ -517,3 +528,3 @@ this.tryWsSend(wsKey, wsMessage);

params: topics,
id: new Date().getTime(),
id: new Date().getTime()
});

@@ -528,3 +539,3 @@ this.tryWsSend(wsKey, wsMessage);

method: 'LIST_SUBSCRIPTIONS',
id: requestId,
id: requestId
});

@@ -540,3 +551,3 @@ this.tryWsSend(wsKey, wsMessage);

params: [property, value],
id: requestId,
id: requestId
});

@@ -552,3 +563,3 @@ this.tryWsSend(wsKey, wsMessage);

params: [property],
id: requestId,
id: requestId
});

@@ -571,3 +582,3 @@ this.tryWsSend(wsKey, wsMessage);

keepAliveTimer: undefined,
keepAliveFailures: 0,
keepAliveFailures: 0
};

@@ -595,3 +606,2 @@ return this.listenKeyStateStore[listenKey];

case 'coinm':
case 'coinmTestnet':
case 'options':

@@ -603,2 +613,4 @@ case 'optionsTestnet':

return this.getUSDMRestClient(isTestnet).keepAliveFuturesUserDataListenKey();
case 'coinmTestnet':
return this.getUSDMRestClient(isTestnet).keepAliveFuturesUserDataListenKey();
default:

@@ -660,3 +672,7 @@ throwUnhandledSwitch(market, `Failed to send keep alive for user data stream in unhandled market ${market}`);

case 'coinm':
ws = yield this.subscribeCoinFuturesUserDataStream(isTestnet, forceNewConnection, isReconnecting);
break;
case 'coinmTestnet':
ws = yield this.subscribeCoinFuturesUserDataStream(true, forceNewConnection, isReconnecting);
break;
case 'options':

@@ -1004,3 +1020,3 @@ case 'optionsTestnet':

const { listenKey } = yield this.getSpotRestClient().getIsolatedMarginUserDataListenKey({
symbol: lowerCaseSymbol,
symbol: lowerCaseSymbol
});

@@ -1023,3 +1039,3 @@ const market = 'isolatedMargin';

wsKey: 'isolatedMargin' + '_' + 'userData',
error: e,
error: e
});

@@ -1062,4 +1078,31 @@ }

}
/**
* Subscribe to COIN-M Futures user data stream - listen key is automatically generated.
*/
subscribeCoinFuturesUserDataStream(isTestnet, forceNewConnection, isReconnecting) {
return __awaiter(this, void 0, void 0, function* () {
try {
const { listenKey } = yield this.getCOINMRestClient(isTestnet).getFuturesUserDataListenKey();
const market = isTestnet ? 'coinmTestnet' : 'coinm';
const streamName = 'userData';
const wsKey = [market, streamName, listenKey].join('_');
if (!forceNewConnection && this.wsStore.isWsConnecting(wsKey)) {
this.logger.silly('Existing usd futures user data connection in progress for listen key. Avoiding duplicate');
return this.getWs(wsKey);
}
// Necessary so client knows this is a reconnect
this.setWsState(wsKey, isReconnecting ? READY_STATE_RECONNECTING : READY_STATE_CONNECTING);
const ws = this.connectToWsUrl(this.getWsBaseUrl(market, wsKey) + `/ws/${listenKey}`, wsKey, forceNewConnection);
// Start & store timer to keep alive listen key (and handle expiration)
this.setKeepAliveListenKeyTimer(listenKey, market, ws, wsKey, undefined, isTestnet);
return ws;
}
catch (e) {
this.logger.error(`Failed to connect to COIN Futures user data`, Object.assign(Object.assign({}, loggerCategory), { error: e }));
this.emit('error', { wsKey: 'coinm' + '_' + 'userData', error: e });
}
});
}
}
exports.WebsocketClient = WebsocketClient;
//# sourceMappingURL=websocket-client.js.map
{
"name": "binance",
"version": "2.1.2",
"version": "2.1.3",
"description": "Node.js connector for Binance's REST APIs and WebSockets, with TypeScript & integration tests.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc