@requestly/requestly-proxy 1.3.2 → 1.3.4
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/dist/components/proxy-middleware/constants.d.ts +8 -8
- package/dist/components/proxy-middleware/helpers/ctx_rq_namespace.js +4 -4
- package/dist/components/proxy-middleware/helpers/harObectCreator.js +7 -7
- package/dist/components/proxy-middleware/helpers/proxy_ctx_helper.js +6 -9
- package/dist/components/proxy-middleware/helpers/rule_processor_helper.js +2 -2
- package/dist/components/proxy-middleware/index.d.ts +5 -5
- package/dist/components/proxy-middleware/index.js +97 -114
- package/dist/components/proxy-middleware/middlewares/amiusing_middleware.js +2 -11
- package/dist/components/proxy-middleware/middlewares/logger_middleware.js +12 -16
- package/dist/components/proxy-middleware/middlewares/rules_middleware.js +20 -26
- package/dist/components/proxy-middleware/middlewares/ssl_cert_middleware.js +2 -11
- package/dist/components/proxy-middleware/rule_action_processor/handle_mixed_response.js +3 -12
- package/dist/components/proxy-middleware/rule_action_processor/index.js +9 -18
- package/dist/components/proxy-middleware/rule_action_processor/processors/block_processor.js +2 -11
- package/dist/components/proxy-middleware/rule_action_processor/processors/delay_processor.js +5 -14
- package/dist/components/proxy-middleware/rule_action_processor/processors/modify_request_processor.js +3 -12
- package/dist/components/proxy-middleware/rule_action_processor/processors/modify_response_processor.js +11 -20
- package/dist/components/proxy-middleware/rule_action_processor/processors/redirect_processor.js +3 -12
- package/dist/components/ssl-proxying/ssl-proxying-manager.js +5 -0
- package/dist/lib/proxy/index.d.ts +2 -2
- package/dist/lib/proxy/index.js +31 -1
- package/dist/lib/proxy/lib/middleware/gunzip.js +2 -1
- package/dist/lib/proxy/lib/middleware/wildcard.js +2 -1
- package/dist/lib/proxy/lib/proxy.d.ts +5 -5
- package/dist/test.js +5 -14
- package/dist/utils/helpers/rules-helper.js +10 -19
- package/dist/utils/index.js +31 -42
- package/package.json +14 -4
package/dist/utils/index.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
6
|
+
exports.getFunctionFromString = void 0;
|
|
7
|
+
exports.executeUserFunction = executeUserFunction;
|
|
16
8
|
const util_1 = require("util");
|
|
17
9
|
const capture_console_logs_1 = __importDefault(require("capture-console-logs"));
|
|
18
10
|
const state_1 = __importDefault(require("../components/proxy-middleware/middlewares/state"));
|
|
@@ -22,36 +14,33 @@ const getFunctionFromString = function (functionStringEscaped) {
|
|
|
22
14
|
};
|
|
23
15
|
exports.getFunctionFromString = getFunctionFromString;
|
|
24
16
|
/* Expects that the functionString has already been validated to be representing a proper function */
|
|
25
|
-
function executeUserFunction(ctx, functionString, args) {
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return finalResponse;
|
|
55
|
-
});
|
|
17
|
+
async function executeUserFunction(ctx, functionString, args) {
|
|
18
|
+
const generateFunctionWithSharedState = function (functionStringEscaped) {
|
|
19
|
+
const SHARED_STATE_VAR_NAME = "$sharedState";
|
|
20
|
+
const sharedState = state_1.default.getInstance().getSharedStateCopy();
|
|
21
|
+
return new Function(`${SHARED_STATE_VAR_NAME}`, `return { func: ${functionStringEscaped}, updatedSharedState: ${SHARED_STATE_VAR_NAME}}`)(sharedState);
|
|
22
|
+
};
|
|
23
|
+
const { func: generatedFunction, updatedSharedState } = generateFunctionWithSharedState(functionString);
|
|
24
|
+
const consoleCapture = new capture_console_logs_1.default();
|
|
25
|
+
consoleCapture.start(true);
|
|
26
|
+
let finalResponse = generatedFunction(args);
|
|
27
|
+
if (util_1.types.isPromise(finalResponse)) {
|
|
28
|
+
finalResponse = await finalResponse;
|
|
29
|
+
}
|
|
30
|
+
consoleCapture.stop();
|
|
31
|
+
const consoleLogs = consoleCapture.getCaptures();
|
|
32
|
+
ctx.rq.consoleLogs.push(...consoleLogs);
|
|
33
|
+
/**
|
|
34
|
+
* If we use GlobalState.getSharedStateRef instead of GlobalState.getSharedStateCopy
|
|
35
|
+
* then this update is completely unnecessary.
|
|
36
|
+
* Because then the function gets a reference to the global states,
|
|
37
|
+
* and any changes made inside the userFunction will directly be reflected there.
|
|
38
|
+
*
|
|
39
|
+
* But we are using it here to make the data flow obvious as we read this code.
|
|
40
|
+
*/
|
|
41
|
+
state_1.default.getInstance().setSharedState(updatedSharedState);
|
|
42
|
+
if (typeof finalResponse === "object") {
|
|
43
|
+
finalResponse = JSON.stringify(finalResponse);
|
|
44
|
+
}
|
|
45
|
+
return finalResponse;
|
|
56
46
|
}
|
|
57
|
-
exports.executeUserFunction = executeUserFunction;
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@requestly/requestly-proxy",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Proxy that gives superpowers to all the Requestly clients",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
6
8
|
"scripts": {
|
|
7
9
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
10
|
"dev": "nodemon src/test.ts",
|
|
@@ -13,11 +15,19 @@
|
|
|
13
15
|
"type": "git",
|
|
14
16
|
"url": "git+https://github.com/requestly/rq-proxy.git"
|
|
15
17
|
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"require": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
16
26
|
"author": "",
|
|
17
27
|
"license": "ISC",
|
|
18
28
|
"dependencies": {
|
|
19
|
-
"@requestly/requestly-core": "^1.0
|
|
20
|
-
"@sentry/browser": "^
|
|
29
|
+
"@requestly/requestly-core": "^1.1.0",
|
|
30
|
+
"@sentry/browser": "^8.33.1",
|
|
21
31
|
"async": "^3.2.5",
|
|
22
32
|
"axios": "^1.7.2",
|
|
23
33
|
"capture-console-logs": "^1.0.1",
|
|
@@ -40,7 +50,7 @@
|
|
|
40
50
|
"ajv": "^8.13.0",
|
|
41
51
|
"nodemon": "^3.1.0",
|
|
42
52
|
"type-fest": "^2.12.2",
|
|
43
|
-
"typescript": "^
|
|
53
|
+
"typescript": "^5.6.3"
|
|
44
54
|
},
|
|
45
55
|
"files": [
|
|
46
56
|
"dist"
|