Comparing version 4.2.1 to 4.3.0
@@ -70,2 +70,4 @@ /// <reference types="node" /> | ||
fetchImplementation?: FetchImplementation; | ||
cert?: string; | ||
key?: string; | ||
} | ||
@@ -72,0 +74,0 @@ /** |
@@ -0,4 +1,7 @@ | ||
/// <reference types="node" /> | ||
import { Agent } from 'http'; | ||
import { URL } from 'url'; | ||
import { GaxiosOptions, GaxiosPromise } from './common'; | ||
export declare class Gaxios { | ||
private agentCache; | ||
protected agentCache: Map<string, Agent | ((parsedUrl: URL) => Agent)>; | ||
/** | ||
@@ -23,3 +26,3 @@ * Default HTTP options that will be used for every HTTP request. | ||
*/ | ||
private _request; | ||
protected _request<T = any>(opts?: GaxiosOptions): GaxiosPromise<T>; | ||
private getResponseData; | ||
@@ -26,0 +29,0 @@ /** |
@@ -20,5 +20,7 @@ "use strict"; | ||
const extend_1 = __importDefault(require("extend")); | ||
const https_1 = require("https"); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const querystring_1 = __importDefault(require("querystring")); | ||
const is_stream_1 = __importDefault(require("is-stream")); | ||
const url_1 = require("url"); | ||
const common_1 = require("./common"); | ||
@@ -68,3 +70,3 @@ const retry_1 = require("./retry"); | ||
const noProxyUrls = noProxyEnv.split(','); | ||
const parsedURL = new URL(url); | ||
const parsedURL = new url_1.URL(url); | ||
return !!noProxyUrls.find(url => { | ||
@@ -138,3 +140,4 @@ if (url.startsWith('*.') || url.startsWith('.')) { | ||
if (shouldRetry && config) { | ||
err.config.retryConfig.currentRetryAttempt = config.retryConfig.currentRetryAttempt; | ||
err.config.retryConfig.currentRetryAttempt = | ||
config.retryConfig.currentRetryAttempt; | ||
return this._request(err.config); | ||
@@ -238,6 +241,32 @@ } | ||
else { | ||
opts.agent = new HttpsProxyAgent(proxy); | ||
// Proxy is being used in conjunction with mTLS. | ||
if (opts.cert && opts.key) { | ||
const parsedURL = new url_1.URL(proxy); | ||
opts.agent = new HttpsProxyAgent({ | ||
port: parsedURL.port, | ||
host: parsedURL.host, | ||
protocol: parsedURL.protocol, | ||
cert: opts.cert, | ||
key: opts.key, | ||
}); | ||
} | ||
else { | ||
opts.agent = new HttpsProxyAgent(proxy); | ||
} | ||
this.agentCache.set(proxy, opts.agent); | ||
} | ||
} | ||
else if (opts.cert && opts.key) { | ||
// Configure client for mTLS: | ||
if (this.agentCache.has(opts.key)) { | ||
opts.agent = this.agentCache.get(opts.key); | ||
} | ||
else { | ||
opts.agent = new https_1.Agent({ | ||
cert: opts.cert, | ||
key: opts.key, | ||
}); | ||
this.agentCache.set(opts.key, opts.agent); | ||
} | ||
} | ||
return opts; | ||
@@ -244,0 +273,0 @@ } |
# Changelog | ||
## [4.3.0](https://www.github.com/googleapis/gaxios/compare/v4.2.1...v4.3.0) (2021-05-26) | ||
### Features | ||
* allow cert and key to be provided for mTLS ([#399](https://www.github.com/googleapis/gaxios/issues/399)) ([d74ab91](https://www.github.com/googleapis/gaxios/commit/d74ab9125d581e46d655614729872e79317c740d)) | ||
### [4.2.1](https://www.github.com/googleapis/gaxios/compare/v4.2.0...v4.2.1) (2021-04-20) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "gaxios", | ||
"version": "4.2.1", | ||
"version": "4.3.0", | ||
"description": "A simple common HTTP client specifically for Google APIs and services.", | ||
@@ -53,3 +53,3 @@ "main": "build/src/index.js", | ||
"@types/ncp": "^2.0.1", | ||
"@types/node": "^11.9.5", | ||
"@types/node": "^14.0.0", | ||
"@types/node-fetch": "^2.5.7", | ||
@@ -59,2 +59,4 @@ "@types/sinon": "^10.0.0", | ||
"@types/uuid": "^8.0.0", | ||
"assert": "^2.0.0", | ||
"browserify": "^17.0.0", | ||
"c8": "^7.0.0", | ||
@@ -82,3 +84,4 @@ "cors": "^2.8.5", | ||
"puppeteer": "^8.0.0", | ||
"sinon": "^10.0.0", | ||
"sinon": "^11.0.0", | ||
"stream-browserify": "^3.0.0", | ||
"tmp": "0.2.1", | ||
@@ -88,3 +91,3 @@ "ts-loader": "^8.0.0", | ||
"uuid": "^8.0.0", | ||
"webpack": "^5.30.0", | ||
"webpack": "^5.35.0", | ||
"webpack-cli": "^4.0.0" | ||
@@ -91,0 +94,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66675
696
48
3