Add eslint rule for disallowing implicit dependencies
This commit is contained in:
parent
db9987b4c1
commit
b51c97f6e3
@ -7,7 +7,7 @@ module.exports = {
|
|||||||
'eslint-config-prettier'
|
'eslint-config-prettier'
|
||||||
],
|
],
|
||||||
parser: '@typescript-eslint/parser',
|
parser: '@typescript-eslint/parser',
|
||||||
plugins: ['@typescript-eslint', 'eslint-plugin-jest'],
|
plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/no-require-imports': 'error',
|
'@typescript-eslint/no-require-imports': 'error',
|
||||||
'@typescript-eslint/no-non-null-assertion': 'off',
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
@ -28,7 +28,8 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
'no-control-regex': 'off',
|
'no-control-regex': 'off',
|
||||||
'no-constant-condition': ['error', {checkLoops: false}]
|
'no-constant-condition': ['error', {checkLoops: false}],
|
||||||
|
'node/no-extraneous-import': 'error',
|
||||||
},
|
},
|
||||||
overrides: [
|
overrides: [
|
||||||
{
|
{
|
||||||
|
|||||||
2331
dist/cache-save/index.js
vendored
2331
dist/cache-save/index.js
vendored
@ -245,8 +245,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const http_client_1 = __nccwpck_require__(1825);
|
const http_client_1 = __nccwpck_require__(6255);
|
||||||
const auth_1 = __nccwpck_require__(2001);
|
const auth_1 = __nccwpck_require__(5526);
|
||||||
const crypto = __importStar(__nccwpck_require__(6113));
|
const crypto = __importStar(__nccwpck_require__(6113));
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
const url_1 = __nccwpck_require__(7310);
|
const url_1 = __nccwpck_require__(7310);
|
||||||
@ -718,7 +718,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const http_client_1 = __nccwpck_require__(1825);
|
const http_client_1 = __nccwpck_require__(6255);
|
||||||
const storage_blob_1 = __nccwpck_require__(4100);
|
const storage_blob_1 = __nccwpck_require__(4100);
|
||||||
const buffer = __importStar(__nccwpck_require__(4300));
|
const buffer = __importStar(__nccwpck_require__(4300));
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
@ -976,7 +976,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const http_client_1 = __nccwpck_require__(1825);
|
const http_client_1 = __nccwpck_require__(6255);
|
||||||
const constants_1 = __nccwpck_require__(8840);
|
const constants_1 = __nccwpck_require__(8840);
|
||||||
function isSuccessStatusCode(statusCode) {
|
function isSuccessStatusCode(statusCode) {
|
||||||
if (!statusCode) {
|
if (!statusCode) {
|
||||||
@ -2486,774 +2486,6 @@ exports.SearchState = SearchState;
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 2001:
|
|
||||||
/***/ (function(__unused_webpack_module, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
|
||||||
class BasicCredentialHandler {
|
|
||||||
constructor(username, password) {
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.BasicCredentialHandler = BasicCredentialHandler;
|
|
||||||
class BearerCredentialHandler {
|
|
||||||
constructor(token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
// currently implements pre-authorization
|
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Bearer ${this.token}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.BearerCredentialHandler = BearerCredentialHandler;
|
|
||||||
class PersonalAccessTokenCredentialHandler {
|
|
||||||
constructor(token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
// currently implements pre-authorization
|
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
|
||||||
//# sourceMappingURL=auth.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 1825:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
|
||||||
const http = __importStar(__nccwpck_require__(3685));
|
|
||||||
const https = __importStar(__nccwpck_require__(5687));
|
|
||||||
const pm = __importStar(__nccwpck_require__(4977));
|
|
||||||
const tunnel = __importStar(__nccwpck_require__(4294));
|
|
||||||
var HttpCodes;
|
|
||||||
(function (HttpCodes) {
|
|
||||||
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
|
||||||
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
|
||||||
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
|
||||||
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
|
||||||
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
|
||||||
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
|
||||||
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
|
||||||
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
|
||||||
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
||||||
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
||||||
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
|
||||||
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
|
||||||
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
|
||||||
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
|
||||||
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
|
||||||
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
||||||
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
|
||||||
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
||||||
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
|
||||||
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
|
||||||
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
|
||||||
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
|
||||||
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
|
||||||
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
|
||||||
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
|
||||||
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
||||||
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
||||||
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
|
||||||
var Headers;
|
|
||||||
(function (Headers) {
|
|
||||||
Headers["Accept"] = "accept";
|
|
||||||
Headers["ContentType"] = "content-type";
|
|
||||||
})(Headers = exports.Headers || (exports.Headers = {}));
|
|
||||||
var MediaTypes;
|
|
||||||
(function (MediaTypes) {
|
|
||||||
MediaTypes["ApplicationJson"] = "application/json";
|
|
||||||
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
|
||||||
/**
|
|
||||||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
|
||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
||||||
*/
|
|
||||||
function getProxyUrl(serverUrl) {
|
|
||||||
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
|
||||||
return proxyUrl ? proxyUrl.href : '';
|
|
||||||
}
|
|
||||||
exports.getProxyUrl = getProxyUrl;
|
|
||||||
const HttpRedirectCodes = [
|
|
||||||
HttpCodes.MovedPermanently,
|
|
||||||
HttpCodes.ResourceMoved,
|
|
||||||
HttpCodes.SeeOther,
|
|
||||||
HttpCodes.TemporaryRedirect,
|
|
||||||
HttpCodes.PermanentRedirect
|
|
||||||
];
|
|
||||||
const HttpResponseRetryCodes = [
|
|
||||||
HttpCodes.BadGateway,
|
|
||||||
HttpCodes.ServiceUnavailable,
|
|
||||||
HttpCodes.GatewayTimeout
|
|
||||||
];
|
|
||||||
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
|
||||||
const ExponentialBackoffCeiling = 10;
|
|
||||||
const ExponentialBackoffTimeSlice = 5;
|
|
||||||
class HttpClientError extends Error {
|
|
||||||
constructor(message, statusCode) {
|
|
||||||
super(message);
|
|
||||||
this.name = 'HttpClientError';
|
|
||||||
this.statusCode = statusCode;
|
|
||||||
Object.setPrototypeOf(this, HttpClientError.prototype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClientError = HttpClientError;
|
|
||||||
class HttpClientResponse {
|
|
||||||
constructor(message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
readBody() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let output = Buffer.alloc(0);
|
|
||||||
this.message.on('data', (chunk) => {
|
|
||||||
output = Buffer.concat([output, chunk]);
|
|
||||||
});
|
|
||||||
this.message.on('end', () => {
|
|
||||||
resolve(output.toString());
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClientResponse = HttpClientResponse;
|
|
||||||
function isHttps(requestUrl) {
|
|
||||||
const parsedUrl = new URL(requestUrl);
|
|
||||||
return parsedUrl.protocol === 'https:';
|
|
||||||
}
|
|
||||||
exports.isHttps = isHttps;
|
|
||||||
class HttpClient {
|
|
||||||
constructor(userAgent, handlers, requestOptions) {
|
|
||||||
this._ignoreSslError = false;
|
|
||||||
this._allowRedirects = true;
|
|
||||||
this._allowRedirectDowngrade = false;
|
|
||||||
this._maxRedirects = 50;
|
|
||||||
this._allowRetries = false;
|
|
||||||
this._maxRetries = 1;
|
|
||||||
this._keepAlive = false;
|
|
||||||
this._disposed = false;
|
|
||||||
this.userAgent = userAgent;
|
|
||||||
this.handlers = handlers || [];
|
|
||||||
this.requestOptions = requestOptions;
|
|
||||||
if (requestOptions) {
|
|
||||||
if (requestOptions.ignoreSslError != null) {
|
|
||||||
this._ignoreSslError = requestOptions.ignoreSslError;
|
|
||||||
}
|
|
||||||
this._socketTimeout = requestOptions.socketTimeout;
|
|
||||||
if (requestOptions.allowRedirects != null) {
|
|
||||||
this._allowRedirects = requestOptions.allowRedirects;
|
|
||||||
}
|
|
||||||
if (requestOptions.allowRedirectDowngrade != null) {
|
|
||||||
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
|
||||||
}
|
|
||||||
if (requestOptions.maxRedirects != null) {
|
|
||||||
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
|
||||||
}
|
|
||||||
if (requestOptions.keepAlive != null) {
|
|
||||||
this._keepAlive = requestOptions.keepAlive;
|
|
||||||
}
|
|
||||||
if (requestOptions.allowRetries != null) {
|
|
||||||
this._allowRetries = requestOptions.allowRetries;
|
|
||||||
}
|
|
||||||
if (requestOptions.maxRetries != null) {
|
|
||||||
this._maxRetries = requestOptions.maxRetries;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
get(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
del(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
post(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
patch(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
put(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
head(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request(verb, requestUrl, stream, additionalHeaders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets a typed object from an endpoint
|
|
||||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
|
||||||
*/
|
|
||||||
getJson(requestUrl, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.get(requestUrl, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
postJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.post(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
putJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.put(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Makes a raw http request.
|
|
||||||
* All other methods such as get, post, patch, and request ultimately call this.
|
|
||||||
* Prefer get, del, post and patch
|
|
||||||
*/
|
|
||||||
request(verb, requestUrl, data, headers) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (this._disposed) {
|
|
||||||
throw new Error('Client has already been disposed.');
|
|
||||||
}
|
|
||||||
const parsedUrl = new URL(requestUrl);
|
|
||||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
|
||||||
// Only perform retries on reads since writes may not be idempotent.
|
|
||||||
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
|
||||||
? this._maxRetries + 1
|
|
||||||
: 1;
|
|
||||||
let numTries = 0;
|
|
||||||
let response;
|
|
||||||
do {
|
|
||||||
response = yield this.requestRaw(info, data);
|
|
||||||
// Check if it's an authentication challenge
|
|
||||||
if (response &&
|
|
||||||
response.message &&
|
|
||||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
|
||||||
let authenticationHandler;
|
|
||||||
for (const handler of this.handlers) {
|
|
||||||
if (handler.canHandleAuthentication(response)) {
|
|
||||||
authenticationHandler = handler;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (authenticationHandler) {
|
|
||||||
return authenticationHandler.handleAuthentication(this, info, data);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// We have received an unauthorized response but have no handlers to handle it.
|
|
||||||
// Let the response return to the caller.
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let redirectsRemaining = this._maxRedirects;
|
|
||||||
while (response.message.statusCode &&
|
|
||||||
HttpRedirectCodes.includes(response.message.statusCode) &&
|
|
||||||
this._allowRedirects &&
|
|
||||||
redirectsRemaining > 0) {
|
|
||||||
const redirectUrl = response.message.headers['location'];
|
|
||||||
if (!redirectUrl) {
|
|
||||||
// if there's no location to redirect to, we won't
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const parsedRedirectUrl = new URL(redirectUrl);
|
|
||||||
if (parsedUrl.protocol === 'https:' &&
|
|
||||||
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
|
||||||
!this._allowRedirectDowngrade) {
|
|
||||||
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.');
|
|
||||||
}
|
|
||||||
// we need to finish reading the response before reassigning response
|
|
||||||
// which will leak the open socket.
|
|
||||||
yield response.readBody();
|
|
||||||
// strip authorization header if redirected to a different hostname
|
|
||||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
|
||||||
for (const header in headers) {
|
|
||||||
// header names are case insensitive
|
|
||||||
if (header.toLowerCase() === 'authorization') {
|
|
||||||
delete headers[header];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// let's make the request with the new redirectUrl
|
|
||||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
|
||||||
response = yield this.requestRaw(info, data);
|
|
||||||
redirectsRemaining--;
|
|
||||||
}
|
|
||||||
if (!response.message.statusCode ||
|
|
||||||
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
|
||||||
// If not a retry code, return immediately instead of retrying
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
numTries += 1;
|
|
||||||
if (numTries < maxTries) {
|
|
||||||
yield response.readBody();
|
|
||||||
yield this._performExponentialBackoff(numTries);
|
|
||||||
}
|
|
||||||
} while (numTries < maxTries);
|
|
||||||
return response;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Needs to be called if keepAlive is set to true in request options.
|
|
||||||
*/
|
|
||||||
dispose() {
|
|
||||||
if (this._agent) {
|
|
||||||
this._agent.destroy();
|
|
||||||
}
|
|
||||||
this._disposed = true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Raw request.
|
|
||||||
* @param info
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
requestRaw(info, data) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
function callbackForResult(err, res) {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
else if (!res) {
|
|
||||||
// If `err` is not passed, then `res` must be passed.
|
|
||||||
reject(new Error('Unknown error'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.requestRawWithCallback(info, data, callbackForResult);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Raw request with callback.
|
|
||||||
* @param info
|
|
||||||
* @param data
|
|
||||||
* @param onResult
|
|
||||||
*/
|
|
||||||
requestRawWithCallback(info, data, onResult) {
|
|
||||||
if (typeof data === 'string') {
|
|
||||||
if (!info.options.headers) {
|
|
||||||
info.options.headers = {};
|
|
||||||
}
|
|
||||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
|
||||||
}
|
|
||||||
let callbackCalled = false;
|
|
||||||
function handleResult(err, res) {
|
|
||||||
if (!callbackCalled) {
|
|
||||||
callbackCalled = true;
|
|
||||||
onResult(err, res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const req = info.httpModule.request(info.options, (msg) => {
|
|
||||||
const res = new HttpClientResponse(msg);
|
|
||||||
handleResult(undefined, res);
|
|
||||||
});
|
|
||||||
let socket;
|
|
||||||
req.on('socket', sock => {
|
|
||||||
socket = sock;
|
|
||||||
});
|
|
||||||
// If we ever get disconnected, we want the socket to timeout eventually
|
|
||||||
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
|
||||||
if (socket) {
|
|
||||||
socket.end();
|
|
||||||
}
|
|
||||||
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
|
||||||
});
|
|
||||||
req.on('error', function (err) {
|
|
||||||
// err has statusCode property
|
|
||||||
// res should have headers
|
|
||||||
handleResult(err);
|
|
||||||
});
|
|
||||||
if (data && typeof data === 'string') {
|
|
||||||
req.write(data, 'utf8');
|
|
||||||
}
|
|
||||||
if (data && typeof data !== 'string') {
|
|
||||||
data.on('close', function () {
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
data.pipe(req);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
req.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets an http agent. This function is useful when you need an http agent that handles
|
|
||||||
* routing through a proxy server - depending upon the url and proxy environment variables.
|
|
||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
||||||
*/
|
|
||||||
getAgent(serverUrl) {
|
|
||||||
const parsedUrl = new URL(serverUrl);
|
|
||||||
return this._getAgent(parsedUrl);
|
|
||||||
}
|
|
||||||
_prepareRequest(method, requestUrl, headers) {
|
|
||||||
const info = {};
|
|
||||||
info.parsedUrl = requestUrl;
|
|
||||||
const usingSsl = info.parsedUrl.protocol === 'https:';
|
|
||||||
info.httpModule = usingSsl ? https : http;
|
|
||||||
const defaultPort = usingSsl ? 443 : 80;
|
|
||||||
info.options = {};
|
|
||||||
info.options.host = info.parsedUrl.hostname;
|
|
||||||
info.options.port = info.parsedUrl.port
|
|
||||||
? parseInt(info.parsedUrl.port)
|
|
||||||
: defaultPort;
|
|
||||||
info.options.path =
|
|
||||||
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
|
||||||
info.options.method = method;
|
|
||||||
info.options.headers = this._mergeHeaders(headers);
|
|
||||||
if (this.userAgent != null) {
|
|
||||||
info.options.headers['user-agent'] = this.userAgent;
|
|
||||||
}
|
|
||||||
info.options.agent = this._getAgent(info.parsedUrl);
|
|
||||||
// gives handlers an opportunity to participate
|
|
||||||
if (this.handlers) {
|
|
||||||
for (const handler of this.handlers) {
|
|
||||||
handler.prepareRequest(info.options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
_mergeHeaders(headers) {
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
|
||||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
|
||||||
}
|
|
||||||
return lowercaseKeys(headers || {});
|
|
||||||
}
|
|
||||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
|
||||||
let clientHeader;
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
|
||||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
|
||||||
}
|
|
||||||
return additionalHeaders[header] || clientHeader || _default;
|
|
||||||
}
|
|
||||||
_getAgent(parsedUrl) {
|
|
||||||
let agent;
|
|
||||||
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
|
||||||
const useProxy = proxyUrl && proxyUrl.hostname;
|
|
||||||
if (this._keepAlive && useProxy) {
|
|
||||||
agent = this._proxyAgent;
|
|
||||||
}
|
|
||||||
if (this._keepAlive && !useProxy) {
|
|
||||||
agent = this._agent;
|
|
||||||
}
|
|
||||||
// if agent is already assigned use that agent.
|
|
||||||
if (agent) {
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
const usingSsl = parsedUrl.protocol === 'https:';
|
|
||||||
let maxSockets = 100;
|
|
||||||
if (this.requestOptions) {
|
|
||||||
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
|
||||||
}
|
|
||||||
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
|
||||||
if (proxyUrl && proxyUrl.hostname) {
|
|
||||||
const agentOptions = {
|
|
||||||
maxSockets,
|
|
||||||
keepAlive: this._keepAlive,
|
|
||||||
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
|
||||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
|
||||||
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
|
||||||
};
|
|
||||||
let tunnelAgent;
|
|
||||||
const overHttps = proxyUrl.protocol === 'https:';
|
|
||||||
if (usingSsl) {
|
|
||||||
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
|
||||||
}
|
|
||||||
agent = tunnelAgent(agentOptions);
|
|
||||||
this._proxyAgent = agent;
|
|
||||||
}
|
|
||||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
|
||||||
if (this._keepAlive && !agent) {
|
|
||||||
const options = { keepAlive: this._keepAlive, maxSockets };
|
|
||||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
|
||||||
this._agent = agent;
|
|
||||||
}
|
|
||||||
// if not using private agent and tunnel agent isn't setup then use global agent
|
|
||||||
if (!agent) {
|
|
||||||
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
|
||||||
}
|
|
||||||
if (usingSsl && this._ignoreSslError) {
|
|
||||||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
|
||||||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
|
||||||
// we have to cast it to any and change it directly
|
|
||||||
agent.options = Object.assign(agent.options || {}, {
|
|
||||||
rejectUnauthorized: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
_performExponentialBackoff(retryNumber) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
|
||||||
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
|
||||||
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_processResponse(res, options) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const statusCode = res.message.statusCode || 0;
|
|
||||||
const response = {
|
|
||||||
statusCode,
|
|
||||||
result: null,
|
|
||||||
headers: {}
|
|
||||||
};
|
|
||||||
// not found leads to null obj returned
|
|
||||||
if (statusCode === HttpCodes.NotFound) {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
// get the result from the body
|
|
||||||
function dateTimeDeserializer(key, value) {
|
|
||||||
if (typeof value === 'string') {
|
|
||||||
const a = new Date(value);
|
|
||||||
if (!isNaN(a.valueOf())) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
let obj;
|
|
||||||
let contents;
|
|
||||||
try {
|
|
||||||
contents = yield res.readBody();
|
|
||||||
if (contents && contents.length > 0) {
|
|
||||||
if (options && options.deserializeDates) {
|
|
||||||
obj = JSON.parse(contents, dateTimeDeserializer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
obj = JSON.parse(contents);
|
|
||||||
}
|
|
||||||
response.result = obj;
|
|
||||||
}
|
|
||||||
response.headers = res.message.headers;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// Invalid resource (contents not json); leaving result obj null
|
|
||||||
}
|
|
||||||
// note that 3xx redirects are handled by the http layer.
|
|
||||||
if (statusCode > 299) {
|
|
||||||
let msg;
|
|
||||||
// if exception/error in body, attempt to get better error
|
|
||||||
if (obj && obj.message) {
|
|
||||||
msg = obj.message;
|
|
||||||
}
|
|
||||||
else if (contents && contents.length > 0) {
|
|
||||||
// it may be the case that the exception is in the body message as string
|
|
||||||
msg = contents;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
msg = `Failed request: (${statusCode})`;
|
|
||||||
}
|
|
||||||
const err = new HttpClientError(msg, statusCode);
|
|
||||||
err.result = response.result;
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClient = HttpClient;
|
|
||||||
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 4977:
|
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.checkBypass = exports.getProxyUrl = void 0;
|
|
||||||
function getProxyUrl(reqUrl) {
|
|
||||||
const usingSsl = reqUrl.protocol === 'https:';
|
|
||||||
if (checkBypass(reqUrl)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const proxyVar = (() => {
|
|
||||||
if (usingSsl) {
|
|
||||||
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
if (proxyVar) {
|
|
||||||
return new URL(proxyVar);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.getProxyUrl = getProxyUrl;
|
|
||||||
function checkBypass(reqUrl) {
|
|
||||||
if (!reqUrl.hostname) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
|
||||||
if (!noProxy) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Determine the request port
|
|
||||||
let reqPort;
|
|
||||||
if (reqUrl.port) {
|
|
||||||
reqPort = Number(reqUrl.port);
|
|
||||||
}
|
|
||||||
else if (reqUrl.protocol === 'http:') {
|
|
||||||
reqPort = 80;
|
|
||||||
}
|
|
||||||
else if (reqUrl.protocol === 'https:') {
|
|
||||||
reqPort = 443;
|
|
||||||
}
|
|
||||||
// Format the request hostname and hostname with port
|
|
||||||
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
|
||||||
if (typeof reqPort === 'number') {
|
|
||||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
|
||||||
}
|
|
||||||
// Compare request host against noproxy
|
|
||||||
for (const upperNoProxyItem of noProxy
|
|
||||||
.split(',')
|
|
||||||
.map(x => x.trim().toUpperCase())
|
|
||||||
.filter(x => x)) {
|
|
||||||
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
exports.checkBypass = checkBypass;
|
|
||||||
//# sourceMappingURL=proxy.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 3771:
|
/***/ 3771:
|
||||||
/***/ ((module, exports) => {
|
/***/ ((module, exports) => {
|
||||||
|
|
||||||
@ -5380,8 +4612,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.OidcClient = void 0;
|
exports.OidcClient = void 0;
|
||||||
const http_client_1 = __nccwpck_require__(1404);
|
const http_client_1 = __nccwpck_require__(6255);
|
||||||
const auth_1 = __nccwpck_require__(6758);
|
const auth_1 = __nccwpck_require__(5526);
|
||||||
const core_1 = __nccwpck_require__(2186);
|
const core_1 = __nccwpck_require__(2186);
|
||||||
class OidcClient {
|
class OidcClient {
|
||||||
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
||||||
@ -5850,774 +5082,6 @@ exports.toCommandProperties = toCommandProperties;
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6758:
|
|
||||||
/***/ (function(__unused_webpack_module, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
|
||||||
class BasicCredentialHandler {
|
|
||||||
constructor(username, password) {
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.BasicCredentialHandler = BasicCredentialHandler;
|
|
||||||
class BearerCredentialHandler {
|
|
||||||
constructor(token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
// currently implements pre-authorization
|
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Bearer ${this.token}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.BearerCredentialHandler = BearerCredentialHandler;
|
|
||||||
class PersonalAccessTokenCredentialHandler {
|
|
||||||
constructor(token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
// currently implements pre-authorization
|
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
|
||||||
//# sourceMappingURL=auth.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 1404:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
|
||||||
const http = __importStar(__nccwpck_require__(3685));
|
|
||||||
const https = __importStar(__nccwpck_require__(5687));
|
|
||||||
const pm = __importStar(__nccwpck_require__(2843));
|
|
||||||
const tunnel = __importStar(__nccwpck_require__(4294));
|
|
||||||
var HttpCodes;
|
|
||||||
(function (HttpCodes) {
|
|
||||||
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
|
||||||
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
|
||||||
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
|
||||||
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
|
||||||
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
|
||||||
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
|
||||||
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
|
||||||
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
|
||||||
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
||||||
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
||||||
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
|
||||||
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
|
||||||
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
|
||||||
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
|
||||||
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
|
||||||
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
||||||
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
|
||||||
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
||||||
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
|
||||||
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
|
||||||
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
|
||||||
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
|
||||||
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
|
||||||
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
|
||||||
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
|
||||||
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
||||||
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
||||||
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
|
||||||
var Headers;
|
|
||||||
(function (Headers) {
|
|
||||||
Headers["Accept"] = "accept";
|
|
||||||
Headers["ContentType"] = "content-type";
|
|
||||||
})(Headers = exports.Headers || (exports.Headers = {}));
|
|
||||||
var MediaTypes;
|
|
||||||
(function (MediaTypes) {
|
|
||||||
MediaTypes["ApplicationJson"] = "application/json";
|
|
||||||
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
|
||||||
/**
|
|
||||||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
|
||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
||||||
*/
|
|
||||||
function getProxyUrl(serverUrl) {
|
|
||||||
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
|
||||||
return proxyUrl ? proxyUrl.href : '';
|
|
||||||
}
|
|
||||||
exports.getProxyUrl = getProxyUrl;
|
|
||||||
const HttpRedirectCodes = [
|
|
||||||
HttpCodes.MovedPermanently,
|
|
||||||
HttpCodes.ResourceMoved,
|
|
||||||
HttpCodes.SeeOther,
|
|
||||||
HttpCodes.TemporaryRedirect,
|
|
||||||
HttpCodes.PermanentRedirect
|
|
||||||
];
|
|
||||||
const HttpResponseRetryCodes = [
|
|
||||||
HttpCodes.BadGateway,
|
|
||||||
HttpCodes.ServiceUnavailable,
|
|
||||||
HttpCodes.GatewayTimeout
|
|
||||||
];
|
|
||||||
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
|
||||||
const ExponentialBackoffCeiling = 10;
|
|
||||||
const ExponentialBackoffTimeSlice = 5;
|
|
||||||
class HttpClientError extends Error {
|
|
||||||
constructor(message, statusCode) {
|
|
||||||
super(message);
|
|
||||||
this.name = 'HttpClientError';
|
|
||||||
this.statusCode = statusCode;
|
|
||||||
Object.setPrototypeOf(this, HttpClientError.prototype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClientError = HttpClientError;
|
|
||||||
class HttpClientResponse {
|
|
||||||
constructor(message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
readBody() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let output = Buffer.alloc(0);
|
|
||||||
this.message.on('data', (chunk) => {
|
|
||||||
output = Buffer.concat([output, chunk]);
|
|
||||||
});
|
|
||||||
this.message.on('end', () => {
|
|
||||||
resolve(output.toString());
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClientResponse = HttpClientResponse;
|
|
||||||
function isHttps(requestUrl) {
|
|
||||||
const parsedUrl = new URL(requestUrl);
|
|
||||||
return parsedUrl.protocol === 'https:';
|
|
||||||
}
|
|
||||||
exports.isHttps = isHttps;
|
|
||||||
class HttpClient {
|
|
||||||
constructor(userAgent, handlers, requestOptions) {
|
|
||||||
this._ignoreSslError = false;
|
|
||||||
this._allowRedirects = true;
|
|
||||||
this._allowRedirectDowngrade = false;
|
|
||||||
this._maxRedirects = 50;
|
|
||||||
this._allowRetries = false;
|
|
||||||
this._maxRetries = 1;
|
|
||||||
this._keepAlive = false;
|
|
||||||
this._disposed = false;
|
|
||||||
this.userAgent = userAgent;
|
|
||||||
this.handlers = handlers || [];
|
|
||||||
this.requestOptions = requestOptions;
|
|
||||||
if (requestOptions) {
|
|
||||||
if (requestOptions.ignoreSslError != null) {
|
|
||||||
this._ignoreSslError = requestOptions.ignoreSslError;
|
|
||||||
}
|
|
||||||
this._socketTimeout = requestOptions.socketTimeout;
|
|
||||||
if (requestOptions.allowRedirects != null) {
|
|
||||||
this._allowRedirects = requestOptions.allowRedirects;
|
|
||||||
}
|
|
||||||
if (requestOptions.allowRedirectDowngrade != null) {
|
|
||||||
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
|
||||||
}
|
|
||||||
if (requestOptions.maxRedirects != null) {
|
|
||||||
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
|
||||||
}
|
|
||||||
if (requestOptions.keepAlive != null) {
|
|
||||||
this._keepAlive = requestOptions.keepAlive;
|
|
||||||
}
|
|
||||||
if (requestOptions.allowRetries != null) {
|
|
||||||
this._allowRetries = requestOptions.allowRetries;
|
|
||||||
}
|
|
||||||
if (requestOptions.maxRetries != null) {
|
|
||||||
this._maxRetries = requestOptions.maxRetries;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
get(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
del(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
post(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
patch(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
put(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
head(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request(verb, requestUrl, stream, additionalHeaders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets a typed object from an endpoint
|
|
||||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
|
||||||
*/
|
|
||||||
getJson(requestUrl, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.get(requestUrl, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
postJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.post(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
putJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.put(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Makes a raw http request.
|
|
||||||
* All other methods such as get, post, patch, and request ultimately call this.
|
|
||||||
* Prefer get, del, post and patch
|
|
||||||
*/
|
|
||||||
request(verb, requestUrl, data, headers) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (this._disposed) {
|
|
||||||
throw new Error('Client has already been disposed.');
|
|
||||||
}
|
|
||||||
const parsedUrl = new URL(requestUrl);
|
|
||||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
|
||||||
// Only perform retries on reads since writes may not be idempotent.
|
|
||||||
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
|
||||||
? this._maxRetries + 1
|
|
||||||
: 1;
|
|
||||||
let numTries = 0;
|
|
||||||
let response;
|
|
||||||
do {
|
|
||||||
response = yield this.requestRaw(info, data);
|
|
||||||
// Check if it's an authentication challenge
|
|
||||||
if (response &&
|
|
||||||
response.message &&
|
|
||||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
|
||||||
let authenticationHandler;
|
|
||||||
for (const handler of this.handlers) {
|
|
||||||
if (handler.canHandleAuthentication(response)) {
|
|
||||||
authenticationHandler = handler;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (authenticationHandler) {
|
|
||||||
return authenticationHandler.handleAuthentication(this, info, data);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// We have received an unauthorized response but have no handlers to handle it.
|
|
||||||
// Let the response return to the caller.
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let redirectsRemaining = this._maxRedirects;
|
|
||||||
while (response.message.statusCode &&
|
|
||||||
HttpRedirectCodes.includes(response.message.statusCode) &&
|
|
||||||
this._allowRedirects &&
|
|
||||||
redirectsRemaining > 0) {
|
|
||||||
const redirectUrl = response.message.headers['location'];
|
|
||||||
if (!redirectUrl) {
|
|
||||||
// if there's no location to redirect to, we won't
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const parsedRedirectUrl = new URL(redirectUrl);
|
|
||||||
if (parsedUrl.protocol === 'https:' &&
|
|
||||||
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
|
||||||
!this._allowRedirectDowngrade) {
|
|
||||||
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.');
|
|
||||||
}
|
|
||||||
// we need to finish reading the response before reassigning response
|
|
||||||
// which will leak the open socket.
|
|
||||||
yield response.readBody();
|
|
||||||
// strip authorization header if redirected to a different hostname
|
|
||||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
|
||||||
for (const header in headers) {
|
|
||||||
// header names are case insensitive
|
|
||||||
if (header.toLowerCase() === 'authorization') {
|
|
||||||
delete headers[header];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// let's make the request with the new redirectUrl
|
|
||||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
|
||||||
response = yield this.requestRaw(info, data);
|
|
||||||
redirectsRemaining--;
|
|
||||||
}
|
|
||||||
if (!response.message.statusCode ||
|
|
||||||
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
|
||||||
// If not a retry code, return immediately instead of retrying
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
numTries += 1;
|
|
||||||
if (numTries < maxTries) {
|
|
||||||
yield response.readBody();
|
|
||||||
yield this._performExponentialBackoff(numTries);
|
|
||||||
}
|
|
||||||
} while (numTries < maxTries);
|
|
||||||
return response;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Needs to be called if keepAlive is set to true in request options.
|
|
||||||
*/
|
|
||||||
dispose() {
|
|
||||||
if (this._agent) {
|
|
||||||
this._agent.destroy();
|
|
||||||
}
|
|
||||||
this._disposed = true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Raw request.
|
|
||||||
* @param info
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
requestRaw(info, data) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
function callbackForResult(err, res) {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
else if (!res) {
|
|
||||||
// If `err` is not passed, then `res` must be passed.
|
|
||||||
reject(new Error('Unknown error'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.requestRawWithCallback(info, data, callbackForResult);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Raw request with callback.
|
|
||||||
* @param info
|
|
||||||
* @param data
|
|
||||||
* @param onResult
|
|
||||||
*/
|
|
||||||
requestRawWithCallback(info, data, onResult) {
|
|
||||||
if (typeof data === 'string') {
|
|
||||||
if (!info.options.headers) {
|
|
||||||
info.options.headers = {};
|
|
||||||
}
|
|
||||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
|
||||||
}
|
|
||||||
let callbackCalled = false;
|
|
||||||
function handleResult(err, res) {
|
|
||||||
if (!callbackCalled) {
|
|
||||||
callbackCalled = true;
|
|
||||||
onResult(err, res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const req = info.httpModule.request(info.options, (msg) => {
|
|
||||||
const res = new HttpClientResponse(msg);
|
|
||||||
handleResult(undefined, res);
|
|
||||||
});
|
|
||||||
let socket;
|
|
||||||
req.on('socket', sock => {
|
|
||||||
socket = sock;
|
|
||||||
});
|
|
||||||
// If we ever get disconnected, we want the socket to timeout eventually
|
|
||||||
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
|
||||||
if (socket) {
|
|
||||||
socket.end();
|
|
||||||
}
|
|
||||||
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
|
||||||
});
|
|
||||||
req.on('error', function (err) {
|
|
||||||
// err has statusCode property
|
|
||||||
// res should have headers
|
|
||||||
handleResult(err);
|
|
||||||
});
|
|
||||||
if (data && typeof data === 'string') {
|
|
||||||
req.write(data, 'utf8');
|
|
||||||
}
|
|
||||||
if (data && typeof data !== 'string') {
|
|
||||||
data.on('close', function () {
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
data.pipe(req);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
req.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets an http agent. This function is useful when you need an http agent that handles
|
|
||||||
* routing through a proxy server - depending upon the url and proxy environment variables.
|
|
||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
||||||
*/
|
|
||||||
getAgent(serverUrl) {
|
|
||||||
const parsedUrl = new URL(serverUrl);
|
|
||||||
return this._getAgent(parsedUrl);
|
|
||||||
}
|
|
||||||
_prepareRequest(method, requestUrl, headers) {
|
|
||||||
const info = {};
|
|
||||||
info.parsedUrl = requestUrl;
|
|
||||||
const usingSsl = info.parsedUrl.protocol === 'https:';
|
|
||||||
info.httpModule = usingSsl ? https : http;
|
|
||||||
const defaultPort = usingSsl ? 443 : 80;
|
|
||||||
info.options = {};
|
|
||||||
info.options.host = info.parsedUrl.hostname;
|
|
||||||
info.options.port = info.parsedUrl.port
|
|
||||||
? parseInt(info.parsedUrl.port)
|
|
||||||
: defaultPort;
|
|
||||||
info.options.path =
|
|
||||||
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
|
||||||
info.options.method = method;
|
|
||||||
info.options.headers = this._mergeHeaders(headers);
|
|
||||||
if (this.userAgent != null) {
|
|
||||||
info.options.headers['user-agent'] = this.userAgent;
|
|
||||||
}
|
|
||||||
info.options.agent = this._getAgent(info.parsedUrl);
|
|
||||||
// gives handlers an opportunity to participate
|
|
||||||
if (this.handlers) {
|
|
||||||
for (const handler of this.handlers) {
|
|
||||||
handler.prepareRequest(info.options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
_mergeHeaders(headers) {
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
|
||||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
|
||||||
}
|
|
||||||
return lowercaseKeys(headers || {});
|
|
||||||
}
|
|
||||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
|
||||||
let clientHeader;
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
|
||||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
|
||||||
}
|
|
||||||
return additionalHeaders[header] || clientHeader || _default;
|
|
||||||
}
|
|
||||||
_getAgent(parsedUrl) {
|
|
||||||
let agent;
|
|
||||||
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
|
||||||
const useProxy = proxyUrl && proxyUrl.hostname;
|
|
||||||
if (this._keepAlive && useProxy) {
|
|
||||||
agent = this._proxyAgent;
|
|
||||||
}
|
|
||||||
if (this._keepAlive && !useProxy) {
|
|
||||||
agent = this._agent;
|
|
||||||
}
|
|
||||||
// if agent is already assigned use that agent.
|
|
||||||
if (agent) {
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
const usingSsl = parsedUrl.protocol === 'https:';
|
|
||||||
let maxSockets = 100;
|
|
||||||
if (this.requestOptions) {
|
|
||||||
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
|
||||||
}
|
|
||||||
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
|
||||||
if (proxyUrl && proxyUrl.hostname) {
|
|
||||||
const agentOptions = {
|
|
||||||
maxSockets,
|
|
||||||
keepAlive: this._keepAlive,
|
|
||||||
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
|
||||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
|
||||||
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
|
||||||
};
|
|
||||||
let tunnelAgent;
|
|
||||||
const overHttps = proxyUrl.protocol === 'https:';
|
|
||||||
if (usingSsl) {
|
|
||||||
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
|
||||||
}
|
|
||||||
agent = tunnelAgent(agentOptions);
|
|
||||||
this._proxyAgent = agent;
|
|
||||||
}
|
|
||||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
|
||||||
if (this._keepAlive && !agent) {
|
|
||||||
const options = { keepAlive: this._keepAlive, maxSockets };
|
|
||||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
|
||||||
this._agent = agent;
|
|
||||||
}
|
|
||||||
// if not using private agent and tunnel agent isn't setup then use global agent
|
|
||||||
if (!agent) {
|
|
||||||
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
|
||||||
}
|
|
||||||
if (usingSsl && this._ignoreSslError) {
|
|
||||||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
|
||||||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
|
||||||
// we have to cast it to any and change it directly
|
|
||||||
agent.options = Object.assign(agent.options || {}, {
|
|
||||||
rejectUnauthorized: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
_performExponentialBackoff(retryNumber) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
|
||||||
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
|
||||||
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_processResponse(res, options) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const statusCode = res.message.statusCode || 0;
|
|
||||||
const response = {
|
|
||||||
statusCode,
|
|
||||||
result: null,
|
|
||||||
headers: {}
|
|
||||||
};
|
|
||||||
// not found leads to null obj returned
|
|
||||||
if (statusCode === HttpCodes.NotFound) {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
// get the result from the body
|
|
||||||
function dateTimeDeserializer(key, value) {
|
|
||||||
if (typeof value === 'string') {
|
|
||||||
const a = new Date(value);
|
|
||||||
if (!isNaN(a.valueOf())) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
let obj;
|
|
||||||
let contents;
|
|
||||||
try {
|
|
||||||
contents = yield res.readBody();
|
|
||||||
if (contents && contents.length > 0) {
|
|
||||||
if (options && options.deserializeDates) {
|
|
||||||
obj = JSON.parse(contents, dateTimeDeserializer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
obj = JSON.parse(contents);
|
|
||||||
}
|
|
||||||
response.result = obj;
|
|
||||||
}
|
|
||||||
response.headers = res.message.headers;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// Invalid resource (contents not json); leaving result obj null
|
|
||||||
}
|
|
||||||
// note that 3xx redirects are handled by the http layer.
|
|
||||||
if (statusCode > 299) {
|
|
||||||
let msg;
|
|
||||||
// if exception/error in body, attempt to get better error
|
|
||||||
if (obj && obj.message) {
|
|
||||||
msg = obj.message;
|
|
||||||
}
|
|
||||||
else if (contents && contents.length > 0) {
|
|
||||||
// it may be the case that the exception is in the body message as string
|
|
||||||
msg = contents;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
msg = `Failed request: (${statusCode})`;
|
|
||||||
}
|
|
||||||
const err = new HttpClientError(msg, statusCode);
|
|
||||||
err.result = response.result;
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClient = HttpClient;
|
|
||||||
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 2843:
|
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.checkBypass = exports.getProxyUrl = void 0;
|
|
||||||
function getProxyUrl(reqUrl) {
|
|
||||||
const usingSsl = reqUrl.protocol === 'https:';
|
|
||||||
if (checkBypass(reqUrl)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const proxyVar = (() => {
|
|
||||||
if (usingSsl) {
|
|
||||||
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
if (proxyVar) {
|
|
||||||
return new URL(proxyVar);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.getProxyUrl = getProxyUrl;
|
|
||||||
function checkBypass(reqUrl) {
|
|
||||||
if (!reqUrl.hostname) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
|
||||||
if (!noProxy) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Determine the request port
|
|
||||||
let reqPort;
|
|
||||||
if (reqUrl.port) {
|
|
||||||
reqPort = Number(reqUrl.port);
|
|
||||||
}
|
|
||||||
else if (reqUrl.protocol === 'http:') {
|
|
||||||
reqPort = 80;
|
|
||||||
}
|
|
||||||
else if (reqUrl.protocol === 'https:') {
|
|
||||||
reqPort = 443;
|
|
||||||
}
|
|
||||||
// Format the request hostname and hostname with port
|
|
||||||
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
|
||||||
if (typeof reqPort === 'number') {
|
|
||||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
|
||||||
}
|
|
||||||
// Compare request host against noproxy
|
|
||||||
for (const upperNoProxyItem of noProxy
|
|
||||||
.split(',')
|
|
||||||
.map(x => x.trim().toUpperCase())
|
|
||||||
.filter(x => x)) {
|
|
||||||
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
exports.checkBypass = checkBypass;
|
|
||||||
//# sourceMappingURL=proxy.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 8974:
|
/***/ 8974:
|
||||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
@ -7999,6 +6463,789 @@ class ExecState extends events.EventEmitter {
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 5526:
|
||||||
|
/***/ (function(__unused_webpack_module, exports) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
||||||
|
class BasicCredentialHandler {
|
||||||
|
constructor(username, password) {
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
prepareRequest(options) {
|
||||||
|
if (!options.headers) {
|
||||||
|
throw Error('The request has no headers');
|
||||||
|
}
|
||||||
|
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
||||||
|
}
|
||||||
|
// This handler cannot handle 401
|
||||||
|
canHandleAuthentication() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handleAuthentication() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.BasicCredentialHandler = BasicCredentialHandler;
|
||||||
|
class BearerCredentialHandler {
|
||||||
|
constructor(token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
// currently implements pre-authorization
|
||||||
|
// TODO: support preAuth = false where it hooks on 401
|
||||||
|
prepareRequest(options) {
|
||||||
|
if (!options.headers) {
|
||||||
|
throw Error('The request has no headers');
|
||||||
|
}
|
||||||
|
options.headers['Authorization'] = `Bearer ${this.token}`;
|
||||||
|
}
|
||||||
|
// This handler cannot handle 401
|
||||||
|
canHandleAuthentication() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handleAuthentication() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.BearerCredentialHandler = BearerCredentialHandler;
|
||||||
|
class PersonalAccessTokenCredentialHandler {
|
||||||
|
constructor(token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
// currently implements pre-authorization
|
||||||
|
// TODO: support preAuth = false where it hooks on 401
|
||||||
|
prepareRequest(options) {
|
||||||
|
if (!options.headers) {
|
||||||
|
throw Error('The request has no headers');
|
||||||
|
}
|
||||||
|
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
||||||
|
}
|
||||||
|
// This handler cannot handle 401
|
||||||
|
canHandleAuthentication() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handleAuthentication() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
||||||
|
//# sourceMappingURL=auth.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6255:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
||||||
|
const http = __importStar(__nccwpck_require__(3685));
|
||||||
|
const https = __importStar(__nccwpck_require__(5687));
|
||||||
|
const pm = __importStar(__nccwpck_require__(9835));
|
||||||
|
const tunnel = __importStar(__nccwpck_require__(4294));
|
||||||
|
var HttpCodes;
|
||||||
|
(function (HttpCodes) {
|
||||||
|
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
||||||
|
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
||||||
|
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
||||||
|
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
||||||
|
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
||||||
|
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
||||||
|
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
||||||
|
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
||||||
|
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
||||||
|
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
||||||
|
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
||||||
|
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
||||||
|
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
||||||
|
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
||||||
|
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
||||||
|
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
||||||
|
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
||||||
|
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
||||||
|
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
||||||
|
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
||||||
|
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
||||||
|
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
||||||
|
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
||||||
|
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
||||||
|
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
||||||
|
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
||||||
|
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
||||||
|
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
||||||
|
var Headers;
|
||||||
|
(function (Headers) {
|
||||||
|
Headers["Accept"] = "accept";
|
||||||
|
Headers["ContentType"] = "content-type";
|
||||||
|
})(Headers = exports.Headers || (exports.Headers = {}));
|
||||||
|
var MediaTypes;
|
||||||
|
(function (MediaTypes) {
|
||||||
|
MediaTypes["ApplicationJson"] = "application/json";
|
||||||
|
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
||||||
|
/**
|
||||||
|
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
||||||
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
|
*/
|
||||||
|
function getProxyUrl(serverUrl) {
|
||||||
|
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
||||||
|
return proxyUrl ? proxyUrl.href : '';
|
||||||
|
}
|
||||||
|
exports.getProxyUrl = getProxyUrl;
|
||||||
|
const HttpRedirectCodes = [
|
||||||
|
HttpCodes.MovedPermanently,
|
||||||
|
HttpCodes.ResourceMoved,
|
||||||
|
HttpCodes.SeeOther,
|
||||||
|
HttpCodes.TemporaryRedirect,
|
||||||
|
HttpCodes.PermanentRedirect
|
||||||
|
];
|
||||||
|
const HttpResponseRetryCodes = [
|
||||||
|
HttpCodes.BadGateway,
|
||||||
|
HttpCodes.ServiceUnavailable,
|
||||||
|
HttpCodes.GatewayTimeout
|
||||||
|
];
|
||||||
|
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
||||||
|
const ExponentialBackoffCeiling = 10;
|
||||||
|
const ExponentialBackoffTimeSlice = 5;
|
||||||
|
class HttpClientError extends Error {
|
||||||
|
constructor(message, statusCode) {
|
||||||
|
super(message);
|
||||||
|
this.name = 'HttpClientError';
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
Object.setPrototypeOf(this, HttpClientError.prototype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.HttpClientError = HttpClientError;
|
||||||
|
class HttpClientResponse {
|
||||||
|
constructor(message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
readBody() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
let output = Buffer.alloc(0);
|
||||||
|
this.message.on('data', (chunk) => {
|
||||||
|
output = Buffer.concat([output, chunk]);
|
||||||
|
});
|
||||||
|
this.message.on('end', () => {
|
||||||
|
resolve(output.toString());
|
||||||
|
});
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.HttpClientResponse = HttpClientResponse;
|
||||||
|
function isHttps(requestUrl) {
|
||||||
|
const parsedUrl = new URL(requestUrl);
|
||||||
|
return parsedUrl.protocol === 'https:';
|
||||||
|
}
|
||||||
|
exports.isHttps = isHttps;
|
||||||
|
class HttpClient {
|
||||||
|
constructor(userAgent, handlers, requestOptions) {
|
||||||
|
this._ignoreSslError = false;
|
||||||
|
this._allowRedirects = true;
|
||||||
|
this._allowRedirectDowngrade = false;
|
||||||
|
this._maxRedirects = 50;
|
||||||
|
this._allowRetries = false;
|
||||||
|
this._maxRetries = 1;
|
||||||
|
this._keepAlive = false;
|
||||||
|
this._disposed = false;
|
||||||
|
this.userAgent = userAgent;
|
||||||
|
this.handlers = handlers || [];
|
||||||
|
this.requestOptions = requestOptions;
|
||||||
|
if (requestOptions) {
|
||||||
|
if (requestOptions.ignoreSslError != null) {
|
||||||
|
this._ignoreSslError = requestOptions.ignoreSslError;
|
||||||
|
}
|
||||||
|
this._socketTimeout = requestOptions.socketTimeout;
|
||||||
|
if (requestOptions.allowRedirects != null) {
|
||||||
|
this._allowRedirects = requestOptions.allowRedirects;
|
||||||
|
}
|
||||||
|
if (requestOptions.allowRedirectDowngrade != null) {
|
||||||
|
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
||||||
|
}
|
||||||
|
if (requestOptions.maxRedirects != null) {
|
||||||
|
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
||||||
|
}
|
||||||
|
if (requestOptions.keepAlive != null) {
|
||||||
|
this._keepAlive = requestOptions.keepAlive;
|
||||||
|
}
|
||||||
|
if (requestOptions.allowRetries != null) {
|
||||||
|
this._allowRetries = requestOptions.allowRetries;
|
||||||
|
}
|
||||||
|
if (requestOptions.maxRetries != null) {
|
||||||
|
this._maxRetries = requestOptions.maxRetries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options(requestUrl, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
get(requestUrl, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
del(requestUrl, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
post(requestUrl, data, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
patch(requestUrl, data, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
put(requestUrl, data, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
head(requestUrl, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request(verb, requestUrl, stream, additionalHeaders);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets a typed object from an endpoint
|
||||||
|
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
||||||
|
*/
|
||||||
|
getJson(requestUrl, additionalHeaders = {}) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
|
const res = yield this.get(requestUrl, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
postJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const data = JSON.stringify(obj, null, 2);
|
||||||
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
|
const res = yield this.post(requestUrl, data, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
putJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const data = JSON.stringify(obj, null, 2);
|
||||||
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
|
const res = yield this.put(requestUrl, data, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const data = JSON.stringify(obj, null, 2);
|
||||||
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
|
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Makes a raw http request.
|
||||||
|
* All other methods such as get, post, patch, and request ultimately call this.
|
||||||
|
* Prefer get, del, post and patch
|
||||||
|
*/
|
||||||
|
request(verb, requestUrl, data, headers) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (this._disposed) {
|
||||||
|
throw new Error('Client has already been disposed.');
|
||||||
|
}
|
||||||
|
const parsedUrl = new URL(requestUrl);
|
||||||
|
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||||
|
// Only perform retries on reads since writes may not be idempotent.
|
||||||
|
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
||||||
|
? this._maxRetries + 1
|
||||||
|
: 1;
|
||||||
|
let numTries = 0;
|
||||||
|
let response;
|
||||||
|
do {
|
||||||
|
response = yield this.requestRaw(info, data);
|
||||||
|
// Check if it's an authentication challenge
|
||||||
|
if (response &&
|
||||||
|
response.message &&
|
||||||
|
response.message.statusCode === HttpCodes.Unauthorized) {
|
||||||
|
let authenticationHandler;
|
||||||
|
for (const handler of this.handlers) {
|
||||||
|
if (handler.canHandleAuthentication(response)) {
|
||||||
|
authenticationHandler = handler;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (authenticationHandler) {
|
||||||
|
return authenticationHandler.handleAuthentication(this, info, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// We have received an unauthorized response but have no handlers to handle it.
|
||||||
|
// Let the response return to the caller.
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let redirectsRemaining = this._maxRedirects;
|
||||||
|
while (response.message.statusCode &&
|
||||||
|
HttpRedirectCodes.includes(response.message.statusCode) &&
|
||||||
|
this._allowRedirects &&
|
||||||
|
redirectsRemaining > 0) {
|
||||||
|
const redirectUrl = response.message.headers['location'];
|
||||||
|
if (!redirectUrl) {
|
||||||
|
// if there's no location to redirect to, we won't
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const parsedRedirectUrl = new URL(redirectUrl);
|
||||||
|
if (parsedUrl.protocol === 'https:' &&
|
||||||
|
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
||||||
|
!this._allowRedirectDowngrade) {
|
||||||
|
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.');
|
||||||
|
}
|
||||||
|
// we need to finish reading the response before reassigning response
|
||||||
|
// which will leak the open socket.
|
||||||
|
yield response.readBody();
|
||||||
|
// strip authorization header if redirected to a different hostname
|
||||||
|
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
||||||
|
for (const header in headers) {
|
||||||
|
// header names are case insensitive
|
||||||
|
if (header.toLowerCase() === 'authorization') {
|
||||||
|
delete headers[header];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// let's make the request with the new redirectUrl
|
||||||
|
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
||||||
|
response = yield this.requestRaw(info, data);
|
||||||
|
redirectsRemaining--;
|
||||||
|
}
|
||||||
|
if (!response.message.statusCode ||
|
||||||
|
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
||||||
|
// If not a retry code, return immediately instead of retrying
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
numTries += 1;
|
||||||
|
if (numTries < maxTries) {
|
||||||
|
yield response.readBody();
|
||||||
|
yield this._performExponentialBackoff(numTries);
|
||||||
|
}
|
||||||
|
} while (numTries < maxTries);
|
||||||
|
return response;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Needs to be called if keepAlive is set to true in request options.
|
||||||
|
*/
|
||||||
|
dispose() {
|
||||||
|
if (this._agent) {
|
||||||
|
this._agent.destroy();
|
||||||
|
}
|
||||||
|
this._disposed = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Raw request.
|
||||||
|
* @param info
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
requestRaw(info, data) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
function callbackForResult(err, res) {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
else if (!res) {
|
||||||
|
// If `err` is not passed, then `res` must be passed.
|
||||||
|
reject(new Error('Unknown error'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolve(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.requestRawWithCallback(info, data, callbackForResult);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Raw request with callback.
|
||||||
|
* @param info
|
||||||
|
* @param data
|
||||||
|
* @param onResult
|
||||||
|
*/
|
||||||
|
requestRawWithCallback(info, data, onResult) {
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
if (!info.options.headers) {
|
||||||
|
info.options.headers = {};
|
||||||
|
}
|
||||||
|
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||||||
|
}
|
||||||
|
let callbackCalled = false;
|
||||||
|
function handleResult(err, res) {
|
||||||
|
if (!callbackCalled) {
|
||||||
|
callbackCalled = true;
|
||||||
|
onResult(err, res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const req = info.httpModule.request(info.options, (msg) => {
|
||||||
|
const res = new HttpClientResponse(msg);
|
||||||
|
handleResult(undefined, res);
|
||||||
|
});
|
||||||
|
let socket;
|
||||||
|
req.on('socket', sock => {
|
||||||
|
socket = sock;
|
||||||
|
});
|
||||||
|
// If we ever get disconnected, we want the socket to timeout eventually
|
||||||
|
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
||||||
|
if (socket) {
|
||||||
|
socket.end();
|
||||||
|
}
|
||||||
|
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
||||||
|
});
|
||||||
|
req.on('error', function (err) {
|
||||||
|
// err has statusCode property
|
||||||
|
// res should have headers
|
||||||
|
handleResult(err);
|
||||||
|
});
|
||||||
|
if (data && typeof data === 'string') {
|
||||||
|
req.write(data, 'utf8');
|
||||||
|
}
|
||||||
|
if (data && typeof data !== 'string') {
|
||||||
|
data.on('close', function () {
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
data.pipe(req);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
req.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets an http agent. This function is useful when you need an http agent that handles
|
||||||
|
* routing through a proxy server - depending upon the url and proxy environment variables.
|
||||||
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
|
*/
|
||||||
|
getAgent(serverUrl) {
|
||||||
|
const parsedUrl = new URL(serverUrl);
|
||||||
|
return this._getAgent(parsedUrl);
|
||||||
|
}
|
||||||
|
_prepareRequest(method, requestUrl, headers) {
|
||||||
|
const info = {};
|
||||||
|
info.parsedUrl = requestUrl;
|
||||||
|
const usingSsl = info.parsedUrl.protocol === 'https:';
|
||||||
|
info.httpModule = usingSsl ? https : http;
|
||||||
|
const defaultPort = usingSsl ? 443 : 80;
|
||||||
|
info.options = {};
|
||||||
|
info.options.host = info.parsedUrl.hostname;
|
||||||
|
info.options.port = info.parsedUrl.port
|
||||||
|
? parseInt(info.parsedUrl.port)
|
||||||
|
: defaultPort;
|
||||||
|
info.options.path =
|
||||||
|
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
||||||
|
info.options.method = method;
|
||||||
|
info.options.headers = this._mergeHeaders(headers);
|
||||||
|
if (this.userAgent != null) {
|
||||||
|
info.options.headers['user-agent'] = this.userAgent;
|
||||||
|
}
|
||||||
|
info.options.agent = this._getAgent(info.parsedUrl);
|
||||||
|
// gives handlers an opportunity to participate
|
||||||
|
if (this.handlers) {
|
||||||
|
for (const handler of this.handlers) {
|
||||||
|
handler.prepareRequest(info.options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
_mergeHeaders(headers) {
|
||||||
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
|
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
||||||
|
}
|
||||||
|
return lowercaseKeys(headers || {});
|
||||||
|
}
|
||||||
|
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
||||||
|
let clientHeader;
|
||||||
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
|
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
||||||
|
}
|
||||||
|
return additionalHeaders[header] || clientHeader || _default;
|
||||||
|
}
|
||||||
|
_getAgent(parsedUrl) {
|
||||||
|
let agent;
|
||||||
|
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
||||||
|
const useProxy = proxyUrl && proxyUrl.hostname;
|
||||||
|
if (this._keepAlive && useProxy) {
|
||||||
|
agent = this._proxyAgent;
|
||||||
|
}
|
||||||
|
if (this._keepAlive && !useProxy) {
|
||||||
|
agent = this._agent;
|
||||||
|
}
|
||||||
|
// if agent is already assigned use that agent.
|
||||||
|
if (agent) {
|
||||||
|
return agent;
|
||||||
|
}
|
||||||
|
const usingSsl = parsedUrl.protocol === 'https:';
|
||||||
|
let maxSockets = 100;
|
||||||
|
if (this.requestOptions) {
|
||||||
|
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
||||||
|
}
|
||||||
|
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
||||||
|
if (proxyUrl && proxyUrl.hostname) {
|
||||||
|
const agentOptions = {
|
||||||
|
maxSockets,
|
||||||
|
keepAlive: this._keepAlive,
|
||||||
|
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
||||||
|
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||||
|
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
||||||
|
};
|
||||||
|
let tunnelAgent;
|
||||||
|
const overHttps = proxyUrl.protocol === 'https:';
|
||||||
|
if (usingSsl) {
|
||||||
|
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
||||||
|
}
|
||||||
|
agent = tunnelAgent(agentOptions);
|
||||||
|
this._proxyAgent = agent;
|
||||||
|
}
|
||||||
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
||||||
|
if (this._keepAlive && !agent) {
|
||||||
|
const options = { keepAlive: this._keepAlive, maxSockets };
|
||||||
|
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
||||||
|
this._agent = agent;
|
||||||
|
}
|
||||||
|
// if not using private agent and tunnel agent isn't setup then use global agent
|
||||||
|
if (!agent) {
|
||||||
|
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
||||||
|
}
|
||||||
|
if (usingSsl && this._ignoreSslError) {
|
||||||
|
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
||||||
|
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
||||||
|
// we have to cast it to any and change it directly
|
||||||
|
agent.options = Object.assign(agent.options || {}, {
|
||||||
|
rejectUnauthorized: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return agent;
|
||||||
|
}
|
||||||
|
_performExponentialBackoff(retryNumber) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
||||||
|
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
||||||
|
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
_processResponse(res, options) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const statusCode = res.message.statusCode || 0;
|
||||||
|
const response = {
|
||||||
|
statusCode,
|
||||||
|
result: null,
|
||||||
|
headers: {}
|
||||||
|
};
|
||||||
|
// not found leads to null obj returned
|
||||||
|
if (statusCode === HttpCodes.NotFound) {
|
||||||
|
resolve(response);
|
||||||
|
}
|
||||||
|
// get the result from the body
|
||||||
|
function dateTimeDeserializer(key, value) {
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
const a = new Date(value);
|
||||||
|
if (!isNaN(a.valueOf())) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
let obj;
|
||||||
|
let contents;
|
||||||
|
try {
|
||||||
|
contents = yield res.readBody();
|
||||||
|
if (contents && contents.length > 0) {
|
||||||
|
if (options && options.deserializeDates) {
|
||||||
|
obj = JSON.parse(contents, dateTimeDeserializer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj = JSON.parse(contents);
|
||||||
|
}
|
||||||
|
response.result = obj;
|
||||||
|
}
|
||||||
|
response.headers = res.message.headers;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
// Invalid resource (contents not json); leaving result obj null
|
||||||
|
}
|
||||||
|
// note that 3xx redirects are handled by the http layer.
|
||||||
|
if (statusCode > 299) {
|
||||||
|
let msg;
|
||||||
|
// if exception/error in body, attempt to get better error
|
||||||
|
if (obj && obj.message) {
|
||||||
|
msg = obj.message;
|
||||||
|
}
|
||||||
|
else if (contents && contents.length > 0) {
|
||||||
|
// it may be the case that the exception is in the body message as string
|
||||||
|
msg = contents;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = `Failed request: (${statusCode})`;
|
||||||
|
}
|
||||||
|
const err = new HttpClientError(msg, statusCode);
|
||||||
|
err.result = response.result;
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolve(response);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.HttpClient = HttpClient;
|
||||||
|
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 9835:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.checkBypass = exports.getProxyUrl = void 0;
|
||||||
|
function getProxyUrl(reqUrl) {
|
||||||
|
const usingSsl = reqUrl.protocol === 'https:';
|
||||||
|
if (checkBypass(reqUrl)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const proxyVar = (() => {
|
||||||
|
if (usingSsl) {
|
||||||
|
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
if (proxyVar) {
|
||||||
|
return new URL(proxyVar);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.getProxyUrl = getProxyUrl;
|
||||||
|
function checkBypass(reqUrl) {
|
||||||
|
if (!reqUrl.hostname) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const reqHost = reqUrl.hostname;
|
||||||
|
if (isLoopbackAddress(reqHost)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||||||
|
if (!noProxy) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Determine the request port
|
||||||
|
let reqPort;
|
||||||
|
if (reqUrl.port) {
|
||||||
|
reqPort = Number(reqUrl.port);
|
||||||
|
}
|
||||||
|
else if (reqUrl.protocol === 'http:') {
|
||||||
|
reqPort = 80;
|
||||||
|
}
|
||||||
|
else if (reqUrl.protocol === 'https:') {
|
||||||
|
reqPort = 443;
|
||||||
|
}
|
||||||
|
// Format the request hostname and hostname with port
|
||||||
|
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
||||||
|
if (typeof reqPort === 'number') {
|
||||||
|
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||||||
|
}
|
||||||
|
// Compare request host against noproxy
|
||||||
|
for (const upperNoProxyItem of noProxy
|
||||||
|
.split(',')
|
||||||
|
.map(x => x.trim().toUpperCase())
|
||||||
|
.filter(x => x)) {
|
||||||
|
if (upperNoProxyItem === '*' ||
|
||||||
|
upperReqHosts.some(x => x === upperNoProxyItem ||
|
||||||
|
x.endsWith(`.${upperNoProxyItem}`) ||
|
||||||
|
(upperNoProxyItem.startsWith('.') &&
|
||||||
|
x.endsWith(`${upperNoProxyItem}`)))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
exports.checkBypass = checkBypass;
|
||||||
|
function isLoopbackAddress(host) {
|
||||||
|
const hostLower = host.toLowerCase();
|
||||||
|
return (hostLower === 'localhost' ||
|
||||||
|
hostLower.startsWith('127.') ||
|
||||||
|
hostLower.startsWith('[::1]') ||
|
||||||
|
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=proxy.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 1962:
|
/***/ 1962:
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
|||||||
2803
dist/setup/index.js
vendored
2803
dist/setup/index.js
vendored
@ -245,8 +245,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const http_client_1 = __nccwpck_require__(1825);
|
const http_client_1 = __nccwpck_require__(6255);
|
||||||
const auth_1 = __nccwpck_require__(2001);
|
const auth_1 = __nccwpck_require__(5526);
|
||||||
const crypto = __importStar(__nccwpck_require__(6113));
|
const crypto = __importStar(__nccwpck_require__(6113));
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
const url_1 = __nccwpck_require__(7310);
|
const url_1 = __nccwpck_require__(7310);
|
||||||
@ -718,7 +718,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const http_client_1 = __nccwpck_require__(1825);
|
const http_client_1 = __nccwpck_require__(6255);
|
||||||
const storage_blob_1 = __nccwpck_require__(4100);
|
const storage_blob_1 = __nccwpck_require__(4100);
|
||||||
const buffer = __importStar(__nccwpck_require__(4300));
|
const buffer = __importStar(__nccwpck_require__(4300));
|
||||||
const fs = __importStar(__nccwpck_require__(7147));
|
const fs = __importStar(__nccwpck_require__(7147));
|
||||||
@ -976,7 +976,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const http_client_1 = __nccwpck_require__(1825);
|
const http_client_1 = __nccwpck_require__(6255);
|
||||||
const constants_1 = __nccwpck_require__(8840);
|
const constants_1 = __nccwpck_require__(8840);
|
||||||
function isSuccessStatusCode(statusCode) {
|
function isSuccessStatusCode(statusCode) {
|
||||||
if (!statusCode) {
|
if (!statusCode) {
|
||||||
@ -2486,774 +2486,6 @@ exports.SearchState = SearchState;
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 2001:
|
|
||||||
/***/ (function(__unused_webpack_module, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
|
||||||
class BasicCredentialHandler {
|
|
||||||
constructor(username, password) {
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.BasicCredentialHandler = BasicCredentialHandler;
|
|
||||||
class BearerCredentialHandler {
|
|
||||||
constructor(token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
// currently implements pre-authorization
|
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Bearer ${this.token}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.BearerCredentialHandler = BearerCredentialHandler;
|
|
||||||
class PersonalAccessTokenCredentialHandler {
|
|
||||||
constructor(token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
// currently implements pre-authorization
|
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
|
||||||
//# sourceMappingURL=auth.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 1825:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
|
||||||
const http = __importStar(__nccwpck_require__(3685));
|
|
||||||
const https = __importStar(__nccwpck_require__(5687));
|
|
||||||
const pm = __importStar(__nccwpck_require__(4977));
|
|
||||||
const tunnel = __importStar(__nccwpck_require__(4294));
|
|
||||||
var HttpCodes;
|
|
||||||
(function (HttpCodes) {
|
|
||||||
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
|
||||||
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
|
||||||
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
|
||||||
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
|
||||||
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
|
||||||
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
|
||||||
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
|
||||||
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
|
||||||
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
||||||
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
||||||
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
|
||||||
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
|
||||||
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
|
||||||
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
|
||||||
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
|
||||||
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
||||||
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
|
||||||
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
||||||
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
|
||||||
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
|
||||||
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
|
||||||
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
|
||||||
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
|
||||||
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
|
||||||
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
|
||||||
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
||||||
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
||||||
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
|
||||||
var Headers;
|
|
||||||
(function (Headers) {
|
|
||||||
Headers["Accept"] = "accept";
|
|
||||||
Headers["ContentType"] = "content-type";
|
|
||||||
})(Headers = exports.Headers || (exports.Headers = {}));
|
|
||||||
var MediaTypes;
|
|
||||||
(function (MediaTypes) {
|
|
||||||
MediaTypes["ApplicationJson"] = "application/json";
|
|
||||||
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
|
||||||
/**
|
|
||||||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
|
||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
||||||
*/
|
|
||||||
function getProxyUrl(serverUrl) {
|
|
||||||
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
|
||||||
return proxyUrl ? proxyUrl.href : '';
|
|
||||||
}
|
|
||||||
exports.getProxyUrl = getProxyUrl;
|
|
||||||
const HttpRedirectCodes = [
|
|
||||||
HttpCodes.MovedPermanently,
|
|
||||||
HttpCodes.ResourceMoved,
|
|
||||||
HttpCodes.SeeOther,
|
|
||||||
HttpCodes.TemporaryRedirect,
|
|
||||||
HttpCodes.PermanentRedirect
|
|
||||||
];
|
|
||||||
const HttpResponseRetryCodes = [
|
|
||||||
HttpCodes.BadGateway,
|
|
||||||
HttpCodes.ServiceUnavailable,
|
|
||||||
HttpCodes.GatewayTimeout
|
|
||||||
];
|
|
||||||
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
|
||||||
const ExponentialBackoffCeiling = 10;
|
|
||||||
const ExponentialBackoffTimeSlice = 5;
|
|
||||||
class HttpClientError extends Error {
|
|
||||||
constructor(message, statusCode) {
|
|
||||||
super(message);
|
|
||||||
this.name = 'HttpClientError';
|
|
||||||
this.statusCode = statusCode;
|
|
||||||
Object.setPrototypeOf(this, HttpClientError.prototype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClientError = HttpClientError;
|
|
||||||
class HttpClientResponse {
|
|
||||||
constructor(message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
readBody() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let output = Buffer.alloc(0);
|
|
||||||
this.message.on('data', (chunk) => {
|
|
||||||
output = Buffer.concat([output, chunk]);
|
|
||||||
});
|
|
||||||
this.message.on('end', () => {
|
|
||||||
resolve(output.toString());
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClientResponse = HttpClientResponse;
|
|
||||||
function isHttps(requestUrl) {
|
|
||||||
const parsedUrl = new URL(requestUrl);
|
|
||||||
return parsedUrl.protocol === 'https:';
|
|
||||||
}
|
|
||||||
exports.isHttps = isHttps;
|
|
||||||
class HttpClient {
|
|
||||||
constructor(userAgent, handlers, requestOptions) {
|
|
||||||
this._ignoreSslError = false;
|
|
||||||
this._allowRedirects = true;
|
|
||||||
this._allowRedirectDowngrade = false;
|
|
||||||
this._maxRedirects = 50;
|
|
||||||
this._allowRetries = false;
|
|
||||||
this._maxRetries = 1;
|
|
||||||
this._keepAlive = false;
|
|
||||||
this._disposed = false;
|
|
||||||
this.userAgent = userAgent;
|
|
||||||
this.handlers = handlers || [];
|
|
||||||
this.requestOptions = requestOptions;
|
|
||||||
if (requestOptions) {
|
|
||||||
if (requestOptions.ignoreSslError != null) {
|
|
||||||
this._ignoreSslError = requestOptions.ignoreSslError;
|
|
||||||
}
|
|
||||||
this._socketTimeout = requestOptions.socketTimeout;
|
|
||||||
if (requestOptions.allowRedirects != null) {
|
|
||||||
this._allowRedirects = requestOptions.allowRedirects;
|
|
||||||
}
|
|
||||||
if (requestOptions.allowRedirectDowngrade != null) {
|
|
||||||
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
|
||||||
}
|
|
||||||
if (requestOptions.maxRedirects != null) {
|
|
||||||
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
|
||||||
}
|
|
||||||
if (requestOptions.keepAlive != null) {
|
|
||||||
this._keepAlive = requestOptions.keepAlive;
|
|
||||||
}
|
|
||||||
if (requestOptions.allowRetries != null) {
|
|
||||||
this._allowRetries = requestOptions.allowRetries;
|
|
||||||
}
|
|
||||||
if (requestOptions.maxRetries != null) {
|
|
||||||
this._maxRetries = requestOptions.maxRetries;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
get(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
del(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
post(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
patch(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
put(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
head(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request(verb, requestUrl, stream, additionalHeaders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets a typed object from an endpoint
|
|
||||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
|
||||||
*/
|
|
||||||
getJson(requestUrl, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.get(requestUrl, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
postJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.post(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
putJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.put(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Makes a raw http request.
|
|
||||||
* All other methods such as get, post, patch, and request ultimately call this.
|
|
||||||
* Prefer get, del, post and patch
|
|
||||||
*/
|
|
||||||
request(verb, requestUrl, data, headers) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (this._disposed) {
|
|
||||||
throw new Error('Client has already been disposed.');
|
|
||||||
}
|
|
||||||
const parsedUrl = new URL(requestUrl);
|
|
||||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
|
||||||
// Only perform retries on reads since writes may not be idempotent.
|
|
||||||
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
|
||||||
? this._maxRetries + 1
|
|
||||||
: 1;
|
|
||||||
let numTries = 0;
|
|
||||||
let response;
|
|
||||||
do {
|
|
||||||
response = yield this.requestRaw(info, data);
|
|
||||||
// Check if it's an authentication challenge
|
|
||||||
if (response &&
|
|
||||||
response.message &&
|
|
||||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
|
||||||
let authenticationHandler;
|
|
||||||
for (const handler of this.handlers) {
|
|
||||||
if (handler.canHandleAuthentication(response)) {
|
|
||||||
authenticationHandler = handler;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (authenticationHandler) {
|
|
||||||
return authenticationHandler.handleAuthentication(this, info, data);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// We have received an unauthorized response but have no handlers to handle it.
|
|
||||||
// Let the response return to the caller.
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let redirectsRemaining = this._maxRedirects;
|
|
||||||
while (response.message.statusCode &&
|
|
||||||
HttpRedirectCodes.includes(response.message.statusCode) &&
|
|
||||||
this._allowRedirects &&
|
|
||||||
redirectsRemaining > 0) {
|
|
||||||
const redirectUrl = response.message.headers['location'];
|
|
||||||
if (!redirectUrl) {
|
|
||||||
// if there's no location to redirect to, we won't
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const parsedRedirectUrl = new URL(redirectUrl);
|
|
||||||
if (parsedUrl.protocol === 'https:' &&
|
|
||||||
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
|
||||||
!this._allowRedirectDowngrade) {
|
|
||||||
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.');
|
|
||||||
}
|
|
||||||
// we need to finish reading the response before reassigning response
|
|
||||||
// which will leak the open socket.
|
|
||||||
yield response.readBody();
|
|
||||||
// strip authorization header if redirected to a different hostname
|
|
||||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
|
||||||
for (const header in headers) {
|
|
||||||
// header names are case insensitive
|
|
||||||
if (header.toLowerCase() === 'authorization') {
|
|
||||||
delete headers[header];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// let's make the request with the new redirectUrl
|
|
||||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
|
||||||
response = yield this.requestRaw(info, data);
|
|
||||||
redirectsRemaining--;
|
|
||||||
}
|
|
||||||
if (!response.message.statusCode ||
|
|
||||||
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
|
||||||
// If not a retry code, return immediately instead of retrying
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
numTries += 1;
|
|
||||||
if (numTries < maxTries) {
|
|
||||||
yield response.readBody();
|
|
||||||
yield this._performExponentialBackoff(numTries);
|
|
||||||
}
|
|
||||||
} while (numTries < maxTries);
|
|
||||||
return response;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Needs to be called if keepAlive is set to true in request options.
|
|
||||||
*/
|
|
||||||
dispose() {
|
|
||||||
if (this._agent) {
|
|
||||||
this._agent.destroy();
|
|
||||||
}
|
|
||||||
this._disposed = true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Raw request.
|
|
||||||
* @param info
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
requestRaw(info, data) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
function callbackForResult(err, res) {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
else if (!res) {
|
|
||||||
// If `err` is not passed, then `res` must be passed.
|
|
||||||
reject(new Error('Unknown error'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.requestRawWithCallback(info, data, callbackForResult);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Raw request with callback.
|
|
||||||
* @param info
|
|
||||||
* @param data
|
|
||||||
* @param onResult
|
|
||||||
*/
|
|
||||||
requestRawWithCallback(info, data, onResult) {
|
|
||||||
if (typeof data === 'string') {
|
|
||||||
if (!info.options.headers) {
|
|
||||||
info.options.headers = {};
|
|
||||||
}
|
|
||||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
|
||||||
}
|
|
||||||
let callbackCalled = false;
|
|
||||||
function handleResult(err, res) {
|
|
||||||
if (!callbackCalled) {
|
|
||||||
callbackCalled = true;
|
|
||||||
onResult(err, res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const req = info.httpModule.request(info.options, (msg) => {
|
|
||||||
const res = new HttpClientResponse(msg);
|
|
||||||
handleResult(undefined, res);
|
|
||||||
});
|
|
||||||
let socket;
|
|
||||||
req.on('socket', sock => {
|
|
||||||
socket = sock;
|
|
||||||
});
|
|
||||||
// If we ever get disconnected, we want the socket to timeout eventually
|
|
||||||
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
|
||||||
if (socket) {
|
|
||||||
socket.end();
|
|
||||||
}
|
|
||||||
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
|
||||||
});
|
|
||||||
req.on('error', function (err) {
|
|
||||||
// err has statusCode property
|
|
||||||
// res should have headers
|
|
||||||
handleResult(err);
|
|
||||||
});
|
|
||||||
if (data && typeof data === 'string') {
|
|
||||||
req.write(data, 'utf8');
|
|
||||||
}
|
|
||||||
if (data && typeof data !== 'string') {
|
|
||||||
data.on('close', function () {
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
data.pipe(req);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
req.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets an http agent. This function is useful when you need an http agent that handles
|
|
||||||
* routing through a proxy server - depending upon the url and proxy environment variables.
|
|
||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
||||||
*/
|
|
||||||
getAgent(serverUrl) {
|
|
||||||
const parsedUrl = new URL(serverUrl);
|
|
||||||
return this._getAgent(parsedUrl);
|
|
||||||
}
|
|
||||||
_prepareRequest(method, requestUrl, headers) {
|
|
||||||
const info = {};
|
|
||||||
info.parsedUrl = requestUrl;
|
|
||||||
const usingSsl = info.parsedUrl.protocol === 'https:';
|
|
||||||
info.httpModule = usingSsl ? https : http;
|
|
||||||
const defaultPort = usingSsl ? 443 : 80;
|
|
||||||
info.options = {};
|
|
||||||
info.options.host = info.parsedUrl.hostname;
|
|
||||||
info.options.port = info.parsedUrl.port
|
|
||||||
? parseInt(info.parsedUrl.port)
|
|
||||||
: defaultPort;
|
|
||||||
info.options.path =
|
|
||||||
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
|
||||||
info.options.method = method;
|
|
||||||
info.options.headers = this._mergeHeaders(headers);
|
|
||||||
if (this.userAgent != null) {
|
|
||||||
info.options.headers['user-agent'] = this.userAgent;
|
|
||||||
}
|
|
||||||
info.options.agent = this._getAgent(info.parsedUrl);
|
|
||||||
// gives handlers an opportunity to participate
|
|
||||||
if (this.handlers) {
|
|
||||||
for (const handler of this.handlers) {
|
|
||||||
handler.prepareRequest(info.options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
_mergeHeaders(headers) {
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
|
||||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
|
||||||
}
|
|
||||||
return lowercaseKeys(headers || {});
|
|
||||||
}
|
|
||||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
|
||||||
let clientHeader;
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
|
||||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
|
||||||
}
|
|
||||||
return additionalHeaders[header] || clientHeader || _default;
|
|
||||||
}
|
|
||||||
_getAgent(parsedUrl) {
|
|
||||||
let agent;
|
|
||||||
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
|
||||||
const useProxy = proxyUrl && proxyUrl.hostname;
|
|
||||||
if (this._keepAlive && useProxy) {
|
|
||||||
agent = this._proxyAgent;
|
|
||||||
}
|
|
||||||
if (this._keepAlive && !useProxy) {
|
|
||||||
agent = this._agent;
|
|
||||||
}
|
|
||||||
// if agent is already assigned use that agent.
|
|
||||||
if (agent) {
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
const usingSsl = parsedUrl.protocol === 'https:';
|
|
||||||
let maxSockets = 100;
|
|
||||||
if (this.requestOptions) {
|
|
||||||
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
|
||||||
}
|
|
||||||
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
|
||||||
if (proxyUrl && proxyUrl.hostname) {
|
|
||||||
const agentOptions = {
|
|
||||||
maxSockets,
|
|
||||||
keepAlive: this._keepAlive,
|
|
||||||
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
|
||||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
|
||||||
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
|
||||||
};
|
|
||||||
let tunnelAgent;
|
|
||||||
const overHttps = proxyUrl.protocol === 'https:';
|
|
||||||
if (usingSsl) {
|
|
||||||
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
|
||||||
}
|
|
||||||
agent = tunnelAgent(agentOptions);
|
|
||||||
this._proxyAgent = agent;
|
|
||||||
}
|
|
||||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
|
||||||
if (this._keepAlive && !agent) {
|
|
||||||
const options = { keepAlive: this._keepAlive, maxSockets };
|
|
||||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
|
||||||
this._agent = agent;
|
|
||||||
}
|
|
||||||
// if not using private agent and tunnel agent isn't setup then use global agent
|
|
||||||
if (!agent) {
|
|
||||||
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
|
||||||
}
|
|
||||||
if (usingSsl && this._ignoreSslError) {
|
|
||||||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
|
||||||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
|
||||||
// we have to cast it to any and change it directly
|
|
||||||
agent.options = Object.assign(agent.options || {}, {
|
|
||||||
rejectUnauthorized: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
_performExponentialBackoff(retryNumber) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
|
||||||
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
|
||||||
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_processResponse(res, options) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const statusCode = res.message.statusCode || 0;
|
|
||||||
const response = {
|
|
||||||
statusCode,
|
|
||||||
result: null,
|
|
||||||
headers: {}
|
|
||||||
};
|
|
||||||
// not found leads to null obj returned
|
|
||||||
if (statusCode === HttpCodes.NotFound) {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
// get the result from the body
|
|
||||||
function dateTimeDeserializer(key, value) {
|
|
||||||
if (typeof value === 'string') {
|
|
||||||
const a = new Date(value);
|
|
||||||
if (!isNaN(a.valueOf())) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
let obj;
|
|
||||||
let contents;
|
|
||||||
try {
|
|
||||||
contents = yield res.readBody();
|
|
||||||
if (contents && contents.length > 0) {
|
|
||||||
if (options && options.deserializeDates) {
|
|
||||||
obj = JSON.parse(contents, dateTimeDeserializer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
obj = JSON.parse(contents);
|
|
||||||
}
|
|
||||||
response.result = obj;
|
|
||||||
}
|
|
||||||
response.headers = res.message.headers;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// Invalid resource (contents not json); leaving result obj null
|
|
||||||
}
|
|
||||||
// note that 3xx redirects are handled by the http layer.
|
|
||||||
if (statusCode > 299) {
|
|
||||||
let msg;
|
|
||||||
// if exception/error in body, attempt to get better error
|
|
||||||
if (obj && obj.message) {
|
|
||||||
msg = obj.message;
|
|
||||||
}
|
|
||||||
else if (contents && contents.length > 0) {
|
|
||||||
// it may be the case that the exception is in the body message as string
|
|
||||||
msg = contents;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
msg = `Failed request: (${statusCode})`;
|
|
||||||
}
|
|
||||||
const err = new HttpClientError(msg, statusCode);
|
|
||||||
err.result = response.result;
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClient = HttpClient;
|
|
||||||
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 4977:
|
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.checkBypass = exports.getProxyUrl = void 0;
|
|
||||||
function getProxyUrl(reqUrl) {
|
|
||||||
const usingSsl = reqUrl.protocol === 'https:';
|
|
||||||
if (checkBypass(reqUrl)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const proxyVar = (() => {
|
|
||||||
if (usingSsl) {
|
|
||||||
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
if (proxyVar) {
|
|
||||||
return new URL(proxyVar);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.getProxyUrl = getProxyUrl;
|
|
||||||
function checkBypass(reqUrl) {
|
|
||||||
if (!reqUrl.hostname) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
|
||||||
if (!noProxy) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Determine the request port
|
|
||||||
let reqPort;
|
|
||||||
if (reqUrl.port) {
|
|
||||||
reqPort = Number(reqUrl.port);
|
|
||||||
}
|
|
||||||
else if (reqUrl.protocol === 'http:') {
|
|
||||||
reqPort = 80;
|
|
||||||
}
|
|
||||||
else if (reqUrl.protocol === 'https:') {
|
|
||||||
reqPort = 443;
|
|
||||||
}
|
|
||||||
// Format the request hostname and hostname with port
|
|
||||||
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
|
||||||
if (typeof reqPort === 'number') {
|
|
||||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
|
||||||
}
|
|
||||||
// Compare request host against noproxy
|
|
||||||
for (const upperNoProxyItem of noProxy
|
|
||||||
.split(',')
|
|
||||||
.map(x => x.trim().toUpperCase())
|
|
||||||
.filter(x => x)) {
|
|
||||||
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
exports.checkBypass = checkBypass;
|
|
||||||
//# sourceMappingURL=proxy.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 3771:
|
/***/ 3771:
|
||||||
/***/ ((module, exports) => {
|
/***/ ((module, exports) => {
|
||||||
|
|
||||||
@ -5380,8 +4612,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.OidcClient = void 0;
|
exports.OidcClient = void 0;
|
||||||
const http_client_1 = __nccwpck_require__(1404);
|
const http_client_1 = __nccwpck_require__(6255);
|
||||||
const auth_1 = __nccwpck_require__(6758);
|
const auth_1 = __nccwpck_require__(5526);
|
||||||
const core_1 = __nccwpck_require__(2186);
|
const core_1 = __nccwpck_require__(2186);
|
||||||
class OidcClient {
|
class OidcClient {
|
||||||
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
||||||
@ -5850,774 +5082,6 @@ exports.toCommandProperties = toCommandProperties;
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6758:
|
|
||||||
/***/ (function(__unused_webpack_module, exports) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
|
||||||
class BasicCredentialHandler {
|
|
||||||
constructor(username, password) {
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.BasicCredentialHandler = BasicCredentialHandler;
|
|
||||||
class BearerCredentialHandler {
|
|
||||||
constructor(token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
// currently implements pre-authorization
|
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Bearer ${this.token}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.BearerCredentialHandler = BearerCredentialHandler;
|
|
||||||
class PersonalAccessTokenCredentialHandler {
|
|
||||||
constructor(token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
// currently implements pre-authorization
|
|
||||||
// TODO: support preAuth = false where it hooks on 401
|
|
||||||
prepareRequest(options) {
|
|
||||||
if (!options.headers) {
|
|
||||||
throw Error('The request has no headers');
|
|
||||||
}
|
|
||||||
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
|
||||||
}
|
|
||||||
// This handler cannot handle 401
|
|
||||||
canHandleAuthentication() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
handleAuthentication() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
throw new Error('not implemented');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
|
||||||
//# sourceMappingURL=auth.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 1404:
|
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
||||||
}) : function(o, v) {
|
|
||||||
o["default"] = v;
|
|
||||||
});
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
||||||
__setModuleDefault(result, mod);
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
|
||||||
const http = __importStar(__nccwpck_require__(3685));
|
|
||||||
const https = __importStar(__nccwpck_require__(5687));
|
|
||||||
const pm = __importStar(__nccwpck_require__(2843));
|
|
||||||
const tunnel = __importStar(__nccwpck_require__(4294));
|
|
||||||
var HttpCodes;
|
|
||||||
(function (HttpCodes) {
|
|
||||||
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
|
||||||
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
|
||||||
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
|
||||||
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
|
||||||
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
|
||||||
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
|
||||||
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
|
||||||
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
|
||||||
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
|
||||||
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
|
||||||
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
|
||||||
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
|
||||||
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
|
||||||
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
|
||||||
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
|
||||||
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
|
||||||
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
|
||||||
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
|
||||||
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
|
||||||
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
|
||||||
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
|
||||||
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
|
||||||
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
|
||||||
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
|
||||||
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
|
||||||
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
|
||||||
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
|
||||||
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
|
||||||
var Headers;
|
|
||||||
(function (Headers) {
|
|
||||||
Headers["Accept"] = "accept";
|
|
||||||
Headers["ContentType"] = "content-type";
|
|
||||||
})(Headers = exports.Headers || (exports.Headers = {}));
|
|
||||||
var MediaTypes;
|
|
||||||
(function (MediaTypes) {
|
|
||||||
MediaTypes["ApplicationJson"] = "application/json";
|
|
||||||
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
|
||||||
/**
|
|
||||||
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
|
||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
||||||
*/
|
|
||||||
function getProxyUrl(serverUrl) {
|
|
||||||
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
|
||||||
return proxyUrl ? proxyUrl.href : '';
|
|
||||||
}
|
|
||||||
exports.getProxyUrl = getProxyUrl;
|
|
||||||
const HttpRedirectCodes = [
|
|
||||||
HttpCodes.MovedPermanently,
|
|
||||||
HttpCodes.ResourceMoved,
|
|
||||||
HttpCodes.SeeOther,
|
|
||||||
HttpCodes.TemporaryRedirect,
|
|
||||||
HttpCodes.PermanentRedirect
|
|
||||||
];
|
|
||||||
const HttpResponseRetryCodes = [
|
|
||||||
HttpCodes.BadGateway,
|
|
||||||
HttpCodes.ServiceUnavailable,
|
|
||||||
HttpCodes.GatewayTimeout
|
|
||||||
];
|
|
||||||
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
|
||||||
const ExponentialBackoffCeiling = 10;
|
|
||||||
const ExponentialBackoffTimeSlice = 5;
|
|
||||||
class HttpClientError extends Error {
|
|
||||||
constructor(message, statusCode) {
|
|
||||||
super(message);
|
|
||||||
this.name = 'HttpClientError';
|
|
||||||
this.statusCode = statusCode;
|
|
||||||
Object.setPrototypeOf(this, HttpClientError.prototype);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClientError = HttpClientError;
|
|
||||||
class HttpClientResponse {
|
|
||||||
constructor(message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
readBody() {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
let output = Buffer.alloc(0);
|
|
||||||
this.message.on('data', (chunk) => {
|
|
||||||
output = Buffer.concat([output, chunk]);
|
|
||||||
});
|
|
||||||
this.message.on('end', () => {
|
|
||||||
resolve(output.toString());
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClientResponse = HttpClientResponse;
|
|
||||||
function isHttps(requestUrl) {
|
|
||||||
const parsedUrl = new URL(requestUrl);
|
|
||||||
return parsedUrl.protocol === 'https:';
|
|
||||||
}
|
|
||||||
exports.isHttps = isHttps;
|
|
||||||
class HttpClient {
|
|
||||||
constructor(userAgent, handlers, requestOptions) {
|
|
||||||
this._ignoreSslError = false;
|
|
||||||
this._allowRedirects = true;
|
|
||||||
this._allowRedirectDowngrade = false;
|
|
||||||
this._maxRedirects = 50;
|
|
||||||
this._allowRetries = false;
|
|
||||||
this._maxRetries = 1;
|
|
||||||
this._keepAlive = false;
|
|
||||||
this._disposed = false;
|
|
||||||
this.userAgent = userAgent;
|
|
||||||
this.handlers = handlers || [];
|
|
||||||
this.requestOptions = requestOptions;
|
|
||||||
if (requestOptions) {
|
|
||||||
if (requestOptions.ignoreSslError != null) {
|
|
||||||
this._ignoreSslError = requestOptions.ignoreSslError;
|
|
||||||
}
|
|
||||||
this._socketTimeout = requestOptions.socketTimeout;
|
|
||||||
if (requestOptions.allowRedirects != null) {
|
|
||||||
this._allowRedirects = requestOptions.allowRedirects;
|
|
||||||
}
|
|
||||||
if (requestOptions.allowRedirectDowngrade != null) {
|
|
||||||
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
|
||||||
}
|
|
||||||
if (requestOptions.maxRedirects != null) {
|
|
||||||
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
|
||||||
}
|
|
||||||
if (requestOptions.keepAlive != null) {
|
|
||||||
this._keepAlive = requestOptions.keepAlive;
|
|
||||||
}
|
|
||||||
if (requestOptions.allowRetries != null) {
|
|
||||||
this._allowRetries = requestOptions.allowRetries;
|
|
||||||
}
|
|
||||||
if (requestOptions.maxRetries != null) {
|
|
||||||
this._maxRetries = requestOptions.maxRetries;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
get(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
del(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
post(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
patch(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
put(requestUrl, data, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
head(requestUrl, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return this.request(verb, requestUrl, stream, additionalHeaders);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets a typed object from an endpoint
|
|
||||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
|
||||||
*/
|
|
||||||
getJson(requestUrl, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.get(requestUrl, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
postJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.post(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
putJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.put(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const data = JSON.stringify(obj, null, 2);
|
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
|
||||||
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
|
||||||
return this._processResponse(res, this.requestOptions);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Makes a raw http request.
|
|
||||||
* All other methods such as get, post, patch, and request ultimately call this.
|
|
||||||
* Prefer get, del, post and patch
|
|
||||||
*/
|
|
||||||
request(verb, requestUrl, data, headers) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
if (this._disposed) {
|
|
||||||
throw new Error('Client has already been disposed.');
|
|
||||||
}
|
|
||||||
const parsedUrl = new URL(requestUrl);
|
|
||||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
|
||||||
// Only perform retries on reads since writes may not be idempotent.
|
|
||||||
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
|
||||||
? this._maxRetries + 1
|
|
||||||
: 1;
|
|
||||||
let numTries = 0;
|
|
||||||
let response;
|
|
||||||
do {
|
|
||||||
response = yield this.requestRaw(info, data);
|
|
||||||
// Check if it's an authentication challenge
|
|
||||||
if (response &&
|
|
||||||
response.message &&
|
|
||||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
|
||||||
let authenticationHandler;
|
|
||||||
for (const handler of this.handlers) {
|
|
||||||
if (handler.canHandleAuthentication(response)) {
|
|
||||||
authenticationHandler = handler;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (authenticationHandler) {
|
|
||||||
return authenticationHandler.handleAuthentication(this, info, data);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// We have received an unauthorized response but have no handlers to handle it.
|
|
||||||
// Let the response return to the caller.
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let redirectsRemaining = this._maxRedirects;
|
|
||||||
while (response.message.statusCode &&
|
|
||||||
HttpRedirectCodes.includes(response.message.statusCode) &&
|
|
||||||
this._allowRedirects &&
|
|
||||||
redirectsRemaining > 0) {
|
|
||||||
const redirectUrl = response.message.headers['location'];
|
|
||||||
if (!redirectUrl) {
|
|
||||||
// if there's no location to redirect to, we won't
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const parsedRedirectUrl = new URL(redirectUrl);
|
|
||||||
if (parsedUrl.protocol === 'https:' &&
|
|
||||||
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
|
||||||
!this._allowRedirectDowngrade) {
|
|
||||||
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.');
|
|
||||||
}
|
|
||||||
// we need to finish reading the response before reassigning response
|
|
||||||
// which will leak the open socket.
|
|
||||||
yield response.readBody();
|
|
||||||
// strip authorization header if redirected to a different hostname
|
|
||||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
|
||||||
for (const header in headers) {
|
|
||||||
// header names are case insensitive
|
|
||||||
if (header.toLowerCase() === 'authorization') {
|
|
||||||
delete headers[header];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// let's make the request with the new redirectUrl
|
|
||||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
|
||||||
response = yield this.requestRaw(info, data);
|
|
||||||
redirectsRemaining--;
|
|
||||||
}
|
|
||||||
if (!response.message.statusCode ||
|
|
||||||
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
|
||||||
// If not a retry code, return immediately instead of retrying
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
numTries += 1;
|
|
||||||
if (numTries < maxTries) {
|
|
||||||
yield response.readBody();
|
|
||||||
yield this._performExponentialBackoff(numTries);
|
|
||||||
}
|
|
||||||
} while (numTries < maxTries);
|
|
||||||
return response;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Needs to be called if keepAlive is set to true in request options.
|
|
||||||
*/
|
|
||||||
dispose() {
|
|
||||||
if (this._agent) {
|
|
||||||
this._agent.destroy();
|
|
||||||
}
|
|
||||||
this._disposed = true;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Raw request.
|
|
||||||
* @param info
|
|
||||||
* @param data
|
|
||||||
*/
|
|
||||||
requestRaw(info, data) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
function callbackForResult(err, res) {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
else if (!res) {
|
|
||||||
// If `err` is not passed, then `res` must be passed.
|
|
||||||
reject(new Error('Unknown error'));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.requestRawWithCallback(info, data, callbackForResult);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Raw request with callback.
|
|
||||||
* @param info
|
|
||||||
* @param data
|
|
||||||
* @param onResult
|
|
||||||
*/
|
|
||||||
requestRawWithCallback(info, data, onResult) {
|
|
||||||
if (typeof data === 'string') {
|
|
||||||
if (!info.options.headers) {
|
|
||||||
info.options.headers = {};
|
|
||||||
}
|
|
||||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
|
||||||
}
|
|
||||||
let callbackCalled = false;
|
|
||||||
function handleResult(err, res) {
|
|
||||||
if (!callbackCalled) {
|
|
||||||
callbackCalled = true;
|
|
||||||
onResult(err, res);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const req = info.httpModule.request(info.options, (msg) => {
|
|
||||||
const res = new HttpClientResponse(msg);
|
|
||||||
handleResult(undefined, res);
|
|
||||||
});
|
|
||||||
let socket;
|
|
||||||
req.on('socket', sock => {
|
|
||||||
socket = sock;
|
|
||||||
});
|
|
||||||
// If we ever get disconnected, we want the socket to timeout eventually
|
|
||||||
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
|
||||||
if (socket) {
|
|
||||||
socket.end();
|
|
||||||
}
|
|
||||||
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
|
||||||
});
|
|
||||||
req.on('error', function (err) {
|
|
||||||
// err has statusCode property
|
|
||||||
// res should have headers
|
|
||||||
handleResult(err);
|
|
||||||
});
|
|
||||||
if (data && typeof data === 'string') {
|
|
||||||
req.write(data, 'utf8');
|
|
||||||
}
|
|
||||||
if (data && typeof data !== 'string') {
|
|
||||||
data.on('close', function () {
|
|
||||||
req.end();
|
|
||||||
});
|
|
||||||
data.pipe(req);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
req.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets an http agent. This function is useful when you need an http agent that handles
|
|
||||||
* routing through a proxy server - depending upon the url and proxy environment variables.
|
|
||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
|
||||||
*/
|
|
||||||
getAgent(serverUrl) {
|
|
||||||
const parsedUrl = new URL(serverUrl);
|
|
||||||
return this._getAgent(parsedUrl);
|
|
||||||
}
|
|
||||||
_prepareRequest(method, requestUrl, headers) {
|
|
||||||
const info = {};
|
|
||||||
info.parsedUrl = requestUrl;
|
|
||||||
const usingSsl = info.parsedUrl.protocol === 'https:';
|
|
||||||
info.httpModule = usingSsl ? https : http;
|
|
||||||
const defaultPort = usingSsl ? 443 : 80;
|
|
||||||
info.options = {};
|
|
||||||
info.options.host = info.parsedUrl.hostname;
|
|
||||||
info.options.port = info.parsedUrl.port
|
|
||||||
? parseInt(info.parsedUrl.port)
|
|
||||||
: defaultPort;
|
|
||||||
info.options.path =
|
|
||||||
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
|
||||||
info.options.method = method;
|
|
||||||
info.options.headers = this._mergeHeaders(headers);
|
|
||||||
if (this.userAgent != null) {
|
|
||||||
info.options.headers['user-agent'] = this.userAgent;
|
|
||||||
}
|
|
||||||
info.options.agent = this._getAgent(info.parsedUrl);
|
|
||||||
// gives handlers an opportunity to participate
|
|
||||||
if (this.handlers) {
|
|
||||||
for (const handler of this.handlers) {
|
|
||||||
handler.prepareRequest(info.options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
_mergeHeaders(headers) {
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
|
||||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
|
||||||
}
|
|
||||||
return lowercaseKeys(headers || {});
|
|
||||||
}
|
|
||||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
|
||||||
let clientHeader;
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
|
||||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
|
||||||
}
|
|
||||||
return additionalHeaders[header] || clientHeader || _default;
|
|
||||||
}
|
|
||||||
_getAgent(parsedUrl) {
|
|
||||||
let agent;
|
|
||||||
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
|
||||||
const useProxy = proxyUrl && proxyUrl.hostname;
|
|
||||||
if (this._keepAlive && useProxy) {
|
|
||||||
agent = this._proxyAgent;
|
|
||||||
}
|
|
||||||
if (this._keepAlive && !useProxy) {
|
|
||||||
agent = this._agent;
|
|
||||||
}
|
|
||||||
// if agent is already assigned use that agent.
|
|
||||||
if (agent) {
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
const usingSsl = parsedUrl.protocol === 'https:';
|
|
||||||
let maxSockets = 100;
|
|
||||||
if (this.requestOptions) {
|
|
||||||
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
|
||||||
}
|
|
||||||
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
|
||||||
if (proxyUrl && proxyUrl.hostname) {
|
|
||||||
const agentOptions = {
|
|
||||||
maxSockets,
|
|
||||||
keepAlive: this._keepAlive,
|
|
||||||
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
|
||||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
|
||||||
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
|
||||||
};
|
|
||||||
let tunnelAgent;
|
|
||||||
const overHttps = proxyUrl.protocol === 'https:';
|
|
||||||
if (usingSsl) {
|
|
||||||
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
|
||||||
}
|
|
||||||
agent = tunnelAgent(agentOptions);
|
|
||||||
this._proxyAgent = agent;
|
|
||||||
}
|
|
||||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
|
||||||
if (this._keepAlive && !agent) {
|
|
||||||
const options = { keepAlive: this._keepAlive, maxSockets };
|
|
||||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
|
||||||
this._agent = agent;
|
|
||||||
}
|
|
||||||
// if not using private agent and tunnel agent isn't setup then use global agent
|
|
||||||
if (!agent) {
|
|
||||||
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
|
||||||
}
|
|
||||||
if (usingSsl && this._ignoreSslError) {
|
|
||||||
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
|
||||||
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
|
||||||
// we have to cast it to any and change it directly
|
|
||||||
agent.options = Object.assign(agent.options || {}, {
|
|
||||||
rejectUnauthorized: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return agent;
|
|
||||||
}
|
|
||||||
_performExponentialBackoff(retryNumber) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
|
||||||
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
|
||||||
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_processResponse(res, options) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
||||||
const statusCode = res.message.statusCode || 0;
|
|
||||||
const response = {
|
|
||||||
statusCode,
|
|
||||||
result: null,
|
|
||||||
headers: {}
|
|
||||||
};
|
|
||||||
// not found leads to null obj returned
|
|
||||||
if (statusCode === HttpCodes.NotFound) {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
// get the result from the body
|
|
||||||
function dateTimeDeserializer(key, value) {
|
|
||||||
if (typeof value === 'string') {
|
|
||||||
const a = new Date(value);
|
|
||||||
if (!isNaN(a.valueOf())) {
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
let obj;
|
|
||||||
let contents;
|
|
||||||
try {
|
|
||||||
contents = yield res.readBody();
|
|
||||||
if (contents && contents.length > 0) {
|
|
||||||
if (options && options.deserializeDates) {
|
|
||||||
obj = JSON.parse(contents, dateTimeDeserializer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
obj = JSON.parse(contents);
|
|
||||||
}
|
|
||||||
response.result = obj;
|
|
||||||
}
|
|
||||||
response.headers = res.message.headers;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// Invalid resource (contents not json); leaving result obj null
|
|
||||||
}
|
|
||||||
// note that 3xx redirects are handled by the http layer.
|
|
||||||
if (statusCode > 299) {
|
|
||||||
let msg;
|
|
||||||
// if exception/error in body, attempt to get better error
|
|
||||||
if (obj && obj.message) {
|
|
||||||
msg = obj.message;
|
|
||||||
}
|
|
||||||
else if (contents && contents.length > 0) {
|
|
||||||
// it may be the case that the exception is in the body message as string
|
|
||||||
msg = contents;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
msg = `Failed request: (${statusCode})`;
|
|
||||||
}
|
|
||||||
const err = new HttpClientError(msg, statusCode);
|
|
||||||
err.result = response.result;
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.HttpClient = HttpClient;
|
|
||||||
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 2843:
|
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
||||||
exports.checkBypass = exports.getProxyUrl = void 0;
|
|
||||||
function getProxyUrl(reqUrl) {
|
|
||||||
const usingSsl = reqUrl.protocol === 'https:';
|
|
||||||
if (checkBypass(reqUrl)) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
const proxyVar = (() => {
|
|
||||||
if (usingSsl) {
|
|
||||||
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
if (proxyVar) {
|
|
||||||
return new URL(proxyVar);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.getProxyUrl = getProxyUrl;
|
|
||||||
function checkBypass(reqUrl) {
|
|
||||||
if (!reqUrl.hostname) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
|
||||||
if (!noProxy) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Determine the request port
|
|
||||||
let reqPort;
|
|
||||||
if (reqUrl.port) {
|
|
||||||
reqPort = Number(reqUrl.port);
|
|
||||||
}
|
|
||||||
else if (reqUrl.protocol === 'http:') {
|
|
||||||
reqPort = 80;
|
|
||||||
}
|
|
||||||
else if (reqUrl.protocol === 'https:') {
|
|
||||||
reqPort = 443;
|
|
||||||
}
|
|
||||||
// Format the request hostname and hostname with port
|
|
||||||
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
|
||||||
if (typeof reqPort === 'number') {
|
|
||||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
|
||||||
}
|
|
||||||
// Compare request host against noproxy
|
|
||||||
for (const upperNoProxyItem of noProxy
|
|
||||||
.split(',')
|
|
||||||
.map(x => x.trim().toUpperCase())
|
|
||||||
.filter(x => x)) {
|
|
||||||
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
exports.checkBypass = checkBypass;
|
|
||||||
//# sourceMappingURL=proxy.js.map
|
|
||||||
|
|
||||||
/***/ }),
|
|
||||||
|
|
||||||
/***/ 8974:
|
/***/ 8974:
|
||||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
@ -9186,16 +7650,134 @@ exports.SearchState = SearchState;
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 9925:
|
/***/ 5526:
|
||||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
/***/ (function(__unused_webpack_module, exports) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const http = __nccwpck_require__(3685);
|
exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0;
|
||||||
const https = __nccwpck_require__(5687);
|
class BasicCredentialHandler {
|
||||||
const pm = __nccwpck_require__(6443);
|
constructor(username, password) {
|
||||||
let tunnel;
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
prepareRequest(options) {
|
||||||
|
if (!options.headers) {
|
||||||
|
throw Error('The request has no headers');
|
||||||
|
}
|
||||||
|
options.headers['Authorization'] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString('base64')}`;
|
||||||
|
}
|
||||||
|
// This handler cannot handle 401
|
||||||
|
canHandleAuthentication() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handleAuthentication() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.BasicCredentialHandler = BasicCredentialHandler;
|
||||||
|
class BearerCredentialHandler {
|
||||||
|
constructor(token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
// currently implements pre-authorization
|
||||||
|
// TODO: support preAuth = false where it hooks on 401
|
||||||
|
prepareRequest(options) {
|
||||||
|
if (!options.headers) {
|
||||||
|
throw Error('The request has no headers');
|
||||||
|
}
|
||||||
|
options.headers['Authorization'] = `Bearer ${this.token}`;
|
||||||
|
}
|
||||||
|
// This handler cannot handle 401
|
||||||
|
canHandleAuthentication() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handleAuthentication() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.BearerCredentialHandler = BearerCredentialHandler;
|
||||||
|
class PersonalAccessTokenCredentialHandler {
|
||||||
|
constructor(token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
// currently implements pre-authorization
|
||||||
|
// TODO: support preAuth = false where it hooks on 401
|
||||||
|
prepareRequest(options) {
|
||||||
|
if (!options.headers) {
|
||||||
|
throw Error('The request has no headers');
|
||||||
|
}
|
||||||
|
options.headers['Authorization'] = `Basic ${Buffer.from(`PAT:${this.token}`).toString('base64')}`;
|
||||||
|
}
|
||||||
|
// This handler cannot handle 401
|
||||||
|
canHandleAuthentication() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handleAuthentication() {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
throw new Error('not implemented');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
||||||
|
//# sourceMappingURL=auth.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 6255:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||||
|
}) : (function(o, m, k, k2) {
|
||||||
|
if (k2 === undefined) k2 = k;
|
||||||
|
o[k2] = m[k];
|
||||||
|
}));
|
||||||
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
|
}) : function(o, v) {
|
||||||
|
o["default"] = v;
|
||||||
|
});
|
||||||
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
|
if (mod && mod.__esModule) return mod;
|
||||||
|
var result = {};
|
||||||
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
|
__setModuleDefault(result, mod);
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0;
|
||||||
|
const http = __importStar(__nccwpck_require__(3685));
|
||||||
|
const https = __importStar(__nccwpck_require__(5687));
|
||||||
|
const pm = __importStar(__nccwpck_require__(9835));
|
||||||
|
const tunnel = __importStar(__nccwpck_require__(4294));
|
||||||
var HttpCodes;
|
var HttpCodes;
|
||||||
(function (HttpCodes) {
|
(function (HttpCodes) {
|
||||||
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
||||||
@ -9240,7 +7822,7 @@ var MediaTypes;
|
|||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
*/
|
*/
|
||||||
function getProxyUrl(serverUrl) {
|
function getProxyUrl(serverUrl) {
|
||||||
let proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
const proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
||||||
return proxyUrl ? proxyUrl.href : '';
|
return proxyUrl ? proxyUrl.href : '';
|
||||||
}
|
}
|
||||||
exports.getProxyUrl = getProxyUrl;
|
exports.getProxyUrl = getProxyUrl;
|
||||||
@ -9273,20 +7855,22 @@ class HttpClientResponse {
|
|||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
readBody() {
|
readBody() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let output = Buffer.alloc(0);
|
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
||||||
this.message.on('data', (chunk) => {
|
let output = Buffer.alloc(0);
|
||||||
output = Buffer.concat([output, chunk]);
|
this.message.on('data', (chunk) => {
|
||||||
});
|
output = Buffer.concat([output, chunk]);
|
||||||
this.message.on('end', () => {
|
});
|
||||||
resolve(output.toString());
|
this.message.on('end', () => {
|
||||||
});
|
resolve(output.toString());
|
||||||
|
});
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.HttpClientResponse = HttpClientResponse;
|
exports.HttpClientResponse = HttpClientResponse;
|
||||||
function isHttps(requestUrl) {
|
function isHttps(requestUrl) {
|
||||||
let parsedUrl = new URL(requestUrl);
|
const parsedUrl = new URL(requestUrl);
|
||||||
return parsedUrl.protocol === 'https:';
|
return parsedUrl.protocol === 'https:';
|
||||||
}
|
}
|
||||||
exports.isHttps = isHttps;
|
exports.isHttps = isHttps;
|
||||||
@ -9329,141 +7913,169 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
options(requestUrl, additionalHeaders) {
|
options(requestUrl, additionalHeaders) {
|
||||||
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
get(requestUrl, additionalHeaders) {
|
get(requestUrl, additionalHeaders) {
|
||||||
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
del(requestUrl, additionalHeaders) {
|
del(requestUrl, additionalHeaders) {
|
||||||
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
post(requestUrl, data, additionalHeaders) {
|
post(requestUrl, data, additionalHeaders) {
|
||||||
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
patch(requestUrl, data, additionalHeaders) {
|
patch(requestUrl, data, additionalHeaders) {
|
||||||
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
put(requestUrl, data, additionalHeaders) {
|
put(requestUrl, data, additionalHeaders) {
|
||||||
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
head(requestUrl, additionalHeaders) {
|
head(requestUrl, additionalHeaders) {
|
||||||
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
||||||
return this.request(verb, requestUrl, stream, additionalHeaders);
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return this.request(verb, requestUrl, stream, additionalHeaders);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets a typed object from an endpoint
|
* Gets a typed object from an endpoint
|
||||||
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
||||||
*/
|
*/
|
||||||
async getJson(requestUrl, additionalHeaders = {}) {
|
getJson(requestUrl, additionalHeaders = {}) {
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let res = await this.get(requestUrl, additionalHeaders);
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
return this._processResponse(res, this.requestOptions);
|
const res = yield this.get(requestUrl, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async postJson(requestUrl, obj, additionalHeaders = {}) {
|
postJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
let data = JSON.stringify(obj, null, 2);
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
const data = JSON.stringify(obj, null, 2);
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
let res = await this.post(requestUrl, data, additionalHeaders);
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
return this._processResponse(res, this.requestOptions);
|
const res = yield this.post(requestUrl, data, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async putJson(requestUrl, obj, additionalHeaders = {}) {
|
putJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
let data = JSON.stringify(obj, null, 2);
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
const data = JSON.stringify(obj, null, 2);
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
let res = await this.put(requestUrl, data, additionalHeaders);
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
return this._processResponse(res, this.requestOptions);
|
const res = yield this.put(requestUrl, data, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
async patchJson(requestUrl, obj, additionalHeaders = {}) {
|
patchJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
let data = JSON.stringify(obj, null, 2);
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
const data = JSON.stringify(obj, null, 2);
|
||||||
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
let res = await this.patch(requestUrl, data, additionalHeaders);
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
return this._processResponse(res, this.requestOptions);
|
const res = yield this.patch(requestUrl, data, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Makes a raw http request.
|
* Makes a raw http request.
|
||||||
* All other methods such as get, post, patch, and request ultimately call this.
|
* All other methods such as get, post, patch, and request ultimately call this.
|
||||||
* Prefer get, del, post and patch
|
* Prefer get, del, post and patch
|
||||||
*/
|
*/
|
||||||
async request(verb, requestUrl, data, headers) {
|
request(verb, requestUrl, data, headers) {
|
||||||
if (this._disposed) {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
throw new Error('Client has already been disposed.');
|
if (this._disposed) {
|
||||||
}
|
throw new Error('Client has already been disposed.');
|
||||||
let parsedUrl = new URL(requestUrl);
|
|
||||||
let info = this._prepareRequest(verb, parsedUrl, headers);
|
|
||||||
// Only perform retries on reads since writes may not be idempotent.
|
|
||||||
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
|
|
||||||
? this._maxRetries + 1
|
|
||||||
: 1;
|
|
||||||
let numTries = 0;
|
|
||||||
let response;
|
|
||||||
while (numTries < maxTries) {
|
|
||||||
response = await this.requestRaw(info, data);
|
|
||||||
// Check if it's an authentication challenge
|
|
||||||
if (response &&
|
|
||||||
response.message &&
|
|
||||||
response.message.statusCode === HttpCodes.Unauthorized) {
|
|
||||||
let authenticationHandler;
|
|
||||||
for (let i = 0; i < this.handlers.length; i++) {
|
|
||||||
if (this.handlers[i].canHandleAuthentication(response)) {
|
|
||||||
authenticationHandler = this.handlers[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (authenticationHandler) {
|
|
||||||
return authenticationHandler.handleAuthentication(this, info, data);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// We have received an unauthorized response but have no handlers to handle it.
|
|
||||||
// Let the response return to the caller.
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let redirectsRemaining = this._maxRedirects;
|
const parsedUrl = new URL(requestUrl);
|
||||||
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
|
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||||
this._allowRedirects &&
|
// Only perform retries on reads since writes may not be idempotent.
|
||||||
redirectsRemaining > 0) {
|
const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb)
|
||||||
const redirectUrl = response.message.headers['location'];
|
? this._maxRetries + 1
|
||||||
if (!redirectUrl) {
|
: 1;
|
||||||
// if there's no location to redirect to, we won't
|
let numTries = 0;
|
||||||
break;
|
let response;
|
||||||
}
|
do {
|
||||||
let parsedRedirectUrl = new URL(redirectUrl);
|
response = yield this.requestRaw(info, data);
|
||||||
if (parsedUrl.protocol == 'https:' &&
|
// Check if it's an authentication challenge
|
||||||
parsedUrl.protocol != parsedRedirectUrl.protocol &&
|
if (response &&
|
||||||
!this._allowRedirectDowngrade) {
|
response.message &&
|
||||||
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.');
|
response.message.statusCode === HttpCodes.Unauthorized) {
|
||||||
}
|
let authenticationHandler;
|
||||||
// we need to finish reading the response before reassigning response
|
for (const handler of this.handlers) {
|
||||||
// which will leak the open socket.
|
if (handler.canHandleAuthentication(response)) {
|
||||||
await response.readBody();
|
authenticationHandler = handler;
|
||||||
// strip authorization header if redirected to a different hostname
|
break;
|
||||||
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
|
||||||
for (let header in headers) {
|
|
||||||
// header names are case insensitive
|
|
||||||
if (header.toLowerCase() === 'authorization') {
|
|
||||||
delete headers[header];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (authenticationHandler) {
|
||||||
|
return authenticationHandler.handleAuthentication(this, info, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// We have received an unauthorized response but have no handlers to handle it.
|
||||||
|
// Let the response return to the caller.
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// let's make the request with the new redirectUrl
|
let redirectsRemaining = this._maxRedirects;
|
||||||
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
while (response.message.statusCode &&
|
||||||
response = await this.requestRaw(info, data);
|
HttpRedirectCodes.includes(response.message.statusCode) &&
|
||||||
redirectsRemaining--;
|
this._allowRedirects &&
|
||||||
}
|
redirectsRemaining > 0) {
|
||||||
if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) {
|
const redirectUrl = response.message.headers['location'];
|
||||||
// If not a retry code, return immediately instead of retrying
|
if (!redirectUrl) {
|
||||||
return response;
|
// if there's no location to redirect to, we won't
|
||||||
}
|
break;
|
||||||
numTries += 1;
|
}
|
||||||
if (numTries < maxTries) {
|
const parsedRedirectUrl = new URL(redirectUrl);
|
||||||
await response.readBody();
|
if (parsedUrl.protocol === 'https:' &&
|
||||||
await this._performExponentialBackoff(numTries);
|
parsedUrl.protocol !== parsedRedirectUrl.protocol &&
|
||||||
}
|
!this._allowRedirectDowngrade) {
|
||||||
}
|
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.');
|
||||||
return response;
|
}
|
||||||
|
// we need to finish reading the response before reassigning response
|
||||||
|
// which will leak the open socket.
|
||||||
|
yield response.readBody();
|
||||||
|
// strip authorization header if redirected to a different hostname
|
||||||
|
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
||||||
|
for (const header in headers) {
|
||||||
|
// header names are case insensitive
|
||||||
|
if (header.toLowerCase() === 'authorization') {
|
||||||
|
delete headers[header];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// let's make the request with the new redirectUrl
|
||||||
|
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
||||||
|
response = yield this.requestRaw(info, data);
|
||||||
|
redirectsRemaining--;
|
||||||
|
}
|
||||||
|
if (!response.message.statusCode ||
|
||||||
|
!HttpResponseRetryCodes.includes(response.message.statusCode)) {
|
||||||
|
// If not a retry code, return immediately instead of retrying
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
numTries += 1;
|
||||||
|
if (numTries < maxTries) {
|
||||||
|
yield response.readBody();
|
||||||
|
yield this._performExponentialBackoff(numTries);
|
||||||
|
}
|
||||||
|
} while (numTries < maxTries);
|
||||||
|
return response;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Needs to be called if keepAlive is set to true in request options.
|
* Needs to be called if keepAlive is set to true in request options.
|
||||||
@ -9480,14 +8092,22 @@ class HttpClient {
|
|||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
requestRaw(info, data) {
|
requestRaw(info, data) {
|
||||||
return new Promise((resolve, reject) => {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let callbackForResult = function (err, res) {
|
return new Promise((resolve, reject) => {
|
||||||
if (err) {
|
function callbackForResult(err, res) {
|
||||||
reject(err);
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
else if (!res) {
|
||||||
|
// If `err` is not passed, then `res` must be passed.
|
||||||
|
reject(new Error('Unknown error'));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolve(res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resolve(res);
|
this.requestRawWithCallback(info, data, callbackForResult);
|
||||||
};
|
});
|
||||||
this.requestRawWithCallback(info, data, callbackForResult);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -9497,21 +8117,24 @@ class HttpClient {
|
|||||||
* @param onResult
|
* @param onResult
|
||||||
*/
|
*/
|
||||||
requestRawWithCallback(info, data, onResult) {
|
requestRawWithCallback(info, data, onResult) {
|
||||||
let socket;
|
|
||||||
if (typeof data === 'string') {
|
if (typeof data === 'string') {
|
||||||
|
if (!info.options.headers) {
|
||||||
|
info.options.headers = {};
|
||||||
|
}
|
||||||
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||||||
}
|
}
|
||||||
let callbackCalled = false;
|
let callbackCalled = false;
|
||||||
let handleResult = (err, res) => {
|
function handleResult(err, res) {
|
||||||
if (!callbackCalled) {
|
if (!callbackCalled) {
|
||||||
callbackCalled = true;
|
callbackCalled = true;
|
||||||
onResult(err, res);
|
onResult(err, res);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
let req = info.httpModule.request(info.options, (msg) => {
|
const req = info.httpModule.request(info.options, (msg) => {
|
||||||
let res = new HttpClientResponse(msg);
|
const res = new HttpClientResponse(msg);
|
||||||
handleResult(null, res);
|
handleResult(undefined, res);
|
||||||
});
|
});
|
||||||
|
let socket;
|
||||||
req.on('socket', sock => {
|
req.on('socket', sock => {
|
||||||
socket = sock;
|
socket = sock;
|
||||||
});
|
});
|
||||||
@ -9520,12 +8143,12 @@ class HttpClient {
|
|||||||
if (socket) {
|
if (socket) {
|
||||||
socket.end();
|
socket.end();
|
||||||
}
|
}
|
||||||
handleResult(new Error('Request timeout: ' + info.options.path), null);
|
handleResult(new Error(`Request timeout: ${info.options.path}`));
|
||||||
});
|
});
|
||||||
req.on('error', function (err) {
|
req.on('error', function (err) {
|
||||||
// err has statusCode property
|
// err has statusCode property
|
||||||
// res should have headers
|
// res should have headers
|
||||||
handleResult(err, null);
|
handleResult(err);
|
||||||
});
|
});
|
||||||
if (data && typeof data === 'string') {
|
if (data && typeof data === 'string') {
|
||||||
req.write(data, 'utf8');
|
req.write(data, 'utf8');
|
||||||
@ -9546,7 +8169,7 @@ class HttpClient {
|
|||||||
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
*/
|
*/
|
||||||
getAgent(serverUrl) {
|
getAgent(serverUrl) {
|
||||||
let parsedUrl = new URL(serverUrl);
|
const parsedUrl = new URL(serverUrl);
|
||||||
return this._getAgent(parsedUrl);
|
return this._getAgent(parsedUrl);
|
||||||
}
|
}
|
||||||
_prepareRequest(method, requestUrl, headers) {
|
_prepareRequest(method, requestUrl, headers) {
|
||||||
@ -9570,21 +8193,19 @@ class HttpClient {
|
|||||||
info.options.agent = this._getAgent(info.parsedUrl);
|
info.options.agent = this._getAgent(info.parsedUrl);
|
||||||
// gives handlers an opportunity to participate
|
// gives handlers an opportunity to participate
|
||||||
if (this.handlers) {
|
if (this.handlers) {
|
||||||
this.handlers.forEach(handler => {
|
for (const handler of this.handlers) {
|
||||||
handler.prepareRequest(info.options);
|
handler.prepareRequest(info.options);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
_mergeHeaders(headers) {
|
_mergeHeaders(headers) {
|
||||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {}));
|
||||||
}
|
}
|
||||||
return lowercaseKeys(headers || {});
|
return lowercaseKeys(headers || {});
|
||||||
}
|
}
|
||||||
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
||||||
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
|
||||||
let clientHeader;
|
let clientHeader;
|
||||||
if (this.requestOptions && this.requestOptions.headers) {
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
||||||
@ -9593,8 +8214,8 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
_getAgent(parsedUrl) {
|
_getAgent(parsedUrl) {
|
||||||
let agent;
|
let agent;
|
||||||
let proxyUrl = pm.getProxyUrl(parsedUrl);
|
const proxyUrl = pm.getProxyUrl(parsedUrl);
|
||||||
let useProxy = proxyUrl && proxyUrl.hostname;
|
const useProxy = proxyUrl && proxyUrl.hostname;
|
||||||
if (this._keepAlive && useProxy) {
|
if (this._keepAlive && useProxy) {
|
||||||
agent = this._proxyAgent;
|
agent = this._proxyAgent;
|
||||||
}
|
}
|
||||||
@ -9602,29 +8223,22 @@ class HttpClient {
|
|||||||
agent = this._agent;
|
agent = this._agent;
|
||||||
}
|
}
|
||||||
// if agent is already assigned use that agent.
|
// if agent is already assigned use that agent.
|
||||||
if (!!agent) {
|
if (agent) {
|
||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
const usingSsl = parsedUrl.protocol === 'https:';
|
const usingSsl = parsedUrl.protocol === 'https:';
|
||||||
let maxSockets = 100;
|
let maxSockets = 100;
|
||||||
if (!!this.requestOptions) {
|
if (this.requestOptions) {
|
||||||
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
||||||
}
|
}
|
||||||
if (useProxy) {
|
// This is `useProxy` again, but we need to check `proxyURl` directly for TypeScripts's flow analysis.
|
||||||
// If using proxy, need tunnel
|
if (proxyUrl && proxyUrl.hostname) {
|
||||||
if (!tunnel) {
|
|
||||||
tunnel = __nccwpck_require__(4294);
|
|
||||||
}
|
|
||||||
const agentOptions = {
|
const agentOptions = {
|
||||||
maxSockets: maxSockets,
|
maxSockets,
|
||||||
keepAlive: this._keepAlive,
|
keepAlive: this._keepAlive,
|
||||||
proxy: {
|
proxy: Object.assign(Object.assign({}, ((proxyUrl.username || proxyUrl.password) && {
|
||||||
...((proxyUrl.username || proxyUrl.password) && {
|
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||||
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
})), { host: proxyUrl.hostname, port: proxyUrl.port })
|
||||||
}),
|
|
||||||
host: proxyUrl.hostname,
|
|
||||||
port: proxyUrl.port
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let tunnelAgent;
|
let tunnelAgent;
|
||||||
const overHttps = proxyUrl.protocol === 'https:';
|
const overHttps = proxyUrl.protocol === 'https:';
|
||||||
@ -9639,7 +8253,7 @@ class HttpClient {
|
|||||||
}
|
}
|
||||||
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
||||||
if (this._keepAlive && !agent) {
|
if (this._keepAlive && !agent) {
|
||||||
const options = { keepAlive: this._keepAlive, maxSockets: maxSockets };
|
const options = { keepAlive: this._keepAlive, maxSockets };
|
||||||
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
||||||
this._agent = agent;
|
this._agent = agent;
|
||||||
}
|
}
|
||||||
@ -9658,109 +8272,121 @@ class HttpClient {
|
|||||||
return agent;
|
return agent;
|
||||||
}
|
}
|
||||||
_performExponentialBackoff(retryNumber) {
|
_performExponentialBackoff(retryNumber) {
|
||||||
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
||||||
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
||||||
|
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
static dateTimeDeserializer(key, value) {
|
_processResponse(res, options) {
|
||||||
if (typeof value === 'string') {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let a = new Date(value);
|
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
||||||
if (!isNaN(a.valueOf())) {
|
const statusCode = res.message.statusCode || 0;
|
||||||
return a;
|
const response = {
|
||||||
}
|
statusCode,
|
||||||
}
|
result: null,
|
||||||
return value;
|
headers: {}
|
||||||
}
|
};
|
||||||
async _processResponse(res, options) {
|
// not found leads to null obj returned
|
||||||
return new Promise(async (resolve, reject) => {
|
if (statusCode === HttpCodes.NotFound) {
|
||||||
const statusCode = res.message.statusCode;
|
resolve(response);
|
||||||
const response = {
|
}
|
||||||
statusCode: statusCode,
|
// get the result from the body
|
||||||
result: null,
|
function dateTimeDeserializer(key, value) {
|
||||||
headers: {}
|
if (typeof value === 'string') {
|
||||||
};
|
const a = new Date(value);
|
||||||
// not found leads to null obj returned
|
if (!isNaN(a.valueOf())) {
|
||||||
if (statusCode == HttpCodes.NotFound) {
|
return a;
|
||||||
resolve(response);
|
}
|
||||||
}
|
}
|
||||||
let obj;
|
return value;
|
||||||
let contents;
|
}
|
||||||
// get the result from the body
|
let obj;
|
||||||
try {
|
let contents;
|
||||||
contents = await res.readBody();
|
try {
|
||||||
if (contents && contents.length > 0) {
|
contents = yield res.readBody();
|
||||||
if (options && options.deserializeDates) {
|
if (contents && contents.length > 0) {
|
||||||
obj = JSON.parse(contents, HttpClient.dateTimeDeserializer);
|
if (options && options.deserializeDates) {
|
||||||
|
obj = JSON.parse(contents, dateTimeDeserializer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj = JSON.parse(contents);
|
||||||
|
}
|
||||||
|
response.result = obj;
|
||||||
|
}
|
||||||
|
response.headers = res.message.headers;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
// Invalid resource (contents not json); leaving result obj null
|
||||||
|
}
|
||||||
|
// note that 3xx redirects are handled by the http layer.
|
||||||
|
if (statusCode > 299) {
|
||||||
|
let msg;
|
||||||
|
// if exception/error in body, attempt to get better error
|
||||||
|
if (obj && obj.message) {
|
||||||
|
msg = obj.message;
|
||||||
|
}
|
||||||
|
else if (contents && contents.length > 0) {
|
||||||
|
// it may be the case that the exception is in the body message as string
|
||||||
|
msg = contents;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
obj = JSON.parse(contents);
|
msg = `Failed request: (${statusCode})`;
|
||||||
}
|
}
|
||||||
response.result = obj;
|
const err = new HttpClientError(msg, statusCode);
|
||||||
}
|
err.result = response.result;
|
||||||
response.headers = res.message.headers;
|
reject(err);
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
// Invalid resource (contents not json); leaving result obj null
|
|
||||||
}
|
|
||||||
// note that 3xx redirects are handled by the http layer.
|
|
||||||
if (statusCode > 299) {
|
|
||||||
let msg;
|
|
||||||
// if exception/error in body, attempt to get better error
|
|
||||||
if (obj && obj.message) {
|
|
||||||
msg = obj.message;
|
|
||||||
}
|
|
||||||
else if (contents && contents.length > 0) {
|
|
||||||
// it may be the case that the exception is in the body message as string
|
|
||||||
msg = contents;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg = 'Failed request: (' + statusCode + ')';
|
resolve(response);
|
||||||
}
|
}
|
||||||
let err = new HttpClientError(msg, statusCode);
|
}));
|
||||||
err.result = response.result;
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(response);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.HttpClient = HttpClient;
|
exports.HttpClient = HttpClient;
|
||||||
|
const lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 6443:
|
/***/ 9835:
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.checkBypass = exports.getProxyUrl = void 0;
|
||||||
function getProxyUrl(reqUrl) {
|
function getProxyUrl(reqUrl) {
|
||||||
let usingSsl = reqUrl.protocol === 'https:';
|
const usingSsl = reqUrl.protocol === 'https:';
|
||||||
let proxyUrl;
|
|
||||||
if (checkBypass(reqUrl)) {
|
if (checkBypass(reqUrl)) {
|
||||||
return proxyUrl;
|
return undefined;
|
||||||
}
|
}
|
||||||
let proxyVar;
|
const proxyVar = (() => {
|
||||||
if (usingSsl) {
|
if (usingSsl) {
|
||||||
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
return process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
if (proxyVar) {
|
||||||
|
return new URL(proxyVar);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
return undefined;
|
||||||
}
|
}
|
||||||
if (proxyVar) {
|
|
||||||
proxyUrl = new URL(proxyVar);
|
|
||||||
}
|
|
||||||
return proxyUrl;
|
|
||||||
}
|
}
|
||||||
exports.getProxyUrl = getProxyUrl;
|
exports.getProxyUrl = getProxyUrl;
|
||||||
function checkBypass(reqUrl) {
|
function checkBypass(reqUrl) {
|
||||||
if (!reqUrl.hostname) {
|
if (!reqUrl.hostname) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
const reqHost = reqUrl.hostname;
|
||||||
|
if (isLoopbackAddress(reqHost)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||||||
if (!noProxy) {
|
if (!noProxy) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -9776,23 +8402,34 @@ function checkBypass(reqUrl) {
|
|||||||
reqPort = 443;
|
reqPort = 443;
|
||||||
}
|
}
|
||||||
// Format the request hostname and hostname with port
|
// Format the request hostname and hostname with port
|
||||||
let upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
const upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
||||||
if (typeof reqPort === 'number') {
|
if (typeof reqPort === 'number') {
|
||||||
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||||||
}
|
}
|
||||||
// Compare request host against noproxy
|
// Compare request host against noproxy
|
||||||
for (let upperNoProxyItem of noProxy
|
for (const upperNoProxyItem of noProxy
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(x => x.trim().toUpperCase())
|
.map(x => x.trim().toUpperCase())
|
||||||
.filter(x => x)) {
|
.filter(x => x)) {
|
||||||
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
if (upperNoProxyItem === '*' ||
|
||||||
|
upperReqHosts.some(x => x === upperNoProxyItem ||
|
||||||
|
x.endsWith(`.${upperNoProxyItem}`) ||
|
||||||
|
(upperNoProxyItem.startsWith('.') &&
|
||||||
|
x.endsWith(`${upperNoProxyItem}`)))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
exports.checkBypass = checkBypass;
|
exports.checkBypass = checkBypass;
|
||||||
|
function isLoopbackAddress(host) {
|
||||||
|
const hostLower = host.toLowerCase();
|
||||||
|
return (hostLower === 'localhost' ||
|
||||||
|
hostLower.startsWith('127.') ||
|
||||||
|
hostLower.startsWith('[::1]') ||
|
||||||
|
hostLower.startsWith('[0:0:0:0:0:0:0:1]'));
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=proxy.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
@ -10516,7 +9153,7 @@ const fs = __importStar(__nccwpck_require__(7147));
|
|||||||
const mm = __importStar(__nccwpck_require__(2473));
|
const mm = __importStar(__nccwpck_require__(2473));
|
||||||
const os = __importStar(__nccwpck_require__(2037));
|
const os = __importStar(__nccwpck_require__(2037));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const httpm = __importStar(__nccwpck_require__(9925));
|
const httpm = __importStar(__nccwpck_require__(7371));
|
||||||
const semver = __importStar(__nccwpck_require__(562));
|
const semver = __importStar(__nccwpck_require__(562));
|
||||||
const stream = __importStar(__nccwpck_require__(2781));
|
const stream = __importStar(__nccwpck_require__(2781));
|
||||||
const util = __importStar(__nccwpck_require__(3837));
|
const util = __importStar(__nccwpck_require__(3837));
|
||||||
@ -11058,6 +9695,616 @@ function _getGlobal(key, defaultValue) {
|
|||||||
}
|
}
|
||||||
//# sourceMappingURL=tool-cache.js.map
|
//# sourceMappingURL=tool-cache.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 7371:
|
||||||
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
const http = __nccwpck_require__(3685);
|
||||||
|
const https = __nccwpck_require__(5687);
|
||||||
|
const pm = __nccwpck_require__(3118);
|
||||||
|
let tunnel;
|
||||||
|
var HttpCodes;
|
||||||
|
(function (HttpCodes) {
|
||||||
|
HttpCodes[HttpCodes["OK"] = 200] = "OK";
|
||||||
|
HttpCodes[HttpCodes["MultipleChoices"] = 300] = "MultipleChoices";
|
||||||
|
HttpCodes[HttpCodes["MovedPermanently"] = 301] = "MovedPermanently";
|
||||||
|
HttpCodes[HttpCodes["ResourceMoved"] = 302] = "ResourceMoved";
|
||||||
|
HttpCodes[HttpCodes["SeeOther"] = 303] = "SeeOther";
|
||||||
|
HttpCodes[HttpCodes["NotModified"] = 304] = "NotModified";
|
||||||
|
HttpCodes[HttpCodes["UseProxy"] = 305] = "UseProxy";
|
||||||
|
HttpCodes[HttpCodes["SwitchProxy"] = 306] = "SwitchProxy";
|
||||||
|
HttpCodes[HttpCodes["TemporaryRedirect"] = 307] = "TemporaryRedirect";
|
||||||
|
HttpCodes[HttpCodes["PermanentRedirect"] = 308] = "PermanentRedirect";
|
||||||
|
HttpCodes[HttpCodes["BadRequest"] = 400] = "BadRequest";
|
||||||
|
HttpCodes[HttpCodes["Unauthorized"] = 401] = "Unauthorized";
|
||||||
|
HttpCodes[HttpCodes["PaymentRequired"] = 402] = "PaymentRequired";
|
||||||
|
HttpCodes[HttpCodes["Forbidden"] = 403] = "Forbidden";
|
||||||
|
HttpCodes[HttpCodes["NotFound"] = 404] = "NotFound";
|
||||||
|
HttpCodes[HttpCodes["MethodNotAllowed"] = 405] = "MethodNotAllowed";
|
||||||
|
HttpCodes[HttpCodes["NotAcceptable"] = 406] = "NotAcceptable";
|
||||||
|
HttpCodes[HttpCodes["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
|
||||||
|
HttpCodes[HttpCodes["RequestTimeout"] = 408] = "RequestTimeout";
|
||||||
|
HttpCodes[HttpCodes["Conflict"] = 409] = "Conflict";
|
||||||
|
HttpCodes[HttpCodes["Gone"] = 410] = "Gone";
|
||||||
|
HttpCodes[HttpCodes["TooManyRequests"] = 429] = "TooManyRequests";
|
||||||
|
HttpCodes[HttpCodes["InternalServerError"] = 500] = "InternalServerError";
|
||||||
|
HttpCodes[HttpCodes["NotImplemented"] = 501] = "NotImplemented";
|
||||||
|
HttpCodes[HttpCodes["BadGateway"] = 502] = "BadGateway";
|
||||||
|
HttpCodes[HttpCodes["ServiceUnavailable"] = 503] = "ServiceUnavailable";
|
||||||
|
HttpCodes[HttpCodes["GatewayTimeout"] = 504] = "GatewayTimeout";
|
||||||
|
})(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {}));
|
||||||
|
var Headers;
|
||||||
|
(function (Headers) {
|
||||||
|
Headers["Accept"] = "accept";
|
||||||
|
Headers["ContentType"] = "content-type";
|
||||||
|
})(Headers = exports.Headers || (exports.Headers = {}));
|
||||||
|
var MediaTypes;
|
||||||
|
(function (MediaTypes) {
|
||||||
|
MediaTypes["ApplicationJson"] = "application/json";
|
||||||
|
})(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {}));
|
||||||
|
/**
|
||||||
|
* Returns the proxy URL, depending upon the supplied url and proxy environment variables.
|
||||||
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
|
*/
|
||||||
|
function getProxyUrl(serverUrl) {
|
||||||
|
let proxyUrl = pm.getProxyUrl(new URL(serverUrl));
|
||||||
|
return proxyUrl ? proxyUrl.href : '';
|
||||||
|
}
|
||||||
|
exports.getProxyUrl = getProxyUrl;
|
||||||
|
const HttpRedirectCodes = [
|
||||||
|
HttpCodes.MovedPermanently,
|
||||||
|
HttpCodes.ResourceMoved,
|
||||||
|
HttpCodes.SeeOther,
|
||||||
|
HttpCodes.TemporaryRedirect,
|
||||||
|
HttpCodes.PermanentRedirect
|
||||||
|
];
|
||||||
|
const HttpResponseRetryCodes = [
|
||||||
|
HttpCodes.BadGateway,
|
||||||
|
HttpCodes.ServiceUnavailable,
|
||||||
|
HttpCodes.GatewayTimeout
|
||||||
|
];
|
||||||
|
const RetryableHttpVerbs = ['OPTIONS', 'GET', 'DELETE', 'HEAD'];
|
||||||
|
const ExponentialBackoffCeiling = 10;
|
||||||
|
const ExponentialBackoffTimeSlice = 5;
|
||||||
|
class HttpClientError extends Error {
|
||||||
|
constructor(message, statusCode) {
|
||||||
|
super(message);
|
||||||
|
this.name = 'HttpClientError';
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
Object.setPrototypeOf(this, HttpClientError.prototype);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.HttpClientError = HttpClientError;
|
||||||
|
class HttpClientResponse {
|
||||||
|
constructor(message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
readBody() {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
let output = Buffer.alloc(0);
|
||||||
|
this.message.on('data', (chunk) => {
|
||||||
|
output = Buffer.concat([output, chunk]);
|
||||||
|
});
|
||||||
|
this.message.on('end', () => {
|
||||||
|
resolve(output.toString());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.HttpClientResponse = HttpClientResponse;
|
||||||
|
function isHttps(requestUrl) {
|
||||||
|
let parsedUrl = new URL(requestUrl);
|
||||||
|
return parsedUrl.protocol === 'https:';
|
||||||
|
}
|
||||||
|
exports.isHttps = isHttps;
|
||||||
|
class HttpClient {
|
||||||
|
constructor(userAgent, handlers, requestOptions) {
|
||||||
|
this._ignoreSslError = false;
|
||||||
|
this._allowRedirects = true;
|
||||||
|
this._allowRedirectDowngrade = false;
|
||||||
|
this._maxRedirects = 50;
|
||||||
|
this._allowRetries = false;
|
||||||
|
this._maxRetries = 1;
|
||||||
|
this._keepAlive = false;
|
||||||
|
this._disposed = false;
|
||||||
|
this.userAgent = userAgent;
|
||||||
|
this.handlers = handlers || [];
|
||||||
|
this.requestOptions = requestOptions;
|
||||||
|
if (requestOptions) {
|
||||||
|
if (requestOptions.ignoreSslError != null) {
|
||||||
|
this._ignoreSslError = requestOptions.ignoreSslError;
|
||||||
|
}
|
||||||
|
this._socketTimeout = requestOptions.socketTimeout;
|
||||||
|
if (requestOptions.allowRedirects != null) {
|
||||||
|
this._allowRedirects = requestOptions.allowRedirects;
|
||||||
|
}
|
||||||
|
if (requestOptions.allowRedirectDowngrade != null) {
|
||||||
|
this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade;
|
||||||
|
}
|
||||||
|
if (requestOptions.maxRedirects != null) {
|
||||||
|
this._maxRedirects = Math.max(requestOptions.maxRedirects, 0);
|
||||||
|
}
|
||||||
|
if (requestOptions.keepAlive != null) {
|
||||||
|
this._keepAlive = requestOptions.keepAlive;
|
||||||
|
}
|
||||||
|
if (requestOptions.allowRetries != null) {
|
||||||
|
this._allowRetries = requestOptions.allowRetries;
|
||||||
|
}
|
||||||
|
if (requestOptions.maxRetries != null) {
|
||||||
|
this._maxRetries = requestOptions.maxRetries;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
options(requestUrl, additionalHeaders) {
|
||||||
|
return this.request('OPTIONS', requestUrl, null, additionalHeaders || {});
|
||||||
|
}
|
||||||
|
get(requestUrl, additionalHeaders) {
|
||||||
|
return this.request('GET', requestUrl, null, additionalHeaders || {});
|
||||||
|
}
|
||||||
|
del(requestUrl, additionalHeaders) {
|
||||||
|
return this.request('DELETE', requestUrl, null, additionalHeaders || {});
|
||||||
|
}
|
||||||
|
post(requestUrl, data, additionalHeaders) {
|
||||||
|
return this.request('POST', requestUrl, data, additionalHeaders || {});
|
||||||
|
}
|
||||||
|
patch(requestUrl, data, additionalHeaders) {
|
||||||
|
return this.request('PATCH', requestUrl, data, additionalHeaders || {});
|
||||||
|
}
|
||||||
|
put(requestUrl, data, additionalHeaders) {
|
||||||
|
return this.request('PUT', requestUrl, data, additionalHeaders || {});
|
||||||
|
}
|
||||||
|
head(requestUrl, additionalHeaders) {
|
||||||
|
return this.request('HEAD', requestUrl, null, additionalHeaders || {});
|
||||||
|
}
|
||||||
|
sendStream(verb, requestUrl, stream, additionalHeaders) {
|
||||||
|
return this.request(verb, requestUrl, stream, additionalHeaders);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets a typed object from an endpoint
|
||||||
|
* Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise
|
||||||
|
*/
|
||||||
|
async getJson(requestUrl, additionalHeaders = {}) {
|
||||||
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
|
let res = await this.get(requestUrl, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
}
|
||||||
|
async postJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
|
let data = JSON.stringify(obj, null, 2);
|
||||||
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
|
let res = await this.post(requestUrl, data, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
}
|
||||||
|
async putJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
|
let data = JSON.stringify(obj, null, 2);
|
||||||
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
|
let res = await this.put(requestUrl, data, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
}
|
||||||
|
async patchJson(requestUrl, obj, additionalHeaders = {}) {
|
||||||
|
let data = JSON.stringify(obj, null, 2);
|
||||||
|
additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson);
|
||||||
|
additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson);
|
||||||
|
let res = await this.patch(requestUrl, data, additionalHeaders);
|
||||||
|
return this._processResponse(res, this.requestOptions);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Makes a raw http request.
|
||||||
|
* All other methods such as get, post, patch, and request ultimately call this.
|
||||||
|
* Prefer get, del, post and patch
|
||||||
|
*/
|
||||||
|
async request(verb, requestUrl, data, headers) {
|
||||||
|
if (this._disposed) {
|
||||||
|
throw new Error('Client has already been disposed.');
|
||||||
|
}
|
||||||
|
let parsedUrl = new URL(requestUrl);
|
||||||
|
let info = this._prepareRequest(verb, parsedUrl, headers);
|
||||||
|
// Only perform retries on reads since writes may not be idempotent.
|
||||||
|
let maxTries = this._allowRetries && RetryableHttpVerbs.indexOf(verb) != -1
|
||||||
|
? this._maxRetries + 1
|
||||||
|
: 1;
|
||||||
|
let numTries = 0;
|
||||||
|
let response;
|
||||||
|
while (numTries < maxTries) {
|
||||||
|
response = await this.requestRaw(info, data);
|
||||||
|
// Check if it's an authentication challenge
|
||||||
|
if (response &&
|
||||||
|
response.message &&
|
||||||
|
response.message.statusCode === HttpCodes.Unauthorized) {
|
||||||
|
let authenticationHandler;
|
||||||
|
for (let i = 0; i < this.handlers.length; i++) {
|
||||||
|
if (this.handlers[i].canHandleAuthentication(response)) {
|
||||||
|
authenticationHandler = this.handlers[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (authenticationHandler) {
|
||||||
|
return authenticationHandler.handleAuthentication(this, info, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// We have received an unauthorized response but have no handlers to handle it.
|
||||||
|
// Let the response return to the caller.
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let redirectsRemaining = this._maxRedirects;
|
||||||
|
while (HttpRedirectCodes.indexOf(response.message.statusCode) != -1 &&
|
||||||
|
this._allowRedirects &&
|
||||||
|
redirectsRemaining > 0) {
|
||||||
|
const redirectUrl = response.message.headers['location'];
|
||||||
|
if (!redirectUrl) {
|
||||||
|
// if there's no location to redirect to, we won't
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
let parsedRedirectUrl = new URL(redirectUrl);
|
||||||
|
if (parsedUrl.protocol == 'https:' &&
|
||||||
|
parsedUrl.protocol != parsedRedirectUrl.protocol &&
|
||||||
|
!this._allowRedirectDowngrade) {
|
||||||
|
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.');
|
||||||
|
}
|
||||||
|
// we need to finish reading the response before reassigning response
|
||||||
|
// which will leak the open socket.
|
||||||
|
await response.readBody();
|
||||||
|
// strip authorization header if redirected to a different hostname
|
||||||
|
if (parsedRedirectUrl.hostname !== parsedUrl.hostname) {
|
||||||
|
for (let header in headers) {
|
||||||
|
// header names are case insensitive
|
||||||
|
if (header.toLowerCase() === 'authorization') {
|
||||||
|
delete headers[header];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// let's make the request with the new redirectUrl
|
||||||
|
info = this._prepareRequest(verb, parsedRedirectUrl, headers);
|
||||||
|
response = await this.requestRaw(info, data);
|
||||||
|
redirectsRemaining--;
|
||||||
|
}
|
||||||
|
if (HttpResponseRetryCodes.indexOf(response.message.statusCode) == -1) {
|
||||||
|
// If not a retry code, return immediately instead of retrying
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
numTries += 1;
|
||||||
|
if (numTries < maxTries) {
|
||||||
|
await response.readBody();
|
||||||
|
await this._performExponentialBackoff(numTries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Needs to be called if keepAlive is set to true in request options.
|
||||||
|
*/
|
||||||
|
dispose() {
|
||||||
|
if (this._agent) {
|
||||||
|
this._agent.destroy();
|
||||||
|
}
|
||||||
|
this._disposed = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Raw request.
|
||||||
|
* @param info
|
||||||
|
* @param data
|
||||||
|
*/
|
||||||
|
requestRaw(info, data) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
let callbackForResult = function (err, res) {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
resolve(res);
|
||||||
|
};
|
||||||
|
this.requestRawWithCallback(info, data, callbackForResult);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Raw request with callback.
|
||||||
|
* @param info
|
||||||
|
* @param data
|
||||||
|
* @param onResult
|
||||||
|
*/
|
||||||
|
requestRawWithCallback(info, data, onResult) {
|
||||||
|
let socket;
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
info.options.headers['Content-Length'] = Buffer.byteLength(data, 'utf8');
|
||||||
|
}
|
||||||
|
let callbackCalled = false;
|
||||||
|
let handleResult = (err, res) => {
|
||||||
|
if (!callbackCalled) {
|
||||||
|
callbackCalled = true;
|
||||||
|
onResult(err, res);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let req = info.httpModule.request(info.options, (msg) => {
|
||||||
|
let res = new HttpClientResponse(msg);
|
||||||
|
handleResult(null, res);
|
||||||
|
});
|
||||||
|
req.on('socket', sock => {
|
||||||
|
socket = sock;
|
||||||
|
});
|
||||||
|
// If we ever get disconnected, we want the socket to timeout eventually
|
||||||
|
req.setTimeout(this._socketTimeout || 3 * 60000, () => {
|
||||||
|
if (socket) {
|
||||||
|
socket.end();
|
||||||
|
}
|
||||||
|
handleResult(new Error('Request timeout: ' + info.options.path), null);
|
||||||
|
});
|
||||||
|
req.on('error', function (err) {
|
||||||
|
// err has statusCode property
|
||||||
|
// res should have headers
|
||||||
|
handleResult(err, null);
|
||||||
|
});
|
||||||
|
if (data && typeof data === 'string') {
|
||||||
|
req.write(data, 'utf8');
|
||||||
|
}
|
||||||
|
if (data && typeof data !== 'string') {
|
||||||
|
data.on('close', function () {
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
data.pipe(req);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
req.end();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets an http agent. This function is useful when you need an http agent that handles
|
||||||
|
* routing through a proxy server - depending upon the url and proxy environment variables.
|
||||||
|
* @param serverUrl The server URL where the request will be sent. For example, https://api.github.com
|
||||||
|
*/
|
||||||
|
getAgent(serverUrl) {
|
||||||
|
let parsedUrl = new URL(serverUrl);
|
||||||
|
return this._getAgent(parsedUrl);
|
||||||
|
}
|
||||||
|
_prepareRequest(method, requestUrl, headers) {
|
||||||
|
const info = {};
|
||||||
|
info.parsedUrl = requestUrl;
|
||||||
|
const usingSsl = info.parsedUrl.protocol === 'https:';
|
||||||
|
info.httpModule = usingSsl ? https : http;
|
||||||
|
const defaultPort = usingSsl ? 443 : 80;
|
||||||
|
info.options = {};
|
||||||
|
info.options.host = info.parsedUrl.hostname;
|
||||||
|
info.options.port = info.parsedUrl.port
|
||||||
|
? parseInt(info.parsedUrl.port)
|
||||||
|
: defaultPort;
|
||||||
|
info.options.path =
|
||||||
|
(info.parsedUrl.pathname || '') + (info.parsedUrl.search || '');
|
||||||
|
info.options.method = method;
|
||||||
|
info.options.headers = this._mergeHeaders(headers);
|
||||||
|
if (this.userAgent != null) {
|
||||||
|
info.options.headers['user-agent'] = this.userAgent;
|
||||||
|
}
|
||||||
|
info.options.agent = this._getAgent(info.parsedUrl);
|
||||||
|
// gives handlers an opportunity to participate
|
||||||
|
if (this.handlers) {
|
||||||
|
this.handlers.forEach(handler => {
|
||||||
|
handler.prepareRequest(info.options);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
_mergeHeaders(headers) {
|
||||||
|
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||||
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
|
return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers));
|
||||||
|
}
|
||||||
|
return lowercaseKeys(headers || {});
|
||||||
|
}
|
||||||
|
_getExistingOrDefaultHeader(additionalHeaders, header, _default) {
|
||||||
|
const lowercaseKeys = obj => Object.keys(obj).reduce((c, k) => ((c[k.toLowerCase()] = obj[k]), c), {});
|
||||||
|
let clientHeader;
|
||||||
|
if (this.requestOptions && this.requestOptions.headers) {
|
||||||
|
clientHeader = lowercaseKeys(this.requestOptions.headers)[header];
|
||||||
|
}
|
||||||
|
return additionalHeaders[header] || clientHeader || _default;
|
||||||
|
}
|
||||||
|
_getAgent(parsedUrl) {
|
||||||
|
let agent;
|
||||||
|
let proxyUrl = pm.getProxyUrl(parsedUrl);
|
||||||
|
let useProxy = proxyUrl && proxyUrl.hostname;
|
||||||
|
if (this._keepAlive && useProxy) {
|
||||||
|
agent = this._proxyAgent;
|
||||||
|
}
|
||||||
|
if (this._keepAlive && !useProxy) {
|
||||||
|
agent = this._agent;
|
||||||
|
}
|
||||||
|
// if agent is already assigned use that agent.
|
||||||
|
if (!!agent) {
|
||||||
|
return agent;
|
||||||
|
}
|
||||||
|
const usingSsl = parsedUrl.protocol === 'https:';
|
||||||
|
let maxSockets = 100;
|
||||||
|
if (!!this.requestOptions) {
|
||||||
|
maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets;
|
||||||
|
}
|
||||||
|
if (useProxy) {
|
||||||
|
// If using proxy, need tunnel
|
||||||
|
if (!tunnel) {
|
||||||
|
tunnel = __nccwpck_require__(4294);
|
||||||
|
}
|
||||||
|
const agentOptions = {
|
||||||
|
maxSockets: maxSockets,
|
||||||
|
keepAlive: this._keepAlive,
|
||||||
|
proxy: {
|
||||||
|
...((proxyUrl.username || proxyUrl.password) && {
|
||||||
|
proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`
|
||||||
|
}),
|
||||||
|
host: proxyUrl.hostname,
|
||||||
|
port: proxyUrl.port
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let tunnelAgent;
|
||||||
|
const overHttps = proxyUrl.protocol === 'https:';
|
||||||
|
if (usingSsl) {
|
||||||
|
tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp;
|
||||||
|
}
|
||||||
|
agent = tunnelAgent(agentOptions);
|
||||||
|
this._proxyAgent = agent;
|
||||||
|
}
|
||||||
|
// if reusing agent across request and tunneling agent isn't assigned create a new agent
|
||||||
|
if (this._keepAlive && !agent) {
|
||||||
|
const options = { keepAlive: this._keepAlive, maxSockets: maxSockets };
|
||||||
|
agent = usingSsl ? new https.Agent(options) : new http.Agent(options);
|
||||||
|
this._agent = agent;
|
||||||
|
}
|
||||||
|
// if not using private agent and tunnel agent isn't setup then use global agent
|
||||||
|
if (!agent) {
|
||||||
|
agent = usingSsl ? https.globalAgent : http.globalAgent;
|
||||||
|
}
|
||||||
|
if (usingSsl && this._ignoreSslError) {
|
||||||
|
// we don't want to set NODE_TLS_REJECT_UNAUTHORIZED=0 since that will affect request for entire process
|
||||||
|
// http.RequestOptions doesn't expose a way to modify RequestOptions.agent.options
|
||||||
|
// we have to cast it to any and change it directly
|
||||||
|
agent.options = Object.assign(agent.options || {}, {
|
||||||
|
rejectUnauthorized: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return agent;
|
||||||
|
}
|
||||||
|
_performExponentialBackoff(retryNumber) {
|
||||||
|
retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber);
|
||||||
|
const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber);
|
||||||
|
return new Promise(resolve => setTimeout(() => resolve(), ms));
|
||||||
|
}
|
||||||
|
static dateTimeDeserializer(key, value) {
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
let a = new Date(value);
|
||||||
|
if (!isNaN(a.valueOf())) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
async _processResponse(res, options) {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
|
const statusCode = res.message.statusCode;
|
||||||
|
const response = {
|
||||||
|
statusCode: statusCode,
|
||||||
|
result: null,
|
||||||
|
headers: {}
|
||||||
|
};
|
||||||
|
// not found leads to null obj returned
|
||||||
|
if (statusCode == HttpCodes.NotFound) {
|
||||||
|
resolve(response);
|
||||||
|
}
|
||||||
|
let obj;
|
||||||
|
let contents;
|
||||||
|
// get the result from the body
|
||||||
|
try {
|
||||||
|
contents = await res.readBody();
|
||||||
|
if (contents && contents.length > 0) {
|
||||||
|
if (options && options.deserializeDates) {
|
||||||
|
obj = JSON.parse(contents, HttpClient.dateTimeDeserializer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
obj = JSON.parse(contents);
|
||||||
|
}
|
||||||
|
response.result = obj;
|
||||||
|
}
|
||||||
|
response.headers = res.message.headers;
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
// Invalid resource (contents not json); leaving result obj null
|
||||||
|
}
|
||||||
|
// note that 3xx redirects are handled by the http layer.
|
||||||
|
if (statusCode > 299) {
|
||||||
|
let msg;
|
||||||
|
// if exception/error in body, attempt to get better error
|
||||||
|
if (obj && obj.message) {
|
||||||
|
msg = obj.message;
|
||||||
|
}
|
||||||
|
else if (contents && contents.length > 0) {
|
||||||
|
// it may be the case that the exception is in the body message as string
|
||||||
|
msg = contents;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg = 'Failed request: (' + statusCode + ')';
|
||||||
|
}
|
||||||
|
let err = new HttpClientError(msg, statusCode);
|
||||||
|
err.result = response.result;
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resolve(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.HttpClient = HttpClient;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 3118:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
function getProxyUrl(reqUrl) {
|
||||||
|
let usingSsl = reqUrl.protocol === 'https:';
|
||||||
|
let proxyUrl;
|
||||||
|
if (checkBypass(reqUrl)) {
|
||||||
|
return proxyUrl;
|
||||||
|
}
|
||||||
|
let proxyVar;
|
||||||
|
if (usingSsl) {
|
||||||
|
proxyVar = process.env['https_proxy'] || process.env['HTTPS_PROXY'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
proxyVar = process.env['http_proxy'] || process.env['HTTP_PROXY'];
|
||||||
|
}
|
||||||
|
if (proxyVar) {
|
||||||
|
proxyUrl = new URL(proxyVar);
|
||||||
|
}
|
||||||
|
return proxyUrl;
|
||||||
|
}
|
||||||
|
exports.getProxyUrl = getProxyUrl;
|
||||||
|
function checkBypass(reqUrl) {
|
||||||
|
if (!reqUrl.hostname) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let noProxy = process.env['no_proxy'] || process.env['NO_PROXY'] || '';
|
||||||
|
if (!noProxy) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Determine the request port
|
||||||
|
let reqPort;
|
||||||
|
if (reqUrl.port) {
|
||||||
|
reqPort = Number(reqUrl.port);
|
||||||
|
}
|
||||||
|
else if (reqUrl.protocol === 'http:') {
|
||||||
|
reqPort = 80;
|
||||||
|
}
|
||||||
|
else if (reqUrl.protocol === 'https:') {
|
||||||
|
reqPort = 443;
|
||||||
|
}
|
||||||
|
// Format the request hostname and hostname with port
|
||||||
|
let upperReqHosts = [reqUrl.hostname.toUpperCase()];
|
||||||
|
if (typeof reqPort === 'number') {
|
||||||
|
upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`);
|
||||||
|
}
|
||||||
|
// Compare request host against noproxy
|
||||||
|
for (let upperNoProxyItem of noProxy
|
||||||
|
.split(',')
|
||||||
|
.map(x => x.trim().toUpperCase())
|
||||||
|
.filter(x => x)) {
|
||||||
|
if (upperReqHosts.some(x => x === upperNoProxyItem)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
exports.checkBypass = checkBypass;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 562:
|
/***/ 562:
|
||||||
@ -67174,7 +66421,7 @@ const path = __importStar(__nccwpck_require__(1017));
|
|||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const tc = __importStar(__nccwpck_require__(7784));
|
const tc = __importStar(__nccwpck_require__(7784));
|
||||||
const semver = __importStar(__nccwpck_require__(1383));
|
const semver = __importStar(__nccwpck_require__(1383));
|
||||||
const httpm = __importStar(__nccwpck_require__(9925));
|
const httpm = __importStar(__nccwpck_require__(6255));
|
||||||
const exec = __importStar(__nccwpck_require__(1514));
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
const fs_1 = __importDefault(__nccwpck_require__(7147));
|
||||||
const utils_1 = __nccwpck_require__(1314);
|
const utils_1 = __nccwpck_require__(1314);
|
||||||
|
|||||||
226
package-lock.json
generated
226
package-lock.json
generated
@ -18,6 +18,7 @@
|
|||||||
"semver": "^7.1.3"
|
"semver": "^7.1.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@actions/http-client": "^2.1.0",
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^16.11.25",
|
"@types/node": "^16.11.25",
|
||||||
"@types/semver": "^7.1.0",
|
"@types/semver": "^7.1.0",
|
||||||
@ -27,6 +28,7 @@
|
|||||||
"eslint": "^8.35.0",
|
"eslint": "^8.35.0",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
"eslint-plugin-jest": "^27.2.1",
|
"eslint-plugin-jest": "^27.2.1",
|
||||||
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"husky": "^7.0.2",
|
"husky": "^7.0.2",
|
||||||
"jest": "^27.2.5",
|
"jest": "^27.2.5",
|
||||||
"jest-circus": "^27.2.5",
|
"jest-circus": "^27.2.5",
|
||||||
@ -61,14 +63,6 @@
|
|||||||
"minimatch": "^3.0.4"
|
"minimatch": "^3.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/cache/node_modules/@actions/http-client": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
|
||||||
"dependencies": {
|
|
||||||
"tunnel": "^0.0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@actions/cache/node_modules/semver": {
|
"node_modules/@actions/cache/node_modules/semver": {
|
||||||
"version": "6.3.0",
|
"version": "6.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
@ -86,14 +80,6 @@
|
|||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/core/node_modules/@actions/http-client": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
|
||||||
"dependencies": {
|
|
||||||
"tunnel": "^0.0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/@actions/core/node_modules/uuid": {
|
"node_modules/@actions/core/node_modules/uuid": {
|
||||||
"version": "8.3.2",
|
"version": "8.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
@ -120,11 +106,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/http-client": {
|
"node_modules/@actions/http-client": {
|
||||||
"version": "1.0.11",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
|
||||||
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
"integrity": "sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tunnel": "0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@actions/io": {
|
"node_modules/@actions/io": {
|
||||||
@ -145,6 +131,14 @@
|
|||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@actions/tool-cache/node_modules/@actions/http-client": {
|
||||||
|
"version": "1.0.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||||
|
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||||
|
"dependencies": {
|
||||||
|
"tunnel": "0.0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@actions/tool-cache/node_modules/semver": {
|
"node_modules/@actions/tool-cache/node_modules/semver": {
|
||||||
"version": "6.3.0",
|
"version": "6.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
@ -3511,6 +3505,49 @@
|
|||||||
"eslint": ">=7.0.0"
|
"eslint": ">=7.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/eslint-plugin-es": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-utils": "^2.0.0",
|
||||||
|
"regexpp": "^3.0.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.10.0"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/mysticatea"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": ">=4.19.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-es/node_modules/eslint-utils": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-visitor-keys": "^1.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/mysticatea"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-es/node_modules/eslint-visitor-keys": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eslint-plugin-jest": {
|
"node_modules/eslint-plugin-jest": {
|
||||||
"version": "27.2.1",
|
"version": "27.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.2.1.tgz",
|
||||||
@ -3535,6 +3572,59 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/eslint-plugin-node": {
|
||||||
|
"version": "11.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz",
|
||||||
|
"integrity": "sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-plugin-es": "^3.0.0",
|
||||||
|
"eslint-utils": "^2.0.0",
|
||||||
|
"ignore": "^5.1.1",
|
||||||
|
"minimatch": "^3.0.4",
|
||||||
|
"resolve": "^1.10.1",
|
||||||
|
"semver": "^6.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.10.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"eslint": ">=5.16.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-node/node_modules/eslint-utils": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
|
||||||
|
"dev": true,
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-visitor-keys": "^1.1.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/mysticatea"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-node/node_modules/eslint-visitor-keys": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/eslint-plugin-node/node_modules/semver": {
|
||||||
|
"version": "6.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
|
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||||
|
"dev": true,
|
||||||
|
"bin": {
|
||||||
|
"semver": "bin/semver.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/eslint-scope": {
|
"node_modules/eslint-scope": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
||||||
@ -6821,14 +6911,6 @@
|
|||||||
"minimatch": "^3.0.4"
|
"minimatch": "^3.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/http-client": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
|
||||||
"requires": {
|
|
||||||
"tunnel": "^0.0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "6.3.0",
|
"version": "6.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
@ -6845,14 +6927,6 @@
|
|||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/http-client": {
|
|
||||||
"version": "2.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
|
||||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
|
||||||
"requires": {
|
|
||||||
"tunnel": "^0.0.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"uuid": {
|
"uuid": {
|
||||||
"version": "8.3.2",
|
"version": "8.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||||
@ -6878,11 +6952,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/http-client": {
|
"@actions/http-client": {
|
||||||
"version": "1.0.11",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.0.tgz",
|
||||||
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
"integrity": "sha512-BonhODnXr3amchh4qkmjPMUO8mFi/zLaaCeCAJZqch8iQqyDnVIkySjB38VHAC8IJ+bnlgfOqlhpyCUZHlQsqw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"tunnel": "0.0.6"
|
"tunnel": "^0.0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/io": {
|
"@actions/io": {
|
||||||
@ -6903,6 +6977,14 @@
|
|||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@actions/http-client": {
|
||||||
|
"version": "1.0.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
|
||||||
|
"integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
|
||||||
|
"requires": {
|
||||||
|
"tunnel": "0.0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "6.3.0",
|
"version": "6.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
@ -9664,6 +9746,33 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {}
|
"requires": {}
|
||||||
},
|
},
|
||||||
|
"eslint-plugin-es": {
|
||||||
|
"version": "3.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-es/-/eslint-plugin-es-3.0.1.tgz",
|
||||||
|
"integrity": "sha512-GUmAsJaN4Fc7Gbtl8uOBlayo2DqhwWvEzykMHSCZHU3XdJ+NSzzZcVhXh3VxX5icqQ+oQdIEawXX8xkR3mIFmQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"eslint-utils": "^2.0.0",
|
||||||
|
"regexpp": "^3.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-utils": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"eslint-visitor-keys": "^1.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eslint-visitor-keys": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"eslint-plugin-jest": {
|
"eslint-plugin-jest": {
|
||||||
"version": "27.2.1",
|
"version": "27.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.2.1.tgz",
|
||||||
@ -9673,6 +9782,43 @@
|
|||||||
"@typescript-eslint/utils": "^5.10.0"
|
"@typescript-eslint/utils": "^5.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"eslint-plugin-node": {
|
||||||
|
"version": "11.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz",
|
||||||
|
"integrity": "sha512-oUwtPJ1W0SKD0Tr+wqu92c5xuCeQqB3hSCHasn/ZgjFdA9iDGNkNf2Zi9ztY7X+hNuMib23LNGRm6+uN+KLE3g==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"eslint-plugin-es": "^3.0.0",
|
||||||
|
"eslint-utils": "^2.0.0",
|
||||||
|
"ignore": "^5.1.1",
|
||||||
|
"minimatch": "^3.0.4",
|
||||||
|
"resolve": "^1.10.1",
|
||||||
|
"semver": "^6.1.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"eslint-utils": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"eslint-visitor-keys": "^1.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"eslint-visitor-keys": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"semver": {
|
||||||
|
"version": "6.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||||
|
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||||
|
"dev": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"eslint-scope": {
|
"eslint-scope": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
||||||
|
|||||||
@ -34,6 +34,7 @@
|
|||||||
"semver": "^7.1.3"
|
"semver": "^7.1.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@actions/http-client": "^2.1.0",
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/node": "^16.11.25",
|
"@types/node": "^16.11.25",
|
||||||
"@types/semver": "^7.1.0",
|
"@types/semver": "^7.1.0",
|
||||||
@ -43,6 +44,7 @@
|
|||||||
"eslint": "^8.35.0",
|
"eslint": "^8.35.0",
|
||||||
"eslint-config-prettier": "^8.6.0",
|
"eslint-config-prettier": "^8.6.0",
|
||||||
"eslint-plugin-jest": "^27.2.1",
|
"eslint-plugin-jest": "^27.2.1",
|
||||||
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"husky": "^7.0.2",
|
"husky": "^7.0.2",
|
||||||
"jest": "^27.2.5",
|
"jest": "^27.2.5",
|
||||||
"jest-circus": "^27.2.5",
|
"jest-circus": "^27.2.5",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user