@requestly/requestly-proxy 1.2.1 → 1.2.3
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.
|
@@ -3,49 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.parseJsonBody = exports.getContentType = exports.bodyParser = void 0;
|
|
6
|
+
exports.parseJsonBody = exports.getContentType = exports.bodyParser = exports.getEncoding = void 0;
|
|
7
7
|
const charset_1 = __importDefault(require("charset"));
|
|
8
8
|
const mime_types_1 = __importDefault(require("mime-types"));
|
|
9
|
+
const getEncoding = (contentTypeHeader, buffer) => {
|
|
10
|
+
const encoding = (0, charset_1.default)(contentTypeHeader, buffer) || mime_types_1.default.charset(contentTypeHeader) || "utf8";
|
|
11
|
+
return encoding;
|
|
12
|
+
};
|
|
13
|
+
exports.getEncoding = getEncoding;
|
|
9
14
|
const bodyParser = (contentTypeHeader, buffer) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const setBufferString = (givenEncoding) => (str_buffer = buffer.toString(givenEncoding));
|
|
14
|
-
if (isEncodingValid(inherentEncoding)) {
|
|
15
|
-
setBufferString(inherentEncoding);
|
|
15
|
+
const encoding = (0, exports.getEncoding)(contentTypeHeader, buffer);
|
|
16
|
+
try {
|
|
17
|
+
return buffer.toString(encoding);
|
|
16
18
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"utf16le",
|
|
21
|
-
"ascii",
|
|
22
|
-
"ucs2",
|
|
23
|
-
"base64",
|
|
24
|
-
"latin1",
|
|
25
|
-
"binary",
|
|
26
|
-
"hex",
|
|
27
|
-
];
|
|
28
|
-
mostCommonEncodings.every((newPossibleEncoding) => {
|
|
29
|
-
if (isEncodingValid(newPossibleEncoding)) {
|
|
30
|
-
setBufferString(newPossibleEncoding);
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
19
|
+
catch (error) {
|
|
20
|
+
// some encodings are not supposed to be turned into string
|
|
21
|
+
return buffer;
|
|
34
22
|
}
|
|
35
|
-
return str_buffer;
|
|
36
|
-
/*
|
|
37
|
-
FOLLOWING IS HOW API CLIENT PARSES THE BODY
|
|
38
|
-
much simpler than above, but requires thorough testing
|
|
39
|
-
*/
|
|
40
|
-
// // todo: add support for other content types
|
|
41
|
-
// let parsedResponse;
|
|
42
|
-
// if (contentTypeHeader?.includes("image/")) {
|
|
43
|
-
// const raw = Buffer.from(buffer).toString("base64");
|
|
44
|
-
// parsedResponse = `data:${contentTypeHeader};base64,${raw}`;
|
|
45
|
-
// } else {
|
|
46
|
-
// parsedResponse = new TextDecoder().decode(buffer);
|
|
47
|
-
// }
|
|
48
|
-
// return parsedResponse;
|
|
49
23
|
};
|
|
50
24
|
exports.bodyParser = bodyParser;
|
|
51
25
|
const getContentType = (contentTypeHeader) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@requestly/requestly-proxy",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Proxy that gives superpowers to all the Requestly clients",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@requestly/requestly-core": "^1.0.
|
|
20
|
-
"@sentry/browser": "^6.19.
|
|
19
|
+
"@requestly/requestly-core": "^1.0.4",
|
|
20
|
+
"@sentry/browser": "^6.19.7",
|
|
21
21
|
"async": "^3.2.5",
|
|
22
|
-
"axios": "^
|
|
22
|
+
"axios": "^1.7.2",
|
|
23
23
|
"capture-console-logs": "^1.0.1",
|
|
24
24
|
"charset": "^1.0.1",
|
|
25
25
|
"debug": "^4.3.2",
|
|
26
|
-
"httpsnippet": "^
|
|
26
|
+
"httpsnippet": "^3.0.4",
|
|
27
27
|
"lodash": "^4.17.21",
|
|
28
28
|
"mime-types": "^2.1.35",
|
|
29
29
|
"mkdirp": "^0.5.5",
|
|
@@ -35,8 +35,11 @@
|
|
|
35
35
|
"ws": "^8.16.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/
|
|
38
|
+
"@types/har-format": "^1.2.15",
|
|
39
|
+
"@types/node": "^20.12.12",
|
|
40
|
+
"ajv": "^8.13.0",
|
|
39
41
|
"nodemon": "^3.1.0",
|
|
42
|
+
"type-fest": "^2.12.2",
|
|
40
43
|
"typescript": "^4.6.3"
|
|
41
44
|
},
|
|
42
45
|
"files": [
|