@requestly/requestly-proxy 1.1.8 → 1.1.10

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.
@@ -4,6 +4,7 @@ declare class CtxRQNamespace {
4
4
  original_response: {};
5
5
  final_request: {};
6
6
  final_response: {};
7
+ consoleLogs: any[];
7
8
  set_original_request: ({ method, path, host, port, headers, agent, body, query_params, }: {
8
9
  method?: any;
9
10
  path?: any;
@@ -91,6 +91,7 @@ class CtxRQNamespace {
91
91
  // headers,
92
92
  // body
93
93
  };
94
+ this.consoleLogs = [];
94
95
  }
95
96
  }
96
97
  exports.default = CtxRQNamespace;
@@ -61,6 +61,7 @@ declare class LoggerMiddleware {
61
61
  };
62
62
  requestShellCurl: string;
63
63
  actions: any[];
64
+ consoleLogs: any;
64
65
  requestState: string;
65
66
  };
66
67
  }
@@ -70,7 +70,7 @@ class LoggerMiddleware {
70
70
  this.loggerService.addLog(this.createLog(ctx, action_result_objs, requestState), ctx.rq.final_request.headers || {});
71
71
  };
72
72
  this.createLog = (ctx, action_result_objs = [], requestState = "") => {
73
- var _a, _b;
73
+ var _a, _b, _c;
74
74
  const protocol = ctx.isSSL ? "https" : "http";
75
75
  const rqLog = {
76
76
  id: ctx.uuid,
@@ -78,6 +78,7 @@ class LoggerMiddleware {
78
78
  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 || {}),
79
79
  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),
80
80
  actions: (0, utils_1.get_success_actions_from_action_results)(action_result_objs),
81
+ consoleLogs: (_c = ctx === null || ctx === void 0 ? void 0 : ctx.rq) === null || _c === void 0 ? void 0 : _c.consoleLogs,
81
82
  requestState
82
83
  };
83
84
  return rqLog;
@@ -8,11 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  const proxy_1 = require("../../../../lib/proxy");
13
16
  const requestly_core_1 = require("@requestly/requestly-core");
14
17
  const proxy_ctx_helper_1 = require("../../helpers/proxy_ctx_helper");
15
18
  const utils_1 = require("../utils");
19
+ const capture_console_logs_1 = __importDefault(require("capture-console-logs"));
16
20
  const { types } = require("util");
17
21
  const process_modify_request_action = (action, ctx) => {
18
22
  const allowed_handlers = [proxy_1.PROXY_HANDLER_TYPE.ON_REQUEST_END];
@@ -66,10 +70,15 @@ const modify_request_using_code = (action, ctx) => __awaiter(void 0, void 0, voi
66
70
  catch (_a) {
67
71
  /*Do nothing -- could not parse body as JSON */
68
72
  }
73
+ const consoleCapture = new capture_console_logs_1.default();
74
+ consoleCapture.start(true);
69
75
  finalRequest = userFunction(args);
70
76
  if (types.isPromise(finalRequest)) {
71
77
  finalRequest = yield finalRequest;
72
78
  }
79
+ consoleCapture.stop();
80
+ const consoleLogs = consoleCapture.getCaptures();
81
+ ctx.rq.consoleLogs.push(...consoleLogs);
73
82
  const isRequestJSON = !!args.requestJSON;
74
83
  if (typeof finalRequest === "object" && isRequestJSON) {
75
84
  finalRequest = JSON.stringify(finalRequest);
@@ -18,6 +18,7 @@ const proxy_ctx_helper_1 = require("../../helpers/proxy_ctx_helper");
18
18
  const utils_1 = require("../utils");
19
19
  const fs_1 = __importDefault(require("fs"));
20
20
  const http_helpers_1 = require("../../helpers/http_helpers");
21
+ const capture_console_logs_1 = __importDefault(require("capture-console-logs"));
21
22
  const { types } = require("util");
22
23
  const process_modify_response_action = (action, ctx) => __awaiter(void 0, void 0, void 0, function* () {
23
24
  const allowed_handlers = [proxy_1.PROXY_HANDLER_TYPE.ON_RESPONSE_END];
@@ -88,10 +89,15 @@ const modify_response_using_code = (action, ctx) => __awaiter(void 0, void 0, vo
88
89
  catch (_c) {
89
90
  /*Do nothing -- could not parse body as JSON */
90
91
  }
92
+ const consoleCapture = new capture_console_logs_1.default();
93
+ consoleCapture.start(true);
91
94
  finalResponse = userFunction(args);
92
95
  if (types.isPromise(finalResponse)) {
93
96
  finalResponse = yield finalResponse;
94
97
  }
98
+ consoleCapture.stop();
99
+ const consoleLogs = consoleCapture.getCaptures();
100
+ ctx.rq.consoleLogs.push(...consoleLogs);
95
101
  if (typeof finalResponse === "object") {
96
102
  finalResponse = JSON.stringify(finalResponse);
97
103
  }
@@ -997,7 +997,7 @@ Proxy.prototype._onWebSocketConnection = function (ctx, callback) {
997
997
  return fn(ctx, callback);
998
998
  }, callback);
999
999
  };
1000
- Proxy.prototype._onWebSocketFrame = function (ctx, type, fromServer, data, isBinary) {
1000
+ Proxy.prototype._onWebSocketFrame = function (ctx, type, fromServer, data, flags) {
1001
1001
  var self = this;
1002
1002
  async.forEach(this.onWebSocketFrameHandlers.concat(ctx.onWebSocketFrameHandlers), function (fn, callback) {
1003
1003
  return fn(ctx, type, fromServer, data, flags, function (err, newData, newFlags) {
@@ -1018,7 +1018,7 @@ Proxy.prototype._onWebSocketFrame = function (ctx, type, fromServer, data, isBin
1018
1018
  if (destWebSocket.readyState === WebSocket.OPEN) {
1019
1019
  switch (type) {
1020
1020
  case "message":
1021
- destWebSocket.send(data, { binary: isBinary });
1021
+ destWebSocket.send(data, { binary: flags });
1022
1022
  break;
1023
1023
  case "ping":
1024
1024
  destWebSocket.ping(data, flags, false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@requestly/requestly-proxy",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "Proxy that gives superpowers to all the Requestly clients",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -19,6 +19,7 @@
19
19
  "@sentry/browser": "^6.19.2",
20
20
  "async": "^3.2.1",
21
21
  "axios": "^0.26.1",
22
+ "capture-console-logs": "^1.0.1",
22
23
  "charset": "^1.0.1",
23
24
  "debug": "^4.3.2",
24
25
  "httpsnippet": "^2.0.0",