typed-rest-client
Advanced tools
Comparing version 0.11.0 to 0.12.0
@@ -50,2 +50,6 @@ import url = require("url"); | ||
private _httpProxyBypassHosts; | ||
private _certConfig; | ||
private _ca; | ||
private _cert; | ||
private _key; | ||
constructor(userAgent: string, handlers?: ifm.IRequestHandler[], requestOptions?: ifm.IRequestOptions); | ||
@@ -52,0 +56,0 @@ options(requestUrl: string, additionalHeaders?: ifm.IHeaders): Promise<HttpClientResponse>; |
@@ -16,2 +16,3 @@ // Copyright (c) Microsoft. All rights reserved. | ||
const tunnel = require("tunnel"); | ||
const fs = require("fs"); | ||
http.globalAgent.maxSockets = 100; | ||
@@ -86,2 +87,13 @@ var HttpCodes; | ||
} | ||
this._certConfig = requestOptions.cert; | ||
// cache the cert content into memory, so we don't have to read it from disk every time | ||
if (this._certConfig && this._certConfig.caFile && fs.existsSync(this._certConfig.caFile)) { | ||
this._ca = fs.readFileSync(this._certConfig.caFile, 'utf8'); | ||
} | ||
if (this._certConfig && this._certConfig.certFile && fs.existsSync(this._certConfig.certFile)) { | ||
this._cert = fs.readFileSync(this._certConfig.certFile, 'utf8'); | ||
} | ||
if (this._certConfig && this._certConfig.keyFile && fs.existsSync(this._certConfig.keyFile)) { | ||
this._key = fs.readFileSync(this._certConfig.keyFile, 'utf8'); | ||
} | ||
} | ||
@@ -241,2 +253,9 @@ } | ||
} | ||
if (usingSsl && this._certConfig) { | ||
if (!info.options.agent) { | ||
info.options.agent = https.globalAgent; | ||
} | ||
let agent = info.options.agent; | ||
agent.options = Object.assign(agent.options || {}, { ca: this._ca, cert: this._cert, key: this._key, passphrase: this._certConfig.passphrase }); | ||
} | ||
// gives handlers an opportunity to participate | ||
@@ -243,0 +262,0 @@ if (this.handlers) { |
@@ -21,2 +21,3 @@ export interface IHeaders { | ||
proxy?: IProxyConfiguration; | ||
cert?: ICertConfiguration; | ||
} | ||
@@ -29,1 +30,7 @@ export interface IProxyConfiguration { | ||
} | ||
export interface ICertConfiguration { | ||
caFile?: string; | ||
certFile?: string; | ||
keyFile?: string; | ||
passphrase?: string; | ||
} |
{ | ||
"name": "typed-rest-client", | ||
"version": "0.11.0", | ||
"version": "0.12.0", | ||
"description": "Node Rest and Http Clients with typings for use with TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "./RestClient.js", |
@@ -32,2 +32,3 @@ # Typed Rest and Http Client with TypeScript Typings | ||
- Proxy support | ||
- Certificate support (Self-signed server and client cert) | ||
- Layered for Rest or Http use | ||
@@ -34,0 +35,0 @@ - Full Samples and Tests included for usage |
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
48853
991
82
5