@sap-ux/backend-proxy-middleware 0.6.39 → 0.6.42

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.
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import type { ServerOptions } from 'http-proxy';
3
4
  import type { RequestHandler, Options } from 'http-proxy-middleware';
4
5
  import type { ClientRequest, IncomingMessage, ServerResponse } from 'http';
@@ -19,7 +20,7 @@ export declare const ProxyEventHandlers: {
19
20
  * @param _res (not used)
20
21
  * @param _options (not used)
21
22
  */
22
- onProxyReq(proxyReq: ClientRequest, _req?: IncomingMessage | undefined, _res?: ServerResponse | undefined, _options?: ServerOptions | undefined): void;
23
+ onProxyReq(proxyReq: ClientRequest, _req?: IncomingMessage, _res?: ServerResponse, _options?: ServerOptions): void;
23
24
  /**
24
25
  * Retrieve the set-cookie headers from the response and transform secure cookies to insecure ones.
25
26
  *
@@ -27,7 +28,7 @@ export declare const ProxyEventHandlers: {
27
28
  * @param _req (not used) original request
28
29
  * @param _res (not used)
29
30
  */
30
- onProxyRes(proxyRes: IncomingMessage, _req?: IncomingMessage | undefined, _res?: ServerResponse | undefined): void;
31
+ onProxyRes(proxyRes: IncomingMessage, _req?: IncomingMessage, _res?: ServerResponse): void;
31
32
  };
32
33
  /**
33
34
  * Specifically handling errors due to unsigned certificates and empty errors.
@@ -100,8 +100,8 @@ exports.proxyErrorHandler = proxyErrorHandler;
100
100
  function getApiHubKey(logger) {
101
101
  return __awaiter(this, void 0, void 0, function* () {
102
102
  let apiHubKey = process.env.API_HUB_API_KEY;
103
- if (!apiHubKey && !btp_utils_1.isAppStudio()) {
104
- const apiHubStore = (yield store_1.getService({
103
+ if (!apiHubKey && !(0, btp_utils_1.isAppStudio)()) {
104
+ const apiHubStore = (yield (0, store_1.getService)({
105
105
  logger,
106
106
  entityName: 'api-hub'
107
107
  }));
@@ -208,16 +208,16 @@ exports.initI18n = initI18n;
208
208
  function enhanceConfigsForDestination(proxyOptions, backend) {
209
209
  var _a;
210
210
  return __awaiter(this, void 0, void 0, function* () {
211
- proxyOptions.target = btp_utils_1.getDestinationUrlForAppStudio(backend.destination);
211
+ proxyOptions.target = (0, btp_utils_1.getDestinationUrlForAppStudio)(backend.destination);
212
212
  if (backend.destinationInstance) {
213
- proxyOptions.headers[btp_utils_1.BAS_DEST_INSTANCE_CRED_HEADER] = yield btp_utils_1.getCredentialsForDestinationService(backend.destinationInstance);
213
+ proxyOptions.headers[btp_utils_1.BAS_DEST_INSTANCE_CRED_HEADER] = yield (0, btp_utils_1.getCredentialsForDestinationService)(backend.destinationInstance);
214
214
  }
215
215
  else {
216
- const destinations = yield btp_utils_1.listDestinations();
216
+ const destinations = yield (0, btp_utils_1.listDestinations)();
217
217
  const destination = destinations[backend.destination];
218
218
  if (destination) {
219
219
  // in case of a full url destination remove the path defined in the destination from the forwarded call
220
- if (btp_utils_1.isFullUrlDestination(destination)) {
220
+ if ((0, btp_utils_1.isFullUrlDestination)(destination)) {
221
221
  backend.path = new URL(destination.Host).pathname.replace(/\/$/, '');
222
222
  backend.pathReplace = (_a = backend.pathReplace) !== null && _a !== void 0 ? _a : '/';
223
223
  }
@@ -241,7 +241,7 @@ function enhanceConfigForSystem(proxyOptions, system, oAuthRequired, tokenChange
241
241
  return __awaiter(this, void 0, void 0, function* () {
242
242
  if (oAuthRequired) {
243
243
  if (system.serviceKeys) {
244
- const provider = axios_extension_1.createForAbapOnCloud({
244
+ const provider = (0, axios_extension_1.createForAbapOnCloud)({
245
245
  environment: axios_extension_1.AbapCloudEnvironment.Standalone,
246
246
  service: system.serviceKeys,
247
247
  refreshToken: system.refreshToken,
@@ -256,7 +256,7 @@ function enhanceConfigForSystem(proxyOptions, system, oAuthRequired, tokenChange
256
256
  }
257
257
  }
258
258
  else if (system.authenticationType === store_1.AuthenticationType.ReentranceTicket) {
259
- const provider = axios_extension_1.createForAbapOnCloud({
259
+ const provider = (0, axios_extension_1.createForAbapOnCloud)({
260
260
  environment: axios_extension_1.AbapCloudEnvironment.EmbeddedSteampunk,
261
261
  url: system.url
262
262
  });
@@ -290,7 +290,7 @@ function generateProxyMiddlewareOptions(backend, options = {}, logger = new logg
290
290
  // always set the target to the url provided in yaml
291
291
  proxyOptions.target = backend.url;
292
292
  // overwrite url if running in AppStudio
293
- if (btp_utils_1.isAppStudio()) {
293
+ if ((0, btp_utils_1.isAppStudio)()) {
294
294
  const destBackend = backend;
295
295
  destBackend.destination = (_a = destBackend.destination) !== null && _a !== void 0 ? _a : process.env.FIORI_TOOLS_DESTINATION;
296
296
  if (destBackend.destination) {
@@ -302,7 +302,7 @@ function generateProxyMiddlewareOptions(backend, options = {}, logger = new logg
302
302
  const localBackend = backend;
303
303
  // check if system credentials are stored in the store
304
304
  try {
305
- const systemStore = yield store_1.getService({ logger, entityName: 'system' });
305
+ const systemStore = yield (0, store_1.getService)({ logger, entityName: 'system' });
306
306
  const system = yield systemStore.read(new store_1.BackendSystemKey({ url: localBackend.url, client: localBackend.client }));
307
307
  if (system) {
308
308
  yield enhanceConfigForSystem(proxyOptions, system, backend.scp, (refreshToken) => {
@@ -323,7 +323,7 @@ function generateProxyMiddlewareOptions(backend, options = {}, logger = new logg
323
323
  }
324
324
  proxyOptions.pathRewrite = exports.PathRewriters.getPathRewrite(backend, logger);
325
325
  if (backend.bsp) {
326
- yield bsp_1.addOptionsForEmbeddedBSP(backend.bsp, proxyOptions, logger);
326
+ yield (0, bsp_1.addOptionsForEmbeddedBSP)(backend.bsp, proxyOptions, logger);
327
327
  }
328
328
  if (backend.apiHub) {
329
329
  const apiHubKey = yield getApiHubKey(logger);
@@ -335,8 +335,8 @@ function generateProxyMiddlewareOptions(backend, options = {}, logger = new logg
335
335
  throw new Error(`Unable to determine target from configuration:\n${JSON.stringify(backend, null, 2)}`);
336
336
  }
337
337
  // update proxy config with values coming from args or ui5.yaml
338
- config_1.updateProxyEnv(backend.proxy);
339
- backend.proxy = proxy_from_env_1.getProxyForUrl(proxyOptions.target);
338
+ (0, config_1.updateProxyEnv)(backend.proxy);
339
+ backend.proxy = (0, proxy_from_env_1.getProxyForUrl)(proxyOptions.target);
340
340
  if (backend.proxy) {
341
341
  proxyOptions.agent = new https_proxy_agent_1.HttpsProxyAgent(backend.proxy);
342
342
  }
@@ -355,7 +355,7 @@ exports.generateProxyMiddlewareOptions = generateProxyMiddlewareOptions;
355
355
  */
356
356
  function createProxy(backend, options, logger) {
357
357
  return __awaiter(this, void 0, void 0, function* () {
358
- return http_proxy_middleware_1.createProxyMiddleware(yield generateProxyMiddlewareOptions(backend, options, logger));
358
+ return (0, http_proxy_middleware_1.createProxyMiddleware)(yield generateProxyMiddlewareOptions(backend, options, logger));
359
359
  });
360
360
  }
361
361
  exports.createProxy = createProxy;
@@ -50,7 +50,7 @@ export interface LocalBackendConfig extends BaseBackendConfig {
50
50
  */
51
51
  url: string;
52
52
  }
53
- export declare type BackendConfig = LocalBackendConfig | DestinationBackendConfig;
53
+ export type BackendConfig = LocalBackendConfig | DestinationBackendConfig;
54
54
  export interface BackendMiddlewareConfig {
55
55
  backend: BackendConfig;
56
56
  options?: Partial<Options>;
package/dist/ext/bsp.js CHANGED
@@ -36,12 +36,12 @@ exports.convertAppDescriptorToManifest = convertAppDescriptorToManifest;
36
36
  */
37
37
  function promptUserPass(log) {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
- if (btp_utils_1.isAppStudio()) {
40
- const { authNeeded } = yield prompts_1.default([
39
+ if ((0, btp_utils_1.isAppStudio)()) {
40
+ const { authNeeded } = yield (0, prompts_1.default)([
41
41
  {
42
42
  type: 'confirm',
43
43
  name: 'authNeeded',
44
- message: `${chalk_1.cyan(i18next_1.default.t('info.authNeeded'))}\n\n`
44
+ message: `${(0, chalk_1.cyan)(i18next_1.default.t('info.authNeeded'))}\n\n`
45
45
  }
46
46
  ]);
47
47
  if (!authNeeded) {
@@ -49,13 +49,13 @@ function promptUserPass(log) {
49
49
  }
50
50
  }
51
51
  else {
52
- log.info(chalk_1.yellow(i18next_1.default.t('info.credentialsRequiredForFLP')));
52
+ log.info((0, chalk_1.yellow)(i18next_1.default.t('info.credentialsRequiredForFLP')));
53
53
  }
54
- const { username, password } = yield prompts_1.default([
54
+ const { username, password } = yield (0, prompts_1.default)([
55
55
  {
56
56
  type: 'text',
57
57
  name: 'username',
58
- message: `${chalk_1.cyan(i18next_1.default.t('info.username'))}\n\n`,
58
+ message: `${(0, chalk_1.cyan)(i18next_1.default.t('info.username'))}\n\n`,
59
59
  validate: (value) => {
60
60
  if (!value || !value.trim()) {
61
61
  return `${i18next_1.default.t('error.emptyUsername')}`;
@@ -68,7 +68,7 @@ function promptUserPass(log) {
68
68
  {
69
69
  type: 'password',
70
70
  name: 'password',
71
- message: `${chalk_1.cyan(i18next_1.default.t('info.password'))}\n\n`,
71
+ message: `${(0, chalk_1.cyan)(i18next_1.default.t('info.password'))}\n\n`,
72
72
  validate: (value) => {
73
73
  if (!value || !value.trim()) {
74
74
  return `${i18next_1.default.t('error.emptyPassword')}`;
@@ -80,7 +80,7 @@ function promptUserPass(log) {
80
80
  }
81
81
  ], {
82
82
  onCancel: () => {
83
- log.info(chalk_1.yellow(i18next_1.default.t('info.operationAborted')));
83
+ log.info((0, chalk_1.yellow)(i18next_1.default.t('info.operationAborted')));
84
84
  return process.exit(1);
85
85
  }
86
86
  });
package/dist/index.js CHANGED
@@ -4,5 +4,5 @@ exports.createProxy = exports.generateProxyMiddlewareOptions = void 0;
4
4
  const proxy_1 = require("./base/proxy");
5
5
  Object.defineProperty(exports, "generateProxyMiddlewareOptions", { enumerable: true, get: function () { return proxy_1.generateProxyMiddlewareOptions; } });
6
6
  Object.defineProperty(exports, "createProxy", { enumerable: true, get: function () { return proxy_1.createProxy; } });
7
- proxy_1.initI18n();
7
+ (0, proxy_1.initI18n)();
8
8
  //# sourceMappingURL=index.js.map
@@ -43,14 +43,14 @@ module.exports = ({ options }) => __awaiter(void 0, void 0, void 0, function* ()
43
43
  const logger = new logger_1.ToolsLogger({
44
44
  transports: [new logger_1.UI5ToolingTransport({ moduleName: 'backend-proxy-middleware' })]
45
45
  });
46
- yield proxy_1.initI18n();
46
+ yield (0, proxy_1.initI18n)();
47
47
  dotenv_1.default.config();
48
48
  const backend = options.configuration.backend;
49
49
  const configOptions = (_a = options.configuration.options) !== null && _a !== void 0 ? _a : {};
50
50
  configOptions.secure = configOptions.secure !== undefined ? !!configOptions.secure : true;
51
51
  try {
52
- const proxyOptions = yield proxy_1.generateProxyMiddlewareOptions(options.configuration.backend, configOptions, logger);
53
- const proxyFn = http_proxy_middleware_1.createProxyMiddleware(proxyOptions);
52
+ const proxyOptions = yield (0, proxy_1.generateProxyMiddlewareOptions)(options.configuration.backend, configOptions, logger);
53
+ const proxyFn = (0, http_proxy_middleware_1.createProxyMiddleware)(proxyOptions);
54
54
  logger.info(`Starting backend-proxy-middleware using following configuration:\nbackend: ${JSON.stringify(Object.assign(Object.assign({}, backend), { proxy: formatProxyForLogging(backend.proxy) }))}\noptions: ${JSON.stringify(configOptions)}'`);
55
55
  return (req, res, next) => {
56
56
  if (req.path.startsWith(backend.path)) {
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%3Abackend-proxy-middleware"
11
11
  },
12
- "version": "0.6.39",
12
+ "version": "0.6.42",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -21,10 +21,10 @@
21
21
  "!dist/**/*.map"
22
22
  ],
23
23
  "dependencies": {
24
- "@sap-ux/axios-extension": "0.14.0",
25
- "@sap-ux/btp-utils": "0.11.3",
26
- "@sap-ux/logger": "0.3.3",
27
- "@sap-ux/store": "0.3.8",
24
+ "@sap-ux/axios-extension": "1.0.1",
25
+ "@sap-ux/btp-utils": "0.11.5",
26
+ "@sap-ux/logger": "0.3.5",
27
+ "@sap-ux/store": "0.3.10",
28
28
  "chalk": "4.1.2",
29
29
  "dotenv": "16.0.0",
30
30
  "http-proxy-middleware": "2.0.1",