@binance/common 1.2.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import crypto from "crypto";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import https from "https";
|
|
5
|
+
import { JSONParse } from "json-with-bigint";
|
|
5
6
|
import { platform, arch } from "os";
|
|
6
7
|
import globalAxios from "axios";
|
|
7
8
|
var signerCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -179,7 +180,7 @@ var httpRequestFunction = async function(axiosArgs, configuration) {
|
|
|
179
180
|
return {
|
|
180
181
|
data: async () => {
|
|
181
182
|
try {
|
|
182
|
-
return
|
|
183
|
+
return JSONParse(response.data);
|
|
183
184
|
} catch (err) {
|
|
184
185
|
throw new Error(`Failed to parse JSON response: ${err}`);
|
|
185
186
|
}
|
|
@@ -205,7 +206,7 @@ var httpRequestFunction = async function(axiosArgs, configuration) {
|
|
|
205
206
|
if (responseData && responseData !== null) {
|
|
206
207
|
if (typeof responseData === "string" && responseData !== "")
|
|
207
208
|
try {
|
|
208
|
-
data =
|
|
209
|
+
data = JSONParse(responseData);
|
|
209
210
|
} catch {
|
|
210
211
|
data = {};
|
|
211
212
|
}
|
|
@@ -480,7 +481,6 @@ var TimeUnit = {
|
|
|
480
481
|
microsecond: "microsecond"
|
|
481
482
|
};
|
|
482
483
|
var ALGO_REST_API_PROD_URL = "https://api.binance.com";
|
|
483
|
-
var AUTO_INVEST_REST_API_PROD_URL = "https://api.binance.com";
|
|
484
484
|
var C2C_REST_API_PROD_URL = "https://api.binance.com";
|
|
485
485
|
var CONVERT_REST_API_PROD_URL = "https://api.binance.com";
|
|
486
486
|
var COPY_TRADING_REST_API_PROD_URL = "https://api.binance.com";
|
|
@@ -664,6 +664,7 @@ var Logger = class _Logger {
|
|
|
664
664
|
// src/websocket.ts
|
|
665
665
|
import { EventEmitter } from "events";
|
|
666
666
|
import WebSocketClient from "ws";
|
|
667
|
+
import { JSONParse as JSONParse2 } from "json-with-bigint";
|
|
667
668
|
var WebsocketEventEmitter = class {
|
|
668
669
|
constructor() {
|
|
669
670
|
this.eventEmitter = new EventEmitter();
|
|
@@ -952,6 +953,7 @@ var WebsocketCommon = class _WebsocketCommon extends WebsocketEventEmitter {
|
|
|
952
953
|
} else if (targetConnection.closeInitiated) {
|
|
953
954
|
this.closeConnectionGracefully(targetConnection.ws, targetConnection);
|
|
954
955
|
} else {
|
|
956
|
+
targetConnection.reconnectionPending = false;
|
|
955
957
|
this.emit("open", this);
|
|
956
958
|
}
|
|
957
959
|
this.sessionReLogon(targetConnection);
|
|
@@ -1065,6 +1067,7 @@ var WebsocketCommon = class _WebsocketCommon extends WebsocketEventEmitter {
|
|
|
1065
1067
|
ws.on("close", (closeEventCode, reason) => {
|
|
1066
1068
|
this.emit("close", closeEventCode, reason);
|
|
1067
1069
|
if (!targetConnection.closeInitiated && !isRenewal) {
|
|
1070
|
+
this.cleanup(ws);
|
|
1068
1071
|
this.logger.warn(
|
|
1069
1072
|
`Connection with id ${targetConnection.id} closed due to ${closeEventCode}: ${reason}`
|
|
1070
1073
|
);
|
|
@@ -1223,7 +1226,7 @@ var WebsocketAPIBase = class extends WebsocketCommon {
|
|
|
1223
1226
|
*/
|
|
1224
1227
|
onMessage(data, connection) {
|
|
1225
1228
|
try {
|
|
1226
|
-
const message =
|
|
1229
|
+
const message = JSONParse2(data);
|
|
1227
1230
|
const { id, status } = message;
|
|
1228
1231
|
if (id && connection.pendingRequests.has(id)) {
|
|
1229
1232
|
const request = connection.pendingRequests.get(id);
|
|
@@ -1411,7 +1414,7 @@ var WebsocketStreamsBase = class extends WebsocketCommon {
|
|
|
1411
1414
|
*/
|
|
1412
1415
|
onMessage(data, connection) {
|
|
1413
1416
|
try {
|
|
1414
|
-
const parsedData =
|
|
1417
|
+
const parsedData = JSONParse2(data);
|
|
1415
1418
|
const streamName = parsedData?.stream;
|
|
1416
1419
|
if (streamName && this.streamCallbackMap.has(streamName))
|
|
1417
1420
|
this.streamCallbackMap.get(streamName)?.forEach((callback) => callback(parsedData.data));
|
|
@@ -1542,7 +1545,6 @@ function createStreamHandler(websocketBase, streamOrId, id) {
|
|
|
1542
1545
|
}
|
|
1543
1546
|
export {
|
|
1544
1547
|
ALGO_REST_API_PROD_URL,
|
|
1545
|
-
AUTO_INVEST_REST_API_PROD_URL,
|
|
1546
1548
|
BadRequestError,
|
|
1547
1549
|
C2C_REST_API_PROD_URL,
|
|
1548
1550
|
CONVERT_REST_API_PROD_URL,
|