piral-cli 1.5.0-beta.6446 → 1.5.0-beta.6454

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60548,6 +60548,24 @@ var require_follow_redirects = __commonJS({
60548
60548
  var Writable = require("stream").Writable;
60549
60549
  var assert = require("assert");
60550
60550
  var debug = require_debug2();
60551
+ var useNativeURL = false;
60552
+ try {
60553
+ assert(new URL2());
60554
+ } catch (error) {
60555
+ useNativeURL = error.code === "ERR_INVALID_URL";
60556
+ }
60557
+ var preservedUrlFields = [
60558
+ "auth",
60559
+ "host",
60560
+ "hostname",
60561
+ "href",
60562
+ "path",
60563
+ "pathname",
60564
+ "port",
60565
+ "protocol",
60566
+ "query",
60567
+ "search"
60568
+ ];
60551
60569
  var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
60552
60570
  var eventHandlers = Object.create(null);
60553
60571
  events.forEach(function(event) {
@@ -60557,7 +60575,7 @@ var require_follow_redirects = __commonJS({
60557
60575
  });
60558
60576
  var InvalidUrlError = createErrorType("ERR_INVALID_URL", "Invalid URL", TypeError);
60559
60577
  var RedirectionError = createErrorType("ERR_FR_REDIRECTION_FAILURE", "Redirected request failed");
60560
- var TooManyRedirectsError = createErrorType("ERR_FR_TOO_MANY_REDIRECTS", "Maximum number of redirects exceeded");
60578
+ var TooManyRedirectsError = createErrorType("ERR_FR_TOO_MANY_REDIRECTS", "Maximum number of redirects exceeded", RedirectionError);
60561
60579
  var MaxBodyLengthExceededError = createErrorType("ERR_FR_MAX_BODY_LENGTH_EXCEEDED", "Request body larger than maxBodyLength limit");
60562
60580
  var WriteAfterEndError = createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end");
60563
60581
  var destroy = Writable.prototype.destroy || noop;
@@ -60576,7 +60594,11 @@ var require_follow_redirects = __commonJS({
60576
60594
  }
60577
60595
  var self2 = this;
60578
60596
  this._onNativeResponse = function(response) {
60579
- self2._processResponse(response);
60597
+ try {
60598
+ self2._processResponse(response);
60599
+ } catch (cause) {
60600
+ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause }));
60601
+ }
60580
60602
  };
60581
60603
  this._performRequest();
60582
60604
  }
@@ -60735,8 +60757,7 @@ var require_follow_redirects = __commonJS({
60735
60757
  var protocol = this._options.protocol;
60736
60758
  var nativeProtocol = this._options.nativeProtocols[protocol];
60737
60759
  if (!nativeProtocol) {
60738
- this.emit("error", new TypeError("Unsupported protocol " + protocol));
60739
- return;
60760
+ throw new TypeError("Unsupported protocol " + protocol);
60740
60761
  }
60741
60762
  if (this._options.agents) {
60742
60763
  var scheme = protocol.slice(0, -1);
@@ -60788,8 +60809,7 @@ var require_follow_redirects = __commonJS({
60788
60809
  destroyRequest(this._currentRequest);
60789
60810
  response.destroy();
60790
60811
  if (++this._redirectCount > this._options.maxRedirects) {
60791
- this.emit("error", new TooManyRedirectsError());
60792
- return;
60812
+ throw new TooManyRedirectsError();
60793
60813
  }
60794
60814
  var requestHeaders;
60795
60815
  var beforeRedirect = this._options.beforeRedirect;
@@ -60805,21 +60825,14 @@ var require_follow_redirects = __commonJS({
60805
60825
  removeMatchingHeaders(/^content-/i, this._options.headers);
60806
60826
  }
60807
60827
  var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
60808
- var currentUrlParts = url.parse(this._currentUrl);
60828
+ var currentUrlParts = parseUrl(this._currentUrl);
60809
60829
  var currentHost = currentHostHeader || currentUrlParts.host;
60810
60830
  var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url.format(Object.assign(currentUrlParts, { host: currentHost }));
60811
- var redirectUrl;
60812
- try {
60813
- redirectUrl = url.resolve(currentUrl, location);
60814
- } catch (cause) {
60815
- this.emit("error", new RedirectionError({ cause }));
60816
- return;
60817
- }
60818
- debug("redirecting to", redirectUrl);
60831
+ var redirectUrl = resolveUrl(location, currentUrl);
60832
+ debug("redirecting to", redirectUrl.href);
60819
60833
  this._isRedirect = true;
60820
- var redirectUrlParts = url.parse(redirectUrl);
60821
- Object.assign(this._options, redirectUrlParts);
60822
- if (redirectUrlParts.protocol !== currentUrlParts.protocol && redirectUrlParts.protocol !== "https:" || redirectUrlParts.host !== currentHost && !isSubdomain(redirectUrlParts.host, currentHost)) {
60834
+ spreadUrlObject(redirectUrl, this._options);
60835
+ if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) {
60823
60836
  removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
60824
60837
  }
60825
60838
  if (isFunction(beforeRedirect)) {
@@ -60832,19 +60845,10 @@ var require_follow_redirects = __commonJS({
60832
60845
  method,
60833
60846
  headers: requestHeaders
60834
60847
  };
60835
- try {
60836
- beforeRedirect(this._options, responseDetails, requestDetails);
60837
- } catch (err) {
60838
- this.emit("error", err);
60839
- return;
60840
- }
60848
+ beforeRedirect(this._options, responseDetails, requestDetails);
60841
60849
  this._sanitizeOptions(this._options);
60842
60850
  }
60843
- try {
60844
- this._performRequest();
60845
- } catch (cause) {
60846
- this.emit("error", new RedirectionError({ cause }));
60847
- }
60851
+ this._performRequest();
60848
60852
  };
60849
60853
  function wrap(protocols) {
60850
60854
  var exports2 = {
@@ -60857,22 +60861,13 @@ var require_follow_redirects = __commonJS({
60857
60861
  var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
60858
60862
  var wrappedProtocol = exports2[scheme] = Object.create(nativeProtocol);
60859
60863
  function request(input, options, callback) {
60860
- if (isString(input)) {
60861
- var parsed;
60862
- try {
60863
- parsed = urlToOptions(new URL2(input));
60864
- } catch (err) {
60865
- parsed = url.parse(input);
60866
- }
60867
- if (!isString(parsed.protocol)) {
60868
- throw new InvalidUrlError({ input });
60869
- }
60870
- input = parsed;
60871
- } else if (URL2 && input instanceof URL2) {
60872
- input = urlToOptions(input);
60864
+ if (isURL(input)) {
60865
+ input = spreadUrlObject(input);
60866
+ } else if (isString(input)) {
60867
+ input = spreadUrlObject(parseUrl(input));
60873
60868
  } else {
60874
60869
  callback = options;
60875
- options = input;
60870
+ options = validateUrl(input);
60876
60871
  input = { protocol };
60877
60872
  }
60878
60873
  if (isFunction(options)) {
@@ -60905,20 +60900,43 @@ var require_follow_redirects = __commonJS({
60905
60900
  }
60906
60901
  function noop() {
60907
60902
  }
60908
- function urlToOptions(urlObject) {
60909
- var options = {
60910
- protocol: urlObject.protocol,
60911
- hostname: urlObject.hostname.startsWith("[") ? urlObject.hostname.slice(1, -1) : urlObject.hostname,
60912
- hash: urlObject.hash,
60913
- search: urlObject.search,
60914
- pathname: urlObject.pathname,
60915
- path: urlObject.pathname + urlObject.search,
60916
- href: urlObject.href
60917
- };
60918
- if (urlObject.port !== "") {
60919
- options.port = Number(urlObject.port);
60903
+ function parseUrl(input) {
60904
+ var parsed;
60905
+ if (useNativeURL) {
60906
+ parsed = new URL2(input);
60907
+ } else {
60908
+ parsed = validateUrl(url.parse(input));
60909
+ if (!isString(parsed.protocol)) {
60910
+ throw new InvalidUrlError({ input });
60911
+ }
60920
60912
  }
60921
- return options;
60913
+ return parsed;
60914
+ }
60915
+ function resolveUrl(relative, base) {
60916
+ return useNativeURL ? new URL2(relative, base) : parseUrl(url.resolve(base, relative));
60917
+ }
60918
+ function validateUrl(input) {
60919
+ if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
60920
+ throw new InvalidUrlError({ input: input.href || input });
60921
+ }
60922
+ if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
60923
+ throw new InvalidUrlError({ input: input.href || input });
60924
+ }
60925
+ return input;
60926
+ }
60927
+ function spreadUrlObject(urlObject, target) {
60928
+ var spread = target || {};
60929
+ for (var key of preservedUrlFields) {
60930
+ spread[key] = urlObject[key];
60931
+ }
60932
+ if (spread.hostname.startsWith("[")) {
60933
+ spread.hostname = spread.hostname.slice(1, -1);
60934
+ }
60935
+ if (spread.port !== "") {
60936
+ spread.port = Number(spread.port);
60937
+ }
60938
+ spread.path = spread.search ? spread.pathname + spread.search : spread.pathname;
60939
+ return spread;
60922
60940
  }
60923
60941
  function removeMatchingHeaders(regex2, headers) {
60924
60942
  var lastValue;
@@ -60938,8 +60956,16 @@ var require_follow_redirects = __commonJS({
60938
60956
  this.message = this.cause ? message + ": " + this.cause.message : message;
60939
60957
  }
60940
60958
  CustomError.prototype = new (baseClass || Error)();
60941
- CustomError.prototype.constructor = CustomError;
60942
- CustomError.prototype.name = "Error [" + code + "]";
60959
+ Object.defineProperties(CustomError.prototype, {
60960
+ constructor: {
60961
+ value: CustomError,
60962
+ enumerable: false
60963
+ },
60964
+ name: {
60965
+ value: "Error [" + code + "]",
60966
+ enumerable: false
60967
+ }
60968
+ });
60943
60969
  return CustomError;
60944
60970
  }
60945
60971
  function destroyRequest(request, error) {
@@ -60963,6 +60989,9 @@ var require_follow_redirects = __commonJS({
60963
60989
  function isBuffer(value) {
60964
60990
  return typeof value === "object" && "length" in value;
60965
60991
  }
60992
+ function isURL(value) {
60993
+ return URL2 && value instanceof URL2;
60994
+ }
60966
60995
  module2.exports = wrap({ http, https });
60967
60996
  module2.exports.wrap = wrap;
60968
60997
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cli",
3
- "version": "1.5.0-beta.6446",
3
+ "version": "1.5.0-beta.6454",
4
4
  "description": "The standard CLI for creating and building a Piral instance or a Pilet.",
5
5
  "keywords": [
6
6
  "portal",
@@ -81,5 +81,5 @@
81
81
  "typescript": "^5.0.0",
82
82
  "yargs": "^15.0.0"
83
83
  },
84
- "gitHead": "9920a2eee24366aac7a52b779735f9e19820cef3"
84
+ "gitHead": "e38bc99bbc8c4287cf14ee07e890ee962ba58387"
85
85
  }