@sap-ux/axios-extension 1.21.2 → 1.21.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/README.adoc CHANGED
@@ -120,20 +120,21 @@ See more examples in link:./test/factory.test.ts[/test/factory.test.ts]
120
120
 
121
121
  ## Proxy Support
122
122
 
123
- To enable support for TLS (Transport Layer Security), enable the `HTTPS_PROXY` environment variable, as shown;
123
+ To enable support for TLS (Transport Layer Security) connections when using `HTTPS_PROXY`, update your environment by setting the `TOOLSUITE_FEATURES` environment variable with `sap.ux.enablePatchProxy`, as shown;
124
124
 
125
125
  ```bash
126
+ export TOOLSUITE_FEATURES=sap.ux.enablePatchProxy
126
127
  export HTTPS_PROXY=<YOUR-PROXY:PORT>
127
- # With Credentials
128
- export HTTPS_PROXY=<USERNAME>:<PASSWORD>@<YOUR-PROXY:PORT>
129
128
  ```
130
129
 
131
- Sample Configuration
130
+ In order to support credentials in the proxy URL, you can set the `HTTPS_PROXY` environment variable to include the username and password in the URL. For example:
131
+
132
132
  ```bash
133
+ export TOOLSUITE_FEATURES=sap.ux.enablePatchProxy
133
134
  export HTTPS_PROXY=http://user:password@proxy.domain.com:3128
134
135
  ```
135
136
 
136
- Ensure you restart any running processes or applications to apply the changes.
137
+ Ensure you restart any running processes to apply the changes.
137
138
 
138
139
  Example Scenario
139
140
 
@@ -1,8 +1,8 @@
1
- import type { Service } from '../base/service-provider';
2
1
  import type { AxiosResponse } from 'axios';
3
2
  import { Axios } from 'axios';
4
3
  import type { Logger } from '@sap-ux/logger';
5
4
  import type { ManifestNamespace } from '@sap-ux/project-access';
5
+ import type { Service } from '../base/service-provider';
6
6
  import type { TransportConfig } from './ui5-abap-repository-service';
7
7
  export type Manifest = ManifestNamespace.SAPJSONSchemaForWebApplicationManifestFile & {
8
8
  [key: string]: unknown;
@@ -2,8 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LayeredRepositoryService = exports.AdaptationProjectType = void 0;
4
4
  const axios_1 = require("axios");
5
- const logger_1 = require("@sap-ux/logger");
6
5
  const fs_1 = require("fs");
6
+ const url_1 = require("url");
7
+ const logger_1 = require("@sap-ux/logger");
7
8
  const odata_request_error_1 = require("../base/odata-request-error");
8
9
  const message_1 = require("./message");
9
10
  /**
@@ -32,6 +33,13 @@ function getNamespaceAsString(namespace) {
32
33
  function isBuffer(input) {
33
34
  return input.BYTES_PER_ELEMENT !== undefined;
34
35
  }
36
+ /**
37
+ * Decodes url parameters.
38
+ *
39
+ * @param params An object containing the parameters to be decoded.
40
+ * @returns The decoded parameters as a string.
41
+ */
42
+ const decodeUrlParams = (params) => decodeURIComponent(params.toString());
35
43
  /**
36
44
  * Path suffix for all DTA actions.
37
45
  */
@@ -67,13 +75,13 @@ class LayeredRepositoryService extends axios_1.Axios {
67
75
  */
68
76
  async mergeAppDescriptorVariant(appDescriptorVariant, workspacePath) {
69
77
  const path = '/appdescr_variant_preview/';
70
- const params = new URLSearchParams(this.defaults?.params);
78
+ const params = new url_1.URLSearchParams(this.defaults?.params);
71
79
  if (workspacePath) {
72
80
  params.append('workspacePath', workspacePath);
73
81
  }
74
82
  try {
75
83
  const response = await this.put(path, appDescriptorVariant, {
76
- paramsSerializer: (params) => decodeURIComponent(params.toString()),
84
+ paramsSerializer: decodeUrlParams,
77
85
  params,
78
86
  headers: {
79
87
  'Content-Type': 'application/zip'
@@ -194,13 +202,16 @@ class LayeredRepositoryService extends axios_1.Axios {
194
202
  */
195
203
  async getSystemInfo(language = 'EN', cloudPackage) {
196
204
  try {
197
- const params = {
205
+ const params = new url_1.URLSearchParams({
198
206
  'sap-language': language
199
- };
207
+ });
200
208
  if (cloudPackage) {
201
- params['package'] = cloudPackage;
209
+ params.append('package', cloudPackage);
202
210
  }
203
- const response = await this.get(`${DTA_PATH_SUFFIX}system_info`, { params });
211
+ const response = await this.get(`${DTA_PATH_SUFFIX}system_info`, {
212
+ params,
213
+ paramsSerializer: decodeUrlParams
214
+ });
204
215
  this.tryLogResponse(response, 'Successful getting system info.');
205
216
  return JSON.parse(response.data);
206
217
  }
package/dist/factory.js CHANGED
@@ -20,6 +20,7 @@ const patchTls_1 = require("./base/patchTls");
20
20
  const proxy_from_env_1 = require("proxy-from-env");
21
21
  const https_proxy_agent_1 = require("https-proxy-agent");
22
22
  const http_proxy_agent_1 = require("http-proxy-agent");
23
+ const feature_toggle_1 = require("@sap-ux/feature-toggle");
23
24
  /**
24
25
  * PatchedHttpsProxyAgent is a custom implementation of HttpsProxyAgent that allows to pass additional options, currently not supported by the original implementation when calling tls.connect
25
26
  */
@@ -61,7 +62,8 @@ function createInstance(ProviderType, config) {
61
62
  rejectUnauthorized: !providerConfig.ignoreCertErrors
62
63
  };
63
64
  const localProxy = (0, proxy_from_env_1.getProxyForUrl)(config.baseURL);
64
- if (localProxy) {
65
+ const isPatchProxyEnabled = (0, feature_toggle_1.isFeatureEnabled)('sap.ux.enablePatchProxy');
66
+ if (isPatchProxyEnabled && localProxy) {
65
67
  // axios doesn't handle proxies correctly, instead use a custom agent with axios proxy disabled
66
68
  providerConfig.httpsAgent = new PatchedHttpsProxyAgent(localProxy, agentOptions);
67
69
  providerConfig.httpAgent = new http_proxy_agent_1.HttpProxyAgent(localProxy);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/axios-extension",
3
- "version": "1.21.2",
3
+ "version": "1.21.4",
4
4
  "description": "Extension of the Axios module adding convenience methods to interact with SAP systems especially with OData services.",
5
5
  "repository": {
6
6
  "type": "git",