publish-microfrontend 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.
Files changed (2) hide show
  1. package/lib/index.js +87 -58
  2. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -24688,6 +24688,24 @@ var require_follow_redirects = __commonJS({
24688
24688
  var Writable2 = require("stream").Writable;
24689
24689
  var assert = require("assert");
24690
24690
  var debug = require_debug2();
24691
+ var useNativeURL = false;
24692
+ try {
24693
+ assert(new URL2());
24694
+ } catch (error) {
24695
+ useNativeURL = error.code === "ERR_INVALID_URL";
24696
+ }
24697
+ var preservedUrlFields = [
24698
+ "auth",
24699
+ "host",
24700
+ "hostname",
24701
+ "href",
24702
+ "path",
24703
+ "pathname",
24704
+ "port",
24705
+ "protocol",
24706
+ "query",
24707
+ "search"
24708
+ ];
24691
24709
  var events = ["abort", "aborted", "connect", "error", "socket", "timeout"];
24692
24710
  var eventHandlers = Object.create(null);
24693
24711
  events.forEach(function(event) {
@@ -24697,7 +24715,7 @@ var require_follow_redirects = __commonJS({
24697
24715
  });
24698
24716
  var InvalidUrlError = createErrorType("ERR_INVALID_URL", "Invalid URL", TypeError);
24699
24717
  var RedirectionError = createErrorType("ERR_FR_REDIRECTION_FAILURE", "Redirected request failed");
24700
- var TooManyRedirectsError = createErrorType("ERR_FR_TOO_MANY_REDIRECTS", "Maximum number of redirects exceeded");
24718
+ var TooManyRedirectsError = createErrorType("ERR_FR_TOO_MANY_REDIRECTS", "Maximum number of redirects exceeded", RedirectionError);
24701
24719
  var MaxBodyLengthExceededError = createErrorType("ERR_FR_MAX_BODY_LENGTH_EXCEEDED", "Request body larger than maxBodyLength limit");
24702
24720
  var WriteAfterEndError = createErrorType("ERR_STREAM_WRITE_AFTER_END", "write after end");
24703
24721
  var destroy = Writable2.prototype.destroy || noop2;
@@ -24716,7 +24734,11 @@ var require_follow_redirects = __commonJS({
24716
24734
  }
24717
24735
  var self2 = this;
24718
24736
  this._onNativeResponse = function(response) {
24719
- self2._processResponse(response);
24737
+ try {
24738
+ self2._processResponse(response);
24739
+ } catch (cause) {
24740
+ self2.emit("error", cause instanceof RedirectionError ? cause : new RedirectionError({ cause }));
24741
+ }
24720
24742
  };
24721
24743
  this._performRequest();
24722
24744
  }
@@ -24875,8 +24897,7 @@ var require_follow_redirects = __commonJS({
24875
24897
  var protocol = this._options.protocol;
24876
24898
  var nativeProtocol = this._options.nativeProtocols[protocol];
24877
24899
  if (!nativeProtocol) {
24878
- this.emit("error", new TypeError("Unsupported protocol " + protocol));
24879
- return;
24900
+ throw new TypeError("Unsupported protocol " + protocol);
24880
24901
  }
24881
24902
  if (this._options.agents) {
24882
24903
  var scheme = protocol.slice(0, -1);
@@ -24928,8 +24949,7 @@ var require_follow_redirects = __commonJS({
24928
24949
  destroyRequest(this._currentRequest);
24929
24950
  response.destroy();
24930
24951
  if (++this._redirectCount > this._options.maxRedirects) {
24931
- this.emit("error", new TooManyRedirectsError());
24932
- return;
24952
+ throw new TooManyRedirectsError();
24933
24953
  }
24934
24954
  var requestHeaders;
24935
24955
  var beforeRedirect = this._options.beforeRedirect;
@@ -24945,21 +24965,14 @@ var require_follow_redirects = __commonJS({
24945
24965
  removeMatchingHeaders(/^content-/i, this._options.headers);
24946
24966
  }
24947
24967
  var currentHostHeader = removeMatchingHeaders(/^host$/i, this._options.headers);
24948
- var currentUrlParts = url2.parse(this._currentUrl);
24968
+ var currentUrlParts = parseUrl(this._currentUrl);
24949
24969
  var currentHost = currentHostHeader || currentUrlParts.host;
24950
24970
  var currentUrl = /^\w+:/.test(location) ? this._currentUrl : url2.format(Object.assign(currentUrlParts, { host: currentHost }));
24951
- var redirectUrl;
24952
- try {
24953
- redirectUrl = url2.resolve(currentUrl, location);
24954
- } catch (cause) {
24955
- this.emit("error", new RedirectionError({ cause }));
24956
- return;
24957
- }
24958
- debug("redirecting to", redirectUrl);
24971
+ var redirectUrl = resolveUrl(location, currentUrl);
24972
+ debug("redirecting to", redirectUrl.href);
24959
24973
  this._isRedirect = true;
24960
- var redirectUrlParts = url2.parse(redirectUrl);
24961
- Object.assign(this._options, redirectUrlParts);
24962
- if (redirectUrlParts.protocol !== currentUrlParts.protocol && redirectUrlParts.protocol !== "https:" || redirectUrlParts.host !== currentHost && !isSubdomain(redirectUrlParts.host, currentHost)) {
24974
+ spreadUrlObject(redirectUrl, this._options);
24975
+ if (redirectUrl.protocol !== currentUrlParts.protocol && redirectUrl.protocol !== "https:" || redirectUrl.host !== currentHost && !isSubdomain(redirectUrl.host, currentHost)) {
24963
24976
  removeMatchingHeaders(/^(?:authorization|cookie)$/i, this._options.headers);
24964
24977
  }
24965
24978
  if (isFunction2(beforeRedirect)) {
@@ -24972,19 +24985,10 @@ var require_follow_redirects = __commonJS({
24972
24985
  method,
24973
24986
  headers: requestHeaders
24974
24987
  };
24975
- try {
24976
- beforeRedirect(this._options, responseDetails, requestDetails);
24977
- } catch (err) {
24978
- this.emit("error", err);
24979
- return;
24980
- }
24988
+ beforeRedirect(this._options, responseDetails, requestDetails);
24981
24989
  this._sanitizeOptions(this._options);
24982
24990
  }
24983
- try {
24984
- this._performRequest();
24985
- } catch (cause) {
24986
- this.emit("error", new RedirectionError({ cause }));
24987
- }
24991
+ this._performRequest();
24988
24992
  };
24989
24993
  function wrap(protocols) {
24990
24994
  var exports3 = {
@@ -24997,22 +25001,13 @@ var require_follow_redirects = __commonJS({
24997
25001
  var nativeProtocol = nativeProtocols[protocol] = protocols[scheme];
24998
25002
  var wrappedProtocol = exports3[scheme] = Object.create(nativeProtocol);
24999
25003
  function request(input, options, callback) {
25000
- if (isString2(input)) {
25001
- var parsed;
25002
- try {
25003
- parsed = urlToOptions(new URL2(input));
25004
- } catch (err) {
25005
- parsed = url2.parse(input);
25006
- }
25007
- if (!isString2(parsed.protocol)) {
25008
- throw new InvalidUrlError({ input });
25009
- }
25010
- input = parsed;
25011
- } else if (URL2 && input instanceof URL2) {
25012
- input = urlToOptions(input);
25004
+ if (isURL(input)) {
25005
+ input = spreadUrlObject(input);
25006
+ } else if (isString2(input)) {
25007
+ input = spreadUrlObject(parseUrl(input));
25013
25008
  } else {
25014
25009
  callback = options;
25015
- options = input;
25010
+ options = validateUrl(input);
25016
25011
  input = { protocol };
25017
25012
  }
25018
25013
  if (isFunction2(options)) {
@@ -25045,20 +25040,43 @@ var require_follow_redirects = __commonJS({
25045
25040
  }
25046
25041
  function noop2() {
25047
25042
  }
25048
- function urlToOptions(urlObject) {
25049
- var options = {
25050
- protocol: urlObject.protocol,
25051
- hostname: urlObject.hostname.startsWith("[") ? urlObject.hostname.slice(1, -1) : urlObject.hostname,
25052
- hash: urlObject.hash,
25053
- search: urlObject.search,
25054
- pathname: urlObject.pathname,
25055
- path: urlObject.pathname + urlObject.search,
25056
- href: urlObject.href
25057
- };
25058
- if (urlObject.port !== "") {
25059
- options.port = Number(urlObject.port);
25043
+ function parseUrl(input) {
25044
+ var parsed;
25045
+ if (useNativeURL) {
25046
+ parsed = new URL2(input);
25047
+ } else {
25048
+ parsed = validateUrl(url2.parse(input));
25049
+ if (!isString2(parsed.protocol)) {
25050
+ throw new InvalidUrlError({ input });
25051
+ }
25060
25052
  }
25061
- return options;
25053
+ return parsed;
25054
+ }
25055
+ function resolveUrl(relative, base) {
25056
+ return useNativeURL ? new URL2(relative, base) : parseUrl(url2.resolve(base, relative));
25057
+ }
25058
+ function validateUrl(input) {
25059
+ if (/^\[/.test(input.hostname) && !/^\[[:0-9a-f]+\]$/i.test(input.hostname)) {
25060
+ throw new InvalidUrlError({ input: input.href || input });
25061
+ }
25062
+ if (/^\[/.test(input.host) && !/^\[[:0-9a-f]+\](:\d+)?$/i.test(input.host)) {
25063
+ throw new InvalidUrlError({ input: input.href || input });
25064
+ }
25065
+ return input;
25066
+ }
25067
+ function spreadUrlObject(urlObject, target) {
25068
+ var spread2 = target || {};
25069
+ for (var key of preservedUrlFields) {
25070
+ spread2[key] = urlObject[key];
25071
+ }
25072
+ if (spread2.hostname.startsWith("[")) {
25073
+ spread2.hostname = spread2.hostname.slice(1, -1);
25074
+ }
25075
+ if (spread2.port !== "") {
25076
+ spread2.port = Number(spread2.port);
25077
+ }
25078
+ spread2.path = spread2.search ? spread2.pathname + spread2.search : spread2.pathname;
25079
+ return spread2;
25062
25080
  }
25063
25081
  function removeMatchingHeaders(regex2, headers) {
25064
25082
  var lastValue;
@@ -25078,8 +25096,16 @@ var require_follow_redirects = __commonJS({
25078
25096
  this.message = this.cause ? message + ": " + this.cause.message : message;
25079
25097
  }
25080
25098
  CustomError.prototype = new (baseClass || Error)();
25081
- CustomError.prototype.constructor = CustomError;
25082
- CustomError.prototype.name = "Error [" + code + "]";
25099
+ Object.defineProperties(CustomError.prototype, {
25100
+ constructor: {
25101
+ value: CustomError,
25102
+ enumerable: false
25103
+ },
25104
+ name: {
25105
+ value: "Error [" + code + "]",
25106
+ enumerable: false
25107
+ }
25108
+ });
25083
25109
  return CustomError;
25084
25110
  }
25085
25111
  function destroyRequest(request, error) {
@@ -25103,6 +25129,9 @@ var require_follow_redirects = __commonJS({
25103
25129
  function isBuffer2(value) {
25104
25130
  return typeof value === "object" && "length" in value;
25105
25131
  }
25132
+ function isURL(value) {
25133
+ return URL2 && value instanceof URL2;
25134
+ }
25106
25135
  module2.exports = wrap({ http: http2, https: https2 });
25107
25136
  module2.exports.wrap = wrap;
25108
25137
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "publish-microfrontend",
3
- "version": "1.5.0-beta.6446",
3
+ "version": "1.5.0-beta.6454",
4
4
  "description": "A CLI for publishing micro frontends to a feed service.",
5
5
  "keywords": [
6
6
  "modules",
@@ -69,5 +69,5 @@
69
69
  "typescript": "^5.0.0",
70
70
  "yargs": "^15.0.0"
71
71
  },
72
- "gitHead": "9920a2eee24366aac7a52b779735f9e19820cef3"
72
+ "gitHead": "e38bc99bbc8c4287cf14ee07e890ee962ba58387"
73
73
  }