arn-browser 0.1.47 → 0.1.49
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/package.json
CHANGED
|
@@ -221,7 +221,7 @@ function sanitizeResponseHeaders(headers, logger, url) {
|
|
|
221
221
|
* @param {boolean} stripLogger - Whether to log stripped headers
|
|
222
222
|
* @returns {Promise<Object>} - The response object containing status, headers, and body
|
|
223
223
|
*/
|
|
224
|
-
async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl, logger, proxyAgent, stripHeaders, stripLogger) {
|
|
224
|
+
async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl, logger, proxyAgent, stripHeaders, stripLogger, postData) {
|
|
225
225
|
// Determine the cache key based on configuration
|
|
226
226
|
let mainUrl = new URL(url).origin + new URL(url).pathname;
|
|
227
227
|
if (useFullUrl) {
|
|
@@ -252,6 +252,26 @@ async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl
|
|
|
252
252
|
request = request.agent(proxyAgent);
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
// Forward POST/PUT/PATCH request body if present
|
|
256
|
+
if (postData && (method !== "GET" && method !== "HEAD")) {
|
|
257
|
+
let bodyToSend = postData;
|
|
258
|
+
if (typeof postData !== "string") {
|
|
259
|
+
const contentTypeKey = Object.keys(finalHeaders).find(k => k.toLowerCase() === "content-type");
|
|
260
|
+
const contentType = contentTypeKey ? String(finalHeaders[contentTypeKey]).toLowerCase() : "";
|
|
261
|
+
if (
|
|
262
|
+
contentType.includes("json") ||
|
|
263
|
+
contentType.includes("urlencoded") ||
|
|
264
|
+
contentType.includes("xml") ||
|
|
265
|
+
contentType.includes("text/")
|
|
266
|
+
) {
|
|
267
|
+
bodyToSend = Buffer.isBuffer(postData)
|
|
268
|
+
? postData.toString("utf-8")
|
|
269
|
+
: Buffer.from(postData).toString("utf-8");
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
request = request.send(bodyToSend);
|
|
273
|
+
}
|
|
274
|
+
|
|
255
275
|
const response = await request;
|
|
256
276
|
|
|
257
277
|
// Determine the correct body type (Buffer for binary, text for others)
|
|
@@ -489,6 +509,7 @@ export async function pwRoute(options = {}) {
|
|
|
489
509
|
? currentConfig.xhrProxyAgent
|
|
490
510
|
: currentConfig.proxyAgent;
|
|
491
511
|
|
|
512
|
+
const postData = request.postDataBuffer ? request.postDataBuffer() : request.postData();
|
|
492
513
|
const response = await fetchWithClient(
|
|
493
514
|
currentConfig.useCache,
|
|
494
515
|
url,
|
|
@@ -498,7 +519,8 @@ export async function pwRoute(options = {}) {
|
|
|
498
519
|
currentConfig.logger,
|
|
499
520
|
agentToUse,
|
|
500
521
|
isXhrOrFetch ? false : currentConfig.stripGotHeaders,
|
|
501
|
-
currentConfig.stripGotLogger
|
|
522
|
+
currentConfig.stripGotLogger,
|
|
523
|
+
postData
|
|
502
524
|
);
|
|
503
525
|
|
|
504
526
|
if (response) {
|
|
@@ -56,7 +56,8 @@ export async function get_multilogin_proxy({
|
|
|
56
56
|
|
|
57
57
|
// 2. Prepare Data (sanitize region: spaces → underscores)
|
|
58
58
|
const sanitizedRegion = region ? region.toLowerCase().replace(/ /g, '_') : region;
|
|
59
|
-
const
|
|
59
|
+
const finalCountry = (country && country.toLowerCase() === "ww") ? "any" : country;
|
|
60
|
+
const data = { country: finalCountry, sessionType, protocol, region: sanitizedRegion, city, IPTTL, count: 1 };
|
|
60
61
|
Object.keys(data).forEach((k) => (data[k] === "" || data[k] === 0 || data[k] == null) && delete data[k]);
|
|
61
62
|
|
|
62
63
|
// 3. Setup Timeout
|
|
@@ -224,7 +224,7 @@ function sanitizeResponseHeaders(headers, logger, url) {
|
|
|
224
224
|
* @param {boolean} stripLogger - Whether to log stripped headers
|
|
225
225
|
* @returns {Promise<Object>} - The response object containing status, headers, and body
|
|
226
226
|
*/
|
|
227
|
-
async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl, logger, proxyAgent, stripHeaders, stripLogger) {
|
|
227
|
+
async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl, logger, proxyAgent, stripHeaders, stripLogger, postData) {
|
|
228
228
|
// Determine the cache key based on configuration
|
|
229
229
|
let mainUrl = new URL(url).origin + new URL(url).pathname;
|
|
230
230
|
if (useFullUrl) {
|
|
@@ -255,6 +255,26 @@ async function fetchWithClient(useCache, url, requestHeaders, method, useFullUrl
|
|
|
255
255
|
request = request.agent(proxyAgent);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
// Forward POST/PUT/PATCH request body if present
|
|
259
|
+
if (postData && (method !== "GET" && method !== "HEAD")) {
|
|
260
|
+
let bodyToSend = postData;
|
|
261
|
+
if (typeof postData !== "string") {
|
|
262
|
+
const contentTypeKey = Object.keys(finalHeaders).find(k => k.toLowerCase() === "content-type");
|
|
263
|
+
const contentType = contentTypeKey ? String(finalHeaders[contentTypeKey]).toLowerCase() : "";
|
|
264
|
+
if (
|
|
265
|
+
contentType.includes("json") ||
|
|
266
|
+
contentType.includes("urlencoded") ||
|
|
267
|
+
contentType.includes("xml") ||
|
|
268
|
+
contentType.includes("text/")
|
|
269
|
+
) {
|
|
270
|
+
bodyToSend = Buffer.isBuffer(postData)
|
|
271
|
+
? postData.toString("utf-8")
|
|
272
|
+
: Buffer.from(postData).toString("utf-8");
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
request = request.send(bodyToSend);
|
|
276
|
+
}
|
|
277
|
+
|
|
258
278
|
const response = await request;
|
|
259
279
|
|
|
260
280
|
// Determine the correct body type (Buffer for binary, text for others)
|
|
@@ -505,7 +525,8 @@ export async function ppRoute(options = {}) {
|
|
|
505
525
|
currentConfig.logger,
|
|
506
526
|
agentToUse,
|
|
507
527
|
isXhrOrFetch ? false : currentConfig.stripGotHeaders,
|
|
508
|
-
currentConfig.stripGotLogger
|
|
528
|
+
currentConfig.stripGotLogger,
|
|
529
|
+
request.postData()
|
|
509
530
|
);
|
|
510
531
|
|
|
511
532
|
if (response) {
|