@sap-ux/ui5-proxy-middleware 1.1.14 → 1.1.16
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/base/proxy.js +8 -0
- package/dist/base/types.d.ts +1 -0
- package/dist/base/utils.d.ts +3 -4
- package/dist/base/utils.js +34 -21
- package/dist/ui5/middleware.js +2 -5
- package/package.json +3 -3
package/dist/base/proxy.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.ui5Proxy = void 0;
|
|
|
4
4
|
const http_proxy_middleware_1 = require("http-proxy-middleware");
|
|
5
5
|
const utils_1 = require("./utils");
|
|
6
6
|
const logger_1 = require("@sap-ux/logger");
|
|
7
|
+
const proxy_from_env_1 = require("proxy-from-env");
|
|
8
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
7
9
|
/**
|
|
8
10
|
* Function for proxying UI5 sources.
|
|
9
11
|
*
|
|
@@ -33,6 +35,12 @@ const ui5Proxy = (config, options, filter) => {
|
|
|
33
35
|
utils_1.proxyErrorHandler(err, req, logger, res, target);
|
|
34
36
|
}
|
|
35
37
|
};
|
|
38
|
+
// update proxy config with values coming from args or ui5.yaml
|
|
39
|
+
utils_1.updateProxyEnv(config.proxy);
|
|
40
|
+
const corporateProxy = proxy_from_env_1.getProxyForUrl(config.url);
|
|
41
|
+
if (corporateProxy) {
|
|
42
|
+
proxyConfig.agent = new https_proxy_agent_1.HttpsProxyAgent(corporateProxy);
|
|
43
|
+
}
|
|
36
44
|
Object.assign(proxyConfig, options);
|
|
37
45
|
let proxyFilter = utils_1.filterCompressedHtmlFiles;
|
|
38
46
|
if (filter) {
|
package/dist/base/types.d.ts
CHANGED
package/dist/base/utils.d.ts
CHANGED
|
@@ -39,12 +39,11 @@ export declare const getCorporateProxyServer: (yamlProxyServer: string | undefin
|
|
|
39
39
|
*/
|
|
40
40
|
export declare const hideProxyCredentials: (proxy: string | undefined) => string | undefined;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Updates the proxy configuration with values from runtime args (highest priority), environment variables or given config value.
|
|
43
43
|
*
|
|
44
|
-
* @param
|
|
45
|
-
* @returns false if host is excluded from user's corporate server, true otherwise
|
|
44
|
+
* @param proxyFromConfig - optional proxy string from configuration
|
|
46
45
|
*/
|
|
47
|
-
export declare
|
|
46
|
+
export declare function updateProxyEnv(proxyFromConfig?: string): void;
|
|
48
47
|
/**
|
|
49
48
|
* Returns the name of html file, which is used to preview the application, from the URL.
|
|
50
49
|
*
|
package/dist/base/utils.js
CHANGED
|
@@ -9,13 +9,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.proxyErrorHandler = exports.filterCompressedHtmlFiles = exports.injectScripts = exports.injectUI5Url = exports.resolveUI5Version = exports.getUI5VersionFromManifest = exports.getManifest = exports.setHtmlResponse = exports.getWebAppFolderFromYaml = exports.getYamlFile = exports.getHtmlFile = exports.
|
|
12
|
+
exports.proxyErrorHandler = exports.filterCompressedHtmlFiles = exports.injectScripts = exports.injectUI5Url = exports.resolveUI5Version = exports.getUI5VersionFromManifest = exports.getManifest = exports.setHtmlResponse = exports.getWebAppFolderFromYaml = exports.getYamlFile = exports.getHtmlFile = exports.updateProxyEnv = exports.hideProxyCredentials = exports.getCorporateProxyServer = exports.proxyRequestHandler = exports.proxyResponseHandler = void 0;
|
|
13
13
|
const ui5_config_1 = require("@sap-ux/ui5-config");
|
|
14
14
|
const fs_1 = require("fs");
|
|
15
15
|
const path_1 = require("path");
|
|
16
16
|
const constants_1 = require("./constants");
|
|
17
17
|
const i18n_1 = require("../i18n");
|
|
18
|
-
const proxy_from_env_1 = require("proxy-from-env");
|
|
19
18
|
/**
|
|
20
19
|
* Handler for the proxy response event.
|
|
21
20
|
* Sets an Etag which will be used for re-validation of the cached UI5 sources.
|
|
@@ -59,21 +58,15 @@ const getCorporateProxyServer = (yamlProxyServer) => {
|
|
|
59
58
|
proxyFromArgs = arg.split('=')[1];
|
|
60
59
|
}
|
|
61
60
|
});
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
return (proxyFromArgs ||
|
|
62
|
+
process.env.FIORI_TOOLS_PROXY ||
|
|
63
|
+
process.env.npm_config_proxy ||
|
|
64
|
+
process.env.npm_config_https_proxy ||
|
|
65
|
+
process.env.http_proxy ||
|
|
64
66
|
process.env.HTTP_PROXY ||
|
|
65
67
|
process.env.https_proxy ||
|
|
66
68
|
process.env.HTTPS_PROXY ||
|
|
67
|
-
|
|
68
|
-
process.env.npm_config_https_proxy;
|
|
69
|
-
if (proxyFromFioriToolsConfig) {
|
|
70
|
-
process.env.npm_config_proxy = proxyFromFioriToolsConfig;
|
|
71
|
-
process.env.npm_config_https_proxy = proxyFromFioriToolsConfig;
|
|
72
|
-
return proxyFromFioriToolsConfig;
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
return proxyFromOSEnvConfig;
|
|
76
|
-
}
|
|
69
|
+
yamlProxyServer);
|
|
77
70
|
};
|
|
78
71
|
exports.getCorporateProxyServer = getCorporateProxyServer;
|
|
79
72
|
/**
|
|
@@ -94,15 +87,35 @@ const hideProxyCredentials = (proxy) => {
|
|
|
94
87
|
};
|
|
95
88
|
exports.hideProxyCredentials = hideProxyCredentials;
|
|
96
89
|
/**
|
|
97
|
-
*
|
|
90
|
+
* Updates the proxy configuration with values from runtime args (highest priority), environment variables or given config value.
|
|
98
91
|
*
|
|
99
|
-
* @param
|
|
100
|
-
* @returns false if host is excluded from user's corporate server, true otherwise
|
|
92
|
+
* @param proxyFromConfig - optional proxy string from configuration
|
|
101
93
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
94
|
+
function updateProxyEnv(proxyFromConfig) {
|
|
95
|
+
let proxyFromArgs;
|
|
96
|
+
process.argv.forEach((arg) => {
|
|
97
|
+
if (arg.match(/proxy=/g)) {
|
|
98
|
+
proxyFromArgs = arg.split('=')[1];
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
if (proxyFromArgs || process.env.FIORI_TOOLS_PROXY) {
|
|
102
|
+
process.env.npm_config_proxy = proxyFromArgs || process.env.FIORI_TOOLS_PROXY;
|
|
103
|
+
process.env.npm_config_https_proxy = proxyFromArgs || process.env.FIORI_TOOLS_PROXY;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const proxyFromEnv = process.env.npm_config_proxy ||
|
|
107
|
+
process.env.npm_config_https_proxy ||
|
|
108
|
+
process.env.http_proxy ||
|
|
109
|
+
process.env.HTTP_PROXY ||
|
|
110
|
+
process.env.https_proxy ||
|
|
111
|
+
process.env.HTTPS_PROXY;
|
|
112
|
+
if (!proxyFromEnv && proxyFromConfig) {
|
|
113
|
+
process.env.npm_config_proxy = proxyFromConfig;
|
|
114
|
+
process.env.npm_config_https_proxy = proxyFromConfig;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
exports.updateProxyEnv = updateProxyEnv;
|
|
106
119
|
/**
|
|
107
120
|
* Returns the name of html file, which is used to preview the application, from the URL.
|
|
108
121
|
*
|
package/dist/ui5/middleware.js
CHANGED
|
@@ -12,7 +12,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
16
15
|
const logger_1 = require("@sap-ux/logger");
|
|
17
16
|
const base_1 = require("../base");
|
|
18
17
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
@@ -70,11 +69,9 @@ module.exports = ({ options }) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
70
69
|
const ui5Config = {
|
|
71
70
|
path: ui5Path,
|
|
72
71
|
url: envUI5Url || ui5.url,
|
|
73
|
-
version: ui5Version
|
|
72
|
+
version: ui5Version,
|
|
73
|
+
proxy: config.proxy
|
|
74
74
|
};
|
|
75
|
-
if (corporateProxyServer && base_1.isProxyRequired(ui5Config.url)) {
|
|
76
|
-
proxyOptions.agent = new https_proxy_agent_1.HttpsProxyAgent(corporateProxyServer);
|
|
77
|
-
}
|
|
78
75
|
routes.push({ route: ui5Config.path, handler: base_1.ui5Proxy(ui5Config, proxyOptions) });
|
|
79
76
|
ui5Configs.push(ui5Config);
|
|
80
77
|
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aui5-proxy-middleware"
|
|
11
11
|
},
|
|
12
|
-
"version": "1.1.
|
|
12
|
+
"version": "1.1.16",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@sap-ux/logger": "0.3.1",
|
|
25
|
-
"@sap-ux/ui5-config": "0.15.
|
|
25
|
+
"@sap-ux/ui5-config": "0.15.4",
|
|
26
26
|
"dotenv": "16.0.0",
|
|
27
27
|
"http-proxy-middleware": "2.0.1",
|
|
28
28
|
"https-proxy-agent": "5.0.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"proxy-from-env": "1.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@sap-ux/project-access": "1.0.
|
|
33
|
+
"@sap-ux/project-access": "1.0.1",
|
|
34
34
|
"@types/express": "4.17.13",
|
|
35
35
|
"@types/supertest": "2.0.12",
|
|
36
36
|
"@types/proxy-from-env": "1.0.1",
|