Skip to content

Commit 8e21576

Browse files
authored
npm update dependencies (#59)
* npm update - @types/jest - @types/node - @typescript-eslint/parser - @zeit/ncc jest - jest-circus - prettier - ts-jest * npm run all * npm update graphql
1 parent 081ab6e commit 8e21576

File tree

3 files changed

+879
-1065
lines changed

3 files changed

+879
-1065
lines changed

dist/index.js

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9509,6 +9509,7 @@ var HttpCodes;
95099509
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
95109510
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
95119511
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
9512+
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
95129513
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
95139514
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
95149515
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
@@ -9533,8 +9534,18 @@ function getProxyUrl(serverUrl) {
95339534
return proxyUrl ? proxyUrl.href : '';
95349535
}
95359536
exports.getProxyUrl = getProxyUrl;
9536-
const HttpRedirectCodes = [HttpCodes.MovedPermanently, HttpCodes.ResourceMoved, HttpCodes.SeeOther, HttpCodes.TemporaryRedirect, HttpCodes.PermanentRedirect];
9537-
const HttpResponseRetryCodes = [HttpCodes.BadGateway, HttpCodes.ServiceUnavailable, HttpCodes.GatewayTimeout];
9537+
const HttpRedirectCodes = [
9538+
HttpCodes.MovedPermanently,
9539+
HttpCodes.ResourceMoved,
9540+
HttpCodes.SeeOther,
9541+
HttpCodes.TemporaryRedirect,
9542+
HttpCodes.PermanentRedirect
9543+
];
9544+
const HttpResponseRetryCodes = [
9545+
HttpCodes.BadGateway,
9546+
HttpCodes.ServiceUnavailable,
9547+
HttpCodes.GatewayTimeout
9548+
];
95389549
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
95399550
const ExponentialBackoffCeiling = 10;
95409551
const ExponentialBackoffTimeSlice = 5;
@@ -9659,18 +9670,22 @@ class HttpClient {
96599670
*/
96609671
async request(verb, requestUrl, data, headers) {
96619672
if (this._disposed) {
9662-
throw new Error("Client has already been disposed.");
9673+
throw new Error('Client has already been disposed.');
96639674
}
96649675
let parsedUrl = url.parse(requestUrl);
96659676
let info = this._prepareRequest(verb, parsedUrl, headers);
96669677
// Only perform retries on reads since writes may not be idempotent.
9667-
let maxTries = (this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1) ? this._maxRetries + 1 : 1;
9678+
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
9679+
? this._maxRetries + 1
9680+
: 1;
96689681
let numTries = 0;
96699682
let response;
96709683
while (numTries < maxTries) {
96719684
response = await this.requestRaw(info, data);
96729685
// Check if it's an authentication challenge
9673-
if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) {
9686+
if (response &&
9687+
response.message &&
9688+
response.message.statusCode === HttpCodes.Unauthorized) {
96749689
let authenticationHandler;
96759690
for (let i = 0; i < this.handlers.length; i++) {
96769691
if (this.handlers[i].canHandleAuthentication(response)) {
@@ -9688,21 +9703,32 @@ class HttpClient {
96889703
}
96899704
}
96909705
let redirectsRemaining = this._maxRedirects;
9691-
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1
9692-
&& this._allowRedirects
9693-
&& redirectsRemaining > 0) {
9694-
const redirectUrl = response.message.headers["location"];
9706+
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
9707+
this._allowRedirects &&
9708+
redirectsRemaining > 0) {
9709+
const redirectUrl = response.message.headers['location'];
96959710
if (!redirectUrl) {
96969711
// if there's no location to redirect to, we won't
96979712
break;
96989713
}
96999714
let parsedRedirectUrl = url.parse(redirectUrl);
9700-
if (parsedUrl.protocol == 'https:' && parsedUrl.protocol != parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) {
9701-
throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.");
9715+
if (parsedUrl.protocol == 'https:' &&
9716+
parsedUrl.protocol != parsedRedirectUrl.protocol &&
9717+
!this._allowRedirectDowngrade) {
9718+
throw new Error('Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true.');
97029719
}
97039720
// we need to finish reading the response before reassigning response
97049721
// which will leak the open socket.
97059722
await response.readBody();
9723+
// strip authorization header if redirected to a different hostname
9724+
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
9725+
for (let header in headers) {
9726+
// header names are case insensitive
9727+
if (header.toLowerCase() === 'authorization') {
9728+
delete headers[header];
9729+
}
9730+
}
9731+
}
97069732
// let's make the request with the new redirectUrl
97079733
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
97089734
response = await this.requestRaw(info, data);
@@ -9753,8 +9779,8 @@ class HttpClient {
97539779
*/
97549780
requestRawWithCallback(info, data, onResult) {
97559781
let socket;
9756-
if (typeof (data) === 'string') {
9757-
info.options.headers["Content-Length"] = Buffer.byteLength(data, 'utf8');
9782+
if (typeof data === 'string') {
9783+
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
97589784
}
97599785
let callbackCalled = false;
97609786
let handleResult = (err, res) => {
@@ -9767,7 +9793,7 @@ class HttpClient {
97679793
let res = new HttpClientResponse(msg);
97689794
handleResult(null, res);
97699795
});
9770-
req.on('socket', (sock) => {
9796+
req.on('socket', sock => {
97719797
socket = sock;
97729798
});
97739799
// If we ever get disconnected, we want the socket to timeout eventually
@@ -9782,10 +9808,10 @@ class HttpClient {
97829808
// res should have headers
97839809
handleResult(err, null);
97849810
});
9785-
if (data && typeof (data) === 'string') {
9811+
if (data && typeof data === 'string') {
97869812
req.write(data, 'utf8');
97879813
}
9788-
if (data && typeof (data) !== 'string') {
9814+
if (data && typeof data !== 'string') {
97899815
data.on('close', function () {
97909816
req.end();
97919817
});
@@ -9812,31 +9838,34 @@ class HttpClient {
98129838
const defaultPort = usingSsl ? 443 : 80;
98139839
info.options = {};
98149840
info.options.host = info.parsedUrl.hostname;
9815-
info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort;
9816-
info.options.path = (info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
9841+
info.options.port = info.parsedUrl.port
9842+
? parseInt(info.parsedUrl.port)
9843+
: defaultPort;
9844+
info.options.path =
9845+
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
98179846
info.options.method = method;
98189847
info.options.headers = this._mergeHeaders(headers);
98199848
if (this.userAgent != null) {
9820-
info.options.headers["user-agent"] = this.userAgent;
9849+
info.options.headers['user-agent'] = this.userAgent;
98219850
}
98229851
info.options.agent = this._getAgent(info.parsedUrl);
98239852
// gives handlers an opportunity to participate
98249853
if (this.handlers) {
9825-
this.handlers.forEach((handler) => {
9854+
this.handlers.forEach(handler => {
98269855
handler.prepareRequest(info.options);
98279856
});
98289857
}
98299858
return info;
98309859
}
98319860
_mergeHeaders(headers) {
9832-
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
9861+
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
98339862
if (this.requestOptions && this.requestOptions.headers) {
98349863
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
98359864
}
98369865
return lowercaseKeys(headers || {});
98379866
}
98389867
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
9839-
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {});
9868+
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
98409869
let clientHeader;
98419870
if (this.requestOptions && this.requestOptions.headers) {
98429871
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
@@ -9874,7 +9903,7 @@ class HttpClient {
98749903
proxyAuth: proxyUrl.auth,
98759904
host: proxyUrl.hostname,
98769905
port: proxyUrl.port
9877-
},
9906+
}
98789907
};
98799908
let tunnelAgent;
98809909
const overHttps = proxyUrl.protocol === 'https:';
@@ -9901,7 +9930,9 @@ class HttpClient {
99019930
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
99029931
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
99039932
// we have to cast it to any and change it directly
9904-
agent.options = Object.assign(agent.options || {}, { rejectUnauthorized: false });
9933+
agent.options = Object.assign(agent.options || {}, {
9934+
rejectUnauthorized: false
9935+
});
99059936
}
99069937
return agent;
99079938
}
@@ -9962,7 +9993,7 @@ class HttpClient {
99629993
msg = contents;
99639994
}
99649995
else {
9965-
msg = "Failed request: (" + statusCode + ")";
9996+
msg = 'Failed request: (' + statusCode + ')';
99669997
}
99679998
let err = new Error(msg);
99689999
// attach statusCode and body obj (if available) to the error object
@@ -28241,12 +28272,10 @@ function getProxyUrl(reqUrl) {
2824128272
}
2824228273
let proxyVar;
2824328274
if (usingSsl) {
28244-
proxyVar = process.env["https_proxy"] ||
28245-
process.env["HTTPS_PROXY"];
28275+
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
2824628276
}
2824728277
else {
28248-
proxyVar = process.env["http_proxy"] ||
28249-
process.env["HTTP_PROXY"];
28278+
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
2825028279
}
2825128280
if (proxyVar) {
2825228281
proxyUrl = url.parse(proxyVar);
@@ -28258,7 +28287,7 @@ function checkBypass(reqUrl) {
2825828287
if (!reqUrl.hostname) {
2825928288
return false;
2826028289
}
28261-
let noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || '';
28290+
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
2826228291
if (!noProxy) {
2826328292
return false;
2826428293
}
@@ -28279,7 +28308,10 @@ function checkBypass(reqUrl) {
2827928308
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
2828028309
}
2828128310
// Compare request host against noproxy
28282-
for (let upperNoProxyItem of noProxy.split(',').map(x => x.trim().toUpperCase()).filter(x => x)) {
28311+
for (let upperNoProxyItem of noProxy
28312+
.split(',')
28313+
.map(x => x.trim().toUpperCase())
28314+
.filter(x => x)) {
2828328315
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
2828428316
return true;
2828528317
}

0 commit comments

Comments
 (0)