diff --git a/package-lock.json b/package-lock.json index 1d0c6a2..946cbed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "2.8.0", "license": "Apache-2.0", "dependencies": { - "axios": "^0.28.0", + "axios": "^0.27.0", "axios-retry": "~3.2.5", "https-proxy-agent": "^5.0.1" }, @@ -24,11 +24,11 @@ "eslint-config-prettier": "^8.5.0", "faker": "5.5.3", "http-proxy": "^1.18.1", - "jest": "^29.3.1", + "jest": "^29.7.0", "nock": "^13.2.4", "prettier": "^2.6.2", "tmp": "^0.2.1", - "ts-jest": "^29.0.3", + "ts-jest": "^29.2.5", "typescript": "^4.7.2" } }, @@ -1862,14 +1862,13 @@ "license": "MIT" }, "node_modules/axios": { - "version": "0.28.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.28.1.tgz", - "integrity": "sha512-iUcGA5a7p0mVb4Gm/sy+FSECNkPFT4y7wt6OM/CDpO/OnNCvSs3PoMG8ibrC9jRoGYU0gUK5pXVC4NPXq6lHRQ==", + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", "license": "MIT", "dependencies": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" } }, "node_modules/axios-retry": { @@ -5194,12 +5193,6 @@ "node": ">= 8" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "license": "MIT" - }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/package.json b/package.json index 97ecdee..7fbb98c 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "dist/**/*" ], "dependencies": { - "axios": "^0.28.0", + "axios": "^0.27.0", "axios-retry": "~3.2.5", "https-proxy-agent": "^5.0.1" }, @@ -42,11 +42,11 @@ "eslint-config-prettier": "^8.5.0", "faker": "5.5.3", "http-proxy": "^1.18.1", - "jest": "^29.3.1", + "jest": "^29.7.0", "nock": "^13.2.4", "prettier": "^2.6.2", "tmp": "^0.2.1", - "ts-jest": "^29.0.3", + "ts-jest": "^29.2.5", "typescript": "^4.7.2" }, "keywords": [ diff --git a/src/HttpClient.ts b/src/HttpClient.ts index a7cc7b5..f3beba9 100644 --- a/src/HttpClient.ts +++ b/src/HttpClient.ts @@ -1,11 +1,4 @@ -import axios, { - AxiosError, - AxiosInstance, - AxiosProxyConfig, - AxiosRequestConfig, - AxiosResponse, - AxiosResponseHeaders -} from 'axios'; +import axios, { AxiosError, AxiosInstance, AxiosProxyConfig, AxiosRequestConfig } from 'axios'; import { IClientResponse, ILogger, IProxyConfig, RetryOnStatusCode } from '../model'; import axiosRetry, { IAxiosRetryConfig } from 'axios-retry'; import { HttpsProxyAgent } from 'https-proxy-agent'; @@ -63,17 +56,9 @@ export class HttpClient { } public async doRequest(requestParams: IRequestParams): Promise { - const response : AxiosResponse = await this._axiosInstance(requestParams); - - return { - data: response.data, - headers: this.mapHeaders(response.headers), // Use your mapHeaders function - status: response.status, - }; + return await this._axiosInstance(requestParams); } - - public async doAuthRequest(requestParams: IRequestParams): Promise { if (this._accessToken !== '') { this.addAuthHeader(requestParams); @@ -109,23 +94,6 @@ export class HttpClient { } } - private mapHeaders(headers?: AxiosResponseHeaders): { [key: string]: string } { - const mappedHeaders: { [key: string]: string } = {}; - - if (!headers) { - return mappedHeaders; - } - - Object.keys(headers).forEach((key) => { - const headerValue : string | undefined = headers[key]; - if (headerValue !== undefined) { - mappedHeaders[key] = headerValue.toString(); - } - }); - - return mappedHeaders; - } - /** * Use to create httpsAgent to handle Http proxy sending to a https server. * (Artifactory is https server, proxy protocol can be both)