@binance/common 1.2.3 → 1.2.5
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 +16 -26
- package/dist/index.d.ts +16 -26
- package/dist/index.js +24 -34
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -50,13 +50,22 @@ var RequestSigner = class {
|
|
|
50
50
|
var clearSignerCache = function() {
|
|
51
51
|
signerCache = /* @__PURE__ */ new WeakMap();
|
|
52
52
|
};
|
|
53
|
+
function serializeValue(value) {
|
|
54
|
+
if (value === null || value === void 0) return "";
|
|
55
|
+
if (Array.isArray(value) || typeof value === "object" && value !== null)
|
|
56
|
+
return JSON.stringify(value);
|
|
57
|
+
return String(value);
|
|
58
|
+
}
|
|
53
59
|
function buildQueryString(params) {
|
|
54
60
|
if (!params) return "";
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
61
|
+
const pairs = [];
|
|
62
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
63
|
+
if (value !== null && value !== void 0) {
|
|
64
|
+
const serializedValue = serializeValue(value);
|
|
65
|
+
pairs.push(`${key}=${encodeURIComponent(serializedValue)}`);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return pairs.join("&");
|
|
60
69
|
}
|
|
61
70
|
function randomString() {
|
|
62
71
|
return crypto.randomBytes(16).toString("hex");
|
|
@@ -91,34 +100,16 @@ var assertParamExists = function(functionName, paramName, paramValue) {
|
|
|
91
100
|
);
|
|
92
101
|
}
|
|
93
102
|
};
|
|
94
|
-
function
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
for (const item of parameter) {
|
|
101
|
-
setFlattenedQueryParams(urlSearchParams, item, "");
|
|
102
|
-
}
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
if (typeof parameter === "object") {
|
|
106
|
-
for (const subKey of Object.keys(parameter)) {
|
|
107
|
-
const subVal = parameter[subKey];
|
|
108
|
-
const newKey = key ? `${key}.${subKey}` : subKey;
|
|
109
|
-
setFlattenedQueryParams(urlSearchParams, subVal, newKey);
|
|
103
|
+
function setSearchParams(url, params) {
|
|
104
|
+
const searchParams = new URLSearchParams();
|
|
105
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
106
|
+
if (value !== null && value !== void 0) {
|
|
107
|
+
const serializedValue = serializeValue(value);
|
|
108
|
+
searchParams.set(key, serializedValue);
|
|
110
109
|
}
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
const str = String(parameter);
|
|
114
|
-
if (urlSearchParams.has(key)) urlSearchParams.append(key, str);
|
|
115
|
-
else urlSearchParams.set(key, str);
|
|
116
|
-
}
|
|
117
|
-
var setSearchParams = function(url, ...objects) {
|
|
118
|
-
const searchParams = new URLSearchParams(url.search);
|
|
119
|
-
setFlattenedQueryParams(searchParams, objects);
|
|
110
|
+
});
|
|
120
111
|
url.search = searchParams.toString();
|
|
121
|
-
}
|
|
112
|
+
}
|
|
122
113
|
var toPathString = function(url) {
|
|
123
114
|
return url.pathname + url.search + url.hash;
|
|
124
115
|
};
|
|
@@ -440,7 +431,8 @@ var ConfigurationRestAPI = class {
|
|
|
440
431
|
proxy: param.proxy && {
|
|
441
432
|
host: param.proxy.host,
|
|
442
433
|
port: param.proxy.port,
|
|
443
|
-
|
|
434
|
+
...param.proxy.protocol && { protocol: param.proxy.protocol },
|
|
435
|
+
...param.proxy.auth && { auth: param.proxy.auth }
|
|
444
436
|
},
|
|
445
437
|
httpsAgent: param.httpsAgent ?? false,
|
|
446
438
|
headers: {
|
|
@@ -1636,7 +1628,6 @@ export {
|
|
|
1636
1628
|
replaceWebsocketStreamsPlaceholders,
|
|
1637
1629
|
sanitizeHeaderValue,
|
|
1638
1630
|
sendRequest,
|
|
1639
|
-
setFlattenedQueryParams,
|
|
1640
1631
|
setSearchParams,
|
|
1641
1632
|
shouldRetryRequest,
|
|
1642
1633
|
sortObject,
|