@requestly/requestly-proxy 1.3.11 → 1.3.12

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.
@@ -71,7 +71,7 @@ class LoggerMiddleware {
71
71
  const rqLog = {
72
72
  id: ctx.uuid,
73
73
  timestamp: Math.floor(Date.now() / 1000),
74
- finalHar: (0, harObectCreator_1.createHar)(ctx.rq.final_request.headers, ctx.rq.final_request.method, protocol, ctx.rq.final_request.host, ctx.rq.final_request.path, ctx.rq.final_request.body, ctx.rq.final_response.status_code, ctx.rq.final_response.body, ctx.rq.final_response.headers || {}, ctx.rq.final_request.query_params),
74
+ finalHar: (0, harObectCreator_1.createHar)(ctx.rq.final_request.headers, ctx.rq.final_request.method, protocol, (0, utils_1.getHost)(ctx), ctx.rq.final_request.path, ctx.rq.final_request.body, ctx.rq.final_response.status_code, ctx.rq.final_response.body, ctx.rq.final_response.headers || {}, ctx.rq.final_request.query_params),
75
75
  requestShellCurl: this.generate_curl_from_har((_b = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.rq) === null || _a === void 0 ? void 0 : _a.final_request) === null || _b === void 0 ? void 0 : _b.requestHarObject), // TODO: Move this to client side
76
76
  actions: (0, utils_1.get_success_actions_from_action_results)(action_result_objs),
77
77
  consoleLogs: (_c = ctx === null || ctx === void 0 ? void 0 : ctx.rq) === null || _c === void 0 ? void 0 : _c.consoleLogs,
@@ -9,4 +9,5 @@ export function build_post_process_data(status_code: any, headers: any, body: an
9
9
  body: any;
10
10
  };
11
11
  export function get_success_actions_from_action_results(action_result_objs?: any[]): any[];
12
+ export function getHost(ctx: any): any;
12
13
  export function get_file_contents(file_path: any): string;
@@ -3,7 +3,7 @@ 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.get_file_contents = 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.getHost = exports.get_success_actions_from_action_results = exports.build_post_process_data = exports.build_action_processor_response = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const build_action_processor_response = (action, success = false, post_process_data = null) => {
9
9
  let resp = {
@@ -35,6 +35,18 @@ const get_success_actions_from_action_results = (action_result_objs = []) => {
35
35
  return success_action_results_objs.map((obj) => obj.action);
36
36
  };
37
37
  exports.get_success_actions_from_action_results = get_success_actions_from_action_results;
38
+ const getHost = (ctx) => {
39
+ const finalHost = ctx.rq.final_request.host;
40
+ const port = ctx.rq.final_request.port;
41
+ const protocol = ctx.isSSL ? "https" : "http";
42
+ const standardPort = protocol === "https" ? 443 : 80;
43
+ // Only append port if it's non-standard and not already in the host
44
+ if (port && port !== standardPort && !finalHost.includes(':')) {
45
+ return `${finalHost}:${port}`;
46
+ }
47
+ return finalHost;
48
+ };
49
+ exports.getHost = getHost;
38
50
  const get_file_contents = (file_path) => {
39
51
  return fs_1.default.readFileSync(file_path, "utf-8");
40
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestly/requestly-proxy",
3
- "version": "1.3.11",
3
+ "version": "1.3.12",
4
4
  "description": "Proxy that gives superpowers to all the Requestly clients",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",