@nsshunt/stsfhirclient 2.0.34 → 2.0.36

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.
@@ -5513,6 +5513,12 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5513
5513
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
5514
5514
  /** @type {(value: string) => boolean} */
5515
5515
  var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
5516
+ /** @type {(value: string) => boolean} */
5517
+ var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
5518
+ /** @type {(value: string) => boolean} */
5519
+ var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
5520
+ /** @type {(value: string) => boolean} */
5521
+ var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
5516
5522
  /**
5517
5523
  * @param {Array<string>} input
5518
5524
  * @returns {string}
@@ -5735,19 +5741,103 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5735
5741
  return output.join("");
5736
5742
  }
5737
5743
  /**
5738
- * @param {import('../types/index').URIComponent} component
5739
- * @param {boolean} esc
5740
- * @returns {import('../types/index').URIComponent}
5744
+ * Re-escape RFC 3986 gen-delims that must not appear literally in the host.
5745
+ * After the URI regex parses, these characters cannot be literal in the host
5746
+ * field, so any that appear after decoding came from percent-encoding and
5747
+ * must be restored to prevent authority structure changes.
5748
+ *
5749
+ * @param {string} host
5750
+ * @param {boolean} isIP - true for IPv4/IPv6 hosts (skip colon re-escaping)
5751
+ * @returns {string}
5741
5752
  */
5742
- function normalizeComponentEncoding(component, esc) {
5743
- const func = esc !== true ? escape : unescape;
5744
- if (component.scheme !== void 0) component.scheme = func(component.scheme);
5745
- if (component.userinfo !== void 0) component.userinfo = func(component.userinfo);
5746
- if (component.host !== void 0) component.host = func(component.host);
5747
- if (component.path !== void 0) component.path = func(component.path);
5748
- if (component.query !== void 0) component.query = func(component.query);
5749
- if (component.fragment !== void 0) component.fragment = func(component.fragment);
5750
- return component;
5753
+ var HOST_DELIMS = {
5754
+ "@": "%40",
5755
+ "/": "%2F",
5756
+ "?": "%3F",
5757
+ "#": "%23",
5758
+ ":": "%3A"
5759
+ };
5760
+ var HOST_DELIM_RE = /[@/?#:]/g;
5761
+ var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
5762
+ function reescapeHostDelimiters(host, isIP) {
5763
+ const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
5764
+ re.lastIndex = 0;
5765
+ return host.replace(re, (ch) => HOST_DELIMS[ch]);
5766
+ }
5767
+ /**
5768
+ * Normalizes percent escapes and optionally decodes only unreserved ASCII bytes.
5769
+ * Reserved delimiters such as `%2F` and `%2E` stay escaped.
5770
+ *
5771
+ * @param {string} input
5772
+ * @param {boolean} [decodeUnreserved=false]
5773
+ * @returns {string}
5774
+ */
5775
+ function normalizePercentEncoding(input, decodeUnreserved = false) {
5776
+ if (input.indexOf("%") === -1) return input;
5777
+ let output = "";
5778
+ for (let i = 0; i < input.length; i++) {
5779
+ if (input[i] === "%" && i + 2 < input.length) {
5780
+ const hex = input.slice(i + 1, i + 3);
5781
+ if (isHexPair(hex)) {
5782
+ const normalizedHex = hex.toUpperCase();
5783
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
5784
+ if (decodeUnreserved && isUnreserved(decoded)) output += decoded;
5785
+ else output += "%" + normalizedHex;
5786
+ i += 2;
5787
+ continue;
5788
+ }
5789
+ }
5790
+ output += input[i];
5791
+ }
5792
+ return output;
5793
+ }
5794
+ /**
5795
+ * Normalizes path data without turning reserved escapes into live path syntax.
5796
+ * Valid escapes are uppercased, raw unsafe characters are escaped, and only
5797
+ * unreserved bytes that are not `.` are decoded.
5798
+ *
5799
+ * @param {string} input
5800
+ * @returns {string}
5801
+ */
5802
+ function normalizePathEncoding(input) {
5803
+ let output = "";
5804
+ for (let i = 0; i < input.length; i++) {
5805
+ if (input[i] === "%" && i + 2 < input.length) {
5806
+ const hex = input.slice(i + 1, i + 3);
5807
+ if (isHexPair(hex)) {
5808
+ const normalizedHex = hex.toUpperCase();
5809
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
5810
+ if (decoded !== "." && isUnreserved(decoded)) output += decoded;
5811
+ else output += "%" + normalizedHex;
5812
+ i += 2;
5813
+ continue;
5814
+ }
5815
+ }
5816
+ if (isPathCharacter(input[i])) output += input[i];
5817
+ else output += escape(input[i]);
5818
+ }
5819
+ return output;
5820
+ }
5821
+ /**
5822
+ * Escapes a component while preserving existing valid percent escapes.
5823
+ *
5824
+ * @param {string} input
5825
+ * @returns {string}
5826
+ */
5827
+ function escapePreservingEscapes(input) {
5828
+ let output = "";
5829
+ for (let i = 0; i < input.length; i++) {
5830
+ if (input[i] === "%" && i + 2 < input.length) {
5831
+ const hex = input.slice(i + 1, i + 3);
5832
+ if (isHexPair(hex)) {
5833
+ output += "%" + hex.toUpperCase();
5834
+ i += 2;
5835
+ continue;
5836
+ }
5837
+ }
5838
+ output += escape(input[i]);
5839
+ }
5840
+ return output;
5751
5841
  }
5752
5842
  /**
5753
5843
  * @param {import('../types/index').URIComponent} component
@@ -5764,7 +5854,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5764
5854
  if (!isIPv4(host)) {
5765
5855
  const ipV6res = normalizeIPv6(host);
5766
5856
  if (ipV6res.isIPV6 === true) host = `[${ipV6res.escapedHost}]`;
5767
- else host = component.host;
5857
+ else host = reescapeHostDelimiters(host, false);
5768
5858
  }
5769
5859
  uriTokens.push(host);
5770
5860
  }
@@ -5777,7 +5867,10 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5777
5867
  module.exports = {
5778
5868
  nonSimpleDomain,
5779
5869
  recomposeAuthority,
5780
- normalizeComponentEncoding,
5870
+ reescapeHostDelimiters,
5871
+ normalizePercentEncoding,
5872
+ normalizePathEncoding,
5873
+ escapePreservingEscapes,
5781
5874
  removeDotSegments,
5782
5875
  isIPv4,
5783
5876
  isUUID,
@@ -5971,7 +6064,7 @@ var require_schemes = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5971
6064
  //#endregion
5972
6065
  //#region node_modules/fast-uri/index.js
5973
6066
  var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5974
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
6067
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
5975
6068
  var { SCHEMES, getSchemeHandler } = require_schemes();
5976
6069
  /**
5977
6070
  * @template {import('./types/index').URIComponent|string} T
@@ -5980,7 +6073,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5980
6073
  * @returns {T}
5981
6074
  */
5982
6075
  function normalize(uri, options) {
5983
- if (typeof uri === "string") uri = serialize(parse(uri, options), options);
6076
+ if (typeof uri === "string") uri = normalizeString(uri, options);
5984
6077
  else if (typeof uri === "object") uri = parse(serialize(uri, options), options);
5985
6078
  return uri;
5986
6079
  }
@@ -6056,27 +6149,9 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6056
6149
  * @returns {boolean}
6057
6150
  */
6058
6151
  function equal(uriA, uriB, options) {
6059
- if (typeof uriA === "string") {
6060
- uriA = unescape(uriA);
6061
- uriA = serialize(normalizeComponentEncoding(parse(uriA, options), true), {
6062
- ...options,
6063
- skipEscape: true
6064
- });
6065
- } else if (typeof uriA === "object") uriA = serialize(normalizeComponentEncoding(uriA, true), {
6066
- ...options,
6067
- skipEscape: true
6068
- });
6069
- if (typeof uriB === "string") {
6070
- uriB = unescape(uriB);
6071
- uriB = serialize(normalizeComponentEncoding(parse(uriB, options), true), {
6072
- ...options,
6073
- skipEscape: true
6074
- });
6075
- } else if (typeof uriB === "object") uriB = serialize(normalizeComponentEncoding(uriB, true), {
6076
- ...options,
6077
- skipEscape: true
6078
- });
6079
- return uriA.toLowerCase() === uriB.toLowerCase();
6152
+ const normalizedA = normalizeComparableURI(uriA, options);
6153
+ const normalizedB = normalizeComparableURI(uriB, options);
6154
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
6080
6155
  }
6081
6156
  /**
6082
6157
  * @param {Readonly<import('./types/index').URIComponent>} cmpts
@@ -6105,9 +6180,9 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6105
6180
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
6106
6181
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
6107
6182
  if (component.path !== void 0) if (!options.skipEscape) {
6108
- component.path = escape(component.path);
6183
+ component.path = escapePreservingEscapes(component.path);
6109
6184
  if (component.scheme !== void 0) component.path = component.path.split("%3A").join(":");
6110
- } else component.path = unescape(component.path);
6185
+ } else component.path = normalizePercentEncoding(component.path);
6111
6186
  if (options.reference !== "suffix" && component.scheme) uriTokens.push(component.scheme, ":");
6112
6187
  const authority = recomposeAuthority(component);
6113
6188
  if (authority !== void 0) {
@@ -6127,11 +6202,20 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6127
6202
  }
6128
6203
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
6129
6204
  /**
6205
+ * @param {import('./types/index').URIComponent} parsed
6206
+ * @param {RegExpMatchArray} matches
6207
+ * @returns {string|undefined}
6208
+ */
6209
+ function getParseError(parsed, matches) {
6210
+ if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") return "URI path must start with \"/\" when authority is present.";
6211
+ if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) return "URI port is malformed.";
6212
+ }
6213
+ /**
6130
6214
  * @param {string} uri
6131
6215
  * @param {import('./types/index').Options} [opts]
6132
- * @returns
6216
+ * @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean }}
6133
6217
  */
6134
- function parse(uri, opts) {
6218
+ function parseWithStatus(uri, opts) {
6135
6219
  const options = Object.assign({}, opts);
6136
6220
  /** @type {import('./types/index').URIComponent} */
6137
6221
  const parsed = {
@@ -6143,6 +6227,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6143
6227
  query: void 0,
6144
6228
  fragment: void 0
6145
6229
  };
6230
+ let malformedAuthorityOrPort = false;
6146
6231
  let isIP = false;
6147
6232
  if (options.reference === "suffix") if (options.scheme) uri = options.scheme + ":" + uri;
6148
6233
  else uri = "//" + uri;
@@ -6156,6 +6241,11 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6156
6241
  parsed.query = matches[7];
6157
6242
  parsed.fragment = matches[8];
6158
6243
  if (isNaN(parsed.port)) parsed.port = matches[5];
6244
+ const parseError = getParseError(parsed, matches);
6245
+ if (parseError !== void 0) {
6246
+ parsed.error = parsed.error || parseError;
6247
+ malformedAuthorityOrPort = true;
6248
+ }
6159
6249
  if (parsed.host) if (isIPv4(parsed.host) === false) {
6160
6250
  const ipv6result = normalizeIPv6(parsed.host);
6161
6251
  parsed.host = ipv6result.host.toLowerCase();
@@ -6177,14 +6267,61 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6177
6267
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
6178
6268
  if (uri.indexOf("%") !== -1) {
6179
6269
  if (parsed.scheme !== void 0) parsed.scheme = unescape(parsed.scheme);
6180
- if (parsed.host !== void 0) parsed.host = unescape(parsed.host);
6270
+ if (parsed.host !== void 0) parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
6271
+ }
6272
+ if (parsed.path) parsed.path = normalizePathEncoding(parsed.path);
6273
+ if (parsed.fragment) try {
6274
+ parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
6275
+ } catch {
6276
+ parsed.error = parsed.error || "URI malformed";
6181
6277
  }
6182
- if (parsed.path) parsed.path = escape(unescape(parsed.path));
6183
- if (parsed.fragment) parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
6184
6278
  }
6185
6279
  if (schemeHandler && schemeHandler.parse) schemeHandler.parse(parsed, options);
6186
6280
  } else parsed.error = parsed.error || "URI can not be parsed.";
6187
- return parsed;
6281
+ return {
6282
+ parsed,
6283
+ malformedAuthorityOrPort
6284
+ };
6285
+ }
6286
+ /**
6287
+ * @param {string} uri
6288
+ * @param {import('./types/index').Options} [opts]
6289
+ * @returns
6290
+ */
6291
+ function parse(uri, opts) {
6292
+ return parseWithStatus(uri, opts).parsed;
6293
+ }
6294
+ /**
6295
+ * @param {string} uri
6296
+ * @param {import('./types/index').Options} [opts]
6297
+ * @returns {string}
6298
+ */
6299
+ function normalizeString(uri, opts) {
6300
+ return normalizeStringWithStatus(uri, opts).normalized;
6301
+ }
6302
+ /**
6303
+ * @param {string} uri
6304
+ * @param {import('./types/index').Options} [opts]
6305
+ * @returns {{ normalized: string, malformedAuthorityOrPort: boolean }}
6306
+ */
6307
+ function normalizeStringWithStatus(uri, opts) {
6308
+ const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
6309
+ return {
6310
+ normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
6311
+ malformedAuthorityOrPort
6312
+ };
6313
+ }
6314
+ /**
6315
+ * @param {import ('./types/index').URIComponent|string} uri
6316
+ * @param {import('./types/index').Options} [opts]
6317
+ * @returns {string|undefined}
6318
+ */
6319
+ function normalizeComparableURI(uri, opts) {
6320
+ if (typeof uri === "string") {
6321
+ const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
6322
+ return malformedAuthorityOrPort ? void 0 : normalized;
6323
+ }
6324
+ if (typeof uri === "object") return serialize(uri, opts);
6188
6325
  }
6189
6326
  var fastUri = {
6190
6327
  SCHEMES,