mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-25 12:47:06 +00:00
Running npm ci && npm run build
This commit is contained in:
parent
7f8cd06e6a
commit
24b27009d6
1 changed files with 113 additions and 75 deletions
188
dist/index.js
vendored
188
dist/index.js
vendored
|
|
@ -16672,6 +16672,29 @@ var Writable = (__nccwpck_require__(2781).Writable);
|
||||||
var assert = __nccwpck_require__(9491);
|
var assert = __nccwpck_require__(9491);
|
||||||
var debug = __nccwpck_require__(1133);
|
var debug = __nccwpck_require__(1133);
|
||||||
|
|
||||||
|
// Whether to use the native URL object or the legacy url module
|
||||||
|
var useNativeURL = false;
|
||||||
|
try {
|
||||||
|
assert(new URL());
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
useNativeURL = error.code === "ERR_INVALID_URL";
|
||||||
|
}
|
||||||
|
|
||||||
|
// URL fields to preserve in copy operations
|
||||||
|
var preservedUrlFields = [
|
||||||
|
"auth",
|
||||||
|
"host",
|
||||||
|
"hostname",
|
||||||
|
"href",
|
||||||
|
"path",
|
||||||
|
"pathname",
|
||||||
|
"port",
|
||||||
|
"protocol",
|
||||||
|
"query",
|
||||||
|
"search",
|
||||||
|
];
|
||||||
|
|
||||||
// Create handlers that pass events from native requests
|
// Create handlers that pass events from native requests
|
||||||
var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
|
var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
|
||||||
var eventHandlers = Object.create(null);
|
var eventHandlers = Object.create(null);
|
||||||
|
|
@ -16681,19 +16704,20 @@ events.forEach(function (event) {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Error types with codes
|
||||||
var InvalidUrlError = createErrorType(
|
var InvalidUrlError = createErrorType(
|
||||||
"ERR_INVALID_URL",
|
"ERR_INVALID_URL",
|
||||||
"Invalid URL",
|
"Invalid URL",
|
||||||
TypeError
|
TypeError
|
||||||
);
|
);
|
||||||
// Error types with codes
|
|
||||||
var RedirectionError = createErrorType(
|
var RedirectionError = createErrorType(
|
||||||
"ERR_FR_REDIRECTION_FAILURE",
|
"ERR_FR_REDIRECTION_FAILURE",
|
||||||
"Redirected request failed"
|
"Redirected request failed"
|
||||||
);
|
);
|
||||||
var TooManyRedirectsError = createErrorType(
|
var TooManyRedirectsError = createErrorType(
|
||||||
"ERR_FR_TOO_MANY_REDIRECTS",
|
"ERR_FR_TOO_MANY_REDIRECTS",
|
||||||
"Maximum number of redirects exceeded"
|
"Maximum number of redirects exceeded",
|
||||||
|
RedirectionError
|
||||||
);
|
);
|
||||||
var MaxBodyLengthExceededError = createErrorType(
|
var MaxBodyLengthExceededError = createErrorType(
|
||||||
"ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
|
"ERR_FR_MAX_BODY_LENGTH_EXCEEDED",
|
||||||
|
|
@ -16728,7 +16752,13 @@ function RedirectableRequest(options, responseCallback) {
|
||||||
// React to responses of native requests
|
// React to responses of native requests
|
||||||
var self = this;
|
var self = this;
|
||||||
this._onNativeResponse = function (response) {
|
this._onNativeResponse = function (response) {
|
||||||
self._processResponse(response);
|
try {
|
||||||
|
self._processResponse(response);
|
||||||
|
}
|
||||||
|
catch (cause) {
|
||||||
|
self.emit("error", cause instanceof RedirectionError ?
|
||||||
|
cause : new RedirectionError({ cause: cause }));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Perform the first request
|
// Perform the first request
|
||||||
|
|
@ -16946,8 +16976,7 @@ RedirectableRequest.prototype._performRequest = function () {
|
||||||
var protocol = this._options.protocol;
|
var protocol = this._options.protocol;
|
||||||
var nativeProtocol = this._options.nativeProtocols[protocol];
|
var nativeProtocol = this._options.nativeProtocols[protocol];
|
||||||
if (!nativeProtocol) {
|
if (!nativeProtocol) {
|
||||||
this.emit("error", new TypeError("Unsupported protocol " + protocol));
|
throw new TypeError("Unsupported protocol " + protocol);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If specified, use the agent corresponding to the protocol
|
// If specified, use the agent corresponding to the protocol
|
||||||
|
|
@ -17046,8 +17075,7 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
||||||
// RFC7231§6.4: A client SHOULD detect and intervene
|
// RFC7231§6.4: A client SHOULD detect and intervene
|
||||||
// in cyclical redirections (i.e., "infinite" redirection loops).
|
// in cyclical redirections (i.e., "infinite" redirection loops).
|
||||||
if (++this._redirectCount > this._options.maxRedirects) {
|
if (++this._redirectCount > this._options.maxRedirects) {
|
||||||
this.emit("error", new TooManyRedirectsError());
|
throw new TooManyRedirectsError();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the request headers if applicable
|
// Store the request headers if applicable
|
||||||
|
|
@ -17081,33 +17109,23 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
||||||
var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
|
var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
|
||||||
|
|
||||||
// If the redirect is relative, carry over the host of the last request
|
// If the redirect is relative, carry over the host of the last request
|
||||||
var currentUrlParts = url.parse(this._currentUrl);
|
var currentUrlParts = parseUrl(this._currentUrl);
|
||||||
var currentHost = currentHostHeader || currentUrlParts.host;
|
var currentHost = currentHostHeader || currentUrlParts.host;
|
||||||
var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
|
var currentUrl = /^\w+:/.test(location) ? this._currentUrl :
|
||||||
url.format(Object.assign(currentUrlParts, { host: currentHost }));
|
url.format(Object.assign(currentUrlParts, { host: currentHost }));
|
||||||
|
|
||||||
// Determine the URL of the redirection
|
|
||||||
var redirectUrl;
|
|
||||||
try {
|
|
||||||
redirectUrl = url.resolve(currentUrl, location);
|
|
||||||
}
|
|
||||||
catch (cause) {
|
|
||||||
this.emit("error", new RedirectionError({ cause: cause }));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the redirected request
|
// Create the redirected request
|
||||||
debug("redirecting to", redirectUrl);
|
var redirectUrl = resolveUrl(location, currentUrl);
|
||||||
|
debug("redirecting to", redirectUrl.href);
|
||||||
this._isRedirect = true;
|
this._isRedirect = true;
|
||||||
var redirectUrlParts = url.parse(redirectUrl);
|
spreadUrlObject(redirectUrl, this._options);
|
||||||
Object.assign(this._options, redirectUrlParts);
|
|
||||||
|
|
||||||
// Drop confidential headers when redirecting to a less secure protocol
|
// Drop confidential headers when redirecting to a less secure protocol
|
||||||
// or to a different domain that is not a superdomain
|
// or to a different domain that is not a superdomain
|
||||||
if (redirectUrlParts.protocol !== currentUrlParts.protocol &&
|
if (redirectUrl.protocol !== currentUrlParts.protocol &&
|
||||||
redirectUrlParts.protocol !== "https:" ||
|
redirectUrl.protocol !== "https:" ||
|
||||||
redirectUrlParts.host !== currentHost &&
|
redirectUrl.host !== currentHost &&
|
||||||
!isSubdomain(redirectUrlParts.host, currentHost)) {
|
!isSubdomain(redirectUrl.host, currentHost)) {
|
||||||
removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
|
removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -17122,23 +17140,12 @@ RedirectableRequest.prototype._processResponse = function (response) {
|
||||||
method: method,
|
method: method,
|
||||||
headers: requestHeaders,
|
headers: requestHeaders,
|
||||||
};
|
};
|
||||||
try {
|
beforeRedirect(this._options, responseDetails, requestDetails);
|
||||||
beforeRedirect(this._options, responseDetails, requestDetails);
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
this.emit("error", err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this._sanitizeOptions(this._options);
|
this._sanitizeOptions(this._options);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform the redirected request
|
// Perform the redirected request
|
||||||
try {
|
this._performRequest();
|
||||||
this._performRequest();
|
|
||||||
}
|
|
||||||
catch (cause) {
|
|
||||||
this.emit("error", new RedirectionError({ cause: cause }));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wraps the key/value object of protocols with redirect functionality
|
// Wraps the key/value object of protocols with redirect functionality
|
||||||
|
|
@ -17158,27 +17165,16 @@ function wrap(protocols) {
|
||||||
|
|
||||||
// Executes a request, following redirects
|
// Executes a request, following redirects
|
||||||
function request(input, options, callback) {
|
function request(input, options, callback) {
|
||||||
// Parse parameters
|
// Parse parameters, ensuring that input is an object
|
||||||
if (isString(input)) {
|
if (isURL(input)) {
|
||||||
var parsed;
|
input = spreadUrlObject(input);
|
||||||
try {
|
|
||||||
parsed = urlToOptions(new URL(input));
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
/* istanbul ignore next */
|
|
||||||
parsed = url.parse(input);
|
|
||||||
}
|
|
||||||
if (!isString(parsed.protocol)) {
|
|
||||||
throw new InvalidUrlError({ input });
|
|
||||||
}
|
|
||||||
input = parsed;
|
|
||||||
}
|
}
|
||||||
else if (URL && (input instanceof URL)) {
|
else if (isString(input)) {
|
||||||
input = urlToOptions(input);
|
input = spreadUrlObject(parseUrl(input));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
callback = options;
|
callback = options;
|
||||||
options = input;
|
options = validateUrl(input);
|
||||||
input = { protocol: protocol };
|
input = { protocol: protocol };
|
||||||
}
|
}
|
||||||
if (isFunction(options)) {
|
if (isFunction(options)) {
|
||||||
|
|
@ -17217,27 +17213,57 @@ function wrap(protocols) {
|
||||||
return exports;
|
return exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore next */
|
|
||||||
function noop() { /* empty */ }
|
function noop() { /* empty */ }
|
||||||
|
|
||||||
// from https://github.com/nodejs/node/blob/master/lib/internal/url.js
|
function parseUrl(input) {
|
||||||
function urlToOptions(urlObject) {
|
var parsed;
|
||||||
var options = {
|
/* istanbul ignore else */
|
||||||
protocol: urlObject.protocol,
|
if (useNativeURL) {
|
||||||
hostname: urlObject.hostname.startsWith("[") ?
|
parsed = new URL(input);
|
||||||
/* istanbul ignore next */
|
|
||||||
urlObject.hostname.slice(1, -1) :
|
|
||||||
urlObject.hostname,
|
|
||||||
hash: urlObject.hash,
|
|
||||||
search: urlObject.search,
|
|
||||||
pathname: urlObject.pathname,
|
|
||||||
path: urlObject.pathname + urlObject.search,
|
|
||||||
href: urlObject.href,
|
|
||||||
};
|
|
||||||
if (urlObject.port !== "") {
|
|
||||||
options.port = Number(urlObject.port);
|
|
||||||
}
|
}
|
||||||
return options;
|
else {
|
||||||
|
// Ensure the URL is valid and absolute
|
||||||
|
parsed = validateUrl(url.parse(input));
|
||||||
|
if (!isString(parsed.protocol)) {
|
||||||
|
throw new InvalidUrlError({ input });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveUrl(relative, base) {
|
||||||
|
/* istanbul ignore next */
|
||||||
|
return useNativeURL ? new URL(relative, base) : parseUrl(url.resolve(base, relative));
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateUrl(input) {
|
||||||
|
if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
|
||||||
|
throw new InvalidUrlError({ input: input.href || input });
|
||||||
|
}
|
||||||
|
if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
|
||||||
|
throw new InvalidUrlError({ input: input.href || input });
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
function spreadUrlObject(urlObject, target) {
|
||||||
|
var spread = target || {};
|
||||||
|
for (var key of preservedUrlFields) {
|
||||||
|
spread[key] = urlObject[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix IPv6 hostname
|
||||||
|
if (spread.hostname.startsWith("[")) {
|
||||||
|
spread.hostname = spread.hostname.slice(1, -1);
|
||||||
|
}
|
||||||
|
// Ensure port is a number
|
||||||
|
if (spread.port !== "") {
|
||||||
|
spread.port = Number(spread.port);
|
||||||
|
}
|
||||||
|
// Concatenate path
|
||||||
|
spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
|
||||||
|
|
||||||
|
return spread;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeMatchingHeaders(regex, headers) {
|
function removeMatchingHeaders(regex, headers) {
|
||||||
|
|
@ -17263,8 +17289,16 @@ function createErrorType(code, message, baseClass) {
|
||||||
|
|
||||||
// Attach constructor and set default properties
|
// Attach constructor and set default properties
|
||||||
CustomError.prototype = new (baseClass || Error)();
|
CustomError.prototype = new (baseClass || Error)();
|
||||||
CustomError.prototype.constructor = CustomError;
|
Object.defineProperties(CustomError.prototype, {
|
||||||
CustomError.prototype.name = "Error [" + code + "]";
|
constructor: {
|
||||||
|
value: CustomError,
|
||||||
|
enumerable: false,
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
value: "Error [" + code + "]",
|
||||||
|
enumerable: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
return CustomError;
|
return CustomError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -17294,6 +17328,10 @@ function isBuffer(value) {
|
||||||
return typeof value === "object" && ("length" in value);
|
return typeof value === "object" && ("length" in value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isURL(value) {
|
||||||
|
return URL && value instanceof URL;
|
||||||
|
}
|
||||||
|
|
||||||
// Exports
|
// Exports
|
||||||
module.exports = wrap({ http: http, https: https });
|
module.exports = wrap({ http: http, https: https });
|
||||||
module.exports.wrap = wrap;
|
module.exports.wrap = wrap;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue