Skip to content

Commit 7782afe

Browse files
authored
chore: (#60)
- bump version to v1.3.7 - update vulnerable axios version
1 parent b764fd6 commit 7782afe

File tree

5 files changed

+38
-16
lines changed

5 files changed

+38
-16
lines changed

dist/components/proxy-middleware/rule_action_processor/processors/modify_response_processor.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
"use strict";
2-
var __importDefault = (this && this.__importDefault) || function (mod) {
3-
return (mod && mod.__esModule) ? mod : { "default": mod };
4-
};
52
Object.defineProperty(exports, "__esModule", { value: true });
63
const proxy_1 = require("../../../../lib/proxy");
74
const requestly_core_1 = require("@requestly/requestly-core");
85
const proxy_ctx_helper_1 = require("../../helpers/proxy_ctx_helper");
96
const utils_1 = require("../utils");
10-
const fs_1 = __importDefault(require("fs"));
117
const http_helpers_1 = require("../../helpers/http_helpers");
128
const utils_2 = require("../../../../utils");
139
const constants_1 = require("../../constants");
@@ -17,16 +13,32 @@ const process_modify_response_action = async (action, ctx) => {
1713
return (0, utils_1.build_action_processor_response)(action, false);
1814
}
1915
if (ctx.currentHandler === proxy_1.PROXY_HANDLER_TYPE.ON_REQUEST) {
20-
if (action.responseType === requestly_core_1.CONSTANTS.RESPONSE_BODY_TYPES.STATIC
21-
&& action.serveWithoutRequest) {
16+
if (action.serveWithoutRequest) {
2217
let contentType, finalBody;
18+
if (action.responseType === requestly_core_1.CONSTANTS.RESPONSE_BODY_TYPES.LOCAL_FILE) {
19+
try {
20+
finalBody = (0, utils_1.get_file_contents)(action.response);
21+
}
22+
catch (err) {
23+
console.log("Error reading file", err);
24+
return (0, utils_1.build_action_processor_response)(action, false);
25+
}
26+
}
27+
else if (action.responseType === requestly_core_1.CONSTANTS.RESPONSE_BODY_TYPES.STATIC) {
28+
finalBody = action.response;
29+
}
30+
else {
31+
return (0, utils_1.build_action_processor_response)(action, false);
32+
}
2333
try {
24-
finalBody = JSON.parse(action.response);
34+
const parsedResponse = JSON.parse(finalBody);
35+
if (action.responseType === requestly_core_1.CONSTANTS.RESPONSE_BODY_TYPES.STATIC) {
36+
finalBody = parsedResponse;
37+
}
2538
contentType = "application/json";
2639
}
2740
catch (_a) {
2841
contentType = "text/plain";
29-
finalBody = action.response;
3042
}
3143
const status = action.statusCode || 200;
3244
const finalHeaders = { "Content-Type": contentType };
@@ -70,7 +82,7 @@ const modify_response = (ctx, new_resp, status_code) => {
7082
const modify_response_using_local = (action, ctx) => {
7183
let data;
7284
try {
73-
data = fs_1.default.readFileSync(action.response, "utf-8");
85+
data = (0, utils_1.get_file_contents)(action.response);
7486
modify_response(ctx, data, action.statusCode);
7587
}
7688
catch (err) {

dist/components/proxy-middleware/rule_action_processor/utils.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ export function build_post_process_data(status_code: any, headers: any, body: an
99
body: any;
1010
};
1111
export function get_success_actions_from_action_results(action_result_objs?: any[]): any[];
12+
export function get_file_contents(file_path: any): string;

dist/components/proxy-middleware/rule_action_processor/utils.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
25
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.get_success_actions_from_action_results = exports.build_post_process_data = exports.build_action_processor_response = void 0;
6+
exports.get_file_contents = exports.get_success_actions_from_action_results = exports.build_post_process_data = exports.build_action_processor_response = void 0;
7+
const fs_1 = __importDefault(require("fs"));
48
const build_action_processor_response = (action, success = false, post_process_data = null) => {
59
let resp = {
610
action: action,
@@ -31,3 +35,7 @@ const get_success_actions_from_action_results = (action_result_objs = []) => {
3135
return success_action_results_objs.map((obj) => obj.action);
3236
};
3337
exports.get_success_actions_from_action_results = get_success_actions_from_action_results;
38+
const get_file_contents = (file_path) => {
39+
return fs_1.default.readFileSync(action.response, "utf-8");
40+
};
41+
exports.get_file_contents = get_file_contents;

package-lock.json

Lines changed: 6 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@requestly/requestly-proxy",
3-
"version": "1.3.6",
3+
"version": "1.3.7",
44
"description": "Proxy that gives superpowers to all the Requestly clients",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)