@binance/common 1.2.4 → 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 +22 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -32
- 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
|
};
|
|
@@ -1637,7 +1628,6 @@ export {
|
|
|
1637
1628
|
replaceWebsocketStreamsPlaceholders,
|
|
1638
1629
|
sanitizeHeaderValue,
|
|
1639
1630
|
sendRequest,
|
|
1640
|
-
setFlattenedQueryParams,
|
|
1641
1631
|
setSearchParams,
|
|
1642
1632
|
shouldRetryRequest,
|
|
1643
1633
|
sortObject,
|