@nsshunt/stsfhirclient 2.0.35 → 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.
@@ -5505,6 +5505,12 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5505
5505
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
5506
5506
  /** @type {(value: string) => boolean} */
5507
5507
  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);
5508
+ /** @type {(value: string) => boolean} */
5509
+ var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
5510
+ /** @type {(value: string) => boolean} */
5511
+ var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
5512
+ /** @type {(value: string) => boolean} */
5513
+ var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
5508
5514
  /**
5509
5515
  * @param {Array<string>} input
5510
5516
  * @returns {string}
@@ -5727,19 +5733,103 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5727
5733
  return output.join("");
5728
5734
  }
5729
5735
  /**
5730
- * @param {import('../types/index').URIComponent} component
5731
- * @param {boolean} esc
5732
- * @returns {import('../types/index').URIComponent}
5736
+ * Re-escape RFC 3986 gen-delims that must not appear literally in the host.
5737
+ * After the URI regex parses, these characters cannot be literal in the host
5738
+ * field, so any that appear after decoding came from percent-encoding and
5739
+ * must be restored to prevent authority structure changes.
5740
+ *
5741
+ * @param {string} host
5742
+ * @param {boolean} isIP - true for IPv4/IPv6 hosts (skip colon re-escaping)
5743
+ * @returns {string}
5733
5744
  */
5734
- function normalizeComponentEncoding(component, esc) {
5735
- const func = esc !== true ? escape : unescape;
5736
- if (component.scheme !== void 0) component.scheme = func(component.scheme);
5737
- if (component.userinfo !== void 0) component.userinfo = func(component.userinfo);
5738
- if (component.host !== void 0) component.host = func(component.host);
5739
- if (component.path !== void 0) component.path = func(component.path);
5740
- if (component.query !== void 0) component.query = func(component.query);
5741
- if (component.fragment !== void 0) component.fragment = func(component.fragment);
5742
- return component;
5745
+ var HOST_DELIMS = {
5746
+ "@": "%40",
5747
+ "/": "%2F",
5748
+ "?": "%3F",
5749
+ "#": "%23",
5750
+ ":": "%3A"
5751
+ };
5752
+ var HOST_DELIM_RE = /[@/?#:]/g;
5753
+ var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
5754
+ function reescapeHostDelimiters(host, isIP) {
5755
+ const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
5756
+ re.lastIndex = 0;
5757
+ return host.replace(re, (ch) => HOST_DELIMS[ch]);
5758
+ }
5759
+ /**
5760
+ * Normalizes percent escapes and optionally decodes only unreserved ASCII bytes.
5761
+ * Reserved delimiters such as `%2F` and `%2E` stay escaped.
5762
+ *
5763
+ * @param {string} input
5764
+ * @param {boolean} [decodeUnreserved=false]
5765
+ * @returns {string}
5766
+ */
5767
+ function normalizePercentEncoding(input, decodeUnreserved = false) {
5768
+ if (input.indexOf("%") === -1) return input;
5769
+ let output = "";
5770
+ for (let i = 0; i < input.length; i++) {
5771
+ if (input[i] === "%" && i + 2 < input.length) {
5772
+ const hex = input.slice(i + 1, i + 3);
5773
+ if (isHexPair(hex)) {
5774
+ const normalizedHex = hex.toUpperCase();
5775
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
5776
+ if (decodeUnreserved && isUnreserved(decoded)) output += decoded;
5777
+ else output += "%" + normalizedHex;
5778
+ i += 2;
5779
+ continue;
5780
+ }
5781
+ }
5782
+ output += input[i];
5783
+ }
5784
+ return output;
5785
+ }
5786
+ /**
5787
+ * Normalizes path data without turning reserved escapes into live path syntax.
5788
+ * Valid escapes are uppercased, raw unsafe characters are escaped, and only
5789
+ * unreserved bytes that are not `.` are decoded.
5790
+ *
5791
+ * @param {string} input
5792
+ * @returns {string}
5793
+ */
5794
+ function normalizePathEncoding(input) {
5795
+ let output = "";
5796
+ for (let i = 0; i < input.length; i++) {
5797
+ if (input[i] === "%" && i + 2 < input.length) {
5798
+ const hex = input.slice(i + 1, i + 3);
5799
+ if (isHexPair(hex)) {
5800
+ const normalizedHex = hex.toUpperCase();
5801
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
5802
+ if (decoded !== "." && isUnreserved(decoded)) output += decoded;
5803
+ else output += "%" + normalizedHex;
5804
+ i += 2;
5805
+ continue;
5806
+ }
5807
+ }
5808
+ if (isPathCharacter(input[i])) output += input[i];
5809
+ else output += escape(input[i]);
5810
+ }
5811
+ return output;
5812
+ }
5813
+ /**
5814
+ * Escapes a component while preserving existing valid percent escapes.
5815
+ *
5816
+ * @param {string} input
5817
+ * @returns {string}
5818
+ */
5819
+ function escapePreservingEscapes(input) {
5820
+ let output = "";
5821
+ for (let i = 0; i < input.length; i++) {
5822
+ if (input[i] === "%" && i + 2 < input.length) {
5823
+ const hex = input.slice(i + 1, i + 3);
5824
+ if (isHexPair(hex)) {
5825
+ output += "%" + hex.toUpperCase();
5826
+ i += 2;
5827
+ continue;
5828
+ }
5829
+ }
5830
+ output += escape(input[i]);
5831
+ }
5832
+ return output;
5743
5833
  }
5744
5834
  /**
5745
5835
  * @param {import('../types/index').URIComponent} component
@@ -5756,7 +5846,7 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5756
5846
  if (!isIPv4(host)) {
5757
5847
  const ipV6res = normalizeIPv6(host);
5758
5848
  if (ipV6res.isIPV6 === true) host = `[${ipV6res.escapedHost}]`;
5759
- else host = component.host;
5849
+ else host = reescapeHostDelimiters(host, false);
5760
5850
  }
5761
5851
  uriTokens.push(host);
5762
5852
  }
@@ -5769,7 +5859,10 @@ var require_utils = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5769
5859
  module.exports = {
5770
5860
  nonSimpleDomain,
5771
5861
  recomposeAuthority,
5772
- normalizeComponentEncoding,
5862
+ reescapeHostDelimiters,
5863
+ normalizePercentEncoding,
5864
+ normalizePathEncoding,
5865
+ escapePreservingEscapes,
5773
5866
  removeDotSegments,
5774
5867
  isIPv4,
5775
5868
  isUUID,
@@ -5963,7 +6056,7 @@ var require_schemes = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5963
6056
  //#endregion
5964
6057
  //#region node_modules/fast-uri/index.js
5965
6058
  var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5966
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
6059
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
5967
6060
  var { SCHEMES, getSchemeHandler } = require_schemes();
5968
6061
  /**
5969
6062
  * @template {import('./types/index').URIComponent|string} T
@@ -5972,7 +6065,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
5972
6065
  * @returns {T}
5973
6066
  */
5974
6067
  function normalize(uri, options) {
5975
- if (typeof uri === "string") uri = serialize(parse(uri, options), options);
6068
+ if (typeof uri === "string") uri = normalizeString(uri, options);
5976
6069
  else if (typeof uri === "object") uri = parse(serialize(uri, options), options);
5977
6070
  return uri;
5978
6071
  }
@@ -6048,27 +6141,9 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6048
6141
  * @returns {boolean}
6049
6142
  */
6050
6143
  function equal(uriA, uriB, options) {
6051
- if (typeof uriA === "string") {
6052
- uriA = unescape(uriA);
6053
- uriA = serialize(normalizeComponentEncoding(parse(uriA, options), true), {
6054
- ...options,
6055
- skipEscape: true
6056
- });
6057
- } else if (typeof uriA === "object") uriA = serialize(normalizeComponentEncoding(uriA, true), {
6058
- ...options,
6059
- skipEscape: true
6060
- });
6061
- if (typeof uriB === "string") {
6062
- uriB = unescape(uriB);
6063
- uriB = serialize(normalizeComponentEncoding(parse(uriB, options), true), {
6064
- ...options,
6065
- skipEscape: true
6066
- });
6067
- } else if (typeof uriB === "object") uriB = serialize(normalizeComponentEncoding(uriB, true), {
6068
- ...options,
6069
- skipEscape: true
6070
- });
6071
- return uriA.toLowerCase() === uriB.toLowerCase();
6144
+ const normalizedA = normalizeComparableURI(uriA, options);
6145
+ const normalizedB = normalizeComparableURI(uriB, options);
6146
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
6072
6147
  }
6073
6148
  /**
6074
6149
  * @param {Readonly<import('./types/index').URIComponent>} cmpts
@@ -6097,9 +6172,9 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6097
6172
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
6098
6173
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
6099
6174
  if (component.path !== void 0) if (!options.skipEscape) {
6100
- component.path = escape(component.path);
6175
+ component.path = escapePreservingEscapes(component.path);
6101
6176
  if (component.scheme !== void 0) component.path = component.path.split("%3A").join(":");
6102
- } else component.path = unescape(component.path);
6177
+ } else component.path = normalizePercentEncoding(component.path);
6103
6178
  if (options.reference !== "suffix" && component.scheme) uriTokens.push(component.scheme, ":");
6104
6179
  const authority = recomposeAuthority(component);
6105
6180
  if (authority !== void 0) {
@@ -6119,11 +6194,20 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6119
6194
  }
6120
6195
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
6121
6196
  /**
6197
+ * @param {import('./types/index').URIComponent} parsed
6198
+ * @param {RegExpMatchArray} matches
6199
+ * @returns {string|undefined}
6200
+ */
6201
+ function getParseError(parsed, matches) {
6202
+ if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") return "URI path must start with \"/\" when authority is present.";
6203
+ if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) return "URI port is malformed.";
6204
+ }
6205
+ /**
6122
6206
  * @param {string} uri
6123
6207
  * @param {import('./types/index').Options} [opts]
6124
- * @returns
6208
+ * @returns {{ parsed: import('./types/index').URIComponent, malformedAuthorityOrPort: boolean }}
6125
6209
  */
6126
- function parse(uri, opts) {
6210
+ function parseWithStatus(uri, opts) {
6127
6211
  const options = Object.assign({}, opts);
6128
6212
  /** @type {import('./types/index').URIComponent} */
6129
6213
  const parsed = {
@@ -6135,6 +6219,7 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6135
6219
  query: void 0,
6136
6220
  fragment: void 0
6137
6221
  };
6222
+ let malformedAuthorityOrPort = false;
6138
6223
  let isIP = false;
6139
6224
  if (options.reference === "suffix") if (options.scheme) uri = options.scheme + ":" + uri;
6140
6225
  else uri = "//" + uri;
@@ -6148,6 +6233,11 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6148
6233
  parsed.query = matches[7];
6149
6234
  parsed.fragment = matches[8];
6150
6235
  if (isNaN(parsed.port)) parsed.port = matches[5];
6236
+ const parseError = getParseError(parsed, matches);
6237
+ if (parseError !== void 0) {
6238
+ parsed.error = parsed.error || parseError;
6239
+ malformedAuthorityOrPort = true;
6240
+ }
6151
6241
  if (parsed.host) if (isIPv4(parsed.host) === false) {
6152
6242
  const ipv6result = normalizeIPv6(parsed.host);
6153
6243
  parsed.host = ipv6result.host.toLowerCase();
@@ -6169,14 +6259,61 @@ var require_fast_uri = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
6169
6259
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
6170
6260
  if (uri.indexOf("%") !== -1) {
6171
6261
  if (parsed.scheme !== void 0) parsed.scheme = unescape(parsed.scheme);
6172
- if (parsed.host !== void 0) parsed.host = unescape(parsed.host);
6262
+ if (parsed.host !== void 0) parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
6263
+ }
6264
+ if (parsed.path) parsed.path = normalizePathEncoding(parsed.path);
6265
+ if (parsed.fragment) try {
6266
+ parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
6267
+ } catch {
6268
+ parsed.error = parsed.error || "URI malformed";
6173
6269
  }
6174
- if (parsed.path) parsed.path = escape(unescape(parsed.path));
6175
- if (parsed.fragment) parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
6176
6270
  }
6177
6271
  if (schemeHandler && schemeHandler.parse) schemeHandler.parse(parsed, options);
6178
6272
  } else parsed.error = parsed.error || "URI can not be parsed.";
6179
- return parsed;
6273
+ return {
6274
+ parsed,
6275
+ malformedAuthorityOrPort
6276
+ };
6277
+ }
6278
+ /**
6279
+ * @param {string} uri
6280
+ * @param {import('./types/index').Options} [opts]
6281
+ * @returns
6282
+ */
6283
+ function parse(uri, opts) {
6284
+ return parseWithStatus(uri, opts).parsed;
6285
+ }
6286
+ /**
6287
+ * @param {string} uri
6288
+ * @param {import('./types/index').Options} [opts]
6289
+ * @returns {string}
6290
+ */
6291
+ function normalizeString(uri, opts) {
6292
+ return normalizeStringWithStatus(uri, opts).normalized;
6293
+ }
6294
+ /**
6295
+ * @param {string} uri
6296
+ * @param {import('./types/index').Options} [opts]
6297
+ * @returns {{ normalized: string, malformedAuthorityOrPort: boolean }}
6298
+ */
6299
+ function normalizeStringWithStatus(uri, opts) {
6300
+ const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
6301
+ return {
6302
+ normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
6303
+ malformedAuthorityOrPort
6304
+ };
6305
+ }
6306
+ /**
6307
+ * @param {import ('./types/index').URIComponent|string} uri
6308
+ * @param {import('./types/index').Options} [opts]
6309
+ * @returns {string|undefined}
6310
+ */
6311
+ function normalizeComparableURI(uri, opts) {
6312
+ if (typeof uri === "string") {
6313
+ const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
6314
+ return malformedAuthorityOrPort ? void 0 : normalized;
6315
+ }
6316
+ if (typeof uri === "object") return serialize(uri, opts);
6180
6317
  }
6181
6318
  var fastUri = {
6182
6319
  SCHEMES,